Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//// SWL_portlet_infobox.js// If the page contain SWLs, it adds a show/hide portlet in the "ca-views" area (top right corner of the page).// Clicking on it produces an infobox collecting all SWLs, and also highlights them throughout the page.// Links to target pages added.//// Salvatore Loguercio, 2011// email:salvatore.loguercio@Gmail.com//if($(".swl").length!=0){// if there are SWLs on the pagevartitle=document.title.split("-")[0];functionmakeLink(str){return"<a href=\"http://en.wikipedia.org/wiki/Category:SWL/"+str+"\">"+str+"</a>";}functionmakeTable(){// make an infobox with all SWLs, displayed as "predicate-object"varswlArray=$('.swl');// initialize array;varcontent=$.makeArray(swlArray).map(function(elem){// map on every swl foundvarinner1=elem.firstChild,inner2,result=[];if(inner1){varinner2=inner1.firstChild;}varline='<tr><td>'+[makeLink(inner1.className),"<a href="+inner2.href+">"+inner2.title+"</a>"].join('</td><td>')+'</tr>\n';// table formatting stuff; links to target pages added as well.returnline;});return'<table class="infobox" style="width: 22em; text-align: left; font-size: 88%; line-height: 1.5em">'+content+'</table>';// make a pretty infobox, same style as PBB infoboxes.}// toggle functionfunctiontoggle(obj){varel=document.getElementById(obj);if(el.style.display!='none'){el.style.display='none';// hide the infobox$(".swl").css("border","");// hide the borders on SWLs}else{el.style.display='';// show infobox..$(".swl").css("border","3px solid lightgreen");// ..and borders}}varswltab='<div id="swltab" style="display:none">'+makeTable().replace(/,/g,'')+'</div>';// instantiate makeTable, as a <div> with an id to be used by the toggle function. Initially not displayed.$('#siteSub').append(swltab);// Add it right below the page title// Create portlet link*;varportletLink=mw.util.addPortletLink('p-views','#','Semantic Wiki Links','ca-SWL','Shows Semantic Wiki Links on the current page','',document.getElementById("ca-watch"));// Bind click handler$(portletLink).click(function(e){e.preventDefault();toggle("swltab");});}// * see http://www.mediawiki.org/wiki/ResourceLoader/Default_modules#addPortletLink