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
| $(document).ready(function(){
$('#menu').on("click", "a", function(){
page=($(this).attr("href"));
id=$(this).attr("id");
$.ajax({
url: page,
success : function(){
$('#corps').load(page);
for (i=1; i<=10; i++){
document.getElementById('a'+i).style.color='#002822';
document.getElementById('a'+i).style.backgroundColor='#FFFFFF';
}
document.getElementById('corps').scrollTop=0;
document.getElementById(id).style.color='#FFFFFF';
document.getElementById(id).style.backgroundColor='#002822';
},
error : function(XMLHttpRequest, textStatus, errorThrows){alert('erreur système');}
});
return false;
});
actualisation();
});
function actualisation(){
for (i=1; i<=10; i++){
if("#ffffff"==colorToHex($('#a'+i).css("color"))){
if(i!=1){$('#a1').css("background-color", "#ffffff");
$('#a1').css("color", "#002822");
}
page=($('#a'+i).attr("href"));
$('#corps').load(page);
}
}
}
function colorToHex(color) {
if (color.substr(0, 1) === '#') {
return color;
}
var digits = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(color);
var red = parseInt(digits[2]);
var green = parseInt(digits[3]);
var blue = parseInt(digits[4]);
var rgb = blue | (green << 8) | (red << 16);
return digits[1] + '#' + rgb.toString(16);
}; |
Partager