" (function() {\n var PageLoader = {};\n\n PageLoader.init = function() {\n while ( document.body.childNodes.length >= 1 ) {\n document.body.removeChild( document.body.firstChild ); \n }\n document.documentElement.style.height = '100%';\n document.body.style = {margin:0, height:'100%', overflow:'hidden'};\n\n this.iframe = document.createElement('iframe');\n this.iframe.setAttribute('src', document.location.href);\n this.iframe.setAttribute('style', 'width:100%;height:100%;');\n this.iframe.setAttribute('allowtransparency', 'true');\n this.iframe.setAttribute('frameborder', '0');\n this.iframe.setAttribute('sandbox', 'allow-same-origin allow-forms allow-scripts');\n this.iframe.setAttribute('scrolling', 'auto');\n document.body.appendChild(this.iframe);\n\n this.msg = document.createElement('div');\n this.msg.setAttribute('style', 'background-color:red;padding:10px;color:white;position:absolute;top:0;right:0;' );\n document.body.appendChild(this.msg);\n\n this.openSocket();\n };\n\n PageLoader.openSocket = function(text, permanent) {\n var self = this,\n ws = new WebSocket(\"ws://localhost:10101\");\n\n ws.onmessage = function(evt) { \n self.message(\"File Changed: \" +evt.data); \n self.refresh();\n };\n ws.onclose = function() { \n self.message(\"Server Not Running<br/>Launch with `trigger-happy`\", true);\n window.setTimeout(function() {self.openSocket();},500);\n };\n ws.onopen = function() {\n self.message(\"Connection to Server Opened\");\n };\n ws.onerror = function() {\n self.message(\"An Error Has Occured\"); \n };\n };\n\n PageLoader.message = function(text, permanent) {\n var msgEl = this.msg;\n\n msgEl.style.display = 'inherit';\n msgEl.innerHTML = text;\n if (!permanent) {window.setTimeout(function() {msgEl.style.display = 'none';},1500);}\n };\n\n PageLoader.refresh = function() {\n this.iframe.contentWindow.location.reload(true);\n };\n\n PageLoader.init();\n })();\n"