מדיה ויקי:Gadget-rcPatrol.js: הבדלים בין גרסאות בדף

תוכן שנמחק תוכן שנוסף
Mikimik (שיחה | תרומות)
מעתיק מוויקיפדיה עריכה של User:Yonidebest - עדכון סקריפט אחרי עדכון תוכנה
Mikimik (שיחה | תרומות)
מעתיק גרסה מעודכנת מוויקיפדיה
שורה 1:
/* Allows to mark articlespages as patrolled infrom the RCRecentchanges or Watchlist page.
*
* Written by [[User:Yonidebest]]
*/
 
window.mypatroltoken = null;
function rcMarkPatrol(id) {
 
var checkbox = document.getElementById(id);
function rcMarkPatrol ( rcspan, id), {tick )
var rcspan = checkbox.parentNode;
{
if (mypatorltoken == "")
if ( !tick ) rcspan.innerHTML = '<font color="orange">מסמן...</font> ';
 
if ( !window.mypatroltoken ) // token not known yet
{
if ( tick < 200 ) setTimeout( function() { rcMarkPatrol( rcspan, id, tick+1 ); }, 50 ); // wait 10 seconds for the token
else rcspan.innerHTML = '<font color="red">נכשל משום שהסקריפט טרם השיג אסימון. נסה שוב בעוד מספר שניות.</font> ';
return;
}
 
else
var a = sajax_init_object();
{
a.open( 'POST', '/w/api.php?action=patrol&rcid=' + checkbox.id + '&token=' + encodeURIComponent(mypatorltokenwindow.mypatroltoken), true );
rcspan.innerHTML = '<font color="orange">מסמן...</font> ';
a.onreadystatechange = function() {
var a = sajax_init_object();
if (a.readyState != 4) return;
a.open('POST', '/w/api.php?action=patrol&rcid=' + checkbox.id + '&token=' + encodeURIComponent(mypatorltoken), true);
if ( a.responseText.indexOf(id) != -1 ) rcspan.innerHTML = '<font color="green">סומן כבדוק</font>; ';
a.onreadystatechange = function() {
else rcspan.innerHTML = '<font color="red">ארעה שגיאה. לא סומן כבדוק. רענן את הדף ונסה שנית.</font> ';
if (a.readyState != 4) return;
// document.write(a.responseText); for debugging
if (a.responseText.indexOf(checkbox.id) != -1)
rcspan.innerHTML = '<font color="green">סומן כבדוק</font>; ';
else
rcspan.innerHTML = '<font color="red">ארעה שגיאה. לא סומן כבדוק. רענן את הדף ונסה שנית.</font> ';
}
a.send(null);
}
a.send(null);
}
var mypatorltoken = "";
 
function rcPatrol()
שורה 41 ⟵ 37:
var itemList;
var enhancedTables = getElementsByClassName(document, 'table', 'mw-enhanced-rc');
if ( !enhancedTables[0] )
itemList = document.getElementById('bodyContent').getElementsByTagName('LI');
else
שורה 96 ⟵ 92:
checkbox.defaultChecked = false;
checkbox.title = 'סמן כבדוק';
checkbox.onclick = function() { rcMarkPatrol( this.parentNode, this.id, 0 ); }
var rcspan = document.createElement('SPAN');
rcspan.idclassName = 'rcspan';
rcspan.appendChild(checkbox);
unpatrolled[0].style.display = "none";
שורה 108 ⟵ 104:
itemList[i].getElementsByTagName('td')[0].insertBefore(rcspan, x);
}
 
// get a patorl token
var a = sajax_init_object();
שורה 115 ⟵ 111:
if (a.readyState != 4) return;
var response = eval('(' + a.responseText + ')');
mypatorltokenwindow.mypatroltoken = response['query']['recentchanges'][0]['patroltoken'];
}
a.send(null);
שורה 124 ⟵ 120:
wgCanonicalSpecialPageName == "Recentchangeslinked" ) addOnloadHook( rcPatrol );
 
/* Mark articlespage as patrolled using ajax - without leaving the page
*
* Written by [[User:Yonidebest]]