User:Technical 13/SandBox/timestampLinks.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. |
This user script seems to have a documentation page at User:Technical 13/SandBox/timestampLinks. |
/* <nowiki>
*
*/
/* Disable these for now... Will need to think more about them... Need to get class work done for now though...
function postNotes(target, user, summary, content){
}
*/
$('span.localcomments').each(function(){
var timestamp = $(this).attr('timestamp');
$(this).attr('id', timestamp);
var revisionInfoQ = {
action: 'query',
prop: 'revisions',
format: 'json',
rvlimit: 1,
rvprop: 'ids|user|comment',
pageids: mw.config.get('wgArticleId'),
rvstartid: timestamp,
continue: ""
};
$.get(mw.config.get( 'wgScriptPath' )+"/api.php", revisionInfoQ, function(revisionInfoR){
console.log('%O', revisionInfoR);
var revisionUser = $(revisionInfoR).find('user').text();
var revisionSection = $(revisionInfoR).find('comment').text();
revisionSection = revisionSection.match(/\/\* *(.*?) *\*\//);
var revId = $(revisionInfoR).find('revid').text();
console.log('{user: "%s", sectionTitle: "%s", revid: %d}', revisionUser, revisionSection, revId);
var tslbSep = ' | ';
var tslbLB = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?title=";
var timestamplinkbar = '<small class="timestampLinks">( ';
timestamplinkbar += '<a href="' + tslbLB + 'User:' + revisionUser + '" title="User:' + revisionUser + '">u</a>';
timestamplinkbar += tslbSep;
timestamplinkbar += '<a href="' + tslbLB + 'User_talk:' + revisionUser + '" title="User_talk:' + revisionUser + '">t</a>';
timestamplinkbar += tslbSep;
timestamplinkbar += '<a href="#TalkBack" onClick="alert(\'This will eventually post a Talkback\')" title="Send {{Talkback}} to this section">TB</a>';
timestamplinkbar += tslbSep;
timestamplinkbar += '<a href="#Trout" onClick="alert(\'This will eventually trout the user for the revision.\')" title="Trout ' + revisionUser + '"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/16/Rainbow_trout_transparent.png/15px-Rainbow_trout_transparent.png" title="Trout!" /></a>';
timestamplinkbar += tslbSep;
timestamplinkbar += '<a href="' + tslbLB + 'Special:Contributions/' + revisionUser + '" title="Contributions">c</a>';
timestamplinkbar += ' )</small>';
$('span#' + timestamp).prepend(timestamplinkbar);
});
});
//</nowiki>