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 invertCheck(nomForm,nomItem)
{
var objFormulaire = document.forms[nomForm];
if(!objFormulaire)
return;
var objCheckBoxes = objFormulaire.elements[nomItem];
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
for(var i = 0; i < countCheckBoxes; i++)
if(objCheckBoxes[i].checked) objCheckBoxes[i].checked = false;
else objCheckBoxes[i].checked = true;
}
function swapDisplay(nomItem)
{
var objItem = document.getElementById(nomItem);
if(!objItem)
return;
if(objItem.style.display=="none")
objItem.style.display = "block";
else objItem.style.display="none";
}
function series_issues_action_changed()
{
var selectField = document.getElementById("issue_action");
var actionSelected = selectField.value;
var buttonSubmit = document.getElementById("submitSelectedIssues");
var divAddArtist = document.getElementById("add_author_several");
var divMoveSeries = document.getElementById("move_series");
switch(actionSelected)
{
case "add_artist":
buttonSubmit.style.display = "none";
buttonSubmit.disabled = true;
divAddArtist.style.display = "block";
divMoveSeries.style.display = "none";
break;
case "move_series":
buttonSubmit.style.display = "none";
buttonSubmit.disabled = true;
divAddArtist.style.display = "none";
divMoveSeries.style.display = "block";
break;
default :
buttonSubmit.style.display = "inline";
buttonSubmit.disabled = false;
divAddArtist.style.display = "none";
divMoveSeries.style.display = "none";
break;
}
}
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, true);
req.onreadystatechange = function (aEvt)
{
if(req.readyState==4)
{
if(req.status==200)
{
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('arcname')[0].childNodes[0].data;
}
if(items.length==0) element.style.display='none';
else element.style.display='inline';
}
}
}
req.send(null);
}
}
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) , true);
req.onreadystatechange = function (aEvt)
{
if(req.readyState==4)
{
if(req.status==200)
{
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';
}
}
}
}
req.send(null);
}
}
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 mad_include_publisher(buttonSubmit) {
var bouton = document.getElementById(buttonSubmit);
var elementPublisher = document.getElementById("publisher_results");
var elementSeries = document.getElementById("series_results");
var headerSeries = document.getElementById("header_series");
var elementLabel = document.getElementById("label_results");
var headerLabel = document.getElementById("header_label");
while(elementPublisher.hasChildNodes())
{
elementPublisher.removeChild(elementPublisher.lastChild)
}
while(elementLabel.hasChildNodes())
{
elementLabel.removeChild(elementLabel.lastChild)
}
while(elementSeries.hasChildNodes())
{
elementSeries.removeChild(elementSeries.lastChild)
}
bouton.disabled = true;
bouton.style.display = "none";
elementPublisher.style.display = "none";
elementLabel.style.display = "none";
elementSeries.style.display = "none";
headerSeries.style.display = "none";
headerLabel.style.display = "none";
clearTimeout ( timerId );
timerId = setTimeout ( 'mad_include_publisher_post("'+buttonSubmit+'")', 1000 );
}
function mad_include_series(buttonSubmit) {
var bouton = document.getElementById(buttonSubmit);
var elementSeries = document.getElementById("series_results");
while(elementSeries.hasChildNodes())
{
elementSeries.removeChild(elementSeries.lastChild)
}
bouton.disabled = true;
bouton.style.display = "none";
elementSeries.style.display = "none";
clearTimeout ( timerId );
timerId = setTimeout ( 'mad_include_series_post("'+buttonSubmit+'")', 1000 );
}
function check_worker_name(last_name,divResult,buttonSubmit) {
var bouton = document.getElementById(buttonSubmit);
var element = document.getElementById(divResult);
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
bouton.disabled = true;
bouton.style.display = "none";
element.style.display = "none";
clearTimeout ( timerId );
timerId = setTimeout ( 'check_worker_name_post("'+last_name+'","'+divResult+'","'+buttonSubmit+'")', 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) , true);
req.onreadystatechange = function (aEvt)
{
if(req.readyState==4)
{
if(req.status==200)
{
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';
}
}
}
}
req.send(null);
}
}
function check_worker_name_post(last_name,divResult,buttonSubmit) {
clearTimeout ( timerId );
var lastinput = document.getElementById(last_name);
var bouton = document.getElementById(buttonSubmit);
var element = document.getElementById(divResult);
var req = create_XMLHTTP();
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', 'index.php?rub=artist&format=xml' + '&lastname='+ escape(lastinput.value) , true);
req.onreadystatechange = function (aEvt)
{
if(req.readyState==4)
{
if(req.status==200)
{
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(items.length>0)
{
selectVide = document.createElement("select");
selectVide.name="new_artist_id";
element.appendChild(selectVide);
}
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(items.length>0)
{
bouton.disabled = false;
bouton.style.display = 'inline';
}
else
{
bouton.disabled = true;
bouton.style.display = 'none';
}
}
}
}
req.send(null);
}
}
function mad_include_publisher_post(buttonSubmit) {
clearTimeout ( timerId );
var lastinput = document.getElementById("publisher_name_input");
var bouton = document.getElementById(buttonSubmit);
var element = document.getElementById("publisher_results");
var headerLabel = document.getElementById("header_label");
var elementLabel = document.getElementById("label_results");
var headerSeries = document.getElementById("header_series");
var elementSeries = document.getElementById("series_results");
var req = create_XMLHTTP();
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', 'index.php?rub=publisher&format=xml' + '&action='+ escape(lastinput.value) , true);
req.onreadystatechange = function (aEvt)
{
if(req.readyState==4)
{
if(req.status==200)
{
var myDoc = loadXMLData(req.responseText);
var items = myDoc.getElementsByTagName("publisher");
if(items.length>0)
{
selectVide = document.createElement("select");
selectVide.name="select_publisher_id";
selectVide.id="select_publisher_id";
element.appendChild(selectVide);
selectVide.setAttribute("onchange","mad_include_label_post()");
}
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("publishername")[0].childNodes[0].data;
objOptionVide.text = nom;
}
element.style.display="inline";
if(items.length>0)
{
headerLabel.style.display = "block";
elementLabel.style.display = "inline";
headerSeries.style.display = "block";
elementSeries.style.display = "inline";
mad_include_label_post();
}
}
}
}
req.send(null);
}
}
function mad_include_label_post() {
var publisher_results = document.getElementById("select_publisher_id");
var element = document.getElementById("label_results");
var headerSeries = document.getElementById("header_series");
var elementSeries = document.getElementById("series_results");
while(element.hasChildNodes())
{
element.removeChild(element.lastChild)
}
var req = create_XMLHTTP();
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', 'index.php?rub=label&id_publisher='+publisher_results.value+'&format=xml' , true);
req.onreadystatechange = function (aEvt)
{
if(req.readyState==4)
{
if(req.status==200)
{
var myDoc = loadXMLData(req.responseText);
var items = myDoc.getElementsByTagName("label");
selectVide = document.createElement("select");
selectVide.name="select_label_id";
selectVide.id="select_label_id";
element.appendChild(selectVide);
objOptionVide = document.createElement("option");
selectVide.appendChild(objOptionVide);
objOptionVide.value = 0;
objOptionVide.text = "";
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("labelname")[0].childNodes[0].data;
objOptionVide.text = nom;
}
element.style.display="inline";
}
}
}
req.send(null);
}
}
function mad_include_series_post(buttonSubmit) {
clearTimeout ( timerId );
var lastinput = document.getElementById("series_name_input");
var bouton = document.getElementById(buttonSubmit);
var element = document.getElementById("series_results");
var publisherSelect = document.getElementById("select_publisher_id");
var labelSelect = document.getElementById("select_label_id");
var req = create_XMLHTTP();
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', 'index.php?rub=series&id_publisher='+publisherSelect.value+'&id_label='+labelSelect.value+'&format=xml' + '&action='+ escape(lastinput.value) , true);
req.onreadystatechange = function (aEvt)
{
if(req.readyState==4)
{
if(req.status==200)
{
var myDoc = loadXMLData(req.responseText);
var items = myDoc.getElementsByTagName("series");
if(items.length>0)
{
selectVide = document.createElement("select");
selectVide.name="select_series_id";
selectVide.id="select_series_id";
element.appendChild(selectVide);
}
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(items.length>0)
{
element.style.display = "inline";
bouton.disabled = false;
bouton.style.display = 'inline';
}
else
{
element.style.display = "none";
bouton.disabled = true;
bouton.style.display = 'none';
}
}
}
}
req.send(null);
}
}
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), true);
req.onreadystatechange = function (aEvt)
{
if(req.readyState==4)
{
if(req.status==200)
{
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';
}
}
}
}
req.send(null);
}
}
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', true);
req.onreadystatechange = function (aEvt)
{
if(req.readyState==4)
{
if(req.status==200)
{
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");
}
}
}
}
req.send(null);
}
}
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;
}