מדיה ויקי:Functions.js: הבדלים בין גרסאות בדף
תוכן שנמחק תוכן שנוסף
תיקון הוספת רשימת האפשרויות ליד תיבת התקציר |
מוחק פונקציות importUserScript, addLoadEvent, getParamValue - עבר למדיה ויקי:Common.js |
||
שורה 1: | שורה 1: | ||
/* פונקציות כלליות */ |
/* פונקציות כלליות */ |
||
/* פונקציה לייבוא סקריפט מ[[ויקיציטוט:סקריפטים]] */ |
|||
function importUserScript( number ) { |
|||
importScript( "ויקיציטוט:סקריפטים/" + number ); |
|||
} |
|||
/* פונקציה הטוענת פונקציות בעת עליית הדף */ |
|||
function addLoadEvent(e) { |
|||
hookEvent( "load", e ); |
|||
} |
|||
/* פונקציה המחזירה את הטקסט של אלמנט מסוים */ |
/* פונקציה המחזירה את הטקסט של אלמנט מסוים */ |
||
שורה 69: | שורה 59: | ||
} |
} |
||
return li; |
return li; |
||
} |
|||
/* פונקציה לקבלת ערך של פרמטר משורת הכתובת, מתוך [[:en:User:Lupin/autoedit.js]] */ |
|||
function getParamValue( paramName ) { |
|||
if( !location.search ) { |
|||
return null; |
|||
} |
|||
var m = RegExp( "[&?]" + paramName + "=([^&]*)" ).exec( location.search ); |
|||
if (m) { |
|||
try { |
|||
return decodeURIComponent(m[1]); |
|||
} catch( err ) {} |
|||
} |
|||
return null; |
|||
} |
} |
||
גרסה מ־14:19, 18 במאי 2010
/* פונקציות כלליות */
/* פונקציה המחזירה את הטקסט של אלמנט מסוים */
function pickUpText(el) {
return ts_getInnerText(el);
}
/* פונקציה המוסיפה פריט רשימה */
function createOptionElement( select, text, disabled ) {
var option = document.createElement("option");
select.options.add( option );
option.innerHTML = text;
option.title = text;
if( disabled ) {
option.disabled = true;
}
return select;
}
/* פונקציה המוסיפה כפתור לסרגל הכלים */
function addEditButton( imageFile, tagOpen, sampleText, tagClose, speedTip ) {
mwCustomEditButtons.push( {
"imageFile": "http://upload.wikimedia.org/wikipedia/he/" + imageFile,
"tagOpen": tagOpen,
"sampleText": sampleText,
"tagClose": tagClose,
"speedTip": speedTip
} );
}
/* פונקציה להוספת רשימת אפשרויות לצד תיבת התקציר */
function addEditSelect( label, select ) {
var div = document.createElement( "div" );
div.appendChild( document.createTextNode( label + ": " ) );
div.appendChild( select );
document.getElementById( "wpSummaryLabel" ).appendChild( div );
}
/* פונקציה להוספת כפתור לאחד מסרגלי הכלים בממשק, מתוך [[:en:User:Omegatron/monobook.js/addlink.js]] */
function addLink( where, url, name, id, title, key, after ) {
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if( id ) {
li.id = id;
}
li.appendChild(na);
if( key ) {
li.accessKey = key;
title += " [" + tooltipAccessKeyPrefix + key + "]";
}
li.title = title;
var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
if( after ) {
tabs.insertBefore( li, document.getElementById(after) );
} else {
tabs.appendChild( li );
}
return li;
}
/* האורך בבתים של מחרוזת */
String.prototype.getByteLength = function() {
var length = 0, code;
for( var i = 0; i < this.length; i++ ) {
code = this.charCodeAt( i );
if( code < 128 ) {
length++;
} else if( code < 2048 ) {
length += 2;
} else if( code < 65535 ) {
length += 3;
} else {
length += 4;
}
}
return length;
}