Our challenge was to have several Paessler/PRTG MAPs (www.paessler.com) cycling through a TV in the IT room. We did not want to have just one static MAP at all. This was originally posted by myself here: https://kb.paessler.com/en/topic/79668-prtg-maps-auto-cycle
In order to accomplish this – we created a simple HTML file with some JAVASCRIPT code that runs through several URLs you easily can specify. Per URL there is a timeout value. Further is there a company logo that will be displayed while a MAP is loading, that will fade out and actually make the MAP visible.
The HTML code including the JavaScript is below – here are some things I wanted to explain and share about it.
Line 6 – to the end: src=”bgpicture.png” This can be replaced by any other file-name – simple use a LOGO here that you want to see while the MAP is loaded – it will fade out
Line 11 – 21 – those lines hold the URLs in var Source=[] – add a line per URL you want to cycle through, each URL has the same format as follows. Please MAKE SURE that the last URL entry is not followed by a comma “,” otherwise the script might fail to cycle.
Entry format:
- ‘URL’,timeout,showBGfading,’title’
- URL in text-marks
- timeout in seconds
- show background picture/logo fading out – 0 (do not show) or 1 (show and fade)
- title/description in text-marks
Example: ‘https://prtg.company.local/public/mapshow.htm?id=1111&mapid=ABCDEFGH-1234-ABCD-1234-123456789000′,60,1,’Network Map’,
This would mean:
- URL = https://prtg.company.local/public/mapshow.htm?id=1111&mapid=ABCDEFGH-1234-ABCD-1234-123456789000
- timeout = 60 seconds
- bgpicture = 1 – start with BGPicture from the HTML code and let it fade out (fades the map in)
- Title/Description = Network Map
We simply load the HTML file in the browser and display it as full screen – avoiding any browser title-bar etc.
Features:
- you will see a timeout counter in the upper right – this shows you how much longer the current view will be available.
- you will see a title/description in the upper left while the element was loaded – it will slowly (slower the bgpicture) fade out – you can use any text there – per URL
- you might or might not see the BGPicture element – fading out – depending on your URL configuration – we found it worked out nicely cause we didn’t want to see a …load map data… or anything and have a smooth transition between the maps..
- we set timeouts per MAP like 60 seconds etc. – so we a) cycle quick enough and b) have enough time to look at the data shown to us
- you can use the LEFT and RIGHT arrow key on your keyboard to jump to the previous or next URL while you execute the HTML file (if not randomized)
- the up/down arrow keys allow you to show/hide a menu of all links available, this then allows you to click on a specific item in the list and show this specifically – the list is always generated on the fly – this prepares for future adjustments like showing where you are right now…
- added a feature for to PAUSE the script – press P to stop the cycle any time
- added a randomization – you can activate it and any of the URLs will be accessed randomly – if it is disabled, the script will cycle through the URLs as defined
- var bolRandomize=true;
For fun – or how to add a few Easter Eggs:
- you can use any file (we use MP4 and GIFs) to be displayed as well – our URL list is rather long – mostly just going through the same URLs but every now and then showing briefly a little IT joke in between – of course it depends a bit on your company – how ever – wanted to mention that we even like to do that for a short 5 seconds period.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <body style="margin:0px;padding:0px;overflow:hidden;font-family:Arial;" onload="javaqscript:onTimer();"> <div id="bgPicture" style="position: absolute; opacity: 0.4; width: 100%; height: 100%; background-color:white;"><img style="position:fixed;top: 50%; left: 50%;transform: translate(-50%, -50%);" src="bgpicture.png"></div> <div id="TitleBar" style="position: absolute; opacity: 1; width: 100%; height: 100%;"><strong><div id="ShowName" style="top: 2; left: 2; text-shadow: 2px 2px white;"></div></strong></div> <div id="CountDownMaster" style="position: absolute;top: 2; right: 0;"><strong><div id="CountDownCounter" style="text-shadow: 2px 2px white;"></div></strong></div> <div id="Menu" style="opacity: 0.8; display: none; position: absolute; background-color: white; overflow-y: scroll; height: 100%"><h3><u>Menu</u></h3></div> <div id="Pause" style="opacity: 0.2; display: none; position: absolute; background-color: transparent; height: 100%; color: white; text-shadow: 2px 2px black; width: 100%; text-align: center; font-size: xx-large"><h1>PAUSED</h1><br><h1>PAUSED</h1><br><h1>PAUSED</h1><br><h1>PAUSED</h1><br><h1>PAUSED</h1><br><h1>PAUSED</h1><br><h1>PAUSED</h1><br><h1>PAUSED</h1><br><h1>PAUSED</h1><br><h1>PAUSED</h1><br><h1>PAUSED</h1><br></div> <iframe src="about:blank" id="myframe" style="overflow:hidden;height:100vH;width:100%" frameborder="2" scrolling=no></iframe> <script type="text/javascript"> var Source=[ 'https://prtg.domain.com/public/mapshow.htm?id=3528&mapid=4A2F3F55-8565',60,1,'Title 1', 'https://prtg.domain.com/public/mapshow.htm?id=9587&mapid=C09AF100-A9D6',30,1,'Titel 2', 'https://prtg.domain.com/public/mapshow.htm?id=8689&mapid=DC030F11-3A1D',90,1,'Title 3', 'https://prtg.domain.com/public/mapshow.htm?id=8688&mapid=6401B136-D8D9',60,1,'Title 4' ] iSources = Source.length - 1; var iSource=-1; var iMenu=-1; var bolPause=false; var bolRandomize=true; //change this to TRUE to have a randomized map cycle or change it to FALSE to go step by step through the defined URLs document.getElementById('myframe').src = Source[iSource]; function fadeBG() { if (!bolPause) { var myDIV = document.getElementById('bgPicture'); if (myDIV.style.opacity > 0) { myDIV.style.opacity = myDIV.style.opacity-0.01; } myDIV2 = document.getElementById("TitleBar"); if (myDIV2.style.opacity > 0) { myDIV2.style.opacity = myDIV2.style.opacity-0.0025; } } } var DoFadeBG = window.setInterval(fadeBG, 30); var CountDownValue=0; function ExecuteCountdown() { if (CountDownValue > 0) { CountDownValue=CountDownValue-1; document.getElementById("CountDownCounter").innerHTML = CountDownValue; } } var DoCountDown = window.setInterval(ExecuteCountdown, 1000); function onTimer() { window.clearTimeout(myTimeOut); if (iMenu > -1) { iSource = iMenu; iMenu = -1; } else { if (!bolRandomize) { if (iSource >= iSources) { iSource = -1; } iSource = iSource + 1; } else { iSource = Math.round((Math.floor(Math.random() * (+iSources - +0)) + +0) / 4) * 4; } } document.getElementById('myframe').src = Source[iSource]; iSource = iSource + 1; myTimeOut = window.setTimeout(onTimer, parseInt(Source[iSource])*1000); CountDownValue=Source[iSource]; iSource = iSource + 1; document.getElementById('bgPicture').style.opacity=Source[iSource]; iSource = iSource + 1; document.getElementById('ShowName').innerHTML=Source[iSource]; document.getElementById('TitleBar').style.opacity=1; } myTimeOut = window.setTimeout(onTimer, 100); function ShowMenu() { myList = document.createElement('ul'); myList.id= "MenuList"; for (i = 0; i < iSources;){ tmpListItem = document.createElement('li'); tmpLink = document.createElement('a'); tmpLink.href = "javascript:iMenu=" + (i) + ";onTimer();";//Source[i]; tmpLink.textContent = Source[(i+3)]; tmpListItem.appendChild(tmpLink); myList.appendChild(tmpListItem); i = i+4; } myMenu = document.getElementById("Menu"); myMenu.appendChild(myList); document.getElementById("Menu").style.display="block"; } function HideMenu() { myList = document.getElementById("MenuList"); myList.parentNode.removeChild(myList); document.getElementById("Menu").style.display="none"; } var Key = { LEFT: 37, UP: 38, RIGHT: 39, DOWN: 40, PAUSE: 80 }; function checkKey(e) { e = e || window.event; switch (e.keyCode) { case Key.LEFT: //info.value += "LEFT "; if (iSource>3) { iSource = iSource - (2*4); } else { iSource = (iSources-4); } onTimer(); break; case Key.UP: //info.value += "UP "; ShowMenu(); break; case Key.RIGHT: //info.value += "RIGHT "; onTimer(); break; case Key.DOWN: HideMenu(); //info.value += "DOWN "; break; case Key.PAUSE: bolPause = !bolPause; if (bolPause) { window.clearTimeout(myTimeOut); document.getElementById("Pause").style.display="block"; CountDownValue=0; document.getElementById("CountDownCounter").innerHTML = "Paused" document.getElementById('TitleBar').style.opacity=1; document.getElementById('bgPicture').style.opacity=0; } else { myTimeOut = window.setTimeout(onTimer, 100); document.getElementById("Pause").style.display="none"; } break; default: //info.value += "SOMEKEY "; } } document.onkeydown = checkKey; </script> </body> </html> |
Updated – December 2018: This is version 2.0 of the script. Updates are some minor bug fixes and mainly the ability to scroll forward and backward through the URLs while using the left and right arrow keys on you keyboard. Additionally do the up/down keys show or hide a complete menu of all links that are cycled through.This then allows you to click on a specific link to show the content.
Updated – April 2019: Version 3.0 of the script has now a PAUSE feature and a randomization feature that you can enable/disable.
Notes as per May 2022: Did not change the script but wanted to make you all aware that you might run in to issues with X-FRAME-OPTIONS set to SAMEORIGIN. This can be investigated while using your browsers developer tools (F12), you should see script errors revealing this issue. Eventually it boils down to some pages not loading (e.g., https://www.google.com) due to them not allowing to be embedded. You can see if the page offers special embedded links/URLs or try to use a proxy-script that feeds to page to the iFrame. At this point I can not offer a good working solution, the script was designed to load Paessler PRTG MAPS and this is still working just fine. Using the script beyond this purpose might work or not due to the target page settings and configurations.