MediaWiki:Gadget-RealtimeRC.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes.
- Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
- Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
- Opera, Konqueror and Safari users can just click the Reload button.
- Chrome: press Ctrl+F5 or Shift+F5
// Adapted from User:Villahj_Ideeut/RC.js
// --Uses the URL you typed originally rather than a canned one
// --Refreshes every 15 seconds instead of 3 (should be a parameter!)
// --Recoded with jQuery and Ajax
function addRC1() {
if(mw.config.get(wgCanonicalSpecialPageName) == 'Recentchanges') {
// Remove the button if someone enabled the old Gadget in "My preferences"
// $("#td-rc").remove();
// Now add our own enabling button
mw.util.addPortletLink('p-cactions', 'javascript:runRC1()',
'Auto-update', 'td-rc1', 'Update every 15 seconds');
};
}
function runRC1() {
// Call for an update of the current page. Gives "not well-formed" but works anyway
$.get(location.href, "No data", function(data) {
// Change the "Auto-update" button to report the bytes received, showing activity
$("#td-rc1").text(data.length);
// Patch its bodyContent into the document
document.getElementById('bodyContent').innerHTML =
data.substring(
data.indexOf('<div id="bodyContent">'),
data.indexOf('<!-- end content -->')
);
// Fire again in fifteen seconds
var t=setTimeout("runRC1()",15000);
}, "text");
}
$(document).ready(addRC1);