diff options
author | NateN1222 <nathannichols454@gmail.com> | 2017-08-01 11:10:34 -0500 |
---|---|---|
committer | NateN1222 <nathannichols454@gmail.com> | 2017-08-01 11:10:34 -0500 |
commit | 33db5e1fd5f3d94d070ed37f46f370adcdaf1b3b (patch) | |
tree | 9945488a99f10cd433a37dfe386b07465cfefd0d | |
parent | a74bb8ae5e20afa57cbd8bcbffa9420a6281593e (diff) |
UI improvements, removed ES6 'for ... of' statements
-rw-r--r-- | html/display_panel/content/main_panel.js | 19 | ||||
-rw-r--r-- | main_background.js | 15 |
2 files changed, 27 insertions, 7 deletions
diff --git a/html/display_panel/content/main_panel.js b/html/display_panel/content/main_panel.js index 2becb4e..44be902 100644 --- a/html/display_panel/content/main_panel.js +++ b/html/display_panel/content/main_panel.js @@ -18,6 +18,10 @@ function set_webex(){ } set_webex(); + +var myPort = webex.runtime.connect({name:"port-from-cs"}); +var current_blocked_data; + /** * update the HTML of the pop-up window. * If return_HTML is true, it returns the HTML of the popup window without updating it. @@ -31,6 +35,7 @@ set_webex(); * */ function generate_HTML(blocked_data){ + current_blocked_data = blocked_data; var a = blocked_data; var button_complain = '<a id="complain-contact" class="button white" href="#"><span>Complain to site owner</span></a>'; var button_allow_all = '<a id="allow-button" class="button white" href="#"><span>Allow all scripts in this page</span></a>'; @@ -70,17 +75,21 @@ function generate_HTML(blocked_data){ } if(a["blocked"].length != 0){ blocked.innerHTML += "</ul>"; + // add click listeners to the buttons + for(var i = 0; i < a["blocked"].length; i++){ + document.getElementById("wl_"+i).addEventListener("click",function(a){ + console.log(a.path[0].id + " clicked"); + var temp = current_blocked_data["blocked"][parseInt(a.path[0].id.substr(3))]; + console.log(temp); + myPort.postMessage({"whitelist_script": temp}); + }); + } } // At this point, it has the HTML that the popup needs and the only problem is // getting it into the popup. (browserAction() needs a (local) URL to work). } - -// content-script.js - -var myPort = webex.runtime.connect({name:"port-from-cs"}); - myPort.onMessage.addListener(function(m) { if(m["show_info"] !== undefined){ generate_HTML(m["show_info"]); diff --git a/main_background.js b/main_background.js index 300cfb7..caa40cd 100644 --- a/main_background.js +++ b/main_background.js @@ -36,7 +36,8 @@ function options_listener(changes, area){ var changedItems = Object.keys(changes); var changed_items = ""; - for (var item of changedItems) { + for (var i = 0; i < changedItems.length; i++;) { + var item = changedItems[i]; changed_items += item + ","; } console.log(changed_items); @@ -91,10 +92,20 @@ function update_popup(tab_id,blocked_info){ */ var portFromCS; function connected(p) { + console.log("Message:"); console.log(p); p.onMessage.addListener(function(m) { + + + if(m["whitelist_script"] !== undefined){ + console.log("whitelisting script " + m["whitelist_script"][0]); + return; + } + + function logTabs(tabs) { - for(let tab of tabs) { + for(var i = 0; i < tabs.length; i++) { + var tab = tabs[i] var tab_id = tab["id"] console.log(tab_id) if(unused_data[tab_id] !== undefined){ |