How to use consoleTable method in Playwright Internal

Best JavaScript code snippet using playwright-internal

Run Playwright Internal automation tests on LambdaTest cloud grid

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

queries.js

Source: queries.js Github

copy
1// const { selectEmployees, selectRoles, selectDepartments, employeeNames, roleTitles, departmentNames, getAllManagers, getBudgetByDepartment } = require('./queryStatements');
2// // import modules for the queries page
3// const mysql = require('mysql2');
4// const util = require('util');
5// // const cTable = require('console.table');
6// const { Table } = require('console-table-printer');
7// require('dotenv').config();
8// // create the connection
9// const connection = mysql.createConnection({
10// 	host: process.env.DB_HOST,
11// 	user: process.env.DB_NAME,
12// 	password: process.env.DB_PASSWORD,
13// 	database: process.env.DB_NAME
14// });
15// // create promisify version of query
16// const query = util.promisify(connection.query).bind(connection);
17
18// // create function that produces tables in console
19// function consoleTable(rows) {
20// 	const table = new Table();
21// 	table.addRows(rows, { color: 'cyan' });
22// 	table.printTable();
23// }
24
25// // create function to query all data from selected database
26// async function queryAllFrom(tableSelection) {
27// 	if (tableSelection == 'departments') {
28// 		try {
29// 			const rows = await query(selectDepartments);
30// 			consoleTable(rows);
31// 		} finally {
32// 			connection.end();
33// 		}
34// 	} else if (tableSelection == 'roles') {
35// 		try {
36// 			const rows = await query(selectRoles);
37// 			consoleTable(rows);
38// 		} finally {
39// 			connection.end();
40// 		}
41// 	} else if (tableSelection == 'employees') {
42// 		try {
43// 			const rows = await query(selectEmployees);
44// 			consoleTable(rows);
45// 		} finally {
46// 			connection.end();
47// 		}
48// 	}
49// }
50// // create function to query all data from selected database
51// async function addDataTo(tableSelection, params) {
52// 	if (tableSelection == 'employees') {
53// 		const { firstName, lastName, roleId, managerId } = params;
54// 		try {
55// 			await query(`INSERT INTO employees (first_name, last_name, role_id, manager_id) VALUES (?,?,?,?);`, [firstName, lastName, roleId, managerId]);
56// 			const rows = await query(selectEmployees);
57// 			consoleTable(rows);
58// 		} finally {
59// 			connection.end();
60// 		}
61// 	} else if (tableSelection == 'roles') {
62// 		const { title, salary, departmentId } = params;
63// 		try {
64// 			await query(`INSERT INTO roles (title, salary, department_id) VALUES (?,?,?);`, [title, salary, departmentId]);
65// 			const rows = await query(selectRoles);
66// 			consoleTable(rows);
67// 		} finally {
68// 			connection.end();
69// 		}
70// 	} else if (tableSelection == 'departments') {
71// 		const { deptName } = params;
72// 		try {
73// 			await query(`INSERT INTO departments (dept_name) VALUES (?);`, [deptName]);
74// 			const rows = await query(selectDepartments);
75// 			consoleTable(rows);
76// 		} finally {
77// 			connection.end();
78// 		}
79// 	}
80// }
81// // create function to get the current list of employee names
82// async function getEmployeeNames() {
83// 	let employeeData = await query(employeeNames);
84// 	let employeeArray = [];
85// 	for (let employee of employeeData) {
86// 		employeeArray.push(`${employee.first_name} ${employee.last_name}`);
87// 	}
88// 	return employeeArray;
89// }
90// // create function to get the current list of manager names
91// async function getManagerNames() {
92// 	let managerData = await query(getAllManagers);
93// 	let managerArray = [];
94// 	for (let manager of managerData) {
95// 		managerArray.push(`${manager.first_name} ${manager.last_name}`);
96// 	}
97// 	return managerArray;
98// }
99
100// // create function to display the employees for each manager
101// async function queryManagerByEmployee(params) {
102// 	let { manager } = params;
103// 	let managerNameArr = manager.split(" ");
104// 	let managerFirstName = managerNameArr[0];
105// 	let managerLastName = managerNameArr[1];
106// 	let managerIdArr = await query(`SELECT id FROM employees WHERE first_name=? AND last_name= ?;`, [managerFirstName, managerLastName]);
107// 	let managerEmployeeId = managerIdArr[0].id;
108// 	try {
109// 		const rows = await query(`SELECT e.first_name, e.last_name, r.title FROM employees JOIN roles r ON e.role_id = r.id AND e.id = ?;`, [managerEmployeeId]);
110// 		consoleTable(rows);
111// 	} finally {
112// 		connection.end();
113// 	}
114// }
115
116// // create function to get the current list of role titles
117// async function getRoleTitles() {
118// 	let roleData = await query(roleTitles);
119// 	let roleArray = [];
120// 	for (let role of roleData) {
121// 		roleArray.push(role.title);
122// 	}
123// 	return roleArray;
124// }
125// // create function to get the current list of departments
126// async function getDeptNames() {
127// 	let deptData = await query(departmentNames);
128// 	let deptArray = [];
129// 	for (let dept of deptData) {
130// 		deptArray.push(dept.dept_name);
131// 	}
132// 	return deptArray;
133// }
134// // create function to update specific things about employees
135// async function updateDataIn(tableSelection, params, identifier) {
136// 	if (tableSelection == 'employees' && identifier == 'role') {
137// 		const { selectedEmployee, roleTitle } = params;
138// 		let employeeNameArray = selectedEmployee.split(' ');
139// 		let firstName = employeeNameArray[0];
140// 		try {
141// 			let roleIdArr = await query(`SELECT id FROM roles WHERE title=?;`, [roleTitle]);
142// 			let roleId = roleIdArr[0].id;
143// 			await query(`UPDATE employees SET role_id=? WHERE first_name=?;`, [roleId, firstName]);
144// 			const rows = await query(selectEmployees);
145// 			consoleTable(rows);
146// 		} finally {
147// 			connection.end();
148// 		}
149// 	} else if (tableSelection == 'employees' && identifier == 'manager') {
150// 		const { selectedEmployee, selectedManager } = params;
151// 		let employeeNameArray = selectedEmployee.split(' ');
152// 		let lastName = employeeNameArray[1];
153// 		let managerNameArray = selectedManager.split(' ');
154// 		let managerLast = managerNameArray[1];
155// 		try {
156// 			let managerIdArr = await query(`SELECT id FROM employees WHERE last_name=?;`, [managerLast]);
157// 			let managerId = managerIdArr[0].id;
158// 			await query(`UPDATE employees SET manager_id=? WHERE last_name=?;`, [managerId, lastName]);
159// 			const rows = await query(selectEmployees);
160// 			consoleTable(rows);
161// 		} finally {
162// 			connection.end();
163// 		}
164// 	}
165// }
166// // create function to delete rows from chosen table
167// async function deleteDataFrom(tableSelection, params) {
168// 	if (tableSelection == 'employees') {
169// 		const { deletedEmployee } = params;
170// 		let employeeNameArray = deletedEmployee.split(' ');
171// 		let firstName = employeeNameArray[0];
172// 		let lastName = employeeNameArray[1];
173// 		try {
174// 			let employeeIdArr = await query(`SELECT id FROM employees WHERE first_name=? AND last_name=?;`, [firstName, lastName]);
175// 			let employeeId = employeeIdArr[0].id;
176// 			await query(`DELETE FROM employees WHERE id=?;`, [employeeId]);
177// 			const rows = await query(selectEmployees);
178// 			consoleTable(rows);
179// 		} finally {
180// 			connection.end();
181// 		}
182// 	} else if (tableSelection == 'roles') {
183// 		const { deletedRole } = params;
184// 		try {
185// 			let roleIdArr = await query(`SELECT id FROM roles WHERE title=?;`, [deletedRole]);
186// 			let roleId = roleIdArr[0].id;
187// 			await query(`DELETE FROM roles WHERE id=?;`, [roleId]);
188// 			const rows = await query(selectRoles);
189// 			consoleTable(rows);
190// 		} finally {
191// 			connection.end();
192// 		}
193// 	} else if (tableSelection == 'departments') {
194// 		const { deletedDept } = params;
195// 		try {
196// 			let deptIdArr = await query(`SELECT id FROM departments WHERE dept_name=?;`, [deletedDept]);
197// 			let deptId = deptIdArr[0].id;
198// 			await query(`DELETE FROM departments WHERE id=?;`, [deptId]);
199// 			const rows = await query(selectDepartments);
200// 			consoleTable(rows);
201// 		} finally {
202// 			connection.end();
203// 		}
204// 	}
205// }
206// // create function to query employees in given department
207// async function queryEmployeeByDepartment(params) {
208// 	let { departmentName } = params;
209// 	try {
210// 		let rows = await query(`SELECT e.first_name, e.last_name, r.title FROM employees JOIN roles r ON e.role_id = r.id JOIN departments d ON r.department_id = d.id AND dept_name=?;`, [departmentName]);
211// 		consoleTable(rows);
212// 	} finally {
213// 		connection.end();
214// 	}
215// }
216
217// async function queryBudgetsByDepartment() {
218// 	try {
219// 		let rows = await query(getBudgetByDepartment);
220// 		consoleTable(rows);
221// 	} finally {
222// 		connection.end();
223// 	}
224// }
225
226// // export the functions!
227// module.exports = { queryAllFrom, addDataTo, updateDataIn, getEmployeeNames, getRoleTitles, deleteDataFrom, getDeptNames, getManagerNames, queryManagerByEmployee, queryEmployeeByDepartment, queryBudgetsByDepartment };
228
Full Screen

bdgagencyrule_list.js

Source: bdgagencyrule_list.js Github

copy
1var mainmenu = null;
2var menuid = null;
3
4var qtree = null;
5var _qtree = null;
6var consoletable = null;
7var datatable = null;
8var subdatatable = null;
9
10var userdata = null;       //´¦ÊÒÓû§
11var consolegroup = null;   //¿ØÖÆ×é
12var productData = null;    //²úÆ·ÀàÐÍ
13
14var form_content_wind = null;
15var consoleName = null;
16var consoleCode = null;
17var formtag = null;
18var mainArray = [];
19var formId = null;
20
21var bdgagencyrule_list = function(config, service) {
22	mainmenu = config.mainmenu;
23	menuid = config.menuid;
24	
25	userdata = config.userData;
26	usergroup = config.userGroup;
27	consolegroup = config.consoleGroup;
28	productData = config.productList;          
29	
30	//³õʼ»¯Ö÷Ò³Ãæ 
31	initLayoutMain(config);	
32	
33	qtree = new Ext.lt.Qtree({
34		data : userdata,
35		linkchild : true,
36		linkparend : true,
37		parentlinksub : true,
38		showRootNode : true,
39		selectmode : 'n',
40		outformart : '#code-#name'
41	});
42	qtree.draw(treeDiv);	
43	
44	//Ê÷µÄ²éѯ·½·¨
45	$("#selectInput").keyup(function(){		
46		qtree.searchnode([{field:'code',values:[this.value.trim()]},{field:'name',values:[this.value.trim()]}],'contain');
47		
48		if(!this.value.trim()) qtree.clearSelected();
49	}).keyup();
50	
51	qtree.on({
52		nodeclick : function(tree, param) {
53			var selNode = param.data;
54			if (selNode.isleaf != 0) {
55				var params = {};
56				params['bdgagency'] = selNode.itemid;
57				params['menuid'] = menuid;
58				
59				Ext.lt.RCP.server("datacommon_bdgagencyrule_service", "getFromDataByAgency", params, function(data) {
60					if (data != null && data.result != null) {
61						var code = data.result.toArray();		
62						var consolearr = consoletable.getRecordSet().toArray();
63												
64						for(var i = 0; i < consolearr.length; i++){
65							consolearr[i]["check"] = 0;
66						}
67						if(code.length != 0){
68						var consoledatas = consoletable.getRecordSet().query({CONSOLECODE:code[0].CONSOLECODE});
69									   
70						if(consoledatas){
71						consoledatas[0]["check"] = 1;					
72						}
73						}
74						consoletable.reflash();
75					}
76						},function(){
77							alert('´íÎó!');	
78						});
79			}
80		}
81	});
82	
83	var consolenode = function(td,el,l,c,d){
84		var _val = $(el).find("input[type=radio]:checked");
85		var name = consoletable.getCol(c).name;
86		consoleName = d['CONSOLENAME'];
87		consoleCode = d['CONSOLECODE'];
88		$("#consolename").val(consoleName);
89		if(name == 'CONSOLENAME'){
90		   copyfrom(1);
91		}
92	}		
93	 
94	 consoletable = new Ext.lt.datatable35(consolegroup);
95	    consoletable.setCols([
96		consoletable.columns.seq,
97		consoletable.columns.radio,
98		{name:'CONSOLENAME',alias:'¿ØÖÆ×é',width:850,datatype:'S'}
99		]);	
100	    consoletable.setEditSelectCheckbox(false);		
101	    consoletable.setMouselight('#597EAA');
102	    consoletable.mousedrag(false);
103	    consoletable.setClassName('dttheme_ifmis');	
104	    consoletable.setAlign("left");
105	    consoletable.setAllowClock(false);	
106	    consoletable.onEvent('onclick',consolenode);
107	    consoletable.setLayout();
108	    consoletable.draw(consolegroupDiv);     
109		
110		//ÐÂÔö²É¼¯±í¿ØÖÆ×鵯³ö´°
111		form_content_wind = new Ext.lt.window({title:'¿ØÖÆ×éÉèÖÃ',fitmode:'content',className:'wind7',mark:true,autoshow:true,pop:true,w:425,h:400});
112		form_content_wind.draw(form_content);
113		$("#form_content").show();
114		form_content_wind.hidden();
115		
116		//ÐÂÔö²É¼¯±í¿ØÖÆ×éÁÐÒªËص¯³ö´°
117		form_subdata_wind = new Ext.lt.window({title:'ÒªËØÉèÖÃ',fitmode:'content',className:'wind7',mark:true,autoshow:true,pop:true,w:425,h:400});
118		form_subdata_wind.draw(form_subdata);
119		$("#form_subdata").show();
120		form_subdata_wind.hidden();
121}
122
123//³õʼ»¯Ö÷Ò³Ãæ
124function initLayoutMain(config){
125	var sb = new StringBuffer();
126	
127	sb.append("<table align='center' width=\"100%\"  border=\"0\">");
128	sb.append("<tr><td valign=\"top\" width=\"20%\">");
129	sb.append("<div style=\"position:relative;z-index:100;\">");
130	sb.append("<input type=\"text\" style=\"width:99%;\" id=\"selectInput\" value=\"\">");
131    sb.append("</div>");
132	sb.append("</td>");
133	sb.append("<td width=\"80%\">");
134	sb.append("<div class=\"budget_title\" style=\"position:relative;z-index:100;\">");
135	sb.append("<span style=\"vertical-align:middle;\" onmouseover=\"this.className='budget_over'\" onmouseout=\"this.className=''\"><button class=\"budget_clear\" id=\"btn_unBdgagency01\" onclick=\"dosave()\">±£´æ</button></span>");
136	sb.append("<span style=\"vertical-align:middle;\" onmouseover=\"this.className='budget_over'\" onmouseout=\"this.className=''\"><button class=\"budget_clear\" id=\"btn_unBdgagency02\" onclick=\"copyfrom(0)\">ÐÂÔö²É¼¯±í¿ØÖÆ×é</button></span>");
137	sb.append("<span style=\"vertical-align:middle;\" onmouseover=\"this.className='budget_over'\" onmouseout=\"this.className=''\"><button class=\"budget_clear\" id=\"btn_unBdgagency02\" onclick=\"delForm()\">ɾ³ý¿ØÖÆ×é</button></span>");
138	sb.append("</div>");
139	sb.append("</td>");
140	sb.append("</tr>");
141	sb.append("<tr>");
142	sb.append("<td valign=\"top\">");
143	sb.append("<div id=\"treeDiv\" layout=\"{h:{fit:-25}}\" style=\"background:#fff;border:1px solid #ccc;padding:0px; overflow:auto;height:550px;width:100%;\"></div>");
144	sb.append("</td>");
145	sb.append("<td valign=\"top\">");
146	sb.append("<div id='consolegroupDiv' layout=\"{w:{fit:-250},h:{fit:-25}}\" style=\"background:#fff;border:1px solid #ccc;padding:0px; overflow:auto;height:550px;width:100%;\"></div>");
147	sb.append("</td>");
148	sb.append("</tr>");
149	sb.append("</table>");
150	
151	sb.append("<div id=\"form_content\" style=\"display:none;\" >");
152	sb.append("<div style=\"margin-left:2%;height:20px;\">");
153	sb.append("¿ØÖÆ×éÃû³Æ£º<input type=\"text\" id=\"consolename\"></input>");
154	sb.append("</div>");
155	sb.append("<div style=\"width:425px;height:380px;\">");
156	sb.append("<div id='form_content02' style=\"width:99%;height:375px;overflow:scroll;position:absolute;background-color:#FCFCFC;border:1px solid #ccc;\">");
157	sb.append("</div>");
158	sb.append("</div>");
159	sb.append("<div style=\"margin-left:40%;\">");
160	sb.append("<input type=\"button\" value=\"±£ ´æ\" onclick=\"dosaveform()\"></input>");
161	sb.append("<input type=\"button\" value=\"È¡ Ïû\" onclick=\"form_content_wind.hidden();\"></input>");
162	sb.append("</div>");
163	sb.append("</div>");
164	
165	sb.append("<div id=\"form_subdata\" style=\"display:none;\" >");
166	sb.append("<div style=\"width:425px;height:400px;\">");
167	sb.append("<div id='form_subdata02' style=\"width:99%;height:375px;overflow:scroll;position:absolute;background-color:#FCFCFC;border:1px solid #ccc;\">");
168	sb.append("</div>");
169	sb.append("</div>");
170	sb.append("<div style=\"margin-left:40%;\">");
171	sb.append("<input type=\"button\" value=\"±£ ´æ\" onclick=\"dosavesubdata()\"></input>");
172	sb.append("<input type=\"button\" value=\"È¡ Ïû\" onclick=\"form_subdata_wind.hidden();\"></input>");
173	sb.append("</div>");
174	sb.append("</div>");
175	
176	document.getElementById("template_main").innerHTML = sb.toString();
177}
178
179//ÐÂÔö²É¼¯±í¿ØÖÆ×é
180function copyfrom(tag){	
181	formtag = tag;
182	mainArray = [];
183	
184	if(tag == 1){
185		var params = {};
186		params['menuid'] = menuid;
187		params['consoleCode'] = consoleCode;
188	Ext.lt.RCP.server("datacommon_bdgagencyrule_service", "getFromData",params,function(data){
189		if (data != null && data.result != null) {
190		form_content_wind.show(); 
191		if(!datatable){
192			tableView(data.result, form_content02);
193		} else {
194			var datas = datatable.getRecordset();
195			datas.clear();
196			datas.addData(data.result.toArray());
197		}
198		} else {
199			alert("¸Ã¿ØÖÆ×é¶ÔÓ¦µÄ²É¼¯±íÉèÖò»´æÔÚ£¬Çë²é¿´£¡");
200		}
201		},function(){
202		alert('´íÎó!');	
203		});
204	} else {
205		$("#consolename").val("");
206		var params = {};
207//		params['product'] = $("#producttype").val();
208	Ext.lt.RCP.server("datacommon_bdgagencyrule_service", "getMainList",params,function(data){
209			form_content_wind.show();  
210			if(!datatable){	
211				tableView(data.mainList, form_content02);
212			} else {
213				var datas = datatable.getRecordset();
214				datas.clear();
215				datas.addData(data.mainList.toArray());
216			}
217			},function(){
218		alert('´íÎó!');	
219		});
220	}
221}
222
223//ɾ³ý¿ØÖÆ×é
224function delForm(){
225	var datas = consoletable.getRecordSet().query({check:1});
226	if(!consoleCode){
227		alert("ÇëÏÈÑ¡Ôñ¿ØÖÆ×é!");
228		return;
229	}	
230	
231	if(window.confirm("½«»áɾ³ýÑ¡ÖпØÖÆ×é¼°¿ØÖÆ×éÓйصÄÅäÖã¬È·ÈÏÊÇ·ñɾ³ýÑ¡ÖпØÖÆ×飿")){
232	var params = {};
233	params['menuid'] = menuid;
234	params['consoleCode'] = consoleCode;  
235	
236	Ext.lt.RCP.server("datacommon_bdgagencyrule_service", "deleteConsoleGroup",params,function(data){
237		if (data != null && data.result == 1) {
238			consoletable.getRecordSet().remove(datas);
239			alert("¿ØÖÆ×éɾ³ý³É¹¦£¡");
240		} else {
241			if (data.message != null) {
242				alert(data.message);
243			} else {
244				alert("ɾ³ý¿ØÖÆ×éʧ°Ü£¬ÇëÁªÏµ¹ÜÀíÔ±£¡");
245			}
246		}
247	},function(){
248		alert('´íÎó!');	
249	});
250	}
251}
252
253//±£´æ¿ØÖÆ×é
254function dosaveform(){
255	var consolename = $("#consolename").val();
256	if (consolename == null || consolename == "") {
257		alert("ÇëÊäÈë¿ØÖÆ×éÃû³Æ!");
258		return;
259	}
260	
261	var mainarrays = datatable.getRecordset().toArray();  
262	
263	var params = {};
264	params['mainarrays'] = JSON.stringify(mainarrays);
265	params['subarrays'] = JSON.stringify(mainArray);  
266	params['menuid'] = menuid;
267	params['consoleName'] = consolename;
268	params['code'] = consoleCode;
269	params['formtag'] = formtag;
270	
271	Ext.lt.RCP.server("datacommon_bdgagencyrule_service", "saveConsoleGroup",params,function(data){
272		if (data != null && data.result == 1) {
273		alert("¿ØÖÆ×éÉèÖóɹ¦£¡");
274		var params = {};
275		jumpTo("/datacommon/bdgagencyrule/index.page?mainmenu=" + mainmenu
276				+ "&submenu=" + menuid + "", "post", params);
277		} else {
278			if (data.message != null) {
279				alert(data.message);
280			} else {
281				alert("ÉèÖÿØÖÆ×éʧ°Ü£¬ÇëÁªÏµ¹ÜÀíÔ±£¡");
282			}
283		}
284	},function(){
285		alert('´íÎó!');	
286	});
287}
288
289//±£´æÒªËØ
290function dosavesubdata(){
291	var array = [];
292	var datas = subdatatable.getRecordset();
293	array = datas.toArray();
294	for(var i = 0; i < array.length; i++){
295		array[i]['FORMID'] = formId;
296	}
297	for(var i = 0; i < mainArray.length; i++){
298		if(mainArray[i][0].FORMID == array[0].FORMID){
299			mainArray.splice(i, 1);
300		}
301	}
302	mainArray.push(array); 
303	form_subdata_wind.hidden();
304}
305
306//±£´æ²Ëµ¥ºÍ¿ØÖÆ×é¶ÔÓ¦¹Øϵ
307function dosave(){
308	var userdata = consoletable.getRecordset().query({check:1});
309
310	if (userdata.length == 0) {
311		alert("ÇëÑ¡Ôñ¿ØÖÆ×飡");
312		return;
313	}
314	
315	var userData = qtree.getSelected();
316	if (userData.length == 0) {
317		alert("ÇëÑ¡ÔñÓû§£¡");
318		return;
319	}
320	var itemids = [];
321	var j = 0;
322	if (userData.length > 0) {
323		for ( var i = 0; i < userData.length; i++) {
324			if (userData[i].isleaf == '1') {
325				itemids[j] = userData[i].itemid;
326				j++;
327			}
328		}
329	}
330	var userIdes = itemids.join(",");
331	
332	var params = {};
333	params['userarrays'] = userIdes;
334	params['menuid'] = menuid;
335	params['consoleCode'] = userdata[0].CONSOLECODE;
336	
337	Ext.lt.RCP.server("datacommon_bdgagencyrule_service", "saveConsoleAndUserGroup",params,function(data){
338		if (data != null && data.result == 1) {
339			alert("µ¥Î»²É¼¯±íȨÏÞÉèÖóɹ¦£¡");
340		} else {
341			if (data.message != null) {
342				alert(data.message);
343			} else {
344			alert("µ¥Î»²É¼¯±íȨÏÞÉèÖÃʧ°Ü£¬ÇëÁªÏµ¹ÜÀíÔ±£¡");
345			}
346		}
347	},function(){
348		alert('´íÎó!');	
349	});
350}
351
352//²éѯÁÐ
353function column(){
354	var params = {};
355	params['formid'] = formId;
356	params['menuid'] = menuid;
357	params['consoleCode'] = consoleCode;
358	
359	Ext.lt.RCP.server("datacommon_bdgagencyrule_service", "getFromSubData",params,function(data){
360		if (data != null && data.result != null) {
361		    form_subdata_wind.show();
362		    if(!subdatatable){
363			    subdataView(data.result, form_subdata02);
364		    } else {
365		    	var datas = subdatatable.getRecordset();
366		    	datas.clear();
367		    	datas.addData(data.result.toArray());
368		    }
369		} else {
370			alert("»ñÈ¡²É¼¯±íÒªËØʧ°Ü£¬Çë¼ì²é²É¼¯±í!");
371		}
372	},function(){
373		alert('´íÎó!');	
374	});
375}
376
377//»­±í
378function tableView(tableData, tableDiv){
379	var test = function(i,j,rs,value){
380		if(rs.PERM==1){
381		return ['<input type="radio" value=1 name='+rs.FORMID+' checked>¿É¸Ä     <input type="radio" value=2 name='+rs.FORMID+'>²»¿É¸Ä']
382		}
383		else{
384		return ['<input type="radio" value=1 name='+rs.FORMID+'>¿É¸Ä     <input type="radio" value=2 name='+rs.FORMID+' checked>²»¿É¸Ä']
385		}
386		};
387		
388	var node = function(td,el,l,c,d){	
389		var _val = $(el).find("input[type=radio]:checked");
390		var name = datatable.getCol(c).name;
391		formId = d['FORMID'];
392		if(_val.val() == 1){
393			d['PERM'] = 1;
394		} else {
395			d['PERM'] = 2;
396		}
397		if(name == 'NAME'){
398			column();
399		}
400	}
401	
402	datatable = new Ext.lt.datatable35(tableData);
403	datatable.setCols([
404	{name:'NAME',alias:'¿ØÖÆ×é',width:200,datatype:'S'},
405	{name:'PERM',alias:'ÉèÖÃ',width:200,datatype:'S',fn:test}
406	]);	
407	datatable.setEditSelectCheckbox(false);		
408	datatable.setMouselight('#597EAA');
409	datatable.mousedrag(false);
410	datatable.setClassName('dttheme_ifmis');	
411	datatable.setAlign("left");
412	datatable.setAllowClock(false);	
413	datatable.onEvent('onclick',node);	
414	datatable.setLayout();
415	datatable.draw(tableDiv);
416}
417
418//ÁÐÒªËØ»­±í
419function subdataView(tableData, tableDiv){
420	var test = function(i,j,rs,value){
421		if(rs.PERM==1){
422		return ['<input type="radio" value=1 name='+rs.FORMELEMENTID+' checked>¿É¸Ä     <input type="radio" value=2 name='+rs.FORMELEMENTID+'>²»¿É¸Ä']
423		}
424		else{
425		return ['<input type="radio" value=1 name='+rs.FORMELEMENTID+'>¿É¸Ä     <input type="radio" value=2 name='+rs.FORMELEMENTID+' checked>²»¿É¸Ä']
426		}
427		};
428		
429	var node = function(td,el,l,c,d){	
430			var _val = $(el).find("input[type=radio]:checked");
431			if(_val.val() == 1){
432				d['PERM'] = 1;
433			} else {
434				d['PERM'] = 2;
435			}
436		}
437		
438	subdatatable = new Ext.lt.datatable35(tableData);
439	subdatatable.setCols([
440	{name:'NAME',alias:'ÒªËØ',width:200,datatype:'S'},
441	{name:'PERM',alias:'ÉèÖÃ',width:200,datatype:'S',fn:test}
442	]);	
443	subdatatable.setEditSelectCheckbox(false);		
444	subdatatable.setMouselight('#597EAA');
445	subdatatable.mousedrag(false);
446	subdatatable.setClassName('dttheme_ifmis');	
447	subdatatable.setAlign("left");
448	subdatatable.setAllowClock(false);	
449	subdatatable.onEvent('onclick',node);	
450	subdatatable.setLayout();
451	subdatatable.draw(tableDiv);
452}
453
Full Screen

console.js

Source: console.js Github

copy
1define(["require", "exports", "socket"], function (require, exports, socket_1) {

2    "use strict";
3    var ProcessConsole;
4    (function (ProcessConsole) {
5        var consoleTable = {};
6        var consoleCapacity = 5000;
7        var consoleProcess = null;
8        var consoleFont = null;
9        var consoleFontSize = null;
10        function registerConsole() {
11            socket_1.EventBus.createRoute("BEGIN", createConsole, null);
12            socket_1.EventBus.createRoute('PRINT_ERROR', updateConsole, null);
13            socket_1.EventBus.createRoute('PRINT_OUTPUT', updateConsole, null);
14            socket_1.EventBus.createRoute('TERMINATE', terminateConsole, null); // clear focus
15            socket_1.EventBus.createRoute('EXIT', terminateConsole, null);
16            setInterval(showConsole, 200); // prevents reflow overload when console is busy
17        }
18        ProcessConsole.registerConsole = registerConsole;
19        function updateConsoleFont(fontFamily, fontSize) {
20            var consoleElement = document.getElementById("console");
21            if (consoleElement != null) {
22                consoleElement.style.fontFamily = fontFamily;
23                consoleElement.style.fontSize = fontSize;
24            }
25            consoleFont = fontFamily;
26            consoleFontSize = fontSize;
27        }
28        ProcessConsole.updateConsoleFont = updateConsoleFont;
29        function updateConsoleCapacity(maxCapacity) {
30            consoleCapacity = maxCapacity;
31        }
32        ProcessConsole.updateConsoleCapacity = updateConsoleCapacity;
33        function terminateConsole(socket, type, text) {
34            var message = JSON.parse(text);
35            var process = message.process;
36            if (consoleProcess == process) {
37                showConsole();
38            }
39            var consoleData = consoleTable[process];
40            if (consoleData != null) {
41                consoleData.valid = false; // means it should be terminated when unfocused
42            }
43        }
44        function clearConsole() {
45            var consoleElement = document.getElementById("console");
46            if (consoleElement != null) {
47                document.getElementById("console").innerHTML = "";
48            }
49            consoleProcess = null;
50        }
51        ProcessConsole.clearConsole = clearConsole;
52        /**
53         * This method can be very slow, we need to improve the merging of nodes
54         * so that concatenation reduces the overhead.
55         */
56        function showConsole() {
57            var consoleElement = document.getElementById("console");
58            var consoleText = null;
59            var previous = null;
60            if (consoleElement != null && consoleProcess != null) {
61                var currentText = consoleElement.innerHTML;
62                var consoleData = consoleTable[consoleProcess]; // is ther an update?
63                if (consoleData != null && (currentText == "" || consoleData.update == true)) {
64                    consoleData.update = false; // clear the update
65                    for (var i = 0; i < consoleData.list.length; i++) {
66                        var next = consoleData.list[i];
67                        if (previous == null) {
68                            if (next.error) {
69                                consoleText = "<span class='consoleError'>" + next.text;
70                            }
71                            else {
72                                consoleText = "<span class='consoleNormal'>" + next.text;
73                            }
74                            previous = next.error;
75                        }
76                        else if (next.error != previous) {
77                            consoleText += "</span>";
78                            if (next.error) {
79                                consoleText += "<span class='consoleError'>" + next.text;
80                            }
81                            else {
82                                consoleText += "<span class='consoleNormal'>" + next.text;
83                            }
84                            previous = next.error;
85                        }
86                        else {
87                            consoleText += next.text;
88                        }
89                    }
90                    if (consoleText != null) {
91                        consoleText += "</span>";
92                        consoleElement.innerHTML = consoleText;
93                        consoleElement.scrollTop = consoleElement.scrollHeight;
94                    }
95                }
96                if (consoleFont && consoleFontSize) {
97                    updateConsoleFont(consoleFont, consoleFontSize);
98                }
99            }
100        }
101        ProcessConsole.showConsole = showConsole;
102        function updateConsoleFocus(processToFocus) {
103            if (consoleProcess != processToFocus) {
104                deleteAllInvalidConsoles(processToFocus); // delete only on a change of focus
105                clearConsole();
106                consoleProcess = processToFocus;
107                showConsole();
108            }
109        }
110        ProcessConsole.updateConsoleFocus = updateConsoleFocus;
111        function deleteAllInvalidConsoles(processToKeep) {
112            var validConsoles = {};
113            for (var processName in consoleTable) {
114                if (consoleTable.hasOwnProperty(processName)) {
115                    var consoleData = consoleTable[processName];
116                    if (consoleData.valid || processName == processToKeep) {
117                        validConsoles[processName] = consoleData;
118                    }
119                }
120            }
121            consoleTable = validConsoles; // make sure expired consoles are removed
122        }
123        function createConsole(socket, type, value) {
124            var message = JSON.parse(value);
125            var newProcess = message.process;
126            var consoleData = consoleTable[newProcess];
127            consoleTable[newProcess] = {
128                list: [],
129                size: 0,
130                update: true,
131                valid: true
132            };
133            updateConsoleFocus(newProcess);
134        }
135        /**
136         * This function should probably merge the nodes to some extent, it will improve
137         * the performance of the console rendering.
138         */
139        function updateConsole(socket, type, value) {
140            var offset = value.indexOf(':');
141            var updateProcess = value.substring(0, offset);
142            var updateText = value.substring(offset + 1);
143            var node = {
144                error: type == 'PRINT_ERROR',
145                text: updateText
146            };
147            var consoleData = consoleTable[updateProcess];
148            if (consoleData == null) {
149                consoleData = {
150                    list: [],
151                    size: 0,
152                    update: true,
153                    valid: true
154                };
155                consoleTable[updateProcess] = consoleData;
156            }
157            consoleData.list.push(node); // put at the end, i.e index consoleTable.length - 1
158            consoleData.size += updateText.length; // update the size of the console
159            while (consoleData.list.length > 3 && consoleData.size > consoleCapacity) {
160                var removeNode = consoleData.list.shift(); // remove from the start, i.e index 0
161                if (removeNode != null) {
162                    consoleData.size -= removeNode.text.length;
163                }
164            }
165            consoleData.update = true;
166        }
167    })(ProcessConsole = exports.ProcessConsole || (exports.ProcessConsole = {}));
168});
169//ModuleSystem.registerModule("console", "Console module: console.js", null, ProcessConsole.registerConsole, ["common", "socket"]); 
170
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Playwright Internal on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)