MediaWiki:Wiktionary-Einstellungen.js

Aus Wiktionary, dem freien Wörterbuch
/*</pre>
__TOC__
== Javascript to perform the CSS insertions ==
<pre> */

mw.loader.using( ['mediawiki.util'] ).done( function () {
if ( mw.cookie.get('WiktionaryUseJSPreferences') == 'true' ) {

// CSS Insertions

 if ( mw.cookie.get('WiktionaryPreferencesHideSiteNotice') == 'true' ) mw.util.addCSS('#siteNotice { display: none; } ');

 //no button for this yet...
 mw.util.addCSS('#bodyContent .allpagesredirect { text-decoration:line-through }');

//Additional optional JavaScript insertions

 if ( mw.cookie.get('WiktionaryPreferencesPopUps') == 'true' ) {
    // [[w:User:Lupin/popups.js]]
    mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Lupin/popups.js&action=raw&ctype=text/javascript');
    } //end of popups

// End of If (UsePreferences) block
}
});


//array of images
 enWiktPrefButtons = [] ;

/* </pre>
== wiktAddButton ==
<pre> */
// generate buttons 
function wiktAddButton(cookieToToggle, speedTip) {
   var checkbox = document.createElement("input");
       checkbox.type = 'checkbox';
       checkbox.name = cookieToToggle;
       checkbox.onclick = function() {
                if ( mw.cookie.get(this.name) != 'true' ) {
                   mw.cookie.set(this.name, 'true', {expires: 86400 * 399}); // some browsers restrict cookie expiry to 400 days
                } else {
                   mw.cookie.set(this.name, 'false', {expires: 86400 * 399});
                }
	};
       if ( 'true' == mw.cookie.get( cookieToToggle ) ) {
         checkbox.checked = true ;
        }
       var isPreferencePage = document.getElementById('isPreferencePage');
       isPreferencePage.appendChild( checkbox ); 
       if ( 'true' == mw.cookie.get( cookieToToggle ) ) {
         checkbox.checked = true ;
       }
       var text = document.createTextNode( speedTip );
       isPreferencePage.appendChild( text );
       text = document.createElement( 'br' );
       isPreferencePage.appendChild( text );
     return true;
}


function wiktAddSeparator(wiktSepText) {
  var txtnod = document.createTextNode( wiktSepText );
  var isPreferencePage = document.getElementById('isPreferencePage');
      isPreferencePage.appendChild( txtnod );
      txtnod = document.createElement( 'hr' );
      isPreferencePage.appendChild( txtnod );
}

//not used just yet
function wiktAddTextBox(cookieToInput, speedTip) {
    var textbox = document.createElement("input");
        textbox.type = 'text';
        textbox.size = 34;
        textbox.name = cookieToInput;
        textbox.onchange = function() {
            mw.cookie.set(this.name, this.value, {expires: 86400 * 399});
        };
        textbox.value = mw.cookie.get( cookieToInput );
        var text = document.createTextNode( speedTip );
        isPreferencePage.appendChild( text );
        isPreferencePage.appendChild( textbox );
 
        text = document.createElement( 'br' );
        isPreferencePage.appendChild( text );
    return true;
}

/* </pre>
== CustomizePreferencesPage==
<pre> */

function CustomizePreferencesPage() {
   var isPreferencePage = document.getElementById('isPreferencePage');
   if ( !isPreferencePage ) return;

  //OK, so now we know we are on 
  //the Set EnglishWiktionary-specific Preferences page (or impersonation thereof)

   // http://tools.wikimedia.de/~cmackenzie/make_buttons.html
   // crop image to 21 pixels vertical, whatever horizontal.

  wiktAddButton( 'WiktionaryUseJSPreferences', 'Die Einstellungen dieser Seite verwenden');

  wiktAddSeparator('\u00A0 \u00A0 \u00A0 ACHTUNG - Wenn das Kästchen oberhalb nicht gewählt wird, ist ALLES auf dieser Seite deaktiviert');

  wiktAddButton( 'WiktionaryPreferencesHideSiteNotice', 'Globale Nachricht verstecken');

  //TODO: Add color selections for all box-things.

  // [[User:Lupin/popups.js]]
  wiktAddButton( 'WiktionaryPreferencesPopUps', 'Verwende [[w:User:Lupin/popups.js]] (Ursprünglich für die Wikipedia)');

  //Siehe [[MediaWiki:Monobook.js]]
  wiktAddButton( 'WiktionaryPreferencesHideNav', 'Alle Übersetzungstabellen eingeklappt lassen (und ähnliche Bereiche) - Vorgabe ist, sie ausgeklappt zu lassen');
   wiktAddTextBox('WiktionaryPreferencesShowLang', '\u00A0 \u00A0 \u00A0 Diese Sprachen immer anzeigen (mehrere Sprachen mit Komma trennen): ');
  //Siehe [[MediaWiki:Monobook.js]]
  wiktAddButton( 'WiktionaryPreferencesShowNav', 'Alle Übersetzungstabellen ausgeklappt lassen (und ähnliche Bereiche) - Vorgabe ist, sie ausgeklappt zu lassen');
 

}

$(document).ready(CustomizePreferencesPage);

/* </pre> */