MediaWiki:Common.js

From titipi
Revision as of 08:21, 6 October 2021 by MMo (talk | contribs)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */

/*
var customizeToolbar = function () {
	console.log('ciao');
};


if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor' ), $.ready
			).then( customizeToolbar );
		}
	} );
}
*/

var ul = document.querySelector(".ns-3000 #p-namespaces ul,.ns-3001 #p-namespaces ul");//finding the list
var newLi = document.createElement("li");// creating a list item
newLi.innerHTML = '<button id="wiki-to-pdf-button"><a id="wiki-to-pdf-link" href="#" title="[insert title]">Open in wiki-to-pdf!</a></button>';
if (ul){
     ul.appendChild(newLi);//adding list item to list
     urlsplit = window.location.href.split(':');
     lastsplit = urlsplit.length - 1;
     document.querySelector("#wiki-to-pdf-link").setAttribute('href','/wiki-to-pdf/unfold/'+urlsplit[lastsplit]);
}

/* iframe check */

if ( window.location !== window.parent.location ) {
  document.body.classList.add('iniframe');
}