Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. <?php
  2. class JardinController extends AppController {
  3.  
  4. public function index() {
  5.  
  6. }
  7.  
  8. // retornar X Y para la grafica
  9. // 5d896075f2a3a7fc14643def
  10. public function get_xy($id = "5d896075f2a3a7fc14643def") {
  11. $Jardin = new Jardin();
  12. $jardin = $Jardin->get_one($id);
  13.  
  14. View::json($jardin);
  15. }
  16.  
  17. public function set_xy($id = "5d896075f2a3a7fc14643def") {
  18. $Jardin = new Jardin();
  19. $jardin = $Jardin->get_one($id);
  20.  
  21. $arreglo = $jardin;
  22.  
  23. $jardin["intruso"]["x"] = 123;
  24. $jardin["intruso"]["y"] = 345;
  25.  
  26. $jardin = $Jardin->actualizar($id, $jardin);
  27.  
  28. View::json($jardin);
  29. }
  30.  
  31. /**
  32. * Establece el idioma del jardin
  33. *
  34. * @param type $idioma 'es'
  35. */
  36. public function set_lang($id, $idioma) {
  37. $Jardin = new Jardin();
  38. $jardin = $Jardin->get_one($id);
  39.  
  40. $jardin["lang"] = $idioma;
  41.  
  42. $jardin = $Jardin->actualizar($id, $jardin);
  43.  
  44. View::json($jardin);
  45. }
  46.  
  47. public function get_idiomas() {
  48. $Idiomas = new Idiomas();
  49.  
  50.  
  51. $attr["fecha"] = date("h:i:s");
  52. $IdiomaZ = new Idiomas();
  53. $IdiomaZ->save($attr);
  54.  
  55. $idiomas = $Idiomas->findOne("5d8eaaa0c2773e2caa87d4e1");
  56. // $idiomas->update($attr);
  57. $idiomas = $Idiomas->findOne("5d8eaaa0c2773e2caa87d4e1");
  58.  
  59. View::json($IdiomaZ->attrs);
  60. }
  61.  
  62. }
  63.  
  64. ?>
  65.  
  66. <?php Tag::css('jardin') ?>
  67. <?= Html::includeCss() ?>
  68.  
  69. <h1>Jardin</h1>
  70.  
  71. <div id="app_jardin">
  72. <div id="jardin">
  73. <div id="intruso"></div>
  74. </div>
  75.  
  76. <div>
  77. <div v-for="i in idiomas">
  78. <img v-bind:src="'/kumbiaphpiot/banderas/' + i + '.jpg'">
  79. </div>
  80. </div>
  81.  
  82. </div>
  83.  
  84. <script>
  85. var app_jardin = new Vue({
  86. el: '#app_jardin',
  87. data: {
  88. xy: {},
  89. x: 0,
  90. y: 0,
  91. idiomas: {}
  92. },
  93. methods: {
  94. // Solita las coordenadas
  95. get_xy: function () {
  96. este = this;
  97. axios.get('/kumbiaphpiot/jardin/get_xy/5d896075f2a3a7fc14643def').then(function (response) {
  98. este.dispositivos = response.data;
  99. este.x = response.data.intruso.x;
  100. este.y = response.data.intruso.y;
  101. // cada cierto tiempo se manda llamar a si mism
  102. document.getElementById("intruso").style.marginLeft = este.x + "px";
  103. document.getElementById("intruso").style.marginTop = este.y + "px";
  104. setTimeout(function () {
  105. app_jardin.get_xy();
  106. }, 1000);
  107. });
  108. },
  109. get_idiomas: function () {
  110. este = this;
  111. axios.get('/kumbiaphpiot/jardin/get_idiomas').then(function (response) {
  112. este.idiomas = response.data;
  113. });
  114. }
  115. },
  116. mounted: function () {
  117. this.get_xy();
  118. this.get_idiomas();
  119. }
  120. });
  121. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement