User:DodoMan/qualitybutton.js

From Test Wiki
Revision as of 13:04, 1 April 2024 by Justarandomamerican (talk | contribs) (Justarandomamerican moved page User:DodoMan/qualitybutton.js to User:DodoMan~usurped/qualitybutton.js without leaving a redirect: Automatically moved page while renaming the user "DodoMan" to "DodoMan~usurped")
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
var q0  = "//upload.wikimedia.org/wikipedia/commons/8/8f/00%25.png";
var q25 = "//upload.wikimedia.org/wikipedia/commons/5/5b/25%25.png";
var q50 = "//upload.wikimedia.org/wikipedia/commons/3/3a/50%25.png";
var q75 = "//upload.wikimedia.org/wikipedia/commons/c/cd/75%25.png";
var q100 = "//upload.wikimedia.org/wikipedia/commons/6/64/100%25.png";
var qvalid = "//upload.wikimedia.org/wikipedia/commons/thumb/7/79/Mozilla.svg/10px-Mozilla.svg.png";

window.addQuality = function (form,value){

	var text="";
	switch(value){
		case "25%": text = "Texte incomplet"; break;
		case "50%": text = "Texte non formaté"; break;
		case "75%": text = "Complet et formaté"; break;
		case "100%": text = "Relu et corrigé"; break;
		case "Textes validés": text = "Validé"; break;
		case "mode_page|": text = "Texte en mode page"; break;
	} 

	form.elements["wpSummary"].value="/* "+text+" */";
	s = form.elements["wpTextbox1"].value;
	s = s.replace(/\{\{TextQuality\|([^}]*?)\}\}\n/gi,"");
	s = s.replace(/\{\{TextQuality\|([^}]*?)\}\}/gi,"");
	form.elements["wpTextbox1"].value="{"+"{TextQuality|"+value+"}"+"}\n"+s;
};

function addQualityButtons(){
	if( mw.config.get('wgNamespaceNumber') !== 0 ) return;
	var ig  = document.getElementsByClassName("editCheckboxes")[0]; 
	if(!ig) return;

	var f = document.createElement("span");
	f.innerHTML = ' <input type="radio" name="quality" value="25%" onclick="window.addQuality(this.form,this.value)"><img src = "'+q25+'">'
+ '<input type="radio" name="quality" value="50%" onclick="window.addQuality(this.form,this.value)"><img src = "'+q50+'">'
+ '<input type="radio" name="quality" value="75%" onclick="window.addQuality(this.form,this.value)"><img src = "'+q75+'">'
+ '<input type="radio" name="quality" value="100%" onclick="window.addQuality(this.form,this.value)"><img src = "'+q100+'">'
+ '<input type="radio" name="quality" value="Textes validés" onclick="window.addQuality(this.form,this.value)"><img src = "'+qvalid+'">'
//+'<input type="radio" name="quality" value="mode_page|" onclick="window.addQuality(this.form,this.value)"><img src = "//upload.wikimedia.org/wikipedia/commons/thumb/9/92/Open_book_nae_02.svg/20px-Open_book_nae_02.svg.png">'
+ ' Niveau d\’avancement du texte';
	ig.append(f);
}

/****
Seulement en mode édition
*****/
if ( !mw.user.isAnon() ) {
	if (mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') {
		$(addQualityButtons);
	}
}