diff options
Diffstat (limited to 'public/js/main.js')
| -rw-r--r-- | public/js/main.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/public/js/main.js b/public/js/main.js index c8e10b0..825699f 100644 --- a/public/js/main.js +++ b/public/js/main.js | |||
| @@ -36,6 +36,23 @@ 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 | ||
| 39 | |||
| 40 | // réussite de getElementById | ||
| 41 | function getElementOrThrow(id) { | ||
| 42 | const elem = document.getElementById(id); | ||
| 43 | if (!elem) { | ||
| 44 | throw new Error("l'élément d'id: " + id + " non trouvé"); | ||
| 45 | } | ||
| 46 | return elem; | ||
| 47 | } | ||
| 48 | // l'erreur attribut "value" non trouvé devient l'élement attrapé n'a pas le bon type (c'est un peu plus clair) | ||
| 49 | function assertElementType(elem, ctor) { | ||
| 50 | if (!(elem instanceof ctor)) { | ||
| 51 | throw new Error(`l'élement attrapé n'a pas le bon type. type attendu: ${ctor.name}, type obtenu: ${elem.tagName}`); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | |||
| 39 | function controlURL(input){ | 56 | function controlURL(input){ |
| 40 | const url = input.value.trim(); | 57 | const url = input.value.trim(); |
| 41 | if(!url){ | 58 | if(!url){ |
