Best JavaScript code snippet using wpt
webflow.js
Source:webflow.js
1// JScript File -- Edit by Gud2function newFlow() {3 if (g_Flow != null) { if (!confirm('²»±£´æ¾ÉÁ÷³Ì£¬´´½¨ÐÂÁ÷³ÌÂð£¿\n\nDon\'t save the old flow,and Create a new flow?')) return; delete g_Flow; }4 g_Flow = new f_Flow();5 redrawVML();6 workFlowDialog(null, 'Flow', function () { self.location.reload(); });7 8}9function newStep(stepType) { workFlowDialog(null, "Step" + stepType); }10function newStepCopy(stepId) { workFlowDialog(stepId, "StepCopy"); }11function newAction() { workFlowDialog(null, 'Action'); }12function editFlow() { workFlowDialog(g_Flow.id, 'Flow'); }13function editStep(stepId, stepType) { workFlowDialog(stepId, "Step" + stepType); }14function editAction(actionId) { workFlowDialog(actionId, 'Action'); }15function restoreStep(stepId) { g_Flow.getStep(stepId).show = "1"; redrawVML(); objFocusedOn(stepId, "Step"); }16function deleteStep(stepId) { if (!confirm("ÄúȷʵҪÓÀ¾Ãɾ³ý²½Öè" + stepId + "Âð£¿")) return; g_Flow.delStep(g_Flow.getStep(stepId)); redrawVML(); }17function delStep(stepId) {18 if (!confirm("ÄúȷʵҪ´ÓͼÉÏɾ³ý²½Öè" + stepId + "Âð£¿")) return;19 var Step = g_Flow.getStep(stepId);20 if (parseInt(Step.show, 10) > 1) { g_Flow.delStep(Step); } else { Step.show = "0"; g_Flow.delActions(Step); }21 redrawVML();22}23function delAction(actionId) { if (!confirm("ÄúȷʵҪɾ³ý¶¯×÷" + actionId + "Âð£¿")) return; g_Flow.delAction(g_Flow.getAction(actionId)); redrawVML(); }24var CONST_LAY_LOWEST = "0";25var CONST_LAY_LOWER = "10";26var CONST_LAY_MIDDLE = "20";27var CONST_LAY_TOPPER = "30";28var CONST_LAY_TOPPEST = "40";29var FOCUSEDOBJID = "", FOCUSEDOBJTYPE = "";30var LINKSTART = true, LINKSTARTSTEPID = "";31var CURRENTX = CURRENTY = 0;32var COORDX = COORDY = 2000;33var XRATE = YRATE = 0;34var MOVEOBJ = null;35var MOVEFLAG = false;36var MOVEFUNC = null;37var VML_LINKLINE = null;38var VML_FLOWOBJ = null;39function setObjZIndex(obj, drawIndex, zIndex) { if (null == obj) return; document.getElementById(obj.id).style.zIndex = drawIndex; obj.zIndex = zIndex; }40function objFocusedOn(objId, type) {41 if (null == g_Flow) return;42 var focusedOnColor = type == "Action" ? g_Flow.cfg.actionFocusClr : g_Flow.cfg.stepFocusClr;43 /*setObjZIndex((type == "Action") ? g_Flow.getAction(objId) : g_Flow.getStep(objId), parseInt(CONST_LAY_TOPPEST, 10) + 1, parseInt(CONST_LAY_TOPPEST, 10) + 1);44 document.getElementById(objId).StrokeColor = focusedOnColor;45 if (FOCUSEDOBJID == objId && MOVEFLAG)46 return;47 if (FOCUSEDOBJID != objId)48 objFocusedOff();49 FOCUSEDOBJID = objId;50 FOCUSEDOBJTYPE = type;51 */52}53function objFocusedOff() {54 if ((FOCUSEDOBJID == '') || (null == g_Flow))55 return;56 focusedOffColor = (FOCUSEDOBJTYPE == "Action") ? g_Flow.cfg.actionClr : g_Flow.getStep(FOCUSEDOBJID).getBorderClr(g_Flow.cfg);57 eval("document.all." + FOCUSEDOBJID + ".StrokeColor='" + focusedOffColor + "'");58 FOCUSEDOBJID = '';59 FOCUSEDOBJTYPE = '';60}61function moveStep(moveId) {62 if (!LINKSTART)63 dragIt(moveId);64 else65 linkStart(moveId);66}67function redrawAction(Action) {68 var aId = Action.id;69 document.getElementById(aId).style.zIndex = CONST_LAY_TOPPEST;70 Action.zIndex = CONST_LAY_TOPPEST;71 var pts = Action.getActionPoints();72 document.getElementById(aId).points.value = getPointsStr(pts);73 if (Action.fromStep.type != "2") return;74 var textpts = getTextPoints(pts);75 if (textpts.length == 0) return;76 var judgetext = document.getElementById("judgeresult" + aId);77 judgetext.style.left = textpts[0];78 judgetext.style.top = textpts[1];79}80function innerMove(newLeft, newTop) {81 var Step = g_Flow.getStep(MOVEOBJ.id);82 if (null == Step) return;83 Step.x = newLeft;84 Step.y = newTop;85 for (var i = 0; i < Step.getEntryCount(); i++)86 redrawAction(Step.entry(i));87 for (var j = 0; j < Step.getExitCount(); j++)88 redrawAction(Step.exit(j));89}90function moveIt() {91 if (MOVEOBJ == null) return false;92 MOVEFLAG = true;93 var newX = (event.clientX + document.body.scrollLeft);94 var newY = (event.clientY + document.body.scrollTop);95 var distanceX = parseInt(XRATE * (newX - CURRENTX), 10); //X×ø±ê»»Ëã96 var distanceY = parseInt(YRATE * (newY - CURRENTY), 10); //Y×ø±ê»»Ëã 97 var newLeft = parseInt(MOVEOBJ.style.left, 10) + distanceX;98 var newTop = parseInt(MOVEOBJ.style.top, 10) + distanceY;99 // if (inRect(newLeft, newTop, 0, 0, COORDX - parseInt(MOVEOBJ.style.width, 10), COORDY - parseInt(MOVEOBJ.style.height, 10))) {100 if ((newLeft >= 0)&&(newTop >= 0)) {101 MOVEOBJ.style.left = newLeft;102 MOVEOBJ.style.top = newTop;103 MOVEOBJ.style.zIndez = CONST_LAY_TOPPEST;104 CURRENTX = newX;105 CURRENTY = newY;106 innerMove(newLeft, newTop);107 }108 event.returnValue = false;109 return false;110}111function innerDrop() {112 if (!MOVEFLAG) return;113 MOVEFLAG = false;114 if (MOVEOBJ == null) return;115 var Step = g_Flow.getStep(MOVEOBJ.id);116 if (null == Step) return;117 Step.x = MOVEOBJ.style.left;118 Step.y = MOVEOBJ.style.top;119 Step.zIndex = CONST_LAY_TOPPEST;120}121function dropIt() {122 innerDrop();123 MOVEOBJ = null;124 VML_FLOWOBJ.releaseCapture();125 return true;126}127function dragIt(obj) {128 MOVEFUNC = document.onmousemove;129 document.onmousemove = moveIt;130 document.onmouseup = dropIt;131 MOVEOBJ = obj;132 CURRENTX = (event.clientX + document.body.scrollLeft);133 CURRENTY = (event.clientY + document.body.scrollTop);134 var pt = new f_Point();135 pt.parse(VML_FLOWOBJ.coordsize.value);136 COORDX = pt.x;137 COORDY = pt.y;138 XRATE = COORDX / parseInt(VML_FLOWOBJ.style.width, 10);139 YRATE = COORDY / parseInt(VML_FLOWOBJ.style.height, 10);140 VML_FLOWOBJ.setCapture();141 return true;142}143function getPosition(obj) {144 var top = obj.offsetTop;145 var left = obj.offsetLeft;146 while (obj = obj.offsetParent) {147 top += obj.offsetTop;148 left += obj.offsetLeft;149 };150 return { "top": top, "left": left };151}152/*153function ScreenToClientX(obj, coord, x) { return parseInt((x - parseInt(obj.style.left, 10)) * coord.x / parseInt(obj.style.width, 10), 10); }154function ScreenToClientY(obj, coord, y) { return parseInt((y - parseInt(obj.style.top, 10)) * coord.y / parseInt(obj.style.height, 10), 10); }155*/156function ScreenToClientX(obj, coord, x) {157 var pos = getPosition(obj);158 return parseInt((x + parseInt(obj.parentElement.scrollLeft, 10) - pos.left) * coord.x / parseInt(obj.style.width, 10), 10); 159}160function ScreenToClientY(obj, coord, y) {161 var pos = getPosition(obj);162 return parseInt((y + parseInt(obj.parentElement.scrollTop, 10) - pos.top) * coord.y / parseInt(obj.style.height, 10), 10); 163}164function linkStart(startStep) {165 if (g_Flow.getStep(startStep.id).flowStep.type == "3")166 return;167 LINKSTARTSTEPID = startStep.id;168 MOVEFUNC = document.onmousemove;169 document.onmousemove = linkIt;170 document.onmouseup = linkEnd;171 var coord = new f_Point();172 coord.parse(VML_FLOWOBJ.coordsize.value);173 var x = ScreenToClientX(VML_FLOWOBJ, coord, event.clientX + document.body.scrollLeft);174 var y = ScreenToClientY(VML_FLOWOBJ, coord, event.clientY + document.body.scrollTop);175 VML_LINKLINE.from = x + "," + y;176 VML_LINKLINE.to = x + "," + y;177 VML_FLOWOBJ.setCapture();178 return true;179}180function inRect(x, y, left, top, width, height) {181 return !((x < left) || (y < top) || (x > left + width) || (y > top + height));182}183function linkIt() {184 var coord = new f_Point();185 coord.parse(VML_FLOWOBJ.coordsize.value);186 var xScreen = event.clientX + document.body.scrollLeft;187 var yScreen = event.clientY + document.body.scrollTop;188 var x = ScreenToClientX(VML_FLOWOBJ, coord, xScreen);189 var y = ScreenToClientY(VML_FLOWOBJ, coord, yScreen);190 // if (inRect(x, y, 0, 0, coord.x, coord.y))191 // VML_LINKLINE.to = x + "," + y;192 event.returnValue = false;193 //¿ØÖƹö¶¯Ìõ194 var div = VML_FLOWOBJ.parentElement;195 VML_LINKLINE.to = x + "," + y;196 var divPos = getPosition(div); //µÃµ½divµÄ¾ø¶ÔλÖÃ197 if (xScreen <= divPos.left)198 div.scrollLeft = Math.max(0, div.scrollLeft - 100);199 if (yScreen <= divPos.top)200 div.scrollTop = Math.max(0, div.scrollTop - 100);201 if (xScreen >= divPos.left + parseInt(div.clientWidth, 10))202 div.scrollLeft = Math.min(div.scrollLeft + 100, divPos.left + parseInt(div.scrollWidth, 10) - parseInt(div.clientWidth, 10) - 50); //div.scrollWidth203 if (yScreen >= divPos.top + parseInt(div.clientHeight, 10))204 div.scrollTop = Math.min(div.scrollTop + 100, divPos.top + parseInt(div.scrollHeight, 10) - parseInt(div.clientHeight, 10) - 50);205 return false;206}207function linking(x, y) {208 var linkEndStep = null;209 for (var i = 0; i < g_Flow.getStepCount(); i++) {210 var Step = g_Flow.step(i);211 if (Step.show < 1)212 continue;213 if (!inRect(x, y, parseInt(Step.x, 10), parseInt(Step.y, 10), parseInt(Step.width, 10), parseInt(Step.height, 10)))214 continue;215 if (null == linkEndStep) {216 linkEndStep = Step;217 } else {218 var newZ = parseInt(Step.zIndex, 10);219 if (isNaN(newZ))220 continue;221 if (parseInt(linkEndStep.zIndex, 10) < newZ)222 linkEndStep = Step;223 }224 }225 if (null == linkEndStep)226 return;227 if (linkEndStep.id == LINKSTARTSTEPID)228 return;229 /*if (linkEndStep.flowStep.type == "1") {230 alert("²»ÐíÓлؿªÊ¼²½ÖèµÄ¶¯×÷");231 return;232 }*/233 for (var j = 0; j < linkEndStep.getEntryCount(); j++) {234 var Action = linkEndStep.entry(j);235 if (Action.fromStep.id == LINKSTARTSTEPID) {236 alert("ºÍÒÑÓж¯×÷Öظ´£¬ÇëÖØÐÂÑ¡Ôñ£¡");237 return;238 }239 }240 workFlowDialog(LINKSTARTSTEPID + "," + linkEndStep.id, "Action");241}242function linkEnd() {243 document.onmousemove = MOVEFUNC;244 document.onmouseup = null;245 if (LINKSTARTSTEPID != '') {246 var coord = new f_Point();247 coord.parse(VML_FLOWOBJ.coordsize.value);248 var x = ScreenToClientX(VML_FLOWOBJ, coord, event.clientX + document.body.scrollLeft);249 var y = ScreenToClientY(VML_FLOWOBJ, coord, event.clientY + document.body.scrollTop);250 linking(x, y);251 }252 LINKSTARTSTEPID = '';253 VML_LINKLINE.from = "0,0";254 VML_LINKLINE.to = "0,0";255 VML_FLOWOBJ.releaseCapture();256}257function setStepOffset(o, key) {258 var Step = g_Flow.getStep(o.id);259 if (null == Step)260 return;261 if (event.ctrlKey) {262 switch (key) {263 case 37: Step.width--; o.style.width = parseInt(o.style.width, 10) - 1; return;264 case 38: Step.height--; o.style.height = parseInt(o.style.height, 10) - 1; return;265 case 39: Step.width++; o.style.width = parseInt(o.style.width, 10) + 1; return;266 case 40: Step.height++; o.style.height = parseInt(o.style.height, 10) + 1; return;267 default: return;268 }269 }270 switch (key) {271 case 37: Step.x--; o.style.left = parseInt(o.style.left, 10) - 1; return;272 case 38: Step.y--; o.style.top = parseInt(o.style.top, 10) - 1; return;273 case 39: Step.x++; o.style.left = parseInt(o.style.left, 10) + 1; return;274 case 40: Step.y++; o.style.top = parseInt(o.style.top, 10) + 1; return;275 default: return;276 }277}278function getGnrFlowStepEvents(flowStep) {279 return (flowStep.type == "2") ? " onkeydown='setStepOffset(this,event.keyCode);if (event.keyCode==46) delStep(this.id);'" : " onkeydown='setStepOffset(this,event.keyCode);'";280}281function getJdgFlowStepEvents(flowStep) {282 return " onkeydown='setStepOffset(this,event.keyCode);if (event.keyCode==46) delStep(this.id);'";283}284function getStepEvents(Step) {285 var id = Step.id;286 var type = Step.type;287 var eventstr = 'onmouseover=\'this.style.cursor="hand";\' onmousedown=\'cleancontextMenu();objFocusedOn(this.id,"'288 + type + '");moveStep(this);\' ondblclick="editStep(this.id,\'' + type + '\')" oncontextmenu=\'objFocusedOn(this.id,"'289 + type + '");stepContextMenu(this.id,"' + type + '","' + (type == "1" ? Step.flowStep.type : "") + '");return false;\'';290 if (type == "1")291 return eventstr + getGnrFlowStepEvents(Step.flowStep);292 return eventstr + getJdgFlowStepEvents(Step.flowStep);293}294function getActionEvents(Action) {295 return 'onmousedown=\'cleancontextMenu();objFocusedOn(this.id,"Action");\' ondblclick=\'editAction(this.id,"Action")\' oncontextmenu=\'objFocusedOn(this.id,"Action");actionContextMenu(this.id);return false;\''296}297function redrawVML() {298 var flowStepInfo = [];299 var flowActionInfo = [];300 for (var i = 0; i < g_Flow.getStepCount(); i++) {301 var Step = g_Flow.step(i);302 var nShowState = parseInt(Step.show);303 if (isNaN(nShowState) || (nShowState <= 0))304 continue;305 flowStepInfo.push(Step.getShape(g_Flow.cfg));306 }307 for (i = 0; i < g_Flow.getActionCount(); i++) {308 var Action = g_Flow.action(i);309 flowActionInfo.push(Action.getShape(g_Flow.cfg));310 }311 flowChart.redrawFlow(flowStepInfo, flowActionInfo);312 flowChart.updateCameraPos(flowStepInfo);313 drawTreeView();314 FOCUSEDOBJID = "";315 FOCUSEDOBJTYPE = "";316}317function flowContextMenu() {318 menuArray = {319 f: [320 { img: "/i/flow_image/add_step.gif", text: "Ìí¼Óв½Öè", url: "", click: function () { newStep("1"); } },321 { img: "/i/flow_image/add_step.gif", text: "Ìí¼ÓÐÂÌõ¼þ", url: "", click: function () { newStep("2"); } },322 { img: "/i/flow_image/add_action.gif", text: "Ìí¼Óж¯×÷", url: "", click: function () { newAction(); } },323 { img: "/i/flow_image/refresh_vml.gif", text: "Ë¢ÐÂÁ÷³Ìͼ", url: "", click: function () { redrawVML(); } },324 { img: "/i/flow_image/del_obj.gif", text: "ÉèÖøºÔðÈË", url: "", click: function () { setStepPriv("-1"); } },325 { img: "/i/flow_image/del_obj.gif", text: "ÉèÖð²È«Ô±", url: "", click: function () { setStepPriv("-2"); } },326 { img: "/i/flow_image/yaodian.gif", text: "ÉèÖüì²éÒªµã", url: "", click: function () { setFlowInfo(3); } },327 { img: "/i/flow_image/yaodian.gif", text: "ÉèÖôò»ØÀàÐÍ", url: "", click: function () { setFlowInfo(4); } },328 ]329 };330 //ShowMenu("f", window.event.x, window.event.y);331 ShowContextMenu(menuArray.f, window.event.x, window.event.y);332 return 333 var menuSrc = '<menu><entity id="c0"><description>Ìí¼Óв½Öè</description><image>/i/flow_image/add_step.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();newStep("1");</onClick><contents></contents></entity>';334 menuSrc += '<entity id="c1"><description>Ìí¼ÓÐÂÌõ¼þ</description><image>/i/flow_image/add_step.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();newStep("2");</onClick><contents></contents></entity>';335 menuSrc += '<entity id="c2"><description>Ìí¼Óж¯×÷</description><image>/i/flow_image/add_action.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();newAction();</onClick><contents></contents></entity>';336 menuSrc += '<entity id="c3"><description>Ë¢ÐÂÁ÷³Ìͼ</description><image>/i/flow_image/refresh_vml.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();redrawVML();</onClick><contents></contents></entity>';337 menuSrc += '<entity id="c4"><description>ÉèÖøºÔðÈË</description><image>/i/flow_image/del_obj.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();setStepPriv("-1");</onClick><contents></contents></entity>';338 menuSrc += '<entity id="c5"><description>ÉèÖð²È«Ô±</description><image>/i/flow_image/del_obj.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();setStepPriv("-2");</onClick><contents></contents></entity>';339 menuSrc += '<entity id="c6"><description>ÉèÖüì²éÒªµã</description><image>/i/flow_image/yaodian.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();setFlowInfo(3);</onClick><contents></contents></entity>';340 menuSrc += '<entity id="c7"><description>ÉèÖôò»ØÀàÐÍ</description><image>/i/flow_image/yaodian.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();setFlowInfo(4);</onClick><contents></contents></entity>';341 menuSrc += '</menu>';342 showContextMenu(menuSrc);343}344function stepContextMenu(stepId, stepType, flowType) {345 var arr = [];346 arr.push({ img: "/i/flow_image/edit_obj.gif", text: 'Ð޸IJ½Öè[' + stepId + ']', url: "", click: function () { editStep(stepId, stepType); } });347 if (flowType != '1' && flowType != '3') {348 arr.push({ img: "/i/flow_image/del_obj.gif", text: 'ɾ³ý²½Öè[' + stepId + ']', url: "", click: function () { delStep(stepId); } });349 arr.push({ img: "/i/flow_image/del_obj.gif", text: 'ÓÀ¾Ãɾ³ý[' + stepId + ']', url: "", click: function () { deleteStep(stepId); } });350 }351 if ((stepType == '1') && (flowType != "3")) {352 arr.push({ img: "/i/flow_image/add_step.gif", text: 'Ϊģ°å´´½¨[' + stepId + ']', url: "", click: function () { newStepCopy(stepId); } });353 var thisStep = g_Flow.getStep(stepId);354 if (thisStep.flowStep.subFlowId != "")355 arr.push({ img: "/i/flow_image/del_obj.gif", text: '²é¿´×ÓÁ÷³Ì[' + stepId + ']', url: "", click: function () { editFlowDetail(thisStep.flowStep.subFlowId); } });356 else357 arr.push({ img: "/i/flow_image/del_obj.gif", text: 'ÉèÖÃȨÏÞ[' + stepId + ']', url: "", click: function () { setStepPriv(stepId); } });358 arr.push({ img: "/i/flow_image/yaodian.gif", text: 'ÉèÖù¤×÷Ö°Ôð[' + stepId + ']', url: "", click: function () { setStepDuty(stepId); } });359 if (flowType != "1") {360 arr.push({ img: "/i/flow_image/yaodian.gif", text: 'ÉèÖüì²éÒªµã[' + stepId + ']', url: "", click: function () { setStepInfo(3,stepId); } });361 arr.push({ img: "/i/flow_image/yaodian.gif", text: 'ÉèÖôò»ØÀàÐÍ[' + stepId + ']', url: "", click: function () { setStepInfo(4,stepId); } });362 }363 }364 arr.push({ img: "/i/flow_image/refresh_vml.gif", text: 'Ë¢ÐÂÁ÷³Ìͼ', url: "", click: function () { redrawVML(); } });365 menuArray = { s: arr };366 //ShowMenu("s", window.event.x, window.event.y);367 ShowContextMenu(menuArray.s, window.event.x, window.event.y);368 return;369 var menuSrc = '<menu><entity id="c0"><description>Ð޸IJ½Öè[' + stepId + ']</description><image>/i/flow_image/edit_obj.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();editStep("' + stepId + '","' + stepType + '");</onClick><contents></contents></entity>';370 if (flowType != '1' && flowType != '3') {371 menuSrc += '<entity id="c1"><description>ɾ³ý²½Öè[' + stepId + ']</description><image>/i/flow_image/del_obj.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();delStep("' + stepId + '");</onClick><contents></contents></entity>';372 menuSrc += '<entity id="c2"><description>ÓÀ¾Ãɾ³ý[' + stepId + ']</description><image>/i/flow_image/del_obj.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();deleteStep("' + stepId + '");</onClick><contents></contents></entity>';373 }374 if ((stepType == '1') && (flowType != "3")) {375 menuSrc += '<entity id="c4"><description>Ϊģ°å´´½¨[' + stepId + ']</description><image>/i/flow_image/add_step.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();newStepCopy("' + stepId + '");</onClick><contents></contents></entity>';376 var thisStep = g_Flow.getStep(stepId);377 if (thisStep.flowStep.subFlowId != "")378 menuSrc += '<entity id="c5"><description>²é¿´×ÓÁ÷³Ì[' + stepId + ']</description><image>/i/flow_image/del_obj.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();editFlowDetail("' + thisStep.flowStep.subFlowId + '");</onClick><contents></contents></entity>';379 else380 menuSrc += '<entity id="c3"><description>ÉèÖÃȨÏÞ[' + stepId + ']</description><image>/i/flow_image/del_obj.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();setStepPriv("' + stepId + '");</onClick><contents></contents></entity>';381 menuSrc += '<entity id="c6"><description>ÉèÖù¤×÷Ö°Ôð[' + stepId + ']</description><image>/i/flow_image/yaodian.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();setStepDuty("' + stepId + '");</onClick><contents></contents></entity>';382 if (flowType != "1"){383 menuSrc += '<entity id="c7"><description>ÉèÖüì²éÒªµã[' + stepId + ']</description><image>/i/flow_image/yaodian.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();setStepInfo(3,"' + stepId + '");</onClick><contents></contents></entity>';384 menuSrc += '<entity id="c8"><description>ÉèÖôò»ØÀàÐÍ[' + stepId + ']</description><image>/i/flow_image/yaodian.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();setStepInfo(4,"' + stepId + '");</onClick><contents></contents></entity>';385 }386 }387 menuSrc += '<entity id="c4"><description>Ë¢ÐÂÁ÷³Ìͼ</description><image>/i/flow_image/refresh_vml.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();redrawVML();</onClick><contents></contents></entity></menu>';388 showContextMenu(menuSrc);389}390function actionContextMenu(actionId) {391 menuArray = {392 a: [393 { img: "/i/flow_image/add_step.gif", text: "Ð޸Ķ¯×÷[" + actionId + "]", url: "", click: function () { editAction(actionId); } },394 { img: "/i/flow_image/add_step.gif", text: 'ɾ³ý¶¯×÷[' + actionId + ']', url: "", click: function () { delAction(actionId); } },395 { img: "/i/flow_image/add_step.gif", text: "Ë¢ÐÂÁ÷³Ìͼ", url: "", click: function () { redrawVML(); } }396 ]397 };398 //ShowMenu("a", window.event.x, window.event.y);399 ShowContextMenu(menuArray.a, window.event.x, window.event.y);400 return;401 var menuSrc = '<menu><entity id="c0"><description>Ð޸Ķ¯×÷[' + actionId + ']</description><image>/i/flow_image/edit_obj.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();editAction("' + actionId + '");</onClick><contents></contents></entity>';402 menuSrc += '<entity id="c1"><description>ɾ³ý¶¯×÷[' + actionId + ']</description><image>/i/flow_image/del_obj.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();delAction("' + actionId + '");</onClick><contents></contents></entity>';403 menuSrc += '<entity id="c2"><description>Ë¢ÐÂÁ÷³Ìͼ</description><image>/i/flow_image/refresh_vml.gif</image><fontcolor>' + MenuTextColor_enable + '</fontcolor><onClick>cleancontextMenu();redrawVML();</onClick><contents></contents></entity></menu>';404 showContextMenu(menuSrc);405}406function showContextMenu(menuSrc) {407 var root = createXMLRoot(menuSrc);408 var menuText = '' + root.xml + ''409 loadContextMenu(menuText, '/XML/contextmenu.xsl')410}411function setStepPriv(stepId) { workFlowDialog(stepId, "Priv"); }412function setStepDuty(stepId) { workFlowDialog(stepId, "Duty"); }413function setFlowInfo(info) {414 switch (info) {415 case 3:416 Ysh.Web.showModalDialog("_setFlowYaodian.aspx?flowid=" + g_Flow.id + "&a=" + new Date(), window, 390, 480);417 break;418 case 4:419 Ysh.Web.showModalDialog("_setFlowBackType.aspx?flowid=" + g_Flow.id + "&a=" + new Date(), window, 390, 480);420 break;421 default:422 break;423 }424}425function setStepInfo(info, stepId) {426 switch (info) {427 case 3:428 Ysh.Web.showModalDialog("_setStepYaodian.aspx?flowid=" + g_Flow.id + "&nodeid=" + stepId + "&a=" + new Date(), window, 390, 480);429 break;430 case 4:431 Ysh.Web.showModalDialog("_setStepBackType.aspx?flowid=" + g_Flow.id + "&nodeid=" + stepId + "&a=" + new Date(), window, 390, 480);432 break;433 default:434 break;435 }436}437function editFlowDetail(flowId) {438 Ysh.Web.showModalDialog(location.pathname + "?s=1&flowid=" + flowId + "&a" + new Date(), "", 900, 700);439}440var dialogURL = "";441function workFlowDialog(id, type,f) {442 switch (type) {443 case 'Step1': dialogURL = id == null ? '_stepdialog.aspx' : '_stepdialog.aspx?stepid=' + id; break;444 case 'Step2': dialogURL = id == null ? '_judgedialog.htm' : '_judgedialog.htm?stepid=' + id; break;445 case 'Action': dialogURL = id == null ? '_actiondialog.htm' : '_actiondialog.htm?actionid=' + id; break;446 case 'Flow': dialogURL = id == null ? '_flowdialog.aspx' : '_flowdialog.aspx?flowid=' + id; break;447 case 'Priv': dialogURL = id == null ? '_privdialog.htm' : '_privdialog.htm?stepid=' + id; break;448 case 'Duty': dialogURL = "nodedutydlg.aspx?flowid=" + g_Flow.id + "&nodeid=" + id + "&a=" + new Date(); break;449 case 'StepCopy': dialogURL = id == null ? '_stepdialog.aspx' : '_stepdialog.aspx?copystepid=' + id; break;450 default:451 alert(type + "ÀàÐÍûÓÐʵÏÖ");452 return;453 }454 //var dialog = window.showModalDialog(dialogURL, window, "dialogWidth:373px; dialogHeight:460px; center:yes; help:no; resizable:no; status:no");455 Ysh.Web.showModalDialog(dialogURL, window, 390, 480, function (dialog) {456 if ((typeof (dialog) == "undefined") || (dialog == ""))457 return true;458 id = dialog;459 switch (type) {460 case 'Action': redrawVML(); objFocusedOn(id, "Action"); break;461 case 'Flow': redrawVML(); break;462 case 'Priv': if ((id != "-1") && (id != "-2")) objFocusedOn(id, "Step"); break;463 case 'Duty': objFocusedOn(id, "Step"); break;464 default: redrawVML(); objFocusedOn(id, "Step"); break;465 }466 if (f)467 f();468 return true;469 });470}471function drawTreeView() {472 document.all.treeview.src = "_flowtree.htm";...
useQueryPush.ts
Source:useQueryPush.ts
...10 throw new Error(11 'You must use useQueryPush hook inside BrowserLocationQuery'12 );13 const push = (path: string, values: {}, innerReplace = false) => {14 cleanContext(context);15 const action = replace || innerReplace ? history.replace : history.push;16 if (Object.keys(values).length === 0) {17 return action(path);18 }19 20 const query = stringifyQuery(values, context.cryptoOptions);21 return action(`${path}?${query}`);22 };23 return push;24};...
clean-context.spec.js
Source:clean-context.spec.js
...8 const cleanedContext = {9 licenseName: 'Apache--2__0',10 projectVersion: '1.0__0--alpha'11 }12 const result = cleanContext(context)13 expect(result).toEqual(cleanedContext)14 })...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');3 if (err) return console.log(err);4 wpt.cleanContext(data.data.testId, function(err, data) {5 if (err) return console.log(err);6 console.log(data);7 });8});9var wpt = require('webpagetest');10var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');11 if (err) return console.log(err);12 wpt.cleanRun(data.data.testId, function(err, data) {13 if (err) return console.log(err);14 console.log(data);15 });16});17var wpt = require('webpagetest');18var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');19wpt.getLocations(function(err, data) {20 if (err) return console.log(err);21 console.log(data);22});23var wpt = require('webpagetest');24var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');25wpt.getTesters(function(err, data) {26 if (err) return console.log(err);27 console.log(data);28});29var wpt = require('webpagetest');30var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');31wpt.getTesters(function(err, data) {32 if (err) return console.log(err);33 console.log(data);34});35var wpt = require('webpagetest');36var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');37wpt.getTesters(function(err, data) {38 if (err) return console.log(err);39 console.log(data);40});
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.8f6b7c6b3f6d2a2e3a8c3e3f3d3d2c2b');3 if (err) return console.error(err);4 wpt.getTestResults(data.data.testId, function(err, data) {5 if (err) return console.error(err);6 wpt.cleanContext(data.data.runs[1].firstView, function(err, data) {7 if (err) return console.error(err);8 console.log(data);9 });10 });11});12var wpt = require('webpagetest');13var wpt = new WebPageTest('www.webpagetest.org', 'A.8f6b7c6b3f6d2a2e3a8c3e3f3d3d2c2b');14 if (err) return console.error(err);15 wpt.getTestResults(data.data.testId, function(err, data) {16 if (err) return console.error(err);17 wpt.cleanContext(data.data.runs[1].firstView, function(err, data) {18 if (err) return console.error(err);19 console.log(data);20 });21 });22});23var wpt = require('webpagetest');24var wpt = new WebPageTest('www.webpagetest.org', 'A.8f6b7c6b3f6d2a2e3a8c3e3f3d3d2c2b');25 if (err) return console.error(err);26 wpt.getTestResults(data.data.testId, function(err, data) {27 if (err) return console.error(err);28 wpt.cleanContext(data.data.runs[1].firstView, function(err, data) {29 if (err) return console.error(err);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!