Difference between revisions of "User:Fbstj/gadget/history-test.js"
Jump to navigation
Jump to search
m (tweak) |
m (move to staff js) |
||
Line 1: | Line 1: | ||
− | /* add links to edit box */ |
||
− | $(function () { |
||
− | |||
− | const edit_box = document.querySelector('.editButtons') |
||
− | // check that there is an edit box |
||
− | if (!edit_box || mw.config.get('wgCanonicalNamespace') !== '') return |
||
− | |||
− | const page_name = mw.config.get('wgPageName') |
||
− | |||
− | const wob_url = make_edit_button('https://wob.coppermind.net/basic_search/?query='+ page_name, 'Arcanum?', 'Search Arcanum for "'+ page_name +'"') |
||
− | edit_box.appendChild(wob_url) |
||
− | |||
− | const booksearch_url = make_edit_button('http://search.coppermind.net/?search='+ page_name, 'book search', 'Search books for "'+ page_name +'"') |
||
− | edit_box.appendChild(booksearch_url) |
||
− | |||
− | }); |
||
− | |||
/* Add edit link to templates */ |
/* Add edit link to templates */ |
||
$(function () { |
$(function () { |
Revision as of 20:59, 21 November 2017
/* Add edit link to templates */ $(function () { function add_editsection_link(box) { if (!box.id) return; // FIXME: what does this do? const id = box.id.replace(/\.(\d+)/, '%$1') // generate an edit link const el = make_editsection_link('/edit/Template:'+ id) // get the title element const title = box.querySelector('.title') title.appendChild(el) } document.querySelectorAll('.infobox,.navbar').forEach(add_editsection_link) })