User:CFA/Scripts/fastsummary.js

// // From User:TheJJJunk/FastSummary.js 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   = " (FS)');"; //init UI   let link1 = $("", {        "href":linkStartText + "Maintenance: Added missing notelist" + linkEndText,         "style":btnStyle    }); link1.text("NOTEL"); //init UI   let link2 = $("", {        "href":linkStartText + "Maintenance: Fixed " + linkEndText,         "style":btnStyle    }); link2.text("URLERR"); //init UI   let link3 = $("", {        "href":linkStartText + "Categorization: :" + linkEndText,         "style":btnStyle    }); link3.text("STUB"); //init UI   let link4 = $("", {        "href":linkStartText + "CS1 error: " + linkEndText,         "style":btnStyle    }); link4.text("CS1:ED"); //init UI   let link5 = $("", {        "href":linkStartText + "CS1 error: " + linkEndText,         "style":btnStyle    }); link5.text("CS1:PGE"); //init UI   let link6 = $("", {        "href":linkStartText + "CS1 error: " + linkEndText,         "style":btnStyle    }); link6.text("CS1:INVAL"); //init UI   let link7 = $("", {        "href":linkStartText + "CS1 error: " + linkEndText,         "style":btnStyle    }); link7.text("CS1:NME"); //init UI   let link8 = $("", {        "href":linkStartText + "CS1 error: [[Category:CS1 errors: redundant parameter|Redundant parameter]" + linkEndText,         "style":btnStyle    });    link8.text("CS1:REDUN");    //init UI    let link9 = $("", {        "href":linkStartText + "CS1 error: " + linkEndText,         "style":btnStyle    });    link9.text("CS1:ARCH");    //init UI    let link10 = $("", {        "href":linkStartText + "CS1 error: " + linkEndText,         "style":btnStyle    });    link10.text("CS1:DTE");    //init UI    let link11 = $("", {        "href":linkStartText + "CS1 error: " + linkEndText,         "style":btnStyle    });    link11.text("CS1:INVIS");    //init UI    let link12 = $("", {        "href":linkStartText + "CS1 error: " + linkEndText,         "style":btnStyle    });    link12.text("CS1:MRKP");    //init UI    let link13 = $("", {        "href":linkStartText + "CS1 error: " + linkEndText,         "style":btnStyle    });    link13.text("CS1:UNKN");    //init UI    let link14 = $("", {        "href":linkStartText + "Biography: Added,  parameters" + linkEndText,         "style":btnStyle    });    link14.text("BIO_LL");    //init UI    let link15 = $("", {        "href":linkStartText + "Biography: Added  parameter" + linkEndText,         "style":btnStyle    });    link15.text("BIO_LIV");        //init UI    let link16 = $("", {        "href":linkStartText + "Biography: Added  parameter" + linkEndText,         "style":btnStyle    });    link16.text("BIO_LIST");        //init UI    let link17 = $("<a>", {        "href":linkStartText + "Maintenance: Added missing [[Template:Reflist|reflist]]" + linkEndText,         "style":btnStyle    });    link17.text("REFL");    let link18 = $("<a>", {        "href":linkStartText + "Maintenance: " + linkEndText,         "style":btnStyle    });    link18.text("BARE-NOV21");    $('#wpSummaryLabel').prepend(link18).prepend(" ").prepend(link17).prepend(" ").prepend(link16).prepend(" ").prepend(link15).prepend(" ").prepend(link14).prepend(" ").prepend(link13).prepend(" ").prepend(link12).prepend(" ").prepend(link11).prepend(" ").prepend(link10).prepend(" ").prepend(link9).prepend(" ").prepend(link8).prepend(" ").prepend(link7).prepend(" ").prepend(link6).prepend(" ").prepend(link5).prepend(" ").prepend(link4).prepend(" ").prepend(link3).prepend(" ").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 = $(' ', {'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 = $(' ', {'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; } //