User:Magnus Manske/sifter.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:Magnus Manske/sifter. |
/*
To install:
* Get account on en.wikipedia.org
* Go to http://en.wikipedia.org/wiki/Special:Mypage/vector.js
* Add the line importScript('User:Magnus Manske/sifter.js');
to the page
* Go to (for example) http://en.wikipedia.org/wiki/Gulf_Snapping_Turtle
* Behold the "Reviews" tab next to "Read" (on the right; you may have
to force-reload the page once to activate the JavaScript)
* Click on the "Reviews" tab to get a list of all reviewed revisions,
and links to the partner (here: EOL) page, as well as the reviewer
page
Known issues: See http://en.wikipedia.org/wiki/User:Magnus Manske/sifter
*/
var sifter_html ;
var sifter_old_content ;
var sifter_active = false;
$(document).ready( function(){
if ( mw.config.get('wgNamespaceNumber') != 0 ) return ; // Nevermind...
var url = "http://toolserver.org/~magnus/sifter_api.php?query=wikipage&page=" + mw.config.get('wgPageName') + "&format=json&callback=?" ;
$.getJSON ( url , function (data) {
if ( data.length > 0 ) create_sifter_menu ( data ) ;
} ) ;
}) ;
function create_sifter_menu ( data ) {
var html = "<li id='sifter_menu'><a href='#' onclick='show_sifter_dialog(1);return false'><span>Reviews</span></a></li>" ;
$('#p-views ul').prepend ( html ) ;
sifter_html = "<h1>Reviews</h1><table border='1' class='wikitable'>" ;
sifter_html += "<tr><th>Partner</th><th>Partner page</th><th>Wikipedia revision</th><th>Reviewer</th><th>Reviewed</th></tr>" ;
$.each ( data , function ( k , v ) {
sifter_html += "<tr>" ;
sifter_html += "<td>" + v.partner_name + "</td>" ;
sifter_html += "<td><a href='" + v.partner_url + "'>" + v.partner_id + "</a></td>" ;
sifter_html += "<td><a href='" + mw.config.get('wgScript') + "?title=" + escape(mw.config.get('wgPageName')) + "&oldid=" + v.revision + "'>" + v.revision + "</a> <a href='" + mw.config.get('wgScript') + "?title=" + escape(mw.config.get('wgPageName')) + "&oldid=" + v.revision + "&diff=0'>(show latest changes)</a></td>" ;
sifter_html += "<td><a href='" + v.reviewer_url + "'>" + v.reviewer + "</a></td>" ;
sifter_html += "<td>" + v.partner_ts + "</td>" ;
sifter_html += "</tr>" ;
} ) ;
sifter_html += "</table>" ;
sifter_html += "<div><a href='#' onclick='show_sifter_dialog(2);return false'>Restore page</a></div>" ;
}
function show_sifter_dialog ( mode ) {
if ( mode == 1 && !sifter_active ) {
sifter_old_content = $('#content').html();
$('#content').html(sifter_html);
$('#p-views li').removeClass ( 'selected' ) ;
$('#sifter_menu').addClass ( 'selected' ) ;
sifter_active = true;
}
if ( mode == 2 ) {
$('#content').html(sifter_old_content);
$('#sifter_menu').removeClass ( 'selected' ) ;
$('#ca-view').addClass ( 'selected' ) ;
sifter_active = false;
}
return false ;
}