کارن:Af420/test.js
يادښت: د غوره توبونو د خوندي کولو وروسته، خپل د کتنمل (بروزر) ساتل شوې حافظه تازه کړی.د نور تفصيل لپاره د غځول په تنۍ کلېک وکړئ.
- فايرفاکس/ سفري: په دې کتنمل کې د Reload د ټکوهلو په وخت د Shift تڼۍ نيولې وساتی، او يا هم Ctrl-F5 يا Ctrl-Rتڼۍ کېښکاږۍ (په Apple Mac کمپيوټر باندې ⌘-R کېښکاږۍ)
- گووگل کروم: په دې کتنمل کې د Ctrl-Shift-R تڼۍ کېښکاږۍ (د مک لپاره ⌘-Shift-R)
- انټرنټ اېکسپلورر: په دې کتنمل کې د Refresh د ټکوهلو په وخت کې د Ctrl تڼۍ کېښکاږلې ونيسۍ، او يا هم د Ctrl-F5 تڼۍ کېښکاږۍ
- اوپرا: په دې کتنمل کې د خپل براوزر ساتل شوې حافظه پدې توگه سپينولی شی Tools→Preferences
لاسوند[جوړول]
سمونگران د دې کينډۍ په ازمونمخ (جوړول | هېنداره) او ازمونځايونه (جوړول) مخونو کې خپلې تجربې کولای شي. لطفا وېشنيزې د /لاسوند څېرمه مخ کې ورگډې کړئ. د دې مخ څېرمه مخونه. |
mw.loader.using(['mediawiki.util', 'mediawiki.api', 'oojs-ui-windows', 'oojs-ui-core'], function() {
if (mw.config.get('wgAction') != 'history') return;
var RecoverEase = {};
RecoverEase.config = {
tage: '',
ad: '([[meta:User:Gerges/Gadget/RecoverEase|RecoverEase]])',
disable: []
};
if (typeof RecoverEase.config !== 'undefined') {
Object.assign(RecoverEase.config, window.RecoverEase);
}
if ($.inArray(mw.config.get('wgServerName'), RecoverEase.config.disable) === false) {
return;
}
// Functions
function restoreEdits(api, revid, input, i18n) {
var deferred = $.Deferred();
try {
api.get({
action: 'query',
prop: 'revisions',
revids: revid,
rvprop: 'timestamp',
formatversion: '2'
}).then(function(data) {
var dateObject = new Date(data.query.pages[0].revisions[0].timestamp);
dateObject.setSeconds(dateObject.getSeconds() + 1);
const rvstart = dateObject.toISOString();
api.get({
action: 'query',
prop: 'revisions',
titles: mw.config.get('wgPageName'),
rvlimit: 'max',
rvprop: 'user',
rvdir: 'newer',
rvstart: rvstart,
formatversion: '2'
}).then(function(data) {
const users = data.query.pages[0].revisions.map(revision => revision.user);
const uniqueUsers = [...new Set(users)];
const numOfUsers = uniqueUsers.length;
let usersString;
if (numOfUsers === 1) {
usersString = mw.message('RecoverEase-summary_user', uniqueUsers[0]).toString();
} else if (numOfUsers === 2) {
usersString = `${mw.message('RecoverEase-summary_user', uniqueUsers[0])} ${mw.message('RecoverEase-and')}${mw.message('RecoverEase-summary_user', uniqueUsers[1]).toString().toString().toString()}`;
} else {
const lastUser = uniqueUsers.pop();
usersString = `${uniqueUsers.map(user => mw.message('RecoverEase-summary_user', user)).join(mw.message('RecoverEase-comma'))} ${mw.message('RecoverEase-and')}${mw.message('RecoverEase-summary_user', lastUser).toString().toString().toString().toString()}`;
}
if (input === '') {
summaryRecover = mw.message('RecoverEase-summary', usersString).toString();
} else {
summaryRecover = `${mw.message('RecoverEase-summary', usersString).toString()} : ${input}`;
}
api.postWithEditToken({
action: 'edit',
pageid: mw.config.get('wgArticleId'),
undo: mw.config.get('wgCurRevisionId'),
undoafter: revid,
summary: summaryRecover + RecoverEase.ad,
tags: RecoverEase.tags
}).then(function(data) {
deferred.resolve();
}, function(_, data) {
deferred.reject([new OO.ui.Error(api.getErrorMessage(data))]);
});
}, function(_, data) {
deferred.reject([new OO.ui.Error(api.getErrorMessage(data))]);
});
}, function(_, data) {
deferred.reject([new OO.ui.Error(api.getErrorMessage(data))]);
});
} catch (error) {
deferred.reject([new OO.ui.Error(error)]);
}
return deferred.promise();
}
RecoverEase.messages = {
en: {
'RecoverEase-name': 'RecoverEase',
'RecoverEase-summary': 'Undid edits of $1 ',
'RecoverEase-summary_user': '[[User:$1|$1]] ([[User talk:$1|Talk]])',
'RecoverEase-and': 'and ',
'RecoverEase-comma': ', ',
'RecoverEase-dialog_run': 'Run',
'RecoverEase-dialog_cancel': 'Cancel',
'RecoverEase-dialog_placeholder': 'Reason for reversion',
'RecoverEase-dialog_prompt': 'Reason:',
'RecoverEase-successful': 'Revert successful.... Reloading in a sec'
},
ar: {
'RecoverEase-name': 'بیا رغونکی',
'RecoverEase-summary': 'بدلونونه شاته کول $1 ',
'RecoverEase-summary_user': '[[User:$1|$1]] ([[User talk:$1|خبرې]])',
'RecoverEase-dialog_run': 'پلي کول',
'RecoverEase-dialog_cancel': 'لغوه کول',
'RecoverEase-dialog_placeholder': 'د بيا سره کولو لامل',
'RecoverEase-dialog_prompt': 'لامل:',
'RecoverEase-and': 'او',
'RecoverEase-comma': '، ',
'RecoverEase-successful': 'سمونونه په بریالیتوب سره بیا ځای پرځای سوه... مخ به په يو څو ثانیو کې پورته سي
'
}
};
if (undefined === RecoverEase.messages[mw.config.get('wgUserLanguage')]) {
mw.messages.set(RecoverEase.messages['en']);
} else {
mw.messages.set(RecoverEase.messages[mw.config.get('wgUserLanguage')]);
}
RecoverEase.api = new mw.Api({
ajax: {
headers: {
'Api-User-Agent': 'RecoverEase/1.1'
},
parameters: {
errorformat: 'html',
errorlang: mwConfig.wgUserLanguage,
errorsuselocal: true
}
}
});
var rationaleRecoverInput;
function addLink(item) {
var revid = item.getAttribute('data-mw-revid');
if (revid == mw.config.get('wgCurRevisionId')) return;
var links = item.querySelector('.comment + .mw-changeslist-links');
if (!links) return;
var parent = document.createElement('span'),
el = document.createElement('a');
el.addEventListener('click', function() {
function RecoverDialog(config) {
RecoverDialog.super.call(this, config);
}
OO.inheritClass(RecoverDialog, OO.ui.ProcessDialog);
RecoverDialog.static.name = 'RecoverDialog';
RecoverDialog.static.title = mw.message('RecoverEase-name').toString();
RecoverDialog.static.size = 'medium';
RecoverDialog.static.actions = [{
action: 'save',
label: mw.message('RecoverEase-dialog_run').toString(),
flags: ['primary', 'progressive']
}, {
label: mw.message('RecoverEase-dialog_cancel').toString(),
flags: 'safe'
}];
RecoverDialog.prototype.initialize = function() {
RecoverDialog.super.prototype.initialize.apply(this, arguments);
this.content = new OO.ui.PanelLayout({
padded: true,
expanded: false
});
RecoverOptions = new OO.ui.FieldsetLayout({});
RecoverOptions.addItems([new OO.ui.FieldLayout(rationaleRecoverInput = new OO.ui.TextInputWidget({
placeholder: mw.message('RecoverEase-dialog_placeholder').toString(),
indicator: 'required',
value: '',
}), {
label: mw.message('RecoverEase-dialog_prompt').toString(),
align: 'inline',
})]);
this.content.$element.append(RecoverOptions.$element);
this.$body.append(this.content.$element);
};
RecoverDialog.prototype.getActionProcess = function(action) {
dialog = this;
if (action) {
return new OO.ui.Process(function() {
return restoreEdits(RecoverEase.api, revid, rationaleRecoverInput.value, RecoverEase.i18n)
.then(function() {
dialog.close();
mw.notify(mw.message('RecoverEase-successful').toString());
setTimeout(function() {
location.reload()
}, 1500);
});
}, this);
}
return RecoverDialog.super.prototype.getActionProcess.call(this, action);
};
var windowManager = new OO.ui.WindowManager();
$(document.body).append(windowManager.$element);
var dialog = new RecoverDialog();
windowManager.addWindows([dialog]);
windowManager.openWindow(dialog);
});
el.textContent = mw.message('RecoverEase-name').toString() + ' test';
parent.appendChild(el);
links.appendChild(parent);
}
var parents = document.querySelectorAll('li[data-mw-revid]');
for (var i = 0; i < parents.length; i++) {
addLink(parents[i]);
}
});