aboutsummaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2025-11-01 19:20:15 +0100
committerpolo <ordipolo@gmx.fr>2025-11-01 19:20:15 +0100
commit067ec55f13bd472c8d584d8e26d70a34cc9705f3 (patch)
treeb2861a285eb98876512943385efddd90628ea3cf /public
parent46d3c239a7ad2b00e86373f2fd0e829fdcba57f7 (diff)
downloadcms-067ec55f13bd472c8d584d8e26d70a34cc9705f3.tar.gz
cms-067ec55f13bd472c8d584d8e26d70a34cc9705f3.tar.bz2
cms-067ec55f13bd472c8d584d8e26d70a34cc9705f3.zip
contrôle sur les input type url
Diffstat (limited to 'public')
-rw-r--r--public/js/Input.js4
-rw-r--r--public/js/main.js12
2 files changed, 14 insertions, 2 deletions
diff --git a/public/js/Input.js b/public/js/Input.js
index 0ebbbbb..854e5d1 100644
--- a/public/js/Input.js
+++ b/public/js/Input.js
@@ -11,7 +11,7 @@ class InputToggler{
11 this.submit_elem = this.parent.querySelector(options.submit_selector || `#${name}_submit`); 11 this.submit_elem = this.parent.querySelector(options.submit_selector || `#${name}_submit`);
12 this.cancel_elem = this.parent.querySelector(options.cancel_selector || `#${name}_cancel`); 12 this.cancel_elem = this.parent.querySelector(options.cancel_selector || `#${name}_cancel`);
13 13
14 // balises à ne pas gérer (fonctionne mais inutilisé pour l'instant) 14 // balises à ne pas gérer
15 this.ignored_tags = { 15 this.ignored_tags = {
16 has_content: options.has_content !== false, // => true sauf si le paramètre vaut false 16 has_content: options.has_content !== false, // => true sauf si le paramètre vaut false
17 has_input: options.has_input !== false, 17 has_input: options.has_input !== false,
@@ -42,7 +42,7 @@ class InputToggler{
42 42
43 43
44// enfants 44// enfants
45class InputText extends InputToggler{ 45class InputText extends InputToggler{ // pour input type text ou url
46 constructor(name, options = {}){ 46 constructor(name, options = {}){
47 super(name, options); 47 super(name, options);
48 this.fetcher = new Fetcher({ 48 this.fetcher = new Fetcher({
diff --git a/public/js/main.js b/public/js/main.js
index 42bae70..1e47ebe 100644
--- a/public/js/main.js
+++ b/public/js/main.js
@@ -36,6 +36,18 @@ function toastNotify(message){
36 setTimeout(function(){ toast.className = toast.className.replace('show', ''); }, 5000); 36 setTimeout(function(){ toast.className = toast.className.replace('show', ''); }, 5000);
37} 37}
38 38
39function controlURL(input){
40 const url = input.value.trim();
41 if(!url){
42 return;
43 }
44 if(/^[a-z][a-z0-9+.-]*:/i.test(url) // un "protocole" (https://, ftp://, mailto:, etc)
45 || url.startsWith('/') || url.startsWith('./') || url.startsWith('../')){ // Lien local (commence par /, ./ ou ../)
46 return;
47 }
48 input.value = 'https://' + url; // Cas par défaut
49}
50
39// exécuté à la fin du chargement de la page 51// exécuté à la fin du chargement de la page
40document.addEventListener('DOMContentLoaded', () => { 52document.addEventListener('DOMContentLoaded', () => {
41 53