JavaLikeCalc.JavaScript
curTm = SYS.time();
tSek = tSek ? tSek : curTm;

//Archivators real list forming
if(f_start) {
	arch_items = tr("All");
	mods = SYS.Archive.nodeList("mod_");
	for(i_m = 0; i_m < mods.length; i_m++) {
		vas = SYS.Archive[mods[i_m]].nodeList("val_");
		for(i_va = 0; i_va < vas.length; i_va++)
			arch_items += "\n"+mods[i_m].slice(4)+"."+vas[i_va].slice(4);
	}

	trcPer_ = max(1, trcPer);
}

//Events process
for(/*ev_rez = "", */off = 0; (evCur=event.parse(0,"\n",off)).length; ) {
	//SYS.messInfo("Trend control", "Event: "+evCur);
	if(evCur == "ws_LnAccept:/size")
		size_value = SYS.time2str(tSize=SYS.str2time(size_value,false), false);
	else if(evCur == "ws_LnAccept:/dateBeg")
		tSize = max(1, date_value-dateBeg_value);
	else if(evCur == "ws_BtPress:/curstimeBeg")	{ tSize = max(1, tSek-curSek); }
	else if(evCur == "ws_LnAccept:/date")		{ tSek = date_value; if(sclWin == true) sclWin = false; }
	else if(evCur == "ws_BtPress:/curtime")	{ tSek = curSek = curTm; if(sclWin == true) sclWin = false; }
	else if(evCur == "ws_BtPress:/curstime")	{ tSek = curSek; if(sclWin == true) sclWin = false; }
	else if(evCur == "ws_BtPress:/prev")		{ tSek -= tSize/2; if(sclWin == true) sclWin = false; }
	else if(evCur == "ws_BtPress:/prev1")		{ tSek -= 5*tSize; if(sclWin == true) sclWin = false; }
	else if(evCur == "ws_BtPress:/next")		{ tSek += tSize/2; if(sclWin == true) sclWin = false; }
	else if(evCur == "ws_BtPress:/next1")		{ tSek += 5*tSize; if(sclWin == true) sclWin = false; }
	else if(evCur == "ws_CombChange:/arch")	valArch=(arch_value==tr("All")) ? "" : arch_value;
	else if(evCur == "ws_CombChange:/type")	{ type = (type_value==tr("Spectrum"))?1:((type_value==tr("XY"))?2:0); if(sclWin == true) sclWin = false; }
	else if(evCur == "ws_BtPress:/zoomIn")		{ sclVer *= 0.9; if(sclWin == true) sclWin = false; }
	else if(evCur == "ws_BtPress:/zoomOut")	{ sclVer *= 1.1; if(sclWin == true) sclWin = false; }
	else if(evCur == "ws_BtPress:/zoomOffUp")	{ sclVerOff += sclVer/10; if(sclWin == true) sclWin = false; }
	else if(evCur == "ws_BtPress:/zoomOffDown")	{ sclVerOff -= sclVer/10; if(sclWin == true) sclWin = false; }
	else if(evCur == "ws_BtPress:/zoomDef")	{ sclVer = 100, sclVerOff = 0; if(sclWin == true) sclWin = false; }
	else if(evCur == "ws_BtPress:/xZoomIn")	sclHor *= 0.9;
	else if(evCur == "ws_BtPress:/xZoomOut")	sclHor *= 1.1;
	else if(evCur == "ws_BtPress:/xZoomOffRight")sclHorOff += sclHor/10;
	else if(evCur == "ws_BtPress:/xZoomOffLeft") sclHorOff -= sclHor/10;
	else if(evCur == "ws_BtPress:/xZoomDef")	sclHor = 100, sclHorOff = 0;
	else if(evCur == "ws_BtToggleChange:/selWin") {
		if(selWin_value && !sclWinCtx.isEVal()) {
			sclWinCtx.tSek = tSek; sclWinCtx.tSize = tSize; sclWinCtx.sclVer = sclVer; sclWinCtx.sclVerOff = sclVerOff; }
		else if(!selWin_value && !sclWinCtx.isEVal() && !sclWinCtx.tSek.isEVal()) {
			tSek = sclWinCtx.tSek; tSize = sclWinCtx.tSize; sclVer = sclWinCtx.sclVer; sclVerOff = sclWinCtx.sclVerOff; }
		sclWin = selWin_value;
	}
	//else ev_rez += (evCur+"\n");
}
event = "";//ev_rez;

//scaleInfo
scaleInfo_arg0val = 1e4/sclVer; scaleInfo_arg1val = sclVerOff;
xScaleInfo_arg0val = 1e4/sclHor; xScaleInfo_arg1val = sclHorOff;

//Trend time control
date_value = tSek;
if(tSek < curTm) trcPer = 0; else trcPer = trcPer_, tSek = 0;
size_value = SYS.time2str(tSize, false);
dateBeg_value = date_value - tSize;

arch_value = valArch.length ? valArch : tr("All");
cursor_en = !curSek.isEVal() && type != 2;
if(cursor_en && type == 0) cursor_arg0val = SYS.strftime(curSek,"%d.%m.%Y %H:%M:%S") + ((curUSek && (tSize/1000) < 1)?"."+curUSek:"");
if(cursor_en && type == 1) cursor_arg0val = tr("Frequency")+":\n"+(1e6/(1e6*curSek+curUSek)).toFixed(2)+" "+tr("Hz");
type_value = (type==1)?tr("Spectrum"):((type==2)?tr("XY"):tr("Graph"));
xScaleInfo_en = xZoomIn_en = xZoomOut_en = xZoomOffRight_en = xZoomOffLeft_en = xZoomDef_en = (type==2);
selWin_en = (type == 0 && !sclWin.isEVal());
if(selWin_en)	selWin_value = sclWin;

//Checking for correct linking with trend
if(this.attr("pgOpen") && this.attr("pgOpenSrc").length && (tVl=this.wdgAt(this.attr("pgOpenSrc"),true)) && !tVl.ownerPage().attr("pgOpen"))
	this.wdgAt("/s/pg_control/pg_terminator",true).attrSet("pgOpen", true);