From 4716cffa3e60483bb60d3c877f10d07b839001a0 Mon Sep 17 00:00:00 2001 From: Trumeet Date: Fri, 18 Nov 2022 19:16:53 -0800 Subject: Use string template for hitokoto Thanks to Pop: string template does not work for scripts in HTML but only standalone script due to HtmlWebpackPlugin --- neo/src/index.html | 14 -------------- neo/src/index.js | 12 ++++++++++++ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/neo/src/index.html b/neo/src/index.html index ec90934..a8e112f 100644 --- a/neo/src/index.html +++ b/neo/src/index.html @@ -6,20 +6,6 @@ Yuuta Liang - diff --git a/neo/src/index.js b/neo/src/index.js index e69de29..1b3c3ff 100644 --- a/neo/src/index.js +++ b/neo/src/index.js @@ -0,0 +1,12 @@ +document.addEventListener("DOMContentLoaded", () => { + fetch('https://yuuta.moe/quote/') + .then((response) => response.json()) + .then((data) => { + const q = document.querySelector('#quote'); + q.title = data.text_zh; + q.innerHTML = `「${data.text}」`; + const t = document.querySelector('#quote_title'); + t.title = data.title_zh; + t.innerHTML = `—— ${data.title}`; + }); +}); -- cgit v1.2.3