User:Cakemix/Qlicense.js

$(document).ready(function { // Used parts of Quarenon/gemwupdate.js if (document.location.href.indexOf("File:") != -1) { var title = wgPageName;	function callAPI(data, method, callback) {		data['format'] = 'json';		$.ajax({ data: data, dataType: 'json', url: wgScriptPath + '/api.php', type: method, success: function(response) { if (response.error) { showError('API error: ' + response.error.info); } else { callback(response); }			},			error: function(xhr, error) { showError('AJAX error: ' + error); }, timeout: 10000 // msec });	} function cake(R) { var b = document.getElementById("aabbcc").value;		callAPI({ 'action': 'query', 'prop': 'info|revisions', 'intoken': 'edit', 'titles': title, 'rvprop': 'content', 'rvlimit': '1' }, 'GET', function(response) { var pages = response.query.pages; var page = null; for (var i in pages) { page = pages[i]; }			var a = page.revisions[0]['*']; a = a.replace("", "").replace("", "").replace("", ""); a += "\n"+b; callAPI({				'minor': 'yes',				'summary': 'Added licence with Quick license.',				'action': 'edit',				'title': title,				'basetimestamp': page.revisions[0].timestamp,				'startimestamp': page.starttimestamp,				'token': page.edittoken,				'text': a			}, 'POST', function(response) {				if (response.edit.result == 'Success') { document.location.replace(wgScript + '?title=' + encodeURIComponent(wgPageName) + '&action=purge');				} else {					alert('An error occurred while submitting the edit.');				}			}); });		return false;	} var h=""; teabag[""] = "Public domain (PMG)"; teabag[""] = "Game Screenshot"; teabag[""] = "Fair use"; for (i in teabag) {   h+=""+teabag[i]+" "; };                var $p = $('#filetoc'); var $y = $('#toolbar');		var $form = $(' '); 		var $form1 = $(' ');                    $form.submit(cake('0'));                $form1.submit(cake('1'));		var $p1 = '';		var $p2 = $('');

$form1.submit(cake('1')); $p2.append(""+h+" "); $p2.append($(' ').css({'margin': '0 1em 0 1em'}).attr({'id': 'aSubmit', 'type': 'submit'}).val('Add license')); $p1.append($(' ').css({'margin': '0 1em 0 1em'}).attr({'id': 'aSubmit', 'type': 'submit', 'OnClick':)}).val('Replace license'));		$form1.append($p1);		$form.append($p2);               $p.append($form);                $p.append($form1); $y.prepend(""+u+" ");

} });