xmlflow.js

来自「一个用javascript实现的工作流定义工具」· JavaScript 代码 · 共 55 行

JS
55
字号
function parseXML(xml)
{
	if(xml != '')
	{
		var xmlRoot = new Xparse(xml);

		var flowObj = xmlRoot.contents[0];

		var cfgObj = flowObj.contents[0];     //
		var stpObj = flowObj.contents[1];     //
		var actObj = flowObj.contents[2];     // 

		var tmpObj = cfgObj.contents[0]; 
		var flowId = tmpObj.attributes['flowId'];
		var flowText = tmpObj.attributes['flowText'];

		var i = 0,num = 3;

		var id, text, type;
		for (i = 0; i < stpObj.contents.length; i++) 
		{
			var Step = stpObj.contents[i];
			var basep = Step.contents[0];
			id = basep.attributes["id"];
			text = basep.attributes["text"];	
			type = basep.attributes["stepType"];
			if (type == 'NormalStep')
			   type = 'normal';
			if (type == 'EndStep')
			   type = 'end';
			if (type == 'BeginStep')
			   type = 'start';

			var vml = Step.contents[1];
			var x, y;
			x = toInt(vml.attributes["x"]) / 3;
			y = toInt(vml.attributes["y"]) / 3;

			var stp = new FlowStep(x, y, id, text, type);
			flow.addStep(stp);
			stp.draw(flow.drawer);
		}

		for (i = 0;i < actObj.contents.length;i++)
		{
			var Action = actObj.contents[i];
			var basep = Action.contents[0];
			id = basep.attributes["id"];
			var from = flow.findStep(basep.attributes["from"]);
			var to = flow.findStep(basep.attributes["to"]);

			flow.newAction(from, to, id);
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?