User:Cpl.Bohater/wikia.js

function FileTemplateAdder { if (buttonLayout == false) { var tempOptions = { '': 'Screenshot' };                   var tempOptStr = ''; for(i in tempOptions) { tempOptStr += '' + tempOptions[i] + ' '; }                   var html = '' + tempOptStr + ' Add template'; $('#filetoc').append(html); $('#aSubmit').click(function(event) {                           this.innerHTML = '';                            $.getJSON("/api.php", {action: "query", prop: "info", titles: wgPageName, intoken: "edit", format: "json", indexpageids: 1}, function(json) { var pageIdentification = json.query.pageids[0]; var pageToken = json.query.pages[pageIdentification].edittoken; $.post("/api.php", {action: "edit", title: wgPageName, token: pageToken, prependtext: $('#FileTemplateAdder').val + "\n"}, function (result) {$(".TemplateAdder").remove;}); });                   });            }            if (buttonLayout) { var html = 'Screenshot '; $('#filetoc').append(html); $('#submitOne').click(function(event) {                           this.innerHTML = '';                            $.getJSON("/api.php", {action: "query", prop: "info", titles: wgPageName, intoken: "edit", format: "json", indexpageids: 1}, function(json) { var pageIdentification = json.query.pageids[0]; var pageToken = json.query.pages[pageIdentification].edittoken; $.post("/api.php", {action: "edit", title: wgPageName, token: pageToken, prependtext: $('#submitOne').val + "\n"}, function (result) {$(".TemplateAdder").remove;}); });                   });            }    }    if (wgCanonicalNamespace == 'File') { addOnloadHook(FileTemplateAdder); }