« MediaWiki:Gadget-RecentChangesBox.js » : différence entre les versions

Contenu supprimé Contenu ajouté
Dr Brains (discuter | contributions)
mAucun résumé des modifications
Corrections diverses, notamment pour l'outil de traduction — contribution de User:Amire80 et User:Seb35, cf. PdD
Ligne 4 :
var rcp_num_pages;
var rcp_refresh;
 
 
/* initalise */
function rcp_init() {
 
if( !document.getElementById('p-logo') ) return;
 
// allow user settings through
if(rcp_enabled == null) {
Ligne 19 ⟶ 21 :
rcp_refresh = 5;
}
 
// A few limits to be nice to the servers
if (rcp_num_pages > 50) {
Ligne 30 ⟶ 32 :
rcp_refresh = 2;
}
 
// get our cookie
if (document.cookie.length > 0) {
Ligne 40 ⟶ 42 :
c_end = document.cookie.length;
}
 
if (document.cookie.substring(c_start, c_end) == "yes") {
rcp_enabled = true;
Ligne 48 ⟶ 50 :
}
}
 
// Either make a request or show nothing
if (rcp_enabled == true) {
Ligne 56 ⟶ 58 :
}
}
 
/* init ajax */
function rcp_create_request() {
try {
rcp_http = new XMLHttpRequest();
 
} catch (e) {
try {
Ligne 74 ⟶ 76 :
}
}
 
rcp_http.onreadystatechange = function() {
if(rcp_http.readyState == 4) rcp_ajax_response();
}
 
return true;
}
 
/* make a request */
function rcp_ajax_request() {
// check we are enabled
if (rcp_enabled == false) return;
 
// firstly, inform the user
var cur_box = document.getElementById('p-recentchanges');
Ligne 92 ⟶ 94 :
cur_box.firstChild.firstChild.data = 'Recent Changes (updating)';
}
 
if (rcp_create_request () == false) {
if (cur_box != null) {
Ligne 100 ⟶ 102 :
}
}
 
// Then make the request
rcp_http.open("GET", mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/api.php?action=query&list=recentchanges" +
Ligne 106 ⟶ 108 :
rcp_http.send(null);
}
 
/* we have received a response */
function rcp_ajax_response() {
 
var items = rcp_http.responseXML.getElementsByTagName('rc');
 
// create the div that holds all the recentchanges links
var link_div = document.createElement('div');
link_div.className = 'body pBody';
var list = document.createElement('ul');
link_div.appendChild(list);
 
// populate the list with 10 links.
for (var i = 0; i < items.length; i++) {
var item_name = items[i].getAttribute('title');
var item_url = mw.config.get('wgServer') + mw.config.get('wgScript') + '?diff=cur&oldid=prev&title=' + escape(item_name);
 
a = document.createElement('a');
a.setAttribute('href', item_url);
a.appendChild(document.createTextNode(item_name));
 
var li = document.createElement('li');
li.appendChild(a);
list.appendChild(li);
}
 
// Container div
var div = document.createElement('div');
div.setAttribute('id', 'p-recentchanges');
div.className = 'portal portlet';
div.setAttribute('role', 'navigation');
var heading = document.createElement('h3');
if( mw.config.get('skin') == 'vector' ) heading.setAttribute('style', 'display: block');
heading.appendChild(document.createTextNode('Modifications récentes'));
div.appendChild(heading);
div.appendChild(link_div);
 
// disable link
var p = document.createElement('p');
Ligne 147 ⟶ 151 :
p.style.textAlign = 'right';
a = document.createElement('a');
a.setAttribute('style', 'cursor: pointer');
a.appendChild(document.createTextNode('désactiver cette boite'));
a.onclick = rcp_disable_box;
p.appendChild(a);
link_div.appendChild(p);
 
// now replace the div
var old_div = document.getElementById('p-recentchanges');
Ligne 160 ⟶ 165 :
node.parentNode.insertBefore(div, node.nextSibling);
}
 
// and do it again in 5some secsseconds
setTimeout("rcp_ajax_request()", rcp_refresh * 1000);
}
 
function rcp_disable_box() {
rcp_enabled = false;
Ligne 170 ⟶ 175 :
document.cookie = "rcp_show_box=no; path=/";
}
 
function rcp_enable_box() {
rcp_enabled = true;
Ligne 176 ⟶ 181 :
rcp_ajax_request();
}
 
function rcp_draw_disabled_box() {
// Container div
var link_div = document.createElement('div');
link_div.className = 'body pBody';
var div = document.createElement('div');
div.setAttribute('id', 'p-recentchanges');
div.className = 'portal portlet';
div.setAttribute('role', 'navigation');
var heading = document.createElement('h3');
if( mw.config.get('skin') == 'vector' ) heading.setAttribute('style', 'display: block');
heading.appendChild(document.createTextNode('Modifications récentes'));
div.appendChild(heading);
div.appendChild(link_div);
 
// enable link
var p = document.createElement('p');
Ligne 194 ⟶ 201 :
p.style.margin = '0px';
var a = document.createElement('a');
a.setAttribute('style', 'cursor: pointer');
a.appendChild(document.createTextNode('Activer cette boite'));
a.onclick = rcp_enable_box;
p.appendChild(a);
link_div.appendChild(p);
 
// now replace the div
var old_div = document.getElementById('p-recentchanges');
Ligne 209 ⟶ 217 :
}
 
npp_refreshrcp_refresh = 10;
 
$( rcp_init );