frame_data.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. }
  18. function init() {
  19. es = new EventSource('handler/sse/');
  20. es.onopen = function() {
  21. showDocument("FormTest");
  22. // load
  23. };
  24. es.onmessage = function(e) {
  25. if (e.data == 'new') {
  26. reason = '';
  27. showDocument();
  28. }
  29. if (e.data == 'reset') {
  30. reason = '';
  31. showDocument();
  32. }
  33. else{
  34. if(e.data != "keepalive" && e.data != "started"){
  35. try {
  36. showDocument(e.data);
  37. }
  38. catch (e) {
  39. }
  40. }
  41. }
  42. };
  43. es.onerror = function() {
  44. reason = 'Server down.';
  45. clearDocument();
  46. setTimeout(init, 10000);
  47. };
  48. }
  49. $(document).ready(function() {
  50. init();
  51. });