How to use nodeValues method in mountebank

Best JavaScript code snippet using mountebank

tree.js

Source:tree.js Github

copy

Full Screen

1var lastSpan='';2var ifCloseAll=0;3//20110818 BMSA-54 权限树目录菜单可全选 begin4var hasForderCheck = true;//目录菜单前面是否要checkbox5//20110818 BMSA-54 权限树目录菜单可全选 end6// Arrays for nodes and icons7var nodes = new Array();8var openNodes = new Array();9var icons = new Array(6);10// Loads all icons that are used in the tree11function preloadIcons() {12 icons[0] = new Image();13 icons[0].src = "../../../images/plus.gif";14 icons[1] = new Image();15 icons[1].src = "../../../images/plusbottom.gif";16 icons[2] = new Image();17 icons[2].src = "../../../images/minus.gif";18 icons[3] = new Image();19 icons[3].src = "../../../images/minusbottom.gif";20 icons[4] = new Image();21 icons[4].src = "../../../images/folder.gif";22 icons[5] = new Image();23 icons[5].src = "../../../images/folderopen.gif";24}25// Create the tree26function createTree(arrName, startNode, openNode) {27 nodes = arrName;28 if (nodes.length > 0) {29 preloadIcons();30 if (startNode == null) startNode = 0;31 if (openNode != 0 || openNode != null) setOpenNodes(openNode);32 if (startNode !=0) {33 //var nodeValues = nodes[getArrayId(startNode)].split("|");34 document.write("<img id=\"menuHome\" src=\"../../../images/home.gif\" style=\"cursor:hand;\" onclick=\"closeAll(1);\" align=\"absbottom\"><br />");35 } else{36 document.write("<img id=\"menuHome\" src=\"../../../images/home.gif\" style=\"cursor:hand;\" onclick=\"closeAll(1);\" align=\"absbottom\"><br />");37 }38 var recursedNodes = new Array();39 addNode(startNode, recursedNodes);40 }41}42// Returns the position of a node in the array43function getArrayId(node) {44 for (i=0; i<nodes.length; i++) {45 var nodeValues = nodes[i].split("|");46 if (nodeValues[0]==node) return i;47 }48}49// Puts in array nodes that will be open50function setOpenNodes(openNode) {51 for (i=0; i<nodes.length; i++) {52 var nodeValues = nodes[i].split("|");53 if (nodeValues[0]==openNode) {54 openNodes.push(nodeValues[0]);55 setOpenNodes(nodeValues[1]);56 }57 }58}59// Checks if a node is open60function isNodeOpen(node) {61 for (i=0; i<openNodes.length; i++)62 if (openNodes[i]==node) return true;63 return false;64}65// Checks if a node has any children66function hasChildNode(parentNode) {67 for (i=0; i< nodes.length; i++) {68 var nodeValues = nodes[i].split("|");69 if (nodeValues[1] == parentNode) return true;70 }71 return false;72}73// Checks if a node is the last sibling74function lastSibling (node, parentNode) {75 var lastChild = 0;76 for (i=0; i< nodes.length; i++) {77 var nodeValues = nodes[i].split("|");78 if (nodeValues[1] == parentNode)79 lastChild = nodeValues[0];80 }81 if (lastChild==node) return true;82 return false;83}84// Adds a new node in the tree85function addNode(parentNode, recursedNodes) {86 for (var i = 0; i < nodes.length; i++) {87 var nodeValues = nodes[i].split("|");88 if (nodeValues[1] == parentNode) {89 var ls = lastSibling(nodeValues[0], nodeValues[1]);90 var hcn = hasChildNode(nodeValues[0]);91 var ino = isNodeOpen(nodeValues[0]);92 // Write out line & empty icons93 for (g=0; g<recursedNodes.length; g++) {94 if (recursedNodes[g] == 1) document.write("<img src=\"\../../../images/line.gif\" align=\"absbottom\" />");95 else document.write("<img src=\"../../../images/empty.gif\" align=\"absbottom\" />");96 }97 // put in array line & empty icons98 if (ls) recursedNodes.push(0);99 else recursedNodes.push(1);100 // Write out join icons101 if (hcn) {102 if (ls) {103 document.write("<a href=\"javascript: oc('" + nodeValues[0] + "', 1);\"><img id=\"join" + nodeValues[0] + "\" style=\"border:0px;\" src=\"../../../images/");104 if (ino) document.write("minus");105 else document.write("plus");106 document.write("bottom.gif\" align=\"absbottom\" /></a>");107 } else {108 document.write("<a href=\"javascript: oc('" + nodeValues[0] + "', 0);\"><img id=\"join" + nodeValues[0] + "\" style=\"border:0px;\" src=\"../../../images/");109 if (ino) document.write("minus");110 else document.write("plus");111 document.write(".gif\" align=\"absbottom\" /></a>");112 }113 } else {114 if (ls) document.write("<img src=\"../../../images/join.gif\" align=\"absbottom\" />");115 else document.write("<img src=\"../../../images/joinbottom.gif\" align=\"absbottom\" />");116 }117 // Start link118 // Write out folder & page icons & node name119 if (hcn) {120 document.write("<img id=\"icon" + nodeValues[0] + "\" src=\"../../../images/folder")121 if (ino) document.write("open");122 document.write(".gif\" align=\"absbottom\" />");123 //BMSA-54 权限树目录菜单可全选 begin124 if (hasForderCheck) {125 try {126 document.write("<span style=\"cursor:hand\" id=\"SD"+i+"\" onmousedown=\"changeMyStyle(this); \" ><input type='checkbox' id='pid"+nodeValues[0]+"' name='pid'>"+nodeValues[2]+"</input></span><br />");127 var fchk = document.getElementById('pid'+nodeValues[0]);128 fchk.onclick=function() {129 with(this.parentNode.nextSibling.nextSibling) {130 var chs = getElementsByTagName('input');131 for ( var int = 0; int < chs.length; int++) {132 chs[int].checked = this.checked;133 }134 }135 }136 }catch(e) {137 document.write("<span style=\"cursor:hand\" id=\"SD"+i+"\" onmousedown=\"changeMyStyle(this); \" >"+nodeValues[2]+"</span><br />");138 }139 } else {140 if (ls) {141 document.write("<span style=\"cursor:hand\" id=\"SD"+i+"\" onmousedown=\"changeMyStyle(this); \" >"+nodeValues[2]+"</span><br />");142 } else {143 document.write("<span style=\"cursor:hand\" id=\"SD"+i+"\" onmousedown=\"changeMyStyle(this); \" >"+nodeValues[2]+"</span><br />");144 }145 }146 //BMSA-54 权限树目录菜单可全选 end147 } else {148 /*if( nodeValues[5] == "new"){149 document.write("<img id=\"icon" + nodeValues[0] + "\" src=\"../../../page/images/mEditor.gif\" align=\"absbottom\"/>");150 }151 else if(nodeValues[5] == "list"){152 document.write("<img id=\"icon" + nodeValues[0] + "\" src=\"../../../page/images/mReport.gif\" align=\"absbottom\"/>");153 }154 else*/155 document.write("<img id=\"icon" + nodeValues[0] + "\" src=\"../../../images/page.gif\" align=\"absbottom\"/>");156 //2011-08-23 BMSA-62 机构权限及角色权限分配,修改权限勾选项后,页面出现有js错误 begin157 document.write("<span style=\"cursor:hand\" id=\"SD"+i+"\" onmousedown=\"changeMyStyle(this)\" >"+nodeValues[2]+"</span><br />");158 //2011-08-23 BMSA-62 机构权限及角色权限分配,修改权限勾选项后,页面出现有js错误 end159 }160 // If node has children write out divs and go deeper161 if (hcn) {162 document.write("<div id=\"div" + nodeValues[0] + "\"");163 if (!ino) document.write(" style=\"display: none;\"");164 document.write(">");165 addNode(nodeValues[0], recursedNodes);166 document.write("</div>");167 }168 // remove last line or empty icon169 recursedNodes.pop();170 }171 }172}173// Opens or closes a node174function oc(node, bottom) {175 var theDiv = document.getElementById("div" + node);176 var theJoin = document.getElementById("join" + node);177 var theIcon = document.getElementById("icon" + node);178 if (theDiv.style.display == 'none') {179 if (bottom==1) theJoin.src = icons[3].src;180 else theJoin.src = icons[2].src;181 theIcon.src = icons[5].src;182 theDiv.style.display = '';183 } else {184 if (bottom==1) theJoin.src = icons[1].src;185 else theJoin.src = icons[0].src;186 theIcon.src = icons[4].src;187 theDiv.style.display = 'none';188 }189}190// Opens or closes a node191function occ(node, bottom,needopen) {192 var theDiv = document.getElementById("div" + node);193 var theJoin = document.getElementById("join" + node);194 var theIcon = document.getElementById("icon" + node);195 if (theDiv.style.display == 'none' && needopen == 1) {196 if (bottom==1) theJoin.src = icons[3].src;197 else theJoin.src = icons[2].src;198 theIcon.src = icons[5].src;199 theDiv.style.display = '';200 } else if(theDiv.style.display != 'none' && needopen == 0){201 if (bottom==1) theJoin.src = icons[1].src;202 else theJoin.src = icons[0].src;203 theIcon.src = icons[4].src;204 theDiv.style.display = 'none';205 }206}207function changeMyStyle(obj){208 if (lastSpan!==''){209 document.all.item(lastSpan).style.color='';210 document.all.item(lastSpan).style.backgroundColor=''211 document.all.item(lastSpan).style.borderStyle='none';212 document.all.item(lastSpan).style.borderWidth=0;213 document.all.item(lastSpan).style.borderColor='';214 //obj.style.borderStyle='none';215 }216 if (event.button==1){217 obj.style.color='#000000';218 obj.style.backgroundColor='#C6C6C6';219 obj.style.borderWidth=1;220 obj.style.borderColor='#000000';221 obj.style.borderStyle='groove';//'dotted';222 }223 lastSpan=obj.id;224}225function closeAll(needopen){226 if (ifCloseAll==0){227 document.all.menuHome.title="Tree";228 for (var i = 0; i < nodes.length; i++) {229 var nodeValues = nodes[i].split("|");230 var hcn = hasChildNode(nodeValues[0]);231 if(hcn)232 occ(nodeValues[0], 1,needopen);233 }234 }235 else{236 document.all.menuHome.title="Tree";237 for (var i = 0; i < nodes.length; i++) {238 var nodeValues = nodes[i].split("|");239 var hcn = hasChildNode(nodeValues[0]);240 if(hcn)241 occ(nodeValues[0], 0,needopen);242 }243 ifCloseAll = 1;244 }245}246// Push and pop not implemented in IE(crap!)247if(!Array.prototype.push) {248 function array_push() {249 for(var i=0;i<arguments.length;i++)250 this[this.length]=arguments[i];251 return this.length;252 }253 Array.prototype.push = array_push;254}255if(!Array.prototype.pop) {256 function array_pop(){257 lastElement = this[this.length-1];258 this.length = Math.max(this.length-1,0);259 return lastElement;260 }261 Array.prototype.pop = array_pop;262}263//BMSA-54 权限树目录菜单可全选264//flag=1 全选中,flag=0 全不选, 其它则根据子节点checkbox判断是否要勾选父节点的checkbox265function pcheck(flag) {266 if(hasForderCheck) {267 var pid = document.getElementsByName('pid');268 for(var i = pid.length - 1; i >= 0; i --) {269 if (flag==1) {270 pid[i].checked = true;271 continue;272 }273 if (flag==0) {274 pid[i].checked = false;275 continue;276 }277 with(pid[i].parentNode.nextSibling.nextSibling) {278 var chs = getElementsByTagName('input');279 var f = false;280 for ( var int = 0; int < chs.length; int++) {281 if(chs[int].checked){282 f = true;283 break;284 }285 }286 if(f) {287 pid[i].checked = true;288 }289 }290 }291 }...

Full Screen

Full Screen

EgovMenuCreat.js

Source:EgovMenuCreat.js Github

copy

Full Screen

1/*2 * 노드 , 트리 구성 정보 선언3 */4var treeNodes = new Array();5var openTreeNodes = new Array();6var treeIcons = new Array(6);7//var imgpath = "/images/tree/";89/*10 * 노드 , 트리 구성 이미지 정보11 */12function preloadIcons() {13 treeIcons[0] = new Image();14 treeIcons[0].src = imgpath+"menu_plus.gif";15 treeIcons[1] = new Image();16 treeIcons[1].src = imgpath+"menu_plusbottom.gif";17 treeIcons[2] = new Image();18 treeIcons[2].src = imgpath+"menu_minus.gif";19 treeIcons[3] = new Image();20 treeIcons[3].src = imgpath+"menu_minusbottom.gif";21 treeIcons[4] = new Image();22 treeIcons[4].src = imgpath+"menu_folder.gif";23 treeIcons[5] = new Image();24 treeIcons[5].src = imgpath+"menu_folderopen.gif";25}26/*27* 트리생성함수28*/29function createTree(arrName ) {30 var startNode, openNode;31 treeNodes = arrName;32 if (treeNodes.length > 0) {33 preloadIcons();34 if (startNode == null) startNode = 0;35 if (openNode != 0 || openNode != null) setOpenTreeNodes(openNode);36 if (startNode !=0) {37 var nodeValues = treeNodes[getTreeArrayId(startNode)].split("|");38 } else document.write("<input type='checkbox' name='checkAll' class='check2' onclick='javascript:fCheckAll();'>메뉴목록<br>");39 var recursedNodes = new Array();40 addTreeNode(startNode, recursedNodes);41 }42}43/*44* 노드위치 확인45*/46function getTreeArrayId(node) {47 for (i=0; i<treeNodes.length; i++) {48 var nodeValues = treeNodes[i].split("|");49 if (nodeValues[0]==node) return i;50 }51 return 0;52}53/*54* 트리 노드 열기55*/56function setOpenTreeNodes(openNode) {57 for (i=0; i<treeNodes.length; i++) {58 var nodeValues = treeNodes[i].split("|");59 if (nodeValues[0]==openNode) {60 openTreeNodes.push(nodeValues[0]);61 setOpenTreeNodes(nodeValues[1]);62 }63 } 64}65/*66* 트리노드 오픈 여부 확인67*/68function isTreeNodeOpen(node) {69 return true;70}71/*72* 하위 트리노드 존재여부 확인73*/74function hasChildTreeNode(parentNode) {75 for (i=0; i< treeNodes.length; i++) {76 var nodeValues = treeNodes[i].split("|");77 if (nodeValues[1] == parentNode) return true;78 }79 return false;80}81/*82* 트리노드 최하위 여부 확인83*/84function lastTreeSibling (node, parentNode) {85 var lastChild = 0;86 for (i=0; i< treeNodes.length; i++) {87 var nodeValues = treeNodes[i].split("|");88 if (nodeValues[1] == parentNode) lastChild = nodeValues[0];89 }90 if (lastChild==node) return true;91 return false;92}9394/*95* 신규 트리노드 추가96*/97function addTreeNode(parentNode, recursedNodes) {98 for (var i = 0; i < treeNodes.length; i++) {99 var nodeValues = treeNodes[i].split("|");100 if (nodeValues[1] == parentNode) {101 102 var lastSibling = lastTreeSibling(nodeValues[0], nodeValues[1]);103 var hasChildNode = hasChildTreeNode(nodeValues[0]);104 var isNodeOpen = isTreeNodeOpen(nodeValues[0]);105 for (g=0; g<recursedNodes.length; g++) {106 document.write("&nbsp;&nbsp;&nbsp;");107 }108 if (lastSibling) recursedNodes.push(0);109 else recursedNodes.push(1);110 document.write("&nbsp;&nbsp;&nbsp;");111 document.write("<input type='checkbox' id='"+i+"' name='checkField' class='check2' ");112 if(nodeValues[4] == 1){ document.write(" checked "); }113 document.write("onclick='javascript:fCheckDir(this.name, this.value,"+i+");' value=" + nodeValues[0] + ">");114 if (hasChildNode) {115 document.write("<img id='icon" + nodeValues[0] + "' src='"+imgpath+"menu_folder")116 if (isNodeOpen) document.write("open");117 document.write(".gif' border='0' alt='Folder' >");118 } else document.write("<img id='icon" + nodeValues[0] + "' src='"+imgpath+"menu_page.gif' border='0' align='absbottom' alt='Page'>");119 document.write("<a href=javascript:parent.temp_aa('" + treeNodes[i] + "');>");120 document.write(nodeValues[2]);121 document.write("</a><br>");122 if (hasChildNode) {123 document.write("<div id='div" + nodeValues[0] + "'");124 if (!isNodeOpen) document.write(" style='display: none;'");125 document.write(">");126 addTreeNode(nodeValues[0], recursedNodes);127 document.write("</div>");128 }129 recursedNodes.pop();130 }131 }132}133/*134* 트리노드 액션(열기,닫기)135*/136function openCloseEx(node, bottom) {137 var treeDiv = document.getElementById("div" + node);138 var treeJoin = document.getElementById("join" + node);139 var treeIcon = document.getElementById("icon" + node);140 141 if (treeDiv.style.display == 'none') {142 if (bottom==1) treeJoin.src = treeIcons[3].src;143 else treeJoin.src = treeIcons[2].src;144 treeIcon.src = treeIcons[5].src;145 treeDiv.style.display = '';146 } else {147 if (bottom==1) treeJoin.src = treeIcons[1].src;148 else treeJoin.src = treeIcons[0].src;149 treeIcon.src = treeIcons[4].src;150 treeDiv.style.display = 'none';151 }152}153if(!Array.prototype.push) {154 function fnArrayPush() {155 for(var i=0;i<arguments.length;i++)156 this[this.length]=arguments[i];157 return this.length;158 }159 Array.prototype.push = fnArrayPush;160}161if(!Array.prototype.pop) {162 function fnArrayPop(){163 lastElement = this[this.length-1];164 this.length = Math.max(this.length-1,0);165 return lastElement;166 }167 Array.prototype.pop = fnArrayPop;168}169 170/* ********************************************************171 * 모두선택 처리 함수172 ******************************************************** */173function fCheckAll() {174 var checkField = document.menuCreatManageForm.checkField;175 if(document.menuCreatManageForm.checkAll.checked) {176 if(checkField) {177 if(checkField.length > 1) {178 for(var i=0; i < checkField.length; i++) {179 checkField[i].checked = true;180 }181 } else {182 checkField.checked = true;183 }184 }185 } else {186 if(checkField) {187 if(checkField.length > 1) {188 for(var j=0; j < checkField.length; j++) {189 checkField[j].checked = false;190 }191 } else {192 checkField.checked = false;193 }194 }195 }196}197198/* ********************************************************199 * 모두선택 처리 함수200 ******************************************************** */201function fCheckDir(fCheckYB, fValue, fPath){202 var checkField = document.getElementsByName(fCheckYB); ...

Full Screen

Full Screen

EgovMainMenu.js

Source:EgovMainMenu.js Github

copy

Full Screen

1/*2 * 노드 , 트리 구성 정보 선언3 */4var treeNodes = new Array();;5var openTreeNodes = new Array();6var treeIcons = new Array(6);7var imgpath = "/images/egovframework/com/cmm/utl/";8var treeYeobu = false;9var chkValue = "";10var vHtmlCode = "";1112/*13 * 노드 , 트리 구성 이미지 정보14 */15function preloadIcons() {16 treeIcons[0] = new Image();17 treeIcons[0].src = imgpath+"menu_plus.gif";18 treeIcons[1] = new Image();19 treeIcons[1].src = imgpath+"menu_plusbottom.gif";20 treeIcons[2] = new Image();21 treeIcons[2].src = imgpath+"menu_minus.gif";22 treeIcons[3] = new Image();23 treeIcons[3].src = imgpath+"menu_minusbottom.gif";24 treeIcons[4] = new Image();25 treeIcons[4].src = imgpath+"menu_folder.gif";26 treeIcons[5] = new Image();27 treeIcons[5].src = imgpath+"menu_folderopen.gif";28} 29/*30* 트리생성함수31*/32function createTree(arrName, vYeobu, checkValue) {33 var startNode, openNode;34 treeNodes = arrName;35 treeYeobu = vYeobu;36 chkValue = checkValue;//"2000000"37 startNode = chkValue;38 if (treeNodes.length > 0) {39 preloadIcons();40 41 //vHtmlCode +="<table width='181' height='94' border='2' align='center' cellpadding='0' cellspacing='0'><tr>";42 //vHtmlCode +="<td valign='bottom' background='/images/egovframework/com/left_menu_top.gif' style='background-repeat:no-repeat'>";43 44 if (startNode == null) startNode = 0;45 if (openNode != 0 || openNode != null) setOpenTreeNodes(openNode);46 if (startNode !=0) {47 var _getTreeArrayId = getTreeArrayId(startNode)48 var nodeValues = treeNodes[getTreeArrayId(startNode)].split("|");49 //vHtmlCode +="<div class='LeftMenuTitle'><font color='#ffffff'>" + nodeValues[2] + "</font></div></td></tr>"50 } else {51 //vHtmlCode +="<img src='"+imgpath+"menu_base.gif' border='0' align='absbottom' alt='' >메뉴목록<br></td></tr>";52 }53 var recursedNodes = new Array();54 addTreeNode(startNode, recursedNodes);55 //vHtmlCode +="<tr><td height='30' valign='bottom' background='/images/egovframework/com/left_menu_btm.gif' style='background-repeat:no-repeat'>&nbsp;</td></tr></table>";56 document.write("<ul>"+vHtmlCode+"</ul>");57 }58}59/*60* 노드위치 확인61*/62function getTreeArrayId(node) {63 for (i=0; i<treeNodes.length; i++) {64 var nodeValues = treeNodes[i].split("|");65 if (nodeValues[0]==node) return i;66 }67 return 0;68}69/*70* 트리 노드 열기71*/72function setOpenTreeNodes(openNode) {73 for (i=0; i<treeNodes.length; i++) {74 var nodeValues = treeNodes[i].split("|");75 if (nodeValues[0]==openNode) {76 openTreeNodes.push(nodeValues[0]);77 setOpenTreeNodes(nodeValues[1]);78 }79 } 80}81/*82* 트리노드 오픈 여부 확인83*/84function isTreeNodeOpen(node) {85 if (treeYeobu){ return true; }86 for (i=0; i<openTreeNodes.length; i++){87 if (openTreeNodes[i]==node){ return true; }88 }89 return false;90}91/*92* 하위 트리노드 존재여부 확인93*/94function hasChildTreeNode(parentNode) {95 for (i=0; i< treeNodes.length; i++) {96 var nodeValues = treeNodes[i].split("|");97 if (nodeValues[1] == parentNode) return true;98 }99 return false;100}101/*102* 트리노드 최하위 여부 확인103*/104function lastTreeSibling (node, parentNode) {105 var lastChild = 0;106 for (i=0; i< treeNodes.length; i++) {107 var nodeValues = treeNodes[i].split("|");108 if (nodeValues[1] == parentNode)109 lastChild = nodeValues[0];110 }111 if (lastChild==node) return true;112 return false;113}114/*115* 신규 트리노드 추가116*/117function addTreeNode(parentNode, recursedNodes) {118 for (var i = 0; i < treeNodes.length; i++) {119120 var nodeValues = treeNodes[i].split("|");121 if (nodeValues[1] == parentNode) {122 123 var lastSibling = lastTreeSibling(nodeValues[0], nodeValues[1]);124 var hasChildNode = hasChildTreeNode(nodeValues[0]);125 var isNodeOpen = isTreeNodeOpen(nodeValues[0]);126 vHtmlCodeBg ="<li class='leftmenu_dept01'>";127 vHtmlCodeBgList ="<li class='dept02'>";128 129 vHtmlCodeEmpty = "";130 // Write out line | empty treeIcons131 for (g=0; g<recursedNodes.length; g++) {132 vHtmlCodeEmpty +="<img src='"+imgpath+"menu_empty.gif' border='0' align='absbottom' alt='' >";133 }134135 if (lastSibling) recursedNodes.push(0);136 else recursedNodes.push(1);137138 if (hasChildNode) {139 vHtmlCode +=vHtmlCodeBg+"<a href='#'>"+nodeValues[2]+"</a></li>";140 } else{141 // Start link142 if(recursedNodes.length==1){143 vHtmlCode +=vHtmlCodeBg+"<a href=javascript:fn_MovePage('" + i + "');>"+nodeValues[2]+"</a></li>";144 }else{145 vHtmlCode +=vHtmlCodeBgList+"<a href=javascript:fn_MovePage('" + i + "');>"+nodeValues[2]+"</a></li>";146 }147 }148 149 if (hasChildNode) {150 vHtmlCode +="<div id='div" + nodeValues[0] + "'";151 if (!isNodeOpen) vHtmlCode +=" style='display: none;'";152 vHtmlCode +=">";153 addTreeNode(nodeValues[0], recursedNodes);154 vHtmlCode +="</div>";155 }156 recursedNodes.pop();157 }158 }159}160161if(!Array.prototype.push) {162 function fnArrayPush() {163 for(var i=0;i<arguments.length;i++)164 this[this.length]=arguments[i];165 return this.length;166 }167 Array.prototype.push = fnArrayPush;168}169if(!Array.prototype.pop) {170 function fnArrayPop(){171 lastElement = this[this.length-1];172 this.length = Math.max(this.length-1,0);173 return lastElement;174 }175 Array.prototype.pop = fnArrayPop;176} ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2request({3}, function (error, response, body) {4 console.log(body);5});6{7 "_links": {8 "self": {9 },10 "logs": {11 },12 "stubs": {13 }14 }15}

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2request.get(url, function (error, response, body) {3 if (!error && response.statusCode == 200) {4 var obj = JSON.parse(body);5 console.log(obj);6 }7});8[{9}]10var request = require('request');11var options = {12 json: {13 "stubs": [{14 "responses": [{15 "is": {16 }17 }]18 }]19 }20};21request(options, function (error, response, body) {22 if (!error && response.statusCode == 201) {23 console.log(body);24 }25});26var request = require('request');27var options = {28 json: {29 "stubs": [{30 "responses": [{31 "is": {32 }33 }]34 }]35 }36};37request(options, function (error, response, body

Full Screen

Using AI Code Generation

copy

Full Screen

1var http = require('http');2var options = {3};4http.get(options, function(res) {5 console.log("Got response: " + res.statusCode);6 var body = '';7 res.on('data', function(chunk) {8 body += chunk;9 });10 res.on('end', function() {11 var response = JSON.parse(body);12 console.log(response);13 console.log("Node values: ", response.nodeValues);14 });15}).on('error', function(e) {16 console.log("Got error: " + e.message);17});18{ protocol: 'http',19 { self:

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank'),2 assert = require('assert');3var server = mb.create({4});5server.then(function () {6 console.log("Mountebank started successfully");7 return server.get('/test', function (req, res) {8 res.statusCode = 200;9 res.body = { "response": "success" };10 return res;11 });12}).then(function () {13 console.log("Stub created successfully");14 return server.get('/imposters');15}).then(function (imposters) {16 console.log("Imposters fetched successfully");17 console.log("Imposter data: " + JSON.stringify(imposters));18 return server.delete('/imposters');19}).then(function () {20 console.log("Imposter deleted successfully");21 return server.del();22}).then(function () {23 console.log("Mountebank stopped successfully");24}).catch(function (err) {25 console.error("Error occurred: " + err.message);26 return server.del();27});28Imposter data: [{"protocol":"http","port":2525,"numberOfRequests":1,"stubs":[{"responses":[{"is":{"statusCode":200,"headers":{"Content-Type":"application/json"},"body":"{\"response\":\"success\"}"}}],"predicates":[{"equals":{"method":"GET","path":"/test","headers":{"Content-Type":"application/json"}}}]}]}]29var mb = require('mountebank'),30 assert = require('assert');31var server = mb.create({32});33server.then(function () {34 console.log("Mountebank started successfully");35 return server.get('/test', function (req, res) {36 res.statusCode = 200;37 res.body = { "response": "success" };

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank'),2 assert = require('assert');3mb.create({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log', protofile: 'mb.proto'}, function () {4 mb.post('/imposters', {protocol: 'http', port: 4545, stubs: [{responses: [{is: {body: 'Hello World!'}}]}]}, function () {5 mb.get('/imposters/4545', function (response) {6 assert.equal(response.body.stubs[0].responses[0].is.body, 'Hello World!');7 mb.del('/imposters', function () {8 mb.stop(function () {9 console.log('done');10 });11 });12 });13 });14});15var mb = require('mountebank'),16 assert = require('assert');17mb.create({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log', protofile: 'mb.proto'}, function () {18 mb.post('/imposters', {protocol: 'http', port: 4545, stubs: [{responses: [{is: {body: 'Hello World!'}}]}]}, function () {19 mb.get('/imposters/4545', function (response) {20 assert.equal(response.body.stubs[0].responses[0].is.body, 'Hello World!');21 mb.del('/imposters', function () {22 mb.stop(function () {23 console.log('done');24 });25 });26 });27 });28});29var mb = require('mountebank'),30 assert = require('assert');31mb.create({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log', protofile: 'mb.proto'}, function () {32 mb.post('/imposters', {protocol: 'http', port: 4545, stubs: [{responses: [{is: {body: 'Hello World!'}}]}]}, function () {33 mb.get('/imposters/4545', function (response) {34 assert.equal(response.body.stubs[0].responses[0].is.body, 'Hello World!');35 mb.del('/imposters', function () {36 mb.stop(function () {

Full Screen

Using AI Code Generation

copy

Full Screen

1var imposter = require('mountebank').create();2var port = 2525;3var protocol = 'http';4 {5 {6 equals: {7 }8 }9 {10 is: {11 }12 }13 }14];15imposter.addStub(stubs);16imposter.start(port, protocol, function () {17 console.log('Imposter started');18});19var imposter = require('mountebank').create();20var port = 2525;21var protocol = 'http';22 {23 {24 equals: {25 }26 }27 {28 is: {29 }30 }31 }32];33imposter.addStub(stubs);34imposter.start(port, protocol, function () {35 console.log('Imposter started');36});

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var api = mb.create({ port: 2525 });3api.then(function (api) {4 return api.get('/imposters');5}).then(function (response) {6 console.log(response.body);7});8[{"port":2525,"protocol":"http","numberOfRequests":0,"stubs":[]}] 1 [ { "port" : 2525 , "protocol" : "http" , "numberOfRequests" : 0 , "stubs" : [ ] } ]

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2 if (!error && response.statusCode == 200) {3 }4});5var mb = require('mountebank');6var request = require('request');7mb.start({ port: 2525, allowInjection: true }, function () {8 var imposter = { protocol: 'http', port: 3001, stubs: [{ responses: [{ is: { body: 'Hello, world!' } }] }] };9 mb.post('/imposters', imposter, function () {10 if (!error && response.statusCode == 200) {11 }12 });13 });14});15var mb = require('mountebank');16var request = require('request');17mb.start({ port: 2525, allowInjection: true }, function () {18 var imposter = { protocol: 'http', port: 3001, stubs: [{ responses: [{ is: { body: 'Hello, world!' } }] }] };19 mb.post('/imposters', imposter, function () {20 if (!error && response.statusCode == 200) {21 }22 });23 });24});25var request = require('request');26 if (!error && response.statusCode == 200) {27 }28});29var mb = require('mountebank');30var request = require('request');31mb.start({ port: 2525, allowInjection: true }, function () {32 var imposter = { protocol: 'http', port:

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var client = mb.createClient({port: 2525});3client.get('/test', function (error, response) {4 console.log(response.body);5});6var mb = require('mountebank');7var client = mb.createClient({port: 2525});8client.get('/test', function (error, response) {9 console.log(response.body);10});11var mb = require('mountebank');12var client = mb.createClient({port: 2525});13client.get('/test', function (error, response) {14 console.log(response.body);15});16var mb = require('mountebank');17var client = mb.createClient({port: 2525});18client.get('/test', function (error, response) {19 console.log(response.body);20});21var mb = require('mountebank');22var client = mb.createClient({port: 2525});23client.get('/test', function (error, response) {24 console.log(response.body);25});26var mb = require('mountebank');27var client = mb.createClient({port: 2525});28client.get('/test', function (error, response) {29 console.log(response.body);30});31var mb = require('mountebank');32var client = mb.createClient({port: 2525});33client.get('/test', function (error, response) {34 console.log(response.body);35});36var mb = require('mountebank');37var client = mb.createClient({port: 2525});38client.get('/test', function (error, response) {39 console.log(response.body);40});41var mb = require('mountebank');42var client = mb.createClient({port: 2525});43client.get('/test

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var Q = require('q');3var fs = require('fs');4var path = require('path');5var config = require('./config');6var logger = require('./logger');7var test = function () {8 var deferred = Q.defer();9 var imposters = config.getImposters();10 var imposter = imposters[0];11 var imposterPath = imposter.path;12 var imposterPort = imposter.port;13 var imposterProtocol = imposter.protocol;14 var imposterStub = imposter.stub;15 var imposterStubPredicates = imposter.stubPredicates;16 var imposterStubResponses = imposter.stubResponses;17 var imposterStubResponsesIs = imposter.stubResponsesIs;18 var imposterStubResponsesProxy = imposter.stubResponsesProxy;19 var imposterStubResponsesProxyTo = imposter.stubResponsesProxyTo;20 var imposterStubResponsesProxyMode = imposter.stubResponsesProxyMode;21 var imposterStubResponsesProxyPredicateGenerators = imposter.stubResponsesProxyPredicateGenerators;22 var imposterStubResponsesProxyAddDecorators = imposter.stubResponsesProxyAddDecorators;23 var imposterStubResponsesProxyRemoveDecorators = imposter.stubResponsesProxyRemoveDecorators;24 var imposterStubResponsesProxyAddHeaders = imposter.stubResponsesProxyAddHeaders;25 var imposterStubResponsesProxyRemoveHeaders = imposter.stubResponsesProxyRemoveHeaders;26 var imposterStubResponsesIsStatusCode = imposter.stubResponsesIsStatusCode;27 var imposterStubResponsesIsHeaders = imposter.stubResponsesIsHeaders;28 var imposterStubResponsesIsBody = imposter.stubResponsesIsBody;29 var imposterStubResponsesProxyToHost = imposter.stubResponsesProxyToHost;30 var imposterStubResponsesProxyToPort = imposter.stubResponsesProxyToPort;31 var imposterStubResponsesProxyToPath = imposter.stubResponsesProxyToPath;32 var imposterStubResponsesProxyToScheme = imposter.stubResponsesProxyToScheme;33 var imposterStubResponsesProxyPredicateGeneratorsMatches = imposter.stubResponsesProxyPredicateGeneratorsMatches;34 var imposterStubResponsesProxyPredicateGeneratorsMatchesXPath = imposter.stubResponsesProxyPredicateGeneratorsMatchesXPath;35 var imposterStubResponsesProxyPredicateGeneratorsMatchesXPathSelector = imposter.stubResponsesProxyPredicateGeneratorsMatchesXPathSelector;

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run mountebank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful