Best JavaScript code snippet using wpt
ztreeSearch.js
Source:ztreeSearch.js
...73 //ç»è£
æ¾ç¤ºèç¹çç¶èç¹çç¶èç¹....ç´å°æ ¹èç¹ï¼å¹¶å±ç¤º74 getParentShowNodes_ztree(treeId, highlightNodes[i],showNodes);75 }76 treeObj.hideNodes(allNodes)77 treeObj.showNodes(showNodes);78 treeObj.expandAll(true);79 }80 }else if (type == "vehicle"){81 treeObj.hideNodes(allNodes)82 treeObj.showNodes(highlightNodes);83 treeObj.expandAll(true);84 }else{85 //<2>.å¾å°æ¨¡ç³å¹é
æç´¢æ¡ä»¶çèç¹æ°ç»éå86// treeObj.hideNodes(allNodes);87// treeObj.showNodes(highlightNodes);88// treeObj.expandAll(true);89 // éè¦æ¾ç¤ºæ¯èç¹ï¼å
å«ç¶èç¹ï¼90 var showNodes = [];91 // åªæ¾ç¤ºç´æ¥ä¸çº§92 if (highlightNodes != null) {93 for (var i = 0; i < highlightNodes.length; i++) {94 //ç»è£
æ¾ç¤ºèç¹çç¶èç¹çç¶èç¹....ç´å°æ ¹èç¹ï¼å¹¶å±ç¤º95 getParentShowNodes_ztree(treeId, highlightNodes[i],showNodes);96 }97 treeObj.hideNodes(allNodes)98 treeObj.showNodes(showNodes);99 treeObj.expandAll(true);100 }101 }102 }else{103 treeObj.showNodes(allNodes)104 treeObj.expandAll(true);105 }106 //<3>.é«äº®æ¾ç¤ºå¹¶å±ç¤ºãæå®èç¹sã107 // highlightAndExpand_ztree(treeId, highlightNodes, flag);108}109110function realTimeMonitoringFilter(node){ // 模ç³æç´¢ä»ä¸äººåï¼ç»ç«¯ç¼å·111 return (node.type == "station" && node.name.indexOf(searchParam) > -1) || 112 (node.type == "people" && node.name.indexOf(searchParam) > -1) ||113 (node.professional != undefined && node.professional != null && node.professional.indexOf(searchParam) > -1) ||114 (node.simcardNumber != undefined && node.simcardNumber != null && node.simcardNumber.indexOf(searchParam) > -1) || 115 (node.assignName != undefined && node.assignName != null && node.assignName.indexOf(searchParam) > -1) || 116 (node.deviceNumber != undefined && node.deviceNumber != null && node.deviceNumber.indexOf(searchParam) > -1)117}118119function monitorFilter(node){ // æç´¢typeçäºäººæè
车120 return node.type == "station" || node.type == "people" 121}122123function monitorParamFuzzyFilter(node){ // 模ç³å¹é
name,typeçäºäººæè
车124 return (node.type == "station" && node.name.indexOf(searchParam) > -1) || (node.type == "people" && node.name.indexOf(searchParam) > -1)125}126127/**128 * æ索没æå±å¼çåç»èç¹129 * @param node130 * @returns131 */132function assignmentNotExpandFilter(node){ // æç´¢typeçäºäººæè
车133 return node.type == "assignment" && node.children != undefined && node.children.length >0 && node.children[0].open==false;134}135136/**137 * æç´¢ææç对象138 * @param node139 * @returns140 */141function moniterFilter(node){ // æç´¢typeçäºäººæè
车142 return (node.type == "station" || node.type == "people")&&node.isHidden===false;143}144145/**146 * æç´¢æ ï¼é«äº®æ¾ç¤ºå¹¶å±ç¤ºã模ç³å¹é
æç´¢æ¡ä»¶çèç¹sã147 * @param treeId148 * @param searchConditionId æç´¢æ¡ä»¶Id149 * @param flag éè¦é«äº®æ¾ç¤ºçèç¹æ è¯150 */151function high_search_ztree(treeId, searchConditionId,hasBegun) {152 //<1>.æç´¢æ¡ä»¶153 var searchCondition = $('#' + searchConditionId).val();154 var highlightNodes = [];155// var allNodes = [];156 var treeObj = $.fn.zTree.getZTreeObj(treeId);157 searchParam = searchCondition;158 highlightNodes = treeObj.getNodesByFilter(realTimeMonitoringFilter); 159 // allNodes = treeObj.getNodesByFilter(monitorFilter); // æætypeånodes160 var allNodes = treeObj.transformToArray(treeObj.getNodes()); // ææèç¹161 if (searchCondition != "") {162 //<2>.å¾å°æ¨¡ç³å¹é
æç´¢æ¡ä»¶çèç¹æ°ç»éå163 // éè¦æ¾ç¤ºæ¯èç¹ï¼å
å«ç¶èç¹ï¼164 var showNodes = [];165 // åªæ¾ç¤ºç´æ¥ä¸çº§166 if (highlightNodes != null) {167 for (var i = 0; i < highlightNodes.length; i++) {168 //ç»è£
æ¾ç¤ºèç¹çç¶èç¹çç¶èç¹....ç´å°æ ¹èç¹ï¼å¹¶å±ç¤º169 if(hasBegun.indexOf(highlightNodes[i].getParentNode().id)==-1){170 hasBegun.push(highlightNodes[i].getParentNode().id)171 treeObj.expandNode(highlightNodes[i].getParentNode(), true, true, false, true);172 }173 getParentShowNodes_ztree(treeId, highlightNodes[i],showNodes);174 }175176 treeObj.hideNodes(allNodes)177 treeObj.showNodes(showNodes);178 // treeObj.expandAll(true);179 }180 }else{181 // var allNodes1 = treeObj.transformToArray(treeObj.getNodes()); // ææèç¹182// treeObj.hideNodes(allNodes)183 treeObj.showNodes(allNodes)184 treeObj.expandAll(true);185 }186 //<3>.é«äº®æ¾ç¤ºå¹¶å±ç¤ºãæå®èç¹sã187 // highlightAndExpand_ztree(treeId, highlightNodes, flag);188}189190function searchTypeFilter(node){ // 模ç³æç´¢ä»ä¸äººåï¼ç»ç«¯ç¼å·191 var value = node[''+searchTypeValue+''];192 return ((node.type == "station" || node.type == "people") && value != undefined && value != null && value.indexOf(searchParam) > -1)193}194195/**196 * æç´¢æ ï¼æ ¹æ®æ索类å模ç³å¹é
197 * @param treeId198 * @param searchConditionId æç´¢æ¡ä»¶Id199 * @param searchType æç´¢æ¡ä»¶type200 * @param flag éè¦é«äº®æ¾ç¤ºçèç¹æ è¯201 */202function search_ztree_by_search_type(treeId, searchConditionId,searchType,hasBegun) {203 //<1>.æç´¢æ¡ä»¶204 var searchCondition = $('#' + searchConditionId).val();205 var highlightNodes = [];206 var treeObj = $.fn.zTree.getZTreeObj(treeId);207 searchParam = searchCondition;208 searchTypeValue = searchType;209 //highlightNodes = treeObj.getNodesByFilter(searchTypeFilter); 210 // highlightNodes = treeObj.getNodesByParamFuzzy(searchType, searchCondition, null);211 var allNodes = treeObj.transformToArray(treeObj.getNodes()); // ææèç¹212 if (searchCondition != "") {213 //<2>.å¾å°æ¨¡ç³å¹é
æç´¢æ¡ä»¶çèç¹æ°ç»éå214 // éè¦æ¾ç¤ºæ¯èç¹ï¼å
å«ç¶èç¹ï¼ 215 var showNodes = [];216 // åªæ¾ç¤ºç´æ¥ä¸çº§217 if (allNodes != null) {218 for (var i = 0; i < allNodes.length; i++) {219 var node = allNodes[i];220 var value = node[''+searchType+''];221 if ((node.type == "station" || node.type == "people") && value != undefined && value != null && value.indexOf(searchParam) > -1) {222 //highlightNodes.push(node);223 //ç»è£
æ¾ç¤ºèç¹çç¶èç¹çç¶èç¹....ç´å°æ ¹èç¹ï¼å¹¶å±ç¤º224 if(hasBegun.indexOf(node.getParentNode().id)==-1){225 hasBegun.push(node.getParentNode().id)226 treeObj.expandNode(node.getParentNode(), true, true, false, true);227 }228 getParentShowNodes_ztree(treeId, node,showNodes);229 }230 }231 treeObj.hideNodes(allNodes)232 treeObj.showNodes(showNodes);233 }234 235 /*if (highlightNodes != null) {236 for (var i = 0; i < highlightNodes.length; i++) {237 //ç»è£
æ¾ç¤ºèç¹çç¶èç¹çç¶èç¹....ç´å°æ ¹èç¹ï¼å¹¶å±ç¤º238 if(hasBegun.indexOf(highlightNodes[i].getParentNode().id)==-1){239 hasBegun.push(highlightNodes[i].getParentNode().id)240 treeObj.expandNode(highlightNodes[i].getParentNode(), true, true, false, true);241 }242 getParentShowNodes_ztree(treeId, highlightNodes[i],showNodes);243 }244245 treeObj.hideNodes(allNodes)246 treeObj.showNodes(showNodes);247 }*/248 }else{249 treeObj.showNodes(allNodes)250 treeObj.expandAll(true);251 }252}253254function showSearchNodes(treeId, checkedList) {255 var treeObj = $.fn.zTree.getZTreeObj(treeId);256 var allNodes = treeObj.transformToArray(treeObj.getNodes()); // ææèç¹257 //<2>.å¾å°æ¨¡ç³å¹é
æç´¢æ¡ä»¶çèç¹æ°ç»éå258 // éè¦æ¾ç¤ºæ¯èç¹ï¼å
å«ç¶èç¹ï¼ 259 var showNodes = [];260 var checkedNodes = [];261 // åªæ¾ç¤ºç´æ¥ä¸çº§262 if (allNodes !== null) {263 for (var i = 0; i < allNodes.length; i++) {264 var node = allNodes[i];265// var value = node[''+searchType+''];266 if ((node.type === "station" || node.type === "people") ) {267 // å¾éæç´¢åå¾éç车è¾268 if (checkedList !== null &&ãcheckedListã!== undefined && checkedList.length > 0269 && checkedList.indexOf(node.id) !== -1){270 treeObj.checkNode(node, true, true);271 }272 //ç»è£
æ¾ç¤ºèç¹çç¶èç¹çç¶èç¹....ç´å°æ ¹èç¹ï¼å¹¶å±ç¤º273 if (checkedNodes.indexOf(node.pId) >= 0) {274 showNodes.push(node);275 continue;276 }277 checkedNodes.push(node.pId);278 treeObj.expandNode(node.getParentNode(), true, true, false, true);279 getParentShowNodes_ztree(treeId, node, showNodes);280 }281 }282 treeObj.hideNodes(allNodes);283 treeObj.showNodes(showNodes);284 }285}286287function filterQueryResult(data, checkedList) {288 if (data === null) {289 return;290 }291292 if (checkedList === undefined || checkedList === null) {293 checkedList = [];294 }295296 // åå§åèç¹ä¸ºhashMap297 var nodes = {};
...
MtrSearchZTree.js
Source:MtrSearchZTree.js
...55 findParent(ztreeObj, showNodes[n],showNodes);56 }57 }58 //æ¾ç¤ºå¹é
çèç¹ï¼æ³¨æï¼ä½¿ç¨showNodesï¼ï¼æ¹æ³æ¶éè¦å¼å
jquery.ztree.exhide-3.5.min.js59 ztreeObj.showNodes(showNodes);60 //æå½åæ¾ç¤ºççå
ç´ ä¿å61 showNodesAll[id] = showNodes;62 }else{63 //æ¾ç¤ºææèç¹64 ztreeObj.showNodes(nodesAll[id]);65 //æå ææèç¹66 ztreeObj.expandAll(false);67 }68 });69 }70 71 function setAllNodes(id){72 //ä¿åå
¨é¨èç¹73 var ztreeObj = $.fn.zTree.getZTreeObj(id);74 var nodes = ztreeObj.getNodes();75 nodesAll[id] = ztreeObj.transformToArray(nodes);76 //åå§ä¸ºç©º77 showNodesAll[id] = [];78 }79 80 function initSearchZTree(){81 var ztrees = $(location);82 for(let i = 0; i < ztrees.length; i++){83 var ztree = ztrees.eq(i);84 var ztreeId = ztree.attr("id");85 //å é¤åæçè¾å
¥æ¡86 ztree.children("input").remove();87 //æå
¥inputè¾å
¥æ¡88 var html = '<input id="'+ztreeId+'Keyword" type="text" class="form-control" placeholder="请è¾å
¥å
³é®å...">';89 ztree.prepend(html);90 //åå§åèç¹ä¿å91 setAllNodes(ztreeId);92 //ç»å®äºä»¶93 bindingZTree(ztreeId);94 }95 }96 97 //åå§å98 initSearchZTree();99 100 return {101 getshowNodesById : function(id){102 if(id){103 return showNodesAll[id];104 }105 },106 getshowNodes(){107 return showNodesAll;108 }109 }
...
ReDefineTableViewRender.ts
Source:ReDefineTableViewRender.ts
1import * as cc from 'cc';2import { TableViewCell} from "./TableViewCell"3const { ccclass, property} = cc._decorator;4@ccclass('ReDefineTableViewRender')5export class ReDefineTableViewRender extends cc.Renderable2D {6 private m_tableView : any = null;7 8 onEnable()9 {10 if(this.m_tableView == null) return;11 let shownodes : Map<number, TableViewCell> = this.m_tableView.m_showNodes;12 let freeNodes : TableViewCell [] = this.m_tableView.m_freeNodes;13 if(shownodes)14 {15 shownodes.forEach(( cell : TableViewCell)=>{16 cell.__redefineInit();17 })18 }19 if(freeNodes)20 {21 freeNodes.forEach(( cell : TableViewCell)=>{22 cell.__redefineInit();23 })24 }25 }26 onDisable()27 {28 if(this.m_tableView == null) return;29 let shownodes : Map<number, TableViewCell> = this.m_tableView.m_showNodes;30 let freeNodes : TableViewCell [] = this.m_tableView.m_freeNodes;31 if(shownodes)32 {33 shownodes.forEach(( cell : TableViewCell)=>{34 cell.___redefineReset();35 })36 }37 if(freeNodes)38 {39 freeNodes.forEach(( cell : TableViewCell)=>{40 cell.___redefineReset()41 })42 }43 }44 public setTableView( tableview : any )45 {46 this.m_tableView = tableview;47 }48 public updateAssembler (batcher: any) {49 50 }51 public postUpdateAssembler (batcher: any) {52 let shownodes : Map<number, TableViewCell> = this.m_tableView.m_showNodes;53 if(shownodes == null || shownodes.size <= 0) return;54 let isfinish = false;55 for(let level = 0;; level++)56 {57 if(isfinish) break;58 shownodes.forEach(( cell : TableViewCell)=>{59 if(!cell.__renderUI(level, batcher)){60 isfinish = true;61 }62 })63 }64 }...
Using AI Code Generation
1var tree = new WPTree();2var tree2 = new WPTree();3var tree3 = new WPTree();4var tree4 = new WPTree();5var tree5 = new WPTree();6var tree6 = new WPTree();7var tree7 = new WPTree();8var tree8 = new WPTree();9var tree9 = new WPTree();10var tree10 = new WPTree();11var tree11 = new WPTree();12var tree12 = new WPTree();13var tree13 = new WPTree();14var tree14 = new WPTree();15var tree15 = new WPTree();16var tree16 = new WPTree();17var tree17 = new WPTree();18var tree18 = new WPTree();19var tree19 = new WPTree();20var tree20 = new WPTree();21var tree21 = new WPTree();22var tree22 = new WPTree();23var tree23 = new WPTree();24var tree24 = new WPTree();25var tree25 = new WPTree();26var tree26 = new WPTree();27var tree27 = new WPTree();28var tree28 = new WPTree();29var tree29 = new WPTree();30var tree30 = new WPTree();31var tree31 = new WPTree();32var tree32 = new WPTree();33var tree33 = new WPTree();34var tree34 = new WPTree();35var tree35 = new WPTree();36var tree36 = new WPTree();37var tree37 = new WPTree();38var tree38 = new WPTree();39var tree39 = new WPTree();40var tree40 = new WPTree();41var tree41 = new WPTree();42var tree42 = new WPTree();43var tree43 = new WPTree();44var tree44 = new WPTree();45var tree45 = new WPTree();46var tree46 = new WPTree();47var tree47 = new WPTree();48var tree48 = new WPTree();49var tree49 = new WPTree();50var tree50 = new WPTree();51var tree51 = new WPTree();52var tree52 = new WPTree();53var tree53 = new WPTree();54var tree54 = new WPTree();55var tree55 = new WPTree();
Using AI Code Generation
1const wptree = require('wptree');2const tree = new wptree();3tree.insert(5);4tree.insert(3);5tree.insert(7);6tree.insert(2);7tree.insert(4);8tree.insert(6);9tree.insert(8);10tree.insert(1);11tree.insert(9);12tree.insert(10);13tree.showNodes();14### insert(value)15### contains(value)16### remove(value)17### size()18### toArray()19### toString()20### showNodes()
Using AI Code Generation
1var wptree = require('./wptree');2var tree = new wptree();3tree.add(5);4tree.add(3);5tree.add(7);6tree.add(2);7tree.add(4);8tree.add(6);9tree.add(8);10tree.add(1);11tree.add(9);12tree.add(10);13tree.showNodes();
Using AI Code Generation
1var WPTree = require('./wptree.js');2var fs = require('fs');3var data = fs.readFileSync('data.json');4var data = JSON.parse(data);5var wptree = new WPTree(data);6wptree.showNodes();7var WPTree = require('wptree');8var wptree = new WPTree(data);9#### showNodes()10wptree.showNodes();11#### getNodes()12var nodes = wptree.getNodes();13#### getRootNode()14var rootNode = wptree.getRootNode();15#### getChildrenOfNode(node)16var children = wptree.getChildrenOfNode(node);17#### getParentOfNode(node)18var parent = wptree.getParentOfNode(node);19#### getDepthOfNode(node)20var depth = wptree.getDepthOfNode(node);21#### getDepthOfTree()22var depth = wptree.getDepthOfTree();23#### getNumberOfNodes()24var numberOfNodes = wptree.getNumberOfNodes();25#### getNumberOfChildrenOfNode(node)26var numberOfChildren = wptree.getNumberOfChildrenOfNode(node);27#### getNumberOfChildrenOfTree()28var numberOfChildren = wptree.getNumberOfChildrenOfTree();29#### getNumberOfParentsOfNode(node)30var numberOfParents = wptree.getNumberOfParentsOfNode(node);31#### getNumberOfParentsOfTree()32var numberOfParents = wptree.getNumberOfParentsOfTree();33#### getNumberOfLeaves()34var numberOfLeaves = wptree.getNumberOfLeaves();
Using AI Code Generation
1var WPTree = require('./wptree.js');2var tree = new WPTree("root");3tree.addNode("root", "node1");4tree.addNode("root", "node2");5tree.addNode("node1", "node11");6tree.addNode("node1", "node12");7tree.addNode("node2", "node21");8tree.addNode("node2", "node22");9tree.addNode("node12", "node121");10tree.addNode("node12", "node122");11tree.addNode("node12", "node123");12tree.addNode("node122", "node1221");13tree.addNode("node122", "node1222");14tree.addNode("node122", "node1223");15var nodes = tree.showNodes("node1");16console.log(nodes);17var nodes = tree.showNodes("node2");18console.log(nodes);19var nodes = tree.showNodes("node122");20console.log(nodes);21var nodes = tree.showNodes("node1222");22console.log(nodes);23var nodes = tree.showNodes("root");24console.log(nodes);25var WPTree = require('./wptree.js');26var tree = new WPTree("root");27tree.addNode("root", "node1");28tree.addNode("root", "node2");29tree.addNode("node1", "node11");30tree.addNode("node1", "node12");31tree.addNode("node2", "node21");32tree.addNode("node2", "node22");33tree.addNode("node12", "node121");34tree.addNode("node12", "node122");35tree.addNode("node12", "node123");36tree.addNode("node122", "node1221");37tree.addNode("node122", "node1222");38tree.addNode("node122", "node1223");39var nodes = tree.showNodes("node1");40console.log(nodes);41var nodes = tree.showNodes("node2");42console.log(nodes);43var nodes = tree.showNodes("node122");44console.log(nodes);45var nodes = tree.showNodes("node1222");46console.log(nodes);47var nodes = tree.showNodes("root");48console.log(nodes);49var WPTree = require('./wptree.js');50var tree = new WPTree("root");51tree.addNode("root", "node1");52tree.addNode("root", "node2");53tree.addNode("node
Using AI Code Generation
1var wptree = require('./wptree.js');2var tree = new wptree();3var fs = require('fs');4var file = fs.readFileSync('data.txt', 'utf8');5var lines = file.split('\n');6for (var i = 0; i < lines.length; i++) {7 var line = lines[i];8 var parts = line.split(' ');9 var cmd = parts[0];10 var arg = parts[1];11 switch (cmd) {12 tree.add(arg);13 break;14 tree.remove(arg);15 break;16 tree.showNodes();17 break;18 console.log(tree.find(arg));19 break;20 console.log(tree.findMin());21 break;22 console.log(tree.findMax());23 break;24 console.log(tree.count());25 break;26 console.log(tree.height());27 break;28 tree.clear();29 break;30 console.log('unknown command: ' + cmd);31 break;32 }33}
Using AI Code Generation
1var myTree = new wptree();2var myTable = new table();3var myRow = new row();4var myCell = new cell();5var myText = new text();6var myButton = new button();7var myDiv = new div();8var myInput = new input();9var myForm = new form();10var mySelect = new select();11var myOption = new option();12var myForm = new form();13var myDiv = new div();14var mySelect = new select();15var myOption = new option();16var myForm = new form();17var myDiv = new div();18var mySelect = new select();19var myOption = new option();20var myForm = new form();21var myDiv = new div();22var mySelect = new select();23var myOption = new option();24var myForm = new form();25var myDiv = new div();26var mySelect = new select();27var myOption = new option();28var myForm = new form();29var myDiv = new div();30var mySelect = new select();31var myOption = new option();32var myForm = new form();33var myDiv = new div();34var mySelect = new select();
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!!