MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 34: | Line 34: | ||
// HTML | // HTML | ||
const htmlButton = document.createElement('li') | const htmlButton = document.createElement('li') | ||
htmlButton.classList.add('collapsible', 'mw-list-item') | htmlButton.classList.add('collapsible', 'mw-list-item', 'wiki2print') | ||
htmlButton.id = 'ca- | htmlButton.id = 'ca-html' | ||
htmlButton.innerHTML = '<a href="http://51.195.117.20:5555/html/' + pageName + '" target="_blank">HTML</a>' | htmlButton.innerHTML = '<a href="http://51.195.117.20:5555/html/' + pageName + '" target="_blank">HTML</a>' | ||
pageViews.appendChild(htmlButton) | pageViews.appendChild(htmlButton) | ||
Line 41: | Line 41: | ||
// PDF | // PDF | ||
const pdfButton = document.createElement('li') | const pdfButton = document.createElement('li') | ||
pdfButton.classList.add('collapsible', 'mw-list-item') | pdfButton.classList.add('collapsible', 'mw-list-item', 'wiki2print') | ||
pdfButton.id = 'ca- | pdfButton.id = 'ca-pdf' | ||
pdfButton.innerHTML = '<a href="http://51.195.117.20:5555/pdf/' + pageName + '" target="_blank">PDF</a>' | pdfButton.innerHTML = '<a href="http://51.195.117.20:5555/pdf/' + pageName + '" target="_blank">PDF</a>' | ||
pageViews.appendChild(pdfButton) | pageViews.appendChild(pdfButton) | ||
Line 48: | Line 48: | ||
// UPDATE | // UPDATE | ||
const updateButton = document.createElement('li') | const updateButton = document.createElement('li') | ||
updateButton.classList.add('collapsible', 'mw-list-item') | updateButton.classList.add('collapsible', 'mw-list-item', 'wiki2print') | ||
updateButton.id = 'ca- | updateButton.id = 'ca-update' | ||
updateButton.innerHTML = '<a href="http://51.195.117.20:5555/update/' + pageName + '" target="_blank">update</a>' | updateButton.innerHTML = '<a href="http://51.195.117.20:5555/update/' + pageName + '" target="_blank">update</a>' | ||
pageViews.appendChild(updateButton) | pageViews.appendChild(updateButton) | ||
Line 55: | Line 55: | ||
// FULL UPDATE | // FULL UPDATE | ||
const fullupdateButton = document.createElement('li') | const fullupdateButton = document.createElement('li') | ||
fullupdateButton.classList.add('collapsible', 'mw-list-item') | fullupdateButton.classList.add('collapsible', 'mw-list-item', 'wiki2print') | ||
fullupdateButton.id = 'ca- | fullupdateButton.id = 'ca-full-update' | ||
fullupdateButton.innerHTML = '<a href="http://51.195.117.20:5555/update/' + pageName + '?full=true" target="_blank">full update</a>' | fullupdateButton.innerHTML = '<a href="http://51.195.117.20:5555/update/' + pageName + '?full=true" target="_blank">full update</a>' | ||
pageViews.appendChild(fullupdateButton) | pageViews.appendChild(fullupdateButton) | ||
Line 73: | Line 73: | ||
// HTML | // HTML | ||
const htmlButton = document.createElement('li') | const htmlButton = document.createElement('li') | ||
htmlButton.classList.add('collapsible', 'mw-list-item') | htmlButton.classList.add('collapsible', 'mw-list-item', 'wiki2print') | ||
htmlButton.id = 'ca- | htmlButton.id = 'ca-html' | ||
htmlButton.innerHTML = '<a href="http://51.195.117.20:5555/html/' + pageName + '" target="_blank">HTML</a>' | htmlButton.innerHTML = '<a href="http://51.195.117.20:5555/html/' + pageName + '" target="_blank">HTML</a>' | ||
pageViews.appendChild(htmlButton) | pageViews.appendChild(htmlButton) | ||
Line 80: | Line 80: | ||
// PDF | // PDF | ||
const pdfButton = document.createElement('li') | const pdfButton = document.createElement('li') | ||
pdfButton.classList.add('collapsible', 'mw-list-item') | pdfButton.classList.add('collapsible', 'mw-list-item', 'wiki2print') | ||
pdfButton.id = 'ca- | pdfButton.id = 'ca-pdf' | ||
pdfButton.innerHTML = '<a href="http://51.195.117.20:5555/pdf/' + pageName + '" target="_blank">PDF</a>' | pdfButton.innerHTML = '<a href="http://51.195.117.20:5555/pdf/' + pageName + '" target="_blank">PDF</a>' | ||
pageViews.appendChild(pdfButton) | pageViews.appendChild(pdfButton) | ||
Line 87: | Line 87: | ||
// UPDATE | // UPDATE | ||
const updateButton = document.createElement('li') | const updateButton = document.createElement('li') | ||
updateButton.classList.add('collapsible', 'mw-list-item') | updateButton.classList.add('collapsible', 'mw-list-item', 'wiki2print') | ||
updateButton.id = 'ca- | updateButton.id = 'ca-update' | ||
updateButton.innerHTML = '<a href="http://51.195.117.20:5555/update/' + pageName + '" target="_blank">update</a>' | updateButton.innerHTML = '<a href="http://51.195.117.20:5555/update/' + pageName + '" target="_blank">update</a>' | ||
pageViews.appendChild(updateButton) | pageViews.appendChild(updateButton) | ||
Line 94: | Line 94: | ||
// FULL UPDATE | // FULL UPDATE | ||
const fullupdateButton = document.createElement('li') | const fullupdateButton = document.createElement('li') | ||
fullupdateButton.classList.add('collapsible', 'mw-list-item') | fullupdateButton.classList.add('collapsible', 'mw-list-item', 'wiki2print') | ||
fullupdateButton.id = 'ca- | fullupdateButton.id = 'ca-full-update' | ||
fullupdateButton.innerHTML = '<a href="http://51.195.117.20:5555/update/' + pageName + '?full=true" target="_blank">full update</a>' | fullupdateButton.innerHTML = '<a href="http://51.195.117.20:5555/update/' + pageName + '?full=true" target="_blank">full update</a>' | ||
pageViews.appendChild(fullupdateButton) | pageViews.appendChild(fullupdateButton) | ||
} | } |
Revision as of 15:45, 8 December 2022
/* Any JavaScript here will be loaded for all users on every page load. */
// Any JavaScript here will be loaded for all
// users on every page load.
console.log('hello from common.js')
// rename 'Discussion' tab or context menu button
// to 'CSS' in the 'Pdf' namespace.
const
url = window.location.href,
NS = 'Pdf', // content namespace
cssNS = NS + 'CSS', // css namespace
pageName = mw.config.get("wgPageName").split(":")[1]
if (url.includes(NS + ':')) {
console.log('this page is in namespace', NS)
const talkAnchor = document.querySelector('#ca-talk a')
const talkLink = talkAnchor.href
talkAnchor.innerText = 'CSS!'
// adding more buttons
const pageViews = document.querySelector('#p-views ul')
// wiki2print
// const wiki2printButton = document.createElement('li')
// wiki2printButton.classList.add('collapsible', 'mw-list-item')
// wiki2printButton.id = 'ca-wiki2print'
// wiki2printButton.innerHTML = '<a href="http://51.195.117.20:5555/" target="_blank">wiki2print</a>'
// pageViews.appendChild(wiki2printButton)
// HTML
const htmlButton = document.createElement('li')
htmlButton.classList.add('collapsible', 'mw-list-item', 'wiki2print')
htmlButton.id = 'ca-html'
htmlButton.innerHTML = '<a href="http://51.195.117.20:5555/html/' + pageName + '" target="_blank">HTML</a>'
pageViews.appendChild(htmlButton)
// PDF
const pdfButton = document.createElement('li')
pdfButton.classList.add('collapsible', 'mw-list-item', 'wiki2print')
pdfButton.id = 'ca-pdf'
pdfButton.innerHTML = '<a href="http://51.195.117.20:5555/pdf/' + pageName + '" target="_blank">PDF</a>'
pageViews.appendChild(pdfButton)
// UPDATE
const updateButton = document.createElement('li')
updateButton.classList.add('collapsible', 'mw-list-item', 'wiki2print')
updateButton.id = 'ca-update'
updateButton.innerHTML = '<a href="http://51.195.117.20:5555/update/' + pageName + '" target="_blank">update</a>'
pageViews.appendChild(updateButton)
// FULL UPDATE
const fullupdateButton = document.createElement('li')
fullupdateButton.classList.add('collapsible', 'mw-list-item', 'wiki2print')
fullupdateButton.id = 'ca-full-update'
fullupdateButton.innerHTML = '<a href="http://51.195.117.20:5555/update/' + pageName + '?full=true" target="_blank">full update</a>'
pageViews.appendChild(fullupdateButton)
} else if (url.includes(cssNS + ':')) {
console.log('this page is in namespace', cssNS)
const contentAnchor = document.querySelector('#ca-nstab-pdf a')
const contentLink = contentAnchor.href
contentAnchor.innerText = 'Content'
// adding more buttons
const pageViews = document.querySelector('#p-views ul')
// HTML
const htmlButton = document.createElement('li')
htmlButton.classList.add('collapsible', 'mw-list-item', 'wiki2print')
htmlButton.id = 'ca-html'
htmlButton.innerHTML = '<a href="http://51.195.117.20:5555/html/' + pageName + '" target="_blank">HTML</a>'
pageViews.appendChild(htmlButton)
// PDF
const pdfButton = document.createElement('li')
pdfButton.classList.add('collapsible', 'mw-list-item', 'wiki2print')
pdfButton.id = 'ca-pdf'
pdfButton.innerHTML = '<a href="http://51.195.117.20:5555/pdf/' + pageName + '" target="_blank">PDF</a>'
pageViews.appendChild(pdfButton)
// UPDATE
const updateButton = document.createElement('li')
updateButton.classList.add('collapsible', 'mw-list-item', 'wiki2print')
updateButton.id = 'ca-update'
updateButton.innerHTML = '<a href="http://51.195.117.20:5555/update/' + pageName + '" target="_blank">update</a>'
pageViews.appendChild(updateButton)
// FULL UPDATE
const fullupdateButton = document.createElement('li')
fullupdateButton.classList.add('collapsible', 'mw-list-item', 'wiki2print')
fullupdateButton.id = 'ca-full-update'
fullupdateButton.innerHTML = '<a href="http://51.195.117.20:5555/update/' + pageName + '?full=true" target="_blank">full update</a>'
pageViews.appendChild(fullupdateButton)
}