const.js
上传用户:yfdli66
上传日期:2010-02-20
资源大小:47k
文件大小:5k
- /*------------------------------------------------------------------------------
- + 系统常量的定义 +
- + +
- + +
- -------------------------------------------------------------------------------*/
- //是否可以拖动
- var fDragApproved=false;
- var fSelectedObj,fx,fy; //当前所选择的对象
- //选择的按钮
- var fLiftButton="sel";
- //是否在画线 0,不在画线;1,起点;2,终点
- var fAddLineFlag = 0;
- var fLineStartObj = null;
- var fLineEndObj = null;
- //控件的数量
- var fCtlNum;
- //表格宽度和高度
- var fGridNo=20;
- //类型
- var CNST_CTLTYPE_INITIAL = "initial"; //启动
- var CNST_CTLTYPE_STEPS = "steps"; //步骤
- var CNST_CTLTYPE_JOINS = "joins"; //连接
- var CNST_CTLTYPE_SPLITS = "splits"; //分割
- var CNST_CTLTYPE_LINES = "lines"; //线段
- //增加到控件列表中
- function addToObjArray (obj,toLine) {
- var oOption = document.createElement("OPTION");
- sltObjArray.options.add(oOption);
- oOption.innerText = obj;
- oOption.value = obj;
- fSelectedObj = eval(obj);
- if (toLine==true) {
- moveObjToline(fSelectedObj);
- }
- fCtlNum++; //对象计数
- iptCtlNum.value=fCtlNum; //控件中计数同步
- }
- //从控件列表删除
- function removeFromObjArray (obj) {
- for (var i=0;i<sltObjArray.options.length;i++) {
- if (obj.id==sltObjArray.options[i].value) {
- sltObjArray.options[i] = null; //删除
- break;
- }
- }
- }
- //四舍五入
- function floatRound(myFloat) {
- var cutNumber = Math.pow(10,0);
- return Math.round(myFloat * cutNumber)/cutNumber;
- }
- //适应表格
- function moveObjToline(aObj) {
- aObj.style.left = Math.abs(floatRound((parseInt(aObj.style.left)+parseInt(aObj.style.width)/2)/fGridNo)*fGridNo - parseInt(aObj.style.width)/2);
- aObj.style.top = Math.abs(floatRound((parseInt(aObj.style.top)+parseInt(aObj.style.height)/2)/fGridNo)*fGridNo - parseInt(aObj.style.height)/2);
- }
- function cf_CalculateLinePos (aStart,aEnd) {
- var posArray = new Array();
- var x1,y1,x2,y3,x3,y3,x4,y4;
- var sl,st,sw,sh,el,et,ew,eh;
- var spacing;
- //开始
- with (aStart.style) {
- sl = parseInt(pixelLeft); //Left
- st = parseInt(pixelTop); //Top
- sw = 20;//parseInt(width); //width
- sh = 15;//parseInt(height); //height
- }
- //结束
- with (aEnd.style) {
- el = parseInt(pixelLeft); //Left
- et = parseInt(pixelTop); //Top
- ew = 20;//parseInt(width); //width
- eh = 15;//parseInt(height); //height
- }
- //计算路线
- x1 = sl+sw/2;
- y1 = st+sh/2;
- x4 = el+ew/2;
- y4 = et+eh/2;
- var i,j;
- i = x4-x1;
- j = y4-y1;
- if (j>0) {
- if (Math.abs(j)<=Math.abs(i)) {
- if (j<=eh/2) {
- if (i>0) {
- x3 = x1;
- y3 = y1;
- x4 = el;
- y4 = y1;
- } else {
- x3 = x1;
- y3 = y1;
- x4 = el+ew+4;
- y4 = y1;
- }
- } else {
- x3 = x4;
- y3 = y1;
- y4 = et;
- }
- } else {
- if (Math.abs(i)<=ew/2) {
- x3 = x1;
- y3 = y1;
- x4 = x1;
- y4 = et;
- } else {
- if (i==0) {
- x3 = x1;
- y3 = y1;
- y4 = et;
- } else if (i>0) {
- x3 = x1;
- y3 = y4;
- x4 = el;
- } else {
- x3 = x1;
- y3 = y4;
- x4 = el+ew+4;
- }
- }
- }
- } else if (j<0) {
- if (Math.abs(j)<=Math.abs(i)) {
- if (Math.abs(j)<=eh/2) {
- if (i>0) {
- x3 = x1;
- y3 = y1;
- x4 = el;
- y4 = y1;
- } else {
- x3 = x1;
- y3 = y1;
- x4 = el+ew+4;
- y4 = y1;
- }
- } else {
- x3 = x4;
- y3 = y1;
- y4 = et+eh+4;
- }
- } else {
- if (Math.abs(i)<=ew/2) {
- x3 = x1;
- y3 = y1;
- x4 = x1;
- y4 = et+eh+4;
- } else {
- if (i==0) {
- x3 = x1;
- y3 = y1;
- y4 = et+eh+4;
- } else if (i>0) {
- x3 = x1;
- y3 = y4;
- x4 = el;
- } else {
- x3 = x1;
- y3 = y4;
- x4 = el+ew+4;
- }
- }
- }
- } else {
- if (i==0) {
- x3 = x1;
- y3 = y1;
- x4 = el+ew+4;
- } else if (i>0) {
- x3 = x1;
- y3 = y1;
- x4 = el;
- } else {
- x3 = x1;
- y3 = y1;
- x4 = el+ew+4;
- }
- }
- x2 = x1;
- y2 = y1;
- //放到数组里面
- posArray["x1"] = x1;
- posArray["x2"] = x2;
- posArray["x3"] = x3;
- posArray["x4"] = x4;
- posArray["y1"] = y1;
- posArray["y2"] = y2;
- posArray["y3"] = y3;
- posArray["y4"] = y4;
- return posArray; //返回
- }