| Index: options.js |
| diff --git a/options.js b/options.js |
| index 94357cbc88c8ed9ce4572b368a8aa6ad43a3d32e..a2cd337fb93217b10ed24620eb945eaa926e17b1 100644 |
| --- a/options.js |
| +++ b/options.js |
| @@ -520,9 +520,7 @@ function onFilterMessage(action, filter) |
| function clearListBox(id) |
| { |
| - var list = document.getElementById(id); |
| - while (list.lastChild) |
| - list.removeChild(list.lastChild); |
| + document.getElementById(id).innerHTML = ""; |
|
Sebastian Noack
2016/12/20 21:38:18
IMO, this isn't worth a function anymore, and shou
kzar
2016/12/21 10:44:01
Done.
|
| } |
| // Add a filter string to the list box. |
| @@ -538,10 +536,10 @@ function appendToListBox(boxId, text) |
| // Remove a filter string from a list box. |
| function removeFromListBox(boxId, text) |
| { |
| - var list = document.getElementById(boxId); |
| - for (var i = 0; i < list.length; i++) |
| - if (list.options[i].value == text) |
| - list.remove(i--); |
| + let list = document.getElementById(boxId); |
|
Sebastian Noack
2016/12/20 21:38:18
That is unrelated, but I suppose we should go and
kzar
2016/12/21 10:44:01
Yea I considered that too. It's not as trivial as
Sebastian Noack
2016/12/21 16:13:38
Well, so far we used arrow functions only in code
|
| + let selector = "option[value=" + CSS.escape(text) + "]"; |
| + for (let option of list.querySelectorAll(selector)) |
| + list.removeChild(option); |
| } |
| function addWhitelistDomain(event) |
| @@ -592,16 +590,8 @@ function removeSelectedExcludedDomain(event) |
| function removeSelectedFilters(event) |
| { |
| event.preventDefault(); |
| - var userFiltersBox = document.getElementById("userFiltersBox"); |
| - var remove = []; |
| - for (var i = 0; i < userFiltersBox.length; i++) |
| - if (userFiltersBox.options[i].selected) |
| - remove.push(userFiltersBox.options[i].value); |
| - if (!remove.length) |
| - return; |
| - |
| - for (var i = 0; i < remove.length; i++) |
| - removeFilter(remove[i]); |
| + for (let option of document.querySelectorAll("#userFiltersBox > option:checked")) |
| + removeFilter(option.value); |
| } |
| // Shows raw filters box and fills it with the current user filters |
| @@ -609,15 +599,16 @@ function toggleFiltersInRawFormat(event) |
| { |
| event.preventDefault(); |
| + let text = ""; |
| + |
| $("#rawFilters").toggle(); |
| if ($("#rawFilters").is(":visible")) |
| { |
| - var userFiltersBox = document.getElementById("userFiltersBox"); |
| - var text = ""; |
| - for (var i = 0; i < userFiltersBox.length; i++) |
| - text += userFiltersBox.options[i].value + "\n"; |
| - document.getElementById("rawFiltersText").value = text; |
| + for (let option of document.getElementById("userFiltersBox").options) |
| + text += option.value + "\n"; |
|
Sebastian Noack
2016/12/20 21:38:18
String concatenation using a loop is potentially s
kzar
2016/12/21 10:44:01
Done, it does perform a little better. Interesting
|
| } |
| + |
| + document.getElementById("rawFiltersText").value = text; |
| } |
| // Imports filters in the raw text box |