JavaLikeCalc.JavaScript
if(f_start) {
	//Init the avialable parameters
	colors = new Array("#ae77c3", "orange", "blue", "#199696", "#3264C8", "tomato", "magenta", "#B6B600", "#69695C", "darkcyan");
	params = new Array();
	params.repHour = repHour;
	for(iP = 1; iP <= 10; iP++) {
		pO = new Object();
		pO.name = this.doc.attr("p"+iP+"name");
		pO.var = this.doc.attr("p"+iP+"var");
		pO.ed = this.doc.attr("p"+iP+"ed");
		if(pO.ed.isEVal())	pO.ed = "";
		pO.prec = this.doc.attr("p"+iP+"prec");
		pO.min = this.doc.attr("p"+iP+"min");
		pO.max = this.doc.attr("p"+iP+"max");
		pO.isCntr = this.doc.attr("p"+iP+"cntr");
		pO.color = colors[iP-1];
		if(pO.prec.isEVal())	pO.prec = 0;
		if(!pO.name.isEVal() && pO.name.length && !pO.var.isEVal() && (aO=SYS.nodeAt(pO.var).arch()))
			params.push(pO);
	}
	this.doc.attrSet("params", params);

	if(!n) { time = SYS.time(); lastTime = 0; }
	return;
}

curMin = curHour = curDay = curMonth = curYear = 0;

for(off = 0, ev_rez = ""; (ev_cur=event.parse(0,"\n",off)).length; )
	if(ev_cur == "ws_FocusIn:/doc")	ev_rez += "ws_FocusIn";
	else ev_rez += ev_cur;
event = ev_rez;

//Build the document dynamically
if(!n) {
	if(time == lastTime)	return;

	time = min(time, SYS.time());
	SYS.localtime(time, 0, curMin, curHour, curDay, curMonth, curYear);
	doc_bTime = SYS.mktime(0, 0, repHour, curDay, curMonth, curYear);
	doc_time = SYS.mktime(0, 0, repHour, curDay+1, curMonth, curYear);
	if(curHour < repHour || (curHour == repHour && !curMin)) { doc_bTime -= 24*60*60; doc_time -= 24*60*60; }

	bTime = doc_bTime;
	time = lastTime = doc_time;
	doc_doc = "";

	return;
}

//Build the document in the archive
//generation one per hour 
SYS.localtime(SYS.time(), 0, curMin, curHour, curDay, curMonth, curYear);
if(!doc_bTime) {
	doc_bTime = SYS.strptime(""+curYear+"-"+(curMonth+1)+"-"+curDay+" "+repHour+":0:0","%Y-%m-%d %H:%M:%S");
	if(curHour < repHour)	doc_bTime -= 24*60*60;
}
if(lastHour < 0 || lastDay < 0 || lastMin < 0) SYS.localtime(doc_bTime, 0, lastMin, lastHour, lastDay);

//Archive last not closed document
if(closeDoc == true) { if(!doc_process) { this.doc.attrSet("aCur", -1);/*(doc_aCur = -1;*/ closeDoc = false; } }
else if(doc_time && doc_time < doc_bTime) {
	closeDoc = true;  
	SYS.localtime(doc_time, 0, 0, curHour, curDay, curMonth, curYear);
	doc_time = doc_bTime = SYS.strptime(""+curYear+"-"+(curMonth+1)+"-"+curDay+" "+repHour+":0:0","%Y-%m-%d %H:%M:%S");
	if(curHour >= repHour) doc_time += 24*60*60; else doc_bTime -= 24*60*60;
}
//Archive the document
else if(curDay != lastDay && curHour == repHour && curMin >= 3) {
	closeDoc = true;
	doc_time = SYS.strptime(""+curYear+"-"+(curMonth+1)+"-"+curDay+" "+repHour+":0:0","%Y-%m-%d %H:%M:%S");
	lastDay = curDay;
}
//Periodic notfull update
else if(curMin != lastMin && !(curMin%5)) {
	lastMin = curMin;
	doc_time = SYS.time() - 5*60;
	SYS.localtime(doc_time, 0, 0, curHour, curDay, curMonth, curYear);
	doc_bTime = SYS.strptime(""+curYear+"-"+(curMonth+1)+"-"+curDay+" "+repHour+":0:0","%Y-%m-%d %H:%M:%S");
	if(curHour < repHour) doc_bTime -= 24*60*60;
}