Difference between revisions of "User:Fbstj/gadget/history-test.js"

m
hmm
m (silly mediawiki)
m (hmm)
/* 2018-09-16 display Arcanum entry on Cite:Arcanum-X page */
$(function () {
// check that there is an edit box
if (!mw.config.get('wgCanonicalNamespace') !== 'Cite') return -1;
// check that it's an Arcanum page
const page_name = mw.config.get('wgPageName');
if (!page_name.startsWith('Cite:Arcanum-')) return -3;
// work out the api url
const entry = page_name.split('-')[1];
const url = 'https://wob.coppermind.net/api/entry/'+ entry +'/';
// start fetching from Arcanum
console.log('fetching '+ url);
fetch(url)
.then(function(resp) { return resp.json() })
// place container on page
console.log(entry);
});
});