1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| ///////////// autre fonction de colorisation des équipements indépendante de sélection des lignes
function selectedref(id, i, j){
var elem = document.getElementById(id);
if (Data[i][j][2] == true)
return ((elem.style.color = '#000') ^ (elem.style.background = '#FFF') ^
(Data[i][j][2] = false));
return ((elem.style.color = '#FFF') ^ (elem.style.background = '#AF0F00') ^
(Data[i][j][2] = true));
}
//////////////////////////// la fonction de colorisation des boutons des équipement lors d`une sélection des lignes
var code = 'undefined';
var count = 1;
function ChangeColor(elem,code){
var x = document.getElementById(elem);
var i = eval(elem);
var len = Data[i].length;
for(var j=0; j<len; j++){
var y = document.getElementById(Data[i][j][0]);
if(count == 0){
x.style.backgroundColor = '#f0f0f0'; // le gris
y.style.backgroundColor = '#FF0066'; //rose
count = 1;
}else{
x.style.backgroundColor = code;
y.style.backgroundColor = '#FFFF00';// jaune
count = 0;
}
}
}
// affichage des donnes a partir Data sous la forme des boutons
function genBtnByLine(myData){
Data = JSON.parse(myData);
var str = '';
for(var i=0; i<4; i++){
var len = Data[i].length;
var textcolor = ['#33cc66', '#ffbb21', '#e00707', '#8ebbeb'];
// les lignes
str += '<button type=button id=' + i + ' onclick=ChangeColor(\'' + i + '\',\'' + textcolor[i] + '\');>Line ' + (i + 1) +
' : <br\></button><div class=\'btn-group btn-group-sm\'>';
for (var j=0; j<len; j++){
Data[i][j][0] = Data[i][j][0].replace(/ /g, '..');
str += '<button type=button value=' + Data[i][j][0] +
' id=' + Data[i][j][0] + ' onclick=selectedref(\'' + Data[i][j][0] + '\',' + i + ',' + j +
'); class=\'btn btn-default\' title=\'' + Data[i][j][1] + '\'>' +
Data[i][j][0]+'</button>';
Data[i][j][2] = false;
}
str += '</div></br>';
}
document.getElementById('refbyline').innerHTML = str;
}
// chargement des donnees sur la page
jQuery.ajax({
url : abspth + 'getrefbyline.php',
type : 'GET',
success : function(Data){genBtnByLine(Data)}
}); |
Partager