ucbuilder
Version:
For Developing Applications with multiple form/usercontrols etc.. In Single BrowserWindow...
57 lines (56 loc) • 2.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.regsManage = void 0;
const loopRegs_1 = require("ucbuilder/build/regs/process/loopRegs");
const switchRegs_1 = require("ucbuilder/build/regs/process/switchRegs");
const common_1 = require("ucbuilder/build/common");
class regsManage {
constructor() {
this.proceeFindRegs = new RegExp(/`\s*{(\w*)=(.+?)}\s*`([^]*?)`\s*{\/\1}\s*`/g);
this.tableColCellPattern = new RegExp(/{=([\.\w]+?) *}/g);
this.switchRgx = new switchRegs_1.switchRegs();
this.loopRgx = new loopRegs_1.loopRegs();
}
/**
*
* @param {{}} node
* @param {string} content
* @returns {string}
*/
parse(node, content) {
let res = "";
let _this = this;
res = content.replace(this.proceeFindRegs, function (match, _code, valtoFind, subcontent, offset, input_string) {
let prcRes = "";
if (_code.startsWith("loop")) {
if (subcontent.includes("loopCELL")) {
// console.log(subcontent);
}
prcRes += _this.loopRgx.parseDirect(node, _code, valtoFind, subcontent, (obj, loop_content) => {
return _this.parse(obj, loop_content);
});
}
else if (_code.startsWith("switch")) {
let cnt = _this.switchRgx.parseDirect(node, valtoFind, subcontent);
prcRes += _this.parse(node, cnt);
}
else
return subcontent;
// console.log(prcRes);
return prcRes;
});
return this._GET_CELL_VAL(node, res);
}
/**
*
* @param {string} content
* @param {{}} node
* @returns {string}
*/
_GET_CELL_VAL(node, content) {
return content.replace(this.tableColCellPattern, (match, cellName, offset, input_string) => {
return (cellName == ".") ? '' + node : '' + common_1.objectOpt.getValByNameSpace(node, cellName);
});
}
}
exports.regsManage = regsManage;