User:TheJJJunk/FastSummary.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. |
This user script seems to have a documentation page at User:TheJJJunk/FastSummary. |
// <nowiki>
// Everything is encapsulated in a private namespace object---``FastSummary'':
var FastSummary = FastSummary || {};
$(document).ready(function()
{
//initialize Constants
FastSummary.Constants = getFastSummaryConstants();
//only execute on the edit page
if (!FastSummary.Constants.IS_EDIT_PAGE || FastSummary.Constants.IS_JS_PAGE || FastSummary.Constants.ARTICLE_TEXT_BOX_ELEMENT == null)
return;
let btnStyle = "box-shadow:inset 0px 1px 0px 0px #ffffff;background:linear-gradient(to bottom, #f9f9f9 5%, #e9e9e9 100%);background-color:#f9f9f9;border-radius:6px;border:1px solid #ccc;display:inline-block;cursor:pointer;color:#666666;font-family:Arial;font-size:12px;font-weight:bold;padding:3px 6px;text-decoration:none;text-shadow:0px 1px 0px #ffffff;margin-bottom:5px;";
let linkStartText = "javascript:FastSummary.addToSummary('";
let linkEndText = " ([[User:TheJJJunk/FastSummary|FS]])');";
//init UI
let link1 = $("<a>", {
"href":linkStartText + "Added missing [[Template:Notelist|notelist]]" + linkEndText,
"style":btnStyle
});
link1.text("Added missing notelist");
//init UI
let link2 = $("<a>", {
"href":linkStartText + "Fixed [[Category:Pages with URL errors|URL error]]" + linkEndText,
"style":btnStyle
});
link2.text("Fixed URL error");
$('#wpSummaryLabel').prepend(link2).prepend(" ").prepend(link1);
});
FastSummary.addToSummary = function(summary) {
var wpSummary = document.getElementById('wpSummary');
if (wpSummary.value !== '') {
summary = wpSummary.value + '; ' + summary;
}
if ((wpSummary.maxLength > 0) && (summary.length > wpSummary.maxLength)) {
alert('Error: If the proposed text is added to the summary, its length will exceed the character limit.');
return;
}
wpSummary.value = summary;
}
function getFastSummaryConstants()
{
var ARA_Constants = ARA_Constants || {};
//article text box element
ARA_Constants.ARTICLE_TEXT_BOX_ELEMENT = $("#wpTextbox1");
//are we on an Edit page?
ARA_Constants.IS_EDIT_PAGE = mw.config.get('wgAction') === 'edit' || mw.config.get('wgAction') === 'submit';
//are we on a JS page?
ARA_Constants.IS_JS_PAGE = mw.config.get('wgRelevantPageName').endsWith('.js');
//the ARA Suggestion box, which appears above the editing section
ARA_Constants.SUGGESTION_BOX_DIV = $('<div>', {'id':'suggestionBox.ARA', 'style':'border:dashed #ccc 1px;color:#888;'});
//the Add to Summary box, which appears near the edit summary
ARA_Constants.ADD_TO_SUMMARY_DIV = $('<div>', {'id':'addToSummaryBox.ARA', 'style':'border:dashed #ccc 1px;color:#888;display:none;'});
ARA_Constants.DEFAULT_MAX_SUGGESTIONS = 8;
ARA_Constants.maxSuggestions = ARA_Constants.DEFAULT_MAX_SUGGESTIONS;
ARA_Constants.suggestions; // : Suggestion[]
ARA_Constants.appliedSuggestions = {}; // : Map<String, int>
ARA_Constants.scannedText = null; // remember what we scan, to check if it is
// still the same when we try to fix it
ARA_Constants.BIG_THRESHOLD = 100 * 1024;
ARA_Constants.isBigScanConfirmed = false; // is the warning about a big article confirmed
ARA_Constants.isTalkPageScanConfirmed = false;
ARA_Constants.scanTimeoutId = null; // a timeout is set after a keystroke and before
// a scan, this variable tracks its id
return ARA_Constants;
}
// </nowiki>