Diferencia entre revisiones de «MediaWiki:Gadget-Arcanum-autofill-page.js»

m
try this
(Fbstj changed the content model of the page MediaWiki:Gadget-Arcanum-autofill-page.js from "wikitext" to "JavaScript")
Etiqueta: cambio de modelo de contenido
m (try this)
if (!page_name.startsWith('Cite:Arcanum-')) return -3;
console.warn('gadget:', 'Arcanum-autofill-page')
// work out the api url
const entry = page_name.split('-')[1];
const url = 'https://wob.coppermind.net/api/entry/'+ entry +'/';
// start fetching from Arcanum
fetch(url)
.then(function(resp) { return resp.json() })
.then(function(json) {
if (!json || !json.event) { return; }
// the arcanum-entry-info tag
const tag = '<'+'arcanum-entry-info date="'+ (json.date || json.event_date) +'" event="'+ json.event +'">'+ json.event_name +'<'+'/arcanum-entry-info>';
// the rest of the page
const page = tag +"<noinclude>\n\n== Users ==\n\{\{Special:WhatLinksHere/\{\{FULLPAGENAME}}|}}\n[[category: generated citations]]\n";
// only fill in the edit box if it is currently blank
if (edit_box.value == '') {
edit_box.value = page;
console.warn('gadget:', 'Arcanum-autofill-page', 'filled')
// preview the page
document.querySelector('[name="wpPreview"]').click()
}
})
})
40 275

ediciones