User:Kwj2772/remote.js

From Meta, a Wikimedia project coordination wiki

Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); IE: hold Ctrl while clicking Refresh, or press Ctrl-F5; Konqueror: simply click the Reload button, or press F5; Opera users may need to completely clear their cache in Tools→Preferences.

//<nowiki>
// to import script easily
metawiki = "http://meta.wikimedia.org";
enwiki = "http://en.wikipedia.org";
dewiki = "http://de.wikipedia.org";
frwiki = "http://fr.wikipedia.org";
eswiki = "http://es.wikipedia.org";
kowiki = "http://ko.wikipedia.org";
commonswiki = "http://commons.wikimedia.org";
path = "/w/index.php?title=";
jssuffix = "&action=raw&ctype=text/javascript";
CSSsuffix = "&action=raw&ctype=text/css";
 
// removeSpam.js
importScriptURI(metawiki+path+'User:Mike.lifeguard/removeSpam.js'+jssuffix);
 
 
/** extract a URL parameter from the current URL **********
 * From [[en:User:Lupin/autoedit.js]]
 *
 * paramName  : the name of the parameter to extract
 *
 * Local Maintainer: [[User:Dschwen]]
 */
 
function getParamValue( paramName ) 
{
 var cmdRe=RegExp( '[&?]' + paramName + '=([^&]*)' );
 var h = document.location.href;
 var m=cmdRe.exec(h);
 if (m) {
  try {
   return decodeURIComponent(m[1]);
  } catch (someError) {}
 }
 return null;
}
 
/***** subPagesLink ********
 * Adds a link to subpages of current page
 *
 *  Maintainers: [[:he:משתמש:ערן]], [[User:Dschwen]]
 *
 *  JSconfig items: bool JSconfig.subPagesLink
 *                       (true=enabled (default), false=disabled)
 ****/
var subPagesLink =
{ 
 //
 // Translations of the menu item
 //
 i18n :
 {
  'bg': 'Подстраници',
  'ca': 'Subpàgines',
  'de': 'Unterseiten',
  'en': 'Subpages',    // default
  'es': 'Subpáginas',
  'fr': 'Sous-pages',
  'gl': 'Subpáxinas',
  'he': 'דפי משנה',
  'it': 'Sottopagine',
  'is': 'Undirsíður',
  'ko': '하위 문서 목록',
  'nl': "Subpagina's",
  'ru': 'Подстраницы'
 },
 
 install: function()
 {
 
  if ( document.getElementById("t-whatlinkshere") 
       &&  wgNamespaceNumber != -2   // Media: (upcoming)
       &&  wgNamespaceNumber != -1   // Special:
       && wgNamespaceNumber != 6     // Image:
       &&  wgNamespaceNumber != 14   // Category:
     )
  {
   var subpagesText = subPagesLink.i18n[wgUserLanguage] || subPagesLink.i18n['en'];
   var subpagesLink ='/wiki/Special:Prefixindex/' + wgPageName +'/';
 
   addPortletLink( 'p-tb', subpagesLink, subpagesText, 't-subpages' );
  }
 }
}
if (wgDBname !='commonswiki') {
    addOnloadHook(subPagesLink.install);
}
/* Live Clock */
function liveClock()
{
 
	liveClock_node = addPortletLink( 'p-personal', wgServer + wgScriptPath + '/index.php?title=' + encodeURIComponent(wgPageName) + '&action=purge', '', 'utcdate' );
        appendCSS('#utcdate { font-size: larger; font-weight: bolder; }');
 
	showTime();
}
addOnloadHook(liveClock)
 
function showTime()
{
 
	var dateNode = liveClock_node;
	if( !dateNode ) {
		return;
	}
    var now = new Date();
	var hh = now.getHours();
	var mm = now.getUTCMinutes();
	var ss = now.getUTCSeconds();
	var time = ( hh < 10 ? '0' + hh : hh ) + ':' + ( mm < 10 ? '0' + mm : mm ) + ':' + ( ss < 10 ? '0' + ss : ss );
	dateNode.firstChild.replaceChild( document.createTextNode( time ), dateNode.firstChild.firstChild );
 
    window.setTimeout(showTime, 1000);
}
 
 
/* Ajax preview & show changes */
ajaxPreviewScrollTop = true //scroll to the top of preview/changes area after each update
ajaxPreviewPos = 'bottom' //buttons on the bottom, replacing standard
 if (wgUserLanguage == "ko") {
    ajaxPreviewButton = '미리 보기' //"preview" button text
    ajaxDiffButton = '차이 보기' //"changes" button text
    }
 else if (wgUserLanguage != "ko") {
    ajaxPreviewButton = 'Show preview' //"preview" button text
    ajaxDiffButton = 'Show changes' //"changes" button text
    }
if (wgDBname != "kowiki" && wgDBname != "enwiki" && wgDBname != "commonswiki") {
importScriptURI('http://en.wikipedia.org/w/index.php?title=User:Js/ajaxPreview.js&action=raw&ctype=text/javascript');
}
 
/* adds a 'logs for this page' link to the toolbox bar
** if the page is a special page, then no link is displayed
** from User:Thebainer/monobook.js
*/
 
addOnloadHook(function () {
    if ( wgCanonicalNamespace == "Special" )
        return;  // don't display link for special pages
 
    url = wgServer + "/w/index.php?title=Special:Log&page=" + encodeURIComponent(wgPageName);
 
    addPortletLink("p-tb", url, "문서 기록", "pt-logs");
});
 
/* Force external url open in new tab */
importScriptURI('http://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-exlinks.js&action=raw&ctype=text/javascript');
 
/* CSS validator */
/* Author: [[User:Kwj2772]] (my first work!) */
/* License: Creative Commons Attribution-ShareAlike (BY-SA) 3.0, GFDL, GPL */
 
if (wgTitle.match(/\.css$/i) && (wgNamespaceNumber == 2 || wgNamespaceNumber == 8)) {
    function validateCSS() {
        var validator = 'http://jigsaw.w3.org/css-validator/validator?usermedium=all&warning=1&lang=en&uri=' /* CSS validator */
        var uri = wgServer + wgScript + '?title=' + wgPageName + '&action=raw&ctype=text/css'
        var encodeduri = encodeURIComponent(uri);
        var y = addPortletLink(toolboxType, validator + encodeduri, 'validate CSS', 'ca-validatecss',
                           'validate CSS', 'v', null);
    }
    addOnloadHook(validateCSS);
}
 
/* Resize gallery to fit screen */
importScriptURI(commonswiki+ path + 'MediaWiki:ResizeGalleries.js' +jssuffix);
 
/* Contribution Range */
importScriptURI(commonswiki + path + 'User:Kwj2772/contribsrange-ko.js' + jssuffix);
 
 
/* Der Grossteil der Codes befindet sich in [[MediaWiki:Common.js]] */
 
//================================================================================
//*** moveEditsection: Moving of the editsection links
 
/*
 * moveEditsection
 * Dieses Script verschiebt die [Bearbeiten]-Buttons vom rechten Fensterrand
 * direkt rechts neben die jeweiligen Überschriften.
 * This script moves the [edit]-buttons from the right border of the window
 * directly right next to the corresponding headings.
 *
 * Zum Abschalten die folgende Zeile (ohne führendes Sternchen) in die eigene
 * monobook.js (zu finden unter [[Special:Mypage/monobook.js|Benutzer:Name/monobook.js]]) kopieren:
 * var oldEditsectionLinks = true;
 *
 * dbenzhuser (de:Benutzer:Dbenzhuser)
 */
if (wgDBname != 'commonswiki') {
addOnloadHook(function() {
    if (typeof oldEditsectionLinks != 'undefined' && oldEditsectionLinks)   return;
    var spans = document.getElementsByTagName("span");
    for (var i=0; i<spans.length; i++) {
        var span = spans[i];
        if (span.className != "editsection")    continue;
        span.style.fontSize = "x-small";
        span.style.fontWeight = "normal";
        span.style.styleFloat = "none"; // IE-Fix für die folgende Zeile
        span.style.cssFloat = "none";
        span.style.marginLeft = "0px";
        span.parentNode.appendChild(document.createTextNode(" "));
        span.parentNode.appendChild(span);
    }
});
}
 
/* Regex replace */
importScriptURI(enwiki+path+'User:Ilmari_Karonen/replace.js'+jssuffix);
 
 
function namespaceRedirect (ns_shortcut, ns) {
    var piece = wgPageName.split(':', 2);
    var prefix = piece[0];
    var pagename = piece[1];
    if (wgCanonicalSpecialPageName == 'Search') {
        var target = decodeURIComponent(getParamValue('search'));
        if (target.indexOf(ns_shortcut+':') != -1) {
            window.location = wgServer + path + target;
        }
    }
    if (prefix == ns_shortcut) {
        window.location = wgServer + path + ns + ':' + pagename;
    }
}
 
namespaceRedirect('UT', 'User_talk');
namespaceRedirect('MSG', 'MediaWiki');
 
 
// Appends a new tab.
 
function global_append_tab (url, name, id)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
 
  var txt = document.createTextNode(name);
  na.appendChild(txt);
 
  var li = document.createElement('li');
  if(id) li.id = id;
  li.appendChild(na);
 
  // Grab the element we want to append the tab and append the tab to it.
  var c1 = document.getElementById('p-cactions');
  if(!c1) return;
  var tabs = c1.getElementsByTagName('ul')[0];
  tabs.appendChild(li);
}
 
function addSULLink() {
if (wgNamespaceNumber == 2 || wgNamespaceNumber == 3) {
if (wgTitle.indexOf("/") != -1) {
    return;
} else {
    var username = encodeURIComponent( wgTitle );
    global_append_tab ('http://toolserver.org/~vvv/sulutil.php?user=' + username, 'SUL status', 'tab-sul');
}
}
 
if (wgCanonicalSpecialPageName == 'Contributions') {
    var username = document.getElementsByName('target')[0].value;
    contributions_username = username;
    global_append_tab ('http://toolserver.org/~vvv/sulutil.php?user=' + username, 'SUL status', 'tab-sul');
}
}
 
if (wgDBname != 'commonswiki') {     
importScriptURI('http://commons.wikimedia.org/w/index.php?title=User:Kwj2772/validator.js&action=raw&ctype=text/javascript');
addOnloadHook(addSULLink);
} 
 
importScriptURI(enwiki+path+'MediaWiki:Gadget-removeAccessKeys.js'+jssuffix);
 
/* installation
 
importScriptURI('http://meta.wikimedia.org/w/index.php?title=User:Kwj2772/remote.js&action=raw&ctype=text/javascript');
 
 
*/
//</nowiki>