make mobile code usable for embedding

This commit is contained in:
j 2023-07-15 12:59:38 +05:30
parent cf6374e8a6
commit 84c2a3ac3c
2 changed files with 13 additions and 11 deletions

View File

@ -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()

View File

@ -31,17 +31,18 @@ function renderItem(data) {
<div class="video"></div>
</div>
<div class="value">${data.value}</div>
<div class="comments"></div>
<div class="more">
<a href="${data.link}">Open on ${data.site}</a>
</div>
`
var comments = `
<div class="comments" style="width: 100%;text-align: center;">
<textarea style="width:90%;height:45px" placeholder="Respond in style..."></textarea>
<button style="width:90%">Submit</button>
<br>
</div>
`
var comments = div.querySelector('.comments')
if (window.renderComments) {
renderComments(comments, data)
} else {
comments.remove()
}
div.querySelectorAll('.layer a').forEach(a => {
a.addEventListener("click", clickLink)