JavaLikeCalc.JavaScript
if(f_start) {
	//Parameter selection enable
	if(allowSelLst.length)
		for(i_el = 0; i_el < 10; i_el++) {
			cEl = this["el"+(i_el+1)];
			cEl.attrSet("enForce", 1);
			if(cEl.attr("contextMenu").search(":select$") < 0)
				cEl.attrSet("contextMenu",cEl.attr("contextMenu")+tr("Select")+":select\n");
		}
	cnt = 0;
}
cnt++;
if(cnt == 3)	event = "ws_FocusIn:/trnd1";

curTm = SYS.time();
if(!trnd1_tSek) trnd1_tSek = curTm;
selSingle = 0;
selAll = false;

//Events process
evRez = "";
for(off = 0; (evCur=event.parse(0,"\n",off)).length; ) {
	if(evCur == "key_presComma:/trnd1")		trnd1_tSek -= trnd1_tSize/2;
	else if(evCur == "key_presPeriod:/trnd1")	trnd1_tSek += trnd1_tSize/2;
	else if(evCur == "ws_SliderChange:/arh")	trnd1_tSek = arh_value*trnd1_tSize;
	else if(evCur.search("usr_single:/el") == 0)	selSingle = evCur.slice(14).toInt();
	else if(evCur.search("usr_all:/el") == 0)		selAll = true;
	else evRez += evCur+"\n";
	//SYS.messDebug("Trend","Event: "+evCur);
}
event = evRez;

//Trend time control
if(trnd1_tSek < curTm) trnd1_trcPer = 0;
else { trnd1_trcPer = 1; trnd1_tSek = 0; }

//Generic
name_arg0val = this.attr("name");

//Scale
typeXY = (trnd1_type==2);
cntrAct = cntrLog = xCntrAct = xCntrLog = 0;
for(i_el = 0; i_el < 10; i_el++) {
	cEl = this["el"+(i_el+1)];
	if(!cEl.attr("en")) continue;
	if(!typeXY || !(i_el%2)) {
		cntrAct++;
		if(cEl.attr("log") == true)	cntrLog++;
	}
	else {
		xCntrAct++;
		if(cEl.attr("log") == true)	xCntrLog++;
	}
}
trnd1_sclVer = (cntrLog > cntrAct/2) ? trnd1_sclVer|0x4 : trnd1_sclVer&(~0x4);
trnd1_sclHor = (xCntrLog > xCntrAct/2) ? trnd1_sclHor|0x4 : trnd1_sclHor&(~0x4);

//Trends
arh_beg = 1e30, arh_end = 0;
for(i_el = 0; i_el < 10; i_el++) {
	cEl = this["el"+(i_el+1)];
	if(selAll)	cEl.attrSet("bordStyle",3);
	if(selSingle) cEl.attrSet("bordStyle",((i_el+1)==selSingle)?3:1);
	cTr = this["trnd1"];
	cTrPrm = "prm"+i_el;
	if(!cEl.attr("en")) cTr.attrSet(cTrPrm+"addr","");
	else {
		cTr.attrSet(cTrPrm+"addr",cEl.attr("addr"));
		cTr.attrSet(cTrPrm+"bordL",cEl.attr("min"));
		cTr.attrSet(cTrPrm+"bordU",cEl.attr("max"));
		cTr.attrSet(cTrPrm+"color",cEl.attr("color"));
		cTr.attrSet(cTrPrm+"width",cEl.attr("bordWidth")*2);
		cEl.attrSet("varEl",cTr.attr(cTrPrm+"val"));
		//Enable/disable of the mode's indication in the regulators ???
		cEl.attrSet("enMode",((curTm-trnd1_curSek) <= 2));
		//Archive depth calculate
		if(cEl.attr("bordStyle") == 3) {
			arh_tmp = cTr.attr(cTrPrm+"prop");
			if((arh_vl=arh_tmp.parse(0,":").toReal())) arh_beg = min(arh_beg,arh_vl);
			if((arh_vl=arh_tmp.parse(1,":").toReal())) arh_end = min(curTm,max(arh_end,arh_vl));
		}
		if(!typeXY || !(i_el%2)) {
			if((cEl.attr("log")==true) == (cntrLog > cntrAct/2) && cEl.attr("bordWidth") == 1) cTr.attrSet(cTrPrm+"scl",0);
			else cTr.attrSet(cTrPrm+"scl",(cEl.attr("log")==true)?6:2);
		}
		else {
			if((cEl.attr("log")==true) == (xCntrLog > xCntrAct/2)) cTr.attrSet(cTrPrm+"scl",0);
			else cTr.attrSet(cTrPrm+"scl",(cEl.attr("log")==true)?6:2);
		}
	}
}
//Set archive scroll
if(arh_end && ((arh_end-arh_beg)/trnd1_tSize > 2)) {
	arh_cfg = "0:"+floor(arh_beg/trnd1_tSize+1)+":"+floor(arh_end/trnd1_tSize+1)+":1:5";
	arh_value = (trnd1_tSek?trnd1_tSek:curTm)/trnd1_tSize;
	arh_tipTool = tr("Archive space")+": ["+SYS.strftime(arh_beg)+" ... "+SYS.strftime(arh_end)+"]";
	arh_active = true;
	if(selSingle) trnd1_tSek = arh_end;
}
else { arh_active = false; arh_tipTool = ""; }