Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class JardinController extends AppController {
- public function index() {
- }
- // retornar X Y para la grafica
- // 5d896075f2a3a7fc14643def
- public function get_xy($id = "5d896075f2a3a7fc14643def") {
- $Jardin = new Jardin();
- $jardin = $Jardin->get_one($id);
- View::json($jardin);
- }
- public function set_xy($id = "5d896075f2a3a7fc14643def") {
- $Jardin = new Jardin();
- $jardin = $Jardin->get_one($id);
- $arreglo = $jardin;
- $jardin["intruso"]["x"] = 123;
- $jardin["intruso"]["y"] = 345;
- $jardin = $Jardin->actualizar($id, $jardin);
- View::json($jardin);
- }
- /**
- * Establece el idioma del jardin
- *
- * @param type $idioma 'es'
- */
- public function set_lang($id, $idioma) {
- $Jardin = new Jardin();
- $jardin = $Jardin->get_one($id);
- $jardin["lang"] = $idioma;
- $jardin = $Jardin->actualizar($id, $jardin);
- View::json($jardin);
- }
- public function get_idiomas() {
- $Idiomas = new Idiomas();
- $attr["fecha"] = date("h:i:s");
- $IdiomaZ = new Idiomas();
- $IdiomaZ->save($attr);
- $idiomas = $Idiomas->findOne("5d8eaaa0c2773e2caa87d4e1");
- // $idiomas->update($attr);
- $idiomas = $Idiomas->findOne("5d8eaaa0c2773e2caa87d4e1");
- View::json($IdiomaZ->attrs);
- }
- }
- ?>
- <?php Tag::css('jardin') ?>
- <?= Html::includeCss() ?>
- <h1>Jardin</h1>
- <div id="app_jardin">
- <div id="jardin">
- <div id="intruso"></div>
- </div>
- <div>
- <div v-for="i in idiomas">
- <img v-bind:src="'/kumbiaphpiot/banderas/' + i + '.jpg'">
- </div>
- </div>
- </div>
- <script>
- var app_jardin = new Vue({
- el: '#app_jardin',
- data: {
- xy: {},
- x: 0,
- y: 0,
- idiomas: {}
- },
- methods: {
- // Solita las coordenadas
- get_xy: function () {
- este = this;
- axios.get('/kumbiaphpiot/jardin/get_xy/5d896075f2a3a7fc14643def').then(function (response) {
- este.dispositivos = response.data;
- este.x = response.data.intruso.x;
- este.y = response.data.intruso.y;
- // cada cierto tiempo se manda llamar a si mism
- document.getElementById("intruso").style.marginLeft = este.x + "px";
- document.getElementById("intruso").style.marginTop = este.y + "px";
- setTimeout(function () {
- app_jardin.get_xy();
- }, 1000);
- });
- },
- get_idiomas: function () {
- este = this;
- axios.get('/kumbiaphpiot/jardin/get_idiomas').then(function (response) {
- este.idiomas = response.data;
- });
- }
- },
- mounted: function () {
- this.get_xy();
- this.get_idiomas();
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement