From: Mike Frysinger Date: Mon, 15 Apr 2013 03:27:09 +0000 (-0400) Subject: extract user-set name for device, and link to the system X-Git-Tag: v1.2~1 X-Git-Url: https://git.wh0rd.org/?p=chrome-ext%2Fweb-power-switch.git;a=commitdiff_plain;h=3857351138595924308dbfd84bb06a46b3b8a978 extract user-set name for device, and link to the system --- diff --git a/popup.js b/popup.js index 7ba21e2..189bbb7 100644 --- a/popup.js +++ b/popup.js @@ -88,6 +88,31 @@ function initpopup(xhr, state) { // There is no clean API for extracting the current state. // Example result: + /* + + + Controller: !!!Web Power Switch 6 + + + */ + + var th, ths = state.currentTarget.responseXML.querySelectorAll('th'); + for (var i = 0; th = ths[i]; ++i) { + if (th.bgColor != '#DDDDFF') + continue; + + var controller_name = trim(th.innerText); + if (controller_name.slice(0, 12) != 'Controller: ') + continue; + + row = tbl.insertRow(-1); + cell = row.insertCell(-1); + cell.colSpan = 2; + cell.align = 'center'; + cell.innerText = controller_name.slice(12); + cell.innerHTML = '' + cell.innerHTML + '' + } + /* 1 Outlet 1