220
edits
No edit summary |
No edit summary Tag: Undo |
||
(14 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
mw.loader.load('//wiki.ekatrafoundation.org/index.php?title=User:Gurwinder/Edittool.js&action=raw&ctype=text/javascript'); | |||
// Turn <span class="mw-charinsert">foo</span> into a button that inserts "foo" | |||
// into the edit box: | |||
$( function () { | |||
$( 'span.mw-charinsert' ).wrap( function () { | |||
var text = this.title || this.textContent; | |||
var parts = text.split( '+' ); | |||
if ( text === '+' ) parts = [ text ]; | |||
var front = decodeURIComponent( parts[0] || '' ); | |||
var back = decodeURIComponent( parts[1] || '' ); | |||
return $( '<button>' ).click( function () { | |||
insertTags( front, back, '' ); | |||
return false; | |||
} ); | |||
} ); | |||
} ); | |||
$( function(){ | $( function(){ | ||
if (window.matchMedia("(max-width: 768px)").matches) { | |||
if( mw.config.get("skin") !== "minerva" ){ | |||
const currWikiUrl = new URL(window.location.href); | |||
currWikiUrl.searchParams.set('mobileaction', 'toggle_view_mobile'); | |||
window.location.replace(currWikiUrl); | |||
} | |||
} else { | |||
if( mw.config.get("skin") !== "vector" ){ | |||
const currWikiUrl = new URL(window.location.href); | |||
currWikiUrl.searchParams.set('mobileaction', 'toggle_view_desktop'); | |||
window.location.replace(currWikiUrl); | |||
} | |||
} | |||
if( mw.config.get('wgIsMainPage') ){ | if( mw.config.get('wgIsMainPage') ){ | ||
$('#firstHeading').remove(); | $('#firstHeading').remove(); | ||
Line 54: | Line 87: | ||
stopOthersOnPlay: true | stopOthersOnPlay: true | ||
}); | }); | ||
$( ".wikiaudioplayer > audio").css("display", "none"); | |||
}, | }, | ||
function ( e ) { | function ( e ) { | ||
Line 554: | Line 588: | ||
}); | }); | ||
}()); | }()); | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | |||
self.ws_messages = { | |||
'iwtrans':'Its text comes from', | |||
'iwtrans2':'Its text comes from other sub-domains.', | |||
'optlist':'Display options', | |||
'hide_page_numbers':'Hide page links', | |||
'show_page_numbers':'Show page links', | |||
'layout':'Layout', | |||
'author':'Author', | |||
'translator':'Translator', | |||
'editor':'Editor', | |||
'publisher':'Publisher', | |||
'place':'Place', | |||
'volume':'Volume', | |||
'school':'School', | |||
'book':'Book', | |||
'collection':'Collection', | |||
'journal':'Journal or magazine', | |||
'phdthesis':'Thesis, report', | |||
'dictionary':'Dictionary', | |||
'progress':'Progress', | |||
'progress_T':'Done', | |||
'progress_V':'To be validated', | |||
'progress_C':'To be proofread', | |||
'progress_MS':'Ready for Match & Split', | |||
'progress_OCR':'Needs an OCR text layer', | |||
'progress_L':'Source file is incorrect (missing pages, unordered pages, etc)', | |||
'page_namespace_name': 'Page', | |||
'page_trascluded_in': 'Page trascluded in:', | |||
'text_number': 'Text', | |||
'compare_with': 'Comparison with:', | |||
'compare_texts': 'Compare texts' | |||
}; | |||
$.getScript( '//wiki.ekatrafoundation.org/index.php?title=MediaWiki:Base.js&action=raw&ctype=text/javascript' ) | |||
.done( function() { | |||
importScript('MediaWiki:InterWikiTransclusion.js'); | |||
importScript('MediaWiki:TranscludedIn.js'); | |||
importScript('MediaWiki:Compare.js'); | |||
} ); | |||
/* Footnotes as tooltip - from it.wikipedia.org - request by Candalua */ | |||
$( function () | |||
{ | |||
sups = document.getElementsByTagName("sup"); | |||
for (i=0; i<sups.length; i++) | |||
{ | |||
note_id = sups[i].childNodes[0].href; | |||
if (note_id && (note_id.indexOf("#") != -1)) | |||
{ | |||
note_id = document.getElementById(note_id.substr(note_id.indexOf("#")+1)); | |||
if (note_id) | |||
if (document.all) | |||
{ | |||
sups[i].title = note_id.innerText; | |||
sups[i].childNodes[0].title = note_id.innerText; | |||
} | |||
else | |||
{ | |||
sups[i].title = note_id.textContent; | |||
} | |||
} | |||
} | |||
}); | |||
// Add links to Wikidata in the toolbar where [[Module:Interwiki]] is used | |||
$("#t-wikibase").insertBefore($("#p-tb li").last()).removeAttr("style"); | |||
// Code to switch sizes for {{Tscore resizable}} | |||
$( function () | |||
{ | |||
el = document.getElementsByClassName("prp-page-content"); | |||
if (el.length) { | |||
maxwidth = el[0].clientWidth; | |||
} else { | |||
maxwidth = document.getElementById("mw-content-text").clientWidth; | |||
} | |||
screslistslist = document.getElementsByClassName("score-resizable-container"); | |||
scressizelist = []; | |||
for (i = 0; i < screslistslist.length; i++) { | |||
//maxwidth = screslistslist[i].parentNode.clientWidth; | |||
screslist = screslistslist[i].getElementsByClassName("score-resizable"); | |||
fitwidth = 0; | |||
fitelement = -1; | |||
for (j = 0; j < screslist.length; j++) { | |||
s = screslist[j].className.match(/score-resizable-size-\d+/); | |||
scressizelist[j] = parseInt(s[0].match(/\d+/), 10); | |||
//find largest score that has width < parent width | |||
if (scressizelist[j] > fitwidth && scressizelist[j] <= maxwidth) { | |||
fitwidth = scressizelist[j]; | |||
fitelement = j; | |||
} | |||
} | |||
if (fitelement < 0) { | |||
fitelement = 0; | |||
} | |||
for (j = 0; j < screslist.length; j++) { | |||
if (j != fitelement) { | |||
screslist[j].style.display = "none"; | |||
} | |||
} | |||
screslist[fitelement].style.display = "block"; | |||
} | |||
}); | |||
if (mw.user.isAnon() === true) { // Check if the user is anonymous | |||
$(function () { | |||
$('.ext-wikisource-download-button').hide(); // Hide the button for anonymous users | |||
}); | |||
} |