מדיה ויקי:Functions.js: הבדלים בין גרסאות בדף
תוכן שנמחק תוכן שנוסף
מוחק פונקציות importUserScript, addLoadEvent, getParamValue - עבר למדיה ויקי:Common.js |
מ Bot: Security fix: protocol-relative URLs per https://meta.wikimedia.org/?oldid=3197161 (questions?). |
||
שורה 21: | שורה 21: | ||
function addEditButton( imageFile, tagOpen, sampleText, tagClose, speedTip ) { |
function addEditButton( imageFile, tagOpen, sampleText, tagClose, speedTip ) { |
||
mwCustomEditButtons.push( { |
mwCustomEditButtons.push( { |
||
"imageFile": " |
"imageFile": "//upload.wikimedia.org/wikipedia/he/" + imageFile, |
||
"tagOpen": tagOpen, |
"tagOpen": tagOpen, |
||
"sampleText": sampleText, |
"sampleText": sampleText, |
גרסה מ־14:33, 10 בפברואר 2012
/* פונקציות כלליות */
/* פונקציה המחזירה את הטקסט של אלמנט מסוים */
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": "//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;
}