JavaLikeCalc.JavaScript
curTm = SYS.time();
if(n == 0 && !time) { time = curTm; bTime = time - 30; }
size_en = tmTp_en = Text1_en = Text2_en = prev1_en = next1_en = date_en = dateBeg_en = !n;
szVal = time - bTime;

//Archive size
if(n) {
	if(vCur >= 0)	cPos = aCur - vCur;
	if(cPos < 0)		cPos += aSize;
	Text3_text = Text3_text.parse(0,"\n") + "\n" + (cPos+1) + "(" + aSize + ")";
}
else Text3_text = Text3_text.parse(0,"\n");

//Events process
prevTime = time;
for(off = 0, ev_rez = ""; (ev_cur=event.parse(0,"\n",off)).length; ) {
	//SYS.messInfo("Trend control","Event: "+ev_cur);
	if(ev_cur == "ws_LnAccept:/size" || ev_cur == "ws_CombChange:/tmTp") {
		szVal = size_value;
		if(tmTp_value == tr("m"))			szVal = szVal*60;
		else if(tmTp_value == tr("h"))	szVal = szVal*60*60;
		else if(tmTp_value == tr("d"))	szVal = szVal*24*60*60;
		else if(tmTp_value.search("\\d+"+tr("s")) >= 0)	szVal = tmTp_value.toInt();
		else if(tmTp_value.search("\\d+"+tr("m")) >= 0)	szVal = tmTp_value.toInt()*60;
		else if(tmTp_value.search("\\d+"+tr("h")) >= 0)	szVal = tmTp_value.toInt()*60*60;
		else if(tmTp_value.search("\\d+"+tr("d")) >= 0)	szVal = tmTp_value.toInt()*24*60*60;
		time += 1;
	}
	else if(ev_cur == "ws_LnAccept:/dateBeg") { szVal = max(1, date_value-dateBeg_value); time += 1; }
	else if(ev_cur == "ws_LnAccept:/date") time = min(curTm, max(szVal,date_value));
	else if(ev_cur == "ws_BtPress:/curtime") {	
		if(n == 0) time = curTm;
		else vCur = aCur;
	}
	else if(ev_cur == "ws_BtPress:/prev") {
		if(n == 0) time = min(curTm, max(szVal,time-szVal));
		else vCur = -2;
	}
	else if(ev_cur == "ws_BtPress:/next") {
		if(n == 0) time = min(curTm, max(szVal,time+szVal)); 
		else vCur = -1;
	}
	else if(ev_cur == "ws_BtPress:/prev1") time = min(curTm, max(5*szVal,time-5*szVal));
	else if(ev_cur == "ws_BtPress:/next1") time = min(curTm, max(5*szVal,time+5*szVal));
	else ev_rez += (ev_cur+"\n");
}
event = ev_rez;

//Time control
date_value = time;
if(n == 0 && prevTime != time) { bTime = time - szVal; doc=""; }
if(szVal < 60)						{ tmTp_value = tr("s"); size_value = szVal; }
else if(szVal < 60*60)			{ tmTp_value = tr("m"); size_value = szVal/60; }
else if(szVal < 24*60*60)	{ tmTp_value = tr("h"); size_value = szVal/(60*60); }
else									{ tmTp_value = tr("d"); size_value = szVal/(24*60*60); }
dateBeg_value = date_value - szVal;