From 2ecd522e7f6446de50d0d36de95de281206d46cb Mon Sep 17 00:00:00 2001 From: Libor Polčák Date: Oct 14 2021 08:53:12 +0000 Subject: levels.js: Make redefining level names easier See pagure #10 for more details. --- diff --git a/common/levels.js b/common/levels.js index 6526a48..1a686bc 100644 --- a/common/levels.js +++ b/common/levels.js @@ -614,16 +614,24 @@ wrapping_groups.groups.forEach(function (group) { }).bind(null, group.id)); }); +// ***************************************************************************** // levels of protection +// Level aliases +const L0 = "0"; +const L1 = "1"; +const L2 = "2"; +const L3 = "3"; + +/// Built-in levels var level_0 = { - "level_id": "0", + "level_id": L0, "level_text": "Turn wrappers off", "level_description": "No protection at all", }; var level_1 = { - "level_id": "1", + "level_id": L1, "level_text": "Minimal", "level_description": "Minimal level of protection", "time_precision": true, @@ -639,7 +647,7 @@ var level_1 = { }; var level_2 = { - "level_id": "2", + "level_id": L2, "level_text": "Recommended", "level_description": "Recommended level of protection for most sites", "time_precision": true, @@ -667,7 +675,7 @@ var level_2 = { }; var level_3 = { - "level_id": "3", + "level_id": L3, "level_text": "High", "level_description": "High level of protection", "time_precision": true, @@ -705,11 +713,7 @@ var level_3 = { "windowname": true, }; -// Level aliases -const L0 = "0"; -const L1 = "1"; -const L2 = "2"; -const L3 = "3"; +const BUILTIN_LEVEL_NAMES = [L0, L1, L2, L3]; var levels = {}; var default_level = {}; diff --git a/common/options.js b/common/options.js index 60c0d87..925cc3b 100644 --- a/common/options.js +++ b/common/options.js @@ -227,7 +227,7 @@ function show_existing_level(levelsEl, level) { ${escape(levels[level].level_description)} `); levelsEl.appendChild(fragment); - if (!([L0, L1, L2, L3].includes(level))) { + if (!(BUILTIN_LEVEL_NAMES.includes(level))) { var lielem = document.getElementById(`li-${level}`); // Note that FF here requires unescaped ID var existPref = document.createElement("span"); existPref.setAttribute("id", `li-exist-group-${escape(level)}`);