Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. var sess = wialon.core.Session.getInstance(); // get instance of current Session
  2. // flags to specify what kind of data should be returned
  3. var flags = wialon.item.Item.dataFlag.base | wialon.item.Unit.dataFlag.lastMessage | wialon.item.Unit.dataFlag.restricted;
  4. sess.updateDataFlags(// load items to current session
  5. [{type: "type", data: "avl_unit", flags: flags, mode: 0}], // Items specification
  6. function (code) { // updateDataFlags callback
  7. if (code) {
  8. msg(wialon.core.Errors.getErrorText(code));
  9. return;
  10. } // exit if error code
  11. // append option to select
  12. var info = wialon.core.Session.getInstance().getItem("<?php echo $id; ?>"); // get unit by id
  13. var pos = info.getPosition();
  14. var uniqueid = info.getUniqueId();
  15. var phonenumber = info.getPhoneNumber();
  16. var time = wialon.util.DateTime.formatTime(pos.t);
  17. var now = new Date(); // Conseguimos los datos de Ahora
  18. var nowyear = now.getYear();
  19. var nowmonth = now.getMonth();
  20. var nowday = now.getDay(); // Que dia estamos
  21. var nowhour = now.getHours(); // Hora actual
  22. var nowminute = now.getMinutes(); // Minuto actual
  23. var nowsecond = now.getSeconds(); // Segundo actual
  24. var tiempo1 = new Date(nowyear, nowmonth, nowday, 0, 0, 0, 0);
  25. var tiempo2 = new Date(nowyear, nowmonth, nowday, nowhour, nowminute, nowsecond, 0);
  26. var dif = tiempo1.getTime() - tiempo2.getTime();
  27.  
  28. var Segundos_de_T1_a_T2 = dif / 1000;
  29. var Segundos_entre_fechas = Math.abs(Segundos_de_T1_a_T2);
  30. $("#unitlist").append("<p>P " + info.getName() + " " + phonenumber + " " + uniqueid + " " + "<?php echo $id; ?>" + " "+ Segundos_entre_fechas +" " + pos.x + " " + pos.y + " " + pos.s + "</p>");
  31.  
  32. }
  33. );
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement