From ebd35f4ca3638dcb7d637ff417cf2a1d64a14774 Mon Sep 17 00:00:00 2001 From: didierfred <didierfred@gmail.com> Date: Sun, 29 Apr 2018 19:35:31 +0200 Subject: [PATCH] clean code --- background.js | 4 ++-- manifest.json | 2 +- popup/config.js | 16 +++++----------- popup/menu.js | 2 +- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/background.js b/background.js index d1e61a2..b424d12 100644 --- a/background.js +++ b/background.js @@ -4,7 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * @author didierfred@gmail.com - * @version 0.2 + * @version 0.3 */ @@ -49,7 +49,7 @@ else { console.log("Load default config"); var headers = []; - headers.push({action:"add",header_name:"test_header_name",header_value:"test_header_value",comment:"test",apply_on:"req",status:"on"}); + headers.push({action:"add",header_name:"test-header-name",header_value:"test-header-value",comment:"test",apply_on:"req",status:"on"}); config = {format_version:"1.1",target_page:"https://httpbin.org/*",headers:headers}; // save configuration localStorage.setItem("config",JSON.stringify(config)); diff --git a/manifest.json b/manifest.json index 000b24f..535c03c 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "description": "Simple Modify headers ", "manifest_version": 2, "name": "simple-modify-headers", - "version": "1.3", + "version": "1.4", "homepage_url": "https://github.com/didierfred/SimpleModifyHeaders", "icons": { "48": "icons/modify-48.png" diff --git a/popup/config.js b/popup/config.js index 35edc4c..2bf490f 100644 --- a/popup/config.js +++ b/popup/config.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * @author didierfred@gmail.com - * @version 0.2 + * @version 0.3 */ @@ -44,8 +44,6 @@ html = html + "<td> <a href=\"#\" id=\"up_button" + line_number + "\" class=\"b html = html + "<td> <a href=\"#\" id=\"down_button" + line_number + "\" class=\"btn btn-default btn-sm\"> <span class=\"glyphicon glyphicon-arrow-down\"></span></a></td>"; html = html + "<td> <a href=\"#\" id=\"delete_button" + line_number + "\" class=\"btn btn-primary btn-sm\"> <span class=\"glyphicon glyphicon-trash\"></span> Delete </a></td>"; -console.log("html="+ html); - var newTR = document.createElement("tr"); newTR.id="line" + line_number; newTR.innerHTML = html; @@ -265,24 +263,19 @@ function delete_line(line_number_to_delete) } } var Node_to_delete = document.getElementById("line"+(line_number-1)); - Node_to_delete.parentNode.removeChild(Node_to_delete); + Node_to_delete.parentNode.removeChild(Node_to_delete); line_number--; } /** -* Move up a configuration line on the UI +* Invert two configuration lines on the UI **/ -function move_line_up(line_number_to_move) - { - if (line_number_to_move != 1) invert_line(line_number_to_move-1,line_number) - - } function invert_line(line1, line2) { - // if line does not exist + // if a line does not exist , do nothing if ((line1==0)||(line2==0)||(line1>=line_number)||(line2>=line_number)) return; // Save data for line 1 @@ -300,6 +293,7 @@ function invert_line(line1, line2) document.getElementById("comment"+line1).value = document.getElementById("comment"+line2).value; document.getElementById("select_status"+line1).value = document.getElementById("select_status"+line2).value; document.getElementById("apply_on"+line1).value = document.getElementById("apply_on"+line2).value; + // Copy line 1 to line 2 document.getElementById("select_action"+line2).value = select_action1; document.getElementById("header_name"+line2).value = header_name1; diff --git a/popup/menu.js b/popup/menu.js index 8af4f76..91a5ce5 100644 --- a/popup/menu.js +++ b/popup/menu.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * @author didierfred@gmail.com - * @version 0.1 + * @version 0.2 */ -- GitLab