aboutsummaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
authorGravatar maTh <math-home@web.de> 2022-03-14 23:05:47 +0100
committerGravatar GitHub <noreply@github.com> 2022-03-14 23:05:47 +0100
commitbdf7e4d29d954c3d2c137948577b6872c3de4656 (patch)
treeaabf27a2321de6ca547ac3893b15946203e21662 /p/scripts
parent6650d1d29ea5e6f895124afce9ed4a6e920a1ed8 (diff)
Improved: Show URL button (#4238)
* done * fix extra.js * click event * URL input does not extend anymore * fix * improved the i18n key * Update app/i18n/fr/gen.php Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/extra.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/p/scripts/extra.js b/p/scripts/extra.js
index 505b05110..d89342720 100644
--- a/p/scripts/extra.js
+++ b/p/scripts/extra.js
@@ -123,6 +123,29 @@ function init_password_observers() {
});
}
+// overwrites the href attribute from the url input
+function updateHref(ev) {
+ const urlField = document.getElementById(this.getAttribute('data-input'));
+ const url = urlField.value;
+ if (url.length > 0) {
+ this.href = url;
+ return true;
+ } else {
+ urlField.focus();
+ this.removeAttribute('href');
+ ev.preventDefault();
+ return false;
+ }
+}
+
+// set event listener on "show url" buttons
+function init_url_observers() {
+ document.querySelectorAll('.open-url').forEach(function (btn) {
+ btn.addEventListener('mouseover', updateHref);
+ btn.addEventListener('click', updateHref);
+ });
+}
+
function init_select_observers() {
document.querySelectorAll('.select-change').forEach(function (s) {
s.onchange = function (ev) {
@@ -266,6 +289,7 @@ function init_extra() {
}
init_crypto_form();
init_password_observers();
+ init_url_observers();
init_select_observers();
init_slider_observers();
init_configuration_alert();