Update ECMAScript accordingly.
This commit is contained in:
parent
b5762e90ef
commit
b26958acae
1 changed files with 18 additions and 12 deletions
|
@ -9,6 +9,7 @@ window.onload = async function(){
|
||||||
//let feedUrl = location.href.replace(/^https?:/, 'feed:');
|
//let feedUrl = location.href.replace(/^https?:/, 'feed:');
|
||||||
let feedUrl = `feed://${location.host}/atom?pubsub=${pubsub}&node=${node}`;
|
let feedUrl = `feed://${location.host}/atom?pubsub=${pubsub}&node=${node}`;
|
||||||
follow.href = feedUrl;
|
follow.href = feedUrl;
|
||||||
|
follow.type = `application/atom+xml`;
|
||||||
follow.addEventListener ('click', function() {
|
follow.addEventListener ('click', function() {
|
||||||
window.open(feedUrl, "_self");
|
window.open(feedUrl, "_self");
|
||||||
});
|
});
|
||||||
|
@ -81,11 +82,9 @@ window.onload = async function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a journal list
|
// Build a journal list
|
||||||
if (locationHref.pathname.startsWith('/atom') && node) {
|
if (locationHref.pathname.startsWith('/atom') && pubsub && node && !node.includes('/')) {
|
||||||
itemsList = await openJson(node)
|
itemsList = await openJson(pubsub, node)
|
||||||
if (itemsList && locationHref.searchParams.get('item')) {
|
if (itemsList && locationHref.searchParams.get('item')) {
|
||||||
node = locationHref.searchParams.get('node')
|
|
||||||
pubsub = locationHref.searchParams.get('pubsub')
|
|
||||||
let elementDiv = document.createElement('div');
|
let elementDiv = document.createElement('div');
|
||||||
elementDiv.id = 'journal';
|
elementDiv.id = 'journal';
|
||||||
let elementH3 = document.createElement('h3');
|
let elementH3 = document.createElement('h3');
|
||||||
|
@ -96,13 +95,15 @@ window.onload = async function(){
|
||||||
elementDiv.appendChild(elementH4);
|
elementDiv.appendChild(elementH4);
|
||||||
let elementUl = document.createElement('ol');
|
let elementUl = document.createElement('ol');
|
||||||
elementDiv.appendChild(elementUl);
|
elementDiv.appendChild(elementUl);
|
||||||
for (let item of itemsList) {
|
for (let item of itemsList.reverse()) {
|
||||||
let elementLi = document.createElement('li');
|
let elementLi = document.createElement('li');
|
||||||
let elementA = document.createElement('a');
|
let elementA = document.createElement('a');
|
||||||
elementA.textContent = item.title;
|
elementA.textContent = item.title;
|
||||||
elementA.href = item.link;
|
elementA.href = item.link;
|
||||||
elementLi.appendChild(elementA);
|
elementLi.appendChild(elementA);
|
||||||
elementUl.appendChild(elementLi);
|
elementUl.appendChild(elementLi);
|
||||||
|
console.log(elementLi.length)
|
||||||
|
if (elementUl.children.length > 9) {break};
|
||||||
}
|
}
|
||||||
let elementB = document.createElement('b');
|
let elementB = document.createElement('b');
|
||||||
elementB.textContent = 'Actions';
|
elementB.textContent = 'Actions';
|
||||||
|
@ -111,19 +112,24 @@ window.onload = async function(){
|
||||||
elementDiv.appendChild(elementUl2);
|
elementDiv.appendChild(elementUl2);
|
||||||
links = [
|
links = [
|
||||||
{'text' : 'Subscribe from an XMPP client.',
|
{'text' : 'Subscribe from an XMPP client.',
|
||||||
'href' : `xmpp:${pubsub}?pubsub;action=subscribe;node=${node}`},
|
'href' : `xmpp:${pubsub}?pubsub;action=subscribe;node=${node}`,
|
||||||
|
'type' : 'x-scheme-handler/xmpp'},
|
||||||
{'text' : 'Subscribe with a News Reader.',
|
{'text' : 'Subscribe with a News Reader.',
|
||||||
'href' : `feed://${location.host}/atom?pubsub=${pubsub}&node=${node}`},
|
'href' : `feed://${location.host}/atom?pubsub=${pubsub}&node=${node}`,
|
||||||
|
'type' : 'application/atom+xml'},
|
||||||
{'text' : 'Browse the journal.',
|
{'text' : 'Browse the journal.',
|
||||||
'href' : `atom?pubsub=${pubsub}&node=${node}`},
|
'href' : `atom?pubsub=${pubsub}&node=${node}`,
|
||||||
|
'type' : 'application/atom+xml'},
|
||||||
{'text' : 'Browse the portal.',
|
{'text' : 'Browse the portal.',
|
||||||
'href' : `opml?pubsub=${pubsub}`}
|
'href' : `opml?pubsub=${pubsub}`,
|
||||||
|
'type' : 'text/x-opml'}
|
||||||
]
|
]
|
||||||
for (let link of links) {
|
for (let link of links) {
|
||||||
let elementLi = document.createElement('li');
|
let elementLi = document.createElement('li');
|
||||||
let elementA = document.createElement('a');
|
let elementA = document.createElement('a');
|
||||||
elementA.textContent = link.text;
|
elementA.textContent = link.text;
|
||||||
elementA.href = link.href;
|
elementA.href = link.href;
|
||||||
|
elementA.type = link.type;
|
||||||
elementLi.appendChild(elementA);
|
elementLi.appendChild(elementA);
|
||||||
elementUl2.appendChild(elementLi);
|
elementUl2.appendChild(elementLi);
|
||||||
}
|
}
|
||||||
|
@ -233,7 +239,7 @@ window.onload = async function(){
|
||||||
elementDiv.appendChild(elementP2);
|
elementDiv.appendChild(elementP2);
|
||||||
let elementSpan = document.createElement('span');
|
let elementSpan = document.createElement('span');
|
||||||
elementSpan.id = 'return';
|
elementSpan.id = 'return';
|
||||||
elementSpan.textContent = 'Return To PubSub';
|
elementSpan.textContent = 'Return';
|
||||||
elementSpan.addEventListener ('click', function() {
|
elementSpan.addEventListener ('click', function() {
|
||||||
document.querySelector('#selection-page').remove();
|
document.querySelector('#selection-page').remove();
|
||||||
});
|
});
|
||||||
|
@ -242,8 +248,8 @@ window.onload = async function(){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openJson(nodeId) {
|
async function openJson(pubsubJid, nodeId) {
|
||||||
return fetch(`/data/${nodeId}.json`)
|
return fetch(`/data/${pubsubJid}/${nodeId}.json`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('HTTP Error: ' + response.status);
|
throw new Error('HTTP Error: ' + response.status);
|
||||||
|
|
Loading…
Reference in a new issue