Revision 72cbfa74
Added by koszko almost 2 years ago
html/display-panel.js | ||
---|---|---|
21 | 21 |
* IMPORT TYPE_PREFIX |
22 | 22 |
* IMPORT nice_name |
23 | 23 |
* IMPORT open_in_settings |
24 |
* IMPORT url_matches |
|
25 | 24 |
* IMPORT each_url_pattern |
26 | 25 |
* IMPORT by_id |
27 | 26 |
* IMPORT clone_template |
... | ... | |
114 | 113 |
return template; |
115 | 114 |
} |
116 | 115 |
|
117 |
function ensure_pattern_exists(pattern) |
|
118 |
{ |
|
119 |
let entry_object = known_patterns.get(pattern); |
|
120 |
/* |
|
121 |
* As long as pattern computation works well, we should never get into this |
|
122 |
* conditional block. This is just a safety measure. To be removed as part |
|
123 |
* of a bigger rework when we start taking iframes into account. |
|
124 |
*/ |
|
125 |
if (entry_object === undefined) { |
|
126 |
console.log(`unknown pattern: ${pattern}`); |
|
127 |
entry_object = add_pattern_to_list(pattern); |
|
128 |
} |
|
129 |
|
|
130 |
return entry_object; |
|
131 |
} |
|
132 |
|
|
133 | 116 |
function style_possible_pattern_entry(pattern, exists_in_settings) |
134 | 117 |
{ |
135 | 118 |
const [text, class_action] = exists_in_settings ? |
136 | 119 |
["Edit", "add"] : ["Add", "remove"]; |
137 |
const entry_object = ensure_pattern_exists(pattern);
|
|
120 |
const entry_object = known_patterns.get(pattern);
|
|
138 | 121 |
|
139 |
entry_object.button.textContent = `${text} setting`; |
|
140 |
entry_object.entry.classList[class_action]("matched_pattern"); |
|
122 |
if (entry_object) { |
|
123 |
entry_object.button.textContent = `${text} setting`; |
|
124 |
entry_object.entry.classList[class_action]("matched_pattern"); |
|
125 |
} |
|
141 | 126 |
} |
142 | 127 |
|
143 | 128 |
function handle_page_change(change) |
144 | 129 |
{ |
145 |
if (url_matches(tab_url, change.item)) |
|
146 |
style_possible_pattern_entry(change.item, change.new_val !== undefined); |
|
130 |
style_possible_pattern_entry(change.item, change.new_val !== undefined); |
|
147 | 131 |
} |
148 | 132 |
|
149 | 133 |
function populate_possible_patterns_list(url) |
Also available in: Unified diff
limit allowed pattern lengths