| 
									
										
										
										
											2020-07-25 22:07:35 -04:00
										 |  |  | const adjustTableHeight = () => { | 
					
						
							|  |  |  |     const tablesContainer = document.getElementById('tables-container'); | 
					
						
							|  |  |  |     const upperDistance = tablesContainer.getBoundingClientRect().top; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const containerHeight = window.innerHeight - upperDistance; | 
					
						
							|  |  |  |     tablesContainer.style.maxHeight = `calc(${containerHeight}px - 1rem)`; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const tableWrappers = document.getElementsByClassName('table-wrapper'); | 
					
						
							|  |  |  |     for(let i=0; i < tableWrappers.length; i++){ | 
					
						
							|  |  |  |         const maxHeight = (window.innerHeight - upperDistance) / 2; | 
					
						
							|  |  |  |         tableWrappers[i].style.maxHeight = `calc(${maxHeight}px - 1rem)`; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-23 20:54:25 -04:00
										 |  |  | window.addEventListener('load', () => { | 
					
						
							|  |  |  |     const tables = $(".table").DataTable({ | 
					
						
							| 
									
										
										
										
											2020-07-23 03:21:26 -04:00
										 |  |  |         paging: false, | 
					
						
							|  |  |  |         info: false, | 
					
						
							| 
									
										
										
										
											2020-07-25 02:07:52 -04:00
										 |  |  |         dom: "t", | 
					
						
							| 
									
										
										
										
											2021-06-25 21:05:44 +02:00
										 |  |  |         columnDefs: [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 targets: 'hours', | 
					
						
							|  |  |  |                 render: function (data, type, row) { | 
					
						
							|  |  |  |                     if (type === "sort" || type === 'type') { | 
					
						
							|  |  |  |                         if (data === "None") | 
					
						
							| 
									
										
										
										
											2021-06-25 21:15:54 +02:00
										 |  |  |                             return -1; | 
					
						
							| 
									
										
										
										
											2021-06-25 21:05:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                         return parseInt(data); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     if (data === "None") | 
					
						
							| 
									
										
										
										
											2021-06-25 21:15:54 +02:00
										 |  |  |                         return data; | 
					
						
							| 
									
										
										
										
											2021-06-25 21:05:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-25 21:15:54 +02:00
										 |  |  |                     let hours   = Math.floor(data / 3600); | 
					
						
							|  |  |  |                     let minutes = Math.floor((data - (hours * 3600)) / 60); | 
					
						
							| 
									
										
										
										
											2021-06-25 21:05:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                     if (minutes < 10) {minutes = "0"+minutes;} | 
					
						
							|  |  |  |                     return hours+':'+minutes; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }, | 
					
						
							| 
									
										
										
										
											2021-06-25 21:15:54 +02:00
										 |  |  |             { | 
					
						
							|  |  |  |                 targets: 'number', | 
					
						
							|  |  |  |                 render: function (data, type, row) { | 
					
						
							|  |  |  |                     if (type === "sort" || type === 'type') { | 
					
						
							|  |  |  |                         return parseFloat(data); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     return data; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 targets: 'fraction', | 
					
						
							|  |  |  |                 render: function (data, type, row) { | 
					
						
							|  |  |  |                     let splitted = data.split("/", 1); | 
					
						
							|  |  |  |                     let current = splitted[0] | 
					
						
							|  |  |  |                     if (type === "sort" || type === 'type') { | 
					
						
							|  |  |  |                         return parseInt(current); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     return data; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }, | 
					
						
							| 
									
										
										
										
											2021-06-25 21:05:44 +02:00
										 |  |  |         ], | 
					
						
							| 
									
										
										
										
											2020-07-23 03:21:26 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // DO NOT use the scrollX or scrollY options. They cause DataTables to split the thead from
 | 
					
						
							|  |  |  |         // the tbody and render two separate tables.
 | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-25 02:07:52 -04:00
										 |  |  |     document.getElementById('search').addEventListener('keyup', (event) => { | 
					
						
							|  |  |  |         tables.search(event.target.value); | 
					
						
							|  |  |  |         console.info(tables.search()); | 
					
						
							|  |  |  |         tables.draw(); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-23 03:21:26 -04:00
										 |  |  |     const update = () => { | 
					
						
							|  |  |  |         const target = $("<div></div>"); | 
					
						
							| 
									
										
										
										
											2020-07-24 03:57:44 +02:00
										 |  |  |         const tracker = document.getElementById('tracker-wrapper').getAttribute('data-tracker'); | 
					
						
							|  |  |  |         target.load("/tracker/" + tracker, function (response, status) { | 
					
						
							| 
									
										
										
										
											2020-07-23 03:21:26 -04:00
										 |  |  |             if (status === "success") { | 
					
						
							|  |  |  |                 target.find(".table").each(function (i, new_table) { | 
					
						
							|  |  |  |                     const new_trs = $(new_table).find("tbody>tr"); | 
					
						
							|  |  |  |                     const old_table = tables.eq(i); | 
					
						
							|  |  |  |                     const topscroll = $(old_table.settings()[0].nScrollBody).scrollTop(); | 
					
						
							|  |  |  |                     const leftscroll = $(old_table.settings()[0].nScrollBody).scrollLeft(); | 
					
						
							|  |  |  |                     old_table.clear(); | 
					
						
							|  |  |  |                     old_table.rows.add(new_trs).draw(); | 
					
						
							|  |  |  |                     $(old_table.settings()[0].nScrollBody).scrollTop(topscroll); | 
					
						
							|  |  |  |                     $(old_table.settings()[0].nScrollBody).scrollLeft(leftscroll); | 
					
						
							|  |  |  |                 }); | 
					
						
							| 
									
										
										
										
											2020-07-29 21:35:31 +02:00
										 |  |  |                 $("#multi-stream-link").replaceWith(target.find("#multi-stream-link")); | 
					
						
							| 
									
										
										
										
											2020-07-23 03:21:26 -04:00
										 |  |  |             } else { | 
					
						
							|  |  |  |                 console.log("Failed to connect to Server, in order to update Table Data."); | 
					
						
							|  |  |  |                 console.log(response); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setInterval(update, 30000); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-25 22:07:35 -04:00
										 |  |  |     window.addEventListener('resize', () => { | 
					
						
							|  |  |  |         adjustTableHeight(); | 
					
						
							| 
									
										
										
										
											2021-02-19 15:18:26 +01:00
										 |  |  |         tables.draw(); | 
					
						
							| 
									
										
										
										
											2020-07-25 22:07:35 -04:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-25 02:07:52 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-25 17:24:23 -04:00
										 |  |  |     $(".table-wrapper").scrollsync({ | 
					
						
							| 
									
										
										
										
											2020-07-23 03:21:26 -04:00
										 |  |  |         y_sync: true, | 
					
						
							|  |  |  |         x_sync: true | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-25 22:07:35 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     adjustTableHeight(); | 
					
						
							| 
									
										
										
										
											2020-07-23 20:54:25 -04:00
										 |  |  | }); |