MediaWiki:Common.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 134: | Regel 134: | ||
addOnloadHook( function() { | addOnloadHook( function() { | ||
− | |||
if( $('.mw-newarticletext').length ) { | if( $('.mw-newarticletext').length ) { | ||
− | |||
var titles = []; | var titles = []; | ||
if( wgTitle.split(" ").length > 1 ) { | if( wgTitle.split(" ").length > 1 ) { | ||
Regel 157: | Regel 155: | ||
titles.push( wgTitle.substring( 0, wgTitle.length - 1 ) + "us" ); | titles.push( wgTitle.substring( 0, wgTitle.length - 1 ) + "us" ); | ||
} | } | ||
− | |||
if( titles.length ) { | if( titles.length ) { | ||
$('.mw-newarticletext').append( $('<div></div>').addClass("mw-articleAlert") ); | $('.mw-newarticletext').append( $('<div></div>').addClass("mw-articleAlert") ); | ||
$.get("http://wikikids.wiki.kennisnet.nl/api.php?action=query&prop=info&inprop=url&format=json&titles="+titles.join("|"), function( data ) { | $.get("http://wikikids.wiki.kennisnet.nl/api.php?action=query&prop=info&inprop=url&format=json&titles="+titles.join("|"), function( data ) { | ||
for(page in data['query']['pages']) { | for(page in data['query']['pages']) { | ||
− | if( | + | if( data['query']['pages'][page]['missing'] != "" && data['query']['pages'][page]['redirect'] != "" ) { |
− | |||
$('.mw-articleAlert').html('<b>Let op:</b> Er bestaat mogelijk al een artikel over dit onderwerp onder de naam <i><a href="'+data['query']['pages'][page]['fullurl']+'">'+data['query']['pages'][page]['title']+'</a></i>. Door dit te controleren doe je geen werk voor niets!').addClass("errorbox"); | $('.mw-articleAlert').html('<b>Let op:</b> Er bestaat mogelijk al een artikel over dit onderwerp onder de naam <i><a href="'+data['query']['pages'][page]['fullurl']+'">'+data['query']['pages'][page]['title']+'</a></i>. Door dit te controleren doe je geen werk voor niets!').addClass("errorbox"); | ||
} | } |
Versie van 5 jan 2012 22:34
/* JavaScript die hier wordt geplaatst heeft invloed op alle pagina's voor alle gebruikers
<pre>*/
//Als het goed is wordt de scrollbalk nu niet weergegeven, maar word het suggestievakje wat groter...
os_max_lines_per_suggest = 10;
/**********************************/
/* Pas op: Dit is een woordenboek */
/* script */
/* Sumurai8; contact: OP */
/* Maakt 'tooltips' mogelijk */
/* Zie Sjabloon:Wbwoord */
/* Sjabloon:Wbbetekenis */
/**********************************/
var Wbq = ""
var Wbx = ""
var Wby = ""
var Wbz = ""
var WbK = "x" //keep it?
function enableTips() {
for(var counter=1;counter<99;counter++) {
Wbx = document.getElementById('woordenboek'+counter)
Wbq = document.getElementById('woordenboekX'+counter)
if(!Wbx) {
break;
}
Wbq.style.display = "none"
Wbx.style.display = ""
Wbx.onmouseover = showWbTip
Wbx.onmouseout = hideWbTip
Wbx.onclick = keepWbTip
}
}
addOnloadHook(enableTips)
function showWbTip() {
if (WbK == "x") {
Wbz = this.id
Wbz = Wbz.substring(11,Wbz.length)
Wby = document.getElementById('wbcontent'+Wbz)
Wby.style.display = ""
}
}
function hideWbTip() {
if (WbK == "x") {
Wby.style.display = "none"
}
}
function keepWbTip() {
if (WbK == "x") {
WbK = "v"
}
else {
WbK = "x"
}
}
// <source lang='javascript'>
function protectionTemplates() {
if (wgPageName == wgMainPageTitle || wgCanonicalNamespace == "Special" || typeof(wgRestrictionEdit) == "undefined") {
// The current page is the main page, a special page or new. Nothing to do there!
return false;
}
var content = document.getElementById('content');
if (content == null || document.getElementsByTagName('h1')[0] == null) {
// There is no 'content' element and/or no h1 element. So quit.
return false;
}
// Determine template.
if (wgRestrictionEdit[0] != null && wgRestrictionEdit[0] == 'sysop') {
// Editing is limited to sysops.
var templateTitle = 'Beveiligd';
var nodeId = 'templ_Beveiligd';
} else if (wgRestrictionEdit[0] != null && wgRestrictionEdit[0] == 'autoconfirmed') {
// Editing is limited to autoconfirmed users. Effectief nutteloos op deze wiki, dus geen sjabloon
return false;
} else if (wgRestrictionMove[0] != null) {
// Moving the page is limited.
var templateTitle = 'TitelBeveiligd';
var nodeId = 'templ_TitelBeveiligd';
} else {
// The page is not protected.
return false;
}
// Get template from API.
var request = sajax_init_object ();
request.open('GET', wgServer + wgScriptPath + '/api.php?format=json&action=parse&text={{' + encodeURIComponent(templateTitle) + '}}&title=' + encodeURIComponent(wgPageName), true);
request.onreadystatechange =
function () {
if (request.readyState != 4) return;
if (request.status == 200 && request.responseText && request.responseText.charAt(0) == '{') {
var json = eval ('(' + request.responseText + ')');
if (json.parse.text['*']) {
var divContent = json.parse.text['*'];
}
}
if (divContent != null) {
// We retrieved the template. Add it to the page.
var divNode = document.createElement('div');
divNode.id = nodeId;
divNode.className = 'Titel_item3';
divNode.innerHTML = divContent;
content.insertBefore(divNode, document.getElementsByTagName('h1')[0]);
}
if( $('#awardtemplate').length ) { $('#protectedtext').hide() }
};
request.setRequestHeader ('Pragma', 'cache=yes');
request.setRequestHeader ('Cache-Control', 'no-transform');
request.send (null);
}
addOnloadHook(protectionTemplates);
//Voeg automatisch beschrijvingsjabloon in op [[Speciaal:Upload]]
addOnloadHook( function() {
if($('#wpDestFile').val() == "") {
$('#wpUploadDescription').val('{{Afbeelding|\n|Wat staat er precies op de afbeelding?=\n|Waar heb je de afbeelding vandaan?=\n|Schrijf de complete link van de vindplaats op=\n|Wie heeft de afbeelding gemaakt?=\n|Heb je toestemming om de afbeelding te uploaden?=\n|Welke licentie?=\n}}');
}
// else {
// reupload ipv gewone upload
// }
} );
addOnloadHook( function() {
if( $('.mw-newarticletext').length ) {
var titles = [];
if( wgTitle.split(" ").length > 1 ) {
return false;
}
//Werken -> Werk
if( wgTitle.substring( wgTitle.length - 2 ) == "en" ) {
titles.push( wgTitle.substring( 0, wgTitle.length - 2 ) );
}
//Musicals -> Musical
if( wgTitle.substring( wgTitle.length - 1 ) == "s" ) {
titles.push( wgTitle.substring( 0, wgTitle.length - 1 ) );
}
//Fora -> Forum
if( wgTitle.substring( wgTitle.length - 1 ) == "a" ) {
titles.push( wgTitle.substring( 0, wgTitle.length - 1 ) + "um" );
}
//Technici -> Technicus
if( wgTitle.substring( wgTitle.length - 1 ) == "i" ) {
titles.push( wgTitle.substring( 0, wgTitle.length - 1 ) + "us" );
}
if( titles.length ) {
$('.mw-newarticletext').append( $('<div></div>').addClass("mw-articleAlert") );
$.get("http://wikikids.wiki.kennisnet.nl/api.php?action=query&prop=info&inprop=url&format=json&titles="+titles.join("|"), function( data ) {
for(page in data['query']['pages']) {
if( data['query']['pages'][page]['missing'] != "" && data['query']['pages'][page]['redirect'] != "" ) {
$('.mw-articleAlert').html('<b>Let op:</b> Er bestaat mogelijk al een artikel over dit onderwerp onder de naam <i><a href="'+data['query']['pages'][page]['fullurl']+'">'+data['query']['pages'][page]['title']+'</a></i>. Door dit te controleren doe je geen werk voor niets!').addClass("errorbox");
}
}
} );
}
}
} );
// </source>
/*</pre>*/