משתמש:Hidro/common.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
/* אימות - האם באמת התכוונת לצאת מהחשבון? */
function confirmLogout() {
document.getElementById("pt-logout").firstChild.onclick = function() {
return confirm( "האם אתה בטוח שברצונך לצאת מהחשבון?" );
}
}
$(confirmLogout);
//
// סקריפט 16: נלקח מ[[ויקיפדיה:סקריפטים/16]]
// הקוד בודק אחוזי תמיכה בהצבעות. יש לסמן לפחות 2 תיבות סימון ואז לחיצה על תיבת סימון כלשהי תבדוק את אחוז התמיכה של שתי הרשימות.
// נכתב על ידי [[משתמש:Yonidebest]]
//
function checkVotingStatus() {
var inputs = document.getElementById('bodyContent').getElementsByTagName('INPUT');
var ols = document.getElementById('bodyContent').getElementsByTagName('OL');
var firstCatch = true;
var firstOL;
var secondOL;
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].getAttribute('name') != 'VoteOption' || !inputs[i].checked) continue;
if (firstCatch) {
firstOL = ols[Number(inputs[i].getAttribute('value'))];
firstCatch = false;
} else {
secondOL = ols[Number(inputs[i].getAttribute('value'))];
break;
}
}
if (firstOL && secondOL) {
var li1Length = firstOL.getElementsByTagName('LI').length;
var li2Length = secondOL.getElementsByTagName('LI').length;
var result1 = ( (li1Length / (li1Length + li2Length))*100 ).toFixed(2);
var result2 = ( (li2Length / (li1Length + li2Length))*100 ).toFixed(2);
alert('אחוז תמיכה רשימה ראשונה: ' + result1 + '%\nאחוז תמיכה רשימה שנייה: ' + + result2 + '%');
} else alert('הייתה בעיה. האם סימנת שתי תיבות סימון?');
}
function addCheckVotingStatus() {
if (wgPageName.indexOf('ויקיפדיה:פרלמנט') != 0 &&
wgPageName.indexOf('ויקיפדיה:רשימת_מועמדים_למחיקה/') != 0 &&
wgPageName.indexOf('ויקיפדיה:רשימת_ערכים_במחלוקת/') != 0) return;
var ols = document.getElementById('bodyContent').getElementsByTagName('OL');
if (!ols) return;
for (var i = 0; i < ols.length; i++) {
var checkbox = document.createElement('INPUT');
checkbox.type = "checkbox";
checkbox.name = "VoteOption";
checkbox.value = i;
checkbox.oncontextmenu = function(){checkVotingStatus();return false;}
ols[i].parentNode.insertBefore(checkbox, ols[i]);
ols[i].parentNode.insertBefore(document.createTextNode('השווה רשימה זו'), ols[i]);
ols[i].parentNode.insertBefore(document.createElement('BR'), ols[i]);
}
}
$(addCheckVotingStatus);
// עד כאן סקריפט 16
//
// סקריפט 15: מתוך [[ויקיפדיה:סקריפטים/15]]
// מוסיף קישור "הסר" תחת הכותרת "קישורי תמונות" בדפי תמונה. לחיצה על הקישור תסיף את התמונה מהערך. עובד ב-IE בלבד.
// created by [[user:Yonidebest]]
//
function addRemoveImageLinks() {
// add the link to image pages
if (wgNamespaceNumber == 6 && wgAction == 'view') {
var ul = document.getElementById('filelinks').nextSibling.nextSibling;
if (!ul) return;
var lis = ul.getElementsByTagName('LI');
for (var i = 0; i < lis.length; i++) {
link = document.createElement('A');
link.href = '/w/index.php?title=' + lis[i].childNodes[0].title + '&action=edit&removeimage=yes&name=' + encodeURIComponent(wgTitle);
link.appendChild(document.createTextNode('הסר'));
lis[i].appendChild(document.createTextNode(' ('));
lis[i].appendChild(link);
lis[i].appendChild(document.createTextNode(')'));
}
}
// remove image and save
if (getParamValue('removeimage') == 'yes') {
var imageName = decodeURIComponent(getParamValue('name'));
if (imageName) {
var rx = new RegExp('\\[\\[\\s?:?(תמונה|image)\\s?:\\s?(' + imageName + '|' + imageName.replace(' ', '_') + ')([^\\[]|\\[\\[[^\\]]*\\]\\])*\\]\\]', 'ig');
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(rx, '');
document.editform.wpSummary.value = 'הסרת [[תמונה:' + imageName + ']]';
document.editform.wpSave.click();
}
}
}
$(addRemoveImageLinks);
// עד כאן סקריפט 15
// Revert tools by Lorian
function getElementsByClass(searchClass,node,tag) {
// Function from http://www.dustindiaz.com/getelementsbyclass/
var classElements = new Array();
if ( node == null )
node = document;
if ( tag == null )
tag = '*';
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
// _GET code from NoGray JS Library http://www.nogray.com/new_site/
var _GET = new Array();
var _uri = location.href;
var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");
var _temp_get_arr_1 = new Array();
for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){
_temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("=");
_GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]);
}
delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;
function getMessage (where, user1, user2) {
var message = prompt ('איזו הודעה ברצונך להשאיר?', '');
window.location = 'https://he.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
}
$(function (){
if (location.href.match(/diff=/)) {
// Get username of submitter
var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;
document.getElementById('contentSub').innerHTML = '(<a href="https://he.wikipedia.org/w/index.php?title=' + wgPageName + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">שחזר</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">הודעה</a>) (<a href="https://he.wikipedia.org/w/index.php?title=' + wgPageName + '&action=edit&oldid=' + _GET['oldid'] + '&vandalism=1&user1='+user1+'&user2='+user2+'">ונדליזם</a> / <a href="javascript:var message = getMessage(\'vandalism\', \''+user1+'\', \''+user2+'\');">הודעה</a>) (אזהרה: <a href="https://he.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=1">אזהרה</a> / <a href="https://he.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=2">ניסויים</a> / <a href="https://he.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=3">תודה</a>)';
} else if (location.href.match(/revert=1/)) {
document.getElementById('wpSummary').value = 'שוחזר מעריכה של [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] לגרסה ' + _GET['oldid']+' של [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
document.getElementById('editform').submit();
} else if (location.href.match(/revert=2/)) {
document.getElementById('wpSummary').value = 'שוחזר מעריכה של [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] לגרסה ' + _GET['oldid']+' של [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
document.getElementById('editform').submit();
} else if (location.href.match(/vandalism=1/)) {
document.getElementById('wpSummary').value = 'שחזור השחתה של[[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] לגרסה ' + _GET['oldid']+' של [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
document.getElementById('editform').submit();
} else if (location.href.match(/vandalism=2/)) {
document.getElementById('wpSummary').value = 'שחזור השחתה של [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] לגרסה ' + _GET['oldid']+' של [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=1/)) {
document.getElementById('wpSummary').value = 'אזהרת השחתה';
document.getElementById('wpTextbox1').value = '{{אזהרה}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=2/)) {
document.getElementById('wpSummary').value = 'ניסויי עריכה';
document.getElementById('wpTextbox1').value = '{{ניסויים}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=3/)) {
document.getElementById('wpSummary').value = 'תודה על תרומתך לוויקיפדיתנו!';
document.getElementById('wpTextbox1').value = '{{תודה}} ~~'+'~~';
document.getElementById('editform').submit();
}
});
//עד כאן סקריפט השחזורים
// addPurge
$(function () {
var hist; var url;
if (!(hist = document.getElementById('ca-history') )) return;
if (!(url = hist.getElementsByTagName('a')[0] )) return;
if (!(url = url.href )) return;
mw.util.addPortletLink('p-cactions', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'),
'purge', 'ca-purge', 'Purge server cache for this page', '0');
});
//