1072 lines
32 KiB
JavaScript
1072 lines
32 KiB
JavaScript
var GSM_origin_liste = false;
|
|
var GSM_liste = false;
|
|
var GSM_liste_CDA = false; //CDs année
|
|
var GSM_liste_CDC = false; //CDs chanteur
|
|
var GSM_liste_CDD = false; //CDs décénies
|
|
var GSM_lastSort = -1;
|
|
var GSM_delay = null;
|
|
var nbParPage = 50;
|
|
|
|
//On charge la liste des porte-clés
|
|
function GSM_loadList()
|
|
{
|
|
GSM_origin_liste = false;
|
|
GSM_liste = false;
|
|
GSM_liste_CDA = false;
|
|
GSM_liste_CDC = false;
|
|
GSM_liste_CDD = false;
|
|
GSM_lastSort = -1;
|
|
$('nbpc').innerHTML = '<img src="applications/GSM/loader.gif" alt="Chargement en cours ...">';
|
|
new Ajax.Request(
|
|
'ajax.php',
|
|
{
|
|
method: 'get',
|
|
parameters: {d: "action", a: "GSM", p: "liste"},
|
|
onSuccess: GSM_parseList,
|
|
onFailure: function() { printEtat(3); }
|
|
}
|
|
);
|
|
}
|
|
function GSM_loadSelectedList()
|
|
{
|
|
//TODO: ne charger que les listes dont l'état est false
|
|
GSM_loadList();
|
|
}
|
|
GSM_loadList();
|
|
|
|
//Une fois la liste reçue, on la parse
|
|
function GSM_parseList(transport, json)
|
|
{
|
|
$('nbpc').innerHTML = json.nombre;
|
|
|
|
var liste = transport.responseXML.documentElement.getElementsByTagName("liste")[0].getElementsByTagName("chanson");
|
|
GSM_origin_liste = new Array();
|
|
|
|
for (var i = 0; i < liste.length; i++)
|
|
{
|
|
var elt = liste[i];
|
|
GSM_origin_liste.push([elt.getAttribute("id"), elt.getAttribute("titre"), elt.getAttribute("chanteur"), elt.getAttribute("CD_annee"), elt.getAttribute("CD_interprete"), elt.getAttribute("CD_decenie")]);
|
|
}
|
|
|
|
var liste = transport.responseXML.documentElement.getElementsByTagName("liste")[0].getElementsByTagName("cdannee");
|
|
GSM_liste_CDA = new Array();
|
|
for (var i = 0; i < liste.length; i++)
|
|
{
|
|
var elt = liste[i];
|
|
GSM_liste_CDA[elt.getAttribute("id")] = elt.getAttribute("nom");
|
|
}
|
|
|
|
var liste = transport.responseXML.documentElement.getElementsByTagName("liste")[0].getElementsByTagName("cdchant");
|
|
GSM_liste_CDC = new Array();
|
|
for (var i = 0; i < liste.length; i++)
|
|
{
|
|
var elt = liste[i];
|
|
GSM_liste_CDC[elt.getAttribute("id")] = elt.getAttribute("nom");
|
|
}
|
|
|
|
var liste = transport.responseXML.documentElement.getElementsByTagName("liste")[0].getElementsByTagName("cddece");
|
|
GSM_liste_CDD = new Array();
|
|
for (var i = 0; i < liste.length; i++)
|
|
{
|
|
var elt = liste[i];
|
|
GSM_liste_CDD[elt.getAttribute("id")] = elt.getAttribute("nom");
|
|
}
|
|
}
|
|
|
|
function GSM_add()
|
|
{
|
|
window.scrollTo(0,0);
|
|
$('contenu').innerHTML = "";
|
|
titre = document.createElement("h2");
|
|
titre.innerHTML = "Ajout d'un album à la base de données";
|
|
$('contenu').appendChild(titre);
|
|
|
|
GSM_addAlbum();
|
|
}
|
|
|
|
function GSM_edit()
|
|
{
|
|
window.scrollTo(0,0);
|
|
$('contenu').innerHTML = "";
|
|
titre = document.createElement("h2");
|
|
titre.innerHTML = "Liste des albums";
|
|
$('contenu').appendChild(titre);
|
|
|
|
GSM_viewliste(0, 0, 0);
|
|
}
|
|
|
|
function GSM_listAlbums()
|
|
{
|
|
window.scrollTo(0,0);
|
|
$('contenu').innerHTML = "";
|
|
titre = document.createElement("h2");
|
|
titre.innerHTML = "Liste des albums";
|
|
$('contenu').appendChild(titre);
|
|
|
|
GSM_viewalbums(false);
|
|
}
|
|
|
|
function GSM_listTitres()
|
|
{
|
|
window.scrollTo(0,0);
|
|
$('contenu').innerHTML = "";
|
|
titre = document.createElement("h2");
|
|
titre.innerHTML = "Liste des titres";
|
|
$('contenu').appendChild(titre);
|
|
|
|
GSM_liste = false;
|
|
|
|
GSM_viewliste(0, 0, 0);
|
|
}
|
|
|
|
function GSM_addAlbum()
|
|
{
|
|
var formulaire = document.createElement("form");
|
|
formulaire.id = "addAlbms";
|
|
formulaire.onsubmit = function() { newAlbum(); return false; }
|
|
var inpt = document.createElement("input");
|
|
inpt.type = "radio";
|
|
inpt.name = "cd";
|
|
inpt.id = "cda";
|
|
inpt.value = "1";
|
|
inpt.onclick = function() { GSM_addAlbum_chColor(1); };
|
|
formulaire.appendChild(inpt);
|
|
var lbl = document.createElement("label");
|
|
lbl.htmlFor = "cda";
|
|
lbl.innerHTML = "Ajouter un album d'année";
|
|
formulaire.appendChild(lbl);
|
|
formulaire.appendChild(document.createElement("br"));
|
|
var inpt = document.createElement("input");
|
|
inpt.type = "radio";
|
|
inpt.name = "cd";
|
|
inpt.id = "cdc";
|
|
inpt.value = "1";
|
|
inpt.onclick = function() { GSM_addAlbum_chColor(2); };
|
|
formulaire.appendChild(inpt);
|
|
var lbl = document.createElement("label");
|
|
lbl.htmlFor = "cdc";
|
|
lbl.innerHTML = "Ajouter un album d'un interprête";
|
|
formulaire.appendChild(lbl);
|
|
formulaire.appendChild(document.createElement("br"));
|
|
var inpt = document.createElement("input");
|
|
inpt.type = "radio";
|
|
inpt.name = "cd";
|
|
inpt.id = "cdd";
|
|
inpt.value = "1";
|
|
inpt.onclick = function() { GSM_addAlbum_chColor(3); };
|
|
formulaire.appendChild(inpt);
|
|
var lbl = document.createElement("label");
|
|
lbl.htmlFor = "cdd";
|
|
lbl.innerHTML = "Ajouter d'une compilation";
|
|
formulaire.appendChild(lbl);
|
|
formulaire.appendChild(document.createElement("br"));
|
|
formulaire.appendChild(document.createElement("br"));
|
|
var cntr = document.createElement("div");
|
|
var lbl = document.createElement("label");
|
|
lbl.htmlFor = "nom";
|
|
lbl.innerHTML = "Nom :";
|
|
cntr.appendChild(lbl);
|
|
var inpt = document.createElement("input");
|
|
inpt.type = "text";
|
|
inpt.name = "nom";
|
|
inpt.id = "nom";
|
|
cntr.appendChild(inpt);
|
|
cntr.appendChild(document.createElement("br"));
|
|
var lbl = document.createElement("label");
|
|
lbl.htmlFor = "color";
|
|
lbl.innerHTML = "Couleur :";
|
|
cntr.appendChild(lbl);
|
|
var inpt = document.createElement("input");
|
|
inpt.type = "color";
|
|
inpt.name = "color";
|
|
inpt.id = "color";
|
|
inpt.onchange = function() { $("testColor").style.backgroundColor = $('color').value; };
|
|
cntr.appendChild(inpt);
|
|
var test = document.createElement("div");
|
|
test.id = "testColor";
|
|
cntr.appendChild(test);
|
|
cntr.appendChild(document.createElement("br"));
|
|
var lbl = document.createElement("label");
|
|
lbl.htmlFor = "ccf";
|
|
lbl.innerHTML = "Copier la couleur depuis :";
|
|
cntr.appendChild(lbl);
|
|
var inpt = document.createElement("select");
|
|
inpt.name = "ccf";
|
|
inpt.id = "ccf";
|
|
cntr.appendChild(inpt);
|
|
cntr.appendChild(document.createElement("br"));
|
|
cntr.appendChild(document.createElement("br"));
|
|
var inpt = document.createElement("input");
|
|
inpt.type = "submit";
|
|
inpt.value = "Valider";
|
|
cntr.appendChild(inpt);
|
|
formulaire.appendChild(cntr);
|
|
$('contenu').appendChild(formulaire);
|
|
}
|
|
|
|
function GSM_addAlbum_chColor(type)
|
|
{
|
|
var liste;
|
|
if (type == 1)
|
|
liste = GSM_liste_CDA;
|
|
else if (type == 2)
|
|
liste = GSM_liste_CDC;
|
|
else
|
|
liste = GSM_liste_CDD;
|
|
|
|
$("ccf").innerHTML = '<option value="0"> </option>';
|
|
|
|
for (var i in liste)
|
|
{
|
|
if (Math.floor(i) == i)
|
|
{
|
|
var opt = document.createElement("option");
|
|
opt.value = i;
|
|
opt.innerHTML = liste[i];
|
|
$("ccf").appendChild(opt);
|
|
}
|
|
}
|
|
|
|
if ($("ccf").innerHTML != "")
|
|
$("ccf").onchange = function(event) { if (this.value > 0) GSM_addAlbum_loadColor(this, type); };
|
|
}
|
|
|
|
function GSM_addAlbum_loadColor(elt, type)
|
|
{
|
|
new Ajax.Request(
|
|
'ajax.php',
|
|
{
|
|
method: 'get',
|
|
parameters: {d: "action", a: "GSM", p: "color", type: type, id: elt.value},
|
|
onSuccess: function(transport, json)
|
|
{
|
|
$('color').value = transport.responseXML.documentElement.getElementsByTagName("color")[0].firstChild.textContent;
|
|
$("testColor").style.backgroundColor = $('color').value;
|
|
}
|
|
});
|
|
}
|
|
|
|
function newAlbum()
|
|
{
|
|
var type;
|
|
if ($('cda').checked == 1)
|
|
type = 1;
|
|
else if ($('cdc').checked == 1)
|
|
type = 2;
|
|
else if ($('cdd').checked == 1)
|
|
type = 3;
|
|
else
|
|
{
|
|
alert("Vous n'avez pas sélectionné de type !");
|
|
return;
|
|
}
|
|
|
|
var nom = $('nom').value;
|
|
if (nom)
|
|
{
|
|
//On ajoute l'album
|
|
new Ajax.Request(
|
|
'ajax.php?d=action&a=GSM&p=add',
|
|
{
|
|
method: 'post',
|
|
parameters: {type: type, title: nom, color: $('color').value},
|
|
onSuccess: function(transport, json)
|
|
{
|
|
if (json.statut != 1)
|
|
{
|
|
firstLoad();
|
|
alert("Vous avez été déconnecté. L'album' n'a pas été ajouté.");
|
|
}
|
|
else
|
|
{
|
|
if (transport.responseXML.documentElement.getElementsByTagName("id")[0])
|
|
{
|
|
if (type == 1)
|
|
GSM_liste_CDA = false;
|
|
else if (type == 2)
|
|
GSM_liste_CDC = false;
|
|
else
|
|
GSM_liste_CDD = false;
|
|
|
|
//On recharge la liste d'album
|
|
GSM_loadSelectedList();
|
|
|
|
$('contenu').innerHTML = "";
|
|
titre = document.createElement("h2");
|
|
titre.style.color = "#FF8800";
|
|
titre.innerHTML = 'Chargement en cours ... <img src="applications/GSM/loader.gif" alt="Veuilez patienter">';
|
|
$('contenu').appendChild(titre);
|
|
|
|
//On passe à l'écran de modification du nouvel album
|
|
GSM_viewalbum(type, transport.responseXML.documentElement.getElementsByTagName("id")[0].textContent, 0);
|
|
}
|
|
else
|
|
alert("L'ajout de l'album ne s'est pas passé correctement.")
|
|
}
|
|
},
|
|
onFailure: function() { printEtat(3); }
|
|
}
|
|
);
|
|
}
|
|
else
|
|
alert("Vous n'avez pas précisé de nom pour ce nouvel album.");
|
|
}
|
|
|
|
function GSM_addForm(type, idAlbum, modif, page)
|
|
{
|
|
//Si le formulaire existe déjà, on ne fait que remplacer son contenu
|
|
var formulaire;
|
|
if ($('ajout'))
|
|
{
|
|
formulaire = $('ajout');
|
|
formulaire.innerHTML = "";
|
|
}
|
|
else
|
|
{
|
|
formulaire = document.createElement("form");
|
|
formulaire.id = "ajout";
|
|
$('contenu').appendChild(formulaire);
|
|
}
|
|
|
|
formulaire.onsubmit = function() { checkAndAdd(type, idAlbum, modif, page); return false; }
|
|
var th = document.createElement("h3");
|
|
if (modif)
|
|
th.innerHTML = "Modification d'un titre";
|
|
else
|
|
th.innerHTML = "Ajout d'un titre à l'album";
|
|
|
|
var lab_nom = document.createElement("label");
|
|
lab_nom.innerHTML = "Titre :";
|
|
lab_nom.forHTML = "titrechan";
|
|
var inp_nom = document.createElement("input");
|
|
if(modif)
|
|
inp_nom.value = GSM_liste[modif-1][1];
|
|
inp_nom.type = "text";
|
|
inp_nom.maxLength = "250";
|
|
inp_nom.id = "titrechan";
|
|
|
|
var lab_carac = document.createElement("label");
|
|
lab_carac.innerHTML = "Interpréte :";
|
|
lab_carac.setAttribute("for", "auteur");
|
|
var inp_carac = document.createElement("input");
|
|
if(modif)
|
|
inp_carac.value = GSM_liste[modif-1][2];
|
|
inp_carac.type = "text";
|
|
inp_carac.maxLength = "250";
|
|
inp_carac.id = "auteur";
|
|
|
|
var auteur_propos = document.createElement("div");
|
|
auteur_propos.id = "auteur_propositions";
|
|
auteur_propos.className = "autocomplete";
|
|
|
|
var inp_submit = document.createElement("input");
|
|
inp_submit.type = "submit";
|
|
if (modif)
|
|
inp_submit.value = "Modifier";
|
|
else
|
|
inp_submit.value = "Ajouter";
|
|
inp_submit.style.marginLeft = "165px";
|
|
|
|
formulaire.appendChild(th);
|
|
formulaire.appendChild(lab_nom);
|
|
formulaire.appendChild(inp_nom);
|
|
formulaire.appendChild(document.createElement("br"));
|
|
formulaire.appendChild(lab_carac);
|
|
formulaire.appendChild(inp_carac);
|
|
formulaire.appendChild(auteur_propos);
|
|
formulaire.appendChild(document.createElement("br"));
|
|
formulaire.appendChild(document.createElement("br"));
|
|
formulaire.appendChild(inp_submit);
|
|
if (modif)
|
|
{
|
|
var inp_del = document.createElement("input");
|
|
inp_del.type = "button";
|
|
inp_del.value = "Supprimer";
|
|
inp_del.onclick = function() { GSM_del(type, idAlbum, modif, page); };
|
|
inp_del.style.marginLeft = "15px";
|
|
formulaire.appendChild(inp_del);
|
|
}
|
|
if (modif)
|
|
$('titrechan').focus();
|
|
|
|
new Ajax.Autocompleter(
|
|
"auteur",
|
|
"auteur_propositions",
|
|
"applications/GSM/auteurs.php",
|
|
{
|
|
paramName: 'auteur',
|
|
minChars: 1
|
|
});
|
|
}
|
|
|
|
function GSM_checkChange(e)
|
|
{
|
|
if (this.value == "add")
|
|
{
|
|
if (this.id == "discAuteur")
|
|
id_name = "new_auteur";
|
|
else if (this.id == "discDece")
|
|
id_name = "new_decenie";
|
|
else if (this.id == "discAnnee")
|
|
id_name = "new_annee";
|
|
|
|
document.getElementById(id_name).style.display = "inline";
|
|
if (document.getElementById(id_name).value == "")
|
|
document.getElementById(id_name).value = "Nom du nouvel l'album";
|
|
document.getElementById(id_name).focus();
|
|
document.getElementById(id_name).select();
|
|
}
|
|
else if (this.id == "discAuteur")
|
|
document.getElementById("new_auteur").style.display = "none";
|
|
else if (this.id == "discDece")
|
|
document.getElementById("new_decenie").style.display = "none";
|
|
else if (this.id == "discAnnee")
|
|
document.getElementById("new_annee").style.display = "none";
|
|
}
|
|
|
|
function GSM_del(type, idAlbum, modif, page)
|
|
{
|
|
$('titrechan').disabled = true;
|
|
$('auteur').disabled = true;
|
|
|
|
new Ajax.Request(
|
|
'ajax.php?d=action&a=GSM&p=del',
|
|
{
|
|
method: 'post',
|
|
parameters: {id: GSM_rech.getElementsByTagName("chanson")[modif-1].getAttribute("id")},
|
|
onSuccess: function(transport, json)
|
|
{
|
|
if (json.statut != 1)
|
|
{
|
|
firstLoad();
|
|
alert("Vous avez été déconnecté. La chanson n'a pas été enregistrée");
|
|
}
|
|
else
|
|
{
|
|
setTimeout('$("confirm").innerHTML = "Chanson supprimée avec succès !";', 234);
|
|
setTimeout("$('confirm').innerHTML = '';", 3500);
|
|
|
|
$('nbpc').innerHTML = json.nombre;
|
|
|
|
if (type)
|
|
GSM_viewalbum(type, idAlbum, page);
|
|
else
|
|
GSM_viewalbum(type, idAlbum, page);
|
|
|
|
if (modif)
|
|
window.scrollTo(0,0);
|
|
}
|
|
},
|
|
onFailure: function() { printEtat(3); }
|
|
}
|
|
);
|
|
|
|
//On réinitialise les variables de liste pour aller rechercher les listes
|
|
GSM_liste = false;
|
|
GSM_pagination = false;
|
|
$('contenu').innerHTML = "<h2 class=\"vp\">Veuillez patienter suppression de la chanson en cours ...</h2>";
|
|
}
|
|
|
|
function checkAndAdd(type, idAlbum, modif, page)
|
|
{
|
|
var modifURI;
|
|
if(modif)
|
|
modifURI = "&id=" + GSM_liste[modif-1][0];
|
|
else
|
|
modifURI = "";
|
|
|
|
if ($('titrechan').value == "")
|
|
{
|
|
$('titrechan').className = "erreur";
|
|
alert('Vous n\'avez pas indiqué le titre de la chanson !');
|
|
}
|
|
else if ($('auteur').value == "")
|
|
{
|
|
$('auteur').className = "erreur";
|
|
alert('Vous n\'avez pas indiqué l\'auteur de la chanson !');
|
|
}
|
|
else
|
|
{
|
|
$('titrechan').disabled = true;
|
|
$('auteur').disabled = true;
|
|
|
|
new Ajax.Request(
|
|
'ajax.php?d=action&a=GSM' + modifURI,
|
|
{
|
|
method: 'post',
|
|
parameters: {titre: $('titrechan').value, auteur: $('auteur').value, type: type, alb: idAlbum},
|
|
onSuccess: function(transport, json)
|
|
{
|
|
if (json.statut != 1)
|
|
{
|
|
firstLoad();
|
|
alert("Vous avez été déconnecté. La chanson n'a pas été enregistrée");
|
|
}
|
|
else
|
|
{
|
|
if(modif)
|
|
{
|
|
setTimeout('$("confirm").innerHTML = "Chanson modifiée avec succès !";', 234);
|
|
setTimeout("$('confirm').innerHTML = '';", 3500);
|
|
|
|
GSM_liste[modif-1][1] = $('titrechan').value;
|
|
GSM_liste[modif-1][2] = $('auteur').value;
|
|
}
|
|
else
|
|
{
|
|
GSM_origin_liste.push([transport.responseXML.documentElement.getElementsByTagName("id")[0].textContent, $('titrechan').value, $('auteur').value, (type==1?idAlbum:0), (type==2?idAlbum:0), (type==3?idAlbum:0)]);
|
|
$('titrechan').value = "";
|
|
$('auteur').value = "";
|
|
|
|
$('titrechan').disabled = false;
|
|
$('auteur').disabled = false;
|
|
|
|
$('nbpc').innerHTML = json.nombre;
|
|
|
|
setTimeout('$("confirm").innerHTML = "Chanson ajoutée avec succès !";', 234);
|
|
setTimeout("$('confirm').innerHTML = '';", 3500);
|
|
}
|
|
|
|
if (type)
|
|
GSM_viewalbum(type, idAlbum, page);
|
|
else
|
|
//TODO à tester ça marche pas
|
|
GSM_viewliste(null, null, page);
|
|
|
|
if (modif)
|
|
window.scrollTo(0,0);
|
|
else
|
|
$('titrechan').focus();
|
|
}
|
|
},
|
|
onFailure: function() { printEtat(3); }
|
|
}
|
|
);
|
|
}
|
|
}
|
|
|
|
function GSM_viewalbums()
|
|
{
|
|
if (GSM_origin_liste == false)
|
|
setTimeout(GSM_viewalbums, 200);
|
|
else
|
|
{
|
|
var tableau = document.createElement("div");
|
|
tableau.className = "table cols2 stats";
|
|
tableau.id = "statsA";
|
|
var tableau_head = document.createElement("div");
|
|
tableau_head.className = "head";
|
|
var head_th = document.createElement("span");
|
|
head_th.innerHTML = "CD années";
|
|
tableau_head.appendChild(head_th);
|
|
var head_th = document.createElement("span");
|
|
head_th.innerHTML = "Nombre";
|
|
tableau_head.appendChild(head_th);
|
|
tableau.appendChild(tableau_head);
|
|
var tableau_bodyA = document.createElement("div");
|
|
tableau_bodyA.className = "body";
|
|
tableau_bodyA.innerHTML = '<div class="lign elt0 foot">Chargement de la liste ... <img src="applications/GSM/loader.gif" alt="Veuillez patienter"></div>';
|
|
tableau.appendChild(tableau_bodyA);
|
|
$('contenu').appendChild(tableau);
|
|
|
|
var tableau = document.createElement("div");
|
|
tableau.className = "table cols2 stats";
|
|
tableau.id = "statsC";
|
|
var tableau_head = document.createElement("div");
|
|
tableau_head.className = "head";
|
|
var head_th = document.createElement("span");
|
|
head_th.innerHTML = "CD chanteurs";
|
|
tableau_head.appendChild(head_th);
|
|
var head_th = document.createElement("span");
|
|
head_th.innerHTML = "Nombre";
|
|
tableau_head.appendChild(head_th);
|
|
tableau.appendChild(tableau_head);
|
|
var tableau_bodyC = document.createElement("div");
|
|
tableau_bodyC.className = "body";
|
|
tableau_bodyC.innerHTML = '<div class="lign elt0 foot">Chargement de la liste ... <img src="applications/GSM/loader.gif" alt="Veuillez patienter"></div>';
|
|
tableau.appendChild(tableau_bodyC);
|
|
$('contenu').appendChild(tableau);
|
|
|
|
var tableau = document.createElement("div");
|
|
tableau.className = "table cols2 stats";
|
|
tableau.id = "statsD";
|
|
var tableau_head = document.createElement("div");
|
|
tableau_head.className = "head";
|
|
var head_th = document.createElement("span");
|
|
head_th.innerHTML = "CD décénies";
|
|
tableau_head.appendChild(head_th);
|
|
var head_th = document.createElement("span");
|
|
head_th.innerHTML = "Nombre";
|
|
tableau_head.appendChild(head_th);
|
|
tableau.appendChild(tableau_head);
|
|
var tableau_bodyD = document.createElement("div");
|
|
tableau_bodyD.className = "body";
|
|
tableau_bodyD.innerHTML = '<div class="lign elt0 foot">Chargement de la liste ... <img src="applications/GSM/loader.gif" alt="Veuillez patienter"></div>';
|
|
tableau.appendChild(tableau_bodyD);
|
|
$('contenu').appendChild(tableau);
|
|
|
|
|
|
new Ajax.Request(
|
|
'ajax.php',
|
|
{
|
|
method: 'get',
|
|
parameters: {d: "action", a: "GSM", p: "stats"},
|
|
onSuccess: function(transport, json)
|
|
{
|
|
var annees = transport.responseXML.documentElement.getElementsByTagName("annee");
|
|
var chanteurs = transport.responseXML.documentElement.getElementsByTagName("interprete");
|
|
var decenies = transport.responseXML.documentElement.getElementsByTagName("decenie");
|
|
|
|
tableau_bodyA.innerHTML = "";
|
|
for (var i = 0; i < annees.length; i++)
|
|
{
|
|
if (annees[i].getAttribute("id") != "")
|
|
{
|
|
var lign = document.createElement("div");
|
|
lign.className = "elt" + (i%2);
|
|
GSM_addStatLign(lign, 1, annees[i].getAttribute("id"));
|
|
var col = document.createElement("span");
|
|
col.innerHTML = GSM_liste_CDA[annees[i].getAttribute("id")];
|
|
lign.appendChild(col);
|
|
var col = document.createElement("span");
|
|
col.innerHTML = annees[i].getAttribute("nbTitles");
|
|
lign.appendChild(col);
|
|
tableau_bodyA.appendChild(lign);
|
|
}
|
|
}
|
|
if (annees.length == 0)
|
|
tableau_bodyA.innerHTML = '<div class="lign elt0 foot">Aucun CD</div>';
|
|
else
|
|
lign.className += " foot";
|
|
|
|
tableau_bodyC.innerHTML = "";
|
|
for (var i = 0; i < chanteurs.length; i++)
|
|
{
|
|
if (chanteurs[i].getAttribute("id") != "")
|
|
{
|
|
var lign = document.createElement("div");
|
|
lign.className = "elt" + (i%2);
|
|
GSM_addStatLign(lign, 2, chanteurs[i].getAttribute("id"));
|
|
var col = document.createElement("span");
|
|
col.innerHTML = GSM_liste_CDC[chanteurs[i].getAttribute("id")];
|
|
lign.appendChild(col);
|
|
var col = document.createElement("span");
|
|
col.innerHTML = chanteurs[i].getAttribute("nbTitles");
|
|
lign.appendChild(col);
|
|
tableau_bodyC.appendChild(lign);
|
|
}
|
|
}
|
|
if (chanteurs.length == 0)
|
|
tableau_bodyC.innerHTML = '<div class="lign elt0 foot">Aucun CD</div>';
|
|
else
|
|
lign.className += " foot";
|
|
|
|
tableau_bodyD.innerHTML = "";
|
|
for (var i = 0; i < decenies.length; i++)
|
|
{
|
|
if (decenies[i].getAttribute("id") != "")
|
|
{
|
|
var lign = document.createElement("div");
|
|
lign.className = "elt" + (i%2);
|
|
GSM_addStatLign(lign, 3, decenies[i].getAttribute("id"));
|
|
var col = document.createElement("span");
|
|
col.innerHTML = GSM_liste_CDD[decenies[i].getAttribute("id")];
|
|
lign.appendChild(col);
|
|
var col = document.createElement("span");
|
|
col.innerHTML = decenies[i].getAttribute("nbTitles");
|
|
lign.appendChild(col);
|
|
tableau_bodyD.appendChild(lign);
|
|
}
|
|
}
|
|
if (decenies.length == 0)
|
|
tableau_bodyD.innerHTML = '<div class="lign elt0 foot">Aucun CD</div>';
|
|
else
|
|
lign.className += " foot";
|
|
},
|
|
onFailure: function() { printEtat(3); }
|
|
}
|
|
);
|
|
}
|
|
}
|
|
|
|
function GSM_addStatLign(lign, type, id)
|
|
{
|
|
lign.onclick = function() { window.scrollTo(0,0); GSM_viewalbum(type, id, 0) };
|
|
}
|
|
|
|
function GSM_viewalbum(type, id, page)
|
|
{
|
|
$('contenu').innerHTML = "";
|
|
var confirmation = document.createElement("h2");
|
|
confirmation.style.color = "teal";
|
|
confirmation.id = "confirm";
|
|
|
|
var titre = document.createElement("h2");
|
|
if (type == 2)
|
|
{
|
|
titre.innerHTML = "Liste des titres de " + GSM_liste_CDC[id];
|
|
$('contenu').appendChild(titre);
|
|
$('contenu').appendChild(confirmation);
|
|
GSM_delay_viewalbum(2, id, page);
|
|
}
|
|
else if (type == 3)
|
|
{
|
|
titre.innerHTML = "Liste des titres de " + GSM_liste_CDD[id];
|
|
$('contenu').appendChild(titre);
|
|
$('contenu').appendChild(confirmation);
|
|
GSM_delay_viewalbum(3, id, page);
|
|
}
|
|
else
|
|
{
|
|
titre.innerHTML = "Liste des titres de " + GSM_liste_CDA[id];
|
|
$('contenu').appendChild(titre);
|
|
$('contenu').appendChild(confirmation);
|
|
GSM_delay_viewalbum(1, id, page);
|
|
}
|
|
}
|
|
|
|
function GSM_delay_viewalbum(type, id, page)
|
|
{
|
|
if (GSM_origin_liste == false)
|
|
GSM_delay = setTimeout(GSM_delay_viewalbum, 200, type, id, page);
|
|
else
|
|
{
|
|
GSM_liste = new Array();
|
|
for (var i = 0; i < GSM_origin_liste.length; i++)
|
|
{
|
|
if (GSM_origin_liste[i][type+2] == id)
|
|
GSM_liste.push(GSM_origin_liste[i]);
|
|
}
|
|
if (GSM_liste == false)
|
|
GSM_liste[0] = 2;
|
|
|
|
GSM_lastSort = -1;
|
|
|
|
GSM_viewliste(type, id, page);
|
|
|
|
GSM_addForm(type, id, false, 0);
|
|
}
|
|
}
|
|
|
|
function GSM_viewliste(type, idAlbum, page)
|
|
{
|
|
var pagination = document.createElement("div");
|
|
pagination.className = "pagination top";
|
|
pagination.id = "pagination1";
|
|
$('contenu').appendChild(pagination);
|
|
|
|
var tableau = document.createElement("div");
|
|
tableau.className = "table cols3";
|
|
tableau.id = "list";
|
|
var tableau_head = document.createElement("div");
|
|
tableau_head.className = "head";
|
|
var head_th = document.createElement("span");
|
|
head_th.innerHTML = "Titre";
|
|
head_th.onclick = function() { GSM_showliste(1, 0, type, idAlbum); }
|
|
tableau_head.appendChild(head_th);
|
|
var head_th = document.createElement("span");
|
|
head_th.innerHTML = "Chanteur";
|
|
head_th.onclick = function() { GSM_showliste(2, 0, type, idAlbum); }
|
|
tableau_head.appendChild(head_th);
|
|
var head_th = document.createElement("span");
|
|
head_th.innerHTML = "CDs";
|
|
head_th.style.cursor = "auto";
|
|
tableau_head.appendChild(head_th);
|
|
tableau.appendChild(tableau_head);
|
|
var tableau_body = document.createElement("div");
|
|
tableau_body.className = "body";
|
|
tableau_body.id = "bodyList";
|
|
tableau_body.innerHTML = '<div class="lign elt0 foot">Chargement de la liste en cours ... <img src="applications/GSM/loader.gif" alt="Veuillez patienter"></div>';
|
|
tableau.appendChild(tableau_body);
|
|
$('contenu').appendChild(tableau);
|
|
|
|
|
|
var pagination = document.createElement("div");
|
|
pagination.className = "pagination bottom";
|
|
pagination.id = "pagination2";
|
|
$('contenu').appendChild(pagination);
|
|
|
|
GSM_showliste(-1, page, type, idAlbum);
|
|
}
|
|
|
|
function GSM_showliste(tri, page, type, idAlbum)
|
|
{
|
|
if (GSM_origin_liste == false)
|
|
setTimeout(GSM_showliste, 200, tri, page, type, idAlbum);
|
|
else
|
|
{
|
|
if (GSM_liste == false)
|
|
GSM_liste = GSM_origin_liste;
|
|
|
|
//On tente un tri
|
|
if (GSM_lastSort != tri)
|
|
{
|
|
$('bodyList').innerHTML = '<div class="lign elt0 foot">Tri de la liste en cours ...</div>';
|
|
GSM_liste = GSM_liste.sort(function(a,b){return a[tri].localeCompare(b[tri]);});
|
|
GSM_lastSort = tri;
|
|
}
|
|
|
|
nbPages = Math.ceil(GSM_liste.length / nbParPage);
|
|
$('pagination1').innerHTML = "";
|
|
$('pagination2').innerHTML = "";
|
|
|
|
if (nbPages < 3)
|
|
{
|
|
var lnkP = document.createElement("a");
|
|
lnkP.href = "javascript:GSM_printliste(" + GSM_lastSort + ", " + type + ", " + idAlbum + ");";
|
|
lnkP.innerHTML = "Imprimer la pochette";
|
|
$('pagination1').appendChild(lnkP);
|
|
var lnkP = document.createElement("a");
|
|
lnkP.href = "javascript:GSM_printliste(" + GSM_lastSort + ", " + type + ", " + idAlbum + ");";
|
|
lnkP.innerHTML = "Imprimer la pochette";
|
|
$('pagination2').appendChild(lnkP);
|
|
}
|
|
|
|
for (var i = 0; i < 4 && i < nbPages; i++)
|
|
GSM_addLinkPagination(i, type, idAlbum);
|
|
if (page > 5 && i < nbPages)
|
|
{
|
|
$('pagination1').innerHTML += "...";
|
|
$('pagination2').innerHTML += "...";
|
|
}
|
|
for (var i = (page < 6?4:page - 2); (i < page + 3 && i < nbPages); i++)
|
|
GSM_addLinkPagination(i, type, idAlbum);
|
|
if (page <= 5 && i < nbPages)
|
|
{
|
|
$('pagination1').innerHTML += "...";
|
|
$('pagination2').innerHTML += "...";
|
|
for (var i = Math.ceil(nbPages/2) - 2; i < nbPages/2 + 2; i++)
|
|
GSM_addLinkPagination(i, type, idAlbum);
|
|
}
|
|
if (page + 3 < nbPages - 4)
|
|
{
|
|
$('pagination1').innerHTML += "...";
|
|
$('pagination2').innerHTML += "...";
|
|
}
|
|
for (var i = (page + 3 >= nbPages - 4?page + 3:nbPages - 4); (i < nbPages); i++)
|
|
GSM_addLinkPagination(i, type, idAlbum);
|
|
|
|
start = page * nbParPage;
|
|
$('bodyList').innerHTML = "";
|
|
|
|
if (GSM_liste[0] != 2)
|
|
{
|
|
for (var i = 0; i < nbParPage && i + start < GSM_liste.length; i++)
|
|
{
|
|
var lign = document.createElement("div");
|
|
lign.className = "elt" + (i%2);
|
|
|
|
GSM_addLinkCD(lign, i + start, idAlbum, type, page);
|
|
var col = document.createElement("span");
|
|
col.innerHTML = GSM_liste[i + start][1];
|
|
lign.appendChild(col);
|
|
var col = document.createElement("span");
|
|
col.innerHTML = GSM_liste[i + start][2];
|
|
lign.appendChild(col);
|
|
var col = document.createElement("span");
|
|
if (GSM_liste[i + start][3] != 0)
|
|
col.innerHTML += GSM_liste_CDA[GSM_liste[i + start][3]] + "<br>";
|
|
if (GSM_liste[i + start][4] != 0)
|
|
col.innerHTML += GSM_liste_CDC[GSM_liste[i + start][4]] + "<br>";
|
|
if (GSM_liste[i + start][5] != 0)
|
|
col.innerHTML += GSM_liste_CDD[GSM_liste[i + start][5]];
|
|
lign.appendChild(col);
|
|
$('bodyList').appendChild(lign);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var lign = document.createElement("div");
|
|
lign.className = "elt0";
|
|
lign.innerHTML = "Il n'y a aucun titre enregistré dans cet album.";
|
|
$('bodyList').appendChild(lign);
|
|
}
|
|
lign.className += " foot";
|
|
}
|
|
}
|
|
function GSM_addLinkPagination(page, type, idAlbum)
|
|
{
|
|
var lnkP = document.createElement("a");
|
|
lnkP.href = "javascript:GSM_showliste(" + GSM_lastSort + ", " + page + ", " + type + ", " + idAlbum + ");";
|
|
lnkP.innerHTML = page+1;
|
|
$('pagination1').appendChild(lnkP);
|
|
var lnkP = document.createElement("a");
|
|
lnkP.href = "javascript:GSM_showliste(" + GSM_lastSort + ", " + page + ", " + type + ", " + idAlbum + ");";
|
|
lnkP.innerHTML = page+1;
|
|
$('pagination2').appendChild(lnkP);
|
|
}
|
|
|
|
function GSM_printliste(tri, type, idAlbum)
|
|
{
|
|
if (GSM_origin_liste == false)
|
|
setTimeout(GSM_printliste, 200, tri, type, idAlbum);
|
|
else
|
|
{
|
|
$('contenu').innerHTML = "";
|
|
|
|
var listeT;
|
|
if (type == 2)
|
|
listeT = GSM_liste_CDC;
|
|
else if (type == 3)
|
|
listeT = GSM_liste_CDD;
|
|
else
|
|
listeT = GSM_liste_CDA;
|
|
|
|
var patt1 = listeT[idAlbum].match(/cd ?([0-9]+)/i).toString();
|
|
var trueTitleL1 = listeT[idAlbum];
|
|
trueTitleL1 = trueTitleL1.substr(0, trueTitleL1.length - patt1.indexOf(','));
|
|
if (type == 1)
|
|
trueTitleL1 = "Année " + trueTitleL1;
|
|
|
|
var trueTitleL2;
|
|
if (patt1)
|
|
trueTitleL2 = "CD " + patt1.substr(patt1.indexOf(',')+1);
|
|
else
|
|
trueTitleL2 = "";
|
|
|
|
var trueTitle = trueTitleL1 + " – " + trueTitleL2;
|
|
|
|
var front = document.createElement("div");
|
|
front.className = "front";
|
|
var titleP = document.createElement("div");
|
|
titleP.className = "title";
|
|
titleP.innerHTML = trueTitleL1;
|
|
front.appendChild(titleP);
|
|
var cd = document.createElement("div");
|
|
cd.className = "cd";
|
|
cd.innerHTML = trueTitleL2;
|
|
if (trueTitleL2)
|
|
cd.style.marginTop = "70px";
|
|
front.appendChild(cd);
|
|
$('contenu').appendChild(front);
|
|
|
|
new Ajax.Request(
|
|
'ajax.php',
|
|
{
|
|
method: 'get',
|
|
parameters: {d: "action", a: "GSM", p: "color", type: type, id: idAlbum},
|
|
onSuccess: function(transport, json)
|
|
{
|
|
var colors = transport.responseXML.documentElement.getElementsByTagName("color");
|
|
if (colors.length == 2)
|
|
{
|
|
titleP.style.color = colors[1].firstChild.textContent;
|
|
cd.style.color = colors[0].firstChild.textContent;
|
|
}
|
|
else if (colors.length == 1)
|
|
{
|
|
titleP.style.color = colors[0].firstChild.textContent;
|
|
cd.style.color = colors[0].firstChild.textContent;
|
|
}
|
|
}
|
|
});
|
|
|
|
var sp = document.createElement("div");
|
|
sp.className = "sp";
|
|
$('contenu').appendChild(sp);
|
|
|
|
var back = document.createElement("div");
|
|
back.className = "back";
|
|
var backL = document.createElement("div");
|
|
backL.className = "left";
|
|
var title = document.createElement("div");
|
|
title.className = "title";
|
|
title.innerHTML = trueTitleL1 + " " + trueTitleL2;
|
|
backL.appendChild(title);
|
|
back.appendChild(backL);
|
|
var backR = document.createElement("div");
|
|
backR.className = "right";
|
|
var title = document.createElement("div");
|
|
title.className = "title";
|
|
title.innerHTML = trueTitleL1 + " " + trueTitleL2;
|
|
backR.appendChild(title);
|
|
back.appendChild(backR);
|
|
|
|
var backC = document.createElement("div");
|
|
backC.className = "center";
|
|
var title = document.createElement("div");
|
|
title.className = "title";
|
|
title.innerHTML = trueTitleL1 + " – " + trueTitleL2;
|
|
backC.appendChild(title);
|
|
|
|
var listeC = document.createElement("ol");
|
|
backC.appendChild(listeC);
|
|
|
|
back.appendChild(backC);
|
|
$('contenu').appendChild(back);
|
|
|
|
if (GSM_liste == false)
|
|
GSM_liste = GSM_origin_liste;
|
|
|
|
//On tente un tri
|
|
if (GSM_lastSort != tri)
|
|
{
|
|
GSM_liste = GSM_liste.sort(function(a,b){return a[tri].localeCompare(b[tri]);});
|
|
GSM_lastSort = tri;
|
|
}
|
|
|
|
if (GSM_liste[0] != 2)
|
|
{
|
|
for (var i = 0; i < GSM_liste.length; i++)
|
|
{
|
|
var lign = document.createElement("li");
|
|
lign.className = "elt" + (i%2);
|
|
lign.innerHTML = GSM_liste[i + start][1]
|
|
var col = document.createElement("span");
|
|
col.className = "author";
|
|
col.innerHTML = GSM_liste[i + start][2];
|
|
lign.appendChild(col);
|
|
GSM_addLinkOrder(lign, i + start, tri, type, idAlbum);
|
|
listeC.appendChild(lign);
|
|
}
|
|
|
|
//On ajuste automatiquement la taille de la police
|
|
listeC.style.fontSize = Math.floor(4000/(GSM_liste.length*1.35))/10 + "px";
|
|
listeC.style.marginTop = ((400 - listeC.clientHeight) / 2) + "px";
|
|
}
|
|
else
|
|
{
|
|
var lign = document.createElement("div");
|
|
lign.className = "elt0";
|
|
lign.innerHTML = "Il n'y a aucun titre enregistré dans cet album.";
|
|
$('bodyList').appendChild(lign);
|
|
}
|
|
lign.className += " foot";
|
|
}
|
|
}
|
|
|
|
function GSM_addLinkCD(elt, idTitle, idAlbum, type, page)
|
|
{
|
|
elt.onclick = function() {
|
|
GSM_addForm(type, idAlbum, idTitle+1, page);
|
|
}
|
|
}
|
|
|
|
function GSM_addLinkOrder(elt, id, tri, type, idAlbum)
|
|
{
|
|
elt.onclick = function() {
|
|
GSM_chOrder(id, tri, type, idAlbum);
|
|
}
|
|
}
|
|
function GSM_chOrder(id, tri, type, idAlbum)
|
|
{
|
|
var num = prompt("Quel est le numéro de cette chanson : ", id+1);
|
|
if (num > 0 && num <= GSM_liste.length)
|
|
{
|
|
if (num != id)
|
|
{
|
|
var tmp = GSM_liste[num-1];
|
|
GSM_liste[num-1] = GSM_liste[id];
|
|
GSM_liste[id] = tmp;
|
|
|
|
GSM_printliste(tri, type, idAlbum);
|
|
}
|
|
}
|
|
else
|
|
alert("Ce nombre n'est pas valide !\nLe numéro de la chanson doit être compris entre 1 et " + GSM_liste.length);
|
|
}
|
|
|
|
function GSM_apropos()
|
|
{
|
|
aproposApp("GSM", "contenu");
|
|
} |