User:Super Miron/QuickLicense.js

// // BEGIN MW GADGET //Modified version of https://github.com/sactage/wikia-js-snippets/blob/master/QuickLicence.js by User:Super Miron /* * QLicense.js, [originally] by User:Cakemix, * then decoded, formatted, and shortened by Monchoman45, * and then further modified by Sactage. */

function QLicenseUI { var options = { '': 'Public domain', '': 'CP image', '': 'Custom image' };	var optstr = ''; for ( i in options ) { if ( options.hasOwnProperty( i ) ) { optstr += '' + options[i] + ' '; }	}

var html = '' + optstr + ' Add license'; if($('#LicensedFile').length || $('#Copyright').length) { html += ' This file is licensed. ';	} else { html += ' This file is not licensed. ';	}	$('#filetoc').append(html); $('#aSubmit').click( function(event) {		this.innerHTML = '';		$.post("/api.php", {action: "edit", title: mw.config.get("wgPageName"), token: mw.user.tokens.values.editToken, bot: true, minor: true, appendtext: $("#QLicenseSelect").val, summary: "adding license"}, function (result) { window.location = wgServer + '/index.php?title=' + mw.config.get("wgPageName") + '&action=purge'; });	}); }

if (wgCanonicalNamespace == 'File') { addOnloadHook(QLicenseUI); } // END MW GADGET //