omlink.js 922 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * Main Javascript file
  3. *
  4. * @author Open Mind
  5. * @date 27/06/2018
  6. * @time 17:42
  7. */
  8. $(function () {
  9. var ws = new WebSocket('ws://localhost:80');
  10. ws.onopen = function () {
  11. console.log('websocket connection stabilita...')
  12. ws.send('hello')
  13. }
  14. ws.onmessage = function (message) {
  15. console.log('Messaggio ricevuto :',message);
  16. }
  17. $('form').on('submit', function () {
  18. $('form input,select').prop('disabled', false);
  19. setTimeout(function () {
  20. $('form input,select').prop('disabled', true);
  21. }, 500);
  22. });
  23. setInterval(() => {
  24. fetch('/omlink/getserverstatus')
  25. .then(resp => {
  26. if (resp.status == 200)
  27. return resp.json();
  28. else
  29. return Promise.reject("getserverstatus: error");
  30. })
  31. .then(data => {
  32. $('#sysmsgnum').html(data.notify);
  33. })
  34. .catch(err => {
  35. console.log(err);
  36. });
  37. }, 5000);
  38. });