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

ככה?
מ שיפצורים של קיפוד למפעילים
שורה 2: שורה 2:
/* סקריפט להוספת קישורים להוספת תבניות אזהרה שונות למשתמשים, התורמים: Yonidebest, Ofekalef, קיפודנחש, חיים 7 */
/* סקריפט להוספת קישורים להוספת תבניות אזהרה שונות למשתמשים, התורמים: Yonidebest, Ofekalef, קיפודנחש, חיים 7 */


$(document).ready(function() {
$(function() {


function save_topage(title, summary, content, unwatch, next) {
    function save_topage(title, summary, content, unwatch, next) {
var param = {action: 'edit', title: title, summary: summary, token: mw.user.tokens.get('editToken'), appendtext: content, format: 'json'};
var param = {action: 'edit', title: title, summary: summary, token: mw.user.tokens.get('editToken'), appendtext: content, format: 'json'};
if (unwatch)  
if (unwatch)  
שורה 46: שורה 46:
}  
}  


function tn(t) {return $('<span>').text(t);}  
function getUserLink() {
 
if (wgCanonicalSpecialPageName == 'Block')
return mw.util.$content.find('p a:first');
else if (wgAction == 'rollback')
return $('.mw-userlink:first');
else
return $('#mw-diff-ntitle2 a:first');
}
// main body of function
// main body of function
var link = link = mw.util.getParamValue('action') == 'rollback' ?  $('.mw-userlink:first') : $('#mw-diff-ntitle2 a:first'),
var  
link = getUserLink(),
user = link.text(),
user = link.text(),
span = $("<span>"),
anon = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(user),
anon = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(user),
all = [
all = [
שורה 62: שורה 68:
anon ? {t:"תודה", m: "תודה", tl:"הוספת תבנית תודה"} : {t:"בה", m: "בה", tl:"הוספת תבנית ברוך בואך", noPage: true}
anon ? {t:"תודה", m: "תודה", tl:"הוספת תבנית תודה"} : {t:"בה", m: "בה", tl:"הוספת תבנית ברוך בואך", noPage: true}
];
];
if (! user)
function makeSpan(forUser, withUserLinks) {
return;
var span = $("<span>");
if ($.inArray('sysop', wgUserGroups)+1)
if (withUserLinks) {
span.append($('<a>', {href: mw.util.wikiGetlink('User:' + forUser), text: forUser}));
span.append(' ( ');
span.append($('<a>', {href: mw.util.wikiGetlink('User Talk:' + forUser), text: 'שיחה'}));
span.append(', ');
span.append($('<a>', {href: mw.util.wikiGetlink('Special:Contributions/' + forUser), text: 'תרומות'}));
span.append(', ');
span.append($('<a>', {href: mw.util.wikiGetlink('Special:Block/' + forUser), text: 'חסימה'}));
span.append(' ) ');
}
for (var i in all) {
var templ = all[i];
var page = (templ.noPage)
? ''
: (($.inArray(mw.config.get('wgNamespaceNumber'), [6, 14]) + 1) ? ':' : '') + mw.config.get('wgPageName').replace(/_/g, " ");
var a = $("<a>", {href: '#', user: forUser, refPage: page, title: templ.tl})
.text(templ.t)
.click(activate)
.data({templ: templ});
span.append(i==0 ? '':' | ').append(a);
}
return span;
}
if ($.inArray('sysop', wgUserGroups)+1) {
if (wgCanonicalSpecialPageName == 'Block')
all.splice(0,all.length);
all.push({t:"נחסמת", m: "נחסמת", tl:"הודעה למשתמש שנחסם"});
all.push({t:"נחסמת", m: "נחסמת", tl:"הודעה למשתמש שנחסם"});
 
}
for (var i in all) {
var templ = all[i];
if (user)
var page = (templ.noPage)
link.after(') ').after(makeSpan(user)).after(' (');
? ''
else if (wgAction == 'delete' && wgArticleId == 0) { //more complex case: we have to use API to get the user.
: (($.inArray(mw.config.get('wgNamespaceNumber'), [6, 14]) + 1) ? ':' : '') + mw.config.get('wgPageName').replace(/_/g, " ");
users = {},
var a = $("<a>", {href: '#', user: user, refPage: page, title: templ.tl})
content = mw.util.$content;
.text(templ.t)
$.getJSON(
.click(activate)
mw.util.wikiScript('api'),
.data({templ: templ});
{action: 'query', list: 'deletedrevs', drlimit: 20, drfrom: wgPageName, drto: wgPageName, drprop: 'user', format: 'json'},
span.append(tn(i==0? '':' | ')).append(a);
function(data) {
}
if (data && data.query && data.query.deletedrevs)
link.after(tn(') ')).after(span).after(tn(' ('));
$(data.query.deletedrevs).each(function() {
$(this.revisions).each(function() {users[this.user] = true;});
});
content.append('<p>', {text: 'את הדף ' + wgPageName + ' ערכו העורכים הבאים:'});
for (var editor in users)
content.append($('<p>').append(makeSpan(editor, true)));
});
}
});
});
//</source>
//</source>