/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */
/******************************************************************/
// Sliders using jquery by Tierrie
// Source: http://dragonage.wikia.com/wiki/MediaWiki:Common.js
// Author: http://dragonage.wikia.com/wiki/User:Tierrie
/******************************************************************/
mw.loader.load("jquery.ui.tabs");
});
});
/****************************************************************/
// Spoilers by Tierrie
// Source: http://dragonage.wikia.com/wiki/MediaWiki:Common.js
// Author: http://dragonage.wikia.com/wiki/User:Tierrie
/****************************************************************/
var showSpoiler = new Array();
function showSpoilers(splrType) {
var Divs= document.getElementsByTagName("div");
for (i=0;i<Divs.length;i++) {
// allows the child to be something besides a div (a table for example)
if (hasClass(Divs[i], 'splr') && hasClass(Divs[i].childNodes[0], 'splr_'+splrType)) {
var warning = Divs[i].childNodes[0].childNodes[1];
warning.className = warning.className.replace('show_warning','hide_warning');
var spoiler = Divs[i].childNodes[1];
spoiler.className = spoiler.className.replace('hide_spoiler','show_spoiler');
}
}
document.cookie='showspoiler_'+splrType+'=1; path=/';
}
function hideSpoilers(splrType) {
var Divs= document.getElementsByTagName("div");
for (i=0;i<Divs.length;i++) {
// allows the child to be something besides a div (a table for example)
if (hasClass(Divs[i], 'splr') && hasClass(Divs[i].childNodes[0], 'splr_'+splrType)) {
var warning = Divs[i].childNodes[0].childNodes[1];
warning.className = warning.className.replace('hide_warning','show_warning');
var spoiler = Divs[i].childNodes[1];
spoiler.className = spoiler.className.replace('show_spoiler','hide_spoiler');
}
}
document.cookie='showspoiler_'+splrType+'=0; path=/';
}
function toggleSpoilers(ev) {
var splrType=this.className.split('_')[1];
showSpoiler[splrType] = showSpoiler[splrType]?0:1;
if(showSpoiler[splrType])
showSpoilers(splrType);
else
hideSpoilers(splrType);
//ev.target.focus(); /* focus back on the element because large spoilers tend to move the page around */
}
function initSpoilers() {
var Divs= document.getElementsByTagName("div");
for (i=0;i<Divs.length;i++) {
if (hasClass(Divs[i], 'splr')) {
Divs[i].childNodes[0].onclick = toggleSpoilers;
var warning = Divs[i].childNodes[0].childNodes[1];
warning.className = warning.className.replace('hide_warning','show_warning');
var spoiler = Divs[i].childNodes[1];
spoiler.className = spoiler.className.replace('show_spoiler','hide_spoiler');
}
}
var cookies = document.cookie.split("; ");
for (var i=0; i < cookies.length; i++) {
// a name/value pair (a crumb) is separated by an equal sign
if(cookies[i].indexOf('showspoiler')!=-1) {
var crumbs = cookies[i].split("=");
var splrType = crumbs[0].split('_')[1]; /* cookie="showspoiler_dao=1", crumbs[0] = "showspoiler_dao", splrType="dao" */
var splrValue = parseInt(crumbs[1]);
showSpoiler[splrType]=splrValue;
if(splrValue)
showSpoilers(splrType);
else
hideSpoilers(splrType);
}
}
}
var spoilers = true;
function loadSpoilers() {
if(spoilers) initSpoilers();
}
addOnloadHook(loadSpoilers);