|
|
Riga 1: |
Riga 1: |
| /* Il codice JavaScript inserito qui viene caricato da ciascuna pagina, per tutti gli utenti. */ | | /* Collegamento diretto alla pagina di upload di Commons nel menu di sinistra, da WP:PT */ |
| /*** RICERCA ***/
| | function linkUploadToMedia() |
| /**
| |
| *******************************************************
| |
| *
| |
| * Descrizione: Cambia Speciale:Ricerca per usare un menu' a
| |
| * tendina, con come default il motore interno di MediaWiki
| |
| *
| |
| * Creato e gestito da: [[:en:User:Gracenotes]]
| |
| * Importato in it.wiki da: [[Utente:Jalo]]
| |
| */
| |
|
| |
| if (wgPageName == "Speciale:Ricerca") {
| |
| var searchEngines = [];
| |
| addOnloadHook(SpecialSearchEnhanced);
| |
| }
| |
|
| |
| function SpecialSearchEnhanced() {
| |
| var createOption = function(site, action, mainQ, addQ, addV) {
| |
| var opt = document.createElement('option');
| |
| opt.appendChild(document.createTextNode(site));
| |
| searchEngines[searchEngines.length] = [action, mainQ, addQ, addV];
| |
| return opt;
| |
| }
| |
| if (document.forms['powersearch'])
| |
| var searchForm = document.forms['powersearch'];
| |
| if (document.forms['search'])
| |
| var searchForm = document.forms['search'];
| |
| | |
| if (searchForm.lsearchbox) {
| |
| var searchBox = searchForm.lsearchbox;
| |
| } else {
| |
| var searchBox = searchForm.search;
| |
| }
| |
| | |
| var selectBox = document.createElement('select');
| |
| selectBox.id = 'searchEngine';
| |
| searchForm.onsubmit = function() {
| |
| var optSelected = searchEngines[document.getElementById('searchEngine').selectedIndex];
| |
| searchForm.action = optSelected[0];
| |
| searchBox.name = optSelected[1];
| |
| searchForm.title.value = optSelected[3];
| |
| searchForm.title.name = optSelected[2];
| |
| }
| |
| selectBox.appendChild(createOption('MediaWiki', wgScriptPath + '/index.php', 'search', 'title', 'Speciale:Ricerca'));
| |
| selectBox.appendChild(createOption('Google', 'http://www.google.com/search', 'q', 'sitesearch', 'it.scoutwiki.org'));
| |
| selectBox.appendChild(createOption('Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'it.scoutwiki.org'));
| |
| selectBox.appendChild(createOption('Windows Live', 'http://search.live.com/results.aspx', 'q', 'q1', 'site:http://it.scoutwiki.org'));
| |
| | |
| searchBox.style.marginLeft = '0px';
| |
|
| |
| // 'searchText' is the firt search text. 'powerSearchText' is the second, used only if the first is not existent (e.g.: not yet done any search)
| |
| buttonSearch=document.getElementById('searchText');
| |
| if (buttonSearch)
| |
| buttonSearch.parentNode.insertBefore(selectBox, buttonSearch.nextSibling);
| |
| else
| |
| {
| |
| buttonSearch=document.getElementById('powerSearchText');
| |
| buttonSearch.parentNode.insertBefore(selectBox, buttonSearch.nextSibling);
| |
| }
| |
| }
| |
| | |
| // Serve per far funzionare il Cassetto2 con IE6.
| |
| if (window.attachEvent && !window.XMLHttpRequest) window.attachEvent("onload", function() {
| |
| var x=document.getElementById("bodyContent").getElementsByTagName("div");
| |
| for (var i=0; i<x.length; i++) {
| |
| if (x[i].className != "HopFrame") continue;
| |
| var y=x[i].getElementsByTagName("div"); var j;
| |
| for (j=0; j<y.length; j++)
| |
| if (y[j].className == "HopContent") {x[i].hopContent = y[j]; break;}
| |
| if (j<y.length) {
| |
| x[i].onmouseover=function() { this.hopContent.style.display="block"; };
| |
| x[i].onmouseout=function() { this.hopContent.style.display="none"; };
| |
| }
| |
| }
| |
| });
| |
| | |
| // BEGIN Dynamic Navigation Bars
| |
| | |
| | |
| /* Test if an element has a certain class **************************************
| |
| *
| |
| * Description: Uses regular expressions and caching for better performance.
| |
| * Maintainers: User:Mike Dillon, User:R. Koot, User:SG
| |
| */
| |
| | |
| var hasClass = (function () {
| |
| var reCache = {};
| |
| return function (element, className) {
| |
| return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
| |
| };
| |
| })();
| |
| | |
| | |
| // set up the words in your language
| |
| var NavigationBarHide = '▲ Nascondi';
| |
| var NavigationBarShow = '▼ Espandi';
| |
| | |
| // set up max count of Navigation Bars on page,
| |
| // if there are more, all will be hidden
| |
| // NavigationBarShowDefault = 0; // all bars will be hidden
| |
| // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
| |
| var NavigationBarShowDefault = 0;
| |
| | |
| | |
| // shows and hides content and picture (if available) of navigation bars
| |
| // Parameters:
| |
| // indexNavigationBar: the index of navigation bar to be toggled
| |
| function toggleNavigationBar(indexNavigationBar)
| |
| {
| |
| var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
| |
| var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
| |
| | |
| if (!NavFrame || !NavToggle) {
| |
| return false;
| |
| }
| |
| | |
| // if shown now
| |
| if (NavToggle.firstChild.data == NavigationBarHide) {
| |
| for (
| |
| var NavChild = NavFrame.firstChild;
| |
| NavChild != null;
| |
| NavChild = NavChild.nextSibling
| |
| ) {
| |
| if (hasClass(NavChild, 'NavPic')) {
| |
| NavChild.style.display = 'none';
| |
| }
| |
| if (hasClass(NavChild, 'NavContent')) {
| |
| NavChild.style.display = 'none';
| |
| }
| |
| if (hasClass(NavChild, 'NavToggle')) {
| |
| NavChild.firstChild.data = NavigationBarShow;
| |
| }
| |
| }
| |
| | |
| // if hidden now
| |
| } else if (NavToggle.firstChild.data == NavigationBarShow) {
| |
| for (
| |
| var NavChild = NavFrame.firstChild;
| |
| NavChild != null;
| |
| NavChild = NavChild.nextSibling
| |
| ) {
| |
| if (hasClass(NavChild, 'NavPic')) {
| |
| NavChild.style.display = 'block';
| |
| }
| |
| if (hasClass(NavChild, 'NavContent')) {
| |
| NavChild.style.display = 'block';
| |
| }
| |
| if (hasClass(NavChild, 'NavToggle')) {
| |
| NavChild.firstChild.data = NavigationBarHide;
| |
| }
| |
| }
| |
| }
| |
| }
| |
| | |
| // adds show/hide-button to navigation bars
| |
| function createNavigationBarToggleButton()
| |
| {
| |
| var indexNavigationBar = 0;
| |
| // iterate over all < div >-elements
| |
| for(
| |
| var i=0;
| |
| NavFrame = document.getElementsByTagName("div")[i];
| |
| i++
| |
| ) {
| |
| // if found a navigation bar
| |
| if (hasClass(NavFrame, 'NavFrame')) {
| |
| | |
| indexNavigationBar++;
| |
| var NavToggle = document.createElement("a");
| |
| NavToggle.className = 'NavToggle';
| |
| NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
| |
| NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
| |
| | |
| var NavToggleText = document.createTextNode(NavigationBarHide);
| |
| NavToggle.appendChild(NavToggleText);
| |
| | |
| // add NavToggle-Button as first div-element
| |
| // in < div class="NavFrame" >
| |
| NavFrame.insertBefore(
| |
| NavToggle,
| |
| NavFrame.firstChild
| |
| );
| |
| NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
| |
| }
| |
| }
| |
| // if more Navigation Bars found than Default: hide all
| |
| if (NavigationBarShowDefault < indexNavigationBar) {
| |
| for(
| |
| var i=1;
| |
| i<=indexNavigationBar;
| |
| i++
| |
| ) {
| |
| toggleNavigationBar(i);
| |
| }
| |
| }
| |
| | |
| }
| |
| | |
| aOnloadFunctions[aOnloadFunctions.length] = createNavigationBarToggleButton;
| |
| | |
| // END Dynamic Navigation Bars
| |
| | |
| | |
| /** Collapsible tables *********************************************************
| |
| *
| |
| * Taken from http://en.wikipedia.org/wiki/MediaWiki:Common.js
| |
| * Description: Allows tables to be collapsed, showing only the header. See
| |
| * Wikipedia:NavFrame.
| |
| * Maintainers: User:R. Koot
| |
| */
| |
| | |
| var autoCollapse = 2;
| |
| var collapseCaption = "nascondi";
| |
| var expandCaption = "espandi";
| |
| | |
| function collapseTable( tableIndex )
| |
| {
| |
| var Button = document.getElementById( "collapseButton" + tableIndex );
| |
| var Table = document.getElementById( "collapsibleTable" + tableIndex );
| |
| | |
| if ( !Table || !Button ) {
| |
| return false;
| |
| }
| |
| | |
| var Rows = Table.getElementsByTagName( "tr" );
| |
| | |
| if ( Button.firstChild.data == collapseCaption ) {
| |
| for ( var i = 1; i < Rows.length; i++ ) {
| |
| Rows[i].style.display = "none";
| |
| }
| |
| Button.firstChild.data = expandCaption;
| |
| } else {
| |
| for ( var i = 1; i < Rows.length; i++ ) {
| |
| Rows[i].style.display = Rows[0].style.display;
| |
| }
| |
| Button.firstChild.data = collapseCaption;
| |
| }
| |
| }
| |
| | |
| function createCollapseButtons() | |
| { | | { |
| var tableIndex = 0; | | if (document.getElementById("carrega-para-media")) return; |
| var NavigationBoxes = new Object();
| | var li_carrega = document.getElementById("t-upload"); |
| var Tables = document.getElementsByTagName( "table" );
| | if (!li_carrega) return; |
| | | var afegit = li_carrega.nextSibling; |
| for ( var i = 0; i < Tables.length; i++ ) {
| | var ul_eines = li_carrega.parentNode; |
| if ( hasClass( Tables[i], "collapsible" ) ) {
| | var li = document.createElement("li"); |
| NavigationBoxes[ tableIndex ] = Tables[i];
| | li.id = "carrega-para-media"; |
| Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
| | li.innerHTML = '<a href="http://media.scoutwiki.org/index.php?title=Special:Upload&wpUploadDescription={{Info%0D%0A%7CDescription+%3D%0D%0A%7CSource+%3D%0D%0A%7CAuthor+%3D+%0D%0A}}">Carica su ScoutMedia</a>'; |
| | | if (afegit) ul_eines.insertBefore(li, afegit); |
| var Button = document.createElement( "span" );
| | else ul_eines.appendChild(li); |
| var ButtonLink = document.createElement( "a" );
| |
| var ButtonText = document.createTextNode( collapseCaption );
| |
| | |
| Button.style.styleFloat = "right";
| |
| Button.style.cssFloat = "right";
| |
| Button.style.fontWeight = "normal";
| |
| Button.style.textAlign = "right";
| |
| Button.style.width = "6em";
| |
| | |
| ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
| |
| ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
| |
| ButtonLink.appendChild( ButtonText );
| |
| | |
| Button.appendChild( document.createTextNode( "[" ) );
| |
| Button.appendChild( ButtonLink );
| |
| Button.appendChild( document.createTextNode( "]" ) );
| |
| | |
| var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
| |
| /* only add button and increment count if there is a header row to work with */
| |
| if (Header) {
| |
| Header.insertBefore( Button, Header.childNodes[0] );
| |
| tableIndex++;
| |
| }
| |
| }
| |
| }
| |
| | |
| for ( var i = 0; i < tableIndex; i++ ) {
| |
| if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
| |
| collapseTable( i );
| |
| }
| |
| }
| |
| }
| |
| | |
| addOnloadHook( createCollapseButtons );
| |
| | |
| //END Collapsible tables
| |
| | |
| //HIDDENCAT (mostra le categorie nascoste). Scippato ai francesi
| |
| function addClass(node, className) {
| |
| if (hasClass(node, className)) {
| |
| return false;
| |
| }
| |
| node.className += ' '+ className;
| |
| return true;
| |
| }
| |
| | |
| function eregReplace(search, replace, subject) {
| |
| return subject.replace(new RegExp(search,'g'), replace); | |
| }
| |
| | |
| function removeClass(node, className) {
| |
| if (!hasClass(node, className)) {
| |
| return false;
| |
| }
| |
| node.className = eregReplace('(^|\\s+)'+ className +'($|\\s+)', ' ', node.className);
| |
| return true;
| |
| }
| |
| | |
| function isClass(element, classe) {
| |
| return hasClass(element, classe); | |
| }
| |
| | |
| function hiddencat()
| |
| {
| |
| var cl = document.getElementById('catlinks'); if(!cl) return;
| |
| var hc = document.getElementById('mw-hidden-catlinks'); if(!hc) return;
| |
| var nc = document.getElementById('mw-normal-catlinks');
| |
| if(!nc)
| |
| {
| |
| var ahc = '<div id="mw-normal-catlinks"><a href="/wiki/Categoria:Categorie" title="Categoria:Categorie">Categorie</a> : <span dir="ltr"><a onclick="javascript:toggleHiddenCats();" id="mw-hidden-cats-link" style="cursor:pointer; color:#002BB8;" title="Questa voce contiene categorie nascoste">[<span style="font-style:italic;">altre</span>]</a></span></div>';
| |
| document.getElementById('catlinks').innerHTML = ahc + cl.innerHTML;
| |
| }
| |
| else if( isClass(hc, 'mw-hidden-cats-hidden') )
| |
| {
| |
| var ahc = ' | <a onclick="javascript:toggleHiddenCats();" id="mw-hidden-cats-link" style="cursor:pointer; color:#002BB8;" title="Questa voce contiene categorie nascoste">[<span style="font-style:italic;">altre</span>]</a>';
| |
| document.getElementById('mw-normal-catlinks').innerHTML += ahc;
| |
| }
| |
| } | |
| function toggleHiddenCats()
| |
| {
| |
| var hc = document.getElementById('mw-hidden-catlinks');
| |
| if( isClass(hc, 'mw-hidden-cats-hidden') )
| |
| {
| |
| removeClass(hc, 'mw-hidden-cats-hidden');
| |
| addClass(hc, 'mw-hidden-cat-user-shown');
| |
| document.getElementById('mw-hidden-cats-link').innerHTML = '[<span style="font-style:italic;">nascondi</span>]';
| |
| }
| |
| else
| |
| {
| |
| removeClass(hc, 'mw-hidden-cat-user-shown');
| |
| addClass(hc, 'mw-hidden-cats-hidden');
| |
| document.getElementById('mw-hidden-cats-link').innerHTML = '[<span style="font-style:italic;">altre</span>]';
| |
| }
| |
| } | | } |
| | | |
| addOnloadHook(hiddencat);
| | addLoadEvent(linkUploadToMedia); |
| | |
| /* Layout pagina di modifica */
| |
| addLoadEvent ( function () | |
| {
| |
| if (wgAction == "edit")
| |
| {
| |
| /* Allarga l'edittools a tutta pagina */
| |
| document.getElementById("Standard").style.width = "100%";
| |
| }
| |
| })
| |