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