From ab4a4a9c49c25e2703b1fded3272d0a4cfb35838 Mon Sep 17 00:00:00 2001 From: NateN1222 Date: Sat, 12 Aug 2017 12:27:49 -0500 Subject: UI improvements, started a file for the JS evaluation --- html/display_panel/content/display-panel.html | 6 ++-- html/display_panel/content/main_panel.js | 41 +++++++++++++++++++-------- 2 files changed, 32 insertions(+), 15 deletions(-) (limited to 'html/display_panel/content') diff --git a/html/display_panel/content/display-panel.html b/html/display_panel/content/display-panel.html index e8345ae..8a456c8 100644 --- a/html/display_panel/content/display-panel.html +++ b/html/display_panel/content/display-panel.html @@ -47,9 +47,9 @@ LibreJS 7.0

-
-
-
+
+ +
diff --git a/html/display_panel/content/main_panel.js b/html/display_panel/content/main_panel.js index 54db745..3848a2e 100644 --- a/html/display_panel/content/main_panel.js +++ b/html/display_panel/content/main_panel.js @@ -69,8 +69,6 @@ function write_elements(data,name,color){ } else{ heading.innerHTML = "

List of
" + name.toUpperCase() + "
javascript in " + data["url"]+":

"; } - console.log(data); - console.log(data[name]); // Iterate over data[name] and generate bulleted list for(var i = 0; i < data[name].length; i++){ list.innerHTML += "
  • "+data[name][i][0]+ ":
    " + data[name][i][1]+"\n"+button_html+"

    \n"+button_html_2+"

    \n"+button_html_3+"
  • "; @@ -112,12 +110,25 @@ function write_elements(data,name,color){ /** * displays the button specified by HTML string "button" */ -var num_buttons = 0; -function write_button(button,lr,callback){ - - document.getElementById("buttons-"+lr).insertAdjacentHTML("beforeend","
    " + button + "
    "); - document.getElementById("buttonno_"+num_buttons).addEventListener("click",callback); - num_buttons = num_buttons + 1; +var template = ''; +var lr_flag = true; +var button_num = 0; +function write_button(button,callback){ + var id = "buttonno_"+button_num; + if(lr_flag){ + document.getElementById("buttons_table").insertAdjacentHTML("beforeend",template); + document.getElementById("c1").insertAdjacentHTML("beforeend","
    " + button + "
    "); + document.getElementById("c1").id = "cell_"+button_num; + }else{ + var temp = document.getElementById("c2"); + temp.id = "cell_"+button_num; + temp.insertAdjacentHTML("beforeend","
    " + button + "
    "); + } + + button_num = button_num+1; + lr_flag = !lr_flag; + + document.getElementById(id).addEventListener("click",callback); } /** * update the HTML of the pop-up window. @@ -157,10 +168,16 @@ function generate_HTML(blocked_data){ if( blocked_data["blacklisted"].length != 0 || blocked_data["blocked"].length != 0 || blocked_data["whitelisted"].length != 0 || blocked_data["accepted"].length != 0){ - write_button(button_allow_all,"l",function(){console.log("button_allow_all");}); - write_button(button_block_nonfree,"r",function(){console.log("button_block_nonfree");}); - write_button(button_complain,"l",function(){console.log("button_complain");}); - write_button(button_new_tab,"r",function(){ + write_button(button_allow_all,function(){ + console.log("button_allow_all"); + }); + write_button(button_block_nonfree,function(){ + console.log("button_block_nonfree"); + }); + write_button(button_complain,function(){ + myPort.postMessage({"invoke_contact_finder": blocked_data}); + }); + write_button(button_new_tab,function(){ myPort.postMessage({"open_popup_tab": blocked_data}); }); } else{ -- cgit v1.2.3