JavaLikeCalc.JavaScript
var reqUser_; var reqLang_; var toCompleteUpd = false;
if(this.ownerSess().reqUser() != reqUser_ || this.ownerSess().reqLang() != reqLang_)
	toCompleteUpd = true, reqUser_ = this.ownerSess().reqUser(), reqLang_ = this.ownerSess().reqLang();

calcCnt++;

if(f_start || toCompleteUpd) {
	play_en = demoPlayProc.length;
	if(!play_en)	this.infoW.attrSet("geomH",this.play.attr("geomY")+this.play.attr("geomH")-this.infoW.attr("geomY"));
	//Checking the signal object's presenting and creating needed
	soLst = this.nodeList("pg_"); soLstS = new Object();
	for(i = 0; i < soLst.length; i++)
		if((curSO=soLst[i].slice(3).toInt())) {
			soNm = this["pg_"+curSO].attr("name");
			for(soNmSz = 0, off = 0; off < soNm.length; soNmSz++)
				soNm.charAt(off, "UTF-8");
			soLstS[curSO.toString(10,2)] = tVl = new Object();
			tVl.nm = soNm;
			tVl.nmSz = soNmSz;
		}
	//Init views
	viewGrps = new Array(new Object(), new Object(), new Object());
	v = viewGrps[0]; v.cnt = 0, v.first = 1, v.last = 2;
	v = viewGrps[1]; v.cnt = 0, v.first = 3, v.last = 5;
	v = viewGrps[2]; v.cnt = 0, v.first = 6, v.last = 6, v.global = true;	//Only one item currently
	oldViewLs = new Array("mn", "ggraph", "gcadr", "gview", "doc", "rg");

	//Processing SO and views
	logoR = this.logo.attr("geomX") > this.so1.attr("geomX");
	soInterSpecX = logoR ? this.so1.attr("geomX") : (this.logo.attr("en")?this.so1.attr("geomX")-this.logo.attr("geomX")-this.logo.attr("geomW"):2);
	soX = logoR ? soInterSpecX : this.so1.attr("geomX");
	soWdth =	logoR ?	((this.logo.attr("en")?this.logo.attr("geomX"):this.attr("geomW"))-soX) : (this.attr("geomW") - soX);
	soSymbSz = this.so1.attr("font").parse(1," ").toReal()*0.75;

	soInterSpecY = this.so1.attr("geomY");
	soY = this.so1.attr("geomY");
	soY2 = soY + this.so1.attr("geomH") + soInterSpecY;
	row1 = 0, row2 = 0, row1w = 0, row2w = 0;
	oldViews = false;
	for(var iSO in soLstS) {
		if(!(curSO=iSO.toInt()))	continue;
		soNmSz = soLstS[iSO].nmSz*soSymbSz + soInterSpecX;
		if(!row2 && (row1w+soNmSz) < soWdth)		row1w += soNmSz, row1++;
		else if((row2w+soNmSz) < soWdth)			row2w += soNmSz, row2++;
		else continue;	//Too many and long SO
		if(curSO != 1)	this.wdgAdd("so"+curSO, soLstS[iSO].nm, this.attr("parent")+"/wdg_so1");

		soW = this["wdg_so"+curSO];
		soW.attrSet("name", soLstS[iSO].nm)
			.attrSet("color", backColorButton)
			.attrSet("colorText", labColorGood)
			.attrSet("tipTool", tr("Signal object")+" "+curSO+((curSO<=9)?" (CtrlAlt+"+curSO+")":""))
			.attrSet("tipStatus", tr("Press for select signal object")+" "+curSO+((curSO<=9)?" (CtrlAlt+"+curSO+")":""));

		soDscr = this["pg_"+curSO].attr("dscr");
		if(soDscr.length) soW.attrSet("tipTool", soDscr);
		soW.attrSet("en", 1);

		// Appending the events and hotkey processing
		evProc += "ws_BtPress:/so"+curSO+":open:/pg_so/"+curSO+"/*/*\n";
		if(curSO <= 9)	evProc += "key_presCtrlAlt"+curSO+":*:open:/pg_so/"+curSO+"/*/*\n";

		for(iV = viewGrps[0].first; iV <= viewGrps[2].last; iV++) {
			viewGrp = viewGrps[0];
			if(iV >= viewGrps[2].first)	viewGrp = viewGrps[2];
			else if(iV >= viewGrps[1].first)	viewGrp = viewGrps[1];
			if(viewGrp[iV].isEVal()) {
				vNm = "";
				isG = (viewGrp.global == true);
				if(this.nodeList("pg_","/pg_"+(isG?"view"+iV:curSO)+"/pg_view"+iV).length)	vNm = "view"+iV;
				else if(this.nodeList("pg_","/pg_"+(isG?oldViewLs[iV-1]:curSO)+"/pg_"+oldViewLs[iV-1]).length)	vNm = oldViewLs[iV-1];
				if(vNm.length) {
					viewGrp[iV] = true, viewGrp.cnt++;
					// Appending the events processing
					evProc += "ws_BtPress:/go_view"+iV+":open:/pg_so/"+(isG?vNm:"*")+"/"+vNm+"/*\n";
					// Append for the processing events of the hotkeys
					vO = this["wdg_go_view"+iV];
					if((tVl=vO.attr("tipTool").match("\\(CtrlAlt\\+(.)\\)")).length)
						evProc += "key_presCtrlAlt"+tVl[1]+":*:open:/pg_so/"+(isG?vNm:"*")+"/"+vNm+"/*\n"; 
				}
			}
		}
	}

	soWdthAdd = (soWdth-row1w)/row1;
	soOff = soX, i = 0;
	for(var iSO in soLstS) {
		if(!(curSO=iSO.toInt()))	continue;
		if(i > (row1+row2))	break;
		soW = this["so"+curSO];
		soNm = soW.attr("name");
		soNmSz = soLstS[iSO].nmSz*soSymbSz + soInterSpecX;
		soOffY = soY2;
		if(i < row1)	soNmSz += soWdthAdd, soOffY = soY;
		else if(i == row1)	soOff = soX;
		soW.attrSet("geomX",soOff).attrSet("geomY",soOffY).attrSet("geomW",soNmSz-soInterSpecX);
		soOff += soNmSz;
		i++;
	}
	if(row1 == 1)		soOff = soY;
	else if(!row2)	soOff = soY2 - soInterSpecY;
	else soOff = soY2 + this.so1.attr("geomH");
	this.pgCont.attrSet("geomY",soOff).attrSet("geomH",(alarms_en?alarms_geomY:geomH)-soOff);

	//Unused views concealment
	for(iVG = 0; iVG < viewGrps.length; iVG++) {
		viewGrp = viewGrps[iVG];
		viewOff = this["wdg_go_view"+viewGrp.first].attr("geomX");
		viewWdth = this["wdg_go_view"+viewGrp.last].attr("geomX") + this["wdg_go_view"+viewGrp.last].attr("geomW") - viewOff;
		for(iV = viewGrp.first; viewGrp.cnt < (viewGrp.last-viewGrp.first)+1 && iV <= viewGrp.last; iV++) {
			vO = this["wdg_go_view"+iV];
			if(viewGrp[iV].isEVal()) vO.attrSet("en", false);
			else {
				vO.attrSet("geomX", viewOff).attrSet("geomW", viewWdth/viewGrp.cnt);
				viewOff += viewWdth/viewGrp.cnt;
			}
		}
	}

	toCalcCycles = -max(1, 10000/this.ownerSess().period());
	if(f_start)	toFastCalc = toFastCalc_ = false;
}

toChangeCnt = "";
if(pgCont_pgOpenSrc != lastView || toCompleteUpd) {
	//Checking for SO selection change
	curSO = pgCont_pgOpenSrc.parsePath(2).slice(3);
	lastSO = lastView.parsePath(2).slice(3);
	if(curSO != lastSO) {
		if(lastSO.length) this["wdg_so"+lastSO].attrSet("color", backColorButton);
		if(curSO.length) {
			this["wdg_so"+curSO].attrSet("color", backColorButtonSel);
			// Check for view modes active
			for(iV = viewGrps[0].first; iV <= viewGrps[2].last; iV++) {
				viewGrp = viewGrps[0];
				if(iV >= viewGrps[2].first)		viewGrp = viewGrps[2];
				else if(iV >= viewGrps[1].first)	viewGrp = viewGrps[1];
				if(viewGrp[iV] == true) {
					vNm = "";
					isG = (viewGrp.global == true);
					if(this.nodeList("pg_","/pg_"+(isG?"view"+iV:curSO)+"/pg_view"+iV).length)	vNm = "view"+iV;
					else if(this.nodeList("pg_","/pg_"+(isG?oldViewLs[iV-1]:curSO)+"/pg_"+oldViewLs[iV-1]).length)	vNm = oldViewLs[iV-1];
					this["wdg_go_view"+iV].attrSet("active", vNm.length);
				}
			}
		}
	}
	//Checking for view selection change
	curMode = pgCont_pgOpenSrc.parsePath(3).slice(3);
	lastMode = lastView.parsePath(3).slice(3);
	if(curMode != lastMode) {
		if(lastMode.length)
			this["wdg_go_"+(((tVl=oldViewLs.indexOf(lastMode)) >= 0)?"view"+(tVl.toInt()+1):lastMode)].attrSet("color","");
		if(curMode.length)
			this["wdg_go_"+(((tVl=oldViewLs.indexOf(curMode)) >= 0)?"view"+(tVl.toInt()+1):curMode)].attrSet("color", backColorButtonSel);
	}

	//Pages counter display
	if(pgCont_pgOpenSrc.length && curMode.length) {
		elLst = this["pg_"+curSO]["pg_"+curMode].nodeList("pg_");
		curEl = pgCont_pgOpenSrc.parsePath(4);
		pgSel_items = "";
		for(iEl = 0, iM = -1; iEl < elLst.length; iEl++) {
			oEl = this["pg_"+curSO]["pg_"+curMode][elLst[iEl]];
			if(!SYS.Security.access(reqUser_,4,oEl.attr("owner").parse(0,":"),oEl.attr("owner").parse(1,":"),oEl.attr("perm")))
				continue;
			if(!(elNm=oEl.attr("name")).length)
				elNm = oEl.ownerPage().attr("name") + " " + iEl;
			elNm += " ("+elLst[iEl].slice(3)+")";
			pgSel_items += (pgSel_items.length?"\n":"") + elNm;
			if(iM < 0 && elLst[iEl] == curEl) { pgSel_value = elNm; iM = iEl; }
			delete oEl;
		}
		pgCntr_text = ""+(iM+1)+"\n("+elLst.length+")";
		prev_active = next_active = pgSel_active = (elLst.length>1);
	}
	else { pgCntr_text = "-"; prev_active = next_active = pgSel_active = false; }

	lastView = pgCont_pgOpenSrc;
}

//Cvitation button's
cvt_light_en = alarmSt&0x100; cvt_alarm_en = alarmSt&0x200; cvt_sound_en = alarmSt&0x400;
cvt_light_active = alarmSt&0x10000; cvt_alarm_active = alarmSt&0x20000; cvt_sound_active = alarmSt&0x40000;
toFastCalc = alarmSt&0x10000;

//Per one second's calls
if((calcCnt%f_frq) == 0) {
	//Alarms display
	actSO = pgCont_pgOpenSrc.parsePath(2).slice(3);
	soLst = this.nodeList("pg_");
	for(i = 0; i < soLst.length; i++) {
		curSO = soLst[i].slice(3);

		this["wdg_so"+curSO].attrSet("color", ((curSO==actSO)?backColorButtonSel:backColorButton));

		aSt = this["pg_"+curSO].attr("alarmSt");
		aLev = aSt&0xFF;
		if(aLev && aSt&0x100) {
			if(aLev > 30) wColor = labColorAlarm;
			else wColor = labColorWarning;
			curColor = this["wdg_so"+curSO].attr("colorText");
			this["wdg_so"+curSO].attrSet("colorText",(aSt&0x10000 && curColor==wColor)?"black":wColor);
		} else this["wdg_so"+curSO].attrSet("colorText", labColorGood);
	}
}

//Events process
for(off = 0, ev_rez = ""; (sval=event.parse(0,"\n",off)).length; )
	if(sval == "ws_CombChange:/pgSel" && (tPg=pgSel_value.match("\\((.+)\\)$")).length)
		toChangeCnt = "/pg_so/" + pgCont_pgOpenSrc.parsePath(2) + "/" + pgCont_pgOpenSrc.parsePath(3) + "/pg_" + tPg[1];
	else if(sval == "ws_BtPress:/cvt_light")	alarmSt = 0x1000001;
	else if(sval == "ws_BtPress:/cvt_alarm")	alarmSt = 0x1000002;
	else if(sval == "ws_BtPress:/cvt_sound")	alarmSt = 0x1000004;
	else if(sval.parse(0,":") == "ws_BtRelease" && ((tVl=sval.parse(1,":")) == "/prev" || tVl == "/next" || tVl.indexOf("/so") == 0 || tVl.indexOf("/go_view") == 0))
		toChangeCnt = "1";

if(toChangeCnt.length) {
	this.ownerSess().uiCmd("open", "/pg_control/pg_terminator", this.attr("path"));	//!!!! To open the terminator panel before other
	if(toChangeCnt.length > 1) this.ownerSess().uiCmd("open", toChangeCnt, this.attr("path"));
	toCalcCycles = 1;
}

//Updating cycles processing for big processing periods of that page 
if(abs(toCalcCycles) > 0.1) {
	this.attrSet("event", this.attr("event")+"usr_calc\n");	//!!!! Just to calc in the next session cycle for update
	toCalcCycles = (sign(toCalcCycles) < 0 && pgCont_pgOpenSrc.length) ? 0 : max(0, abs(toCalcCycles)-1)*sign(toCalcCycles);
}
if(toFastCalc != toFastCalc_)	{ toFastCalc_ = toFastCalc; this.calcPer(toFastCalc?500:-3); }

//Demo play process
if(f_start || !play_value) { stepCur = -1; stepTm = 0; play_img = "start"; }
if(play_value && (SYS.time()-this.ownerSess().reqTm()) < (1e-3*this.calcPer())) {	//With preventing call in background on WEB
	play_img = "stop";
	if(stepTm > 0) stepTm -= 1/f_frq;
	else {
		var args = new Object();
		args.this = this;
		args.stepTm = stepTm;
		args.stepCur = stepCur;
		SYS.DAQ.funcCall("JavaLikeCalc.JavaScript",args,demoPlayProc);
		stepTm = args.stepTm;
		stepCur = args.stepCur;
	}
}

if((tVl=defUser.toInt()) && (tVl2=defUser.parse(1,"-")).length) {
	if((SYS.time()-this.ownerSess().userActTm()) < tVl*60)	userSetVis = "";
	else if(this.ownerSess().reqUser() != tVl2.parse(0,":"))	userSetVis = tVl2;
}