User:Gryllida/js/admin-dash-0.1.js

From Wikinews, the free news source you can write!
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); IE: hold Ctrl while clicking Refresh, or press Ctrl-F5; Konqueror: simply click the Reload button, or press F5; Opera users may need to completely clear their cache in Tools→Preferences. — More skins

/*

Derived work from [[User:Acagastya/admin-dash.js]]
Changes: made page title a first argument for template

Uses: http://en.wikinews.org/wiki/Template:Gryllida/Testing whose contents is

"Hello.

First argument: {{{1}}}

Links: [[Special:WhatLinksHere/{{{1}}}]]

Bye..."

Version : 0.1
Date: 2018-06-26

Authors:

* [[User:Acagastya]]
* [[User:Gryllida]] svetlana@members.fsf.org

Licence:

* Creative Commons Attribution 2.5 License (see footer at the bottom of this page)

*/

mw.loader.using(['mediawiki.api'], function () {
	"use strict";
	// == Create an API object ==
	var api = new mw.Api();
	// == Query the wiki API to get HTML of {{Special:MyPage/MyNotice}}==
	var fillMyDiv = function(){
		var mypagetitle = wgCanonicalNamespace+":"+wgTitle;
		api.get( { 
	    		action: 'parse',
	    		disableeditsection: 'true',
	    		text: '{{Gryllida/Testing|'+mypagetitle+'}}'
		} ).done( function ( data ) {
			var $mydiv = $('#gryllida-rcattheend-div');
			$mydiv.empty();
			$mydiv.append($(data.parse.text['*']));
	    });
	};
	// == Add the HTML at the end of current page ==
	var $mydiv = $('<div></div>',{
		id: 'gryllida-rcattheend-div',
		style:"background-color: beige !important; border: 5px red dashed; margin-left: 176px; padding: 20px; right: 1em"
	});
	$mydiv.click(function(){fillMyDiv();});
	//$mydiv.mouseenter(function(){
	//	fillMyDiv();
	//});
	$('body').append($mydiv);
	fillMyDiv();
});