12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <html>
- <head>
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
- <style>
- * {box-sizing: border-box}
- body {font-family: "Lato", sans-serif;}
- .tab button {
- display: block;
- background-color: inherit;
- color: black;
- padding: 22px 16px;
- width: 100%;
- border: none;
- outline: none;
- text-align: left;
- cursor: pointer;
- transition: 0.3s;
- font-size: 17px;
- }
- .but {
- background-color: #33CCFF;
- color: black;
- padding: 5px 10px;
- text-align: center;
- display: inline-block;
- font-size: 15px;
- margin: 10px 40px;
- cursor: pointer;
- text-decoration:none;
- border-radius:10px;
- padding: 10px 30px;
- }
- a:hover {
- background-color: #003399;
- }
- a:focus {
- background-color: #003399;
- }
- </style>
- <h2>Tasks</h2>
- <div id='mylist'><div id='cont'></div></div>
- <script type="text/javascript" >
- var linkList = "";
- var role = "MAB"; ///read from smth
- var elem = document.getElementById("cont");
- $.ajax({
- url: '../callbacks/DTC_EVENT.txt',
- async: false,
- success: function (data){
- linkList = data;
- }
- });
- var workerID = window.parent.workerID;
- linkList = JSON.parse(linkList);
- createList(elem,linkList, role);
- /*
- //SSE
- let eventSource = new EventSource('sse_events.php');
- eventSource.addEventListener("message", function(event) {
- let data = JSON.parse(event.data);
- console.log(data);
- var elem = document.getElementById("cont");
- elem.parentElement.removeChild(elem);
- var innerDiv = document.createElement('div');
- innerDiv.id = 'cont';
- document.getElementById('mylist').appendChild(innerDiv);
- createList(innerDiv,data,role);
- });
- */
- function createList(elem,linkList, role){
- var mydiv = "";
- for (var i = 0; i < linkList.length; i++) {
- if (linkList[i]['role'] == role) {
- var myLink = linkList[i]['form'] + "?cbid=" + linkList[i]['cbid'] + "&workerID=" + workerID;
- mydiv += "<li><a class=\"but\" href="+ myLink +" target=\"mainFrame\" >" + linkList[i]['task']+ "</a></li>";
- }
- }
- elem.insertAdjacentHTML( 'beforeend', mydiv );
- }
- </script>
- </head>
- </html>
|