From 33db5e1fd5f3d94d070ed37f46f370adcdaf1b3b Mon Sep 17 00:00:00 2001 From: NateN1222 Date: Tue, 1 Aug 2017 11:10:34 -0500 Subject: UI improvements, removed ES6 'for ... of' statements --- html/display_panel/content/main_panel.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'html') 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 = 'Complain to site owner'; var button_allow_all = 'Allow all scripts in this page'; @@ -70,17 +75,21 @@ function generate_HTML(blocked_data){ } if(a["blocked"].length != 0){ blocked.innerHTML += ""; + // 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"]); -- cgit v1.2.3