User:Mxn/vector.js
Appearance
< User:Mxn
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin is at User:Mxn/vector.css. |
// importScript("User:ProveIt GT/ProveIt.js");
// [[User:ProveIt GT/ProveIt.js]]
//importScriptURI("http://toolserver.org/~magnus/wysiwtf/wysiwtf.js");
/**
* MediaWiki:Gadget-codeeditor.js
* Stub to load [[Extension:CodeEditor]] and Ace syntax-highlighting editor as a gadget.
*
* Requires enhanced editing toolbar (WikiEditor extension); integrates with toolbar.
*
* Gadget stub CC-BY-SA 2
* (c) 2011 Brion Vibber <brion @ pobox.com>
*
* Extension:CodeEditor JS bits are GPLv2 -- http://www.mediawiki.org/wiki/Extension:CodeEditor
*
* Syntax highlighting, auto-indenting code editor widget for on-wiki JS and CSS pages.
* Uses embedded Ajax.org Cloud9 Editor: http://ace.ajax.org/
* MPL/LGPL/GPL
*/
(function($) {
// @fixme need an SSL alternative
mw.config.set('wgCodeEditorAssetsPath', '//toolserver.org/~brion/extensions');
var moduleBase = mw.config.get('wgCodeEditorAssetsPath') + '/CodeEditor/modules',
$box = $('#wpTextbox1'),
matches = /\.(js|css)$/.exec(mw.config.get('wgTitle'));
if ($box.length && matches && (wgNamespaceNumber === 2 /* User: */ || wgNamespaceNumber === 8 /* MediaWiki: */)) {
$(function() {
var modules = [
moduleBase + '/ace/ace.js',
moduleBase + '/ace/mode-javascript.js',
moduleBase + '/ace/mode-css.js',
moduleBase + '/jquery.codeEditor.js',
moduleBase + '/ext.codeEditor.js'
];
var i = 0;
// @fixme loading serially is kinda lame, but it works for now
var ping = function() {
if ( i < modules.length ) {
var url = modules[i];
$.getScript(url, function() {
i++;
ping();
});
}
};
ping();
});
}
})(jQuery);
if (mw.config.get("wgAction") == "view" && mw.config.get("wgNamespaceNumber") == 0) {
mw.loader.using("mediawiki.api", function () {
var api = new mw.Api();
/**
* Retrieves the rendered HTML content of an alphabetically adjacent
* article and passes the content to a callback function.
*
* @param forward {boolean} True to get the next page; false to get
* the previous one.
* @param ok {function} A callback function that takes two
* arguments: title, html.
*/
function fetchAdjacentArticle(forward, ok) {
api.get({
list: "allpages",
apfrom: mw.config.get("wgPageName"),
apnamespace: 0,
apfilterredir: "nonredirects",
aplimit: 2,
apdir: forward ? "ascending" : "descending",
}, {
ok: function (data) {
var pages = data.query && data.query.allpages;
var page = pages && data.query.allpages[1];
$.get(mw.util.wikiScript("index"), {
title: page.title,
action: "render",
}, function (html) {
if (ok) ok(page.title, html);
}, "html");
},
});
}
/**
* Hides content features that facilitate user contributions, multimedia
* experiences, non-linear navigation, or fact-checking.
*/
function hideNewFangledFeatures() {
if (!hideNewFangledFeatures.stylesAdded) {
hideNewFangledFeatures.stylesAdded = true;
// Links
mw.util.addCSS("#bodyContent a {" +
"background-color: inherit; cursor: inherit;" +
"color: inherit; text-decoration: inherit;" +
"}");
}
// Links
$("#bodyContent a").unbind("click").click(function (evt) {
evt.preventDefault();
evt.stopPropagation();
});
// Software-powered features
$("#mw-articlefeeddback, #catlinks, .editsection, .magnify").hide();
// Cite extension
$(".reference, .reflist").hide();
$(".reflist").prev().filter("h2:contains('eference')").hide();
// Template-powered features
$("#coordinates, img[alt='play'], .navbox, .stub").hide();
// WikiMiniAtlas
wma_settings = {enabled: false};
}
/**
* Inserts the contents of the previous article above the original one.
*/
function insertPreviousArticle(title, html) {
// Stuff the main article’s title inside its body element.
$("#bodyContent").prepend($("#firstHeading"));
$("#firstHeading").css({
"font-size": 1.25 * parseFloat($("#firstHeading").css("font-size")),
});
$("#bodyContent").prepend("<div class='visualClear'></div>")
.prepend($(html).wrap("<div id='prevBodyContent'></div>"))
.prepend("<h1 id='prevFirstHeading' class='firstHeading'>" +
"<span dir='auto'>" + title + "</span>" +
"</h1>");
hideNewFangledFeatures();
};
/**
* Inserts the contents of the next article above the original one.
*/
function insertNextArticle(title, html) {
$("#bodyContent").append("<h1 id='nextFirstHeading' class='firstHeading'>" +
"<span dir='auto'>" + title + "</span>" +
"</h1>")
.append($(html).wrap("<div id='nextBodyContent'></div>"))
.append("<div class='visualClear'></div>");
hideNewFangledFeatures();
};
$(function () {
fetchAdjacentArticle(false, insertPreviousArticle);
fetchAdjacentArticle(true, insertNextArticle);
});
});
}