From 3953fe066418f8371fe5689f71767019df435da1 Mon Sep 17 00:00:00 2001 From: Jeremy Thomas Date: Thu, 11 Jan 2024 21:14:22 +0000 Subject: [PATCH] Fix JS --- docs/_javascript/index.js | 18 +++++++----------- docs/lib/index.js | 25 +++++++------------------ 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/docs/_javascript/index.js b/docs/_javascript/index.js index 98619442..7e11dbc2 100644 --- a/docs/_javascript/index.js +++ b/docs/_javascript/index.js @@ -97,7 +97,7 @@ document.addEventListener("DOMContentLoaded", () => { const $amis = document.getElementById("amis"); - fetch("https://jgthms.com/amis.json") + fetch("https://jgthms.com/amis/new.json") .then((response) => { if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); @@ -106,21 +106,17 @@ document.addEventListener("DOMContentLoaded", () => { return response.json(); }) .then((response) => { - const { by_id, home } = response; - - home.forEach((id) => { - const ami = by_id[id]; - const { url, alt = "", width, height } = ami; + response.forEach((item) => { const el = document.createElement("a"); el.className = "bd-sponsor-item bd-partner-sponsor"; el.href = "url"; el.target = "_blank"; - el.title = alt; - const extension = ami.svg ? ".svg" : ".png"; + el.title = item.title || item.id; + + const extension = item.svg ? ".svg" : ".png"; const img = document.createElement("img"); - img.src = `/images/amis/${id}${extension}`; - img.height = height; - img.width = width; + img.src = `https://jgthms.com/amis/images/${item.id}${extension}`; + el.appendChild(img); $amis.appendChild(el); }); diff --git a/docs/lib/index.js b/docs/lib/index.js index 2e267c2b..00fdaf5b 100644 --- a/docs/lib/index.js +++ b/docs/lib/index.js @@ -86,35 +86,24 @@ document.addEventListener("DOMContentLoaded", function () { var $amis = document.getElementById("amis"); - fetch("https://jgthms.com/amis.json").then(function (response) { + fetch("https://jgthms.com/amis/new.json").then(function (response) { if (!response.ok) { throw new Error("HTTP error! Status: " + response.status); } return response.json(); }).then(function (response) { - var by_id = response.by_id, - home = response.home; - - - home.forEach(function (id) { - var ami = by_id[id]; - var url = ami.url, - _ami$alt = ami.alt, - alt = _ami$alt === undefined ? "" : _ami$alt, - width = ami.width, - height = ami.height; - + response.forEach(function (item) { var el = document.createElement("a"); el.className = "bd-sponsor-item bd-partner-sponsor"; el.href = "url"; el.target = "_blank"; - el.title = alt; - var extension = ami.svg ? ".svg" : ".png"; + el.title = item.title || item.id; + + var extension = item.svg ? ".svg" : ".png"; var img = document.createElement("img"); - img.src = "/images/amis/" + id + extension; - img.height = height; - img.width = width; + img.src = "https://jgthms.com/amis/images/" + item.id + extension; + el.appendChild(img); $amis.appendChild(el); });