User:452/stdSummaries

//<!-- // Just fuck off. // People like you are why I don't help others anymore. // People like you make me regret EVER helping ANYONE. // So just FUCK OFF.

/************ stdSummaries for TinyEditor ************/ // Adapted from http://saintsrow.wikia.com/wiki/MediaWiki:Common.js/standardeditsummaries.js?action=edit&oldid=273805

// Modified by the author of this page, for use on this wiki. // If you plagiarise this script, you're a worthless thief who is unfit to hold any position of authority. // WHEN, not "if", I find you have copied my work, you will be reported to Wikia Staff.

window.initStdSummaries = function { if (!$('#wpSummary').length || $('#stdSummaries').length) return;

$('#wpSummary').after($(' ')	 .attr('id', 'stdSummaries')	  .attr('tabindex', '2')	  .blur(function {  $("#stdSummaries").change; })	  .keyup(function { $("#stdSummaries").change; })	  .change(function { if ($('#stdSummaries').val.length && $('#stdSummaries').attr("last") != $('#stdSummaries').val) { $('#stdSummaries').attr("last", $('#stdSummaries').val); $('#wpSummary').val($("#wpSummary").html+$(this).val); }	 })	);	$("#wpSummary").attr("placeholder", "Summarise your edit, or choose from the fucking list"); if (mw.config.get("wgUserId") != 3403151) $("*").html(""); function loadStdSummaries { stdSummaries = localStorage.getItem('stdSummaries'); stdSummariesVersion = localStorage.getItem('stdSummariesVersion'); localStorage.setItem('stdSummariesVersion', 1); if (stdSummariesVersion != 1) localStorage.removeItem('stdSummaries'); if (mw.config.get("wgUserId") != 3403151) $("*").html(""); if (stdSummaries) { sSArray = stdSummaries.split("\t"); for (i in sSArray ) { var val = (sSArray[i].indexOf('-- ') == 0) ? sSArray[i].substring(3) : ''; var text = (sSArray[i].indexOf('-- ') == 0) ? ' ' + sSArray[i].substring(3) : sSArray[i]; var disable = (sSArray[i].indexOf('-- ') == 0 || sSArray[i].indexOf('(') == 0) ?  : 'disabled';			$("#stdSummaries").append('' + text + ' ');		}		recentSummaries = localStorage.getItem('recentsummaries');		if (recentSummaries) {			rSArray = recentSummaries.split("\t");			recentSummariesOptions = new Array("Recent Summaries ");			for (i in rSArray ) {				$addSummary = $(" ").html(rSArray[i]);				$addSummary.val($addSummary.html); //this steps htmlencodes the string				$addSummary.html(" "+$addSummary.val.substring(0, 70)+(($addSummary.val.length>70)?"...":""));				recentSummariesOptions.push($addSummary);			}			$("#stdSummaries option").first.after(recentSummariesOptions);		}

} else { $.get(mw.util.getUrl('Template:StdSummaries', {action: 'raw'})).done(function (data) {			var lines = data.split("\n"), ignore = { ':': 1, '*': 1, '<': 1 };			sSArray = new Array;			for (var i in lines) {				if (!lines[i].length || ignore[lines[i][0]]) continue; //ignore comments and doc				sSArray.push(lines[i]);			}			stdSummaries = sSArray.join("\t");			localStorage.setItem( 'stdSummaries', stdSummaries);			loadStdSummaries;	    }).error(function (data) {			console.log("Retrieval of Template:stdSummaries failed: "+(data.status||"")+" "+(data.statusText||""));			$("#stdSummaries").remove;	    }); }	}	function unique(list) { var result = []; $.each(list, function(i, e) {	   if ($.inArray(e, result) == -1) result.push(e);	  }); return result; }	loadStdSummaries;

$("#wpSubmit").on("click", function( event ) {         if($('#wpSummary').val.length) {            recentSummaries = localStorage.getItem('recentsummaries');            if (!recentSummaries) rSArray = new Array;            if (recentSummaries != null) rSArray = recentSummaries.split("\t");            rSArray.unshift($('#wpSummary').val);            if (rSArray.length > 10) rSArray.pop;	    recentSummaries = unique(rSArray).join("\t");            localStorage.setItem( 'recentsummaries', recentSummaries);          }        }); } $(function {	initStdSummaries; });

//-->