How to use initParam method in wpt

Best JavaScript code snippet using wpt

MForm.js

Source:MForm.js Github

copy

Full Screen

1/**2 * 与表单相关的方法3 * 4 * @author 姜友瑶5 */678//公用的form对象9var MForm = function() {10 "use strict";// 严格模式1112 return {1314 /**15 * 表单提交前,初始化一些必要的事情16 */17 initForm : function(_initParam) {1819 var option = {20 beforeSubmit : null,// 表单提交之前调用函数21 afterSubmit : null,// 刷新数据回调函数22 formSelecter : "#dataform",// 表单默认选择器23 isvalid : true,// 是否对表单进行验证24 validform : null,// 验证表单25 extendParam : {},// 需要添加到表单中的额外参数会一起提交到服务器26 invokeUrl : "",// 数据提交地址27 layerIndex : "",// layer当前窗口的index值(用来关闭ifram)28 isAutoClose : true,// 是否自动关闭29 }30 option = $.extend(option, _initParam);31 var mForm = new mform(option);32 return mForm;33 },3435 /**36 * form表单数据转json37 */38 toJson : function(form) {39 var result = {};40 var fieldArray = $(form).serializeArray();41 for (var i = 0; i < fieldArray.length; i++) {42 var field = fieldArray[i];43 if (field.name in result) {44 result[field.name] += "," + field.value;45 } else {46 result[field.name] = field.value;47 }48 }49 return result;50 },51 /**52 * 重置表单53 */54 reset:function clear_form(formId){55 $(':input',formId) 56 .not(':button, :submit, :reset, :hidden') 57 .val('') 58 .removeAttr('value')59 .removeAttr('checked') 60 .removeAttr('selected');61 $(".select2",formId).val("").trigger("change"); 62 }6364 }65}();6667//私有form表单对象68function mform(option) {6970 this.initParam = option;71 // 对表单进验证72 if (this.initParam.isvalid) {73 this.initParam.validform = MValidform74 .validform(this.initParam.formSelecter);75 }76 if (parent.layer.getFrameIndex) {77 this.initParam.layerIndex = parent.layer.getFrameIndex(window.name);78 }7980 // 提交表单数据81 this.submit = function() {8283 var _this = this;8485 // 验证表单86 if (this.initParam.isvalid) {87 if (!this.initParam.validform.check()) {88 return false;89 }90 }91 // 调用beforesubmit92 if (this.initParam.beforeSubmit) {93 if (this.initParam.beforeSubmit() == false) {94 return;95 }96 }97 98 // 提交表单数据99 $.AjaxProxy(100 {101 p : $.extend(MForm.toJson(_this.initParam.formSelecter),102 _this.initParam.extendParam)103104 }).invoke(105 _this.initParam.invokeUrl,106 function(loj) {107 if (layer.alert) {108 // 执行成功弹出提示层109 layer.msg(loj.getValue("info"), {110 icon : 1,time: 1000111 }, function(inindex) {112 // 关闭提示层113 layer.close(inindex);114 // 自定义刷新回调115 if (_this.initParam.afterSubmit) {116 _this.initParam.afterSubmit();117 }118 // 关闭iframe层119 if (_this.initParam.isAutoClose120 && _this.initParam.layerIndex) {121 parent.layer.close(_this.initParam.layerIndex);122 }123 });124 return;125 } else {126 // 自定义刷新回调127 if (_this.initParam.afterSubmit) {128 _this.initParam.afterSubmit(loj);129 }130 }131 });132 };133 return this; ...

Full Screen

Full Screen

Pagination.js

Source:Pagination.js Github

copy

Full Screen

1/**2 * 分页工具 by 姜友瑶 2016-07-203 */4var Pagination = function() {56 return {7 initParam:{8 pageNow : 1,9 pageSize : 10,10 url:"",11 pagingBoxSelect:"#pagingBox",12 showdataBoxSelect:"#showdataBox",13 offsetSelect:"#_offset",//数据角标14 builderDate:null,//创建数据函数15 },16 17 init:function(param){18 initParam=$.extend(this.initParam,param);19 console.log(param)20 console.log(initParam)21 return this;22 },2324 /**25 * 改变页数26 */27 changePage : function(_pageNow) {28 initParam.pageNow = _pageNow;29 $(initParam.offsetSelect).val((initParam.pageNow - 1) * initParam.pageSize);30 this.serchDate();31 },32 33 //搜索数据34 serchDate:function(){35 36 $.AjaxProxy({c:false,p:MForm.toJson("#dataform")}).invoke(initParam.url , function(loj){37 $(initParam.showdataBoxSelect).empty().html(Pagination.initParam.builderDate(loj));38 //构建分页信息39 Pagination.paging(loj.getValue("total"));40 });41 42 },43 /**44 * 计算分页45 */46 paging:function(rowCount){47 console.log( initParam.pageNow);48 if(rowCount%initParam.pageSize==0){49 initParam.pageCount=parseInt(rowCount/initParam.pageSize);50 }else{51 initParam.pageCount=parseInt(rowCount/initParam.pageSize+1);52 }53// var html = '<span><span>共 ' + rowCount + ' 条记录 </span> &nbsp&nbsp共'54// + initParam.pageCount + '页/当前第' + initParam.pageNow + '页</span>&nbsp&nbsp';55 var html="";56 if (initParam.pageNow == 1) {57 html += '<a class="size-S mr-5" onclick="javascript:void(0)" >&lt;</a>';58 } else {59 html += '<a class="size-S mr-5" onclick="Pagination.changePage(' + (initParam.pageNow - 1) + ')" >&lt;</a>';60 }61 var begin = 0;62 var end = 0;6364 if (initParam.pageCount <= 6) {65 begin = 1;66 end = initParam.pageCount;67 } else {68 begin = initParam.pageNow - 2;69 end = initParam.pageNow + 3 >initParam.pageCount?initParam.pageCount:initParam.pageNow + 3 ;70 if (begin < 1) {71 begin = 1;72 end = 6;73 }74 if (end > initParam.pageCount) {75 begin = pageCount - 5;76 end = pageCount;77 }78 }79 if (initParam.pageNow > 3) {80 html += '<a class="size-S mr-5" onclick="Pagination.changePage(' + 1 + ')" >首页</a>';81 }82 for (var i = begin; i <= end; i++) {8384 if (initParam.pageNow == i) {85 html += '<a class="active size-S mr-5" onclick="javascript:void(0)" >'86 + i + '</a>';87 } else {88 html += '<a class=" size-S mr-5" onclick="Pagination.changePage(' + i + ')">' + i + '</a>';89 }9091 }92 if (end < initParam.pageCount) {93 html += '<a class=" size-S mr-5" onclick="Pagination.changePage(' + pageCount + ')">尾页</a>';94 }95 if (initParam.pageNow == initParam.pageCount) {96 html += '<a class="size-S mr-5" onclick="javascript:void(0)">&gt;</a>';97 } else {9899 html += '<a class="size-S mr-5" onclick="Pagination.changePage(' + (initParam.pageNow + 1) + ')" >&gt;</a>';100 }101 $(initParam.pagingBoxSelect).empty().html(html);102 }103 } ...

Full Screen

Full Screen

transaction.js

Source:transaction.js Github

copy

Full Screen

...8 'api' : 'transaction',9 'do' : 'types'10 };11 if ( userId != null )12 initParam(params, 'user', userId);13 if ( start != null )14 initParam(params, 'start', start);15 if ( end != null )16 initParam(params, 'end', end);17 if ( includeDeleted != null )18 initParam(params, 'deleted', ( includeDeleted ? 1 : 0 ));19 gui.request(params, callback, 'array');20 },21 list: function (filter, callback) {22 var params = {23 'api' : 'transaction',24 'do' : 'list'25 };26 if ( filter != null ) {27 initParam(params, 'user', filter.user);28 initParam(params, 'start', filter.start);29 initParam(params, 'end', filter.end);30 initParam(params, 'showdeleted', filter.showdeleted);31 initParam(params, 'ordermode', filter.mode);32 initParam(params, 'orderby', filter.id);33 }34 gui.request(params, callback, 'array');35 },36 details: function (id, callback) {37 gui.request({38 'api' : 'transaction',39 'do' : 'details',40 'id' : id41 }, callback, 'object');42 },43 add: function (clockingIds, commit, callback) {44 var params = {45 'api' : 'transaction',46 'do' : 'add'47 };48 initParam(params, 'clockings', clockingIds);49 initParam(params, 'commit', commit);50 gui.request(params, callback, ( commit ? 'array' : 'object' ));51 },52 create: function (transaction, bookings, clockings, callback) {53 var clockingIds = [];54 for (var i = 0; i < clockings.length; i++)55 clockingIds.push( clockings[i] && (typeof(clockings[i]) === 'object') ? clockings[i].Id : clockings[i] );56 var params = {57 'api' : 'transaction',58 'do' : 'create'59 };60 initParam(params, 'transaction', {61 'UserId' : transaction.UserId,62 'Start' : transaction.Start,63 'End' : transaction.End,64 'Comment': transaction.Comment65 });66 initParam(params, 'bookings', bookings);67 initParam(params, 'clockings', clockingIds);68 gui.request(params, callback);69 },70 remove: function (id, callback) {71 gui.request({72 'api' : 'transaction',73 'do' : 'remove',74 'id' : id75 }, callback, 'boolean');76 },77 restore: function (id, callback) {78 gui.request({79 'api' : 'transaction',80 'do' : 'restore',81 'id' : id82 }, callback, 'boolean');83 },84 listBookings: function (filter, callback) {85 var params = {86 'api' : 'transaction',87 'do' : 'list_bookings'88 };89 if ( filter != null ) {90 initParam(params, 'user', filter.user);91 initParam(params, 'start', filter.start);92 initParam(params, 'end', filter.end);93 initParam(params, 'types', filter.types);94 initParam(params, 'showdeleted', filter.showdeleted);95 initParam(params, 'ordermode', filter.mode);96 initParam(params, 'orderby', filter.id);97 }98 gui.request(params, callback, 'array');99 }100 };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1wpt.initParam("runs", 3);2wpt.initParam("location", "Dulles_IE10");3wpt.initParam("k", "A.1234567890abcdef1234567890abcdef");4wpt.initParam("f", "json");5wpt.initParam("video", 1);6wpt.initParam("timeline", 1);7wpt.initParam("pollResults", 10);8wpt.initParam("type", "repeatView");9wpt.initParam("mobile", 1);10wpt.initParam("mobileDevice", "Motorola Droid 3");11wpt.initParam("mobileCarrier", "Verizon Wireless");12wpt.initParam("mobileLocation", "Dulles_MotoDroid3");13wpt.initParam("mobileEmulation", 1);14wpt.initParam("mobileEmulationUserAgent", "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.20 (KHTML, like Gecko) Mobile/7B298g");15wpt.initParam("mobileEmulationWidth", 320);16wpt.initParam("mobileEmulationHeight", 480);17wpt.initParam("mobileEmulationPixelRatio", 2);18wpt.initParam("mobileEmulationUserAgent", "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.20 (KHTML, like Gecko) Mobile/7B298g");19wpt.initParam("mobileEmulationWidth", 320);20wpt.initParam("mobileEmulationHeight", 480);21wpt.initParam("mobileEmulationPixelRatio", 2);22wpt.initParam("connectivity", "Cable");23wpt.initParam("bwIn", 1000);24wpt.initParam("bwOut", 1000);25wpt.initParam("latency", 50);26wpt.initParam("plr", 0);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var WPT = new wpt('API_KEY');3WPT.initParam('runs', '3');4var wpt = require('wpt');5var WPT = new wpt('API_KEY');6WPT.initParam('runs', '3');7WPT.initParam('location', 'Dulles:Chrome');8WPT.runTest(function(err, data) {9 if (err) {10 console.log(err);11 } else {12 console.log(data);13 }14});15### wpt(apiKey, options)16### wpt.initParam(key, value)17### wpt.runTest(callback

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 wpt 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