| Index: new-options.js |
| =================================================================== |
| --- a/new-options.js |
| +++ b/new-options.js |
| @@ -44,18 +44,25 @@ |
| this.items = []; |
| } |
| - Collection.prototype._setEmpty = function(table, text) |
| + Collection.prototype._setEmpty = function(table, texts) |
| { |
| - let placeholder = table.querySelector(".empty-placeholder"); |
| - if (text && !placeholder) |
| + let placeholders = table.querySelectorAll(".empty-placeholder"); |
| + |
| + if (texts && placeholders.length == 0) |
| { |
| - placeholder = document.createElement("li"); |
| - placeholder.className = "empty-placeholder"; |
| - placeholder.textContent = getMessage(text); |
| - table.appendChild(placeholder); |
| + for (let text of texts) |
| + { |
| + let placeholder = document.createElement("li"); |
| + placeholder.className = "empty-placeholder"; |
| + placeholder.textContent = getMessage(text); |
| + table.appendChild(placeholder); |
| + } |
| } |
| - else if (placeholder) |
| - table.removeChild(placeholder); |
| + else if (placeholders.length > 0) |
| + { |
| + for (let placeholder of placeholders) |
| + table.removeChild(placeholder); |
| + } |
| }; |
| Collection.prototype._createElementQuery = function(item) |
| @@ -285,17 +292,17 @@ |
| collections.langs = new Collection([ |
| { |
| id: "blocking-languages-table", |
| - emptyText: "options_dialog_language_added_empty" |
| + emptyText: ["options_dialog_language_added_empty"] |
| }, |
| { |
| id: "blocking-languages-dialog-table", |
| - emptyText: "options_dialog_language_added_empty" |
| + emptyText: ["options_dialog_language_added_empty"] |
| } |
| ]); |
| collections.allLangs = new Collection([ |
| { |
| id: "all-lang-table", |
| - emptyText: "options_dialog_language_other_empty", |
| + emptyText: ["options_dialog_language_other_empty"], |
| searchable: true |
| } |
| ]); |
| @@ -312,13 +319,13 @@ |
| collections.whitelist = new Collection([ |
| { |
| id: "whitelisting-table", |
| - emptyText: "options_whitelisted_empty" |
| + emptyText: ["options_whitelist_empty_1", "options_whitelist_empty_2"] |
| } |
| ]); |
| collections.customFilters = new Collection([ |
| { |
| id: "custom-filters-table", |
| - emptyText: "options_customFilters_empty" |
| + emptyText: ["options_customFilters_empty"] |
| } |
| ]); |
| collections.filterLists = new Collection([ |
| @@ -495,22 +502,12 @@ |
| case "cancel-custom-filters": |
| E("custom-filters").classList.remove("mode-edit"); |
| break; |
| - case "cancel-domain-exception": |
| - E("whitelisting-textbox").value = ""; |
| - document.querySelector("#whitelisting .controls").classList |
| - .remove("mode-edit"); |
| - break; |
| case "close-dialog": |
| closeDialog(); |
| break; |
| case "edit-custom-filters": |
| editCustomFilters(); |
| break; |
| - case "edit-domain-exception": |
| - document.querySelector("#whitelisting .controls").classList |
| - .add("mode-edit"); |
| - E("whitelisting-textbox").focus(); |
| - break; |
| case "import-subscription": { |
| let url = E("blockingList-textbox").value; |
| addEnableSubscription(url); |
| @@ -750,10 +747,33 @@ |
| let placeholderValue = getMessage("options_dialog_language_find"); |
| E("find-language").setAttribute("placeholder", placeholderValue); |
| E("find-language").addEventListener("keyup", onFindLanguageKeyUp, false); |
| - E("whitelisting-textbox").addEventListener("keypress", (e) => |
| + let exampleValue = getMessage("options_whitelist_placeholder_example"); |
| + E("whitelisting-textbox").setAttribute("placeholder", exampleValue); |
| + E("whitelisting-textbox").addEventListener("keyup", (e) => |
| { |
| + let addWhitelistButton = E("whitelisting-add-button"); |
| + addWhitelistButton.disabled = false; |
| if (getKey(e) == "Enter") |
| - addWhitelistedDomain(); |
| + { |
| + if (!addWhitelistButton.disabled) |
| + addWhitelistedDomain(); |
| + } |
| + else |
| + { |
| + for (let whitelistItem of collections.whitelist.items) |
| + { |
| + if (!e.target.value) |
| + { |
| + addWhitelistButton.disabled = true; |
| + } |
| + if (whitelistItem.title == e.target.value) |
| + { |
| + addWhitelistButton.disabled = true; |
| + E("whitelisting-validation").textContent = |
| + getMessage("options_whitelist_duplicate"); |
|
Thomas Greiner
2017/05/26 11:10:38
Detail: This text doesn't appear to be used anymor
|
| + } |
| + } |
| + } |
| }, false); |
| // Advanced tab |
| @@ -971,8 +991,7 @@ |
| } |
| domain.value = ""; |
| - document.querySelector("#whitelisting .controls") |
| - .classList.remove("mode-edit"); |
| + E("whitelisting-add-button").disabled = true; |
| } |
| function editCustomFilters() |