/*
* EN-Addons
* разукрашенная статистика с бегунком времени
*
* Tucker http://56.en.cx/UserDetails.aspx?uid=19577
*
* http://world.en.cx/Guestbook/Messages.aspx?page=1000&topic=26337
*
*/
var PreviousTeam = new Array();
var ColorNum = 0;
var ColorsCnt = 19
function Highlight(tu,id) {
if(PreviousTeam[id] && PreviousTeam[id] != 0) {
$('a[href$="'+tu+'id='+id+'"]').parents("td").removeClass("tuckstat"+PreviousTeam[id]);
PreviousTeam[id]=0;
} else {
ColorNum++;
if(ColorNum > ColorsCnt) {
ColorNum = 1;
}
PreviousTeam[id]=ColorNum;
$('a[href$="'+tu+'id='+id+'"]').parents("td").addClass("tuckstat"+ColorNum);
}
return false;
}
// *******************************************
function highlightStat(){
if ($("a[href*='?tid=']").eq(0).length) {
wa_type = 't';
} else if ($("a[href*='?uid=']").eq(0).length) {
wa_type = 'u';
}
$("a[href*='?"+wa_type+"id=']").each(function(el) {
wa_re = new RegExp(wa_type+'id=(\\d+)');
wa_id = $(this).attr('href').match(wa_re)[1];
$(this).parent().prepend('
');
});
}
// track
var times = [];
var times_pos = [];
function setTime(l) {
$('#timeStep').eq(0).html('Шаг: '+(l)+'
Время: '+times[l-1][0].substring(6,8)+'.'+times[l-1][0].substring(4,6)+'.'+times[l-1][0].substring(0,4)+' '+times[l-1][0].substring(8,10)+':'+times[l-1][0].substring(10,12)+':'+times[l-1][0].substring(12,14)+'.'+times[l-1][0].substring(14,17));
timeStat(l-1);
}
function timeStat(p_pos) {
wa_tmp = 0;
$(".dataCell").each(function(el) {
if (times_pos[wa_tmp]<=p_pos) {
$(this).children().show();
} else {
$(this).children().hide();
}
wa_tmp++;
});
}
function prevStep(){
if (trackbar.getObject('track').leftValue > trackbar.getObject('track').leftLimit) {
trackbar.getObject('track').updateLeftValue(trackbar.getObject('track').leftValue-1);
setTime(trackbar.getObject('track').leftValue);
}
}
function nextStep(){
if (trackbar.getObject('track').rightValue < trackbar.getObject('track').rightLimit) {
trackbar.getObject('track').updateRightValue(trackbar.getObject('track').rightValue+1);
setTime(trackbar.getObject('track').rightValue);
}
}
function displayTrack(){
// добавление бегунка перед таблицей
$("#GameStatObject_DataTable").before('\
\
\
Управление бегунком: влево - Ctrl-<, вправо - Ctrl->\
\
\
');
// получение времени ячеек
$(".dataCell").each(function(el) {
var tmp_res = $(this).text().match(/(\d\d)\.(\d\d)\.(\d\d\d\d).*(\d\d)\:(\d\d)\:(\d\d)\.(\d\d\d)/);
tmp_res.shift();
tmp_tmp = tmp_res[2]; tmp_res[2] = tmp_res[0]; tmp_res[0] = tmp_tmp;
times[times.length] = [tmp_res.join(''),times.length];
$(this).wrapInner("");
});
times.sort();
for (i in times) {times_pos[times[i][1]]=i;}
trackbar.getObject('track').init({
onMove : function() {
setTime(this.leftValue);
},
dual : false, // two intervals
width : 700, // px
leftLimit : 1, // unit of value
leftValue : times.length, // unit of value
rightLimit : times.length, // unit of value
rightValue : times.length, // unit of value
clearLimits : true,
clearValues : true,
showBigTicks : true,
bigTicks : 10
},
"level-track");
// регистрация события "Нажатие клавиши Ctrl-< и Ctrl->"
document.onkeydown = function (e){
if (e.ctrlKey && (e.keyCode == 188 || e.keyCode == 1041)) {prevStep();}
else if (e.ctrlKey && (e.keyCode == 190 || e.keyCode == 1070)) {nextStep();};
}
}