From 84c2a3ac3ce998648854e66d694a07315de02b12 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 15 Jul 2023 12:59:38 +0530 Subject: [PATCH] make mobile code usable for embedding --- static/mobile/js/main.js | 9 +++++---- static/mobile/js/render.js | 15 ++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/static/mobile/js/main.js b/static/mobile/js/main.js index c69a9f79..a9b368bd 100644 --- a/static/mobile/js/main.js +++ b/static/mobile/js/main.js @@ -1,10 +1,11 @@ function parseURL() { - var fragment = document.location.hash.slice(1) - if (!fragment && document.location.pathname.startsWith('/m/')) { - var prefix = document.location.protocol + '//' + document.location.hostname + '/m/' - fragment = document.location.href.slice(prefix.length) + var url = pandora.url ? pandora.url : document.location, + fragment = url.hash.slice(1) + if (!fragment && url.pathname.startsWith('/m/')) { + var prefix = url.protocol + '//' + url.hostname + '/m/' + fragment = url.href.slice(prefix.length) } var args = fragment.split('?') var id = args.shift() diff --git a/static/mobile/js/render.js b/static/mobile/js/render.js index a7519342..d9724da7 100644 --- a/static/mobile/js/render.js +++ b/static/mobile/js/render.js @@ -31,17 +31,18 @@ function renderItem(data) {
${data.value}
+
Open on ${data.site}
` - var comments = ` -
- - -
-
- ` + + var comments = div.querySelector('.comments') + if (window.renderComments) { + renderComments(comments, data) + } else { + comments.remove() + } div.querySelectorAll('.layer a').forEach(a => { a.addEventListener("click", clickLink)