Difference between revisions of "User:Fbstj/gadget/history-test.js"
Jump to navigation
Jump to search
m (tweak for now) |
m (ooui buttons) |
||
Line 3: | Line 3: | ||
function A(url, text) { |
function A(url, text) { |
||
− | const el = document.createElement('a') |
+ | const el = document.createElement('a') |
− | el.setAttribute('href', url) |
+ | el.setAttribute('href', url) |
− | el.innerText = text |
+ | el.innerText = text |
+ | el.className = "oo-ui-inputWidget-input oo-ui-buttonElement-button" |
||
− | return el |
+ | return el |
− | } |
+ | } |
+ | function wrap(kid) { |
||
− | const pagename = mw.config.get('wgPageName'); |
||
+ | const el = document.createElement('span') |
||
+ | 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" |
||
+ | el.appendChild(kid) |
||
+ | return el |
||
+ | } |
||
− | const |
+ | const pagename = mw.config.get('wgPageName') |
+ | |||
⚫ | |||
+ | const edit_box = document.querySelector('.editButtons') |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | edit_box.appendChild(wrap(wob_url)) |
||
+ | edit_box.appendChild(wrap(book_url)) |
||
}); |
}); |
Revision as of 18:54, 21 November 2017
/* add links to edit box */ $(function () { function A(url, text) { const el = document.createElement('a') el.setAttribute('href', url) el.innerText = text el.className = "oo-ui-inputWidget-input oo-ui-buttonElement-button" return el } function wrap(kid) { const el = document.createElement('span') 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" el.appendChild(kid) return el } const pagename = mw.config.get('wgPageName') const edit_box = document.querySelector('.editButtons') const wob_url = A('https://wob.coppermind.net/basic_search/?query='+ pagename, 'search Arcanum for "'+ pagename +'"') const book_url = A('http://search.coppermind.net/?search='+ pagename, 'search books for "'+ pagename +'"') edit_box.appendChild(wrap(wob_url)) edit_box.appendChild(wrap(book_url)) });