From 600fbca86951c28b4cf96a93b1a5fe5ba6149161 Mon Sep 17 00:00:00 2001 From: polo Date: Thu, 15 Jan 2026 23:14:05 +0100 Subject: =?UTF-8?q?am=C3=A9lioration=20code=20calendar.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/main.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'public/js/main.js') 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){ setTimeout(function(){ toast.className = toast.className.replace('show', ''); }, 5000); } + +// réussite de getElementById +function getElementOrThrow(id) { + const elem = document.getElementById(id); + if (!elem) { + throw new Error("l'élément d'id: " + id + " non trouvé"); + } + return elem; +} +// l'erreur attribut "value" non trouvé devient l'élement attrapé n'a pas le bon type (c'est un peu plus clair) +function assertElementType(elem, ctor) { + if (!(elem instanceof ctor)) { + throw new Error(`l'élement attrapé n'a pas le bon type. type attendu: ${ctor.name}, type obtenu: ${elem.tagName}`); + } +} + + function controlURL(input){ const url = input.value.trim(); if(!url){ -- cgit v1.2.3