مستخدم:Salam32/morebits.js: الفرق بين النسختين

تم إضافة 9٬662 بايت ، ‏ قبل 10 سنوات
لا يوجد ملخص تحرير
ط
}
function twUserIsWhitelisted() {
return userIsInGroup( 'autoconfirmed' ) || userIsInGroup( 'confirmed' );
}
 
if( typeof( TwinkleConfig ) == 'undefined' ) TwinkleConfig = {};
switch (skin)
{
case 'vector':
if( typeof( TwinkleConfig.portletArea ) == 'undefined' ) TwinkleConfig.portletArea = 'right-navigation';
if( typeof( TwinkleConfig.portletId ) == 'undefined' ) TwinkleConfig.portletId = 'p-twinkle';
if( typeof( TwinkleConfig.portletName ) == 'undefined' ) TwinkleConfig.portletName = 'TW';
if( typeof( TwinkleConfig.portletType ) == 'undefined' ) TwinkleConfig.portletType = 'menu';
if( typeof( TwinkleConfig.portletNext ) == 'undefined' ) TwinkleConfig.portletNext = 'p-search';
break;
default:
if( typeof( TwinkleConfig.portletId ) == 'undefined' ) TwinkleConfig.portletId = 'p-cactions';
break;
}
 
/**
* Add a portlet menu to one of the navigation areas on the page.
* This is necessarily quite a hack since skins, navigation areas, and
* portlet menu types all work slightly different.
*
* Available navigation areas depend on the script used.
* Monobook:
* "column-one", outer div class "portlet", inner div class "pBody". Existing portlets: "p-cactions", "p-personal", "p-logo", "p-navigation", "p-search", "p-interaction", "p-tb", "p-coll-print_export"
* Special layout of p-cactions and p-personal through specialized styles.
* Vector:
* "mw-panel", outer div class "portal", inner div class "body". Existing portlets/elements: "p-logo", "p-navigation", "p-interaction", "p-tb", "p-coll-print_export"
* "left-navigation", outer div class "vectorTabs" or "vectorMenu", inner div class "" or "menu". Existing portlets: "p-namespaces", "p-variants" (menu)
* "right-navigation", outer div class "vectorTabs" or "vectorMenu", inner div class "" or "menu". Existing portlets: "p-views", "p-cactions" (menu), "p-search"
* Special layout of p-personal portlet (part of "head") through specialized styles.
* Modern:
* "mw_contentwrapper" (top nav), outer div class "portlet", inner div class "pBody". Existing portlets or elements: "p-cactions", "mw_content"
* "mw_portlets" (sidebar), outer div class "portlet", inner div class "pBody". Existing portlets: "p-navigation", "p-search", "p-interaction", "p-tb", "p-coll-print_export"
*
* NOTE: If anyone is brave enough to reuse this directly, please shoot
* me a note. Otherwise I might change the signature down the line and
* your script breaks. Amalthea.
*
* @param String navigation -- id of the target navigation area (skin dependant, on vector either of "left-navigation", "right-navigation", or "mw-panel")
* @param String id -- id of the portlet menu to create, preferably start with "p-".
* @param String text -- name of the portlet menu to create. Visibility depends on the class used.
* @param String type -- type of portlet. Currently only used for the vector non-sidebar portlets, pass "menu" to make this portlet a drop down menu.
* @param Node nextnodeid -- the id of the node before which the new item should be added, should be another item in the same list, or undefined to place it at the end.
*
* @return Node -- the DOM node of the new item (a DIV element) or null
*/
function twAddPortlet( navigation, id, text, type, nextnodeid )
{
//sanity checks, and get required DOM nodes
var root = document.getElementById( navigation );
if ( !root ) return null;
var item = document.getElementById( id );
if (item)
{
if (item.parentNode && item.parentNode==root) return item;
return null;
}
 
var nextnode;
if (nextnodeid) nextnode = document.getElementById(nextnodeid);
 
//Add styles we might need.
if (!twAddPortlet.styleAdded)
{
if (skin=="vector") appendCSS( "div div.extraMenu h5 span { background-position: 90% 50%;} div.extraMenu h5 a { padding-left: 0.4em; padding-right: 0.4em; width:auto; } div.extraMenu h5 a span {display:inline-block; font-size:0.8em; height:2.5em; font-weight: normal; padding-top: 1.25em; margin-right:14px; }" );
else if (skin=="modern") appendCSS("#mw_contentwrapper div.portlet { overflow:hidden; height:1.5em; margin:0 0 0 14em; padding:0; } #mw_contentwrapper div.portlet h5 {display:none;} #mw_contentwrapper div.portlet div.pBody {margin:0; padding:0;} #mw_contentwrapper div.portlet div.pBody ul { display:inline; margin:0; } #mw_contentwrapper div.portlet div.pBody ul li { display:block; float:left; height:1.5em; margin:0 0.5em; padding:0 0.2em; text-transform:lowercase; } #mw_contentwrapper div.portlet div.pBody ul li a { text-decoration:underline;} #mw_contentwrapper div.portlet div.pBody ul li.selected a { text-decoration:none;}");
twAddPortlet.styleAdded = true;
}
 
//verify/normalize input
type = skin=="vector" && type=="menu" && (navigation=="left-navigation" || navigation=="right-navigation")?"menu":"";
var outerDivClass;
var innerDivClass;
switch (skin)
{
case "vector":
if (navigation!="portal" && navigation!="left-navigation" && navigation!="right-navigation") navigation="mw-panel";
outerDivClass = navigation=="mw-panel"?"portal":(type=="menu"?"vectorMenu extraMenu":"vectorTabs extraMenu");
innerDivClass = navigation=="mw-panel"?'body':(type=='menu'?'menu':'');
break;
case "modern":
if (navigation!="mw_portlets" && navigation!="mw_contentwrapper") navigation="mw_portlets";
outerDivClass = "portlet";
innerDivClass = "pBody";
break;
default:
navigation="column-one";
outerDivClass = "portlet";
innerDivClass = "pBody";
break;
}
 
//Build the DOM elements.
var outerDiv = document.createElement( 'div' );
outerDiv.className = outerDivClass+" emptyPortlet";
outerDiv.id = id;
var nextnode;
if ( nextnode && nextnode.parentNode==root ) root.insertBefore( outerDiv, nextnode );
else root.appendChild( outerDiv );
 
var h5 = document.createElement( 'h5' );
if (type=='menu')
{
var span = document.createElement( 'span' );
span.appendChild( document.createTextNode( text ) );
h5.appendChild( span );
var a = document.createElement( 'a' );
a.href = "#";
var span = document.createElement( 'span' );
span.appendChild( document.createTextNode( text ) );
a.appendChild( span );
h5.appendChild( a );
}
else h5.appendChild( document.createTextNode( text ) );
outerDiv.appendChild( h5 );
var innerDiv = document.createElement( 'div' ); //not strictly necessary with type vectorTabs, or other skins.
innerDiv.className = innerDivClass;
outerDiv.appendChild(innerDiv);
var ul = document.createElement( 'ul' );
innerDiv.appendChild( ul );
 
return outerDiv;
}
 
//Build a portlet menu if it doesn't exist yet, and add the portlet link.
function twAddPortletLink( href, text, id, tooltip, accesskey, nextnode )
{
if (TwinkleConfig.portletArea) twAddPortlet(TwinkleConfig.portletArea, TwinkleConfig.portletId, TwinkleConfig.portletName, TwinkleConfig.portletType, TwinkleConfig.portletNext);
addPortletLink( TwinkleConfig.portletId, href, text, id, tooltip, accesskey, nextnode );
}
 
if( data.readonly ) {
textarea.setAttribute( 'readonly', 'readonly' );
}
if( data.value ) {
textarea.value = data.value;
}
break;
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onerror = function() {
this.obj.statelem.error( "Error " + this.target.status + " occurred while quering the api." );
}
xmlhttp.onload = function() {
xmlhttp.obj = this;
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'POST' , wgServer + wgScriptPath + '/index.php?useskin=monobook&' + QueryString.create( this.query ), true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.onerror = function(e) {
var self = this.obj;
self.statelem.error( "Error " + e.targetthis.status + " occurred while posting the document." );
}
xmlhttp.onload = function(e) {
var self = this.obj;
var status = e.targetthis.status;
if( status != 200 ) {
if( status == 503 ) {
var retry = e.targetthis.getResponseHeader( 'Retry-After' );
var lag = e.targetthis.getResponseHeader( 'X-Database-Lag' );
if( lag ) {
self.statelem.warn( "current lag of " + lag + " seconds is more than our defined maximum lag of " + wpMaxLag + " seconds, will retry in " + retry + " seconds" );
var xmlDoc = self.responseXML = this.responseXML;
var to = xmlDoc.evaluate( '//redirects/r/@to', xmlDoc, null, XPathResult.STRING_TYPE, null ).stringValue;
if( !this.parent.followRedirect ) {
this.parent.statelem.info('يتم تجاهل التحويلاتالتحويل');
} else if( to ) {
this.parent.query['title'] = to;
xmlhttp.obj = this.parent;
xmlhttp.overrideMimeType('text/xml');
xmlhttp.open( 'GET' , wgServer + wgScriptPath + '/index.php?useskin=monobook&' + QueryString.create( this.parent.query ), true);
xmlhttp.onerror = function() {
var self = this.obj;
* Will eat the whole link
*/
var links_re = new RegExp( "\\[\\[(?:[Ii]mage|[Ff]ile):\\s*" + image_re_string );
var allLinks = unbinder.content.splitWeightedByKeys( '[[', ']]' ).uniq();
for( var i = 0; i < allLinks.length; ++i ) {
* Will eat the whole line.
*/
var gallery_image_re = new RegExp( "(^\\s*(?:[Ii]mage|[Ff]ile):\\s*" + image_re_string + ".*?$)", 'mg' );
unbinder.content.replace( gallery_image_re, "<!-- " + reason + "$1 -->" );
 
* Will only eat the image name and the preceeding bar and an eventual named parameter
*/
var free_image_re = new RegExp( "(\\|\\s*(?:[\\w\\s]+\\=)?\\s*(?:(?:[Ii]mage|[Ff]ile):\\s*)?" + image_re_string + ")", 'mg' );
unbinder.content.replace( free_image_re, "<!-- " + reason + "$1 -->" );
 
addToImageComment: function( image, data ) {
var first_char = image.substr( 0, 1 );
var image_re_string = "(?:[Ii]mage|[Ff]ile):\\s*[" + first_char.toUpperCase() + first_char.toLowerCase() + ']' + RegExp.escape( image.substr( 1 ), true );
var links_re = new RegExp( "\\[\\[" + image_re_string );
var allLinks = this.text.splitWeightedByKeys( '[[', ']]' ).uniq();
var template_re_string = "(?:[Tt]emplate:)?\\s*[" + first_char.toUpperCase() + first_char.toLowerCase() + ']' + RegExp.escape( template.substr( 1 ), true );
var links_re = new RegExp( "\\\{\\\{" + template_re_string );
var allTemplates = this.text.splitWeightedByKeys( '{\{', '}}', [ '{{{', '}}}' ] ).uniq();
for( var i = 0; i < allTemplates.length; ++i ) {
if( links_re.test( allTemplates[i] ) ) {
styles.insertRule(
".simplewindow { "+
"font: x-small sans-serif;"+
"position: fixed; "+
"background-color: AliceBlue; "+
frame.appendChild( resizeButton2 );
 
frame.style.width = Math.min(parseInt(window.innerWidth), parseInt(width)) + 'px';
frame.style.height = Math.min(parseInt(window.innerHeight), parseInt(height)) + 'px';
frame.style.top = Math.max(0, parseInt( window.innerHeight - this.height )/2 ) + 'px' ;
frame.style.left = Math.max(0, parseInt( window.innerWidth - this.width )/2 ) + 'px';
var img = document.createElement( 'img' );
img.src = "http://upload.wikimedia.org/wikipedia/commons/thumb/56/5265/Nuvola_apps_errorCrystal_button_cancel.pngsvg/18px-Nuvola_apps_errorCrystal_button_cancel.svg.png";
closeButton.appendChild( img );
 
}
}
 
/*
* Things to note:
* - The users listed in the twinkleblacklist array will *not* be able to use Twinkle, even if they have it enabled as a
* gadget. *However*, since javascript files are usually cached in the client's browser cache, it can take a while for
* the blacklisting to come into effect - theoretically for up to 30 days, although usually with the next browser restart.
* - The search method used the detect the usernames in this array is case-sensitive, so make sure that you get the
* capitalization right! Always capitalize the first letter of a username; this is how the software formats usernames.
* - The users on this blacklist will remain so until they are removed. The only way to restore one of these users' access to
* Twinkle is to remove his/her name from the list. Even then, the user might need to [[WP:BYPASS]] his browser cache.
* - Make sure that every username is wrapped in straight quotation marks ("" or ''), that quotation marks or apostrophes
* within the usernames are preceded by a backward-slash (\), and that every name EXCEPT THE LAST ONE is followed by a
* comma. Not following these directions can cause the script to fail.
* - Correct: http://en.wikipedia.org/w/index.php?title=User%3AAzaToth%2Fmorebits.js&diff=298609098&oldid=298609007
*/
 
var twinkleBlacklistedUsers = ["Dilip rajeev", "Jackmantas", "Flaming Grunt", "Catterick", "44 sweet", "Sarangsaras", "WebHamster", "Radiopathy", "Nezzadar", "Darrenhusted", "Notpietru", "Arthur Rubin", "Wuhwuzdat", "MikeWazowski", "Lefty101", "Bender176", "Tej smiles", "Bigvernie", "TK-CP", "NovaSkola", "Inka 888", "Polaron", "SluggoOne"];
 
if(twinkleBlacklistedUsers.indexOf(wgUserName) != -1 && twinkleConfigExists) twinkleConfigExists = false;
 
// to check of morebits had loaded
morebits_js_loaded = true;
 
// When Twinkle modules are imported, we can't be sure that this base module
// has been loaded yet. For that reason, modules using them need
// to initialize themselves using
// window.TwinkleInit = (window.TwinkleInit || []).concat( someInitializationFunction );
// for maximal robustness. Looks weird, works well.
addOnloadHook(function()
{
var funcs = window.TwinkleInit;
window.TwinkleInit = { concat : function(func){ func(); return window.TwinkleInit;} }; //redefine the concat method used to enqueue initializers: From now on, they just execute immediately.
if (funcs) for (var i=0; i<funcs.length; i++) funcs[i]();
});