From 048327acb36cd2a10156228a7ebb313bcb8ff12d Mon Sep 17 00:00:00 2001 From: gablaxy Date: Mon, 23 Feb 2026 19:52:44 +0100 Subject: [PATCH] Actualiser webring.js --- webring.js | 204 ++++++++++++++++++++++++++--------------------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/webring.js b/webring.js index 2e32da5..7646298 100644 --- a/webring.js +++ b/webring.js @@ -1,102 +1,102 @@ -const JSON_WEBRING = "https://raw.githubusercontent.com/gablaxy/webring/main/webring.json"; - -const template = document.createElement("template"); -template.innerHTML = ` - - -
- - - -
-`; - -class Webring extends HTMLElement { - connectedCallback() { - - this.attachShadow({ mode: "open" }); - - this.shadowRoot.appendChild(template.content.cloneNode(true)); - - const currentSite = this.getAttribute("site"); - // ou sinon on peut aller chercher le paramètre site dans la déclaration du widget - - fetch(JSON_WEBRING) - .then((response) => response.json()) - .then((sites) => { - // Va chercher les infos du site actuel dans le json - const matchedSiteIndex = sites.findIndex( - (site) => site.url === currentSite - ) - - // stocke les index des sites avant et après dans le json - let previousSiteIndex = matchedSiteIndex - 1; - if(previousSiteIndex < 0)previousSiteIndex = sites.length - 1; - - let nextSiteIndex = matchedSiteIndex + 1; - if(nextSiteIndex >= sites.length)nextSiteIndex = 0; - - - const content = ` -

grossomodo

- < avant - / - ${sites[matchedSiteIndex].name} - / - après > - `; - - this.shadowRoot - .querySelector("#webring-inner") - .insertAdjacentHTML("afterbegin", content); - }) - .catch((error) => { - console.error(error); - const content = ` -

grossomodo

-

T'es pas dans le gang bozo

- `; - - this.shadowRoot - .querySelector("#webring-inner") - .insertAdjacentHTML("afterbegin", content); - }); - } -} - -window.customElements.define("webring-iutechno", Webring); +const JSON_WEBRING = "https://codeberg.org/gablaxy/webring/raw/commit/1ae8563fe015e88464bc89b49154b072d805c9e9/webring.json"; + +const template = document.createElement("template"); +template.innerHTML = ` + + +
+ + + +
+`; + +class Webring extends HTMLElement { + connectedCallback() { + + this.attachShadow({ mode: "open" }); + + this.shadowRoot.appendChild(template.content.cloneNode(true)); + + const currentSite = this.getAttribute("site"); + // ou sinon on peut aller chercher le paramètre site dans la déclaration du widget + + fetch(JSON_WEBRING) + .then((response) => response.json()) + .then((sites) => { + // Va chercher les infos du site actuel dans le json + const matchedSiteIndex = sites.findIndex( + (site) => site.url === currentSite + ) + + // stocke les index des sites avant et après dans le json + let previousSiteIndex = matchedSiteIndex - 1; + if(previousSiteIndex < 0)previousSiteIndex = sites.length - 1; + + let nextSiteIndex = matchedSiteIndex + 1; + if(nextSiteIndex >= sites.length)nextSiteIndex = 0; + + + const content = ` +

grossomodo

+ < avant + / + ${sites[matchedSiteIndex].name} + / + après > + `; + + this.shadowRoot + .querySelector("#webring-inner") + .insertAdjacentHTML("afterbegin", content); + }) + .catch((error) => { + console.error(error); + const content = ` +

grossomodo

+

T'es pas dans le gang bozo

+ `; + + this.shadowRoot + .querySelector("#webring-inner") + .insertAdjacentHTML("afterbegin", content); + }); + } +} + +window.customElements.define("webring-iutechno", Webring);