diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-03-25 11:19:53 +0100 |
---|---|---|
committer | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-03-25 12:08:39 +0100 |
commit | d4e7a9f05bc45def5e5738ffd8d2391795311fd0 (patch) | |
tree | 15cdc6184ded6fba108c00de1f54d0e9f955e6ce /ogcp/static/js/ogcp.js | |
parent | 4f33ab1128886875346f316d3aeffb999d947281 (diff) |
Replace " " with "_" in HTML scopes IDs
Otherwise, scopes with whitespaces in their names breaks the javascript
code.
From
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id:
---
Note: Technically, in HTML5, the value for an id attribute may contain
any character, except whitespace characters. However, to avoid
inadvertent errors, only ASCII letters, digits, '_', and '-' should be
used and the value for an id attribute should start with a letter. For
example, . has a special meaning in CSS (it acts as a class selector).
Unless you are careful to escape it in the CSS, it won't be recognized
as part of the value of an id attribute. It is easy to forget to do
this, resulting in bugs in your code that could be hard to detect.
---
Diffstat (limited to 'ogcp/static/js/ogcp.js')
-rw-r--r-- | ogcp/static/js/ogcp.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js index 0f3a648..ac31c65 100644 --- a/ogcp/static/js/ogcp.js +++ b/ogcp/static/js/ogcp.js @@ -4,7 +4,7 @@ let updateTimeoutId = null; function showSelectedClient(client_checkbox) { const container = $('#selected-clients'); - const pill_id = 'pill-' + client_checkbox.name.replaceAll('.', '_'); + const pill_id = 'pill-' + client_checkbox.name.replaceAll(/[.]|[ ]/g, '_'); if (client_checkbox.checked) { if (!($('#' + pill_id).length)) @@ -124,7 +124,7 @@ function updatePillStatus(state, pill) { function updateScopes(scopes) { scopes.forEach((scope) => { if (scope.state) { - const scopeId = `${scope.name}_${scope.id}`.replaceAll('.', '_'); + const scopeId = `${scope.name}_${scope.id}`.replaceAll(/[.]|[ ]/g, '_'); const iconEl = document.querySelector(`#${scopeId} .nav-icon`); const iconCls = ['fas', 'far', 'text-danger', 'text-success', 'text-warning', 'text-wol']; |