tabs.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <html>
  2. <head>
  3. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  4. <style>
  5. * {box-sizing: border-box}
  6. body {font-family: "Lato", sans-serif;}
  7. .tab button {
  8. display: block;
  9. background-color: inherit;
  10. color: black;
  11. padding: 22px 16px;
  12. width: 100%;
  13. border: none;
  14. outline: none;
  15. text-align: left;
  16. cursor: pointer;
  17. transition: 0.3s;
  18. font-size: 17px;
  19. }
  20. .but {
  21. background-color: #33CCFF;
  22. color: black;
  23. padding: 5px 10px;
  24. text-align: center;
  25. display: inline-block;
  26. font-size: 15px;
  27. margin: 10px 40px;
  28. cursor: pointer;
  29. text-decoration:none;
  30. border-radius:10px;
  31. padding: 10px 30px;
  32. }
  33. a:hover {
  34. background-color: #003399;
  35. }
  36. a:focus {
  37. background-color: #003399;
  38. }
  39. </style>
  40. <h2>Tasks</h2>
  41. <div id='mylist'><div id='cont'></div></div>
  42. <script type="text/javascript" >
  43. var linkList = "";
  44. var role = "MAB"; ///read from smth
  45. var elem = document.getElementById("cont");
  46. $.ajax({
  47. url: '../callbacks/DTC_EVENT.txt',
  48. async: false,
  49. success: function (data){
  50. linkList = data;
  51. }
  52. });
  53. var workerID = window.parent.workerID;
  54. linkList = JSON.parse(linkList);
  55. createList(elem,linkList, role);
  56. /*
  57. //SSE
  58. let eventSource = new EventSource('sse_events.php');
  59. eventSource.addEventListener("message", function(event) {
  60. let data = JSON.parse(event.data);
  61. console.log(data);
  62. var elem = document.getElementById("cont");
  63. elem.parentElement.removeChild(elem);
  64. var innerDiv = document.createElement('div');
  65. innerDiv.id = 'cont';
  66. document.getElementById('mylist').appendChild(innerDiv);
  67. createList(innerDiv,data,role);
  68. });
  69. */
  70. function createList(elem,linkList, role){
  71. var mydiv = "";
  72. for (var i = 0; i < linkList.length; i++) {
  73. if (linkList[i]['role'] == role) {
  74. var myLink = linkList[i]['form'] + "?cbid=" + linkList[i]['cbid'] + "&workerID=" + workerID;
  75. mydiv += "<li><a class=\"but\" href="+ myLink +" target=\"mainFrame\" >" + linkList[i]['task']+ "</a></li>";
  76. }
  77. }
  78. elem.insertAdjacentHTML( 'beforeend', mydiv );
  79. }
  80. </script>
  81. </head>
  82. </html>