common.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. var basepath = "http://192.168.178.22";
  2. function LoadHostname() {
  3. _basepath = getbasepath();
  4. var xhttp = new XMLHttpRequest();
  5. xhttp.addEventListener('load', function(event) {
  6. if (xhttp.status >= 200 && xhttp.status < 300) {
  7. hostname = xhttp.responseText;
  8. document.title = hostname + " - AI on the edge";
  9. document.getElementById("id_title").innerHTML = "Digitizer - AI on the edge - " + hostname;
  10. }
  11. else {
  12. console.warn(request.statusText, request.responseText);
  13. }
  14. });
  15. // var xhttp = new XMLHttpRequest();
  16. try {
  17. url = _basepath + '/info?type=Hostname';
  18. xhttp.open("GET", url, true);
  19. xhttp.send();
  20. }
  21. catch (error)
  22. {
  23. // alert("Loading Hostname failed");
  24. }
  25. }
  26. var fwVersion = "";
  27. var webUiVersion = "";
  28. function LoadFwVersion() {
  29. _basepath = getbasepath();
  30. var xhttp = new XMLHttpRequest();
  31. xhttp.addEventListener('load', function(event) {
  32. if (xhttp.status >= 200 && xhttp.status < 300) {
  33. fwVersion = xhttp.responseText;
  34. document.getElementById("Version").innerHTML = fwVersion;
  35. console.log(fwVersion);
  36. compareVersions();
  37. }
  38. else {
  39. console.warn(request.statusText, request.responseText);
  40. fwVersion = "NaN";
  41. }
  42. });
  43. try {
  44. url = _basepath + '/info?type=FirmwareVersion';
  45. xhttp.open("GET", url, true);
  46. xhttp.send();
  47. }
  48. catch (error) {
  49. fwVersion = "NaN";
  50. }
  51. }
  52. function LoadWebUiVersion() {
  53. _basepath = getbasepath();
  54. var xhttp = new XMLHttpRequest();
  55. xhttp.addEventListener('load', function(event) {
  56. if (xhttp.status >= 200 && xhttp.status < 300) {
  57. webUiVersion = xhttp.responseText;
  58. console.log("Web UI Version: " + webUiVersion);
  59. compareVersions();
  60. }
  61. else {
  62. console.warn(request.statusText, request.responseText);
  63. webUiVersion = "NaN";
  64. }
  65. });
  66. try {
  67. url = _basepath + '/info?type=HTMLVersion';
  68. xhttp.open("GET", url, true);
  69. xhttp.send();
  70. }
  71. catch (error) {
  72. webUiVersion = "NaN";
  73. }
  74. }
  75. function compareVersions() {
  76. if (fwVersion == "" || webUiVersion == "") {
  77. return;
  78. }
  79. arr = fwVersion.split(" ");
  80. fWGitHash = arr[arr.length - 1].substring(0, 7);
  81. arr = webUiVersion.split(" ");
  82. webUiHash = arr[arr.length - 1].substring(0, 7);
  83. console.log("FW Hash: " + fWGitHash + ", Web UI Hash: " + webUiHash);
  84. if (fWGitHash != webUiHash) {
  85. alert("The Version of the Web Interface (" + webUiHash + ") does not match the Firmware Version (" + fWGitHash + ")! It is suggested to keep them on the same version!");
  86. }
  87. }