Diferencia entre revisiones de «MediaWiki:Gadget-Arcanum-search.js»
Ir a la navegación
Ir a la búsqueda
(+) |
m (squash bug hopefully) |
||
Línea 10: | Línea 10: | ||
const el = document.createElement('span') |
const el = document.createElement('span') |
||
el.setAttribute('title', title) |
el.setAttribute('title', title) |
||
el.setAttribute('name', 'search-Arcanum') |
|||
el.appendChild(link) |
el.appendChild(link) |
||
// style elements |
// style elements |
||
Línea 27: | Línea 28: | ||
const page_name = mw.config.get('wgPageName').replace(/[_]/g, '+') |
const page_name = mw.config.get('wgPageName').replace(/[_]/g, '+') |
||
// check we haven't already inserted one |
|||
if (edit_box.querySelector('[name="search-Arcanum"]')) return |
|||
// add a link to the Arcanum |
// add a link to the Arcanum |
Revisión del 11:23 28 jul 2019
// make a nice link button for the edit box function _make_edit_button(url, text, title) { // create link element const link = document.createElement('a') link.textContent = text link.setAttribute('href', url) link.setAttribute('target', '_blank') // create wrap element const el = document.createElement('span') el.setAttribute('title', title) el.setAttribute('name', 'search-Arcanum') el.appendChild(link) // style elements // FIXME: these are copied from the oo-ui elements in the edit box link.className = 'oo-ui-inputWidget-input oo-ui-buttonElement-button' el.className = 'oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-buttonInputWidget' // return element for insertion return el } /* add links to edit box */ mw.hook('wikipage.editform').add(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').replace(/[_]/g, '+') // check we haven't already inserted one if (edit_box.querySelector('[name="search-Arcanum"]')) return // add a link to the Arcanum const wob_url = _make_edit_button('https://wob.coppermind.net/adv_search/?query='+ page_name, 'Search Arcanum', 'Search Arcanum for "'+ page_name +'"') edit_box.appendChild(wob_url) console.warn('gadget:', 'Arcanum-search') });