JavaLikeCalc.JavaScript
var user_;
if(f_start)	{
	colorDef_ = color_ = "";
	allowSel = this.ownerWdg(true).attr("allowSelLst").length;
	perUserSel = this.ownerWdg(true).attr("perUserSel");
}
if(colorDef_ != colorDef)	color = colorDef_ = colorDef;
user = (perUserSel == true) ? this.ownerSess().user() : "";
if(f_start || user != user_) { loadFromSess = false; user_ = user; }
en = enForce || !name.isEVal();
if(allowSel && ((en && name.isEVal()) || !loadFromSess)) {
	//Load stored session's assignments
	loadOK = false;
	if(!loadFromSess) {
		for(off = 0; (lnA="addr;name;dscr;min;max;ed;log;prec;aMax;aMin;wMax;wMin;pModeA;pModeC;color".parse(0,";",off)).length; )
			if(lnA == "color") {
				if((tVl=this.attr(user+lnA,true)).length)	color = tVl;
			}
			else {
				if(!f_start) this.linkSet(lnA, "");
				if((wA=this.attr(user+lnA,true)).length) { this.linkSet(lnA, wA); loadOK = true; }
			}
		//if((cVal=this.attr("color",true)).length) this.color = cVal;
		loadFromSess = true;
	}
	if(!loadOK)	name = tr("<No selected>");
}
lb_sfr_text = name;
if(varEl.isEVal()) lb_val_arg0val = "-";
else if(!digStts.isEVal() && digStts.length) lb_val_arg0val = (varEl^digRevers) ? digStts.parse(0,";").parse(0,"-") : digStts.parse(1,";").parse(0,"-");
else lb_val_arg0val = prec.isEVal() ? varEl.toPrecision(6) : ((prec < 0) ? varEl.toPrecision(abs(prec)) : ((log==true)?varEl.toExponential(prec):varEl.toFixed(prec)));
lb_val_color = lb_sfr_color = lb_ed_color = labColorGood;
if(varEl.isEVal() || (!min.isEVal() && max > min && varEl < min) || (!max.isEVal() && max > min && varEl > max)) lb_val_color = lb_sfr_color = lb_ed_color =  "grey";
else if(!aMax.isEVal() && !aMin.isEVal() && aMax > aMin && (varEl >= aMax || varEl <= aMin)) lb_val_color = lb_sfr_color = lb_ed_color =  labColorAlarm;
else if(!wMax.isEVal() && !wMin.isEVal() && wMax > wMin && (varEl >= wMax || varEl <= wMin)) lb_val_color = lb_sfr_color = lb_ed_color =  labColorWarning;

lb_ed_text = ed.isEVal() ? "" : ed;

//Blink focused or linked with ElCadr
if(this.attr("focus") ||
		(!name.isEVal() && name.length && this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("pgOpen") && this.wdgAt("/s/pg_control/pg_ElCadr",true).attr("prmShifr") == name))
{
  bordColor = (bordColor == "silver") ? "gray" : "silver";
  bordWidth =  2;
}
else { bordWidth =  1; bordColor = "black"; }

//Check the regulator mode
if(!enMode.isEVal() && enMode) { 
  mode_en = true; 
  if(!pModeC.isEVal() && pModeC) mode_text = tr("C");
  else mode_text = pModeA.isEVal() ? "" : ((pModeA) ? tr("A") : tr("M")); 
}
else mode_en = false;

//Events process
toSave = false;
for(evRez = "", off = 0; (evCur=event.parse(0,"\n",off)).length; ) {
	//this.messInfo("Event: "+evCur);
	if(evCur == "key_mouseDblClick" || evCur == "usr_hideshow") bordStyle = (bordStyle==1) ? 3 : 1;
	//Store session's assignments
	else if(evCur == "usr_set")	toSave = true;
	else evRez += evCur+"\n";
}
event = evRez;

if(toSave || (f_start && allowSel && !loadOK)) {
	for(off = 0; (lnA="addr;name;dscr;min;max;log;ed;prec;aMax;aMin;wMax;wMin;pModeA;pModeC;color".parse(0,";",off)).length; )
		if(lnA == "color")	this.attrSet(user+lnA, color, true);
		else this.attrSet(user+lnA, this.link(lnA), true);
}

if(!color_.length)	color_ = color;
if(bordStyle == 1 && color != "-")			color_ = color, color = "-";
else if(bordStyle != 1 && color == "-")	color = color_;
trClr_lineClr = (color.length && color != "-") ? color : "gray";

tipTool = "";
if(!name.isEVal())	tipTool += tr("Name")+": "+name+"\n";
if(!min.isEVal() && !max.isEVal() && max > min) tipTool += tr("Scale")+": "+min+" ... "+max+"\n";
if(!aMin.isEVal() && !aMax.isEVal() && aMax > aMin) tipTool += tr("Alarm border")+": "+aMin+" ... "+aMax+"\n";
if(!wMin.isEVal() && !wMax.isEVal() && wMax > wMin) tipTool += tr("Warning border")+": "+wMin+" ... "+wMax+"\n";
if(!dscr.isEVal()) {
	tipTool += tr("Description")+": "+dscr+"\n";
	tipStatus = dscr;
}