User:Rurin/timeless.js: Difference between revisions
From Tardis Wiki, the free Doctor Who reference
(Created page with "→############################################: →### ProfileTags ###: →### User:RurinGas ###: →############################################: $(function ($) { 'use strict'; var conf = mw.config.get([ 'wgTitle' ]); var params = { action: 'raw', title: 'MediaWiki:ProfileTags' }; $.get(mw.util.wikiScript(), params, function (data) { if (!data.length) {...") |
mNo edit summary |
||
Line 35: | Line 35: | ||
var tardisProfileTag = document.createElement("p"); | var tardisProfileTag = document.createElement("p"); | ||
tardisProfileTag.id = 'tardisProfileTag'; | tardisProfileTag.id = 'tardisProfileTag'; | ||
var textToInsert = ' | var textToInsert = profileTags.join(', '); | ||
tardisProfileTag.innerHTML = textToInsert; | tardisProfileTag.innerHTML = textToInsert; | ||
$('.mw-page-title-main').append(tardisProfileTag); | $('.mw-page-title-main').append(tardisProfileTag); | ||
} | } | ||
}); | }); |
Revision as of 11:23, 26 February 2024
/* ############################################ */
/* ### ProfileTags ### */
/* ### User:RurinGas ### */
/* ############################################ */
$(function ($) {
'use strict';
var conf = mw.config.get([
'wgTitle'
]);
var params = {
action: 'raw',
title: 'MediaWiki:ProfileTags'
};
$.get(mw.util.wikiScript(), params, function (data) {
if (!data.length) {
return;
}
var escapeRegExp = mw.util.escapeRegExp || (mw.RegExp || {}).escape,
user = escapeRegExp(conf.wgTitle),
re = new RegExp('(?:^|\\n)\\s*' + user + '\\s*\\|\\s*(.*?)\\s*(?:\\n|$)'),
match = re.exec(data);
if (match !== null) {
var profileTags = match[1].split(/\s*,\s*/);
insertTextString(profileTags);
}
});
function insertTextString(profileTags) {
var tardisProfileTag = document.createElement("p");
tardisProfileTag.id = 'tardisProfileTag';
var textToInsert = profileTags.join(', ');
tardisProfileTag.innerHTML = textToInsert;
$('.mw-page-title-main').append(tardisProfileTag);
}
});