User:Foysalur Rahman Shuvo/common.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
The accompanying .css page for this skin is at User:Foysalur Rahman Shuvo/common.css. |
// mobileUndo 2.0.3, a script allowing reversion of edits on mobile.
// All code is released under the default Wikipedia content license.
// Installation instructions at [[User:FR30799386/undo]].
// <doc> This script basically connects an API endpoint to
// a mw-ui-destructive button which is added to the
// footer by using jQuery. Additional functionality
// includes changing the position of the thanks button
// and the addition of a confirm dialog to the thank button,
// to prevent mis-clicks due to both buttons being close
// to each other.
// </doc>
//<nowiki>
console.time('mobileUndo');
$.when(mw.loader.using(['mediawiki.util', 'mediawiki.api', 'oojs-ui-windows', 'oojs-ui-core', 'oojs-ui.styles.icons-editing-core'])).then(function() {
return new mw.Api().getMessages(['editundo', 'Undo-nochange']);
}).then(function(globalmessages) {
var mobileUndo, i18n_lang = mw.config.get('wgUserLanguage');
var i18n = {
"en": {
"mu-success": "Successful",
"mu-fail": "Failed",
"mu-loading": "Loading...",
"editsummary-ad": "([[m:User:FR30799386/undo|mobileUndo]])",
"mu-undo-successful": "Revert successful.... Reloading in a sec",
"mu-empty-reponse-from-server": "An empty response was received from the server",
"mu-edit-summary-prompt": "Add a reason to your edit summary !",
"mu-edit-summary-prompt-placeholder": "Reason...",
"mu-thank-success": "Thanked",
"mu-thank-confirm": "Send public thanks ?",
"mu-thank-loading": "Thanking...",
"mu-thank-successful": "You thanked $1.",
"mu-thank-failed": "Failed to thank $1.",
"mu-http-error":"HTTP error: "
},
"bn": {
"mu-success": "সফল",
"mu-fail": "ব্যর্থ হয়েছে",
"mu-loading": "লোড করা হচ্ছে...",
"editsummary-ad": "([[m:User:FR30799386/undo|mobileUndo]])",
"mu-undo-successful": "পূর্বাবস্থায় ফেরত যাওয়া সফল হয়েছে.... পুনঃলোড করা হচ্ছে",
"mu-empty-reponse-from-server": "সার্ভার থেকে একটি খালি প্রতিক্রিয়া পাওয়া গেছে।",
"mu-edit-summary-prompt": "আপনার সম্পাদনা সারাংশে একটি কারণ যুক্ত করুন !",
"mu-edit-summary-prompt-placeholder": "কারণ...",
"mu-thank-success": "ধন্যবাদ দিয়েছেন",
"mu-thank-confirm": "প্রকাশ্য ধন্যবাদ জানাবেন?",
"mu-thank-loading": "ধন্যবাদ জানানো হচ্ছে...",
"mu-thank-successful": "আপনি $1 কে ধন্যবাদ জানিয়েছেন।",
"mu-thank-failed": "$1 কে ধন্যবাদ জানানো ব্যর্থ হয়েছে।",
"mu-http-error":"HTTP ত্রুটি: "
}
};
if(undefined === i18n[i18n_lang]){
i18n_lang = 'en';
}
if (mw.config.get('wgCanonicalSpecialPageName') === 'MobileDiff') {
mw.util.addCSS('#mw-mf-userinfo .mobileUndo-ui .mw-ui-icon.mw-ui-icon-before:before{display:none;}\n#mobileUndo > a > span.oo-ui-iconElement-icon.oo-ui-icon-editUndo.oo-ui-image-invert{display:inline-block; position:initial;}\n#mobileUndo > a{padding:0.57142857em 0.9375em;}'+
'#mw-mf-userinfo > div > div.mobileUndo-ui > a > div{line-height:normal;}');
if (mw.config.get('wgVisualEditor').pageLanguageDir === 'ltr') {
$('#mw-mf-userinfo .post-content').append($('<div>').attr('class', 'mobileUndo-ui').css({
'display': 'inline-block',
'float': 'right'
}));
} else {
$('#mw-mf-userinfo .post-content').append($('<div>').attr('class', 'mobileUndo-ui').css({
'display': 'inline-block',
'float': 'left'
}));
}
$('.mobileUndo-ui').append($('.mw-mf-action-button').remove().css({
'clear': 'none'
}));
if (!$('.warningbox').length && mw.config.get('wgRelevantPageIsProbablyEditable')) {
mobileUndo = new OO.ui.ButtonWid