var timerId = 0;
function checkAll(nomForm,nomItem)
{
var objFormulaire = document.forms[nomForm];
if(!objFormulaire)
return;
var objCheckBoxes = objFormulaire.elements[nomItem];
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = true;
else
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = true;
}
function uncheckAll(nomForm,nomItem)
{
var objFormulaire = document.forms[nomForm];
if(!objFormulaire)
return;
var objCheckBoxes = objFormulaire.elements[nomItem];
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = false;
else
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = false;
}
function mad_include_arc(id, url, option) {
var element = document.getElementById(id);
if (!element) {
return;
}
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
var req = create_XMLHTTP();
if ((req)&&(option.value!='')) {
// Synchronous request, wait till we have it all
req.open('GET', url + '&select=' + option.value, false);
req.send(null);
element.style.display='none';
var myDoc = loadXMLData(req.responseText);
var items = myDoc.getElementsByTagName('arc');
for(i=0; i<items.length; i++){
objOptionVide = document.createElement("option");
element.appendChild(objOptionVide);
objOptionVide.value = items[i].getAttribute('id');
objOptionVide.text = items[i].getElementsByTagName('label')[0].childNodes[0].data;
}
if(items.length==0) element.style.display='none';
else element.style.display='inline';
}
}
function mad_include_artist(id, url, option) {
var element = document.getElementById(id);
if (!element) {
return;
}
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
var req = create_XMLHTTP();
if ((req)&&(option.value!='')) {
// Synchronous request, wait till we have it all
req.open('GET', url + '&lastname=' + option.value, false);
req.send(null);
element.style.display='none';
var myDoc = loadXMLData(req.responseText);
var items = myDoc.getElementsByTagName('artist');
for(i=0; i<items.length; i++){
objOptionVide = document.createElement("option");
element.appendChild(objOptionVide);
objOptionVide.value = items[i].getAttribute('id');
var nom = items[i].getElementsByTagName("lastname")[0].childNodes[0].data;
if(items[i].getElementsByTagName("firstname").length>0)
nom += ', '+items[i].getElementsByTagName("firstname")[0].childNodes[0].data;
if(items[i].getElementsByTagName("middlename").length>0)
nom += ' '+items[i].getElementsByTagName("middlename")[0].childNodes[0].data;
objOptionVide.text = nom;
}
if(items.length==0) element.style.display='none';
else element.style.display='inline';
}
}
function mad_include_publisher(option) {
var divPublisher = document.getElementById("merge_publisher");
var divSeries = document.getElementById("merge_with_series");
var boutonSumbit = document.getElementById("merge_series_submit");
if (!divPublisher) {
return;
}
while(divPublisher.hasChildNodes())
{
divPublisher.removeChild(divPublisher.lastChild)
}
while(divSeries.hasChildNodes())
{
divSeries.removeChild(divSeries.lastChild)
}
boutonSumbit.style.display='none';
var req = create_XMLHTTP();
if ((req)&&(option.value!='')) {
// Synchronous request, wait till we have it all
req.open('GET', 'index.php?rub=publisher&format=xml&action=' + option.value, false);
req.send(null);
divPublisher.style.display='none';
var myDoc = loadXMLData(req.responseText);
var items = myDoc.getElementsByTagName('publisher');
objSelectVide = document.createElement("select");
objSelectVide.setAttribute("name","merge_publisher_select");
objSelectVide.setAttribute("id","merge_publisher_select");
divPublisher.appendChild(objSelectVide);
for(i=0; i<items.length; i++){
objOptionVide = document.createElement("option");
objSelectVide.appendChild(objOptionVide);
objOptionVide.value = items[i].getAttribute('id');
var nom = items[i].getElementsByTagName("publishername")[0].childNodes[0].data;
objOptionVide.text = nom;
}
if(items.length==0) divPublisher.style.display='none';
else divPublisher.style.display='inline';
}
}
function mad_include_series(option) {
var selectPublisher = document.getElementById("merge_publisher_select");
if (!selectPublisher) {
return;
}
var divSeries = document.getElementById("merge_with_series");
var boutonSumbit = document.getElementById("merge_series_submit");
if (!divSeries) {
return;
}
while(divSeries.hasChildNodes())
{
divSeries.removeChild(divSeries.lastChild)
}
boutonSumbit.style.display='none';
var req = create_XMLHTTP();
if ((req)&&(option.value!='')) {
// Synchronous request, wait till we have it all
var idPublisher = selectPublisher.value;
req.open('GET', 'index.php?rub=series&id_publisher=' + idPublisher + '&format=xml' + '&action=' + option.value, false);
req.send(null);
divSeries.style.display='none';
var myDoc = loadXMLData(req.responseText);
var items = myDoc.getElementsByTagName('series');
objSelectVide = document.createElement("select");
objSelectVide.setAttribute("name","merge_series_select");
objSelectVide.setAttribute("id","merge_series_select");
divSeries.appendChild(objSelectVide);
for(i=0; i<items.length; i++){
objOptionVide = document.createElement("option");
objSelectVide.appendChild(objOptionVide);
objOptionVide.value = items[i].getAttribute('id');
var nom = items[i].getElementsByTagName("seriesname")[0].childNodes[0].data+" vol."+items[i].getAttribute('volume');
objOptionVide.text = nom;
}
if(items.length==0)
{
divSeries.style.display='none';
boutonSumbit.style.display='none';
}
else
{
divSeries.style.display='inline';
boutonSumbit.style.display='inline';
}
}
}
function check_name(tagcheck,valuecheck,input_name,submit_name,url,resultdiv) {
var bouton = document.getElementById(submit_name);
var element = document.getElementById(resultdiv);
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
bouton.disabled = true;
bouton.style.display = "none";
element.style.display = "none";
clearTimeout ( timerId );
timerId = setTimeout ( 'check_name_post("'+tagcheck+'","'+valuecheck+'","'+input_name+'","'+submit_name+'","'+url+'","'+resultdiv+'")', 1000 );
}
function check_name_post(tagcheck,valuecheck,input_name,submit_name,url,resultdiv) {
clearTimeout ( timerId );
var nameinput = document.getElementById(input_name);
var bouton = document.getElementById(submit_name);
var element = document.getElementById(resultdiv);
var req = create_XMLHTTP();
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', url + '&action='+ escape(nameinput.value) , false);
req.send(null);
var myDoc = loadXMLData(req.responseText);
var message = myDoc.getElementsByTagName("message")[0].childNodes[0].data;
var status = myDoc.getElementsByTagName("message")[0].getAttribute('status');
var items = myDoc.getElementsByTagName(tagcheck);
if(message!=null)
{
paragVide = document.createElement("p");
paragVide.innerHTML = message;
element.appendChild(paragVide);
}
if(items.length>0)
{
paragVide2 = document.createElement("p");
selectVide = document.createElement("select");
paragVide2.appendChild(selectVide);
selectVide.name="homonyms";
element.appendChild(paragVide2);
}
for(i=0; i<items.length; i++){
objOptionVide = document.createElement("option");
selectVide.appendChild(objOptionVide);
objOptionVide.value = items[i].getAttribute('id');
objOptionVide.text = items[i].getElementsByTagName(valuecheck)[0].childNodes[0].data;
}
element.style.display="inline";
if(status=='OK')
{
bouton.disabled = false;
bouton.style.display = 'inline';
}
else
{
bouton.disabled = true;
bouton.style.display = 'none';
}
}
}
function check_artist_name(first_name,middle_name,last_name,artist_data_submit,check_artist) {
var bouton = document.getElementById(artist_data_submit);
var element = document.getElementById(check_artist);
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
bouton.disabled = true;
bouton.style.display = "none";
element.style.display = "none";
clearTimeout ( timerId );
timerId = setTimeout ( 'check_artist_name_post("'+first_name+'","'+middle_name+'","'+last_name+'","'+artist_data_submit+'","'+check_artist+'")', 1000 );
}
function check_artist_name_post(first_name,middle_name,last_name,artist_data_submit,check_artist) {
clearTimeout ( timerId );
var firstinput = document.getElementById(first_name);
var middleinput = document.getElementById(middle_name);
var lastinput = document.getElementById(last_name);
var bouton = document.getElementById(artist_data_submit);
var element = document.getElementById(check_artist);
var req = create_XMLHTTP();
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', 'index.php?rub=artist&format=xml' + '&firstname='+ escape(firstinput.value) + '&middlename='+ escape(middleinput.value) + '&lastname='+ escape(lastinput.value) , false);
req.send(null);
var myDoc = loadXMLData(req.responseText);
var message = myDoc.getElementsByTagName("message")[0].childNodes[0].data;
var status = myDoc.getElementsByTagName("message")[0].getAttribute('status');
var items = myDoc.getElementsByTagName("artist");
if(message!=null)
{
paragVide = document.createElement("p");
paragVide.innerHTML = message;
element.appendChild(paragVide);
}
if(items.length>0)
{
paragVide2 = document.createElement("p");
selectVide = document.createElement("select");
paragVide2.appendChild(selectVide);
selectVide.name="homonyms";
element.appendChild(paragVide2);
}
for(i=0; i<items.length; i++){
objOptionVide = document.createElement("option");
selectVide.appendChild(objOptionVide);
objOptionVide.value = items[i].getAttribute('id');
var nom = items[i].getElementsByTagName("lastname")[0].childNodes[0].data;
if(items[i].getElementsByTagName("firstname").length>0)
nom += ', '+items[i].getElementsByTagName("firstname")[0].childNodes[0].data;
if(items[i].getElementsByTagName("middlename").length>0)
nom += ' '+items[i].getElementsByTagName("middlename")[0].childNodes[0].data;
objOptionVide.text = nom;
}
element.style.display="inline";
if(status=='OK')
{
bouton.disabled = false;
bouton.style.display = 'inline';
}
else
{
bouton.disabled = true;
bouton.style.display = 'none';
}
}
}
function check_series_name(refname) {
var nameinput = document.getElementById(refname);
var bouton = nameinput.form.elements["add_series"];
var element = document.getElementById("check_series");
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
bouton.disabled = true;
bouton.style.display = "none";
element.style.display = "none";
clearTimeout ( timerId );
timerId = setTimeout ( 'check_series_name_post("'+refname+'")', 1000 );
}
function check_series_name_post(refname) {
clearTimeout ( timerId );
var nameinput = document.getElementById(refname);
var publisher = nameinput.form.elements["new_publisher"];
var volume = nameinput.form.elements["new_volume"];
var edition = nameinput.form.elements["new_firstedition"];
var edition_value='';
for (var i=0; i<edition.length;i++)
if (edition[i].checked)
edition_value = edition[i].value;
var bouton = nameinput.form.elements["add_series"];
var element = document.getElementById("check_series");
var req = create_XMLHTTP();
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', 'index.php?rub=series&id_publisher=' + publisher.value + '&format=xml&action='+ escape(nameinput.value) + '&volume=' + escape(volume.value) + '&edition=' + escape(edition_value), false);
req.send(null);
var myDoc = loadXMLData(req.responseText);
var message = myDoc.getElementsByTagName("message")[0].childNodes[0].data;
var status = myDoc.getElementsByTagName("message")[0].getAttribute('status');
var items = myDoc.getElementsByTagName("series");
if(message!=null)
{
paragVide = document.createElement("p");
paragVide.innerHTML = message;
element.appendChild(paragVide);
}
if(items.length>0)
{
paragVide2 = document.createElement("p");
selectVide = document.createElement("select");
paragVide2.appendChild(selectVide);
selectVide.name="homonyms";
element.appendChild(paragVide2);
}
for(i=0; i<items.length; i++){
objOptionVide = document.createElement("option");
selectVide.appendChild(objOptionVide);
objOptionVide.value = items[i].getAttribute('id');
var nom = items[i].getElementsByTagName("seriesname")[0].childNodes[0].data + ' vol.' + items[i].getAttribute('volume');
if(items[i].getAttribute('year')!=null) nom += ' (' + items[i].getAttribute('year') + ')';
objOptionVide.text = nom;
}
element.style.display="inline";
if(status=='OK')
{
bouton.disabled = false;
bouton.style.display = 'inline';
}
else
{
bouton.disabled = true;
bouton.style.display = 'none';
}
}
}
function story_vote(id_series,issue,id_story, option) {
var element = document.getElementById("story_vote_"+id_story);
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
var req = create_XMLHTTP();
if ((req)&&(option.value!='')) {
// Synchronous request, wait till we have it all
req.open('GET', 'index.php?rub=vote&id_series=' + id_series + '&issue=' + issue + '&id_story=' + id_story + '&vote=' + option + '&action=story', false);
req.send(null);
var myDoc = loadXMLData(req.responseText);
var status = myDoc.getElementsByTagName("vote")[0].getAttribute('status');
var message = myDoc.getElementsByTagName("message")[0].childNodes[0].data;
if(message!=null)
{
paragVide = document.createElement("p");
textParag = document.createTextNode(message);
paragVide.appendChild(textParag);
element.appendChild(paragVide);
element.setAttribute("class","voted");
}
}
}
function loadXMLData(content)
{
// code for IE
if (window.ActiveXObject)
{
var doc=new ActiveXObject("Microsoft.XMLDOM");
doc.async="false";
doc.loadXML(content);
}
// code for Mozilla, Firefox, Opera, etc.
else
{
var parser=new DOMParser();
var doc=parser.parseFromString(content,"text/xml");
}
return doc.documentElement;
}
function create_XMLHTTP()
{
var req = false;
// For Safari, Firefox, and other non-MS browsers
if (window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch (e) {
req = false;
}
}
else if (window.ActiveXObject) {
// For Internet Explorer on Windows
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
req = false;
}
}
}
return req;
}