From 4dda54edeeacb81e422c7f6d36a73fd737ca6e86 Mon Sep 17 00:00:00 2001 From: wouterlucas Date: Fri, 27 Mar 2020 14:25:24 -0700 Subject: [PATCH 1/2] Bluetooth: Fix minor thingies --- dist/bundle.js | 2 +- src/js/plugins/bluetooth.js | 92 +++++++++++++++++++------------------ 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/dist/bundle.js b/dist/bundle.js index f7eb7d4..a68a1ad 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -1 +1 @@ -!function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=5)}([function(t,e,n){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n=function(t,e){var n=t[1]||"",i=t[3];if(!i)return n;if(e&&"function"==typeof btoa){var o=(l=i,d=btoa(unescape(encodeURIComponent(JSON.stringify(l)))),r="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(d),"/*# ".concat(r," */")),s=i.sources.map(function(t){return"/*# sourceURL=".concat(i.sourceRoot).concat(t," */")});return[n].concat(s).concat([o]).join("\n")}var l,d,r;return[n].join("\n")}(e,t);return e[2]?"@media ".concat(e[2],"{").concat(n,"}"):n}).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var i={},o=0;o{let t=window.location.hostname;return window.location.host===window.location.hostname?t+=":80":t+=":"+window.location.host.substring(window.location.hostname.length+1),t}},function(t,e,n){"use strict";var i=n(2),o=n.n(i);class s{constructor(t){this.prefixForService="Service",this.mainDiv=document.getElementById("main"),this.socket=null,this.host=t.split(":"),this.host[1]||(this.host[1]=80),this.t=o()({host:this.host[0],port:this.host[1]}),this.socketListeners={},this.servicesAvailableInJsonRPC=["DeviceInfo","DHCPServer","DIALServer","LocationSync","Messenger","Monitor","NetworkControl","OCDM","RemoteControl","Spark","Streamer","SystemCommands","TestController","TestUtility","TimeSync","TraceControl","WebKitBrowser","WifiControl"]}handleRequest(t,e,n,i){var o=new XMLHttpRequest;o.open(t,e,!0),i&&(o.onreadystatechange=function(){if(4==o.readyState)if(o.status>=200&&o.status<=299){var t;if(""!==o.responseText)try{t=JSON.parse(o.responseText.replace(/\\x([0-9A-Fa-f]{2})/g,""))}catch(t){}i(null,t,o.status)}else o.status>=300?i(o.responseText,null):0===o.status&&i("Connection interrupted",null)},o.ontimeout=function(){i("Connection timed out",null)}),null!==n?"string"==typeof n||n instanceof String?o.send(n):o.send(JSON.stringify(n)):o.send()}getURLStart(t,e){return t+"://"+this.host[0]+":"+this.host[1]+"/"+this.prefixForService+"/"}req(t,e){return new Promise((n,i)=>{if(e)console.debug(` ${e.plugin}.1.${e.method}`,e.params?e.params:""),this.t.call(e.plugin,e.method,e.params).then(t=>{n(t)}).catch(o=>{t?(console.debug(` ${e.plugin}.1.${e.method} failed, trying ${t.method} ${t.path}`),console.debug(" Error: ",o),this.handleRequest(t.method,this.getURLStart("http")+t.path,t.body,(t,e)=>{t?i(t):n(e)})):(console.error("JSONRPC Error, with no fallback: ",o),i(o))});else{if(void 0===t)return i("No rest or jsonrpc options provided, bailing out");this.handleRequest(t.method,this.getURLStart("http")+t.path,t.body,(t,e)=>{t?i(t):n(e)})}})}getControllerPlugins(){return this.req({method:"GET",path:"Controller/Plugins"},{plugin:"Controller",method:"status"})}startWebShell(t){t(null,new WebSocket(this.getURLStart("ws")+"WebShell","raw"))}startWebSocket(){this.socket&&this.socket.close(),this.socket=new WebSocket(this.getURLStart("ws")+"Controller","notification");var t=this;this.socket.onmessage=function(e){var n={};try{if(void 0===(n=JSON.parse(e.data)).callsign)return;for(var i=0;i\n
\n \n\n \x3c!--navigation--\x3e\n \n ',this.header=document.getElementById("header"),this.nav=document.getElementById("menu");var i=!1,o=new Image;o.alt="Metrological",o.onload=()=>{this.header.appendChild(o)},o.onerror=()=>{!0!==i&&(o.src="UI/img/ml.svg",i=!0)},o.src="img/ml.svg",document.getElementById("button-left").onclick=this.showMenu.bind(this),window.onresize=function(){if(!0!==this.isTouchDevice){var t=document.getElementById("menu");window.innerWidth>960?t.style.left="0px":t.style.left="-600px"}},this.api.t.on("Controller","all",t=>{t.data&&t.data.state&&this.render()})}clear(){this.nav.innerHTML=""}render(t){this.api.getControllerPlugins().then(e=>{this.clear();const n=Object.keys(this.plugins);let i=document.createElement("ul");for(let s=0;s\n \n -\n \n\n
\n \n -\n
\n\n
\n \n -\n
\n\n
\n \n -\n
\n\n
\n \n -\n /\n -\n
\n\n
\n \n -\n /\n -\n
\n\n
\n \n -\n
\n\n hide statistics\n ',this.versionSpan=document.getElementById("statusBarVersion"),this.uptimeSpan=document.getElementById("statusBarUptime"),this.serialSpan=document.getElementById("statusBarSerial"),this.cpuLoadSpan=document.getElementById("statusBarCpuLoad"),this.usedRamSpan=document.getElementById("statusBarUsedRam"),this.totalRamSpan=document.getElementById("statusBarTotalRam"),this.gpuUsedRamSpan=document.getElementById("statusBarGpuRamUsed"),this.gpuTotalRamSpan=document.getElementById("statusBarGpuRamTotal"),document.getElementById("pause-button").onclick=this.togglePause.bind(this),this.pauseButton=document.getElementById("pause-button"),void 0!==this.deviceInfo?(this.interval=setInterval(this.update.bind(this),l.refresh_interval),this.update(),this.updateStatisticsBlock()):this.togglePause()}render(t){void 0!==t&&(this.deviceIsConnected(!0),this.versionSpan.innerHTML=t.version,this.serialSpan.innerHTML=t.serialnumber,this.uptimeSpan.innerHTML=t.uptime,this.totalRamSpan.innerHTML=this.bytesToMbString(t.totalram),this.usedRamSpan.innerHTML=this.bytesToMbString(t.totalram-t.freeram),this.gpuTotalRamSpan.innerHTML=this.bytesToMbString(t.totalgpuram),this.gpuUsedRamSpan.innerHTML=this.bytesToMbString(t.totalgpuram-t.freegpuram),this.cpuLoadSpan.innerHTML=parseFloat(t.cpuload).toFixed(1)+" %")}update(){!0===this.paused||this.deviceInfo&&"activated"!==this.deviceInfo.state||this.deviceInfo&&this.deviceInfo.status().then(this.render.bind(this))}updateStatisticsBlock(){this.pauseButton.innerHTML=!1===this.paused?"hide statistics":"show statistics";var t=this.footer.getElementsByClassName("status"),e=0;if(!1===this.paused){for(;e\n
No connection with device
\n
Attempting to connect
\n ',e.style.display="block"),this.connected=t}}bytesToMbString(t){return(t/1024/1024).toFixed(1)+" MB"}};var a=class{constructor(t){this.renderInMenu=!1,this.api=t,this.api.t.on("Controller","all",this.handleNotification),document.getElementById("hide-notifications").onclick=this.toggleVisibility.bind(this)}handleNotification(t){document.getElementById("notifications-block").style.display="block";var e=document.createElement("div"),n="",i=0;for(var o in t){if("Monitor"===t[o]&&(e.className="red"),"callsign"===o){var s=document.createElement("label");s.innerHTML='"'+t[o]+'"',e.appendChild(s)}else if("data"===o){n=n+o+": {";var l=0;for(var d in t.data)n=n+d+": "+t.data[d],l==Object.keys(t.data).length-1?n+="}":n+=", ",l++}else n=n+o+": "+t[o];"callsign"!=o&&i!=Object.keys(t).length-1&&(n+=", "),i++}var r=document.createElement("span");r.innerHTML=n,e.appendChild(r),document.getElementById("notifications").appendChild(e),document.getElementById("notifications").scrollTop=document.getElementById("notifications").scrollHeight}toggleVisibility(){var t="block"===document.getElementById("notifications").style.display;document.getElementById("notifications").style.display=t?"none":"block",document.getElementById("hide-notifications").innerHTML=t?"show console":"hide console"}};var c=class{constructor(t,e){this.api=e,this.callsign=t.callsign,this.configuration=t.configuration,this.classname=t.classname,this.state=t.state,this.supportsSuspended=!1,this.supportsVisibility=!1,this.renderInMenu=!0,this.displayName=void 0,this.rendered=!1}activate(t){const e={method:"PUT",path:`Controller/Activate/${t||this.callsign}`},n={plugin:"Controller",method:"activate",params:{callsign:t||this.callsign}};return this.api.req(e,n)}deactivate(t){const e={method:"PUT",path:`Controller/Deactivate/${t||this.callsign}`,body:null},n={plugin:"Controller",method:"deactivate",params:{callsign:t||this.callsign}};return this.api.req(e,n)}suspend(t){const e={method:"POST",path:`${t||this.callsign}/Suspend`},n={plugin:t||this.callsign,method:"state",params:"suspended"};return this.api.req(e,n)}resume(t){const e={method:"POST",path:`${t||this.callsign}/Resume`},n={plugin:t||this.callsign,method:"state",params:"resumed"};return this.api.req(e,n)}show(t){const e={method:"POST",path:`${t||this.callsign}/Show`,body:null};t||this.callsign;return this.api.req(e)}hide(t){const e={method:"POST",path:`${t||this.callsign}/Hide`,body:null};this.callsign;return this.api.req(e)}status(t){const e={method:"GET",path:t||this.callsign},n={plugin:t||this.callsign,method:"status"};return this.api.req(e,n)}render(){this.rendered=!0}close(){this.rendered=!1}};var u=class extends c{constructor(t,e){super(t,e),this.observablesList=[],this.restartList=[]}getMemoryInfo(t){return this.api.req({method:"GET",path:"Monitor"},{plugin:"Monitor",method:"status"})}render(){document.getElementById("main").innerHTML='
\n \n \n
Observables
\n
\n
\n
RestartThreshold
\n
\n
\n
',this.getObservableList(),this.observableListEl=document.getElementById("observables"),this.restartListEl=document.getElementById("restart"),this.bt_setRestart=document.getElementById("setRestart"),this.bt_setRestart.onclick=this.setRestartThreshold.bind(this)}getObservableList(){this.status().then(t=>{for(var e=[],n=0;n{this.getMemoryInfo(t).then(o=>{let s=o.filter(e=>e.observable===t||e.name===t||valse);s&&s[0]?e(n.createMonitorDiv(s[0])):i()})})}createMonitorDiv(t){if(void 0!==t.measurment&&(t.measurements=t.measurment),void 0!==t.measurements&&void 0!==t.measurements.resident){var e=t.measurements,n=document.createElement("div"),i=document.createElement("div");for(var o in i.className="title grid__col grid__col--8-of-8",i.innerHTML="Memory",n.appendChild(i),e.resident){var s=document.createElement("div");s.className="label grid__col grid__col--2-of-8",n.appendChild(s);var l=document.createElement("label");l.innerHTML=o,s.appendChild(l);var d=document.createElement("div");d.className="text grid__col grid__col--6-of-8",d.innerHTML=this.bytesToMbString(e.resident[o]),n.appendChild(d)}var r=document.createElement("div");r.className="label grid__col grid__col--2-of-8",n.appendChild(r);var a=document.createElement("label");a.innerHTML="measurements",r.appendChild(a);var c=document.createElement("div");c.className="text grid__col grid__col--6-of-8",c.innerHTML=e.count,n.appendChild(c);var u=document.createElement("div");u.className="label grid__col grid__col--2-of-8",n.appendChild(u);var h=document.createElement("label");h.innerHTML="process",u.appendChild(h);var g=document.createElement("div");return g.className="text grid__col grid__col--6-of-8",g.innerHTML=e.process.last,n.appendChild(g),n}}bytesToMbString(t){return(t/1024/1024).toFixed(1)+" MB"}};var h=class extends c{constructor(t,e){super(t,e),this._url="",this._fps=0,this._isHidden=!1,this._isSuspended=!1,this.lastSetUrlKey="lastSetUrl",this.lastSetUrl=window.localStorage.getItem(this.lastSetUrlKey)||"",this.inspectorPort="9998",this.monitor=void 0,this.updateLoopInterval=void 0,this.template='
\n\n
Presets / URL
\n\n
URL
\n
-
\n\n
\n \n
\n
\n \n \n \n
\n\n
URL presets
\n
\n \n
\n\n
Performance
\n
FPS
\n
-
\n
\n\n
Tools
\n\n
Current State
\n
\n
\n
\n \n
\n\n
Web Inspector
\n
\n \n
\n\n
',this.presets=[{Name:"Select a preset",URL:""},{Name:"about:blank",URL:"about:blank"},{Name:"Smashcat",URL:"http://www.smashcat.org/av/canvas_test/"},{Name:"HTML5",URL:"http://beta.html5test.com/"},{Name:"PeaceKeeper",URL:"http://peacekeeper.futuremark.com/run.action"},{Name:"ChipTune",URL:"http://www.chiptune.com/kaleidoscope/"},{Name:"Poster Circle",URL:"http://www.webkit.org/blog-files/3d-transforms/poster-circle.html"},{Name:"Aquarium",URL:"http://webglsamples.org/aquarium/aquarium.html"},{Name:"Particles",URL:"http://oos.moxiecode.com/js_webgl/particles_morph/"},{Name:"EME v3 (race car)",URL:"http://cdn.metrological.com/static/eme-v3-clean.html"},{Name:"MSE 2018 (no vp9)",URL:"http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2018.html?novp9=true"},{Name:"EME 2018",URL:"http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2018.html?test_type=encryptedmedia-test"},{Name:"Progressive",URL:"http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2018.html?test_type=progressive-test"},{Name:"YouTube",URL:"http://youtube.com/tv"},{Name:"HelloRacer",URL:"http://www.emerveille.fr/lab/helloracer/index.html"},{Name:"Leaves",URL:"http://www.webkit.org/blog-files/leaves"},{Name:"Canvas Dots",URL:"http://themaninblue.com/experiment/AnimationBenchmark/canvas/"},{Name:"Anisotropic",URL:"http://whiteflashwhitehit.com/content/2011/02/anisotropic_webgl.html"},{Name:"Pasta",URL:"http://alteredqualia.com/three/examples/webgl_pasta.html"},{Name:"CSS3",URL:"http://css3test.com"},{Name:"Kraken",URL:"http://krakenbenchmark.mozilla.org/kraken-1.1/driver.html"},{Name:"KeyPress Test",URL:"http://keycode.info"}],void 0!==this.configuration&&void 0!==this.configuration.inspector&&(this.inspectorPort=this.configuration.inspector.split(":")[1]),this.api.t.on(this.callsign,"urlchange",t=>{t.url&&t.loaded&&(this._url=t.url,!0===this.rendered&&this.update())}),this.api.t.on(this.callsign,"visibilitychange",t=>{"boolean"==typeof t.hidden&&(this._isHidden=t.hidden,!0===this.rendered&&this.update())}),this.api.t.on(this.callsign,"statechange",t=>{"boolean"==typeof t.suspended&&(this._isSuspended=t.suspended,!0===this.rendered&&this.update())}),this.api.getControllerPlugins().then(t=>{let e=t.filter(t=>"Monitor"===t.callsign);void 0!==e&&(this.monitor=new u(e,this.api))})}status(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"state"};return this.api.req(t,e)}fps(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"fps"};return this.api.req(t,e)}url(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"url"};return this.api.req(t,e)}render(){var t=document.getElementById("main"),e=this.template.replace(/{{callsign}}/g,this.callsign);t.innerHTML=e,document.getElementById(this.callsign+"_url").value=this.lastSetUrl,document.getElementById(this.callsign+"_button").onclick=this.getAndSetUrl.bind(this),document.getElementById(this.callsign+"_reloadbutton").onclick=this.reloadUrl.bind(this),document.getElementById(this.callsign+"_linkPresets").onchange=this.getAndSetUrlFromPresets.bind(this);var n=document.getElementById(this.callsign+"_linkPresets");if(0===n.children.length)for(var i=0;i{t._isSuspended=e.suspended?e.suspended:"suspended"===e}).then(this.fps.bind(this)).then(e=>{t._fps=e.fps?e.fps:e}).then(this.url.bind(this)).then(e=>{t._url=e.url?e.url:e}).then(this.update.bind(this))}close(){window.removeEventListener("keydown",this.handleKey.bind(this),!1),clearInterval(this.updateLoopInterval),delete this.updateLoopInterval,this.rendered=!1}update(){document.getElementById(this.callsign+"_current_url").innerHTML=this._url,document.getElementById(this.callsign+"_fps").innerHTML=this._fps;var t=this._isSuspended?"Suspended":"Resumed",e=this._isSuspended?"Resume":"Suspend";document.getElementById(this.callsign+"StateInfo").innerHTML=t;var n=document.getElementById(this.callsign+"SuspendButton");n.innerHTML=e.toUpperCase(),n.onclick=this.toggleSuspend.bind(this,e),this.monitor&&this.monitor.getMonitorDataAndDiv().then(t=>{var e=document.getElementById(this.callsign+"Memory");e.innerHTML="",e.appendChild(t)})}setUrl(t){if(""===t)return;console.log("Setting url "+t+" for "+this.callsign);var e={url:t};const n={method:"POST",path:this.callsign+"/URL",body:e},i={plugin:this.callsign,method:"url",params:t};this.api.req(n,i),document.getElementById(this.callsign+"_linkPresets").selectedIndex=0}getAndSetUrl(){this.lastSetUrl=document.getElementById(this.callsign+"_url").value,this.setUrl(this.lastSetUrl),window.localStorage.setItem(this.lastSetUrlKey,this.lastSetUrl)}reloadUrl(){this.setUrl(this.callsign,document.getElementById(this.callsign+"_current_url").innerHTML)}getAndSetUrlFromPresets(){var t=document.getElementById(this.callsign+"_linkPresets").selectedIndex;t>0&&this.setUrl(this.presets[t].URL)}handleKey(t){var e=document.getElementById("WebKitBrowser_url");13===t.which&&e&&e===document.activeElement&&this.getAndSetUrl()}toggleSuspend(t){"Resume"===t?this.resume():this.suspend()}launchWebinspector(){var t="http://"+this.api.host[0]+":"+this.inspectorPort;window.open(t,"_blank").focus()}};var g=class extends c{constructor(t,e){super(t,e),this.monitor=void 0,this.api.t.on("Netflix","visibilitychange",t=>{"boolean"==typeof t.hidden&&(this.isHidden=t.hidden,!0===this.rendered&&this.update())}),this.api.t.on("Netflix","statechange",t=>{"boolean"==typeof t.suspended&&(this.isSuspended=t.suspended,!0===this.rendered&&this.update())}),this.api.getControllerPlugins().then(t=>{let e=t.filter(t=>"Monitor"===t.callsign);void 0!==e&&(this.monitor=new u(e,this.api))})}render(){document.getElementById("main").innerHTML='
\n ESN\n
\n\n
\n ID\n
\n
\n -\n
\n\n
\n
\n
\n
Memory
\n
Current State
\n
\n
\n
\n \n
\n
\n
',this.interval=setInterval(this.update.bind(this),conf.refresh_interval),this.update()}update(t){this.status().then(t=>{t.esn&&(document.getElementById("netflix-esn").innerHTML=t.esn);var e=t.suspended?"Suspended":"Resumed";document.getElementById("NetflixStateInfo").innerHTML=e;var n="Suspend";!0===t.suspended&&(n="Resume");var i=document.getElementById("NetflixSuspendButton");i.innerHTML=n.toUpperCase(),i.onclick=this.toggleSuspend.bind(this,n),this.monitor&&this.monitor.getMonitorDataAndDiv().then(t=>{var e=document.getElementById(this.callsign+"Memory");e.innerHTML="",e.appendChild(t)})})}close(){clearInterval(this.interval)}toggleSuspend(t){var e=this;"Resume"===t?this.resume().then(()=>{e.update({suspended:!1})}).catch(t=>{e.render()}):this.suspend().then(()=>{e.update({suspended:!0})}).catch(t=>{e.render()})}};var p={BluetoothControl:class extends c{constructor(t,e){super(t,e),this._devices=[],this.scanning=!1,this.displayName="BluetoothControl"}render(){document.getElementById("main").innerHTML='\n
\n Status\n
\n\n
\n Devices\n
\n
\n \n
\n
\n Scanning\n
\n
\n OFF\n
\n\n
\n Device\n
\n
\n Name\n
\n
\n -\n
\n
\n Type\n
\n
\n -\n
\n
\n Connected\n
\n
\n -\n
\n
\n Paired\n
\n
\n -\n
\n\n
Controls
\n
\n \n \n \n \n
\n\n
Remote
\n
\n \n \n
\n\n
\n Discovery\n
\n
\n \n
\n
\n \n
\n
\n BlueTooth Low Energy\n
\n
\n
\n \n \n
\n
\n\n
\n\n
\n ',this.scanButton=document.getElementById("BT_ScanForDevices"),this.pairButton=document.getElementById("BT_Pair"),this.unpairButton=document.getElementById("BT_Unpair"),this.connectButton=document.getElementById("BT_Connect"),this.disconnectButton=document.getElementById("BT_Disconnect"),this.btLowEnergyButton=document.getElementById("BT_LE"),this.assignButton=document.getElementById("BT_Assign"),this.revokeButton=document.getElementById("BT_Revoke"),this.deviceList=document.getElementById("BT_Devices"),this.deviceList.onchange=this.renderDevice.bind(this),this.scanButton.onclick=this.scanForDevices.bind(this),this.pairButton.onclick=this.pairDevice.bind(this),this.unpairButton.onclick=this.unpairDevice.bind(this),this.disconnectButton.onclick=this.disconnect.bind(this),this.connectButton.onclick=this.connect.bind(this),this.assignButton.onclick=this.assign.bind(this),this.revokeButton.onclick=this.revoke.bind(this),this.nameEl=document.getElementById("BT_Name"),this.typeEl=document.getElementById("BT_Type"),this.connectedEl=document.getElementById("BT_Connected"),this.pairedEl=document.getElementById("BT_Paired"),this.scanningStatus=document.getElementById("BT_Scanning"),this.statusMessages=document.getElementById("statusMessages"),this.deviceList=document.getElementById("BT_Devices"),this.api.t.on("BluetoothControl","scancomplete",this.update.bind(this)),this.update()}devices(){return this.api.req(null,{plugin:"BluetoothControl",method:"devices"})}device(t){const e={plugin:"BluetoothControl",method:"device@"+t};return this.api.req(null,e)}update(){this.scanning=!1,this.renderScanStatus(),this.devices().then(t=>{void 0!==t&&(this._devices=[],this.deviceList.innerHTML="",t&&t.length&&(t.forEach(t=>{this._devices.push({address:t}),this.deviceList.appendChild(document.createElement("option")).innerHTML=t}),this.renderDevice()))})}renderScanStatus(){this.scanningStatus.innerHTML=!0===this.scanning?"ON":"OFF"}renderDevice(){var t=this.deviceList.selectedIndex;if(void 0===this._devices[t].name){let e=this._devices[t].address;this.device(e).then(n=>{n&&(this._devices[t]={address:e,...n},this.updateDevice(t))})}else this.updateDevice[t]}updateDevice(t){let e=this._devices[t];this.nameEl.innerHTML=e.name,this.typeEl.innerHTML=e.type,this.connectedEl.innerHTML=e.connected,this.pairedEl.innerHTML=e.paired}updateStatus(t){window.clearTimeout(this.statusMessageTimer),this.statusMessages.innerHTML=t,this.statusMessageTimer=setTimeout(this.updateStatus,5e3,"")}scanForDevices(){this.updateStatus("Start scanning"),this.scanning=!0,this.renderScanStatus();const t={method:"PUT",path:"/Scan/?LowEnergy="+this.btLowEnergyButton.checked,body:null},e={plugin:"BluetoothControl",method:"scan",params:{type:this.btLowEnergyButton.checked?"LowEnergy":"Regular",timeout:10}};this.api.req(t,e)}pairDevice(){var t=this.deviceList.selectedIndex;this.updateStatus(`Pairing to ${this._devices[t].name}`);const e={method:"PUT",path:"/Pair",body:'{"address" : "'+this._devices[t].address+'"}'},n={plugin:this.callsign,method:"pair",params:{address:this._devices[t].address}};this.api.req(e,n)}unpairDevice(){var t=this.deviceList.selectedIndex;this.updateStatus(`Unpairing ${this._devices[t].name}`);const e={method:"PUT",path:"/Unpair",body:'{"address" : "'+this._devices[t].address+'"}'},n={plugin:this.callsign,method:"unpair",params:{address:this._devices[t].address}};this.api.req(e,n)}connect(){var t=this.deviceList.selectedIndex;this.updateStatus(`Connecting to ${this._devices[t].name}`);const e={method:"PUT",path:"/Connect",body:'{"address" : "'+this._devices[t].address+'"}'},n={plugin:this.callsign,method:"connect",params:{address:this._devices[t].address}};this.api.req(e,n)}disconnect(){var t=this.deviceList.selectedIndex;this.updateStatus(`Disconnecting from ${this._devices[t].name}`);const e={method:"DELETE",path:"/Connect",body:'{"address" : "'+this._devices[t].address+'"}'},n={plugin:this.callsign,method:"pair",params:{address:this._devices[t].address}};this.api.req(e,n)}assign(){var t=this.deviceList.selectedIndex;this.updateStatus(`Assigning ${this._devices[t].name}`);const e={plugin:"BluetoothRemoteControl",method:"assign",params:{address:this._devices[t].address}};this.api.req(null,e)}revoke(){var t=this.deviceList.selectedIndex;this.updateStatus(`Revoking ${this._devices[t].name}`);const e={plugin:"BluetoothRemoteControl",method:"revoke",params:{address:this._devices[t].address}};this.api.req(null,e)}close(){clearInterval(this.statusMessageTimer)}},Cobalt:class extends h{constructor(t,e){super(t,e),this.template='
\n\n
Presets / URL
\n\n
URL
\n
-
\n\n
\n \n
\n
\n \n \n \n
\n\n
URL presets
\n
\n \n
\n\n
Performance
\n
FPS
\n
-
\n
\n\n
Tools
\n\n
Current State
\n
\n
\n
\n \n
\n\n
Visibility
\n
\n
\n
\n \n
\n\n
\n
Web Inspector
\n
\n \n
\n
\n\n
'}},Compositor:class extends c{constructor(t,e){super(t,e),this._rpcMapping={Top:"putontop"},this.resolutions=["720p","720p50Hz","1080p24Hz","1080i50Hz","1080p50Hz","1080p60Hz"]}render(){document.getElementById("main").innerHTML='
\n Compositor\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n\n
',document.getElementById("compositorResolutions").onclick=this.setResolution.bind(this),this.resolutionsList=document.getElementById("compositorResolutions"),this.menu=document.getElementById("compositorClients"),this.controlDiv=document.getElementById("controls"),this.compositorClientsDiv=document.getElementById("compositorClientsDiv"),this.controlDiv.style.display="none",this.resolutionsList.innerHTML="";for(var t=0;t{null!=t&&Array.isArray(t)?t.length>0&&this.renderControls(t):this.compositorClientsDiv.innerHTML="No clients found."})}getClients(){const t={method:"GET",path:`${this.callsign}/Clients`},e={plugin:this.callsign,method:"clients"};return this.api.req(t,e)}renderControls(t){this.controlDiv.innerHTML='
\n Controls\n
\n
\n Focus\n
\n
\n \n
\n
\n
\n Opacity\n
\n
\n \n \n
\n
\n
\n \n
\n
\n Visibility\n
\n
\n \n \n
\n
\n
\n Geometry\n
\n
\n X\n
\n
\n \n
\n
\n Y\n
\n
\n \n
\n
\n Width\n
\n
\n \n
\n
\n Height\n
\n
\n \n
\n
\n
\n \n
',document.getElementById("compositorSetTop").onclick=this.compositorAction.bind(this,"Top"),document.getElementById("sliderOpacity").onchange=this.updateValue.bind(this,"sliderOpacity","numOpacity"),document.getElementById("numOpacity").onchange=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("numOpacity").onkeyup=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("numOpacity").onpaste=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("numOpacity").oninput=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("compositorSetOpacity").onclick=this.compositorSetOpacity.bind(this),document.getElementById("webkit_hide").onclick=this.compositorVisible.bind(this,"Hide"),document.getElementById("webkit_show").onclick=this.compositorVisible.bind(this,"Show"),document.getElementById("compositorGeometry").onclick=this.compositorSetGeometry.bind(this),document.getElementById("compositorClients").onchange=this.clientChange.bind(this);var e=document.getElementById("compositorClients");e.innerHTML="";var n=document.createElement("option");n.value="",n.setAttributeNode(document.createAttribute("disabled")),n.setAttributeNode(document.createAttribute("selected")),n.innerHTML="Select a client",e.appendChild(n);for(var i=0;i{void 0!==t.state&&!0===this.rendered&&this.render(),void 0!==t.suspended&&!0===this.rendered&&this.render()})}controllerStatus(t){const e={plugin:"Controller"};return e.method=t?`status@${t}`:"status",api.req(void 0,e)}harakiri(){const t={plugin:"Controller",method:"harakiri",params:{callsign:this.callsign}};return this.api.req({method:"PUT",path:"Controller/Harakiri",body:null},t)}initiateDiscovery(){return this.api.req({method:"PUT",path:"Controller/Discovery",body:null},{plugin:"Controller",method:"startdiscovery",params:{ttl:1}})}getDiscovery(){return this.api.req({method:"GET",path:"Controller/Discovery",body:null},{plugin:"Controller",method:"discoveryresults"})}persist(t){return this.api.req({method:"PUT",path:"Controller/Persist",body:null},{plugin:"Controller",method:"storeconfig"})}toggleActivity(t){for(var e,n=0;n{void 0!==plugins[t]&&(plugins[t].state="activated"),e.state="activated"}).catch(t=>{this.render()})):(console.debug("Deactivating "+t),this.deactivate(t).then(n=>{void 0!==plugins[t]&&(plugins[t].state="deactivated"),e.state="deactivated"}).catch(t=>{this.render()}))}toggleSuspend(t){for(var e,n=0;n{void 0!==plugins[t]&&(plugins[t].state="activated"),!1===document.getElementById(t+"suspend").checked?this.resume(t).then(this.render.bind(this)):api.suspendPlugin(t).then(this.render.bind(this))});"resumed"===e.state?(console.debug("Suspending "+t),this.suspend(t).then(n=>{this.updateSuspendLabel(t,"resume"),void 0!==plugins[t]&&(plugins[t].state="resumed"),document.getElementById(t+"suspend").checked=!0,e.state="suspended"})):(console.debug("Resuming "+t),this.resume(t).then(n=>{this.updateSuspendLabel(t,"suspend"),void 0!==plugins[t]&&(plugins[t].state="suspended"),document.getElementById(t+"suspend").checked=!1,e.state="resumed"}))}clear(){this.mainDiv.innerHTML=""}discover(){console.log("Initiating discovery"),this.initiateDiscovery();let t=this;setTimeout(function(){t.getDiscovery().then(t=>{var e=t.bridges?t.bridges:t,n=document.getElementById("discoveryList");n.innerHTML="";for(var i=0;i\n Plugins\n \n
\n
\n Device actions\n
\n
\n \n
\n
\n \n
\n
\n Discover devices\n
\n
\n \n
\n
\n
    \n
    \n \n ',document.getElementById("persistButton").onclick=this.persist.bind(this),document.getElementById("harakiriButton").onclick=this.harakiri.bind(this),document.getElementById("discoverButton").onclick=this.discover.bind(this);var t=document.getElementById("controllerPlugins");this.status().then(e=>{var n=e.plugins?e.plugins:e;this.plugins=n;for(var i=0;inew Promise((e,n)=>{this.deviceInfo().then(n=>{e({...t,...n})})}))}deviceInfo(){return this.api.req({method:"GET",path:"DeviceInfo"},{plugin:"DeviceInfo",method:"systeminfo"})}displayInfo(){return this.api.req({method:"GET",path:"DisplayInfo"},{plugin:"DisplayInfo",method:"displayinfo"})}addresses(){return this.api.req({method:"GET",path:"DeviceInfo"},{plugin:"DeviceInfo",method:"addresses"})}socketinfo(){return this.api.req({method:"GET",path:"DeviceInfo"},{plugin:"DeviceInfo",method:"socketinfo"})}update(){this.deviceInfo().then(t=>{let e=t.systeminfo?t.systeminfo:t;this.deviceNameEl.innerHTML=e.devicename,this.serialNumberEl.innerHTML=e.serialnumber,this.versionEl.innerHTML=e.version,this.uptimeEl.innerHTML=e.uptime,this.totalRamEl.innerHTML=this.bytesToMbString(e.totalram),this.usedRamEl.innerHTML=this.bytesToMbString(e.totalram-e.freeram),this.freeRamEl.innerHTML=this.bytesToMbString(e.freeram),this.cpuLoadEl.innerHTML=parseFloat(e.cpuload).toFixed(1)+" %",this.addresses().then(t=>{let e=t.addresses?t.addresses:t;this.interfacesOptsEl.innerHTML="";for(var n=0;n{this.totalGpuRamEl.innerHTML=this.bytesToMbString(t.totalgpuram),this.freeGpuRamEl.innerHTML=this.bytesToMbString(t.freegpuram),this.usedGpuRamEl.innerHTML=this.bytesToMbString(t.totalgpuram-t.freegpuram)}),document.getElementById("startGraphs").onclick=this.startRealtimeGraphs.bind(this)}render(){this.mainDiv.innerHTML=this.template,this.deviceNameEl=document.getElementById("DeviceName"),this.serialNumberEl=document.getElementById("SerialNumber"),this.versionEl=document.getElementById("Version"),this.uptimeEl=document.getElementById("Uptime"),this.totalRamEl=document.getElementById("TotalRam"),this.usedRamEl=document.getElementById("UsedRam"),this.freeRamEl=document.getElementById("FreeRam"),this.totalGpuRamEl=document.getElementById("TotalGpuRam"),this.freeGpuRamEl=document.getElementById("FreeGpuRam"),this.usedGpuRamEl=document.getElementById("UsedGpuRam"),this.cpuLoadEl=document.getElementById("CpuLoad"),this.interfacesOptsEl=document.getElementById("NetworkInterface"),this.interfacesOptsEl.onchange=this.updateNetworkInterface.bind(this),this.macIdEl=document.getElementById("MAC_ID"),this.ipAddressEl=document.getElementById("IpAddress"),this.update()}startRealtimeGraphs(){this.chartOptions.maxElements=parseInt(document.getElementById("graph_max_elements").value),this.chartOptions.interval=parseInt(document.getElementById("graph_poll_interval").value),this.cpuChart=this.generateGraph("CPU usage",document.getElementById("graph_cpu").getContext("2d"),"#34c749","%"),this.ramChart=this.generateGraph("RAM used",document.getElementById("graph_ram").getContext("2d"),"#fc5652","MB"),this.gpuChart=this.generateGraph("GPU RAM used",document.getElementById("graph_gpu").getContext("2d"),"#fdbc40","MB"),this.chartIntervalId=setInterval(this.updateGraphs.bind(this),this.chartOptions.interval),document.getElementById("graphs").style.display="block"}generateGraph(t,e,n,i){return new Chart(e,{type:"line",data:{labels:[],datasets:[{label:t,backgroundColor:n,borderColor:n,data:[],fill:!1}]},options:{responsive:!1,scales:{yAxes:[{ticks:{callback:function(t,e,n){return t+i}}}]}}})}updateGraphs(){let t=this;const e=t.getTimestampForGraph();this.deviceInfo().then(n=>{t.ramChart&&(t.ramChart.config.data.labels.push(e),t.ramChart.config.data.datasets[0].data.push((n.totalram-n.freeram)/1024/1024),t.ramChart.config.data.labels.length>t.chartOptions.maxElements&&(t.ramChart.config.data.labels.shift(),t.ramChart.config.data.datasets[0].data.shift()),t.ramChart.update()),t.cpuChart&&(t.cpuChart.config.data.labels.push(e),t.cpuChart.config.data.datasets[0].data.push(parseFloat(n.cpuload).toFixed(1)),t.cpuChart.config.data.labels.length>t.chartOptions.maxElements&&(t.cpuChart.config.data.labels.shift(),t.cpuChart.config.data.datasets[0].data.shift()),t.cpuChart.update())}),this.displayInfo().then(n=>{t.gpuChart&&(t.gpuChart.config.data.labels.push(e),t.gpuChart.config.data.datasets[0].data.push((n.totalgpuram-n.freegpuram)/1024/1024),t.gpuChart.config.data.labels.length>t.chartOptions.maxElements&&(t.gpuChart.config.data.labels.shift(),t.gpuChart.config.data.datasets[0].data.shift()),t.gpuChart.update())})}close(){clearInterval(this.chartIntervalId),delete this.ramChart,delete this.cpuChart,delete this.gpuChart}updateNetworkInterface(t){this.selectedNetworkInterface=this.interfacesOptsEl.selectedIndex,this.update()}bytesToMbString(t){return(t/1024/1024).toFixed(1)+" MB"}getTimestampForGraph(){const t=new Date;return`${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}`}},DialServer:class extends c{constructor(t,e){super(t,e),this.api.t.on("DIALServer","start",t=>{this.dialMessage("start",t)}),this.api.t.on("DIALServer","stop",t=>{this.dialMessage("stop",t)})}render(){document.getElementById("main").innerHTML='
    \n Received DIAL requests:\n
    \n\n
    ',this.statusMessagesEl=document.getElementById("statusMessages")}dialMessage(t,e){let n=document.createElement("div");"stop"===t&&(n.className="red");let i=document.createElement("span");i.innerHTML=`${t} :: ${e.application} - ${e.parameters}`,n.appendChild(i),this.statusMessagesEl.appendChild(n)}},LocationSync:class extends c{constructor(t,e){super(t,e),this.renderInMenu=!0,this.displayName="Location"}render(){document.getElementById("main").innerHTML='
    \n Location\n
    \n\n
    \n City\n
    \n
    \n -\n
    \n
    \n Country\n
    \n
    \n -\n
    \n
    \n Region\n
    \n
    \n -\n
    \n\n
    \n Timezone\n
    \n
    \n -\n
    \n\n
    \n Public IP\n
    \n
    \n -\n
    \n\n
    \n Sync\n
    \n
    \n \n
    ',document.getElementById("syncButton").onclick=this.syncLocation.bind(this),this.cityEl=document.getElementById("city"),this.countryEl=document.getElementById("country"),this.regionEl=document.getElementById("region"),this.timezoneEl=document.getElementById("timezone"),this.publicIpEl=document.getElementById("publicip"),this.update()}syncLocation(){const t={method:"PUT",path:`${this.callsign}`},e={plugin:this.callsign,method:"sync"};this.api.req(t,e).then(()=>{this.update()})}location(){const t={method:"GET",path:`${this.callsign}`},e={plugin:this.callsign,method:"location"};return this.api.req(t,e)}update(){this.location().then(t=>{this.cityEl.innerHTML=t.city,this.countryEl.innerHTML=t.country,this.regionEl.innerHTML=t.region,this.timezoneEl.innerHTML=t.timezone,this.publicIpEl.innerHTML=t.publicip})}},Monitor:u,Netflix:g,NetworkControl:class extends c{constructor(t,e){super(t,e),this.renderInMenu=!0,this.displayName="Network",this.selectedNetworkInterface=0,this.networks=[]}render(){document.getElementById("main").innerHTML='\n
    \n Network Control\n
    \n
    \n Network Interface\n
    \n
    \n \n
    \n
    \n IP Address\n
    \n
    \n -\n
    \n
    \n Broadcast\n
    \n
    \n -\n
    \n
    \n Gateway\n
    \n
    \n -\n
    \n
    \n mask\n
    \n
    \n -\n
    \n
    \n mode\n
    \n
    \n -\n
    \n\n
    \n Control\n
    \n
    \n \n \n \n \n
    ',this.interfacesOptsEl=document.getElementById("NetworkInterface"),this.interfacesOptsEl.onchange=this.updateNetworkInterface.bind(this),document.getElementById("reload").onclick=this.reload.bind(this);document.getElementById("request");request.onclick=this.request.bind(this),document.getElementById("assign").onclick=this.assign.bind(this),document.getElementById("flush").onclick=this.flush.bind(this),this.ipEl=document.getElementById("ip"),this.broadcastEl=document.getElementById("broadcast"),this.gatewayEl=document.getElementById("gateway"),this.maskEl=document.getElementById("mask"),this.modeEl=document.getElementById("mode"),this.api.t.on("NetworkControl","networkupdate",t=>{console.log("NETWORK NOT",t),this.update()}),this.update()}network(){const t={method:"GET",path:`${this.callsign}`},e={plugin:this.callsign,method:"network"};return this.api.req(t,e)}reload(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Reload`},n={plugin:this.callsign,method:"reload",params:{device:t}};return this.api.req(e,n)}request(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Request`},n={plugin:this.callsign,method:"request",params:{device:t}};return this.api.req(e,n)}assign(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Assign`},n={plugin:this.callsign,method:"assign",params:{device:t}};return this.api.req(e,n)}flush(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Flush`},n={plugin:this.callsign,method:"flush",params:{device:t}};return this.api.req(e,n)}update(){this.network().then(t=>{let e=t.addresses?t.addresses:t;this._addresses=e,this.interfacesOptsEl.innerHTML="";for(var n=0;n{if(null==t)return;let e=t.systems?t.systems:t;for(let t=0;t{void 0!==t.PowerState&&(this.powerStateDiv.innerHTML=this.stateLookup[t.PowerState],this.stateSelectorEl.children[t.PowerState-1].selected=!0)})}changeState(t){const e={method:"POST",path:`${this.callsign}/State`,body:{PowerState:this.stateSelectorEl.value}},n={plugin:this.callsign,method:"state",params:{powerstate:this.stateSelectorEl.value}};""!==this.timeoutInput.value&&(e.body.Timeout=this.timeoutInput.value,n.body.timeout=this.timeoutInput.value),this.api.req(e).then(()=>{t<2&&setTimeout(this.update,5e3)})}},Provisioning:class extends c{constructor(t,e){super(t,e)}render(){document.getElementById("main").innerHTML='
    \n Provisioning status\n
    \n\n
    \n Device\n
    \n
    \n -\n
    \n
    \n Provisioned for\n
    \n
    \n -\n
    \n
    \n Status\n
    \n
    \n -\n
    \n\n
    \n Provisioning\n
    \n
    \n \n
    ',document.getElementById("provisionButton").onclick=this.tiggerProvisioningRequest.bind(this),this.update()}triggerProvisioning(){const t={method:"PUT",path:`${this.callsign}`},e={plugin:this.callsign,method:"provision"};return this.api.req(t,e)}status(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"state"};return this.api.req(t,e)}update(){this.status().then(t=>{if(null!=t&&""!==t){var e=t.id,n=t.tokens||[],i=t.status;document.getElementById("device").innerHTML=e,document.getElementById("status").innerHTML=200==i?"provisioned":"not provisioned",200==i&&n.length>0&&(document.getElementById("provisioning-tokens").innerHTML=n.join(", ")),document.getElementById("provisionLabel").style.display=200==i?"none":null}}).catch(t=>{console.error(t),this.status(t)})}tiggerProvisioningRequest(){var t=this;this.triggerProvisioning().then(e=>{document.getElementById("provisionButton").style.display="none",document.getElementById("provisionLabel").style.display="none",setTimeout(t.update(),3e3)})}},RemoteControl:class extends c{constructor(t,e){super(t,e),this.displayName="Remote Control",this.onScreenKeyBoardIsRendered=!1,this.doNotHandleKeys=!1,this.devicesThatSupportPairing=["GreenPeakRF4CE","GreenPeak","RF4CE"],this.autoFwdKeys=window.localStorage.getItem("autoFwdKeys"),this.automaticallyForwardKeys="false"!==this.autoFwdKeys,this.keyMapping={1:{code:"0x0021",color:void 0,string:"1"},2:{code:"0x0022",color:void 0,string:"2"},3:{code:"0x0023",color:void 0,string:"3"},4:{code:"0x0024",color:void 0,string:"4"},5:{code:"0x0025",color:void 0,string:"5"},6:{code:"0x0026",color:void 0,string:"6"},7:{code:"0x0027",color:void 0,string:"7"},8:{code:"0x0028",color:void 0,string:"8"},9:{code:"0x0029",color:void 0,string:"9"},0:{code:"0x0020",color:void 0,string:"0"},exit:{code:"0x0009",color:"blue",string:"exit"},a:{code:"0x8004",color:void 0,string:"a"},b:{code:"0x8005",color:void 0,string:"b"},c:{code:"0x8006",color:void 0,string:"c"},d:{code:"0x8007",color:void 0,string:"d"},e:{code:"0x8008",color:void 0,string:"e"},f:{code:"0x8009",color:void 0,string:"f"},g:{code:"0x800A",color:void 0,string:"g"},h:{code:"0x800B",color:void 0,string:"h"},i:{code:"0x800C",color:void 0,string:"i"},back:{code:"0x0032",color:"blue double",string:"back"},j:{code:"0x800D",color:void 0,string:"j"},k:{code:"0x800E",color:void 0,string:"k"},l:{code:"0x800F",color:void 0,string:"l"},m:{code:"0x8010",color:void 0,string:"m"},n:{code:"0x8011",color:void 0,string:"n"},o:{code:"0x8012",color:void 0,string:"o"},p:{code:"0x8013",color:void 0,string:"p"},q:{code:"0x8014",color:void 0,string:"q"},r:{code:"0x8015",color:void 0,string:"r"},up:{code:"0x0001",color:"blue",string:"up",div:'
    '},ok:{code:"0x002B",color:"blue",string:"ok"},s:{code:"0x8016",color:void 0,string:"s"},t:{code:"0x8017",color:void 0,string:"t"},u:{code:"0x8018",color:void 0,string:"u"},v:{code:"0x8019",color:void 0,string:"v"},w:{code:"0x801A",color:void 0,string:"w"},x:{code:"0x801B",color:void 0,string:"x"},y:{code:"0x801C",color:void 0,string:"y"},z:{code:"0x801D",color:void 0,string:"z"},left:{code:"0x0003",color:"blue",string:"left",div:'
    '},down:{code:"0x0002",color:"blue",string:"down",div:'
    '},right:{code:"0x0004",color:"blue",string:"right",div:'
    '}},this.jsToWpeKeyMap={13:{code:"0x002B",string:"enter"},37:{code:"0x0003",string:"left"},38:{code:"0x0001",string:"up"},39:{code:"0x0004",string:"right"},40:{code:"0x0002",string:"down"},27:{code:"0x0009",string:"esc"},8:{code:"0x0032",string:"backspace"},48:{code:"0x0020",string:"0"},49:{code:"0x0021",string:"1"},50:{code:"0x0022",string:"2"},51:{code:"0x0023",string:"3"},52:{code:"0x0024",string:"4"},53:{code:"0x0025",string:"5"},54:{code:"0x0026",string:"6"},55:{code:"0x0027",string:"7"},56:{code:"0x0028",string:"8"},57:{code:"0x0029",string:"9"},33:{code:"0x0030",string:"page up"},34:{code:"0x0031",string:"page down"},65:{code:"0x8004",string:"a"},66:{code:"0x8005",string:"b"},67:{code:"0x8006",string:"c"},68:{code:"0x8007",string:"d"},69:{code:"0x8008",string:"e"},70:{code:"0x8009",string:"f"},71:{code:"0x800A",string:"g"},72:{code:"0x800B",string:"h"},73:{code:"0x800C",string:"i"},74:{code:"0x800D",string:"j"},75:{code:"0x800E",string:"k"},76:{code:"0x800F",string:"l"},77:{code:"0x8010",string:"m"},78:{code:"0x8011",string:"n"},79:{code:"0x8012",string:"o"},80:{code:"0x8013",string:"p"},81:{code:"0x8014",string:"q"},82:{code:"0x8015",string:"r"},83:{code:"0x8016",string:"s"},84:{code:"0x8017",string:"t"},85:{code:"0x8018",string:"u"},86:{code:"0x8019",string:"v"},87:{code:"0x801A",string:"w"},88:{code:"0x801B",string:"x"},89:{code:"0x801C",string:"y"},90:{code:"0x801D",string:"z"},46:{code:"0x802A",string:"delete"},32:{code:"0x802C",string:"space"},189:{code:"0x802D",string:"-"},187:{code:"0x802E",string:"="},220:{code:"0x8031",string:"\\"},186:{code:"0x8033",string:";"},222:{code:"0x8034",string:"`"},188:{code:"0x8036",string:","},190:{code:"0x8037",string:"."},191:{code:"0x8038",string:"/"}},this.addKeyboardButton(),this.keyboardDiv=document.getElementById("keyboard"),this.keyBoardInnerDiv=document.createElement("div"),this.keyBoardInnerDiv.id="keyboard-inner";for(var n=Object.keys(this.keyMapping),i=0;i{if(void 0!==e)for(var n=void 0!==e.devices?e.devices:e,i=document.getElementById("remotesList"),o=document.getElementById("pairingDiv"),s=0;s\n Pairing\n '),o.innerHTML+=`
    ${l}
    \n
    \n \n
    `,document.getElementById(l+"-PairingMode").onclick=t.activatePairing.bind(t,l)}})}toggleAutoforwardOfKeys(){this.automaticallyForwardKeys=!0!==this.automaticallyForwardKeys,window.localStorage.setItem("autoFwdKeys",this.automaticallyForwardKeys)}},Snapshot:class extends c{constructor(t,e){super(t,e)}render(){document.getElementById("main").innerHTML='
    \n Create\n
    \n\n
    \n Snapshot\n
    \n
    \n \n
    \n\n
    \n \n
    ',document.getElementById("snapshotButton").onclick=this.createSnapshot.bind(this)}getSnapshotLocator(){return this.api.getURLStart("http")+"Snapshot/Capture?"+(new Date).getTime()}createSnapshot(){var t=document.getElementById("snapshotOutput");t.src="",t.src=this.getSnapshotLocator()}},Spark:class extends c{constructor(t,e){super(t,e),this.url="",this.isHidden=!1,this.isSuspended=!1,this.lastSetUrlKey="lastSetUrl"+this.callsign,this.lastSetUrl=window.localStorage.getItem(this.lastSetUrlKey)||"",this.template='
    \n\n
    Presets / URL
    \n\n
    \n \n
    \n
    \n \n \n
    \n\n
    URL presets
    \n
    \n \n
    \n\n
    Tools
    \n\n
    Current State
    \n
    \n
    \n
    \n \n
    \n\n
    Visibility
    \n
    \n
    \n
    \n \n
    \n
    ',this.presets=[{Name:"Select a preset",URL:""},{Name:"http://www.sparkui.org/examples/gallery/picturepile.js",URL:"http://www.sparkui.org/examples/gallery/picturepile.js"},{Name:"http://www.sparkui.org/examples/gallery/gallery.js",URL:"http://www.sparkui.org/examples/gallery/gallery.js"}],this.api.t.on("Spark","urlchange",t=>{t.url&&t.loaded&&(this.url=t.url,this.handleNotification())}),this.api.t.on("Spark","visibilitychange",t=>{"boolean"==typeof t.hidden&&(this.isHidden=t.hidden,this.handleNotification())}),this.api.t.on("Spark","statechange",t=>{"boolean"==typeof t.suspended&&(this.isSuspended=t.suspended,this.handleNotification())})}handleNotification(t){!1!==this.rendered&&this.update()}render(){var t=document.getElementById("main"),e=this.template.replace(/{{callsign}}/g,this.callsign);t.innerHTML=e,document.getElementById(this.callsign+"_url").value=this.lastSetUrl,document.getElementById(this.callsign+"_button").onclick=this.getAndSetUrl.bind(this),document.getElementById(this.callsign+"_linkPresets").onchange=this.getAndSetUrlFromPresets.bind(this);var n=document.getElementById(this.callsign+"_linkPresets");if(0===n.children.length)for(var i=0;i0&&this.setUrl(this.presets[t].URL)}handleKey(t){var e=document.getElementById(`${this.callsign}_url`);13===t.which&&e&&e===document.activeElement&&this.getAndSetUrl()}toggleSuspend(t){"Resume"===t?this.resume():this.suspend()}toggleVisibility(t){"Show"===t?this.show():this.hide()}},Switchboard:class extends c{constructor(t,e){super(t,e),this.defaultPlugin=void 0,this.switchablePlugins=[],this.state().then(t=>{this.defaultPlugin=t.default,this.switchablePlugins=t.callsigns})}state(){const t={method:"GET",path:`${this.callsign}/Switch`};return this.api.req(t)}getDefaultSwitchBoardPlugin(){return this.defaultPlugin}getSwitchablePlugins(){return this.switchBoardPlugins}render(){this.mainDiv=document.getElementById("main"),this.mainDiv.innerHTML='\n
    \n Plugins\n
    \n
    ';var t=document.getElementById("switchBoardPlugins");this.api.getControllerPlugins().then(e=>{for(var n=e.plugins,i=0;i{this.render()})}},TimeSync:class extends c{constructor(t,e){super(t,e),this.renderInMenu=!0,this.displayName="Time"}render(){document.getElementById("main").innerHTML='\n
    \n Time\n
    \n
    \n Current time\n
    \n
    \n -\n
    \n
    \n Source\n
    \n
    \n -\n
    \n
    \n Last synced\n
    \n
    \n -\n
    \n\n
    \n \n
    \n
    \n \n \n
    \n\n
    \n Control\n
    \n
    \n \n
    ',document.getElementById("setTime").onclick=this.setTime.bind(this),document.getElementById("sync").onclick=this.synchronizeTime.bind(this),this.timeEl=document.getElementById("time"),this.sourceEl=document.getElementById("source"),this.syncedEl=document.getElementById("synced"),this.api.t.on("TimeSync","update",t=>{console.log("TIME NOT",t),this.update()}),this.update()}synchronizeTime(){this.syncTime().then(this.synchronize())}synchronize(){const t={plugin:this.callsign,method:"synchronize"};return this.api.req(null,t)}syncTime(){const t={plugin:this.callsign,method:"synctime"};return this.api.req(null,t)}setTime(){let t=document.getElementById("timeinput").value;const e={method:"POST",path:`${this.callsign}`,body:{time:t}},n={plugin:this.callsign,method:"time",params:t};return this.api.req(e,n)}getTime(){const t={method:"GET",path:`${this.callsign}`},e={plugin:this.callsign,method:"time"};return this.api.req(t,e)}update(){this.getTime().then(t=>{this.timeEl.innerHTML=t,this.syncTime().then(t=>{this.sourceEl.innerHTML=t.source,this.syncedEl.innerHTML=t.time})})}},TraceControl:class extends c{constructor(t,e){super(t,e),this.displayName="Tracing",this.selectedTraceModule=void 0,this.traceModules=void 0,this.uniqueTraceModules=void 0}toggleTracing(t,e,n){const i={method:"PUT",path:"TraceControl/"+t+"/"+e+"/"+n},o={plugin:"TraceControl",method:"set",params:{module:t,category:e,state:"on"===n?"enabled":"disabled"}};return this.api.req(i,o)}render(){var t=this;document.getElementById("main").innerHTML='
    \n Modules\n
    \n\n
    \n \n
    \n
    \n \n
    \n\n
    ',document.getElementById("tracingModules").onchange=this.getSelectedModuleAndShowCategories.bind(this),this.status().then(e=>{t.traceModules=e.settings?e.settings:[],t.uniqueTraceModules=[];var n=document.getElementById("tracingModules");n.getElementsByTagName("options");if(n.options.length=0,void 0!==t.traceModules){for(var i=0;i{this.mutedEl.innerHTML=t}),this.volume().then(t=>{this.volumeEl.innerHTML=t})}muted(t){const e={plugin:this.callsign,method:"muted"};return t&&(e.params=t),this.api.req(null,e)}volume(t){const e={plugin:this.callsign,method:"volume"};return t&&(e.params=t),this.api.req(null,e)}volumeChange(t){this.volume().then(e=>{this.volume(e+t).then(this.update())})}mute(){this.muted().then(t=>{this.muted(!t).then(this.update())})}},WebKitBrowser:h,WebShell:class extends c{constructor(t,e){super(t,e),this.webShellSocket=void 0}render(){var t=this;document.getElementById("main").innerHTML='
    WebShell
    \n
    \n
    \n        
    \n
    #
    ',this.api.startWebShell(function(e,n){t.webShellSocket=n,t.webShellSocket.onmessage=function(t){var e=new FileReader;e.onload=function(){document.getElementById("webShellData").innerHTML=String.fromCharCode.apply(null,new Uint8Array(e.result))},e.readAsArrayBuffer(t.data)},t.webShellSocket.onclose=function(){t.webShellSocket=null,t.render()}}),void 0!==plugins.RemoteControl&&(plugins.RemoteControl.doNotHandleKeys=!0),window.addEventListener("keydown",this.handleKey.bind(this))}close(){void 0!==plugins.RemoteControl&&(plugins.RemoteControl.doNotHandleKeys=!1),window.removeEventListener("keydown",this.handleKey.bind(this),!1)}handleKey(t){if(this.webShellSocket&&13===t.which){for(var e=document.getElementById("webShellInput").value+" \n",n=new ArrayBuffer(2*e.length),i=new Uint8Array(n),o=0,s=e.length;o{!0===this.rendered&&this.getNetworks()}),this.api.t.on("WifiControl","connectionchange",t=>{this.connected=t.connected,!0===this.rendered&&this.update()})}render(){document.getElementById("main").innerHTML='
    \n Status\n
    \n\n
    \n Connected to\n
    \n
    \n\n
    \n Scanning\n
    \n
    \n False\n
    \n\n
    \n Wireless networks\n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n\n
    \n Configs\n
    \n\n
    \n Configs\n
    \n
    \n \n
    \n\n
    \n SSID\n
    \n
    \n \n
    \n
    \n Mode\n
    \n
    \n
    \n \x3c!-- disable for now\n
    \n
    \n \n
    \n --\x3e\n
    \n Hidden\n
    \n
    \n
    \n Method\n
    \n
    \n \n
    \n
    \n Password\n
    \n
    \n \n
    \n
    Controls
    \n
    \n \n \n \n
    \n
    \n
    \n \n \n
    \n\n
    \n
    \n ',this.scanButton=document.getElementById("Wifi_scanForNetworksButton"),this.saveButton=document.getElementById("Wifi_saveButton"),this.deleteButton=document.getElementById("Wifi_deleteButton"),this.storeButton=document.getElementById("Wifi_storeButton"),this.connectButton=document.getElementById("Wifi_connectButton"),this.disconnectButton=document.getElementById("Wifi_disconnectButton"),this.scanButton.onclick=this.scanForNetworks.bind(this),this.deleteButton.onclick=this.deleteConfig.bind(this),this.saveButton.onclick=this.saveConfig.bind(this),this.storeButton.onclick=this.storeConfig.bind(this),this.disconnectButton.onclick=this.disconnect.bind(this),this.connectButton.onclick=this.connect.bind(this),this.connectedStatus=document.getElementById("Wifi_Connected"),this.scanningStatus=document.getElementById("Wifi_Scanning"),this.statusMessages=document.getElementById("statusMessages"),this.networkListEl=document.getElementById("Wifi_WirelessNetwork"),this.networkListEl.onchange=this.renderNetworkDetails.bind(this),this.configListEl=document.getElementById("Wifi_Configs"),this.configListEl.onchange=this.renderConfigDetails.bind(this),this.ssidEl=document.getElementById("Wifi_SSID"),this.methodEl=document.getElementById("Wifi_Method"),this.passwordEl=document.getElementById("Wifi_Password"),this.accesspointEl=document.getElementById("Wifi_Mode"),this.hiddenEl=document.getElementById("Wifi_Hidden"),this.update(),setTimeout(this.getNetworks.bind(this),200),setTimeout(this.getConfigs.bind(this),400),this.rendered=!0}update(){this.status().then(t=>{void 0!==t&&(this.connected=t.connected,"boolean"==typeof t.scanning&&(this.scanning=t.scanning),this.renderStatus())})}scanForNetworks(){const t={method:"PUT",path:`${this.callsign}/Scan`},e={plugin:this.callsign,method:"scan"};this.api.req(t,e).then(t=>{this.update(),setTimeout(this.getNetworks.bind(this),5e3)})}getConfigs(){this.update();const t={method:"GET",path:`${this.callsign}/Configs`},e={plugin:this.callsign,method:"configs"};this.api.req(t,e).then(t=>{if(void 0===t)return;let e=t.configs?t.configs:t;if(void 0!==e){this.configs=e,this.configListEl.innerHTML="";for(var n=0;n{if(void 0===t)return;if(this.networks=[],!1===this.rendered)return;let e=t.networks?t.networks:t;this.networkListEl.innerHTML="";for(var n=0;n{this.statusMessage(`Saved config for ${this.ssidEl.value}`),t.getConfigs()})}deleteConfig(){var t=this.configListEl.selectedIndex;this.statusMessage(`Deleting config ${this.configs[t].ssid}`);const e={method:"PUT",path:`${this.callsign}/Delete/${this.configs[t].ssid}`},n={plugin:this.callsign,method:"delete",params:{ssid:this.configs[t].ssid}};this.api.req(e,n).then(()=>{this.connecting=!0,this.getConfigs()})}requestDHCP(){this.statusMessage("Requesting DHCP for wlan0");const t={method:"PUT",path:`NetworkControl/${this.wlanInterface}/Request`},e={plugin:"NetworkControl",method:"request",params:{device:this.wlanInterface}};this.api.req(t,e)}storeConfig(){this.statusMessage("Storing WiFi configuration");const t={method:"PUT",path:`${this.callsign}/${this.wlanInterface}/Store`},e={plugin:this.callsign,method:"store"};this.api.req(t,e)}connect(){var t=this.configListEl.selectedIndex;this.statusMessage(`Connecting to ${this.configs[t].ssid}`);const e={method:"PUT",path:`${this.callsign}/Connect/${this.configs[t].ssid}`},n={plugin:this.callsign,method:"connect",params:{ssid:this.configs[t].ssid}};this.api.req(e,n).then(()=>{this.connecting=!0,setTimeout(this.requestDHCP.bind(this),5e3)})}disconnect(){if(void 0===this.connected||""===this.connected)return;const t={method:"DELETE",path:`${this.callsign}/Connect/${this.connected}`},e={plugin:this.callsign,method:"disconnect",params:{ssid:this.connected}};this.statusMessage(`Disconnecting from ${this.connected}`),this.api.req(t,e)}close(){this.rendered=!1}}};n.d(e,"b",function(){return f}),n.d(e,"c",function(){return b}),n.d(e,"a",function(){return l});var m={},_=void 0,v=(document.getElementById("main"),window.localStorage.getItem("lastActivePlugin")||void 0);function f(t){(_=new s(t)).getControllerPlugins().then(t=>t).then(t=>{for(var e=0;e1)for(var n=1;n{let t=window.location.hostname;return window.location.host===window.location.hostname?t+=":80":t+=":"+window.location.host.substring(window.location.hostname.length+1),t}},function(t,e,n){"use strict";var i=n(2),s=n.n(i);class o{constructor(t){this.prefixForService="Service",this.mainDiv=document.getElementById("main"),this.socket=null,this.host=t.split(":"),this.host[1]||(this.host[1]=80),this.t=s()({host:this.host[0],port:this.host[1]}),this.socketListeners={},this.servicesAvailableInJsonRPC=["DeviceInfo","DHCPServer","DIALServer","LocationSync","Messenger","Monitor","NetworkControl","OCDM","RemoteControl","Spark","Streamer","SystemCommands","TestController","TestUtility","TimeSync","TraceControl","WebKitBrowser","WifiControl"]}handleRequest(t,e,n,i){var s=new XMLHttpRequest;s.open(t,e,!0),i&&(s.onreadystatechange=function(){if(4==s.readyState)if(s.status>=200&&s.status<=299){var t;if(""!==s.responseText)try{t=JSON.parse(s.responseText.replace(/\\x([0-9A-Fa-f]{2})/g,""))}catch(t){}i(null,t,s.status)}else s.status>=300?i(s.responseText,null):0===s.status&&i("Connection interrupted",null)},s.ontimeout=function(){i("Connection timed out",null)}),null!==n?"string"==typeof n||n instanceof String?s.send(n):s.send(JSON.stringify(n)):s.send()}getURLStart(t,e){return t+"://"+this.host[0]+":"+this.host[1]+"/"+this.prefixForService+"/"}req(t,e){return new Promise((n,i)=>{if(e)console.debug(` ${e.plugin}.1.${e.method}`,e.params?e.params:""),this.t.call(e.plugin,e.method,e.params).then(t=>{n(t)}).catch(s=>{t?(console.debug(` ${e.plugin}.1.${e.method} failed, trying ${t.method} ${t.path}`),console.debug(" Error: ",s),this.handleRequest(t.method,this.getURLStart("http")+t.path,t.body,(t,e)=>{t?i(t):n(e)})):(console.error("JSONRPC Error, with no fallback: ",s),i(s))});else{if(void 0===t)return i("No rest or jsonrpc options provided, bailing out");this.handleRequest(t.method,this.getURLStart("http")+t.path,t.body,(t,e)=>{t?i(t):n(e)})}})}getControllerPlugins(){return this.req({method:"GET",path:"Controller/Plugins"},{plugin:"Controller",method:"status"})}startWebShell(t){t(null,new WebSocket(this.getURLStart("ws")+"WebShell","raw"))}startWebSocket(){this.socket&&this.socket.close(),this.socket=new WebSocket(this.getURLStart("ws")+"Controller","notification");var t=this;this.socket.onmessage=function(e){var n={};try{if(void 0===(n=JSON.parse(e.data)).callsign)return;for(var i=0;i\n
    \n \n\n \x3c!--navigation--\x3e\n \n ',this.header=document.getElementById("header"),this.nav=document.getElementById("menu");var i=!1,s=new Image;s.alt="Metrological",s.onload=()=>{this.header.appendChild(s)},s.onerror=()=>{!0!==i&&(s.src="UI/img/ml.svg",i=!0)},s.src="img/ml.svg",document.getElementById("button-left").onclick=this.showMenu.bind(this),window.onresize=function(){if(!0!==this.isTouchDevice){var t=document.getElementById("menu");window.innerWidth>960?t.style.left="0px":t.style.left="-600px"}},this.api.t.on("Controller","all",t=>{t.data&&t.data.state&&this.render()})}clear(){this.nav.innerHTML=""}render(t){this.api.getControllerPlugins().then(e=>{this.clear();const n=Object.keys(this.plugins);let i=document.createElement("ul");for(let o=0;o\n \n -\n \n\n
    \n \n -\n
    \n\n
    \n \n -\n
    \n\n
    \n \n -\n
    \n\n
    \n \n -\n /\n -\n
    \n\n
    \n \n -\n /\n -\n
    \n\n
    \n \n -\n
    \n\n hide statistics\n ',this.versionSpan=document.getElementById("statusBarVersion"),this.uptimeSpan=document.getElementById("statusBarUptime"),this.serialSpan=document.getElementById("statusBarSerial"),this.cpuLoadSpan=document.getElementById("statusBarCpuLoad"),this.usedRamSpan=document.getElementById("statusBarUsedRam"),this.totalRamSpan=document.getElementById("statusBarTotalRam"),this.gpuUsedRamSpan=document.getElementById("statusBarGpuRamUsed"),this.gpuTotalRamSpan=document.getElementById("statusBarGpuRamTotal"),document.getElementById("pause-button").onclick=this.togglePause.bind(this),this.pauseButton=document.getElementById("pause-button"),void 0!==this.deviceInfo?(this.interval=setInterval(this.update.bind(this),l.refresh_interval),this.update(),this.updateStatisticsBlock()):this.togglePause()}render(t){void 0!==t&&(this.deviceIsConnected(!0),this.versionSpan.innerHTML=t.version,this.serialSpan.innerHTML=t.serialnumber,this.uptimeSpan.innerHTML=t.uptime,this.totalRamSpan.innerHTML=this.bytesToMbString(t.totalram),this.usedRamSpan.innerHTML=this.bytesToMbString(t.totalram-t.freeram),this.gpuTotalRamSpan.innerHTML=this.bytesToMbString(t.totalgpuram),this.gpuUsedRamSpan.innerHTML=this.bytesToMbString(t.totalgpuram-t.freegpuram),this.cpuLoadSpan.innerHTML=parseFloat(t.cpuload).toFixed(1)+" %")}update(){!0===this.paused||this.deviceInfo&&"activated"!==this.deviceInfo.state||this.deviceInfo&&this.deviceInfo.status().then(this.render.bind(this))}updateStatisticsBlock(){this.pauseButton.innerHTML=!1===this.paused?"hide statistics":"show statistics";var t=this.footer.getElementsByClassName("status"),e=0;if(!1===this.paused){for(;e\n
    No connection with device
    \n
    Attempting to connect
    \n ',e.style.display="block"),this.connected=t}}bytesToMbString(t){return(t/1024/1024).toFixed(1)+" MB"}};var a=class{constructor(t){this.renderInMenu=!1,this.api=t,this.api.t.on("Controller","all",this.handleNotification),document.getElementById("hide-notifications").onclick=this.toggleVisibility.bind(this)}handleNotification(t){document.getElementById("notifications-block").style.display="block";var e=document.createElement("div"),n="",i=0;for(var s in t){if("Monitor"===t[s]&&(e.className="red"),"callsign"===s){var o=document.createElement("label");o.innerHTML='"'+t[s]+'"',e.appendChild(o)}else if("data"===s){n=n+s+": {";var l=0;for(var d in t.data)n=n+d+": "+t.data[d],l==Object.keys(t.data).length-1?n+="}":n+=", ",l++}else n=n+s+": "+t[s];"callsign"!=s&&i!=Object.keys(t).length-1&&(n+=", "),i++}var r=document.createElement("span");r.innerHTML=n,e.appendChild(r),document.getElementById("notifications").appendChild(e),document.getElementById("notifications").scrollTop=document.getElementById("notifications").scrollHeight}toggleVisibility(){var t="block"===document.getElementById("notifications").style.display;document.getElementById("notifications").style.display=t?"none":"block",document.getElementById("hide-notifications").innerHTML=t?"show console":"hide console"}};var c=class{constructor(t,e){this.api=e,this.callsign=t.callsign,this.configuration=t.configuration,this.classname=t.classname,this.state=t.state,this.supportsSuspended=!1,this.supportsVisibility=!1,this.renderInMenu=!0,this.displayName=void 0,this.rendered=!1}activate(t){const e={method:"PUT",path:`Controller/Activate/${t||this.callsign}`},n={plugin:"Controller",method:"activate",params:{callsign:t||this.callsign}};return this.api.req(e,n)}deactivate(t){const e={method:"PUT",path:`Controller/Deactivate/${t||this.callsign}`,body:null},n={plugin:"Controller",method:"deactivate",params:{callsign:t||this.callsign}};return this.api.req(e,n)}suspend(t){const e={method:"POST",path:`${t||this.callsign}/Suspend`},n={plugin:t||this.callsign,method:"state",params:"suspended"};return this.api.req(e,n)}resume(t){const e={method:"POST",path:`${t||this.callsign}/Resume`},n={plugin:t||this.callsign,method:"state",params:"resumed"};return this.api.req(e,n)}show(t){const e={method:"POST",path:`${t||this.callsign}/Show`,body:null};t||this.callsign;return this.api.req(e)}hide(t){const e={method:"POST",path:`${t||this.callsign}/Hide`,body:null};this.callsign;return this.api.req(e)}status(t){const e={method:"GET",path:t||this.callsign},n={plugin:t||this.callsign,method:"status"};return this.api.req(e,n)}render(){this.rendered=!0}close(){this.rendered=!1}};var u=class extends c{constructor(t,e){super(t,e),this.observablesList=[],this.restartList=[]}getMemoryInfo(t){return this.api.req({method:"GET",path:"Monitor"},{plugin:"Monitor",method:"status"})}render(){document.getElementById("main").innerHTML='
    \n \n \n
    Observables
    \n
    \n
    \n
    RestartThreshold
    \n
    \n
    \n
    ',this.getObservableList(),this.observableListEl=document.getElementById("observables"),this.restartListEl=document.getElementById("restart"),this.bt_setRestart=document.getElementById("setRestart"),this.bt_setRestart.onclick=this.setRestartThreshold.bind(this)}getObservableList(){this.status().then(t=>{for(var e=[],n=0;n{this.getMemoryInfo(t).then(s=>{let o=s.filter(e=>e.observable===t||e.name===t||valse);o&&o[0]?e(n.createMonitorDiv(o[0])):i()})})}createMonitorDiv(t){if(void 0!==t.measurment&&(t.measurements=t.measurment),void 0!==t.measurements&&void 0!==t.measurements.resident){var e=t.measurements,n=document.createElement("div"),i=document.createElement("div");for(var s in i.className="title grid__col grid__col--8-of-8",i.innerHTML="Memory",n.appendChild(i),e.resident){var o=document.createElement("div");o.className="label grid__col grid__col--2-of-8",n.appendChild(o);var l=document.createElement("label");l.innerHTML=s,o.appendChild(l);var d=document.createElement("div");d.className="text grid__col grid__col--6-of-8",d.innerHTML=this.bytesToMbString(e.resident[s]),n.appendChild(d)}var r=document.createElement("div");r.className="label grid__col grid__col--2-of-8",n.appendChild(r);var a=document.createElement("label");a.innerHTML="measurements",r.appendChild(a);var c=document.createElement("div");c.className="text grid__col grid__col--6-of-8",c.innerHTML=e.count,n.appendChild(c);var u=document.createElement("div");u.className="label grid__col grid__col--2-of-8",n.appendChild(u);var h=document.createElement("label");h.innerHTML="process",u.appendChild(h);var g=document.createElement("div");return g.className="text grid__col grid__col--6-of-8",g.innerHTML=e.process.last,n.appendChild(g),n}}bytesToMbString(t){return(t/1024/1024).toFixed(1)+" MB"}};var h=class extends c{constructor(t,e){super(t,e),this._url="",this._fps=0,this._isHidden=!1,this._isSuspended=!1,this.lastSetUrlKey="lastSetUrl",this.lastSetUrl=window.localStorage.getItem(this.lastSetUrlKey)||"",this.inspectorPort="9998",this.monitor=void 0,this.updateLoopInterval=void 0,this.template='
    \n\n
    Presets / URL
    \n\n
    URL
    \n
    -
    \n\n
    \n \n
    \n
    \n \n \n \n
    \n\n
    URL presets
    \n
    \n \n
    \n\n
    Performance
    \n
    FPS
    \n
    -
    \n
    \n\n
    Tools
    \n\n
    Current State
    \n
    \n
    \n
    \n \n
    \n\n
    Web Inspector
    \n
    \n \n
    \n\n
    ',this.presets=[{Name:"Select a preset",URL:""},{Name:"about:blank",URL:"about:blank"},{Name:"Smashcat",URL:"http://www.smashcat.org/av/canvas_test/"},{Name:"HTML5",URL:"http://beta.html5test.com/"},{Name:"PeaceKeeper",URL:"http://peacekeeper.futuremark.com/run.action"},{Name:"ChipTune",URL:"http://www.chiptune.com/kaleidoscope/"},{Name:"Poster Circle",URL:"http://www.webkit.org/blog-files/3d-transforms/poster-circle.html"},{Name:"Aquarium",URL:"http://webglsamples.org/aquarium/aquarium.html"},{Name:"Particles",URL:"http://oos.moxiecode.com/js_webgl/particles_morph/"},{Name:"EME v3 (race car)",URL:"http://cdn.metrological.com/static/eme-v3-clean.html"},{Name:"MSE 2018 (no vp9)",URL:"http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2018.html?novp9=true"},{Name:"EME 2018",URL:"http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2018.html?test_type=encryptedmedia-test"},{Name:"Progressive",URL:"http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2018.html?test_type=progressive-test"},{Name:"YouTube",URL:"http://youtube.com/tv"},{Name:"HelloRacer",URL:"http://www.emerveille.fr/lab/helloracer/index.html"},{Name:"Leaves",URL:"http://www.webkit.org/blog-files/leaves"},{Name:"Canvas Dots",URL:"http://themaninblue.com/experiment/AnimationBenchmark/canvas/"},{Name:"Anisotropic",URL:"http://whiteflashwhitehit.com/content/2011/02/anisotropic_webgl.html"},{Name:"Pasta",URL:"http://alteredqualia.com/three/examples/webgl_pasta.html"},{Name:"CSS3",URL:"http://css3test.com"},{Name:"Kraken",URL:"http://krakenbenchmark.mozilla.org/kraken-1.1/driver.html"},{Name:"KeyPress Test",URL:"http://keycode.info"}],void 0!==this.configuration&&void 0!==this.configuration.inspector&&(this.inspectorPort=this.configuration.inspector.split(":")[1]),this.api.t.on(this.callsign,"urlchange",t=>{t.url&&t.loaded&&(this._url=t.url,!0===this.rendered&&this.update())}),this.api.t.on(this.callsign,"visibilitychange",t=>{"boolean"==typeof t.hidden&&(this._isHidden=t.hidden,!0===this.rendered&&this.update())}),this.api.t.on(this.callsign,"statechange",t=>{"boolean"==typeof t.suspended&&(this._isSuspended=t.suspended,!0===this.rendered&&this.update())}),this.api.getControllerPlugins().then(t=>{let e=t.filter(t=>"Monitor"===t.callsign);void 0!==e&&(this.monitor=new u(e,this.api))})}status(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"state"};return this.api.req(t,e)}fps(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"fps"};return this.api.req(t,e)}url(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"url"};return this.api.req(t,e)}render(){var t=document.getElementById("main"),e=this.template.replace(/{{callsign}}/g,this.callsign);t.innerHTML=e,document.getElementById(this.callsign+"_url").value=this.lastSetUrl,document.getElementById(this.callsign+"_button").onclick=this.getAndSetUrl.bind(this),document.getElementById(this.callsign+"_reloadbutton").onclick=this.reloadUrl.bind(this),document.getElementById(this.callsign+"_linkPresets").onchange=this.getAndSetUrlFromPresets.bind(this);var n=document.getElementById(this.callsign+"_linkPresets");if(0===n.children.length)for(var i=0;i{t._isSuspended=e.suspended?e.suspended:"suspended"===e}).then(this.fps.bind(this)).then(e=>{t._fps=e.fps?e.fps:e}).then(this.url.bind(this)).then(e=>{t._url=e.url?e.url:e}).then(this.update.bind(this))}close(){window.removeEventListener("keydown",this.handleKey.bind(this),!1),clearInterval(this.updateLoopInterval),delete this.updateLoopInterval,this.rendered=!1}update(){document.getElementById(this.callsign+"_current_url").innerHTML=this._url,document.getElementById(this.callsign+"_fps").innerHTML=this._fps;var t=this._isSuspended?"Suspended":"Resumed",e=this._isSuspended?"Resume":"Suspend";document.getElementById(this.callsign+"StateInfo").innerHTML=t;var n=document.getElementById(this.callsign+"SuspendButton");n.innerHTML=e.toUpperCase(),n.onclick=this.toggleSuspend.bind(this,e),this.monitor&&this.monitor.getMonitorDataAndDiv().then(t=>{var e=document.getElementById(this.callsign+"Memory");e.innerHTML="",e.appendChild(t)})}setUrl(t){if(""===t)return;console.log("Setting url "+t+" for "+this.callsign);var e={url:t};const n={method:"POST",path:this.callsign+"/URL",body:e},i={plugin:this.callsign,method:"url",params:t};this.api.req(n,i),document.getElementById(this.callsign+"_linkPresets").selectedIndex=0}getAndSetUrl(){this.lastSetUrl=document.getElementById(this.callsign+"_url").value,this.setUrl(this.lastSetUrl),window.localStorage.setItem(this.lastSetUrlKey,this.lastSetUrl)}reloadUrl(){this.setUrl(this.callsign,document.getElementById(this.callsign+"_current_url").innerHTML)}getAndSetUrlFromPresets(){var t=document.getElementById(this.callsign+"_linkPresets").selectedIndex;t>0&&this.setUrl(this.presets[t].URL)}handleKey(t){var e=document.getElementById("WebKitBrowser_url");13===t.which&&e&&e===document.activeElement&&this.getAndSetUrl()}toggleSuspend(t){"Resume"===t?this.resume():this.suspend()}launchWebinspector(){var t="http://"+this.api.host[0]+":"+this.inspectorPort;window.open(t,"_blank").focus()}};var g=class extends c{constructor(t,e){super(t,e),this.monitor=void 0,this.api.t.on("Netflix","visibilitychange",t=>{"boolean"==typeof t.hidden&&(this.isHidden=t.hidden,!0===this.rendered&&this.update())}),this.api.t.on("Netflix","statechange",t=>{"boolean"==typeof t.suspended&&(this.isSuspended=t.suspended,!0===this.rendered&&this.update())}),this.api.getControllerPlugins().then(t=>{let e=t.filter(t=>"Monitor"===t.callsign);void 0!==e&&(this.monitor=new u(e,this.api))})}render(){document.getElementById("main").innerHTML='
    \n ESN\n
    \n\n
    \n ID\n
    \n
    \n -\n
    \n\n
    \n
    \n
    \n
    Memory
    \n
    Current State
    \n
    \n
    \n
    \n \n
    \n
    \n
    ',this.interval=setInterval(this.update.bind(this),conf.refresh_interval),this.update()}update(t){this.status().then(t=>{t.esn&&(document.getElementById("netflix-esn").innerHTML=t.esn);var e=t.suspended?"Suspended":"Resumed";document.getElementById("NetflixStateInfo").innerHTML=e;var n="Suspend";!0===t.suspended&&(n="Resume");var i=document.getElementById("NetflixSuspendButton");i.innerHTML=n.toUpperCase(),i.onclick=this.toggleSuspend.bind(this,n),this.monitor&&this.monitor.getMonitorDataAndDiv().then(t=>{var e=document.getElementById(this.callsign+"Memory");e.innerHTML="",e.appendChild(t)})})}close(){clearInterval(this.interval)}toggleSuspend(t){var e=this;"Resume"===t?this.resume().then(()=>{e.update({suspended:!1})}).catch(t=>{e.render()}):this.suspend().then(()=>{e.update({suspended:!0})}).catch(t=>{e.render()})}};var p={BluetoothControl:class extends c{constructor(t,e){super(t,e),this._devices=[],this.scanning=!1,this.displayName="BluetoothControl"}render(){document.getElementById("main").innerHTML='\n
    \n Status\n
    \n\n
    \n Devices\n
    \n
    \n \n
    \n
    \n Scanning\n
    \n
    \n OFF\n
    \n\n
    \n Device\n
    \n
    \n Name\n
    \n
    \n -\n
    \n
    \n Type\n
    \n
    \n -\n
    \n
    \n Connected\n
    \n
    \n -\n
    \n
    \n Paired\n
    \n
    \n -\n
    \n\n
    Controls
    \n
    \n \n \n \n \n
    \n\n
    Remote
    \n
    \n \n \n
    \n\n
    \n Discovery\n
    \n
    \n \n
    \n
    \n \n
    \n
    \n BlueTooth Low Energy\n
    \n
    \n
    \n \n \n
    \n
    \n\n
    \n\n
    \n ',this.scanButton=document.getElementById("BT_ScanForDevices"),this.pairButton=document.getElementById("BT_Pair"),this.unpairButton=document.getElementById("BT_Unpair"),this.connectButton=document.getElementById("BT_Connect"),this.disconnectButton=document.getElementById("BT_Disconnect"),this.btLowEnergyButton=document.getElementById("BT_LE"),this.assignButton=document.getElementById("BT_Assign"),this.revokeButton=document.getElementById("BT_Revoke"),this.deviceList=document.getElementById("BT_Devices"),this.deviceList.onchange=this.renderDevice.bind(this),this.scanButton.onclick=this.scanForDevices.bind(this),this.pairButton.onclick=this.pairDevice.bind(this),this.unpairButton.onclick=this.unpairDevice.bind(this),this.disconnectButton.onclick=this.disconnect.bind(this),this.connectButton.onclick=this.connect.bind(this),this.assignButton.onclick=this.assign.bind(this),this.revokeButton.onclick=this.revoke.bind(this),this.nameEl=document.getElementById("BT_Name"),this.typeEl=document.getElementById("BT_Type"),this.connectedEl=document.getElementById("BT_Connected"),this.pairedEl=document.getElementById("BT_Paired"),this.scanningStatus=document.getElementById("BT_Scanning"),this.statusMessages=document.getElementById("statusMessages"),this.deviceList=document.getElementById("BT_Devices"),this.api.t.on("BluetoothControl","scancomplete",this.scanComplete.bind(this)),this.api.t.on("BluetoothControl","devicestatechange",this.render.bind(this)),this.update()}devices(){return this.api.req(null,{plugin:"BluetoothControl",method:"devices"}).then(t=>{if(void 0!==t)return this._devices=[],t&&t.length&&t.forEach(t=>{this._devices.push({address:t})}),this._devices})}device(t){const e={plugin:"BluetoothControl",method:"device@"+t};return this.api.req(null,e)}scanComplete(){this.scanning=!1,this.renderScanStatus(),this.update(),this.updateStatus("Scan complete")}renderScanStatus(){this.scanningStatus.innerHTML=!0===this.scanning?"ON":"OFF"}updateDeviceList(){this.deviceList.innerHTML="",this._devices&&this._devices.length&&(this._devices.forEach(t=>{this.deviceList.appendChild(document.createElement("option")).innerHTML=t.address}),this.renderDevice())}renderDevice(){let t=this.deviceList.selectedIndex;if(-1===t||0===this._devices.length)return;let e=this._devices[t].address;this.device(e).then(n=>{n&&(this._devices[t]={address:e,...n}),this.nameEl.innerHTML=this._devices[t].name,this.typeEl.innerHTML=this._devices[t].type,this.connectedEl.innerHTML=this._devices[t].connected,this.pairedEl.innerHTML=this._devices[t].paired})}updateStatus(t){window.clearTimeout(this.statusMessageTimer),this.statusMessages.innerHTML=t,this.statusMessageTimer=setTimeout(this.updateStatus,5e3,"")}update(){this.renderScanStatus(),this.devices().then(()=>{this.updateDeviceList()})}scanForDevices(){this.updateStatus("Start scanning"),this.scanning=!0,this.renderScanStatus();const t={method:"PUT",path:"/Scan/?LowEnergy="+this.btLowEnergyButton.checked,body:null},e={plugin:"BluetoothControl",method:"scan",params:{type:this.btLowEnergyButton.checked?"LowEnergy":"Regular",timeout:10}};this.api.req(t,e)}pairDevice(){var t=this.deviceList.selectedIndex;this.updateStatus(`Pairing to ${this._devices[t].name}`);const e={method:"PUT",path:"/Pair",body:'{"address" : "'+this._devices[t].address+'"}'},n={plugin:this.callsign,method:"pair",params:{address:this._devices[t].address}};this.api.req(e,n)}unpairDevice(){var t=this.deviceList.selectedIndex;this.updateStatus(`Unpairing ${this._devices[t].name}`);const e={method:"PUT",path:"/Unpair",body:'{"address" : "'+this._devices[t].address+'"}'},n={plugin:this.callsign,method:"unpair",params:{address:this._devices[t].address}};this.api.req(e,n)}connect(){var t=this.deviceList.selectedIndex;this.updateStatus(`Connecting to ${this._devices[t].name}`);const e={method:"PUT",path:"/Connect",body:'{"address" : "'+this._devices[t].address+'"}'},n={plugin:this.callsign,method:"connect",params:{address:this._devices[t].address}};this.api.req(e,n)}disconnect(){var t=this.deviceList.selectedIndex;this.updateStatus(`Disconnecting from ${this._devices[t].name}`);const e={method:"DELETE",path:"/Connect",body:'{"address" : "'+this._devices[t].address+'"}'},n={plugin:this.callsign,method:"disconnect",params:{address:this._devices[t].address}};this.api.req(e,n)}assign(){var t=this.deviceList.selectedIndex;this.updateStatus(`Assigning ${this._devices[t].name}`);const e={plugin:"BluetoothRemoteControl",method:"assign",params:{address:this._devices[t].address}};this.api.req(null,e)}revoke(){var t=this.deviceList.selectedIndex;this.updateStatus(`Revoking ${this._devices[t].name}`);const e={plugin:"BluetoothRemoteControl",method:"revoke",params:{address:this._devices[t].address}};this.api.req(null,e)}close(){clearInterval(this.statusMessageTimer)}},Cobalt:class extends h{constructor(t,e){super(t,e),this.template='
    \n\n
    Presets / URL
    \n\n
    URL
    \n
    -
    \n\n
    \n \n
    \n
    \n \n \n \n
    \n\n
    URL presets
    \n
    \n \n
    \n\n
    Performance
    \n
    FPS
    \n
    -
    \n
    \n\n
    Tools
    \n\n
    Current State
    \n
    \n
    \n
    \n \n
    \n\n
    Visibility
    \n
    \n
    \n
    \n \n
    \n\n
    \n
    Web Inspector
    \n
    \n \n
    \n
    \n\n
    '}},Compositor:class extends c{constructor(t,e){super(t,e),this._rpcMapping={Top:"putontop"},this.resolutions=["720p","720p50Hz","1080p24Hz","1080i50Hz","1080p50Hz","1080p60Hz"]}render(){document.getElementById("main").innerHTML='
    \n Compositor\n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n\n
    ',document.getElementById("compositorResolutions").onclick=this.setResolution.bind(this),this.resolutionsList=document.getElementById("compositorResolutions"),this.menu=document.getElementById("compositorClients"),this.controlDiv=document.getElementById("controls"),this.compositorClientsDiv=document.getElementById("compositorClientsDiv"),this.controlDiv.style.display="none",this.resolutionsList.innerHTML="";for(var t=0;t{null!=t&&Array.isArray(t)?t.length>0&&this.renderControls(t):this.compositorClientsDiv.innerHTML="No clients found."})}getClients(){const t={method:"GET",path:`${this.callsign}/Clients`},e={plugin:this.callsign,method:"clients"};return this.api.req(t,e)}renderControls(t){this.controlDiv.innerHTML='
    \n Controls\n
    \n
    \n Focus\n
    \n
    \n \n
    \n
    \n
    \n Opacity\n
    \n
    \n \n \n
    \n
    \n
    \n \n
    \n
    \n Visibility\n
    \n
    \n \n \n
    \n
    \n
    \n Geometry\n
    \n
    \n X\n
    \n
    \n \n
    \n
    \n Y\n
    \n
    \n \n
    \n
    \n Width\n
    \n
    \n \n
    \n
    \n Height\n
    \n
    \n \n
    \n
    \n
    \n \n
    ',document.getElementById("compositorSetTop").onclick=this.compositorAction.bind(this,"Top"),document.getElementById("sliderOpacity").onchange=this.updateValue.bind(this,"sliderOpacity","numOpacity"),document.getElementById("numOpacity").onchange=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("numOpacity").onkeyup=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("numOpacity").onpaste=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("numOpacity").oninput=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("compositorSetOpacity").onclick=this.compositorSetOpacity.bind(this),document.getElementById("webkit_hide").onclick=this.compositorVisible.bind(this,"Hide"),document.getElementById("webkit_show").onclick=this.compositorVisible.bind(this,"Show"),document.getElementById("compositorGeometry").onclick=this.compositorSetGeometry.bind(this),document.getElementById("compositorClients").onchange=this.clientChange.bind(this);var e=document.getElementById("compositorClients");e.innerHTML="";var n=document.createElement("option");n.value="",n.setAttributeNode(document.createAttribute("disabled")),n.setAttributeNode(document.createAttribute("selected")),n.innerHTML="Select a client",e.appendChild(n);for(var i=0;i{void 0!==t.state&&!0===this.rendered&&this.render(),void 0!==t.suspended&&!0===this.rendered&&this.render()})}controllerStatus(t){const e={plugin:"Controller"};return e.method=t?`status@${t}`:"status",api.req(void 0,e)}harakiri(){const t={plugin:"Controller",method:"harakiri",params:{callsign:this.callsign}};return this.api.req({method:"PUT",path:"Controller/Harakiri",body:null},t)}initiateDiscovery(){return this.api.req({method:"PUT",path:"Controller/Discovery",body:null},{plugin:"Controller",method:"startdiscovery",params:{ttl:1}})}getDiscovery(){return this.api.req({method:"GET",path:"Controller/Discovery",body:null},{plugin:"Controller",method:"discoveryresults"})}persist(t){return this.api.req({method:"PUT",path:"Controller/Persist",body:null},{plugin:"Controller",method:"storeconfig"})}toggleActivity(t){for(var e,n=0;n{void 0!==plugins[t]&&(plugins[t].state="activated"),e.state="activated"}).catch(t=>{this.render()})):(console.debug("Deactivating "+t),this.deactivate(t).then(n=>{void 0!==plugins[t]&&(plugins[t].state="deactivated"),e.state="deactivated"}).catch(t=>{this.render()}))}toggleSuspend(t){for(var e,n=0;n{void 0!==plugins[t]&&(plugins[t].state="activated"),!1===document.getElementById(t+"suspend").checked?this.resume(t).then(this.render.bind(this)):api.suspendPlugin(t).then(this.render.bind(this))});"resumed"===e.state?(console.debug("Suspending "+t),this.suspend(t).then(n=>{this.updateSuspendLabel(t,"resume"),void 0!==plugins[t]&&(plugins[t].state="resumed"),document.getElementById(t+"suspend").checked=!0,e.state="suspended"})):(console.debug("Resuming "+t),this.resume(t).then(n=>{this.updateSuspendLabel(t,"suspend"),void 0!==plugins[t]&&(plugins[t].state="suspended"),document.getElementById(t+"suspend").checked=!1,e.state="resumed"}))}clear(){this.mainDiv.innerHTML=""}discover(){console.log("Initiating discovery"),this.initiateDiscovery();let t=this;setTimeout(function(){t.getDiscovery().then(t=>{var e=t.bridges?t.bridges:t,n=document.getElementById("discoveryList");n.innerHTML="";for(var i=0;i\n Plugins\n \n
    \n
    \n Device actions\n
    \n
    \n \n
    \n
    \n \n
    \n
    \n Discover devices\n
    \n
    \n \n
    \n
    \n
      \n
      \n \n ',document.getElementById("persistButton").onclick=this.persist.bind(this),document.getElementById("harakiriButton").onclick=this.harakiri.bind(this),document.getElementById("discoverButton").onclick=this.discover.bind(this);var t=document.getElementById("controllerPlugins");this.status().then(e=>{var n=e.plugins?e.plugins:e;this.plugins=n;for(var i=0;inew Promise((e,n)=>{this.deviceInfo().then(n=>{e({...t,...n})})}))}deviceInfo(){return this.api.req({method:"GET",path:"DeviceInfo"},{plugin:"DeviceInfo",method:"systeminfo"})}displayInfo(){return this.api.req({method:"GET",path:"DisplayInfo"},{plugin:"DisplayInfo",method:"displayinfo"})}addresses(){return this.api.req({method:"GET",path:"DeviceInfo"},{plugin:"DeviceInfo",method:"addresses"})}socketinfo(){return this.api.req({method:"GET",path:"DeviceInfo"},{plugin:"DeviceInfo",method:"socketinfo"})}update(){this.deviceInfo().then(t=>{let e=t.systeminfo?t.systeminfo:t;this.deviceNameEl.innerHTML=e.devicename,this.serialNumberEl.innerHTML=e.serialnumber,this.versionEl.innerHTML=e.version,this.uptimeEl.innerHTML=e.uptime,this.totalRamEl.innerHTML=this.bytesToMbString(e.totalram),this.usedRamEl.innerHTML=this.bytesToMbString(e.totalram-e.freeram),this.freeRamEl.innerHTML=this.bytesToMbString(e.freeram),this.cpuLoadEl.innerHTML=parseFloat(e.cpuload).toFixed(1)+" %",this.addresses().then(t=>{let e=t.addresses?t.addresses:t;this.interfacesOptsEl.innerHTML="";for(var n=0;n{this.totalGpuRamEl.innerHTML=this.bytesToMbString(t.totalgpuram),this.freeGpuRamEl.innerHTML=this.bytesToMbString(t.freegpuram),this.usedGpuRamEl.innerHTML=this.bytesToMbString(t.totalgpuram-t.freegpuram)}),document.getElementById("startGraphs").onclick=this.startRealtimeGraphs.bind(this)}render(){this.mainDiv.innerHTML=this.template,this.deviceNameEl=document.getElementById("DeviceName"),this.serialNumberEl=document.getElementById("SerialNumber"),this.versionEl=document.getElementById("Version"),this.uptimeEl=document.getElementById("Uptime"),this.totalRamEl=document.getElementById("TotalRam"),this.usedRamEl=document.getElementById("UsedRam"),this.freeRamEl=document.getElementById("FreeRam"),this.totalGpuRamEl=document.getElementById("TotalGpuRam"),this.freeGpuRamEl=document.getElementById("FreeGpuRam"),this.usedGpuRamEl=document.getElementById("UsedGpuRam"),this.cpuLoadEl=document.getElementById("CpuLoad"),this.interfacesOptsEl=document.getElementById("NetworkInterface"),this.interfacesOptsEl.onchange=this.updateNetworkInterface.bind(this),this.macIdEl=document.getElementById("MAC_ID"),this.ipAddressEl=document.getElementById("IpAddress"),this.update()}startRealtimeGraphs(){this.chartOptions.maxElements=parseInt(document.getElementById("graph_max_elements").value),this.chartOptions.interval=parseInt(document.getElementById("graph_poll_interval").value),this.cpuChart=this.generateGraph("CPU usage",document.getElementById("graph_cpu").getContext("2d"),"#34c749","%"),this.ramChart=this.generateGraph("RAM used",document.getElementById("graph_ram").getContext("2d"),"#fc5652","MB"),this.gpuChart=this.generateGraph("GPU RAM used",document.getElementById("graph_gpu").getContext("2d"),"#fdbc40","MB"),this.chartIntervalId=setInterval(this.updateGraphs.bind(this),this.chartOptions.interval),document.getElementById("graphs").style.display="block"}generateGraph(t,e,n,i){return new Chart(e,{type:"line",data:{labels:[],datasets:[{label:t,backgroundColor:n,borderColor:n,data:[],fill:!1}]},options:{responsive:!1,scales:{yAxes:[{ticks:{callback:function(t,e,n){return t+i}}}]}}})}updateGraphs(){let t=this;const e=t.getTimestampForGraph();this.deviceInfo().then(n=>{t.ramChart&&(t.ramChart.config.data.labels.push(e),t.ramChart.config.data.datasets[0].data.push((n.totalram-n.freeram)/1024/1024),t.ramChart.config.data.labels.length>t.chartOptions.maxElements&&(t.ramChart.config.data.labels.shift(),t.ramChart.config.data.datasets[0].data.shift()),t.ramChart.update()),t.cpuChart&&(t.cpuChart.config.data.labels.push(e),t.cpuChart.config.data.datasets[0].data.push(parseFloat(n.cpuload).toFixed(1)),t.cpuChart.config.data.labels.length>t.chartOptions.maxElements&&(t.cpuChart.config.data.labels.shift(),t.cpuChart.config.data.datasets[0].data.shift()),t.cpuChart.update())}),this.displayInfo().then(n=>{t.gpuChart&&(t.gpuChart.config.data.labels.push(e),t.gpuChart.config.data.datasets[0].data.push((n.totalgpuram-n.freegpuram)/1024/1024),t.gpuChart.config.data.labels.length>t.chartOptions.maxElements&&(t.gpuChart.config.data.labels.shift(),t.gpuChart.config.data.datasets[0].data.shift()),t.gpuChart.update())})}close(){clearInterval(this.chartIntervalId),delete this.ramChart,delete this.cpuChart,delete this.gpuChart}updateNetworkInterface(t){this.selectedNetworkInterface=this.interfacesOptsEl.selectedIndex,this.update()}bytesToMbString(t){return(t/1024/1024).toFixed(1)+" MB"}getTimestampForGraph(){const t=new Date;return`${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}`}},DialServer:class extends c{constructor(t,e){super(t,e),this.api.t.on("DIALServer","start",t=>{this.dialMessage("start",t)}),this.api.t.on("DIALServer","stop",t=>{this.dialMessage("stop",t)})}render(){document.getElementById("main").innerHTML='
      \n Received DIAL requests:\n
      \n\n
      ',this.statusMessagesEl=document.getElementById("statusMessages")}dialMessage(t,e){let n=document.createElement("div");"stop"===t&&(n.className="red");let i=document.createElement("span");i.innerHTML=`${t} :: ${e.application} - ${e.parameters}`,n.appendChild(i),this.statusMessagesEl.appendChild(n)}},LocationSync:class extends c{constructor(t,e){super(t,e),this.renderInMenu=!0,this.displayName="Location"}render(){document.getElementById("main").innerHTML='
      \n Location\n
      \n\n
      \n City\n
      \n
      \n -\n
      \n
      \n Country\n
      \n
      \n -\n
      \n
      \n Region\n
      \n
      \n -\n
      \n\n
      \n Timezone\n
      \n
      \n -\n
      \n\n
      \n Public IP\n
      \n
      \n -\n
      \n\n
      \n Sync\n
      \n
      \n \n
      ',document.getElementById("syncButton").onclick=this.syncLocation.bind(this),this.cityEl=document.getElementById("city"),this.countryEl=document.getElementById("country"),this.regionEl=document.getElementById("region"),this.timezoneEl=document.getElementById("timezone"),this.publicIpEl=document.getElementById("publicip"),this.update()}syncLocation(){const t={method:"PUT",path:`${this.callsign}`},e={plugin:this.callsign,method:"sync"};this.api.req(t,e).then(()=>{this.update()})}location(){const t={method:"GET",path:`${this.callsign}`},e={plugin:this.callsign,method:"location"};return this.api.req(t,e)}update(){this.location().then(t=>{this.cityEl.innerHTML=t.city,this.countryEl.innerHTML=t.country,this.regionEl.innerHTML=t.region,this.timezoneEl.innerHTML=t.timezone,this.publicIpEl.innerHTML=t.publicip})}},Monitor:u,Netflix:g,NetworkControl:class extends c{constructor(t,e){super(t,e),this.renderInMenu=!0,this.displayName="Network",this.selectedNetworkInterface=0,this.networks=[]}render(){document.getElementById("main").innerHTML='\n
      \n Network Control\n
      \n
      \n Network Interface\n
      \n
      \n \n
      \n
      \n IP Address\n
      \n
      \n -\n
      \n
      \n Broadcast\n
      \n
      \n -\n
      \n
      \n Gateway\n
      \n
      \n -\n
      \n
      \n mask\n
      \n
      \n -\n
      \n
      \n mode\n
      \n
      \n -\n
      \n\n
      \n Control\n
      \n
      \n \n \n \n \n
      ',this.interfacesOptsEl=document.getElementById("NetworkInterface"),this.interfacesOptsEl.onchange=this.updateNetworkInterface.bind(this),document.getElementById("reload").onclick=this.reload.bind(this);document.getElementById("request");request.onclick=this.request.bind(this),document.getElementById("assign").onclick=this.assign.bind(this),document.getElementById("flush").onclick=this.flush.bind(this),this.ipEl=document.getElementById("ip"),this.broadcastEl=document.getElementById("broadcast"),this.gatewayEl=document.getElementById("gateway"),this.maskEl=document.getElementById("mask"),this.modeEl=document.getElementById("mode"),this.api.t.on("NetworkControl","networkupdate",t=>{console.log("NETWORK NOT",t),this.update()}),this.update()}network(){const t={method:"GET",path:`${this.callsign}`},e={plugin:this.callsign,method:"network"};return this.api.req(t,e)}reload(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Reload`},n={plugin:this.callsign,method:"reload",params:{device:t}};return this.api.req(e,n)}request(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Request`},n={plugin:this.callsign,method:"request",params:{device:t}};return this.api.req(e,n)}assign(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Assign`},n={plugin:this.callsign,method:"assign",params:{device:t}};return this.api.req(e,n)}flush(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Flush`},n={plugin:this.callsign,method:"flush",params:{device:t}};return this.api.req(e,n)}update(){this.network().then(t=>{let e=t.addresses?t.addresses:t;this._addresses=e,this.interfacesOptsEl.innerHTML="";for(var n=0;n{if(null==t)return;let e=t.systems?t.systems:t;for(let t=0;t{void 0!==t.PowerState&&(this.powerStateDiv.innerHTML=this.stateLookup[t.PowerState],this.stateSelectorEl.children[t.PowerState-1].selected=!0)})}changeState(t){const e={method:"POST",path:`${this.callsign}/State`,body:{PowerState:this.stateSelectorEl.value}},n={plugin:this.callsign,method:"state",params:{powerstate:this.stateSelectorEl.value}};""!==this.timeoutInput.value&&(e.body.Timeout=this.timeoutInput.value,n.body.timeout=this.timeoutInput.value),this.api.req(e).then(()=>{t<2&&setTimeout(this.update,5e3)})}},Provisioning:class extends c{constructor(t,e){super(t,e)}render(){document.getElementById("main").innerHTML='
      \n Provisioning status\n
      \n\n
      \n Device\n
      \n
      \n -\n
      \n
      \n Provisioned for\n
      \n
      \n -\n
      \n
      \n Status\n
      \n
      \n -\n
      \n\n
      \n Provisioning\n
      \n
      \n \n
      ',document.getElementById("provisionButton").onclick=this.tiggerProvisioningRequest.bind(this),this.update()}triggerProvisioning(){const t={method:"PUT",path:`${this.callsign}`},e={plugin:this.callsign,method:"provision"};return this.api.req(t,e)}status(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"state"};return this.api.req(t,e)}update(){this.status().then(t=>{if(null!=t&&""!==t){var e=t.id,n=t.tokens||[],i=t.status;document.getElementById("device").innerHTML=e,document.getElementById("status").innerHTML=200==i?"provisioned":"not provisioned",200==i&&n.length>0&&(document.getElementById("provisioning-tokens").innerHTML=n.join(", ")),document.getElementById("provisionLabel").style.display=200==i?"none":null}}).catch(t=>{console.error(t),this.status(t)})}tiggerProvisioningRequest(){var t=this;this.triggerProvisioning().then(e=>{document.getElementById("provisionButton").style.display="none",document.getElementById("provisionLabel").style.display="none",setTimeout(t.update(),3e3)})}},RemoteControl:class extends c{constructor(t,e){super(t,e),this.displayName="Remote Control",this.onScreenKeyBoardIsRendered=!1,this.doNotHandleKeys=!1,this.devicesThatSupportPairing=["GreenPeakRF4CE","GreenPeak","RF4CE"],this.autoFwdKeys=window.localStorage.getItem("autoFwdKeys"),this.automaticallyForwardKeys="false"!==this.autoFwdKeys,this.keyMapping={1:{code:"0x0021",color:void 0,string:"1"},2:{code:"0x0022",color:void 0,string:"2"},3:{code:"0x0023",color:void 0,string:"3"},4:{code:"0x0024",color:void 0,string:"4"},5:{code:"0x0025",color:void 0,string:"5"},6:{code:"0x0026",color:void 0,string:"6"},7:{code:"0x0027",color:void 0,string:"7"},8:{code:"0x0028",color:void 0,string:"8"},9:{code:"0x0029",color:void 0,string:"9"},0:{code:"0x0020",color:void 0,string:"0"},exit:{code:"0x0009",color:"blue",string:"exit"},a:{code:"0x8004",color:void 0,string:"a"},b:{code:"0x8005",color:void 0,string:"b"},c:{code:"0x8006",color:void 0,string:"c"},d:{code:"0x8007",color:void 0,string:"d"},e:{code:"0x8008",color:void 0,string:"e"},f:{code:"0x8009",color:void 0,string:"f"},g:{code:"0x800A",color:void 0,string:"g"},h:{code:"0x800B",color:void 0,string:"h"},i:{code:"0x800C",color:void 0,string:"i"},back:{code:"0x0032",color:"blue double",string:"back"},j:{code:"0x800D",color:void 0,string:"j"},k:{code:"0x800E",color:void 0,string:"k"},l:{code:"0x800F",color:void 0,string:"l"},m:{code:"0x8010",color:void 0,string:"m"},n:{code:"0x8011",color:void 0,string:"n"},o:{code:"0x8012",color:void 0,string:"o"},p:{code:"0x8013",color:void 0,string:"p"},q:{code:"0x8014",color:void 0,string:"q"},r:{code:"0x8015",color:void 0,string:"r"},up:{code:"0x0001",color:"blue",string:"up",div:'
      '},ok:{code:"0x002B",color:"blue",string:"ok"},s:{code:"0x8016",color:void 0,string:"s"},t:{code:"0x8017",color:void 0,string:"t"},u:{code:"0x8018",color:void 0,string:"u"},v:{code:"0x8019",color:void 0,string:"v"},w:{code:"0x801A",color:void 0,string:"w"},x:{code:"0x801B",color:void 0,string:"x"},y:{code:"0x801C",color:void 0,string:"y"},z:{code:"0x801D",color:void 0,string:"z"},left:{code:"0x0003",color:"blue",string:"left",div:'
      '},down:{code:"0x0002",color:"blue",string:"down",div:'
      '},right:{code:"0x0004",color:"blue",string:"right",div:'
      '}},this.jsToWpeKeyMap={13:{code:"0x002B",string:"enter"},37:{code:"0x0003",string:"left"},38:{code:"0x0001",string:"up"},39:{code:"0x0004",string:"right"},40:{code:"0x0002",string:"down"},27:{code:"0x0009",string:"esc"},8:{code:"0x0032",string:"backspace"},48:{code:"0x0020",string:"0"},49:{code:"0x0021",string:"1"},50:{code:"0x0022",string:"2"},51:{code:"0x0023",string:"3"},52:{code:"0x0024",string:"4"},53:{code:"0x0025",string:"5"},54:{code:"0x0026",string:"6"},55:{code:"0x0027",string:"7"},56:{code:"0x0028",string:"8"},57:{code:"0x0029",string:"9"},33:{code:"0x0030",string:"page up"},34:{code:"0x0031",string:"page down"},65:{code:"0x8004",string:"a"},66:{code:"0x8005",string:"b"},67:{code:"0x8006",string:"c"},68:{code:"0x8007",string:"d"},69:{code:"0x8008",string:"e"},70:{code:"0x8009",string:"f"},71:{code:"0x800A",string:"g"},72:{code:"0x800B",string:"h"},73:{code:"0x800C",string:"i"},74:{code:"0x800D",string:"j"},75:{code:"0x800E",string:"k"},76:{code:"0x800F",string:"l"},77:{code:"0x8010",string:"m"},78:{code:"0x8011",string:"n"},79:{code:"0x8012",string:"o"},80:{code:"0x8013",string:"p"},81:{code:"0x8014",string:"q"},82:{code:"0x8015",string:"r"},83:{code:"0x8016",string:"s"},84:{code:"0x8017",string:"t"},85:{code:"0x8018",string:"u"},86:{code:"0x8019",string:"v"},87:{code:"0x801A",string:"w"},88:{code:"0x801B",string:"x"},89:{code:"0x801C",string:"y"},90:{code:"0x801D",string:"z"},46:{code:"0x802A",string:"delete"},32:{code:"0x802C",string:"space"},189:{code:"0x802D",string:"-"},187:{code:"0x802E",string:"="},220:{code:"0x8031",string:"\\"},186:{code:"0x8033",string:";"},222:{code:"0x8034",string:"`"},188:{code:"0x8036",string:","},190:{code:"0x8037",string:"."},191:{code:"0x8038",string:"/"}},this.addKeyboardButton(),this.keyboardDiv=document.getElementById("keyboard"),this.keyBoardInnerDiv=document.createElement("div"),this.keyBoardInnerDiv.id="keyboard-inner";for(var n=Object.keys(this.keyMapping),i=0;i{if(void 0!==e)for(var n=void 0!==e.devices?e.devices:e,i=document.getElementById("remotesList"),s=document.getElementById("pairingDiv"),o=0;o\n Pairing\n '),s.innerHTML+=`
      ${l}
      \n
      \n \n
      `,document.getElementById(l+"-PairingMode").onclick=t.activatePairing.bind(t,l)}})}toggleAutoforwardOfKeys(){this.automaticallyForwardKeys=!0!==this.automaticallyForwardKeys,window.localStorage.setItem("autoFwdKeys",this.automaticallyForwardKeys)}},Snapshot:class extends c{constructor(t,e){super(t,e)}render(){document.getElementById("main").innerHTML='
      \n Create\n
      \n\n
      \n Snapshot\n
      \n
      \n \n
      \n\n
      \n \n
      ',document.getElementById("snapshotButton").onclick=this.createSnapshot.bind(this)}getSnapshotLocator(){return this.api.getURLStart("http")+"Snapshot/Capture?"+(new Date).getTime()}createSnapshot(){var t=document.getElementById("snapshotOutput");t.src="",t.src=this.getSnapshotLocator()}},Spark:class extends c{constructor(t,e){super(t,e),this.url="",this.isHidden=!1,this.isSuspended=!1,this.lastSetUrlKey="lastSetUrl"+this.callsign,this.lastSetUrl=window.localStorage.getItem(this.lastSetUrlKey)||"",this.template='
      \n\n
      Presets / URL
      \n\n
      \n \n
      \n
      \n \n \n
      \n\n
      URL presets
      \n
      \n \n
      \n\n
      Tools
      \n\n
      Current State
      \n
      \n
      \n
      \n \n
      \n\n
      Visibility
      \n
      \n
      \n
      \n \n
      \n
      ',this.presets=[{Name:"Select a preset",URL:""},{Name:"http://www.sparkui.org/examples/gallery/picturepile.js",URL:"http://www.sparkui.org/examples/gallery/picturepile.js"},{Name:"http://www.sparkui.org/examples/gallery/gallery.js",URL:"http://www.sparkui.org/examples/gallery/gallery.js"}],this.api.t.on("Spark","urlchange",t=>{t.url&&t.loaded&&(this.url=t.url,this.handleNotification())}),this.api.t.on("Spark","visibilitychange",t=>{"boolean"==typeof t.hidden&&(this.isHidden=t.hidden,this.handleNotification())}),this.api.t.on("Spark","statechange",t=>{"boolean"==typeof t.suspended&&(this.isSuspended=t.suspended,this.handleNotification())})}handleNotification(t){!1!==this.rendered&&this.update()}render(){var t=document.getElementById("main"),e=this.template.replace(/{{callsign}}/g,this.callsign);t.innerHTML=e,document.getElementById(this.callsign+"_url").value=this.lastSetUrl,document.getElementById(this.callsign+"_button").onclick=this.getAndSetUrl.bind(this),document.getElementById(this.callsign+"_linkPresets").onchange=this.getAndSetUrlFromPresets.bind(this);var n=document.getElementById(this.callsign+"_linkPresets");if(0===n.children.length)for(var i=0;i0&&this.setUrl(this.presets[t].URL)}handleKey(t){var e=document.getElementById(`${this.callsign}_url`);13===t.which&&e&&e===document.activeElement&&this.getAndSetUrl()}toggleSuspend(t){"Resume"===t?this.resume():this.suspend()}toggleVisibility(t){"Show"===t?this.show():this.hide()}},Switchboard:class extends c{constructor(t,e){super(t,e),this.defaultPlugin=void 0,this.switchablePlugins=[],this.state().then(t=>{this.defaultPlugin=t.default,this.switchablePlugins=t.callsigns})}state(){const t={method:"GET",path:`${this.callsign}/Switch`};return this.api.req(t)}getDefaultSwitchBoardPlugin(){return this.defaultPlugin}getSwitchablePlugins(){return this.switchBoardPlugins}render(){this.mainDiv=document.getElementById("main"),this.mainDiv.innerHTML='\n
      \n Plugins\n
      \n
      ';var t=document.getElementById("switchBoardPlugins");this.api.getControllerPlugins().then(e=>{for(var n=e.plugins,i=0;i{this.render()})}},TimeSync:class extends c{constructor(t,e){super(t,e),this.renderInMenu=!0,this.displayName="Time"}render(){document.getElementById("main").innerHTML='\n
      \n Time\n
      \n
      \n Current time\n
      \n
      \n -\n
      \n
      \n Source\n
      \n
      \n -\n
      \n
      \n Last synced\n
      \n
      \n -\n
      \n\n
      \n \n
      \n
      \n \n \n
      \n\n
      \n Control\n
      \n
      \n \n
      ',document.getElementById("setTime").onclick=this.setTime.bind(this),document.getElementById("sync").onclick=this.synchronizeTime.bind(this),this.timeEl=document.getElementById("time"),this.sourceEl=document.getElementById("source"),this.syncedEl=document.getElementById("synced"),this.api.t.on("TimeSync","update",t=>{console.log("TIME NOT",t),this.update()}),this.update()}synchronizeTime(){this.syncTime().then(this.synchronize())}synchronize(){const t={plugin:this.callsign,method:"synchronize"};return this.api.req(null,t)}syncTime(){const t={plugin:this.callsign,method:"synctime"};return this.api.req(null,t)}setTime(){let t=document.getElementById("timeinput").value;const e={method:"POST",path:`${this.callsign}`,body:{time:t}},n={plugin:this.callsign,method:"time",params:t};return this.api.req(e,n)}getTime(){const t={method:"GET",path:`${this.callsign}`},e={plugin:this.callsign,method:"time"};return this.api.req(t,e)}update(){this.getTime().then(t=>{this.timeEl.innerHTML=t,this.syncTime().then(t=>{this.sourceEl.innerHTML=t.source,this.syncedEl.innerHTML=t.time})})}},TraceControl:class extends c{constructor(t,e){super(t,e),this.displayName="Tracing",this.selectedTraceModule=void 0,this.traceModules=void 0,this.uniqueTraceModules=void 0}toggleTracing(t,e,n){const i={method:"PUT",path:"TraceControl/"+t+"/"+e+"/"+n},s={plugin:"TraceControl",method:"set",params:{module:t,category:e,state:"on"===n?"enabled":"disabled"}};return this.api.req(i,s)}render(){var t=this;document.getElementById("main").innerHTML='
      \n Modules\n
      \n\n
      \n \n
      \n
      \n \n
      \n\n
      ',document.getElementById("tracingModules").onchange=this.getSelectedModuleAndShowCategories.bind(this),this.status().then(e=>{t.traceModules=e.settings?e.settings:[],t.uniqueTraceModules=[];var n=document.getElementById("tracingModules");n.getElementsByTagName("options");if(n.options.length=0,void 0!==t.traceModules){for(var i=0;i{this.mutedEl.innerHTML=t}),this.volume().then(t=>{this.volumeEl.innerHTML=t})}muted(t){const e={plugin:this.callsign,method:"muted"};return t&&(e.params=t),this.api.req(null,e)}volume(t){const e={plugin:this.callsign,method:"volume"};return t&&(e.params=t),this.api.req(null,e)}volumeChange(t){this.volume().then(e=>{this.volume(e+t).then(this.update())})}mute(){this.muted().then(t=>{this.muted(!t).then(this.update())})}},WebKitBrowser:h,WebShell:class extends c{constructor(t,e){super(t,e),this.webShellSocket=void 0}render(){var t=this;document.getElementById("main").innerHTML='
      WebShell
      \n
      \n
      \n        
      \n
      #
      ',this.api.startWebShell(function(e,n){t.webShellSocket=n,t.webShellSocket.onmessage=function(t){var e=new FileReader;e.onload=function(){document.getElementById("webShellData").innerHTML=String.fromCharCode.apply(null,new Uint8Array(e.result))},e.readAsArrayBuffer(t.data)},t.webShellSocket.onclose=function(){t.webShellSocket=null,t.render()}}),void 0!==plugins.RemoteControl&&(plugins.RemoteControl.doNotHandleKeys=!0),window.addEventListener("keydown",this.handleKey.bind(this))}close(){void 0!==plugins.RemoteControl&&(plugins.RemoteControl.doNotHandleKeys=!1),window.removeEventListener("keydown",this.handleKey.bind(this),!1)}handleKey(t){if(this.webShellSocket&&13===t.which){for(var e=document.getElementById("webShellInput").value+" \n",n=new ArrayBuffer(2*e.length),i=new Uint8Array(n),s=0,o=e.length;s{!0===this.rendered&&this.getNetworks()}),this.api.t.on("WifiControl","connectionchange",t=>{this.connected=t.connected,!0===this.rendered&&this.update()})}render(){document.getElementById("main").innerHTML='
      \n Status\n
      \n\n
      \n Connected to\n
      \n
      \n\n
      \n Scanning\n
      \n
      \n False\n
      \n\n
      \n Wireless networks\n
      \n
      \n \n
      \n
      \n
      \n
      \n \n
      \n\n
      \n Configs\n
      \n\n
      \n Configs\n
      \n
      \n \n
      \n\n
      \n SSID\n
      \n
      \n \n
      \n
      \n Mode\n
      \n
      \n
      \n \x3c!-- disable for now\n
      \n
      \n \n
      \n --\x3e\n
      \n Hidden\n
      \n
      \n
      \n Method\n
      \n
      \n \n
      \n
      \n Password\n
      \n
      \n \n
      \n
      Controls
      \n
      \n \n \n \n
      \n
      \n
      \n \n \n
      \n\n
      \n
      \n ',this.scanButton=document.getElementById("Wifi_scanForNetworksButton"),this.saveButton=document.getElementById("Wifi_saveButton"),this.deleteButton=document.getElementById("Wifi_deleteButton"),this.storeButton=document.getElementById("Wifi_storeButton"),this.connectButton=document.getElementById("Wifi_connectButton"),this.disconnectButton=document.getElementById("Wifi_disconnectButton"),this.scanButton.onclick=this.scanForNetworks.bind(this),this.deleteButton.onclick=this.deleteConfig.bind(this),this.saveButton.onclick=this.saveConfig.bind(this),this.storeButton.onclick=this.storeConfig.bind(this),this.disconnectButton.onclick=this.disconnect.bind(this),this.connectButton.onclick=this.connect.bind(this),this.connectedStatus=document.getElementById("Wifi_Connected"),this.scanningStatus=document.getElementById("Wifi_Scanning"),this.statusMessages=document.getElementById("statusMessages"),this.networkListEl=document.getElementById("Wifi_WirelessNetwork"),this.networkListEl.onchange=this.renderNetworkDetails.bind(this),this.configListEl=document.getElementById("Wifi_Configs"),this.configListEl.onchange=this.renderConfigDetails.bind(this),this.ssidEl=document.getElementById("Wifi_SSID"),this.methodEl=document.getElementById("Wifi_Method"),this.passwordEl=document.getElementById("Wifi_Password"),this.accesspointEl=document.getElementById("Wifi_Mode"),this.hiddenEl=document.getElementById("Wifi_Hidden"),this.update(),setTimeout(this.getNetworks.bind(this),200),setTimeout(this.getConfigs.bind(this),400),this.rendered=!0}update(){this.status().then(t=>{void 0!==t&&(this.connected=t.connected,"boolean"==typeof t.scanning&&(this.scanning=t.scanning),this.renderStatus())})}scanForNetworks(){const t={method:"PUT",path:`${this.callsign}/Scan`},e={plugin:this.callsign,method:"scan"};this.api.req(t,e).then(t=>{this.update(),setTimeout(this.getNetworks.bind(this),5e3)})}getConfigs(){this.update();const t={method:"GET",path:`${this.callsign}/Configs`},e={plugin:this.callsign,method:"configs"};this.api.req(t,e).then(t=>{if(void 0===t)return;let e=t.configs?t.configs:t;if(void 0!==e){this.configs=e,this.configListEl.innerHTML="";for(var n=0;n{if(void 0===t)return;if(this.networks=[],!1===this.rendered)return;let e=t.networks?t.networks:t;this.networkListEl.innerHTML="";for(var n=0;n{this.statusMessage(`Saved config for ${this.ssidEl.value}`),t.getConfigs()})}deleteConfig(){var t=this.configListEl.selectedIndex;this.statusMessage(`Deleting config ${this.configs[t].ssid}`);const e={method:"PUT",path:`${this.callsign}/Delete/${this.configs[t].ssid}`},n={plugin:this.callsign,method:"delete",params:{ssid:this.configs[t].ssid}};this.api.req(e,n).then(()=>{this.connecting=!0,this.getConfigs()})}requestDHCP(){this.statusMessage("Requesting DHCP for wlan0");const t={method:"PUT",path:`NetworkControl/${this.wlanInterface}/Request`},e={plugin:"NetworkControl",method:"request",params:{device:this.wlanInterface}};this.api.req(t,e)}storeConfig(){this.statusMessage("Storing WiFi configuration");const t={method:"PUT",path:`${this.callsign}/${this.wlanInterface}/Store`},e={plugin:this.callsign,method:"store"};this.api.req(t,e)}connect(){var t=this.configListEl.selectedIndex;this.statusMessage(`Connecting to ${this.configs[t].ssid}`);const e={method:"PUT",path:`${this.callsign}/Connect/${this.configs[t].ssid}`},n={plugin:this.callsign,method:"connect",params:{ssid:this.configs[t].ssid}};this.api.req(e,n).then(()=>{this.connecting=!0,setTimeout(this.requestDHCP.bind(this),5e3)})}disconnect(){if(void 0===this.connected||""===this.connected)return;const t={method:"DELETE",path:`${this.callsign}/Connect/${this.connected}`},e={plugin:this.callsign,method:"disconnect",params:{ssid:this.connected}};this.statusMessage(`Disconnecting from ${this.connected}`),this.api.req(t,e)}close(){this.rendered=!1}}};n.d(e,"b",function(){return f}),n.d(e,"c",function(){return b}),n.d(e,"a",function(){return l});var m={},_=void 0,v=(document.getElementById("main"),window.localStorage.getItem("lastActivePlugin")||void 0);function f(t){(_=new o(t)).getControllerPlugins().then(t=>t).then(t=>{for(var e=0;e1)for(var n=1;n { + // bail out if the plugin returns nothing + if (devices === undefined) + return; + + this._devices = [] + if (devices && devices.length) + devices.forEach( (address) => { this._devices.push({ address : address }) }); + + return this._devices + }); } device(address) { @@ -182,61 +192,48 @@ class BluetoothControl extends Plugin { return this.api.req(null, _rpc) } - update() { + scanComplete() { this.scanning = false this.renderScanStatus() - - this.devices().then( devices => { - // bail out if the plugin returns nothing - if (devices === undefined) - return; - - this._devices = [] - this.deviceList.innerHTML = ''; - - - if (devices && devices.length){ - devices.forEach( (address) => { - this._devices.push({ address : address }) - var newDeviceChild = this.deviceList.appendChild(document.createElement("option")); - newDeviceChild.innerHTML = address - }); - - this.renderDevice() - } - }); + this.update() + this.updateStatus('Scan complete'); } - /* ----------------------------- RENDERING ------------------------------*/ renderScanStatus () { this.scanningStatus.innerHTML = this.scanning === true ? 'ON' : 'OFF'; } - renderDevice() { - var idx = this.deviceList.selectedIndex; + updateDeviceList() { + this.deviceList.innerHTML = ''; + + if (this._devices && this._devices.length){ + this._devices.forEach( (d) => { + var newDeviceChild = this.deviceList.appendChild(document.createElement("option")); + newDeviceChild.innerHTML = d.address + }); - if (this._devices[idx].name === undefined) { - let address = this._devices[idx].address - this.device(address).then( (data)=>{ - if (data) { - this._devices[idx] = { address, ...data } - this.updateDevice(idx) - } - }) - } else { - this.updateDevice[idx] + this.renderDevice() } } - updateDevice(idx) { - let device = this._devices[idx] + renderDevice() { + let idx = this.deviceList.selectedIndex; + if (idx === -1 || this._devices.length === 0) + return + - this.nameEl.innerHTML = device.name - this.typeEl.innerHTML = device.type - this.connectedEl.innerHTML = device.connected - this.pairedEl.innerHTML = device.paired + let address = this._devices[idx].address + this.device(address).then( (data)=>{ + if (data) + this._devices[idx] = { address, ...data } + + this.nameEl.innerHTML = this._devices[idx].name + this.typeEl.innerHTML = this._devices[idx].type + this.connectedEl.innerHTML = this._devices[idx].connected + this.pairedEl.innerHTML = this._devices[idx].paired + }) } updateStatus(message) { @@ -247,6 +244,13 @@ class BluetoothControl extends Plugin { this.statusMessageTimer = setTimeout(this.updateStatus, 5000, ''); } + update() { + this.renderScanStatus() + this.devices().then( () => { + this.updateDeviceList() + }) + } + /* ----------------------------- BUTTONS ------------------------------*/ scanForDevices() { @@ -347,7 +351,7 @@ class BluetoothControl extends Plugin { const _rpc = { plugin : this.callsign, - method : 'pair', + method : 'disconnect', params : { "address" : this._devices[idx].address } From bcaa5f82fbf5c346b13e14f55e0ab9d5ea10b6e2 Mon Sep 17 00:00:00 2001 From: wouterlucas Date: Fri, 27 Mar 2020 15:14:13 -0700 Subject: [PATCH 2/2] Bluetooth: Render errors --- dist/bundle.js | 2 +- src/js/plugins/bluetooth.js | 67 +++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 38 deletions(-) diff --git a/dist/bundle.js b/dist/bundle.js index a68a1ad..99438e9 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -1 +1 @@ -!function(t){var e={};function n(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(i,s,function(e){return t[e]}.bind(null,s));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=5)}([function(t,e,n){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n=function(t,e){var n=t[1]||"",i=t[3];if(!i)return n;if(e&&"function"==typeof btoa){var s=(l=i,d=btoa(unescape(encodeURIComponent(JSON.stringify(l)))),r="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(d),"/*# ".concat(r," */")),o=i.sources.map(function(t){return"/*# sourceURL=".concat(i.sourceRoot).concat(t," */")});return[n].concat(o).concat([s]).join("\n")}var l,d,r;return[n].join("\n")}(e,t);return e[2]?"@media ".concat(e[2],"{").concat(n,"}"):n}).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var i={},s=0;s{let t=window.location.hostname;return window.location.host===window.location.hostname?t+=":80":t+=":"+window.location.host.substring(window.location.hostname.length+1),t}},function(t,e,n){"use strict";var i=n(2),s=n.n(i);class o{constructor(t){this.prefixForService="Service",this.mainDiv=document.getElementById("main"),this.socket=null,this.host=t.split(":"),this.host[1]||(this.host[1]=80),this.t=s()({host:this.host[0],port:this.host[1]}),this.socketListeners={},this.servicesAvailableInJsonRPC=["DeviceInfo","DHCPServer","DIALServer","LocationSync","Messenger","Monitor","NetworkControl","OCDM","RemoteControl","Spark","Streamer","SystemCommands","TestController","TestUtility","TimeSync","TraceControl","WebKitBrowser","WifiControl"]}handleRequest(t,e,n,i){var s=new XMLHttpRequest;s.open(t,e,!0),i&&(s.onreadystatechange=function(){if(4==s.readyState)if(s.status>=200&&s.status<=299){var t;if(""!==s.responseText)try{t=JSON.parse(s.responseText.replace(/\\x([0-9A-Fa-f]{2})/g,""))}catch(t){}i(null,t,s.status)}else s.status>=300?i(s.responseText,null):0===s.status&&i("Connection interrupted",null)},s.ontimeout=function(){i("Connection timed out",null)}),null!==n?"string"==typeof n||n instanceof String?s.send(n):s.send(JSON.stringify(n)):s.send()}getURLStart(t,e){return t+"://"+this.host[0]+":"+this.host[1]+"/"+this.prefixForService+"/"}req(t,e){return new Promise((n,i)=>{if(e)console.debug(` ${e.plugin}.1.${e.method}`,e.params?e.params:""),this.t.call(e.plugin,e.method,e.params).then(t=>{n(t)}).catch(s=>{t?(console.debug(` ${e.plugin}.1.${e.method} failed, trying ${t.method} ${t.path}`),console.debug(" Error: ",s),this.handleRequest(t.method,this.getURLStart("http")+t.path,t.body,(t,e)=>{t?i(t):n(e)})):(console.error("JSONRPC Error, with no fallback: ",s),i(s))});else{if(void 0===t)return i("No rest or jsonrpc options provided, bailing out");this.handleRequest(t.method,this.getURLStart("http")+t.path,t.body,(t,e)=>{t?i(t):n(e)})}})}getControllerPlugins(){return this.req({method:"GET",path:"Controller/Plugins"},{plugin:"Controller",method:"status"})}startWebShell(t){t(null,new WebSocket(this.getURLStart("ws")+"WebShell","raw"))}startWebSocket(){this.socket&&this.socket.close(),this.socket=new WebSocket(this.getURLStart("ws")+"Controller","notification");var t=this;this.socket.onmessage=function(e){var n={};try{if(void 0===(n=JSON.parse(e.data)).callsign)return;for(var i=0;i\n
      \n \n\n \x3c!--navigation--\x3e\n \n ',this.header=document.getElementById("header"),this.nav=document.getElementById("menu");var i=!1,s=new Image;s.alt="Metrological",s.onload=()=>{this.header.appendChild(s)},s.onerror=()=>{!0!==i&&(s.src="UI/img/ml.svg",i=!0)},s.src="img/ml.svg",document.getElementById("button-left").onclick=this.showMenu.bind(this),window.onresize=function(){if(!0!==this.isTouchDevice){var t=document.getElementById("menu");window.innerWidth>960?t.style.left="0px":t.style.left="-600px"}},this.api.t.on("Controller","all",t=>{t.data&&t.data.state&&this.render()})}clear(){this.nav.innerHTML=""}render(t){this.api.getControllerPlugins().then(e=>{this.clear();const n=Object.keys(this.plugins);let i=document.createElement("ul");for(let o=0;o\n \n -\n \n\n
      \n \n -\n
      \n\n
      \n \n -\n
      \n\n
      \n \n -\n
      \n\n
      \n \n -\n /\n -\n
      \n\n
      \n \n -\n /\n -\n
      \n\n
      \n \n -\n
      \n\n hide statistics\n ',this.versionSpan=document.getElementById("statusBarVersion"),this.uptimeSpan=document.getElementById("statusBarUptime"),this.serialSpan=document.getElementById("statusBarSerial"),this.cpuLoadSpan=document.getElementById("statusBarCpuLoad"),this.usedRamSpan=document.getElementById("statusBarUsedRam"),this.totalRamSpan=document.getElementById("statusBarTotalRam"),this.gpuUsedRamSpan=document.getElementById("statusBarGpuRamUsed"),this.gpuTotalRamSpan=document.getElementById("statusBarGpuRamTotal"),document.getElementById("pause-button").onclick=this.togglePause.bind(this),this.pauseButton=document.getElementById("pause-button"),void 0!==this.deviceInfo?(this.interval=setInterval(this.update.bind(this),l.refresh_interval),this.update(),this.updateStatisticsBlock()):this.togglePause()}render(t){void 0!==t&&(this.deviceIsConnected(!0),this.versionSpan.innerHTML=t.version,this.serialSpan.innerHTML=t.serialnumber,this.uptimeSpan.innerHTML=t.uptime,this.totalRamSpan.innerHTML=this.bytesToMbString(t.totalram),this.usedRamSpan.innerHTML=this.bytesToMbString(t.totalram-t.freeram),this.gpuTotalRamSpan.innerHTML=this.bytesToMbString(t.totalgpuram),this.gpuUsedRamSpan.innerHTML=this.bytesToMbString(t.totalgpuram-t.freegpuram),this.cpuLoadSpan.innerHTML=parseFloat(t.cpuload).toFixed(1)+" %")}update(){!0===this.paused||this.deviceInfo&&"activated"!==this.deviceInfo.state||this.deviceInfo&&this.deviceInfo.status().then(this.render.bind(this))}updateStatisticsBlock(){this.pauseButton.innerHTML=!1===this.paused?"hide statistics":"show statistics";var t=this.footer.getElementsByClassName("status"),e=0;if(!1===this.paused){for(;e\n
      No connection with device
      \n
      Attempting to connect
      \n ',e.style.display="block"),this.connected=t}}bytesToMbString(t){return(t/1024/1024).toFixed(1)+" MB"}};var a=class{constructor(t){this.renderInMenu=!1,this.api=t,this.api.t.on("Controller","all",this.handleNotification),document.getElementById("hide-notifications").onclick=this.toggleVisibility.bind(this)}handleNotification(t){document.getElementById("notifications-block").style.display="block";var e=document.createElement("div"),n="",i=0;for(var s in t){if("Monitor"===t[s]&&(e.className="red"),"callsign"===s){var o=document.createElement("label");o.innerHTML='"'+t[s]+'"',e.appendChild(o)}else if("data"===s){n=n+s+": {";var l=0;for(var d in t.data)n=n+d+": "+t.data[d],l==Object.keys(t.data).length-1?n+="}":n+=", ",l++}else n=n+s+": "+t[s];"callsign"!=s&&i!=Object.keys(t).length-1&&(n+=", "),i++}var r=document.createElement("span");r.innerHTML=n,e.appendChild(r),document.getElementById("notifications").appendChild(e),document.getElementById("notifications").scrollTop=document.getElementById("notifications").scrollHeight}toggleVisibility(){var t="block"===document.getElementById("notifications").style.display;document.getElementById("notifications").style.display=t?"none":"block",document.getElementById("hide-notifications").innerHTML=t?"show console":"hide console"}};var c=class{constructor(t,e){this.api=e,this.callsign=t.callsign,this.configuration=t.configuration,this.classname=t.classname,this.state=t.state,this.supportsSuspended=!1,this.supportsVisibility=!1,this.renderInMenu=!0,this.displayName=void 0,this.rendered=!1}activate(t){const e={method:"PUT",path:`Controller/Activate/${t||this.callsign}`},n={plugin:"Controller",method:"activate",params:{callsign:t||this.callsign}};return this.api.req(e,n)}deactivate(t){const e={method:"PUT",path:`Controller/Deactivate/${t||this.callsign}`,body:null},n={plugin:"Controller",method:"deactivate",params:{callsign:t||this.callsign}};return this.api.req(e,n)}suspend(t){const e={method:"POST",path:`${t||this.callsign}/Suspend`},n={plugin:t||this.callsign,method:"state",params:"suspended"};return this.api.req(e,n)}resume(t){const e={method:"POST",path:`${t||this.callsign}/Resume`},n={plugin:t||this.callsign,method:"state",params:"resumed"};return this.api.req(e,n)}show(t){const e={method:"POST",path:`${t||this.callsign}/Show`,body:null};t||this.callsign;return this.api.req(e)}hide(t){const e={method:"POST",path:`${t||this.callsign}/Hide`,body:null};this.callsign;return this.api.req(e)}status(t){const e={method:"GET",path:t||this.callsign},n={plugin:t||this.callsign,method:"status"};return this.api.req(e,n)}render(){this.rendered=!0}close(){this.rendered=!1}};var u=class extends c{constructor(t,e){super(t,e),this.observablesList=[],this.restartList=[]}getMemoryInfo(t){return this.api.req({method:"GET",path:"Monitor"},{plugin:"Monitor",method:"status"})}render(){document.getElementById("main").innerHTML='
      \n \n \n
      Observables
      \n
      \n
      \n
      RestartThreshold
      \n
      \n
      \n
      ',this.getObservableList(),this.observableListEl=document.getElementById("observables"),this.restartListEl=document.getElementById("restart"),this.bt_setRestart=document.getElementById("setRestart"),this.bt_setRestart.onclick=this.setRestartThreshold.bind(this)}getObservableList(){this.status().then(t=>{for(var e=[],n=0;n{this.getMemoryInfo(t).then(s=>{let o=s.filter(e=>e.observable===t||e.name===t||valse);o&&o[0]?e(n.createMonitorDiv(o[0])):i()})})}createMonitorDiv(t){if(void 0!==t.measurment&&(t.measurements=t.measurment),void 0!==t.measurements&&void 0!==t.measurements.resident){var e=t.measurements,n=document.createElement("div"),i=document.createElement("div");for(var s in i.className="title grid__col grid__col--8-of-8",i.innerHTML="Memory",n.appendChild(i),e.resident){var o=document.createElement("div");o.className="label grid__col grid__col--2-of-8",n.appendChild(o);var l=document.createElement("label");l.innerHTML=s,o.appendChild(l);var d=document.createElement("div");d.className="text grid__col grid__col--6-of-8",d.innerHTML=this.bytesToMbString(e.resident[s]),n.appendChild(d)}var r=document.createElement("div");r.className="label grid__col grid__col--2-of-8",n.appendChild(r);var a=document.createElement("label");a.innerHTML="measurements",r.appendChild(a);var c=document.createElement("div");c.className="text grid__col grid__col--6-of-8",c.innerHTML=e.count,n.appendChild(c);var u=document.createElement("div");u.className="label grid__col grid__col--2-of-8",n.appendChild(u);var h=document.createElement("label");h.innerHTML="process",u.appendChild(h);var g=document.createElement("div");return g.className="text grid__col grid__col--6-of-8",g.innerHTML=e.process.last,n.appendChild(g),n}}bytesToMbString(t){return(t/1024/1024).toFixed(1)+" MB"}};var h=class extends c{constructor(t,e){super(t,e),this._url="",this._fps=0,this._isHidden=!1,this._isSuspended=!1,this.lastSetUrlKey="lastSetUrl",this.lastSetUrl=window.localStorage.getItem(this.lastSetUrlKey)||"",this.inspectorPort="9998",this.monitor=void 0,this.updateLoopInterval=void 0,this.template='
      \n\n
      Presets / URL
      \n\n
      URL
      \n
      -
      \n\n
      \n \n
      \n
      \n \n \n \n
      \n\n
      URL presets
      \n
      \n \n
      \n\n
      Performance
      \n
      FPS
      \n
      -
      \n
      \n\n
      Tools
      \n\n
      Current State
      \n
      \n
      \n
      \n \n
      \n\n
      Web Inspector
      \n
      \n \n
      \n\n
      ',this.presets=[{Name:"Select a preset",URL:""},{Name:"about:blank",URL:"about:blank"},{Name:"Smashcat",URL:"http://www.smashcat.org/av/canvas_test/"},{Name:"HTML5",URL:"http://beta.html5test.com/"},{Name:"PeaceKeeper",URL:"http://peacekeeper.futuremark.com/run.action"},{Name:"ChipTune",URL:"http://www.chiptune.com/kaleidoscope/"},{Name:"Poster Circle",URL:"http://www.webkit.org/blog-files/3d-transforms/poster-circle.html"},{Name:"Aquarium",URL:"http://webglsamples.org/aquarium/aquarium.html"},{Name:"Particles",URL:"http://oos.moxiecode.com/js_webgl/particles_morph/"},{Name:"EME v3 (race car)",URL:"http://cdn.metrological.com/static/eme-v3-clean.html"},{Name:"MSE 2018 (no vp9)",URL:"http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2018.html?novp9=true"},{Name:"EME 2018",URL:"http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2018.html?test_type=encryptedmedia-test"},{Name:"Progressive",URL:"http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2018.html?test_type=progressive-test"},{Name:"YouTube",URL:"http://youtube.com/tv"},{Name:"HelloRacer",URL:"http://www.emerveille.fr/lab/helloracer/index.html"},{Name:"Leaves",URL:"http://www.webkit.org/blog-files/leaves"},{Name:"Canvas Dots",URL:"http://themaninblue.com/experiment/AnimationBenchmark/canvas/"},{Name:"Anisotropic",URL:"http://whiteflashwhitehit.com/content/2011/02/anisotropic_webgl.html"},{Name:"Pasta",URL:"http://alteredqualia.com/three/examples/webgl_pasta.html"},{Name:"CSS3",URL:"http://css3test.com"},{Name:"Kraken",URL:"http://krakenbenchmark.mozilla.org/kraken-1.1/driver.html"},{Name:"KeyPress Test",URL:"http://keycode.info"}],void 0!==this.configuration&&void 0!==this.configuration.inspector&&(this.inspectorPort=this.configuration.inspector.split(":")[1]),this.api.t.on(this.callsign,"urlchange",t=>{t.url&&t.loaded&&(this._url=t.url,!0===this.rendered&&this.update())}),this.api.t.on(this.callsign,"visibilitychange",t=>{"boolean"==typeof t.hidden&&(this._isHidden=t.hidden,!0===this.rendered&&this.update())}),this.api.t.on(this.callsign,"statechange",t=>{"boolean"==typeof t.suspended&&(this._isSuspended=t.suspended,!0===this.rendered&&this.update())}),this.api.getControllerPlugins().then(t=>{let e=t.filter(t=>"Monitor"===t.callsign);void 0!==e&&(this.monitor=new u(e,this.api))})}status(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"state"};return this.api.req(t,e)}fps(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"fps"};return this.api.req(t,e)}url(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"url"};return this.api.req(t,e)}render(){var t=document.getElementById("main"),e=this.template.replace(/{{callsign}}/g,this.callsign);t.innerHTML=e,document.getElementById(this.callsign+"_url").value=this.lastSetUrl,document.getElementById(this.callsign+"_button").onclick=this.getAndSetUrl.bind(this),document.getElementById(this.callsign+"_reloadbutton").onclick=this.reloadUrl.bind(this),document.getElementById(this.callsign+"_linkPresets").onchange=this.getAndSetUrlFromPresets.bind(this);var n=document.getElementById(this.callsign+"_linkPresets");if(0===n.children.length)for(var i=0;i{t._isSuspended=e.suspended?e.suspended:"suspended"===e}).then(this.fps.bind(this)).then(e=>{t._fps=e.fps?e.fps:e}).then(this.url.bind(this)).then(e=>{t._url=e.url?e.url:e}).then(this.update.bind(this))}close(){window.removeEventListener("keydown",this.handleKey.bind(this),!1),clearInterval(this.updateLoopInterval),delete this.updateLoopInterval,this.rendered=!1}update(){document.getElementById(this.callsign+"_current_url").innerHTML=this._url,document.getElementById(this.callsign+"_fps").innerHTML=this._fps;var t=this._isSuspended?"Suspended":"Resumed",e=this._isSuspended?"Resume":"Suspend";document.getElementById(this.callsign+"StateInfo").innerHTML=t;var n=document.getElementById(this.callsign+"SuspendButton");n.innerHTML=e.toUpperCase(),n.onclick=this.toggleSuspend.bind(this,e),this.monitor&&this.monitor.getMonitorDataAndDiv().then(t=>{var e=document.getElementById(this.callsign+"Memory");e.innerHTML="",e.appendChild(t)})}setUrl(t){if(""===t)return;console.log("Setting url "+t+" for "+this.callsign);var e={url:t};const n={method:"POST",path:this.callsign+"/URL",body:e},i={plugin:this.callsign,method:"url",params:t};this.api.req(n,i),document.getElementById(this.callsign+"_linkPresets").selectedIndex=0}getAndSetUrl(){this.lastSetUrl=document.getElementById(this.callsign+"_url").value,this.setUrl(this.lastSetUrl),window.localStorage.setItem(this.lastSetUrlKey,this.lastSetUrl)}reloadUrl(){this.setUrl(this.callsign,document.getElementById(this.callsign+"_current_url").innerHTML)}getAndSetUrlFromPresets(){var t=document.getElementById(this.callsign+"_linkPresets").selectedIndex;t>0&&this.setUrl(this.presets[t].URL)}handleKey(t){var e=document.getElementById("WebKitBrowser_url");13===t.which&&e&&e===document.activeElement&&this.getAndSetUrl()}toggleSuspend(t){"Resume"===t?this.resume():this.suspend()}launchWebinspector(){var t="http://"+this.api.host[0]+":"+this.inspectorPort;window.open(t,"_blank").focus()}};var g=class extends c{constructor(t,e){super(t,e),this.monitor=void 0,this.api.t.on("Netflix","visibilitychange",t=>{"boolean"==typeof t.hidden&&(this.isHidden=t.hidden,!0===this.rendered&&this.update())}),this.api.t.on("Netflix","statechange",t=>{"boolean"==typeof t.suspended&&(this.isSuspended=t.suspended,!0===this.rendered&&this.update())}),this.api.getControllerPlugins().then(t=>{let e=t.filter(t=>"Monitor"===t.callsign);void 0!==e&&(this.monitor=new u(e,this.api))})}render(){document.getElementById("main").innerHTML='
      \n ESN\n
      \n\n
      \n ID\n
      \n
      \n -\n
      \n\n
      \n
      \n
      \n
      Memory
      \n
      Current State
      \n
      \n
      \n
      \n \n
      \n
      \n
      ',this.interval=setInterval(this.update.bind(this),conf.refresh_interval),this.update()}update(t){this.status().then(t=>{t.esn&&(document.getElementById("netflix-esn").innerHTML=t.esn);var e=t.suspended?"Suspended":"Resumed";document.getElementById("NetflixStateInfo").innerHTML=e;var n="Suspend";!0===t.suspended&&(n="Resume");var i=document.getElementById("NetflixSuspendButton");i.innerHTML=n.toUpperCase(),i.onclick=this.toggleSuspend.bind(this,n),this.monitor&&this.monitor.getMonitorDataAndDiv().then(t=>{var e=document.getElementById(this.callsign+"Memory");e.innerHTML="",e.appendChild(t)})})}close(){clearInterval(this.interval)}toggleSuspend(t){var e=this;"Resume"===t?this.resume().then(()=>{e.update({suspended:!1})}).catch(t=>{e.render()}):this.suspend().then(()=>{e.update({suspended:!0})}).catch(t=>{e.render()})}};var p={BluetoothControl:class extends c{constructor(t,e){super(t,e),this._devices=[],this.scanning=!1,this.displayName="BluetoothControl"}render(){document.getElementById("main").innerHTML='\n
      \n Status\n
      \n\n
      \n Devices\n
      \n
      \n \n
      \n
      \n Scanning\n
      \n
      \n OFF\n
      \n\n
      \n Device\n
      \n
      \n Name\n
      \n
      \n -\n
      \n
      \n Type\n
      \n
      \n -\n
      \n
      \n Connected\n
      \n
      \n -\n
      \n
      \n Paired\n
      \n
      \n -\n
      \n\n
      Controls
      \n
      \n \n \n \n \n
      \n\n
      Remote
      \n
      \n \n \n
      \n\n
      \n Discovery\n
      \n
      \n \n
      \n
      \n \n
      \n
      \n BlueTooth Low Energy\n
      \n
      \n
      \n \n \n
      \n
      \n\n
      \n\n
      \n ',this.scanButton=document.getElementById("BT_ScanForDevices"),this.pairButton=document.getElementById("BT_Pair"),this.unpairButton=document.getElementById("BT_Unpair"),this.connectButton=document.getElementById("BT_Connect"),this.disconnectButton=document.getElementById("BT_Disconnect"),this.btLowEnergyButton=document.getElementById("BT_LE"),this.assignButton=document.getElementById("BT_Assign"),this.revokeButton=document.getElementById("BT_Revoke"),this.deviceList=document.getElementById("BT_Devices"),this.deviceList.onchange=this.renderDevice.bind(this),this.scanButton.onclick=this.scanForDevices.bind(this),this.pairButton.onclick=this.pairDevice.bind(this),this.unpairButton.onclick=this.unpairDevice.bind(this),this.disconnectButton.onclick=this.disconnect.bind(this),this.connectButton.onclick=this.connect.bind(this),this.assignButton.onclick=this.assign.bind(this),this.revokeButton.onclick=this.revoke.bind(this),this.nameEl=document.getElementById("BT_Name"),this.typeEl=document.getElementById("BT_Type"),this.connectedEl=document.getElementById("BT_Connected"),this.pairedEl=document.getElementById("BT_Paired"),this.scanningStatus=document.getElementById("BT_Scanning"),this.statusMessages=document.getElementById("statusMessages"),this.deviceList=document.getElementById("BT_Devices"),this.api.t.on("BluetoothControl","scancomplete",this.scanComplete.bind(this)),this.api.t.on("BluetoothControl","devicestatechange",this.render.bind(this)),this.update()}devices(){return this.api.req(null,{plugin:"BluetoothControl",method:"devices"}).then(t=>{if(void 0!==t)return this._devices=[],t&&t.length&&t.forEach(t=>{this._devices.push({address:t})}),this._devices})}device(t){const e={plugin:"BluetoothControl",method:"device@"+t};return this.api.req(null,e)}scanComplete(){this.scanning=!1,this.renderScanStatus(),this.update(),this.updateStatus("Scan complete")}renderScanStatus(){this.scanningStatus.innerHTML=!0===this.scanning?"ON":"OFF"}updateDeviceList(){this.deviceList.innerHTML="",this._devices&&this._devices.length&&(this._devices.forEach(t=>{this.deviceList.appendChild(document.createElement("option")).innerHTML=t.address}),this.renderDevice())}renderDevice(){let t=this.deviceList.selectedIndex;if(-1===t||0===this._devices.length)return;let e=this._devices[t].address;this.device(e).then(n=>{n&&(this._devices[t]={address:e,...n}),this.nameEl.innerHTML=this._devices[t].name,this.typeEl.innerHTML=this._devices[t].type,this.connectedEl.innerHTML=this._devices[t].connected,this.pairedEl.innerHTML=this._devices[t].paired})}updateStatus(t){window.clearTimeout(this.statusMessageTimer),this.statusMessages.innerHTML=t,this.statusMessageTimer=setTimeout(this.updateStatus,5e3,"")}update(){this.renderScanStatus(),this.devices().then(()=>{this.updateDeviceList()})}scanForDevices(){this.updateStatus("Start scanning"),this.scanning=!0,this.renderScanStatus();const t={method:"PUT",path:"/Scan/?LowEnergy="+this.btLowEnergyButton.checked,body:null},e={plugin:"BluetoothControl",method:"scan",params:{type:this.btLowEnergyButton.checked?"LowEnergy":"Regular",timeout:10}};this.api.req(t,e)}pairDevice(){var t=this.deviceList.selectedIndex;this.updateStatus(`Pairing to ${this._devices[t].name}`);const e={method:"PUT",path:"/Pair",body:'{"address" : "'+this._devices[t].address+'"}'},n={plugin:this.callsign,method:"pair",params:{address:this._devices[t].address}};this.api.req(e,n)}unpairDevice(){var t=this.deviceList.selectedIndex;this.updateStatus(`Unpairing ${this._devices[t].name}`);const e={method:"PUT",path:"/Unpair",body:'{"address" : "'+this._devices[t].address+'"}'},n={plugin:this.callsign,method:"unpair",params:{address:this._devices[t].address}};this.api.req(e,n)}connect(){var t=this.deviceList.selectedIndex;this.updateStatus(`Connecting to ${this._devices[t].name}`);const e={method:"PUT",path:"/Connect",body:'{"address" : "'+this._devices[t].address+'"}'},n={plugin:this.callsign,method:"connect",params:{address:this._devices[t].address}};this.api.req(e,n)}disconnect(){var t=this.deviceList.selectedIndex;this.updateStatus(`Disconnecting from ${this._devices[t].name}`);const e={method:"DELETE",path:"/Connect",body:'{"address" : "'+this._devices[t].address+'"}'},n={plugin:this.callsign,method:"disconnect",params:{address:this._devices[t].address}};this.api.req(e,n)}assign(){var t=this.deviceList.selectedIndex;this.updateStatus(`Assigning ${this._devices[t].name}`);const e={plugin:"BluetoothRemoteControl",method:"assign",params:{address:this._devices[t].address}};this.api.req(null,e)}revoke(){var t=this.deviceList.selectedIndex;this.updateStatus(`Revoking ${this._devices[t].name}`);const e={plugin:"BluetoothRemoteControl",method:"revoke",params:{address:this._devices[t].address}};this.api.req(null,e)}close(){clearInterval(this.statusMessageTimer)}},Cobalt:class extends h{constructor(t,e){super(t,e),this.template='
      \n\n
      Presets / URL
      \n\n
      URL
      \n
      -
      \n\n
      \n \n
      \n
      \n \n \n \n
      \n\n
      URL presets
      \n
      \n \n
      \n\n
      Performance
      \n
      FPS
      \n
      -
      \n
      \n\n
      Tools
      \n\n
      Current State
      \n
      \n
      \n
      \n \n
      \n\n
      Visibility
      \n
      \n
      \n
      \n \n
      \n\n
      \n
      Web Inspector
      \n
      \n \n
      \n
      \n\n
      '}},Compositor:class extends c{constructor(t,e){super(t,e),this._rpcMapping={Top:"putontop"},this.resolutions=["720p","720p50Hz","1080p24Hz","1080i50Hz","1080p50Hz","1080p60Hz"]}render(){document.getElementById("main").innerHTML='
      \n Compositor\n
      \n
      \n \n
      \n
      \n \n
      \n
      \n \n
      \n
      \n \n
      \n
      \n\n
      ',document.getElementById("compositorResolutions").onclick=this.setResolution.bind(this),this.resolutionsList=document.getElementById("compositorResolutions"),this.menu=document.getElementById("compositorClients"),this.controlDiv=document.getElementById("controls"),this.compositorClientsDiv=document.getElementById("compositorClientsDiv"),this.controlDiv.style.display="none",this.resolutionsList.innerHTML="";for(var t=0;t{null!=t&&Array.isArray(t)?t.length>0&&this.renderControls(t):this.compositorClientsDiv.innerHTML="No clients found."})}getClients(){const t={method:"GET",path:`${this.callsign}/Clients`},e={plugin:this.callsign,method:"clients"};return this.api.req(t,e)}renderControls(t){this.controlDiv.innerHTML='
      \n Controls\n
      \n
      \n Focus\n
      \n
      \n \n
      \n
      \n
      \n Opacity\n
      \n
      \n \n \n
      \n
      \n
      \n \n
      \n
      \n Visibility\n
      \n
      \n \n \n
      \n
      \n
      \n Geometry\n
      \n
      \n X\n
      \n
      \n \n
      \n
      \n Y\n
      \n
      \n \n
      \n
      \n Width\n
      \n
      \n \n
      \n
      \n Height\n
      \n
      \n \n
      \n
      \n
      \n \n
      ',document.getElementById("compositorSetTop").onclick=this.compositorAction.bind(this,"Top"),document.getElementById("sliderOpacity").onchange=this.updateValue.bind(this,"sliderOpacity","numOpacity"),document.getElementById("numOpacity").onchange=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("numOpacity").onkeyup=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("numOpacity").onpaste=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("numOpacity").oninput=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("compositorSetOpacity").onclick=this.compositorSetOpacity.bind(this),document.getElementById("webkit_hide").onclick=this.compositorVisible.bind(this,"Hide"),document.getElementById("webkit_show").onclick=this.compositorVisible.bind(this,"Show"),document.getElementById("compositorGeometry").onclick=this.compositorSetGeometry.bind(this),document.getElementById("compositorClients").onchange=this.clientChange.bind(this);var e=document.getElementById("compositorClients");e.innerHTML="";var n=document.createElement("option");n.value="",n.setAttributeNode(document.createAttribute("disabled")),n.setAttributeNode(document.createAttribute("selected")),n.innerHTML="Select a client",e.appendChild(n);for(var i=0;i{void 0!==t.state&&!0===this.rendered&&this.render(),void 0!==t.suspended&&!0===this.rendered&&this.render()})}controllerStatus(t){const e={plugin:"Controller"};return e.method=t?`status@${t}`:"status",api.req(void 0,e)}harakiri(){const t={plugin:"Controller",method:"harakiri",params:{callsign:this.callsign}};return this.api.req({method:"PUT",path:"Controller/Harakiri",body:null},t)}initiateDiscovery(){return this.api.req({method:"PUT",path:"Controller/Discovery",body:null},{plugin:"Controller",method:"startdiscovery",params:{ttl:1}})}getDiscovery(){return this.api.req({method:"GET",path:"Controller/Discovery",body:null},{plugin:"Controller",method:"discoveryresults"})}persist(t){return this.api.req({method:"PUT",path:"Controller/Persist",body:null},{plugin:"Controller",method:"storeconfig"})}toggleActivity(t){for(var e,n=0;n{void 0!==plugins[t]&&(plugins[t].state="activated"),e.state="activated"}).catch(t=>{this.render()})):(console.debug("Deactivating "+t),this.deactivate(t).then(n=>{void 0!==plugins[t]&&(plugins[t].state="deactivated"),e.state="deactivated"}).catch(t=>{this.render()}))}toggleSuspend(t){for(var e,n=0;n{void 0!==plugins[t]&&(plugins[t].state="activated"),!1===document.getElementById(t+"suspend").checked?this.resume(t).then(this.render.bind(this)):api.suspendPlugin(t).then(this.render.bind(this))});"resumed"===e.state?(console.debug("Suspending "+t),this.suspend(t).then(n=>{this.updateSuspendLabel(t,"resume"),void 0!==plugins[t]&&(plugins[t].state="resumed"),document.getElementById(t+"suspend").checked=!0,e.state="suspended"})):(console.debug("Resuming "+t),this.resume(t).then(n=>{this.updateSuspendLabel(t,"suspend"),void 0!==plugins[t]&&(plugins[t].state="suspended"),document.getElementById(t+"suspend").checked=!1,e.state="resumed"}))}clear(){this.mainDiv.innerHTML=""}discover(){console.log("Initiating discovery"),this.initiateDiscovery();let t=this;setTimeout(function(){t.getDiscovery().then(t=>{var e=t.bridges?t.bridges:t,n=document.getElementById("discoveryList");n.innerHTML="";for(var i=0;i\n Plugins\n \n
      \n
      \n Device actions\n
      \n
      \n \n
      \n
      \n \n
      \n
      \n Discover devices\n
      \n
      \n \n
      \n
      \n
        \n
        \n \n ',document.getElementById("persistButton").onclick=this.persist.bind(this),document.getElementById("harakiriButton").onclick=this.harakiri.bind(this),document.getElementById("discoverButton").onclick=this.discover.bind(this);var t=document.getElementById("controllerPlugins");this.status().then(e=>{var n=e.plugins?e.plugins:e;this.plugins=n;for(var i=0;inew Promise((e,n)=>{this.deviceInfo().then(n=>{e({...t,...n})})}))}deviceInfo(){return this.api.req({method:"GET",path:"DeviceInfo"},{plugin:"DeviceInfo",method:"systeminfo"})}displayInfo(){return this.api.req({method:"GET",path:"DisplayInfo"},{plugin:"DisplayInfo",method:"displayinfo"})}addresses(){return this.api.req({method:"GET",path:"DeviceInfo"},{plugin:"DeviceInfo",method:"addresses"})}socketinfo(){return this.api.req({method:"GET",path:"DeviceInfo"},{plugin:"DeviceInfo",method:"socketinfo"})}update(){this.deviceInfo().then(t=>{let e=t.systeminfo?t.systeminfo:t;this.deviceNameEl.innerHTML=e.devicename,this.serialNumberEl.innerHTML=e.serialnumber,this.versionEl.innerHTML=e.version,this.uptimeEl.innerHTML=e.uptime,this.totalRamEl.innerHTML=this.bytesToMbString(e.totalram),this.usedRamEl.innerHTML=this.bytesToMbString(e.totalram-e.freeram),this.freeRamEl.innerHTML=this.bytesToMbString(e.freeram),this.cpuLoadEl.innerHTML=parseFloat(e.cpuload).toFixed(1)+" %",this.addresses().then(t=>{let e=t.addresses?t.addresses:t;this.interfacesOptsEl.innerHTML="";for(var n=0;n{this.totalGpuRamEl.innerHTML=this.bytesToMbString(t.totalgpuram),this.freeGpuRamEl.innerHTML=this.bytesToMbString(t.freegpuram),this.usedGpuRamEl.innerHTML=this.bytesToMbString(t.totalgpuram-t.freegpuram)}),document.getElementById("startGraphs").onclick=this.startRealtimeGraphs.bind(this)}render(){this.mainDiv.innerHTML=this.template,this.deviceNameEl=document.getElementById("DeviceName"),this.serialNumberEl=document.getElementById("SerialNumber"),this.versionEl=document.getElementById("Version"),this.uptimeEl=document.getElementById("Uptime"),this.totalRamEl=document.getElementById("TotalRam"),this.usedRamEl=document.getElementById("UsedRam"),this.freeRamEl=document.getElementById("FreeRam"),this.totalGpuRamEl=document.getElementById("TotalGpuRam"),this.freeGpuRamEl=document.getElementById("FreeGpuRam"),this.usedGpuRamEl=document.getElementById("UsedGpuRam"),this.cpuLoadEl=document.getElementById("CpuLoad"),this.interfacesOptsEl=document.getElementById("NetworkInterface"),this.interfacesOptsEl.onchange=this.updateNetworkInterface.bind(this),this.macIdEl=document.getElementById("MAC_ID"),this.ipAddressEl=document.getElementById("IpAddress"),this.update()}startRealtimeGraphs(){this.chartOptions.maxElements=parseInt(document.getElementById("graph_max_elements").value),this.chartOptions.interval=parseInt(document.getElementById("graph_poll_interval").value),this.cpuChart=this.generateGraph("CPU usage",document.getElementById("graph_cpu").getContext("2d"),"#34c749","%"),this.ramChart=this.generateGraph("RAM used",document.getElementById("graph_ram").getContext("2d"),"#fc5652","MB"),this.gpuChart=this.generateGraph("GPU RAM used",document.getElementById("graph_gpu").getContext("2d"),"#fdbc40","MB"),this.chartIntervalId=setInterval(this.updateGraphs.bind(this),this.chartOptions.interval),document.getElementById("graphs").style.display="block"}generateGraph(t,e,n,i){return new Chart(e,{type:"line",data:{labels:[],datasets:[{label:t,backgroundColor:n,borderColor:n,data:[],fill:!1}]},options:{responsive:!1,scales:{yAxes:[{ticks:{callback:function(t,e,n){return t+i}}}]}}})}updateGraphs(){let t=this;const e=t.getTimestampForGraph();this.deviceInfo().then(n=>{t.ramChart&&(t.ramChart.config.data.labels.push(e),t.ramChart.config.data.datasets[0].data.push((n.totalram-n.freeram)/1024/1024),t.ramChart.config.data.labels.length>t.chartOptions.maxElements&&(t.ramChart.config.data.labels.shift(),t.ramChart.config.data.datasets[0].data.shift()),t.ramChart.update()),t.cpuChart&&(t.cpuChart.config.data.labels.push(e),t.cpuChart.config.data.datasets[0].data.push(parseFloat(n.cpuload).toFixed(1)),t.cpuChart.config.data.labels.length>t.chartOptions.maxElements&&(t.cpuChart.config.data.labels.shift(),t.cpuChart.config.data.datasets[0].data.shift()),t.cpuChart.update())}),this.displayInfo().then(n=>{t.gpuChart&&(t.gpuChart.config.data.labels.push(e),t.gpuChart.config.data.datasets[0].data.push((n.totalgpuram-n.freegpuram)/1024/1024),t.gpuChart.config.data.labels.length>t.chartOptions.maxElements&&(t.gpuChart.config.data.labels.shift(),t.gpuChart.config.data.datasets[0].data.shift()),t.gpuChart.update())})}close(){clearInterval(this.chartIntervalId),delete this.ramChart,delete this.cpuChart,delete this.gpuChart}updateNetworkInterface(t){this.selectedNetworkInterface=this.interfacesOptsEl.selectedIndex,this.update()}bytesToMbString(t){return(t/1024/1024).toFixed(1)+" MB"}getTimestampForGraph(){const t=new Date;return`${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}`}},DialServer:class extends c{constructor(t,e){super(t,e),this.api.t.on("DIALServer","start",t=>{this.dialMessage("start",t)}),this.api.t.on("DIALServer","stop",t=>{this.dialMessage("stop",t)})}render(){document.getElementById("main").innerHTML='
        \n Received DIAL requests:\n
        \n\n
        ',this.statusMessagesEl=document.getElementById("statusMessages")}dialMessage(t,e){let n=document.createElement("div");"stop"===t&&(n.className="red");let i=document.createElement("span");i.innerHTML=`${t} :: ${e.application} - ${e.parameters}`,n.appendChild(i),this.statusMessagesEl.appendChild(n)}},LocationSync:class extends c{constructor(t,e){super(t,e),this.renderInMenu=!0,this.displayName="Location"}render(){document.getElementById("main").innerHTML='
        \n Location\n
        \n\n
        \n City\n
        \n
        \n -\n
        \n
        \n Country\n
        \n
        \n -\n
        \n
        \n Region\n
        \n
        \n -\n
        \n\n
        \n Timezone\n
        \n
        \n -\n
        \n\n
        \n Public IP\n
        \n
        \n -\n
        \n\n
        \n Sync\n
        \n
        \n \n
        ',document.getElementById("syncButton").onclick=this.syncLocation.bind(this),this.cityEl=document.getElementById("city"),this.countryEl=document.getElementById("country"),this.regionEl=document.getElementById("region"),this.timezoneEl=document.getElementById("timezone"),this.publicIpEl=document.getElementById("publicip"),this.update()}syncLocation(){const t={method:"PUT",path:`${this.callsign}`},e={plugin:this.callsign,method:"sync"};this.api.req(t,e).then(()=>{this.update()})}location(){const t={method:"GET",path:`${this.callsign}`},e={plugin:this.callsign,method:"location"};return this.api.req(t,e)}update(){this.location().then(t=>{this.cityEl.innerHTML=t.city,this.countryEl.innerHTML=t.country,this.regionEl.innerHTML=t.region,this.timezoneEl.innerHTML=t.timezone,this.publicIpEl.innerHTML=t.publicip})}},Monitor:u,Netflix:g,NetworkControl:class extends c{constructor(t,e){super(t,e),this.renderInMenu=!0,this.displayName="Network",this.selectedNetworkInterface=0,this.networks=[]}render(){document.getElementById("main").innerHTML='\n
        \n Network Control\n
        \n
        \n Network Interface\n
        \n
        \n \n
        \n
        \n IP Address\n
        \n
        \n -\n
        \n
        \n Broadcast\n
        \n
        \n -\n
        \n
        \n Gateway\n
        \n
        \n -\n
        \n
        \n mask\n
        \n
        \n -\n
        \n
        \n mode\n
        \n
        \n -\n
        \n\n
        \n Control\n
        \n
        \n \n \n \n \n
        ',this.interfacesOptsEl=document.getElementById("NetworkInterface"),this.interfacesOptsEl.onchange=this.updateNetworkInterface.bind(this),document.getElementById("reload").onclick=this.reload.bind(this);document.getElementById("request");request.onclick=this.request.bind(this),document.getElementById("assign").onclick=this.assign.bind(this),document.getElementById("flush").onclick=this.flush.bind(this),this.ipEl=document.getElementById("ip"),this.broadcastEl=document.getElementById("broadcast"),this.gatewayEl=document.getElementById("gateway"),this.maskEl=document.getElementById("mask"),this.modeEl=document.getElementById("mode"),this.api.t.on("NetworkControl","networkupdate",t=>{console.log("NETWORK NOT",t),this.update()}),this.update()}network(){const t={method:"GET",path:`${this.callsign}`},e={plugin:this.callsign,method:"network"};return this.api.req(t,e)}reload(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Reload`},n={plugin:this.callsign,method:"reload",params:{device:t}};return this.api.req(e,n)}request(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Request`},n={plugin:this.callsign,method:"request",params:{device:t}};return this.api.req(e,n)}assign(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Assign`},n={plugin:this.callsign,method:"assign",params:{device:t}};return this.api.req(e,n)}flush(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Flush`},n={plugin:this.callsign,method:"flush",params:{device:t}};return this.api.req(e,n)}update(){this.network().then(t=>{let e=t.addresses?t.addresses:t;this._addresses=e,this.interfacesOptsEl.innerHTML="";for(var n=0;n{if(null==t)return;let e=t.systems?t.systems:t;for(let t=0;t{void 0!==t.PowerState&&(this.powerStateDiv.innerHTML=this.stateLookup[t.PowerState],this.stateSelectorEl.children[t.PowerState-1].selected=!0)})}changeState(t){const e={method:"POST",path:`${this.callsign}/State`,body:{PowerState:this.stateSelectorEl.value}},n={plugin:this.callsign,method:"state",params:{powerstate:this.stateSelectorEl.value}};""!==this.timeoutInput.value&&(e.body.Timeout=this.timeoutInput.value,n.body.timeout=this.timeoutInput.value),this.api.req(e).then(()=>{t<2&&setTimeout(this.update,5e3)})}},Provisioning:class extends c{constructor(t,e){super(t,e)}render(){document.getElementById("main").innerHTML='
        \n Provisioning status\n
        \n\n
        \n Device\n
        \n
        \n -\n
        \n
        \n Provisioned for\n
        \n
        \n -\n
        \n
        \n Status\n
        \n
        \n -\n
        \n\n
        \n Provisioning\n
        \n
        \n \n
        ',document.getElementById("provisionButton").onclick=this.tiggerProvisioningRequest.bind(this),this.update()}triggerProvisioning(){const t={method:"PUT",path:`${this.callsign}`},e={plugin:this.callsign,method:"provision"};return this.api.req(t,e)}status(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"state"};return this.api.req(t,e)}update(){this.status().then(t=>{if(null!=t&&""!==t){var e=t.id,n=t.tokens||[],i=t.status;document.getElementById("device").innerHTML=e,document.getElementById("status").innerHTML=200==i?"provisioned":"not provisioned",200==i&&n.length>0&&(document.getElementById("provisioning-tokens").innerHTML=n.join(", ")),document.getElementById("provisionLabel").style.display=200==i?"none":null}}).catch(t=>{console.error(t),this.status(t)})}tiggerProvisioningRequest(){var t=this;this.triggerProvisioning().then(e=>{document.getElementById("provisionButton").style.display="none",document.getElementById("provisionLabel").style.display="none",setTimeout(t.update(),3e3)})}},RemoteControl:class extends c{constructor(t,e){super(t,e),this.displayName="Remote Control",this.onScreenKeyBoardIsRendered=!1,this.doNotHandleKeys=!1,this.devicesThatSupportPairing=["GreenPeakRF4CE","GreenPeak","RF4CE"],this.autoFwdKeys=window.localStorage.getItem("autoFwdKeys"),this.automaticallyForwardKeys="false"!==this.autoFwdKeys,this.keyMapping={1:{code:"0x0021",color:void 0,string:"1"},2:{code:"0x0022",color:void 0,string:"2"},3:{code:"0x0023",color:void 0,string:"3"},4:{code:"0x0024",color:void 0,string:"4"},5:{code:"0x0025",color:void 0,string:"5"},6:{code:"0x0026",color:void 0,string:"6"},7:{code:"0x0027",color:void 0,string:"7"},8:{code:"0x0028",color:void 0,string:"8"},9:{code:"0x0029",color:void 0,string:"9"},0:{code:"0x0020",color:void 0,string:"0"},exit:{code:"0x0009",color:"blue",string:"exit"},a:{code:"0x8004",color:void 0,string:"a"},b:{code:"0x8005",color:void 0,string:"b"},c:{code:"0x8006",color:void 0,string:"c"},d:{code:"0x8007",color:void 0,string:"d"},e:{code:"0x8008",color:void 0,string:"e"},f:{code:"0x8009",color:void 0,string:"f"},g:{code:"0x800A",color:void 0,string:"g"},h:{code:"0x800B",color:void 0,string:"h"},i:{code:"0x800C",color:void 0,string:"i"},back:{code:"0x0032",color:"blue double",string:"back"},j:{code:"0x800D",color:void 0,string:"j"},k:{code:"0x800E",color:void 0,string:"k"},l:{code:"0x800F",color:void 0,string:"l"},m:{code:"0x8010",color:void 0,string:"m"},n:{code:"0x8011",color:void 0,string:"n"},o:{code:"0x8012",color:void 0,string:"o"},p:{code:"0x8013",color:void 0,string:"p"},q:{code:"0x8014",color:void 0,string:"q"},r:{code:"0x8015",color:void 0,string:"r"},up:{code:"0x0001",color:"blue",string:"up",div:'
        '},ok:{code:"0x002B",color:"blue",string:"ok"},s:{code:"0x8016",color:void 0,string:"s"},t:{code:"0x8017",color:void 0,string:"t"},u:{code:"0x8018",color:void 0,string:"u"},v:{code:"0x8019",color:void 0,string:"v"},w:{code:"0x801A",color:void 0,string:"w"},x:{code:"0x801B",color:void 0,string:"x"},y:{code:"0x801C",color:void 0,string:"y"},z:{code:"0x801D",color:void 0,string:"z"},left:{code:"0x0003",color:"blue",string:"left",div:'
        '},down:{code:"0x0002",color:"blue",string:"down",div:'
        '},right:{code:"0x0004",color:"blue",string:"right",div:'
        '}},this.jsToWpeKeyMap={13:{code:"0x002B",string:"enter"},37:{code:"0x0003",string:"left"},38:{code:"0x0001",string:"up"},39:{code:"0x0004",string:"right"},40:{code:"0x0002",string:"down"},27:{code:"0x0009",string:"esc"},8:{code:"0x0032",string:"backspace"},48:{code:"0x0020",string:"0"},49:{code:"0x0021",string:"1"},50:{code:"0x0022",string:"2"},51:{code:"0x0023",string:"3"},52:{code:"0x0024",string:"4"},53:{code:"0x0025",string:"5"},54:{code:"0x0026",string:"6"},55:{code:"0x0027",string:"7"},56:{code:"0x0028",string:"8"},57:{code:"0x0029",string:"9"},33:{code:"0x0030",string:"page up"},34:{code:"0x0031",string:"page down"},65:{code:"0x8004",string:"a"},66:{code:"0x8005",string:"b"},67:{code:"0x8006",string:"c"},68:{code:"0x8007",string:"d"},69:{code:"0x8008",string:"e"},70:{code:"0x8009",string:"f"},71:{code:"0x800A",string:"g"},72:{code:"0x800B",string:"h"},73:{code:"0x800C",string:"i"},74:{code:"0x800D",string:"j"},75:{code:"0x800E",string:"k"},76:{code:"0x800F",string:"l"},77:{code:"0x8010",string:"m"},78:{code:"0x8011",string:"n"},79:{code:"0x8012",string:"o"},80:{code:"0x8013",string:"p"},81:{code:"0x8014",string:"q"},82:{code:"0x8015",string:"r"},83:{code:"0x8016",string:"s"},84:{code:"0x8017",string:"t"},85:{code:"0x8018",string:"u"},86:{code:"0x8019",string:"v"},87:{code:"0x801A",string:"w"},88:{code:"0x801B",string:"x"},89:{code:"0x801C",string:"y"},90:{code:"0x801D",string:"z"},46:{code:"0x802A",string:"delete"},32:{code:"0x802C",string:"space"},189:{code:"0x802D",string:"-"},187:{code:"0x802E",string:"="},220:{code:"0x8031",string:"\\"},186:{code:"0x8033",string:";"},222:{code:"0x8034",string:"`"},188:{code:"0x8036",string:","},190:{code:"0x8037",string:"."},191:{code:"0x8038",string:"/"}},this.addKeyboardButton(),this.keyboardDiv=document.getElementById("keyboard"),this.keyBoardInnerDiv=document.createElement("div"),this.keyBoardInnerDiv.id="keyboard-inner";for(var n=Object.keys(this.keyMapping),i=0;i{if(void 0!==e)for(var n=void 0!==e.devices?e.devices:e,i=document.getElementById("remotesList"),s=document.getElementById("pairingDiv"),o=0;o\n Pairing\n '),s.innerHTML+=`
        ${l}
        \n
        \n \n
        `,document.getElementById(l+"-PairingMode").onclick=t.activatePairing.bind(t,l)}})}toggleAutoforwardOfKeys(){this.automaticallyForwardKeys=!0!==this.automaticallyForwardKeys,window.localStorage.setItem("autoFwdKeys",this.automaticallyForwardKeys)}},Snapshot:class extends c{constructor(t,e){super(t,e)}render(){document.getElementById("main").innerHTML='
        \n Create\n
        \n\n
        \n Snapshot\n
        \n
        \n \n
        \n\n
        \n \n
        ',document.getElementById("snapshotButton").onclick=this.createSnapshot.bind(this)}getSnapshotLocator(){return this.api.getURLStart("http")+"Snapshot/Capture?"+(new Date).getTime()}createSnapshot(){var t=document.getElementById("snapshotOutput");t.src="",t.src=this.getSnapshotLocator()}},Spark:class extends c{constructor(t,e){super(t,e),this.url="",this.isHidden=!1,this.isSuspended=!1,this.lastSetUrlKey="lastSetUrl"+this.callsign,this.lastSetUrl=window.localStorage.getItem(this.lastSetUrlKey)||"",this.template='
        \n\n
        Presets / URL
        \n\n
        \n \n
        \n
        \n \n \n
        \n\n
        URL presets
        \n
        \n \n
        \n\n
        Tools
        \n\n
        Current State
        \n
        \n
        \n
        \n \n
        \n\n
        Visibility
        \n
        \n
        \n
        \n \n
        \n
        ',this.presets=[{Name:"Select a preset",URL:""},{Name:"http://www.sparkui.org/examples/gallery/picturepile.js",URL:"http://www.sparkui.org/examples/gallery/picturepile.js"},{Name:"http://www.sparkui.org/examples/gallery/gallery.js",URL:"http://www.sparkui.org/examples/gallery/gallery.js"}],this.api.t.on("Spark","urlchange",t=>{t.url&&t.loaded&&(this.url=t.url,this.handleNotification())}),this.api.t.on("Spark","visibilitychange",t=>{"boolean"==typeof t.hidden&&(this.isHidden=t.hidden,this.handleNotification())}),this.api.t.on("Spark","statechange",t=>{"boolean"==typeof t.suspended&&(this.isSuspended=t.suspended,this.handleNotification())})}handleNotification(t){!1!==this.rendered&&this.update()}render(){var t=document.getElementById("main"),e=this.template.replace(/{{callsign}}/g,this.callsign);t.innerHTML=e,document.getElementById(this.callsign+"_url").value=this.lastSetUrl,document.getElementById(this.callsign+"_button").onclick=this.getAndSetUrl.bind(this),document.getElementById(this.callsign+"_linkPresets").onchange=this.getAndSetUrlFromPresets.bind(this);var n=document.getElementById(this.callsign+"_linkPresets");if(0===n.children.length)for(var i=0;i0&&this.setUrl(this.presets[t].URL)}handleKey(t){var e=document.getElementById(`${this.callsign}_url`);13===t.which&&e&&e===document.activeElement&&this.getAndSetUrl()}toggleSuspend(t){"Resume"===t?this.resume():this.suspend()}toggleVisibility(t){"Show"===t?this.show():this.hide()}},Switchboard:class extends c{constructor(t,e){super(t,e),this.defaultPlugin=void 0,this.switchablePlugins=[],this.state().then(t=>{this.defaultPlugin=t.default,this.switchablePlugins=t.callsigns})}state(){const t={method:"GET",path:`${this.callsign}/Switch`};return this.api.req(t)}getDefaultSwitchBoardPlugin(){return this.defaultPlugin}getSwitchablePlugins(){return this.switchBoardPlugins}render(){this.mainDiv=document.getElementById("main"),this.mainDiv.innerHTML='\n
        \n Plugins\n
        \n
        ';var t=document.getElementById("switchBoardPlugins");this.api.getControllerPlugins().then(e=>{for(var n=e.plugins,i=0;i{this.render()})}},TimeSync:class extends c{constructor(t,e){super(t,e),this.renderInMenu=!0,this.displayName="Time"}render(){document.getElementById("main").innerHTML='\n
        \n Time\n
        \n
        \n Current time\n
        \n
        \n -\n
        \n
        \n Source\n
        \n
        \n -\n
        \n
        \n Last synced\n
        \n
        \n -\n
        \n\n
        \n \n
        \n
        \n \n \n
        \n\n
        \n Control\n
        \n
        \n \n
        ',document.getElementById("setTime").onclick=this.setTime.bind(this),document.getElementById("sync").onclick=this.synchronizeTime.bind(this),this.timeEl=document.getElementById("time"),this.sourceEl=document.getElementById("source"),this.syncedEl=document.getElementById("synced"),this.api.t.on("TimeSync","update",t=>{console.log("TIME NOT",t),this.update()}),this.update()}synchronizeTime(){this.syncTime().then(this.synchronize())}synchronize(){const t={plugin:this.callsign,method:"synchronize"};return this.api.req(null,t)}syncTime(){const t={plugin:this.callsign,method:"synctime"};return this.api.req(null,t)}setTime(){let t=document.getElementById("timeinput").value;const e={method:"POST",path:`${this.callsign}`,body:{time:t}},n={plugin:this.callsign,method:"time",params:t};return this.api.req(e,n)}getTime(){const t={method:"GET",path:`${this.callsign}`},e={plugin:this.callsign,method:"time"};return this.api.req(t,e)}update(){this.getTime().then(t=>{this.timeEl.innerHTML=t,this.syncTime().then(t=>{this.sourceEl.innerHTML=t.source,this.syncedEl.innerHTML=t.time})})}},TraceControl:class extends c{constructor(t,e){super(t,e),this.displayName="Tracing",this.selectedTraceModule=void 0,this.traceModules=void 0,this.uniqueTraceModules=void 0}toggleTracing(t,e,n){const i={method:"PUT",path:"TraceControl/"+t+"/"+e+"/"+n},s={plugin:"TraceControl",method:"set",params:{module:t,category:e,state:"on"===n?"enabled":"disabled"}};return this.api.req(i,s)}render(){var t=this;document.getElementById("main").innerHTML='
        \n Modules\n
        \n\n
        \n \n
        \n
        \n \n
        \n\n
        ',document.getElementById("tracingModules").onchange=this.getSelectedModuleAndShowCategories.bind(this),this.status().then(e=>{t.traceModules=e.settings?e.settings:[],t.uniqueTraceModules=[];var n=document.getElementById("tracingModules");n.getElementsByTagName("options");if(n.options.length=0,void 0!==t.traceModules){for(var i=0;i{this.mutedEl.innerHTML=t}),this.volume().then(t=>{this.volumeEl.innerHTML=t})}muted(t){const e={plugin:this.callsign,method:"muted"};return t&&(e.params=t),this.api.req(null,e)}volume(t){const e={plugin:this.callsign,method:"volume"};return t&&(e.params=t),this.api.req(null,e)}volumeChange(t){this.volume().then(e=>{this.volume(e+t).then(this.update())})}mute(){this.muted().then(t=>{this.muted(!t).then(this.update())})}},WebKitBrowser:h,WebShell:class extends c{constructor(t,e){super(t,e),this.webShellSocket=void 0}render(){var t=this;document.getElementById("main").innerHTML='
        WebShell
        \n
        \n
        \n        
        \n
        #
        ',this.api.startWebShell(function(e,n){t.webShellSocket=n,t.webShellSocket.onmessage=function(t){var e=new FileReader;e.onload=function(){document.getElementById("webShellData").innerHTML=String.fromCharCode.apply(null,new Uint8Array(e.result))},e.readAsArrayBuffer(t.data)},t.webShellSocket.onclose=function(){t.webShellSocket=null,t.render()}}),void 0!==plugins.RemoteControl&&(plugins.RemoteControl.doNotHandleKeys=!0),window.addEventListener("keydown",this.handleKey.bind(this))}close(){void 0!==plugins.RemoteControl&&(plugins.RemoteControl.doNotHandleKeys=!1),window.removeEventListener("keydown",this.handleKey.bind(this),!1)}handleKey(t){if(this.webShellSocket&&13===t.which){for(var e=document.getElementById("webShellInput").value+" \n",n=new ArrayBuffer(2*e.length),i=new Uint8Array(n),s=0,o=e.length;s{!0===this.rendered&&this.getNetworks()}),this.api.t.on("WifiControl","connectionchange",t=>{this.connected=t.connected,!0===this.rendered&&this.update()})}render(){document.getElementById("main").innerHTML='
        \n Status\n
        \n\n
        \n Connected to\n
        \n
        \n\n
        \n Scanning\n
        \n
        \n False\n
        \n\n
        \n Wireless networks\n
        \n
        \n \n
        \n
        \n
        \n
        \n \n
        \n\n
        \n Configs\n
        \n\n
        \n Configs\n
        \n
        \n \n
        \n\n
        \n SSID\n
        \n
        \n \n
        \n
        \n Mode\n
        \n
        \n
        \n \x3c!-- disable for now\n
        \n
        \n \n
        \n --\x3e\n
        \n Hidden\n
        \n
        \n
        \n Method\n
        \n
        \n \n
        \n
        \n Password\n
        \n
        \n \n
        \n
        Controls
        \n
        \n \n \n \n
        \n
        \n
        \n \n \n
        \n\n
        \n
        \n ',this.scanButton=document.getElementById("Wifi_scanForNetworksButton"),this.saveButton=document.getElementById("Wifi_saveButton"),this.deleteButton=document.getElementById("Wifi_deleteButton"),this.storeButton=document.getElementById("Wifi_storeButton"),this.connectButton=document.getElementById("Wifi_connectButton"),this.disconnectButton=document.getElementById("Wifi_disconnectButton"),this.scanButton.onclick=this.scanForNetworks.bind(this),this.deleteButton.onclick=this.deleteConfig.bind(this),this.saveButton.onclick=this.saveConfig.bind(this),this.storeButton.onclick=this.storeConfig.bind(this),this.disconnectButton.onclick=this.disconnect.bind(this),this.connectButton.onclick=this.connect.bind(this),this.connectedStatus=document.getElementById("Wifi_Connected"),this.scanningStatus=document.getElementById("Wifi_Scanning"),this.statusMessages=document.getElementById("statusMessages"),this.networkListEl=document.getElementById("Wifi_WirelessNetwork"),this.networkListEl.onchange=this.renderNetworkDetails.bind(this),this.configListEl=document.getElementById("Wifi_Configs"),this.configListEl.onchange=this.renderConfigDetails.bind(this),this.ssidEl=document.getElementById("Wifi_SSID"),this.methodEl=document.getElementById("Wifi_Method"),this.passwordEl=document.getElementById("Wifi_Password"),this.accesspointEl=document.getElementById("Wifi_Mode"),this.hiddenEl=document.getElementById("Wifi_Hidden"),this.update(),setTimeout(this.getNetworks.bind(this),200),setTimeout(this.getConfigs.bind(this),400),this.rendered=!0}update(){this.status().then(t=>{void 0!==t&&(this.connected=t.connected,"boolean"==typeof t.scanning&&(this.scanning=t.scanning),this.renderStatus())})}scanForNetworks(){const t={method:"PUT",path:`${this.callsign}/Scan`},e={plugin:this.callsign,method:"scan"};this.api.req(t,e).then(t=>{this.update(),setTimeout(this.getNetworks.bind(this),5e3)})}getConfigs(){this.update();const t={method:"GET",path:`${this.callsign}/Configs`},e={plugin:this.callsign,method:"configs"};this.api.req(t,e).then(t=>{if(void 0===t)return;let e=t.configs?t.configs:t;if(void 0!==e){this.configs=e,this.configListEl.innerHTML="";for(var n=0;n{if(void 0===t)return;if(this.networks=[],!1===this.rendered)return;let e=t.networks?t.networks:t;this.networkListEl.innerHTML="";for(var n=0;n{this.statusMessage(`Saved config for ${this.ssidEl.value}`),t.getConfigs()})}deleteConfig(){var t=this.configListEl.selectedIndex;this.statusMessage(`Deleting config ${this.configs[t].ssid}`);const e={method:"PUT",path:`${this.callsign}/Delete/${this.configs[t].ssid}`},n={plugin:this.callsign,method:"delete",params:{ssid:this.configs[t].ssid}};this.api.req(e,n).then(()=>{this.connecting=!0,this.getConfigs()})}requestDHCP(){this.statusMessage("Requesting DHCP for wlan0");const t={method:"PUT",path:`NetworkControl/${this.wlanInterface}/Request`},e={plugin:"NetworkControl",method:"request",params:{device:this.wlanInterface}};this.api.req(t,e)}storeConfig(){this.statusMessage("Storing WiFi configuration");const t={method:"PUT",path:`${this.callsign}/${this.wlanInterface}/Store`},e={plugin:this.callsign,method:"store"};this.api.req(t,e)}connect(){var t=this.configListEl.selectedIndex;this.statusMessage(`Connecting to ${this.configs[t].ssid}`);const e={method:"PUT",path:`${this.callsign}/Connect/${this.configs[t].ssid}`},n={plugin:this.callsign,method:"connect",params:{ssid:this.configs[t].ssid}};this.api.req(e,n).then(()=>{this.connecting=!0,setTimeout(this.requestDHCP.bind(this),5e3)})}disconnect(){if(void 0===this.connected||""===this.connected)return;const t={method:"DELETE",path:`${this.callsign}/Connect/${this.connected}`},e={plugin:this.callsign,method:"disconnect",params:{ssid:this.connected}};this.statusMessage(`Disconnecting from ${this.connected}`),this.api.req(t,e)}close(){this.rendered=!1}}};n.d(e,"b",function(){return f}),n.d(e,"c",function(){return b}),n.d(e,"a",function(){return l});var m={},_=void 0,v=(document.getElementById("main"),window.localStorage.getItem("lastActivePlugin")||void 0);function f(t){(_=new o(t)).getControllerPlugins().then(t=>t).then(t=>{for(var e=0;e1)for(var n=1;n{let t=window.location.hostname;return window.location.host===window.location.hostname?t+=":80":t+=":"+window.location.host.substring(window.location.hostname.length+1),t}},function(t,e,n){"use strict";var i=n(2),s=n.n(i);class o{constructor(t){this.prefixForService="Service",this.mainDiv=document.getElementById("main"),this.socket=null,this.host=t.split(":"),this.host[1]||(this.host[1]=80),this.t=s()({host:this.host[0],port:this.host[1]}),this.socketListeners={},this.servicesAvailableInJsonRPC=["DeviceInfo","DHCPServer","DIALServer","LocationSync","Messenger","Monitor","NetworkControl","OCDM","RemoteControl","Spark","Streamer","SystemCommands","TestController","TestUtility","TimeSync","TraceControl","WebKitBrowser","WifiControl"]}handleRequest(t,e,n,i){var s=new XMLHttpRequest;s.open(t,e,!0),i&&(s.onreadystatechange=function(){if(4==s.readyState)if(s.status>=200&&s.status<=299){var t;if(""!==s.responseText)try{t=JSON.parse(s.responseText.replace(/\\x([0-9A-Fa-f]{2})/g,""))}catch(t){}i(null,t,s.status)}else s.status>=300?i(s.responseText,null):0===s.status&&i("Connection interrupted",null)},s.ontimeout=function(){i("Connection timed out",null)}),null!==n?"string"==typeof n||n instanceof String?s.send(n):s.send(JSON.stringify(n)):s.send()}getURLStart(t,e){return t+"://"+this.host[0]+":"+this.host[1]+"/"+this.prefixForService+"/"}req(t,e){return new Promise((n,i)=>{if(e)console.debug(` ${e.plugin}.1.${e.method}`,e.params?e.params:""),this.t.call(e.plugin,e.method,e.params).then(t=>{n(t)}).catch(s=>{t?(console.debug(` ${e.plugin}.1.${e.method} failed, trying ${t.method} ${t.path}`),console.debug(" Error: ",s),this.handleRequest(t.method,this.getURLStart("http")+t.path,t.body,(t,e)=>{t?i(t):n(e)})):(console.error("JSONRPC Error, with no fallback: ",s),i(s))});else{if(void 0===t)return i("No rest or jsonrpc options provided, bailing out");this.handleRequest(t.method,this.getURLStart("http")+t.path,t.body,(t,e)=>{t?i(t):n(e)})}})}getControllerPlugins(){return this.req({method:"GET",path:"Controller/Plugins"},{plugin:"Controller",method:"status"})}startWebShell(t){t(null,new WebSocket(this.getURLStart("ws")+"WebShell","raw"))}startWebSocket(){this.socket&&this.socket.close(),this.socket=new WebSocket(this.getURLStart("ws")+"Controller","notification");var t=this;this.socket.onmessage=function(e){var n={};try{if(void 0===(n=JSON.parse(e.data)).callsign)return;for(var i=0;i\n
        \n \n\n \x3c!--navigation--\x3e\n \n ',this.header=document.getElementById("header"),this.nav=document.getElementById("menu");var i=!1,s=new Image;s.alt="Metrological",s.onload=()=>{this.header.appendChild(s)},s.onerror=()=>{!0!==i&&(s.src="UI/img/ml.svg",i=!0)},s.src="img/ml.svg",document.getElementById("button-left").onclick=this.showMenu.bind(this),window.onresize=function(){if(!0!==this.isTouchDevice){var t=document.getElementById("menu");window.innerWidth>960?t.style.left="0px":t.style.left="-600px"}},this.api.t.on("Controller","all",t=>{t.data&&t.data.state&&this.render()})}clear(){this.nav.innerHTML=""}render(t){this.api.getControllerPlugins().then(e=>{this.clear();const n=Object.keys(this.plugins);let i=document.createElement("ul");for(let o=0;o\n \n -\n \n\n
        \n \n -\n
        \n\n
        \n \n -\n
        \n\n
        \n \n -\n
        \n\n
        \n \n -\n /\n -\n
        \n\n
        \n \n -\n /\n -\n
        \n\n
        \n \n -\n
        \n\n hide statistics\n ',this.versionSpan=document.getElementById("statusBarVersion"),this.uptimeSpan=document.getElementById("statusBarUptime"),this.serialSpan=document.getElementById("statusBarSerial"),this.cpuLoadSpan=document.getElementById("statusBarCpuLoad"),this.usedRamSpan=document.getElementById("statusBarUsedRam"),this.totalRamSpan=document.getElementById("statusBarTotalRam"),this.gpuUsedRamSpan=document.getElementById("statusBarGpuRamUsed"),this.gpuTotalRamSpan=document.getElementById("statusBarGpuRamTotal"),document.getElementById("pause-button").onclick=this.togglePause.bind(this),this.pauseButton=document.getElementById("pause-button"),void 0!==this.deviceInfo?(this.interval=setInterval(this.update.bind(this),l.refresh_interval),this.update(),this.updateStatisticsBlock()):this.togglePause()}render(t){void 0!==t&&(this.deviceIsConnected(!0),this.versionSpan.innerHTML=t.version,this.serialSpan.innerHTML=t.serialnumber,this.uptimeSpan.innerHTML=t.uptime,this.totalRamSpan.innerHTML=this.bytesToMbString(t.totalram),this.usedRamSpan.innerHTML=this.bytesToMbString(t.totalram-t.freeram),this.gpuTotalRamSpan.innerHTML=this.bytesToMbString(t.totalgpuram),this.gpuUsedRamSpan.innerHTML=this.bytesToMbString(t.totalgpuram-t.freegpuram),this.cpuLoadSpan.innerHTML=parseFloat(t.cpuload).toFixed(1)+" %")}update(){!0===this.paused||this.deviceInfo&&"activated"!==this.deviceInfo.state||this.deviceInfo&&this.deviceInfo.status().then(this.render.bind(this))}updateStatisticsBlock(){this.pauseButton.innerHTML=!1===this.paused?"hide statistics":"show statistics";var t=this.footer.getElementsByClassName("status"),e=0;if(!1===this.paused){for(;e\n
        No connection with device
        \n
        Attempting to connect
        \n ',e.style.display="block"),this.connected=t}}bytesToMbString(t){return(t/1024/1024).toFixed(1)+" MB"}};var a=class{constructor(t){this.renderInMenu=!1,this.api=t,this.api.t.on("Controller","all",this.handleNotification),document.getElementById("hide-notifications").onclick=this.toggleVisibility.bind(this)}handleNotification(t){document.getElementById("notifications-block").style.display="block";var e=document.createElement("div"),n="",i=0;for(var s in t){if("Monitor"===t[s]&&(e.className="red"),"callsign"===s){var o=document.createElement("label");o.innerHTML='"'+t[s]+'"',e.appendChild(o)}else if("data"===s){n=n+s+": {";var l=0;for(var r in t.data)n=n+r+": "+t.data[r],l==Object.keys(t.data).length-1?n+="}":n+=", ",l++}else n=n+s+": "+t[s];"callsign"!=s&&i!=Object.keys(t).length-1&&(n+=", "),i++}var d=document.createElement("span");d.innerHTML=n,e.appendChild(d),document.getElementById("notifications").appendChild(e),document.getElementById("notifications").scrollTop=document.getElementById("notifications").scrollHeight}toggleVisibility(){var t="block"===document.getElementById("notifications").style.display;document.getElementById("notifications").style.display=t?"none":"block",document.getElementById("hide-notifications").innerHTML=t?"show console":"hide console"}};var c=class{constructor(t,e){this.api=e,this.callsign=t.callsign,this.configuration=t.configuration,this.classname=t.classname,this.state=t.state,this.supportsSuspended=!1,this.supportsVisibility=!1,this.renderInMenu=!0,this.displayName=void 0,this.rendered=!1}activate(t){const e={method:"PUT",path:`Controller/Activate/${t||this.callsign}`},n={plugin:"Controller",method:"activate",params:{callsign:t||this.callsign}};return this.api.req(e,n)}deactivate(t){const e={method:"PUT",path:`Controller/Deactivate/${t||this.callsign}`,body:null},n={plugin:"Controller",method:"deactivate",params:{callsign:t||this.callsign}};return this.api.req(e,n)}suspend(t){const e={method:"POST",path:`${t||this.callsign}/Suspend`},n={plugin:t||this.callsign,method:"state",params:"suspended"};return this.api.req(e,n)}resume(t){const e={method:"POST",path:`${t||this.callsign}/Resume`},n={plugin:t||this.callsign,method:"state",params:"resumed"};return this.api.req(e,n)}show(t){const e={method:"POST",path:`${t||this.callsign}/Show`,body:null};t||this.callsign;return this.api.req(e)}hide(t){const e={method:"POST",path:`${t||this.callsign}/Hide`,body:null};this.callsign;return this.api.req(e)}status(t){const e={method:"GET",path:t||this.callsign},n={plugin:t||this.callsign,method:"status"};return this.api.req(e,n)}render(){this.rendered=!0}close(){this.rendered=!1}};var u=class extends c{constructor(t,e){super(t,e),this.observablesList=[],this.restartList=[]}getMemoryInfo(t){return this.api.req({method:"GET",path:"Monitor"},{plugin:"Monitor",method:"status"})}render(){document.getElementById("main").innerHTML='
        \n \n \n
        Observables
        \n
        \n
        \n
        RestartThreshold
        \n
        \n
        \n
        ',this.getObservableList(),this.observableListEl=document.getElementById("observables"),this.restartListEl=document.getElementById("restart"),this.bt_setRestart=document.getElementById("setRestart"),this.bt_setRestart.onclick=this.setRestartThreshold.bind(this)}getObservableList(){this.status().then(t=>{for(var e=[],n=0;n{this.getMemoryInfo(t).then(s=>{let o=s.filter(e=>e.observable===t||e.name===t||valse);o&&o[0]?e(n.createMonitorDiv(o[0])):i()})})}createMonitorDiv(t){if(void 0!==t.measurment&&(t.measurements=t.measurment),void 0!==t.measurements&&void 0!==t.measurements.resident){var e=t.measurements,n=document.createElement("div"),i=document.createElement("div");for(var s in i.className="title grid__col grid__col--8-of-8",i.innerHTML="Memory",n.appendChild(i),e.resident){var o=document.createElement("div");o.className="label grid__col grid__col--2-of-8",n.appendChild(o);var l=document.createElement("label");l.innerHTML=s,o.appendChild(l);var r=document.createElement("div");r.className="text grid__col grid__col--6-of-8",r.innerHTML=this.bytesToMbString(e.resident[s]),n.appendChild(r)}var d=document.createElement("div");d.className="label grid__col grid__col--2-of-8",n.appendChild(d);var a=document.createElement("label");a.innerHTML="measurements",d.appendChild(a);var c=document.createElement("div");c.className="text grid__col grid__col--6-of-8",c.innerHTML=e.count,n.appendChild(c);var u=document.createElement("div");u.className="label grid__col grid__col--2-of-8",n.appendChild(u);var h=document.createElement("label");h.innerHTML="process",u.appendChild(h);var g=document.createElement("div");return g.className="text grid__col grid__col--6-of-8",g.innerHTML=e.process.last,n.appendChild(g),n}}bytesToMbString(t){return(t/1024/1024).toFixed(1)+" MB"}};var h=class extends c{constructor(t,e){super(t,e),this._url="",this._fps=0,this._isHidden=!1,this._isSuspended=!1,this.lastSetUrlKey="lastSetUrl",this.lastSetUrl=window.localStorage.getItem(this.lastSetUrlKey)||"",this.inspectorPort="9998",this.monitor=void 0,this.updateLoopInterval=void 0,this.template='
        \n\n
        Presets / URL
        \n\n
        URL
        \n
        -
        \n\n
        \n \n
        \n
        \n \n \n \n
        \n\n
        URL presets
        \n
        \n \n
        \n\n
        Performance
        \n
        FPS
        \n
        -
        \n
        \n\n
        Tools
        \n\n
        Current State
        \n
        \n
        \n
        \n \n
        \n\n
        Web Inspector
        \n
        \n \n
        \n\n
        ',this.presets=[{Name:"Select a preset",URL:""},{Name:"about:blank",URL:"about:blank"},{Name:"Smashcat",URL:"http://www.smashcat.org/av/canvas_test/"},{Name:"HTML5",URL:"http://beta.html5test.com/"},{Name:"PeaceKeeper",URL:"http://peacekeeper.futuremark.com/run.action"},{Name:"ChipTune",URL:"http://www.chiptune.com/kaleidoscope/"},{Name:"Poster Circle",URL:"http://www.webkit.org/blog-files/3d-transforms/poster-circle.html"},{Name:"Aquarium",URL:"http://webglsamples.org/aquarium/aquarium.html"},{Name:"Particles",URL:"http://oos.moxiecode.com/js_webgl/particles_morph/"},{Name:"EME v3 (race car)",URL:"http://cdn.metrological.com/static/eme-v3-clean.html"},{Name:"MSE 2018 (no vp9)",URL:"http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2018.html?novp9=true"},{Name:"EME 2018",URL:"http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2018.html?test_type=encryptedmedia-test"},{Name:"Progressive",URL:"http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2018.html?test_type=progressive-test"},{Name:"YouTube",URL:"http://youtube.com/tv"},{Name:"HelloRacer",URL:"http://www.emerveille.fr/lab/helloracer/index.html"},{Name:"Leaves",URL:"http://www.webkit.org/blog-files/leaves"},{Name:"Canvas Dots",URL:"http://themaninblue.com/experiment/AnimationBenchmark/canvas/"},{Name:"Anisotropic",URL:"http://whiteflashwhitehit.com/content/2011/02/anisotropic_webgl.html"},{Name:"Pasta",URL:"http://alteredqualia.com/three/examples/webgl_pasta.html"},{Name:"CSS3",URL:"http://css3test.com"},{Name:"Kraken",URL:"http://krakenbenchmark.mozilla.org/kraken-1.1/driver.html"},{Name:"KeyPress Test",URL:"http://keycode.info"}],void 0!==this.configuration&&void 0!==this.configuration.inspector&&(this.inspectorPort=this.configuration.inspector.split(":")[1]),this.api.t.on(this.callsign,"urlchange",t=>{t.url&&t.loaded&&(this._url=t.url,!0===this.rendered&&this.update())}),this.api.t.on(this.callsign,"visibilitychange",t=>{"boolean"==typeof t.hidden&&(this._isHidden=t.hidden,!0===this.rendered&&this.update())}),this.api.t.on(this.callsign,"statechange",t=>{"boolean"==typeof t.suspended&&(this._isSuspended=t.suspended,!0===this.rendered&&this.update())}),this.api.getControllerPlugins().then(t=>{let e=t.filter(t=>"Monitor"===t.callsign);void 0!==e&&(this.monitor=new u(e,this.api))})}status(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"state"};return this.api.req(t,e)}fps(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"fps"};return this.api.req(t,e)}url(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"url"};return this.api.req(t,e)}render(){var t=document.getElementById("main"),e=this.template.replace(/{{callsign}}/g,this.callsign);t.innerHTML=e,document.getElementById(this.callsign+"_url").value=this.lastSetUrl,document.getElementById(this.callsign+"_button").onclick=this.getAndSetUrl.bind(this),document.getElementById(this.callsign+"_reloadbutton").onclick=this.reloadUrl.bind(this),document.getElementById(this.callsign+"_linkPresets").onchange=this.getAndSetUrlFromPresets.bind(this);var n=document.getElementById(this.callsign+"_linkPresets");if(0===n.children.length)for(var i=0;i{t._isSuspended=e.suspended?e.suspended:"suspended"===e}).then(this.fps.bind(this)).then(e=>{t._fps=e.fps?e.fps:e}).then(this.url.bind(this)).then(e=>{t._url=e.url?e.url:e}).then(this.update.bind(this))}close(){window.removeEventListener("keydown",this.handleKey.bind(this),!1),clearInterval(this.updateLoopInterval),delete this.updateLoopInterval,this.rendered=!1}update(){document.getElementById(this.callsign+"_current_url").innerHTML=this._url,document.getElementById(this.callsign+"_fps").innerHTML=this._fps;var t=this._isSuspended?"Suspended":"Resumed",e=this._isSuspended?"Resume":"Suspend";document.getElementById(this.callsign+"StateInfo").innerHTML=t;var n=document.getElementById(this.callsign+"SuspendButton");n.innerHTML=e.toUpperCase(),n.onclick=this.toggleSuspend.bind(this,e),this.monitor&&this.monitor.getMonitorDataAndDiv().then(t=>{var e=document.getElementById(this.callsign+"Memory");e.innerHTML="",e.appendChild(t)})}setUrl(t){if(""===t)return;console.log("Setting url "+t+" for "+this.callsign);var e={url:t};const n={method:"POST",path:this.callsign+"/URL",body:e},i={plugin:this.callsign,method:"url",params:t};this.api.req(n,i),document.getElementById(this.callsign+"_linkPresets").selectedIndex=0}getAndSetUrl(){this.lastSetUrl=document.getElementById(this.callsign+"_url").value,this.setUrl(this.lastSetUrl),window.localStorage.setItem(this.lastSetUrlKey,this.lastSetUrl)}reloadUrl(){this.setUrl(this.callsign,document.getElementById(this.callsign+"_current_url").innerHTML)}getAndSetUrlFromPresets(){var t=document.getElementById(this.callsign+"_linkPresets").selectedIndex;t>0&&this.setUrl(this.presets[t].URL)}handleKey(t){var e=document.getElementById("WebKitBrowser_url");13===t.which&&e&&e===document.activeElement&&this.getAndSetUrl()}toggleSuspend(t){"Resume"===t?this.resume():this.suspend()}launchWebinspector(){var t="http://"+this.api.host[0]+":"+this.inspectorPort;window.open(t,"_blank").focus()}};var g=class extends c{constructor(t,e){super(t,e),this.monitor=void 0,this.api.t.on("Netflix","visibilitychange",t=>{"boolean"==typeof t.hidden&&(this.isHidden=t.hidden,!0===this.rendered&&this.update())}),this.api.t.on("Netflix","statechange",t=>{"boolean"==typeof t.suspended&&(this.isSuspended=t.suspended,!0===this.rendered&&this.update())}),this.api.getControllerPlugins().then(t=>{let e=t.filter(t=>"Monitor"===t.callsign);void 0!==e&&(this.monitor=new u(e,this.api))})}render(){document.getElementById("main").innerHTML='
        \n ESN\n
        \n\n
        \n ID\n
        \n
        \n -\n
        \n\n
        \n
        \n
        \n
        Memory
        \n
        Current State
        \n
        \n
        \n
        \n \n
        \n
        \n
        ',this.interval=setInterval(this.update.bind(this),conf.refresh_interval),this.update()}update(t){this.status().then(t=>{t.esn&&(document.getElementById("netflix-esn").innerHTML=t.esn);var e=t.suspended?"Suspended":"Resumed";document.getElementById("NetflixStateInfo").innerHTML=e;var n="Suspend";!0===t.suspended&&(n="Resume");var i=document.getElementById("NetflixSuspendButton");i.innerHTML=n.toUpperCase(),i.onclick=this.toggleSuspend.bind(this,n),this.monitor&&this.monitor.getMonitorDataAndDiv().then(t=>{var e=document.getElementById(this.callsign+"Memory");e.innerHTML="",e.appendChild(t)})})}close(){clearInterval(this.interval)}toggleSuspend(t){var e=this;"Resume"===t?this.resume().then(()=>{e.update({suspended:!1})}).catch(t=>{e.render()}):this.suspend().then(()=>{e.update({suspended:!0})}).catch(t=>{e.render()})}};var p={BluetoothControl:class extends c{constructor(t,e){super(t,e),this._devices=[],this.scanning=!1,this.displayName="BluetoothControl"}render(){document.getElementById("main").innerHTML='\n
        \n Status\n
        \n\n
        \n Devices\n
        \n
        \n \n
        \n
        \n Scanning\n
        \n
        \n OFF\n
        \n\n
        \n Device\n
        \n
        \n Name\n
        \n
        \n -\n
        \n
        \n Type\n
        \n
        \n -\n
        \n
        \n Connected\n
        \n
        \n -\n
        \n
        \n Paired\n
        \n
        \n -\n
        \n\n
        Controls
        \n
        \n \n \n \n \n
        \n\n
        Remote
        \n
        \n \n \n
        \n\n
        \n Discovery\n
        \n
        \n \n
        \n
        \n \n
        \n
        \n BlueTooth Low Energy\n
        \n
        \n
        \n \n \n
        \n
        \n\n
        \n\n
        \n ',this.scanButton=document.getElementById("BT_ScanForDevices"),this.pairButton=document.getElementById("BT_Pair"),this.unpairButton=document.getElementById("BT_Unpair"),this.connectButton=document.getElementById("BT_Connect"),this.disconnectButton=document.getElementById("BT_Disconnect"),this.btLowEnergyButton=document.getElementById("BT_LE"),this.assignButton=document.getElementById("BT_Assign"),this.revokeButton=document.getElementById("BT_Revoke"),this.deviceList=document.getElementById("BT_Devices"),this.deviceList.onchange=this.renderDevice.bind(this),this.scanButton.onclick=this.scanForDevices.bind(this),this.pairButton.onclick=this.pairDevice.bind(this),this.unpairButton.onclick=this.unpairDevice.bind(this),this.disconnectButton.onclick=this.disconnect.bind(this),this.connectButton.onclick=this.connect.bind(this),this.assignButton.onclick=this.assign.bind(this),this.revokeButton.onclick=this.revoke.bind(this),this.nameEl=document.getElementById("BT_Name"),this.typeEl=document.getElementById("BT_Type"),this.connectedEl=document.getElementById("BT_Connected"),this.pairedEl=document.getElementById("BT_Paired"),this.scanningStatus=document.getElementById("BT_Scanning"),this.statusMessages=document.getElementById("statusMessages"),this.deviceList=document.getElementById("BT_Devices"),this.api.t.on("BluetoothControl","scancomplete",this.scanComplete.bind(this)),this.api.t.on("BluetoothControl","devicestatechange",this.render.bind(this)),this.update()}devices(){return this.api.req(null,{plugin:"BluetoothControl",method:"devices"}).then(t=>{if(void 0!==t)return this._devices=[],t&&t.length&&t.forEach(t=>{this._devices.push({address:t})}),this._devices})}device(t){const e={plugin:"BluetoothControl",method:"device@"+t};return this.api.req(null,e)}scanComplete(){this.scanning=!1,this.renderScanStatus(),this.update(),this.updateStatus("Scan complete")}renderScanStatus(){this.scanningStatus.innerHTML=!0===this.scanning?"ON":"OFF"}updateDeviceList(){this.deviceList.innerHTML="",this._devices&&this._devices.length&&(this._devices.forEach(t=>{this.deviceList.appendChild(document.createElement("option")).innerHTML=t.address}),this.renderDevice())}renderDevice(){let t=this.deviceList.selectedIndex;if(-1===t||0===this._devices.length)return;let e=this._devices[t].address;this.device(e).then(n=>{n&&(this._devices[t]={address:e,...n}),this.nameEl.innerHTML=this._devices[t].name,this.typeEl.innerHTML=this._devices[t].type,this.connectedEl.innerHTML=this._devices[t].connected,this.pairedEl.innerHTML=this._devices[t].paired})}updateStatus(t,e=!1){window.clearTimeout(this.statusMessageTimer),this.statusMessages.innerHTML=t,this.statusMessages.style=e?"color: red":"",this.statusMessageTimer=setTimeout(this.updateStatus,5e3,"")}update(){this.renderScanStatus(),this.devices().then(()=>{this.updateDeviceList()})}scanForDevices(){this.updateStatus("Start scanning"),this.scanning=!0,this.renderScanStatus();const t={plugin:"BluetoothControl",method:"scan",params:{type:this.btLowEnergyButton.checked?"LowEnergy":"Regular",timeout:10}};this.api.req(null,t).catch(t=>{t.message&&this.updateStatus(`Error: ${t.message}`)})}pairDevice(){var t=this.deviceList.selectedIndex;this.updateStatus(`Pairing to ${this._devices[t].name}`);const e={plugin:this.callsign,method:"pair",params:{address:this._devices[t].address}};this.api.req(null,e).catch(t=>{t.message&&this.updateStatus(`Error: ${t.message}`,!0)})}unpairDevice(){var t=this.deviceList.selectedIndex;this.updateStatus(`Unpairing ${this._devices[t].name}`);const e={plugin:this.callsign,method:"unpair",params:{address:this._devices[t].address}};this.api.req(null,e).catch(t=>{t.message&&this.updateStatus(`Error: ${t.message}`,!0)})}connect(){var t=this.deviceList.selectedIndex;this.updateStatus(`Connecting to ${this._devices[t].name}`);const e={plugin:this.callsign,method:"connect",params:{address:this._devices[t].address}};this.api.req(null,e).catch(t=>{t.message&&this.updateStatus(`Error: ${t.message}`,!0)})}disconnect(){var t=this.deviceList.selectedIndex;this.updateStatus(`Disconnecting from ${this._devices[t].name}`);const e={plugin:this.callsign,method:"disconnect",params:{address:this._devices[t].address}};this.api.req(null,e).catch(t=>{t.message&&this.updateStatus(`Error: ${t.message}`,!0)})}assign(){var t=this.deviceList.selectedIndex;this.updateStatus(`Assigning ${this._devices[t].name}`);const e={plugin:"BluetoothRemoteControl",method:"assign",params:{address:this._devices[t].address}};this.api.req(null,e)}revoke(){var t=this.deviceList.selectedIndex;this.updateStatus(`Revoking ${this._devices[t].name}`);const e={plugin:"BluetoothRemoteControl",method:"revoke",params:{address:this._devices[t].address}};this.api.req(null,e).catch(t=>{t.message&&this.updateStatus(`Error: ${t.message}`,!0)})}close(){clearInterval(this.statusMessageTimer)}},Cobalt:class extends h{constructor(t,e){super(t,e),this.template='
        \n\n
        Presets / URL
        \n\n
        URL
        \n
        -
        \n\n
        \n \n
        \n
        \n \n \n \n
        \n\n
        URL presets
        \n
        \n \n
        \n\n
        Performance
        \n
        FPS
        \n
        -
        \n
        \n\n
        Tools
        \n\n
        Current State
        \n
        \n
        \n
        \n \n
        \n\n
        Visibility
        \n
        \n
        \n
        \n \n
        \n\n
        \n
        Web Inspector
        \n
        \n \n
        \n
        \n\n
        '}},Compositor:class extends c{constructor(t,e){super(t,e),this._rpcMapping={Top:"putontop"},this.resolutions=["720p","720p50Hz","1080p24Hz","1080i50Hz","1080p50Hz","1080p60Hz"]}render(){document.getElementById("main").innerHTML='
        \n Compositor\n
        \n
        \n \n
        \n
        \n \n
        \n
        \n \n
        \n
        \n \n
        \n
        \n\n
        ',document.getElementById("compositorResolutions").onclick=this.setResolution.bind(this),this.resolutionsList=document.getElementById("compositorResolutions"),this.menu=document.getElementById("compositorClients"),this.controlDiv=document.getElementById("controls"),this.compositorClientsDiv=document.getElementById("compositorClientsDiv"),this.controlDiv.style.display="none",this.resolutionsList.innerHTML="";for(var t=0;t{null!=t&&Array.isArray(t)?t.length>0&&this.renderControls(t):this.compositorClientsDiv.innerHTML="No clients found."})}getClients(){const t={method:"GET",path:`${this.callsign}/Clients`},e={plugin:this.callsign,method:"clients"};return this.api.req(t,e)}renderControls(t){this.controlDiv.innerHTML='
        \n Controls\n
        \n
        \n Focus\n
        \n
        \n \n
        \n
        \n
        \n Opacity\n
        \n
        \n \n \n
        \n
        \n
        \n \n
        \n
        \n Visibility\n
        \n
        \n \n \n
        \n
        \n
        \n Geometry\n
        \n
        \n X\n
        \n
        \n \n
        \n
        \n Y\n
        \n
        \n \n
        \n
        \n Width\n
        \n
        \n \n
        \n
        \n Height\n
        \n
        \n \n
        \n
        \n
        \n \n
        ',document.getElementById("compositorSetTop").onclick=this.compositorAction.bind(this,"Top"),document.getElementById("sliderOpacity").onchange=this.updateValue.bind(this,"sliderOpacity","numOpacity"),document.getElementById("numOpacity").onchange=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("numOpacity").onkeyup=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("numOpacity").onpaste=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("numOpacity").oninput=this.updateValue.bind(this,"numOpacity","sliderOpacity"),document.getElementById("compositorSetOpacity").onclick=this.compositorSetOpacity.bind(this),document.getElementById("webkit_hide").onclick=this.compositorVisible.bind(this,"Hide"),document.getElementById("webkit_show").onclick=this.compositorVisible.bind(this,"Show"),document.getElementById("compositorGeometry").onclick=this.compositorSetGeometry.bind(this),document.getElementById("compositorClients").onchange=this.clientChange.bind(this);var e=document.getElementById("compositorClients");e.innerHTML="";var n=document.createElement("option");n.value="",n.setAttributeNode(document.createAttribute("disabled")),n.setAttributeNode(document.createAttribute("selected")),n.innerHTML="Select a client",e.appendChild(n);for(var i=0;i{void 0!==t.state&&!0===this.rendered&&this.render(),void 0!==t.suspended&&!0===this.rendered&&this.render()})}controllerStatus(t){const e={plugin:"Controller"};return e.method=t?`status@${t}`:"status",api.req(void 0,e)}harakiri(){const t={plugin:"Controller",method:"harakiri",params:{callsign:this.callsign}};return this.api.req({method:"PUT",path:"Controller/Harakiri",body:null},t)}initiateDiscovery(){return this.api.req({method:"PUT",path:"Controller/Discovery",body:null},{plugin:"Controller",method:"startdiscovery",params:{ttl:1}})}getDiscovery(){return this.api.req({method:"GET",path:"Controller/Discovery",body:null},{plugin:"Controller",method:"discoveryresults"})}persist(t){return this.api.req({method:"PUT",path:"Controller/Persist",body:null},{plugin:"Controller",method:"storeconfig"})}toggleActivity(t){for(var e,n=0;n{void 0!==plugins[t]&&(plugins[t].state="activated"),e.state="activated"}).catch(t=>{this.render()})):(console.debug("Deactivating "+t),this.deactivate(t).then(n=>{void 0!==plugins[t]&&(plugins[t].state="deactivated"),e.state="deactivated"}).catch(t=>{this.render()}))}toggleSuspend(t){for(var e,n=0;n{void 0!==plugins[t]&&(plugins[t].state="activated"),!1===document.getElementById(t+"suspend").checked?this.resume(t).then(this.render.bind(this)):api.suspendPlugin(t).then(this.render.bind(this))});"resumed"===e.state?(console.debug("Suspending "+t),this.suspend(t).then(n=>{this.updateSuspendLabel(t,"resume"),void 0!==plugins[t]&&(plugins[t].state="resumed"),document.getElementById(t+"suspend").checked=!0,e.state="suspended"})):(console.debug("Resuming "+t),this.resume(t).then(n=>{this.updateSuspendLabel(t,"suspend"),void 0!==plugins[t]&&(plugins[t].state="suspended"),document.getElementById(t+"suspend").checked=!1,e.state="resumed"}))}clear(){this.mainDiv.innerHTML=""}discover(){console.log("Initiating discovery"),this.initiateDiscovery();let t=this;setTimeout(function(){t.getDiscovery().then(t=>{var e=t.bridges?t.bridges:t,n=document.getElementById("discoveryList");n.innerHTML="";for(var i=0;i\n Plugins\n \n
        \n
        \n Device actions\n
        \n
        \n \n
        \n
        \n \n
        \n
        \n Discover devices\n
        \n
        \n \n
        \n
        \n
          \n
          \n \n ',document.getElementById("persistButton").onclick=this.persist.bind(this),document.getElementById("harakiriButton").onclick=this.harakiri.bind(this),document.getElementById("discoverButton").onclick=this.discover.bind(this);var t=document.getElementById("controllerPlugins");this.status().then(e=>{var n=e.plugins?e.plugins:e;this.plugins=n;for(var i=0;inew Promise((e,n)=>{this.deviceInfo().then(n=>{e({...t,...n})})}))}deviceInfo(){return this.api.req({method:"GET",path:"DeviceInfo"},{plugin:"DeviceInfo",method:"systeminfo"})}displayInfo(){return this.api.req({method:"GET",path:"DisplayInfo"},{plugin:"DisplayInfo",method:"displayinfo"})}addresses(){return this.api.req({method:"GET",path:"DeviceInfo"},{plugin:"DeviceInfo",method:"addresses"})}socketinfo(){return this.api.req({method:"GET",path:"DeviceInfo"},{plugin:"DeviceInfo",method:"socketinfo"})}update(){this.deviceInfo().then(t=>{let e=t.systeminfo?t.systeminfo:t;this.deviceNameEl.innerHTML=e.devicename,this.serialNumberEl.innerHTML=e.serialnumber,this.versionEl.innerHTML=e.version,this.uptimeEl.innerHTML=e.uptime,this.totalRamEl.innerHTML=this.bytesToMbString(e.totalram),this.usedRamEl.innerHTML=this.bytesToMbString(e.totalram-e.freeram),this.freeRamEl.innerHTML=this.bytesToMbString(e.freeram),this.cpuLoadEl.innerHTML=parseFloat(e.cpuload).toFixed(1)+" %",this.addresses().then(t=>{let e=t.addresses?t.addresses:t;this.interfacesOptsEl.innerHTML="";for(var n=0;n{this.totalGpuRamEl.innerHTML=this.bytesToMbString(t.totalgpuram),this.freeGpuRamEl.innerHTML=this.bytesToMbString(t.freegpuram),this.usedGpuRamEl.innerHTML=this.bytesToMbString(t.totalgpuram-t.freegpuram)}),document.getElementById("startGraphs").onclick=this.startRealtimeGraphs.bind(this)}render(){this.mainDiv.innerHTML=this.template,this.deviceNameEl=document.getElementById("DeviceName"),this.serialNumberEl=document.getElementById("SerialNumber"),this.versionEl=document.getElementById("Version"),this.uptimeEl=document.getElementById("Uptime"),this.totalRamEl=document.getElementById("TotalRam"),this.usedRamEl=document.getElementById("UsedRam"),this.freeRamEl=document.getElementById("FreeRam"),this.totalGpuRamEl=document.getElementById("TotalGpuRam"),this.freeGpuRamEl=document.getElementById("FreeGpuRam"),this.usedGpuRamEl=document.getElementById("UsedGpuRam"),this.cpuLoadEl=document.getElementById("CpuLoad"),this.interfacesOptsEl=document.getElementById("NetworkInterface"),this.interfacesOptsEl.onchange=this.updateNetworkInterface.bind(this),this.macIdEl=document.getElementById("MAC_ID"),this.ipAddressEl=document.getElementById("IpAddress"),this.update()}startRealtimeGraphs(){this.chartOptions.maxElements=parseInt(document.getElementById("graph_max_elements").value),this.chartOptions.interval=parseInt(document.getElementById("graph_poll_interval").value),this.cpuChart=this.generateGraph("CPU usage",document.getElementById("graph_cpu").getContext("2d"),"#34c749","%"),this.ramChart=this.generateGraph("RAM used",document.getElementById("graph_ram").getContext("2d"),"#fc5652","MB"),this.gpuChart=this.generateGraph("GPU RAM used",document.getElementById("graph_gpu").getContext("2d"),"#fdbc40","MB"),this.chartIntervalId=setInterval(this.updateGraphs.bind(this),this.chartOptions.interval),document.getElementById("graphs").style.display="block"}generateGraph(t,e,n,i){return new Chart(e,{type:"line",data:{labels:[],datasets:[{label:t,backgroundColor:n,borderColor:n,data:[],fill:!1}]},options:{responsive:!1,scales:{yAxes:[{ticks:{callback:function(t,e,n){return t+i}}}]}}})}updateGraphs(){let t=this;const e=t.getTimestampForGraph();this.deviceInfo().then(n=>{t.ramChart&&(t.ramChart.config.data.labels.push(e),t.ramChart.config.data.datasets[0].data.push((n.totalram-n.freeram)/1024/1024),t.ramChart.config.data.labels.length>t.chartOptions.maxElements&&(t.ramChart.config.data.labels.shift(),t.ramChart.config.data.datasets[0].data.shift()),t.ramChart.update()),t.cpuChart&&(t.cpuChart.config.data.labels.push(e),t.cpuChart.config.data.datasets[0].data.push(parseFloat(n.cpuload).toFixed(1)),t.cpuChart.config.data.labels.length>t.chartOptions.maxElements&&(t.cpuChart.config.data.labels.shift(),t.cpuChart.config.data.datasets[0].data.shift()),t.cpuChart.update())}),this.displayInfo().then(n=>{t.gpuChart&&(t.gpuChart.config.data.labels.push(e),t.gpuChart.config.data.datasets[0].data.push((n.totalgpuram-n.freegpuram)/1024/1024),t.gpuChart.config.data.labels.length>t.chartOptions.maxElements&&(t.gpuChart.config.data.labels.shift(),t.gpuChart.config.data.datasets[0].data.shift()),t.gpuChart.update())})}close(){clearInterval(this.chartIntervalId),delete this.ramChart,delete this.cpuChart,delete this.gpuChart}updateNetworkInterface(t){this.selectedNetworkInterface=this.interfacesOptsEl.selectedIndex,this.update()}bytesToMbString(t){return(t/1024/1024).toFixed(1)+" MB"}getTimestampForGraph(){const t=new Date;return`${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}`}},DialServer:class extends c{constructor(t,e){super(t,e),this.api.t.on("DIALServer","start",t=>{this.dialMessage("start",t)}),this.api.t.on("DIALServer","stop",t=>{this.dialMessage("stop",t)})}render(){document.getElementById("main").innerHTML='
          \n Received DIAL requests:\n
          \n\n
          ',this.statusMessagesEl=document.getElementById("statusMessages")}dialMessage(t,e){let n=document.createElement("div");"stop"===t&&(n.className="red");let i=document.createElement("span");i.innerHTML=`${t} :: ${e.application} - ${e.parameters}`,n.appendChild(i),this.statusMessagesEl.appendChild(n)}},LocationSync:class extends c{constructor(t,e){super(t,e),this.renderInMenu=!0,this.displayName="Location"}render(){document.getElementById("main").innerHTML='
          \n Location\n
          \n\n
          \n City\n
          \n
          \n -\n
          \n
          \n Country\n
          \n
          \n -\n
          \n
          \n Region\n
          \n
          \n -\n
          \n\n
          \n Timezone\n
          \n
          \n -\n
          \n\n
          \n Public IP\n
          \n
          \n -\n
          \n\n
          \n Sync\n
          \n
          \n \n
          ',document.getElementById("syncButton").onclick=this.syncLocation.bind(this),this.cityEl=document.getElementById("city"),this.countryEl=document.getElementById("country"),this.regionEl=document.getElementById("region"),this.timezoneEl=document.getElementById("timezone"),this.publicIpEl=document.getElementById("publicip"),this.update()}syncLocation(){const t={method:"PUT",path:`${this.callsign}`},e={plugin:this.callsign,method:"sync"};this.api.req(t,e).then(()=>{this.update()})}location(){const t={method:"GET",path:`${this.callsign}`},e={plugin:this.callsign,method:"location"};return this.api.req(t,e)}update(){this.location().then(t=>{this.cityEl.innerHTML=t.city,this.countryEl.innerHTML=t.country,this.regionEl.innerHTML=t.region,this.timezoneEl.innerHTML=t.timezone,this.publicIpEl.innerHTML=t.publicip})}},Monitor:u,Netflix:g,NetworkControl:class extends c{constructor(t,e){super(t,e),this.renderInMenu=!0,this.displayName="Network",this.selectedNetworkInterface=0,this.networks=[]}render(){document.getElementById("main").innerHTML='\n
          \n Network Control\n
          \n
          \n Network Interface\n
          \n
          \n \n
          \n
          \n IP Address\n
          \n
          \n -\n
          \n
          \n Broadcast\n
          \n
          \n -\n
          \n
          \n Gateway\n
          \n
          \n -\n
          \n
          \n mask\n
          \n
          \n -\n
          \n
          \n mode\n
          \n
          \n -\n
          \n\n
          \n Control\n
          \n
          \n \n \n \n \n
          ',this.interfacesOptsEl=document.getElementById("NetworkInterface"),this.interfacesOptsEl.onchange=this.updateNetworkInterface.bind(this),document.getElementById("reload").onclick=this.reload.bind(this);document.getElementById("request");request.onclick=this.request.bind(this),document.getElementById("assign").onclick=this.assign.bind(this),document.getElementById("flush").onclick=this.flush.bind(this),this.ipEl=document.getElementById("ip"),this.broadcastEl=document.getElementById("broadcast"),this.gatewayEl=document.getElementById("gateway"),this.maskEl=document.getElementById("mask"),this.modeEl=document.getElementById("mode"),this.api.t.on("NetworkControl","networkupdate",t=>{console.log("NETWORK NOT",t),this.update()}),this.update()}network(){const t={method:"GET",path:`${this.callsign}`},e={plugin:this.callsign,method:"network"};return this.api.req(t,e)}reload(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Reload`},n={plugin:this.callsign,method:"reload",params:{device:t}};return this.api.req(e,n)}request(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Request`},n={plugin:this.callsign,method:"request",params:{device:t}};return this.api.req(e,n)}assign(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Assign`},n={plugin:this.callsign,method:"assign",params:{device:t}};return this.api.req(e,n)}flush(){let t=this._addresses[this.interfacesOptsEl.selectedIndex].interface;const e={method:"PUT",path:`${this.callsign}/${t}/Flush`},n={plugin:this.callsign,method:"flush",params:{device:t}};return this.api.req(e,n)}update(){this.network().then(t=>{let e=t.addresses?t.addresses:t;this._addresses=e,this.interfacesOptsEl.innerHTML="";for(var n=0;n{if(null==t)return;let e=t.systems?t.systems:t;for(let t=0;t{void 0!==t.PowerState&&(this.powerStateDiv.innerHTML=this.stateLookup[t.PowerState],this.stateSelectorEl.children[t.PowerState-1].selected=!0)})}changeState(t){const e={method:"POST",path:`${this.callsign}/State`,body:{PowerState:this.stateSelectorEl.value}},n={plugin:this.callsign,method:"state",params:{powerstate:this.stateSelectorEl.value}};""!==this.timeoutInput.value&&(e.body.Timeout=this.timeoutInput.value,n.body.timeout=this.timeoutInput.value),this.api.req(e).then(()=>{t<2&&setTimeout(this.update,5e3)})}},Provisioning:class extends c{constructor(t,e){super(t,e)}render(){document.getElementById("main").innerHTML='
          \n Provisioning status\n
          \n\n
          \n Device\n
          \n
          \n -\n
          \n
          \n Provisioned for\n
          \n
          \n -\n
          \n
          \n Status\n
          \n
          \n -\n
          \n\n
          \n Provisioning\n
          \n
          \n \n
          ',document.getElementById("provisionButton").onclick=this.tiggerProvisioningRequest.bind(this),this.update()}triggerProvisioning(){const t={method:"PUT",path:`${this.callsign}`},e={plugin:this.callsign,method:"provision"};return this.api.req(t,e)}status(){const t={method:"GET",path:this.callsign},e={plugin:this.callsign,method:"state"};return this.api.req(t,e)}update(){this.status().then(t=>{if(null!=t&&""!==t){var e=t.id,n=t.tokens||[],i=t.status;document.getElementById("device").innerHTML=e,document.getElementById("status").innerHTML=200==i?"provisioned":"not provisioned",200==i&&n.length>0&&(document.getElementById("provisioning-tokens").innerHTML=n.join(", ")),document.getElementById("provisionLabel").style.display=200==i?"none":null}}).catch(t=>{console.error(t),this.status(t)})}tiggerProvisioningRequest(){var t=this;this.triggerProvisioning().then(e=>{document.getElementById("provisionButton").style.display="none",document.getElementById("provisionLabel").style.display="none",setTimeout(t.update(),3e3)})}},RemoteControl:class extends c{constructor(t,e){super(t,e),this.displayName="Remote Control",this.onScreenKeyBoardIsRendered=!1,this.doNotHandleKeys=!1,this.devicesThatSupportPairing=["GreenPeakRF4CE","GreenPeak","RF4CE"],this.autoFwdKeys=window.localStorage.getItem("autoFwdKeys"),this.automaticallyForwardKeys="false"!==this.autoFwdKeys,this.keyMapping={1:{code:"0x0021",color:void 0,string:"1"},2:{code:"0x0022",color:void 0,string:"2"},3:{code:"0x0023",color:void 0,string:"3"},4:{code:"0x0024",color:void 0,string:"4"},5:{code:"0x0025",color:void 0,string:"5"},6:{code:"0x0026",color:void 0,string:"6"},7:{code:"0x0027",color:void 0,string:"7"},8:{code:"0x0028",color:void 0,string:"8"},9:{code:"0x0029",color:void 0,string:"9"},0:{code:"0x0020",color:void 0,string:"0"},exit:{code:"0x0009",color:"blue",string:"exit"},a:{code:"0x8004",color:void 0,string:"a"},b:{code:"0x8005",color:void 0,string:"b"},c:{code:"0x8006",color:void 0,string:"c"},d:{code:"0x8007",color:void 0,string:"d"},e:{code:"0x8008",color:void 0,string:"e"},f:{code:"0x8009",color:void 0,string:"f"},g:{code:"0x800A",color:void 0,string:"g"},h:{code:"0x800B",color:void 0,string:"h"},i:{code:"0x800C",color:void 0,string:"i"},back:{code:"0x0032",color:"blue double",string:"back"},j:{code:"0x800D",color:void 0,string:"j"},k:{code:"0x800E",color:void 0,string:"k"},l:{code:"0x800F",color:void 0,string:"l"},m:{code:"0x8010",color:void 0,string:"m"},n:{code:"0x8011",color:void 0,string:"n"},o:{code:"0x8012",color:void 0,string:"o"},p:{code:"0x8013",color:void 0,string:"p"},q:{code:"0x8014",color:void 0,string:"q"},r:{code:"0x8015",color:void 0,string:"r"},up:{code:"0x0001",color:"blue",string:"up",div:'
          '},ok:{code:"0x002B",color:"blue",string:"ok"},s:{code:"0x8016",color:void 0,string:"s"},t:{code:"0x8017",color:void 0,string:"t"},u:{code:"0x8018",color:void 0,string:"u"},v:{code:"0x8019",color:void 0,string:"v"},w:{code:"0x801A",color:void 0,string:"w"},x:{code:"0x801B",color:void 0,string:"x"},y:{code:"0x801C",color:void 0,string:"y"},z:{code:"0x801D",color:void 0,string:"z"},left:{code:"0x0003",color:"blue",string:"left",div:'
          '},down:{code:"0x0002",color:"blue",string:"down",div:'
          '},right:{code:"0x0004",color:"blue",string:"right",div:'
          '}},this.jsToWpeKeyMap={13:{code:"0x002B",string:"enter"},37:{code:"0x0003",string:"left"},38:{code:"0x0001",string:"up"},39:{code:"0x0004",string:"right"},40:{code:"0x0002",string:"down"},27:{code:"0x0009",string:"esc"},8:{code:"0x0032",string:"backspace"},48:{code:"0x0020",string:"0"},49:{code:"0x0021",string:"1"},50:{code:"0x0022",string:"2"},51:{code:"0x0023",string:"3"},52:{code:"0x0024",string:"4"},53:{code:"0x0025",string:"5"},54:{code:"0x0026",string:"6"},55:{code:"0x0027",string:"7"},56:{code:"0x0028",string:"8"},57:{code:"0x0029",string:"9"},33:{code:"0x0030",string:"page up"},34:{code:"0x0031",string:"page down"},65:{code:"0x8004",string:"a"},66:{code:"0x8005",string:"b"},67:{code:"0x8006",string:"c"},68:{code:"0x8007",string:"d"},69:{code:"0x8008",string:"e"},70:{code:"0x8009",string:"f"},71:{code:"0x800A",string:"g"},72:{code:"0x800B",string:"h"},73:{code:"0x800C",string:"i"},74:{code:"0x800D",string:"j"},75:{code:"0x800E",string:"k"},76:{code:"0x800F",string:"l"},77:{code:"0x8010",string:"m"},78:{code:"0x8011",string:"n"},79:{code:"0x8012",string:"o"},80:{code:"0x8013",string:"p"},81:{code:"0x8014",string:"q"},82:{code:"0x8015",string:"r"},83:{code:"0x8016",string:"s"},84:{code:"0x8017",string:"t"},85:{code:"0x8018",string:"u"},86:{code:"0x8019",string:"v"},87:{code:"0x801A",string:"w"},88:{code:"0x801B",string:"x"},89:{code:"0x801C",string:"y"},90:{code:"0x801D",string:"z"},46:{code:"0x802A",string:"delete"},32:{code:"0x802C",string:"space"},189:{code:"0x802D",string:"-"},187:{code:"0x802E",string:"="},220:{code:"0x8031",string:"\\"},186:{code:"0x8033",string:";"},222:{code:"0x8034",string:"`"},188:{code:"0x8036",string:","},190:{code:"0x8037",string:"."},191:{code:"0x8038",string:"/"}},this.addKeyboardButton(),this.keyboardDiv=document.getElementById("keyboard"),this.keyBoardInnerDiv=document.createElement("div"),this.keyBoardInnerDiv.id="keyboard-inner";for(var n=Object.keys(this.keyMapping),i=0;i{if(void 0!==e)for(var n=void 0!==e.devices?e.devices:e,i=document.getElementById("remotesList"),s=document.getElementById("pairingDiv"),o=0;o\n Pairing\n '),s.innerHTML+=`
          ${l}
          \n
          \n \n
          `,document.getElementById(l+"-PairingMode").onclick=t.activatePairing.bind(t,l)}})}toggleAutoforwardOfKeys(){this.automaticallyForwardKeys=!0!==this.automaticallyForwardKeys,window.localStorage.setItem("autoFwdKeys",this.automaticallyForwardKeys)}},Snapshot:class extends c{constructor(t,e){super(t,e)}render(){document.getElementById("main").innerHTML='
          \n Create\n
          \n\n
          \n Snapshot\n
          \n
          \n \n
          \n\n
          \n \n
          ',document.getElementById("snapshotButton").onclick=this.createSnapshot.bind(this)}getSnapshotLocator(){return this.api.getURLStart("http")+"Snapshot/Capture?"+(new Date).getTime()}createSnapshot(){var t=document.getElementById("snapshotOutput");t.src="",t.src=this.getSnapshotLocator()}},Spark:class extends c{constructor(t,e){super(t,e),this.url="",this.isHidden=!1,this.isSuspended=!1,this.lastSetUrlKey="lastSetUrl"+this.callsign,this.lastSetUrl=window.localStorage.getItem(this.lastSetUrlKey)||"",this.template='
          \n\n
          Presets / URL
          \n\n
          \n \n
          \n
          \n \n \n
          \n\n
          URL presets
          \n
          \n \n
          \n\n
          Tools
          \n\n
          Current State
          \n
          \n
          \n
          \n \n
          \n\n
          Visibility
          \n
          \n
          \n
          \n \n
          \n
          ',this.presets=[{Name:"Select a preset",URL:""},{Name:"http://www.sparkui.org/examples/gallery/picturepile.js",URL:"http://www.sparkui.org/examples/gallery/picturepile.js"},{Name:"http://www.sparkui.org/examples/gallery/gallery.js",URL:"http://www.sparkui.org/examples/gallery/gallery.js"}],this.api.t.on("Spark","urlchange",t=>{t.url&&t.loaded&&(this.url=t.url,this.handleNotification())}),this.api.t.on("Spark","visibilitychange",t=>{"boolean"==typeof t.hidden&&(this.isHidden=t.hidden,this.handleNotification())}),this.api.t.on("Spark","statechange",t=>{"boolean"==typeof t.suspended&&(this.isSuspended=t.suspended,this.handleNotification())})}handleNotification(t){!1!==this.rendered&&this.update()}render(){var t=document.getElementById("main"),e=this.template.replace(/{{callsign}}/g,this.callsign);t.innerHTML=e,document.getElementById(this.callsign+"_url").value=this.lastSetUrl,document.getElementById(this.callsign+"_button").onclick=this.getAndSetUrl.bind(this),document.getElementById(this.callsign+"_linkPresets").onchange=this.getAndSetUrlFromPresets.bind(this);var n=document.getElementById(this.callsign+"_linkPresets");if(0===n.children.length)for(var i=0;i0&&this.setUrl(this.presets[t].URL)}handleKey(t){var e=document.getElementById(`${this.callsign}_url`);13===t.which&&e&&e===document.activeElement&&this.getAndSetUrl()}toggleSuspend(t){"Resume"===t?this.resume():this.suspend()}toggleVisibility(t){"Show"===t?this.show():this.hide()}},Switchboard:class extends c{constructor(t,e){super(t,e),this.defaultPlugin=void 0,this.switchablePlugins=[],this.state().then(t=>{this.defaultPlugin=t.default,this.switchablePlugins=t.callsigns})}state(){const t={method:"GET",path:`${this.callsign}/Switch`};return this.api.req(t)}getDefaultSwitchBoardPlugin(){return this.defaultPlugin}getSwitchablePlugins(){return this.switchBoardPlugins}render(){this.mainDiv=document.getElementById("main"),this.mainDiv.innerHTML='\n
          \n Plugins\n
          \n
          ';var t=document.getElementById("switchBoardPlugins");this.api.getControllerPlugins().then(e=>{for(var n=e.plugins,i=0;i{this.render()})}},TimeSync:class extends c{constructor(t,e){super(t,e),this.renderInMenu=!0,this.displayName="Time"}render(){document.getElementById("main").innerHTML='\n
          \n Time\n
          \n
          \n Current time\n
          \n
          \n -\n
          \n
          \n Source\n
          \n
          \n -\n
          \n
          \n Last synced\n
          \n
          \n -\n
          \n\n
          \n \n
          \n
          \n \n \n
          \n\n
          \n Control\n
          \n
          \n \n
          ',document.getElementById("setTime").onclick=this.setTime.bind(this),document.getElementById("sync").onclick=this.synchronizeTime.bind(this),this.timeEl=document.getElementById("time"),this.sourceEl=document.getElementById("source"),this.syncedEl=document.getElementById("synced"),this.api.t.on("TimeSync","update",t=>{console.log("TIME NOT",t),this.update()}),this.update()}synchronizeTime(){this.syncTime().then(this.synchronize())}synchronize(){const t={plugin:this.callsign,method:"synchronize"};return this.api.req(null,t)}syncTime(){const t={plugin:this.callsign,method:"synctime"};return this.api.req(null,t)}setTime(){let t=document.getElementById("timeinput").value;const e={method:"POST",path:`${this.callsign}`,body:{time:t}},n={plugin:this.callsign,method:"time",params:t};return this.api.req(e,n)}getTime(){const t={method:"GET",path:`${this.callsign}`},e={plugin:this.callsign,method:"time"};return this.api.req(t,e)}update(){this.getTime().then(t=>{this.timeEl.innerHTML=t,this.syncTime().then(t=>{this.sourceEl.innerHTML=t.source,this.syncedEl.innerHTML=t.time})})}},TraceControl:class extends c{constructor(t,e){super(t,e),this.displayName="Tracing",this.selectedTraceModule=void 0,this.traceModules=void 0,this.uniqueTraceModules=void 0}toggleTracing(t,e,n){const i={method:"PUT",path:"TraceControl/"+t+"/"+e+"/"+n},s={plugin:"TraceControl",method:"set",params:{module:t,category:e,state:"on"===n?"enabled":"disabled"}};return this.api.req(i,s)}render(){var t=this;document.getElementById("main").innerHTML='
          \n Modules\n
          \n\n
          \n \n
          \n
          \n \n
          \n\n
          ',document.getElementById("tracingModules").onchange=this.getSelectedModuleAndShowCategories.bind(this),this.status().then(e=>{t.traceModules=e.settings?e.settings:[],t.uniqueTraceModules=[];var n=document.getElementById("tracingModules");n.getElementsByTagName("options");if(n.options.length=0,void 0!==t.traceModules){for(var i=0;i{this.mutedEl.innerHTML=t}),this.volume().then(t=>{this.volumeEl.innerHTML=t})}muted(t){const e={plugin:this.callsign,method:"muted"};return t&&(e.params=t),this.api.req(null,e)}volume(t){const e={plugin:this.callsign,method:"volume"};return t&&(e.params=t),this.api.req(null,e)}volumeChange(t){this.volume().then(e=>{this.volume(e+t).then(this.update())})}mute(){this.muted().then(t=>{this.muted(!t).then(this.update())})}},WebKitBrowser:h,WebShell:class extends c{constructor(t,e){super(t,e),this.webShellSocket=void 0}render(){var t=this;document.getElementById("main").innerHTML='
          WebShell
          \n
          \n
          \n        
          \n
          #
          ',this.api.startWebShell(function(e,n){t.webShellSocket=n,t.webShellSocket.onmessage=function(t){var e=new FileReader;e.onload=function(){document.getElementById("webShellData").innerHTML=String.fromCharCode.apply(null,new Uint8Array(e.result))},e.readAsArrayBuffer(t.data)},t.webShellSocket.onclose=function(){t.webShellSocket=null,t.render()}}),void 0!==plugins.RemoteControl&&(plugins.RemoteControl.doNotHandleKeys=!0),window.addEventListener("keydown",this.handleKey.bind(this))}close(){void 0!==plugins.RemoteControl&&(plugins.RemoteControl.doNotHandleKeys=!1),window.removeEventListener("keydown",this.handleKey.bind(this),!1)}handleKey(t){if(this.webShellSocket&&13===t.which){for(var e=document.getElementById("webShellInput").value+" \n",n=new ArrayBuffer(2*e.length),i=new Uint8Array(n),s=0,o=e.length;s{!0===this.rendered&&this.getNetworks()}),this.api.t.on("WifiControl","connectionchange",t=>{this.connected=t.connected,!0===this.rendered&&this.update()})}render(){document.getElementById("main").innerHTML='
          \n Status\n
          \n\n
          \n Connected to\n
          \n
          \n\n
          \n Scanning\n
          \n
          \n False\n
          \n\n
          \n Wireless networks\n
          \n
          \n \n
          \n
          \n
          \n
          \n \n
          \n\n
          \n Configs\n
          \n\n
          \n Configs\n
          \n
          \n \n
          \n\n
          \n SSID\n
          \n
          \n \n
          \n
          \n Mode\n
          \n
          \n
          \n \x3c!-- disable for now\n
          \n
          \n \n
          \n --\x3e\n
          \n Hidden\n
          \n
          \n
          \n Method\n
          \n
          \n \n
          \n
          \n Password\n
          \n
          \n \n
          \n
          Controls
          \n
          \n \n \n \n
          \n
          \n
          \n \n \n
          \n\n
          \n
          \n ',this.scanButton=document.getElementById("Wifi_scanForNetworksButton"),this.saveButton=document.getElementById("Wifi_saveButton"),this.deleteButton=document.getElementById("Wifi_deleteButton"),this.storeButton=document.getElementById("Wifi_storeButton"),this.connectButton=document.getElementById("Wifi_connectButton"),this.disconnectButton=document.getElementById("Wifi_disconnectButton"),this.scanButton.onclick=this.scanForNetworks.bind(this),this.deleteButton.onclick=this.deleteConfig.bind(this),this.saveButton.onclick=this.saveConfig.bind(this),this.storeButton.onclick=this.storeConfig.bind(this),this.disconnectButton.onclick=this.disconnect.bind(this),this.connectButton.onclick=this.connect.bind(this),this.connectedStatus=document.getElementById("Wifi_Connected"),this.scanningStatus=document.getElementById("Wifi_Scanning"),this.statusMessages=document.getElementById("statusMessages"),this.networkListEl=document.getElementById("Wifi_WirelessNetwork"),this.networkListEl.onchange=this.renderNetworkDetails.bind(this),this.configListEl=document.getElementById("Wifi_Configs"),this.configListEl.onchange=this.renderConfigDetails.bind(this),this.ssidEl=document.getElementById("Wifi_SSID"),this.methodEl=document.getElementById("Wifi_Method"),this.passwordEl=document.getElementById("Wifi_Password"),this.accesspointEl=document.getElementById("Wifi_Mode"),this.hiddenEl=document.getElementById("Wifi_Hidden"),this.update(),setTimeout(this.getNetworks.bind(this),200),setTimeout(this.getConfigs.bind(this),400),this.rendered=!0}update(){this.status().then(t=>{void 0!==t&&(this.connected=t.connected,"boolean"==typeof t.scanning&&(this.scanning=t.scanning),this.renderStatus())})}scanForNetworks(){const t={method:"PUT",path:`${this.callsign}/Scan`},e={plugin:this.callsign,method:"scan"};this.api.req(t,e).then(t=>{this.update(),setTimeout(this.getNetworks.bind(this),5e3)})}getConfigs(){this.update();const t={method:"GET",path:`${this.callsign}/Configs`},e={plugin:this.callsign,method:"configs"};this.api.req(t,e).then(t=>{if(void 0===t)return;let e=t.configs?t.configs:t;if(void 0!==e){this.configs=e,this.configListEl.innerHTML="";for(var n=0;n{if(void 0===t)return;if(this.networks=[],!1===this.rendered)return;let e=t.networks?t.networks:t;this.networkListEl.innerHTML="";for(var n=0;n{this.statusMessage(`Saved config for ${this.ssidEl.value}`),t.getConfigs()})}deleteConfig(){var t=this.configListEl.selectedIndex;this.statusMessage(`Deleting config ${this.configs[t].ssid}`);const e={method:"PUT",path:`${this.callsign}/Delete/${this.configs[t].ssid}`},n={plugin:this.callsign,method:"delete",params:{ssid:this.configs[t].ssid}};this.api.req(e,n).then(()=>{this.connecting=!0,this.getConfigs()})}requestDHCP(){this.statusMessage("Requesting DHCP for wlan0");const t={method:"PUT",path:`NetworkControl/${this.wlanInterface}/Request`},e={plugin:"NetworkControl",method:"request",params:{device:this.wlanInterface}};this.api.req(t,e)}storeConfig(){this.statusMessage("Storing WiFi configuration");const t={method:"PUT",path:`${this.callsign}/${this.wlanInterface}/Store`},e={plugin:this.callsign,method:"store"};this.api.req(t,e)}connect(){var t=this.configListEl.selectedIndex;this.statusMessage(`Connecting to ${this.configs[t].ssid}`);const e={method:"PUT",path:`${this.callsign}/Connect/${this.configs[t].ssid}`},n={plugin:this.callsign,method:"connect",params:{ssid:this.configs[t].ssid}};this.api.req(e,n).then(()=>{this.connecting=!0,setTimeout(this.requestDHCP.bind(this),5e3)})}disconnect(){if(void 0===this.connected||""===this.connected)return;const t={method:"DELETE",path:`${this.callsign}/Connect/${this.connected}`},e={plugin:this.callsign,method:"disconnect",params:{ssid:this.connected}};this.statusMessage(`Disconnecting from ${this.connected}`),this.api.req(t,e)}close(){this.rendered=!1}}};n.d(e,"b",function(){return f}),n.d(e,"c",function(){return b}),n.d(e,"a",function(){return l});var m={},_=void 0,v=(document.getElementById("main"),window.localStorage.getItem("lastActivePlugin")||void 0);function f(t){(_=new o(t)).getControllerPlugins().then(t=>t).then(t=>{for(var e=0;e1)for(var n=1;n { + if (e.message) + this.updateStatus(`Error: ${e.message}`); + }) } pairDevice() { var idx = this.deviceList.selectedIndex; this.updateStatus(`Pairing to ${this._devices[idx].name}`); - const _rest = { - method : 'PUT', - path : '/Pair', - body : '{"address" : "' + this._devices[idx].address + '"}' - }; - const _rpc = { plugin : this.callsign, method : 'pair', @@ -294,19 +290,16 @@ class BluetoothControl extends Plugin { } }; - this.api.req(_rest, _rpc) + this.api.req(null, _rpc).catch( e => { + if (e.message) + this.updateStatus(`Error: ${e.message}`, true); + }) } unpairDevice() { var idx = this.deviceList.selectedIndex; this.updateStatus(`Unpairing ${this._devices[idx].name}`); - const _rest = { - method : 'PUT', - path : '/Unpair', - body : '{"address" : "' + this._devices[idx].address + '"}' - }; - const _rpc = { plugin : this.callsign, method : 'unpair', @@ -315,19 +308,16 @@ class BluetoothControl extends Plugin { } }; - this.api.req(_rest, _rpc) + this.api.req(null, _rpc).catch( e => { + if (e.message) + this.updateStatus(`Error: ${e.message}`, true); + }) } connect() { var idx = this.deviceList.selectedIndex; this.updateStatus(`Connecting to ${this._devices[idx].name}`); - const _rest = { - method : 'PUT', - path : '/Connect', - body : '{"address" : "' + this._devices[idx].address + '"}' - }; - const _rpc = { plugin : this.callsign, method : 'connect', @@ -336,19 +326,16 @@ class BluetoothControl extends Plugin { } }; - this.api.req(_rest, _rpc) + this.api.req(null, _rpc).catch( e => { + if (e.message) + this.updateStatus(`Error: ${e.message}`, true); + }) } disconnect() { var idx = this.deviceList.selectedIndex; this.updateStatus(`Disconnecting from ${this._devices[idx].name}`); - const _rest = { - method : 'DELETE', - path : '/Connect', - body : '{"address" : "' + this._devices[idx].address + '"}' - }; - const _rpc = { plugin : this.callsign, method : 'disconnect', @@ -357,7 +344,10 @@ class BluetoothControl extends Plugin { } }; - this.api.req(_rest, _rpc) + this.api.req(null, _rpc).catch( e => { + if (e.message) + this.updateStatus(`Error: ${e.message}`, true); + }) } assign() { @@ -387,7 +377,10 @@ class BluetoothControl extends Plugin { } }; - this.api.req(null, _rpc) + this.api.req(null, _rpc).catch( e => { + if (e.message) + this.updateStatus(`Error: ${e.message}`, true); + }) } close() {