Uzanto:לערי ריינהארט/vector.js: Malsamoj inter versioj

El Vikipedio, la libera enciklopedio
Enhavo forigita Enhavo aldonita
Nuligis version 5429115 de לערי ריינהארט (kontribuoj, diskutpaĝo)
e +"#" ŝanĝita al +"&live"
Linio 4: Linio 4:
if (wgWikibaseItemId) {
if (wgWikibaseItemId) {
// Add portlet link for item
// Add portlet link for item
mw.util.addPortletLink("p-tb", '//tools.wmflabs.org/reasonator/?lang=eo&q=' + wgWikibaseItemId +"#", "Reasonator (eo)", "t-reasonator-eo", "Wikidata in pretty");
mw.util.addPortletLink("p-tb", '//tools.wmflabs.org/reasonator/?lang=eo&q=' + wgWikibaseItemId +"&live", "Reasonator (eo)", "t-reasonator-eo", "Wikidata in pretty");
if (wgUserLanguage === 'eo') {
if (wgUserLanguage === 'eo') {
} else {
} else {
mw.util.addPortletLink("p-tb", '//tools.wmflabs.org/reasonator/?lang=' + wgUserLanguage + '&q=' + wgWikibaseItemId +"#", "Reasonator", "t-reasonator", "Wikidata in pretty");
mw.util.addPortletLink("p-tb", '//tools.wmflabs.org/reasonator/?lang=' + wgUserLanguage + '&q=' + wgWikibaseItemId +"&live", "Reasonator", "t-reasonator", "Wikidata in pretty");
}
}
}
}

Kiel registrite je 09:50, 26 mar. 2014

/* mw.loader.load("//www.wikidata.org/w/index.php?title=User:%D7%9C%D7%A2%D7%A8%D7%99+%D7%A8%D7%99%D7%99%D7%A0%D7%94%D7%90%D7%A8%D7%98/reasonator.js&action=raw&ctype=text/javascript"); */
/* ne plu havebla ĉe [[MediaWiki:Common.js]] */
(function() {
    if (wgWikibaseItemId) {
      // Add portlet link for item
      mw.util.addPortletLink("p-tb", '//tools.wmflabs.org/reasonator/?lang=eo&q=' + wgWikibaseItemId +"&live", "Reasonator (eo)", "t-reasonator-eo", "Wikidata in pretty");
      if (wgUserLanguage === 'eo') {
      	} else {
    	  mw.util.addPortletLink("p-tb", '//tools.wmflabs.org/reasonator/?lang=' + wgUserLanguage + '&q=' + wgWikibaseItemId +"&live", "Reasonator", "t-reasonator", "Wikidata in pretty");
    	  }
    }
})();
/* ne plu havebla ĉe [[MediaWiki:Common.js]] */

/* test = pruv
function (zemdlekh) {
	if (mw.config.get(mw.user.options.set,language) === 'eo') {
		mw.util.addPortletLink("p-tb", '//zemdlekh.net/found#', "eo found", "t-zemdlekh-eo", "zemdlekh in pretty");
      } else {
      	mw.util.addPortletLink("p-tb", '//zemdlekh.net/not_found#', "eo not found", "t-zemdlekh", "zemdlekh in pretty");
    	  }
    }
}();
test = pruv */

/** extract a URL parameter from the current URL **********
 * From [[commons:en:user:Lupin/autoedit.js]]
 *
 * paramName  : the name of the parameter to extract
 */
 
function getParamValue( paramName, url) 
{
 if (typeof (url) == 'undefined' ) url = document.location.href;
 var cmdRe=RegExp( '[&?]' + paramName + '=([^&]*)' );
 var m=cmdRe.exec(url);
 if (m) {
  try {
   return decodeURIComponent(m[1]);
  } catch (someError) {}
 }
 return null;
}

/* [[commons:Bugzilla:021572]] -- [[commons:meta:user:Platonides]] */
addOnloadHook ( function() { if (wgArticleId) addPortletLink("p-tb", wgScript + "?curid=" + wgArticleId + ( ((wgNamespaceNumber == 24) && getParamValue('dataset')) ? "&dataset=" + getParamValue('dataset') : "" ) , "Short url", "t-curid", "Reference using its article id"); } );

/* <span dir="ltr" >[[commons:user:{{PAGENAME}}|commons:]], [[meta:user:{{PAGENAME}}|meta:]], [[b:user:{{PAGENAME}}|b:]], [[n:user:{{PAGENAME}}|n:]], [[q:user:{{PAGENAME}}|q:]], [[s:user:{{PAGENAME}}|s:]], [[<!-- wikt: -->user:{{PAGENAME}}|wikt:]], [[w:user:{{PAGENAME}}|w:]]</span><br /> */
/* Work-around for [[bugzilla:01229]] */
/* <div dir="ltr" >'''source:''' [[w:en:Wikipedia:WikiProject User scripts/Scripts/Fix diff width]]<br />This script adds scroll bars to wide diffs such as [http://en.wikipedia.org/w/index.php?title=Wikipedia%3ACopyright_problems%2F2005_December_30&diff=33247878&oldid=33247265].  It replaces the table-based diff layout with a CSS-based layout where the column width is always exactly 50%.  Known to work in [[w:en:Firefox|Firefox]], [[w:en:Konqueror|Konqueror]], [[w:en:Opera (web browser)|Opera]] and at least some versions of [[w:en:Internet Explorer|Internet Explorer]].  This script is a workaround for [[bugzilla:01229|Bug 01229]].  If you have any problems with this script, please [[w:en:User talk:Ilmari Karonen|let me know]]. */

// <pre><nowiki>
// inline style sheet to keep this whole thing self-contained:
document.write('<style type="text/css">' +
    ' .xdiff { width: 100%; background: white; }' +
    ' .xdiff-row { width: 100%; margin: 0 0 3px 0; overflow: hidden; }' +
    ' .xdiff-col { width: 49%; margin: 0; float: left; clear: none; position: relative; }' +
    ' .xdiff-sign, .xdiff-outer, .xdiff-inner { display: block; margin: 0; }' +
    ' .xdiff-sign { position: absolute; top: 0; left: 0; width: 2em; text-align: center; }' +
    ' .xdiff-outer { padding: 0 0 0 2em; }' +
    ' .xdiff-inner { overflow: auto; overflow-y: visible; width: 100%; }' +
    ' .xdiff-inner.diff-addedline { font-size: 85%; background: #cfc; }' +
    ' .xdiff-inner.diff-deletedline { font-size: 85%; background: #ffa; }' +
    ' .xdiff-inner.diff-context { font-size: 85%; background: #eee; }' +
    (!document.recalc ? '' :  // IE kluge:
        ' * html .xdiff-inner { padding-bottom: expression(this.scrollWidth > this.offsetWidth ? "16px" : 0); }' +
        ' * html .xdiff-sign { top: expression((this.parentNode.clientHeight - this.offsetHeight)/2 + "px"); }') +
    '<'+'/style>');

addOnloadHook(function () {
    var diffSigns = new Array();
    var fixDiffWidth = function () {
        var tables = document.getElementsByTagName('table');

        for (var i = 0; i < tables.length; i++) {
            if (tables[i].className != 'diff') continue;
            var rows = tables[i].getElementsByTagName('tr');

            var diffDiv = document.createElement('div');
            diffDiv.className = 'xdiff';

            for (var j = 0; j < rows.length; j++) {
                var rowDiv = document.createElement('div');
                rowDiv.className = 'xdiff-row';

                var colDiv = null;
                var cols = rows[j].getElementsByTagName('td');
                for (var k = 0; k < cols.length; k++) { 
                    if (!colDiv) {
                        colDiv = document.createElement('div');
                        colDiv.className = 'xdiff-col';
                        rowDiv.appendChild(colDiv);
                    }
                    if (cols[k].getAttribute('colspan') == 2 || cols[k].className.substring(0,5) == 'diff-') {                
                        // use spans instead of divs so that an eventual non-js solution will look nice in lynx!
                        var outerSpan = document.createElement('span');
                        var innerSpan = document.createElement('span');
                        outerSpan.className = 'xdiff-outer';
                        innerSpan.className = 'xdiff-inner ' + cols[k].className;
                        innerSpan.style.textAlign = cols[k].getAttribute('align');
                        for (var node = cols[k].firstChild; node; node = node.nextSibling)
                            innerSpan.appendChild(node.cloneNode(true));
                        innerSpan.appendChild(document.createTextNode(String.fromCharCode(0xa0))); // add nbsp
                        outerSpan.appendChild(innerSpan);
                        colDiv.appendChild(outerSpan);
                        colDiv = null;  // start new column
                    }
                    else if (cols[k].firstChild && (cols[k].firstChild.nextSibling ||
                             cols[k].firstChild.nodeType != 3 || cols[k].firstChild.nodeValue.match(/\S/))) {
                        // use spans instead of divs so that an eventual non-js solution will look nice in lynx!
                        var signSpan = document.createElement('span');
                        signSpan.className = 'xdiff-sign';
                        if (!signSpan.style.setExpression)
                            diffSigns[diffSigns.length] = signSpan;
                        for (var node = cols[k].firstChild; node; node = node.nextSibling)
                            signSpan.appendChild(node.cloneNode(true));
                        colDiv.appendChild(signSpan);
                    }
                }
                diffDiv.appendChild(rowDiv);
            }
            tables[i].parentNode.replaceChild(diffDiv, tables[i]);
        }
    };
    // finally, a kluge to vertically center the +/- signs
    var centerDiffSigns = function () {
        for (var i = 0; i < diffSigns.length; i++) {
            var parentHeight;
            if (!( parentHeight = diffSigns[i].parentNode )) continue; 
            if (!( parentHeight = parentHeight.clientHeight )) continue; 
            diffSigns[i].style.top = ((parentHeight - diffSigns[i].offsetHeight)/2) + "px";
        }
    };
    fixDiffWidth();
    if (diffSigns.length) {
        hookEvent('resize', centerDiffSigns);
        setTimeout(centerDiffSigns, 250); 
    }
});

function bidiSwitchSetup() {
	var editform = document.getElementById("wpTextbox1");
	if (editform == null) {
		return;
	}
	
	bidiAddButton(editform, "Default", function(style) {
		style.direction = "inherit";
		style.unicodeBidi = "inherit";
	});
	bidiAddButton(editform, "dir=ltr", function(style) {
		style.direction = "ltr";
	});
	bidiAddButton(editform, "dir=rtl", function(style) {
		style.direction = "rtl";
	});
	bidiAddButton(editform, "bidi=normal", function(style) {
		style.unicodeBidi = "normal";
	});
	bidiAddButton(editform, "bidi=override", function(style) {
		style.unicodeBidi = "bidi-override";
	});
}

function bidiAddButton(before, label, action) {
	var button = document.createElement("input");
	button.type = "button";
	button.value = label;
	button.onclick = function(event) {
		var box = document.getElementById("wpTextbox1");
		if (box == null) {
			alert("Broken! Edit box missing.");
		} else {
			//var style = document.getOverrideStyle(box, null);
			var style = box.style;
			action(style);
		}
	}
	before.parentNode.insertBefore(button, before);
}

hookEvent('load', bidiSwitchSetup);

// </nowiki></pre></div>