diff options
author | NateN1222 <nathannichols454@gmail.com> | 2017-07-28 12:16:55 -0500 |
---|---|---|
committer | NateN1222 <nathannichols454@gmail.com> | 2017-07-28 12:16:55 -0500 |
commit | 08e2c650cacb372b913e60c91874af9fcbb786a0 (patch) | |
tree | 387ac2383fa7582d6e361b0408918e2e85d7058b /html/preferences_panel |
Initial commit
Diffstat (limited to 'html/preferences_panel')
-rw-r--r-- | html/preferences_panel/pref.js | 56 | ||||
-rw-r--r-- | html/preferences_panel/preferences_panel.html | 63 |
2 files changed, 119 insertions, 0 deletions
diff --git a/html/preferences_panel/pref.js b/html/preferences_panel/pref.js new file mode 100644 index 0000000..aa88f5d --- /dev/null +++ b/html/preferences_panel/pref.js @@ -0,0 +1,56 @@ +/** +* +* Sets global variable "webex" to either "chrome" or "browser" for +* use on Chrome or a Firefox variant. +* +* Change this to support a new browser that isn't Chrome or Firefox, +* given that it supports webExtensions. +* +* (Use the variable "webex" for all API calls after calling this) +*/ +var store; +function set_webex(){ + if(typeof(browser) == "undefined"){ + webex = chrome; + } else{ + webex = browser; + } +} +set_webex(); + +function storage_got(items){ + var inputs = document.getElementsByTagName("input"); + for(var i = 0; i < inputs.length; i++){ + if(inputs[i].id.indexOf("pref_") != -1){ + if(inputs[i].type == "checkbox" && items[inputs[i].id]){ + inputs[i].checked = true; + } + if(inputs[i].type == "text"){ + inputs[i].value = items[inputs[i].id]; + } + } + } +} +webex.storage.local.get(storage_got); + +document.getElementById("save_changes").addEventListener("click", function(){ + var inputs = document.getElementsByTagName("input"); + // TODO: validate/sanitize the user inputs + var data = {}; + for(var i = 0; i < inputs.length; i++){ + if(inputs[i].id.indexOf("pref_") != -1){ + var input_val = ""; + if(inputs[i].type == "checkbox"){ + input_val = inputs[i].checked; + } else{ + input_val = inputs[i].value; + } + var input_id = inputs[i].id; + data[input_id] = input_val; + } + } + console.log(data); + webex.storage.local.set(data); +}); + + diff --git a/html/preferences_panel/preferences_panel.html b/html/preferences_panel/preferences_panel.html new file mode 100644 index 0000000..5c5a217 --- /dev/null +++ b/html/preferences_panel/preferences_panel.html @@ -0,0 +1,63 @@ +<html> + <head> +<!-- /** + * GNU LibreJS - A browser add-on to block nonfree nontrivial JavaScript. + * * + * Copyright (C) 2011, 2012, 2014 Loic J. Duros + * Copyright (C) 2014, 2015 Nik Nyby + * + * This file is part of GNU LibreJS. + * + * GNU LibreJS is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNU LibreJS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU LibreJS. If not, see <http://www.gnu.org/licenses/>. + */ +--> + <title> + LibreJS preferences + </title> + </head> + + <body> + <h3> + LibreJS Preferences + </h3> + + <table> + <tr> + <td><p>Whitelist domains, seperated by comma (wildcard is *)</p></td> + <td><input id="pref_whitelist" type="text"></input></td> + </tr> + <tr> + <td><p>Display complaint tab on sites where nonfree nontrivial Javascript detected</p></td> + <td><input id="pref_complaint_tab" type="checkbox"></input></td> + </tr> + <tr> + <td><p>Display notifications of the JavaScript code being analyzed by LibreJS</p></td> + <td><input id="pref_notify_analyze" type="checkbox"></input></td> + </tr> + <tr> + <td><p>Default complaint email subject</p></td> + <td><input id="pref_subject" type="text"></input></td> + </tr> + <tr> + <td><p>Default complaint email body</p></td> + <td><input id="pref_body" type="text"></input></td> + </tr> + <tr> + <td><input type="button" value="Save changes" id="save_changes"></input></td> + <td></td> + </tr> + </table> + <script type="text/javascript" src="pref.js"></script> + </body> +</html> |