From df5f6048e6a177b5ce3920d10a1249129c669a1f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 19 Jun 2024 19:50:55 -0300 Subject: client: client modules --- src/content/dependencies/generatePageLayout.js | 2 +- src/static/js/client-util.js | 122 + src/static/js/client.js | 4956 -------------------- src/static/js/client/additional-names-box.js | 83 + src/static/js/client/album-commentary-sidebar.js | 212 + .../js/client/artist-external-link-tooltip.js | 196 + .../js/client/css-compatibility-assistant.js | 22 + src/static/js/client/datetimestamp-tooltip.js | 36 + src/static/js/client/hash-link.js | 146 + src/static/js/client/hoverable-tooltip.js | 1083 +++++ src/static/js/client/index.js | 226 + src/static/js/client/live-mouse-position.js | 21 + src/static/js/client/quick-description.js | 62 + src/static/js/client/scripted-link.js | 275 ++ src/static/js/client/sidebar-search.js | 903 ++++ src/static/js/client/sticky-heading.js | 257 + src/static/js/client/summary-nested-link.js | 48 + src/static/js/client/text-with-tooltip.js | 34 + src/static/js/client/wiki-search.js | 239 + src/static/js/group-contributions-table.js | 35 + src/static/js/image-overlay.js | 256 + src/static/js/info-card.js | 181 + src/static/js/localization-nonsense.js | 30 + src/static/js/rectangles.js | 513 ++ 24 files changed, 4981 insertions(+), 4957 deletions(-) create mode 100644 src/static/js/client-util.js delete mode 100644 src/static/js/client.js create mode 100644 src/static/js/client/additional-names-box.js create mode 100644 src/static/js/client/album-commentary-sidebar.js create mode 100644 src/static/js/client/artist-external-link-tooltip.js create mode 100644 src/static/js/client/css-compatibility-assistant.js create mode 100644 src/static/js/client/datetimestamp-tooltip.js create mode 100644 src/static/js/client/hash-link.js create mode 100644 src/static/js/client/hoverable-tooltip.js create mode 100644 src/static/js/client/index.js create mode 100644 src/static/js/client/live-mouse-position.js create mode 100644 src/static/js/client/quick-description.js create mode 100644 src/static/js/client/scripted-link.js create mode 100644 src/static/js/client/sidebar-search.js create mode 100644 src/static/js/client/sticky-heading.js create mode 100644 src/static/js/client/summary-nested-link.js create mode 100644 src/static/js/client/text-with-tooltip.js create mode 100644 src/static/js/client/wiki-search.js create mode 100644 src/static/js/group-contributions-table.js create mode 100644 src/static/js/image-overlay.js create mode 100644 src/static/js/info-card.js create mode 100644 src/static/js/localization-nonsense.js create mode 100644 src/static/js/rectangles.js diff --git a/src/content/dependencies/generatePageLayout.js b/src/content/dependencies/generatePageLayout.js index 7e9e49a0..fd2ebdc7 100644 --- a/src/content/dependencies/generatePageLayout.js +++ b/src/content/dependencies/generatePageLayout.js @@ -673,7 +673,7 @@ export default { html.tag('script', { blocking: 'render', type: 'module', - src: to('staticJS.path', 'client.js'), + src: to('staticJS.path', 'client/index.js'), }), ]), diff --git a/src/static/js/client-util.js b/src/static/js/client-util.js new file mode 100644 index 00000000..f06b707a --- /dev/null +++ b/src/static/js/client-util.js @@ -0,0 +1,122 @@ +/* eslint-env browser */ + +export function rebase(href, rebaseKey = 'rebaseLocalized') { + const relative = (document.documentElement.dataset[rebaseKey] || '.') + '/'; + if (relative) { + return relative + href; + } else { + return href; + } +} + +export function cssProp(el, ...args) { + if (typeof args[0] === 'string' && args.length === 1) { + return getComputedStyle(el).getPropertyValue(args[0]).trim(); + } + + if (typeof args[0] === 'string' && args.length === 2) { + if (args[1] === null) { + el.style.removeProperty(args[0]); + } else { + el.style.setProperty(args[0], args[1]); + } + return; + } + + if (typeof args[0] === 'object') { + for (const [property, value] of Object.entries(args[0])) { + cssProp(el, property, value); + } + } +} + +export function templateContent(el) { + if (el === null) { + return null; + } + + if (el?.nodeName !== 'TEMPLATE') { + throw new Error(`Expected a