frame_data.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. function showDocument(fr = "") {
  2. if(fr != ""){
  3. $.ajax({
  4. type: "GET",
  5. url: 'https://centurio.work/out/frames/' + fr + '/dataelements.json',
  6. success: function(ret) {
  7. $("#alldata").text(JSON.stringify(ret["ausfuehrungen"]));
  8. },
  9. error: function() {
  10. reason = '';
  11. clearDocument();
  12. }
  13. });
  14. }
  15. }
  16. function clearDocument() {
  17. console.log('rrrr');
  18. }
  19. function init() {
  20. es = new EventSource('handler/sse/');
  21. es.onopen = function() {
  22. showDocument("FormTest");
  23. // load
  24. };
  25. es.onmessage = function(e) {
  26. if (e.data == 'new') {
  27. reason = '';
  28. showDocument();
  29. }
  30. if (e.data == 'reset') {
  31. reason = '';
  32. showDocument();
  33. }
  34. else{
  35. if(e.data != "keepalive" && e.data != "started"){
  36. try {
  37. showDocument(e.data);
  38. }
  39. catch (e) {
  40. }
  41. }
  42. }
  43. };
  44. es.onerror = function() {
  45. reason = 'Server down.';
  46. clearDocument();
  47. setTimeout(init, 10000);
  48. };
  49. }
  50. $(document).ready(function() {
  51. init();
  52. });