User:Xytl/wikia.js

$( function($, mw) {   'use strict';    var conf = mw.config.get([ 'wgCategories', 'wgPageName', 'wgNamespaceNumber', 'wgUserGroups', 'wgUserName' ]);   function loadTools {        // TODO - where on earth to put this...    }    // Creates a forum thread notifying wiki users that an RfR has been created    function createNotificationThread {        var titleData = conf.wgPageName.match(/Request_for_(.*)\/(.*)/);        var data = {            'body': 'A new ' + titleData[1] + ' RfR has been created by ' + titleData[2] + '. You can vote by going to to this page, pressing the "vote" button and entering the required information.',            'messagetitle': 'New RfR',            'pagetitle': 'Testing',            'pagenamespace': 2000,            'token': mw.user.tokens.get("editToken")        };        $.nirvana.postJson( 'WallExternal', 'postNewMessage', data, function(data) { alert("Success"); }       );    }    // Allows an administrator to strike votes that break the rules (?)    function strikeVotes {        // TODO    }    // For Mooziq    function createArchiveTemplate {        // TODO    }    function init {        if (conf.wgCategories.includes("RfR") && conf.wgNamespaceNumber == 4 && $.inArray("sysop", conf.wgUserGroups)) {            mw.loader.using(['wikia.nirvana'], loadTools);        }    }    $(init); }(jQuery, mediaWiki));

/* $.showCustomModal('Submit Council request', 'Fill in the following details to submit a council request: Involved Parties Statement   Please add all users involved (on both sides of the issue, excluding yourself) to the "Involved Parties" box, seperated by commas, and your own statement of the issue in the "Statement" box.', {        id: 'council-form',        width: 650,        buttons: [{            message: 'Submit',            defaultButton: true,            handler: function  {                submitForm;            }        }, {            message: 'Cancel',            handler: function  {                $('#council-form').closeModal;            }        }] });

$(function {   api = new mw.Api;	$('.userimage').each(function  { var currentelement = $(this).attr('id'); var $self = $(this); $.ajax({			url: 'http://rinzler135.wikia.com/api/v1/User/Details',			data: 'ids='+currentelement,			dataType: 'json',		}) .done(function(data) {			var responseurl = data.items[0].avatar;			var string = responseurl.split("/")[3];			var reconstructed = "";			$self.html(reconstructed);		}); }); });

$( ".requestur" ).click(function {   var right = $(this).attr('id');    $.ajax({ url: mw.util.wikiScript( 'api' ), data: { format: 'json', action: 'edit', title: "Project:Request for "+right+"/"+mw.config.get("wgUserName"), summary: "Creating new RfR", createonly: true, text: "Very distinctive text", token: mw.user.tokens.get('editToken') },       dataType: 'json', type: 'POST', success: function( data ) { if ( data && data.edit && data.edit.result == 'Success' ) { window.location.reload; // reload page if edit was successful alert("Your RfR page had been created."); } else if ( data && data.error ) { alert( 'Error: API returned error code "' + data.error.code + '": ' + data.error.info ); } else { alert( 'Error: Unknown result from API.' ); }       },        error: function( xhr ) { alert( 'Error: Request failed.' ); }   }); }); /* mediaWiki.loader.using('mediawiki.util', function { "use strict"; jQuery(function($) { var $tabs = $('#WikiaUserPagesHeader ul.tabs'); if (!$tabs.length) return; var newTabs = { 'Sandbox': '/Sandbox', };  var name = $('#UserProfileMasthead .masthead-info hgroup > h1'); if (!name.length) return; name = name.text; var tabs = document.createDocumentFragment, li, a;  for (var tab in newTabs) { li = document.createElement('li'); a = document.createElement('a'); a.title = 'User:' + name + newTabs[tab]; a.href = mw.util.wikiGetlink(a.title); a.appendChild(document.createTextNode(tab)); li.appendChild(a); tabs.appendChild(li); }  $tabs.append(tabs); }); });

if (mw.config.get("wgPageName") == "Special:Test") { document.title = "Special: Test"; $('#mw-content-text p:lt(2)').remove; content; }

function content { $('#mw-content-text').append(' A test page '); }

( function ($, mw) {   'use strict';    function test {        var testString = "";        console.log(testString);    }    mw.loader.using(['mediawiki.util'], test); }(jQuery, mediaWiki));