How to use contentJson method in apickli

Best JavaScript code snippet using apickli

tjlbForTb.js

Source:tjlbForTb.js Github

copy

Full Screen

1/**2 * 统计图表生成3 * 4 * @return5 */6function createTb() {7 if(depth > 2){8 alert("图表绘制最多支持两级纵向列,请重设查询条件后再进行操作!");9 return false;10 } 11 12 createTbHxl();//13 createTbZxl();//纵向列表头14 15 createTbTjx();// 统计项16 createTbZxlHead();// 纵向列表头17 createTbContentHead2();// head218 createTbZxlhj();// 纵向列合计19 createTbHxlhj();// 横向列合计20 jQuery("#form2").submit();21}22// 统计项23function createTbTjx() {24 var splitFlag = FGF_BS + ZS;25 var theadName = "thead0";26 var codes = "";27 var tjxJson = "";28 var thead0ThName = "#" + theadName + " th";29 if (depth > 0 && jQuery(thead0ThName).length == 0) {// 有纵向列,仅包含“总数”30 tjxJson += "{";31 tjxJson += "code:'" + ZS + "'";32 tjxJson += ",name:'" + ZS_CN + "'";33 tjxJson += "}";34 } else {35 if (jQuery(thead0ThName).length == 0) {// 无纵向列36 thead0ThName = "[id='thead"+FGF_BS+"hxl'] th[name^='" + theadName + "']";37 }38 jQuery(thead0ThName).each(function(index) {39 var thName = jQuery(this).attr("name");40 var name = jQuery(this).text();// 表头字段名称41 var head0Code = thName.substr(theadName.length + 1);42 var code = head0Code.split(splitFlag)[0];43 if (code == null || code == "" || code.indexOf(ZS) > -1) {44 code = ZS;45 } else {46 code += FGF_BS + ZS;47 }48 if (codes.indexOf(code) > -1) {49 return false;50 } else {51 codes += code + ";";52 }53 if (index > 0) {54 tjxJson += ",";55 }56 tjxJson += "{";57 tjxJson += "code:'" + code + "'";58 tjxJson += ",name:'" + name + "'";59 tjxJson += "}";60 });61 }62 tjxJson = "[" + tjxJson + "]";63 jQuery("#tjxJson").val(tjxJson);64}65/*66 * 图表横向列值设置67 */68function createTbHxl() {69 var hxlHead = "";70 var hxlContent = "";71 var hxlContentCode = "";72 // 报表横向列,取最末一列73 if (bbhxlArr != null && bbhxlArr.length > 0) {74 var lastHxl = bbhxlArr[bbhxlArr.length - 1];75 hxlHead = jQuery("[id='thead" + FGF_BS + "hxl'] th[name='thead"+FGF_BS+"hxl" + FGF_BS + lastHxl + "']")76 .text();77 hxlContent = jQuery(TBODY + " tr td[name^='" + lastHxl + FGF_BS + "']").map(78 function() {79 return "'" + jQuery(this).text() + "'";80 }).get().join(",");81 hxlContentCode = jQuery(TBODY + " tr td[name^='" + lastHxl + FGF_BS + "']").map(82 function() {83 var code = jQuery(this).attr("name");84 return "'" + code + "'";85 }).get().join(",");86 }87 if (hxlContent != "") {88 hxlContent = "[" + hxlContent + "]";89 hxlContentCode = "[" + hxlContentCode + "]";90 }91 jQuery("#hxlHead").val(hxlHead);92 jQuery("#hxlContent").val(hxlContent);93 jQuery("#hxlContentCode").val(hxlContentCode);94}95function createTbZxl(){96 var zxlContent = "";97 var zxlContentCode = "";98 jQuery("#thead1 th[name^='thead1']").each(function(index) {99 var bblname = "'" + jQuery(this).text() + "'";100 if (zxlContent.indexOf(bblname) > -1) {101 return true;102 }103 if (index > 0) {104 zxlContent += ",";105 zxlContentCode += ",";106 }107 zxlContent += bblname;108 zxlContentCode += "'" + jQuery(this).attr("name") + "'";109 });110 111 if (zxlContent != "") {112 zxlContent = "[" + zxlContent + "]";113 zxlContentCode = "[" + zxlContentCode + "]";114 }115 jQuery("#zxlContent").val(zxlContent);116 jQuery("#zxlContentCode").val(zxlContentCode);117}118/*119 * head2的内容,纵向列二级情况 // contentJson = "[{bblname:'2011',zs : [{ name :120 * '男',data:[0,3,5,1,1341,1382,1466,1379]},{ name :121 * '女',data:[1,0,4,1,2991,3076,3207,3406]},{ name :122 * '未知',data:[0,0,0,0,0,0,1,59]}]}]";123 */124function createTbContentHead2() {125 var contentJson = "";126 var theadName = "thead2";127 jQuery("#" + theadName + " th[name^='" + theadName + FGF_BS + "']").each(128 function(index) {129 var thName = jQuery(this).attr("name");130 var name = jQuery(this).text();// 表头字段名称131 var head2Code = thName.substr(theadName.length + 1);132 if (index > 0) {133 contentJson += ",";134 }135 contentJson += createTbContent(name, head2Code);136 });137 if (contentJson == "") {// 仅一级表头138 var zxlHead = jQuery("#zxlHead").val();139 var zxlHeads = zxlHead.split(",");140 var zxlHead0 = "";141 if (zxlHeads != null) {142 zxlHead0 = zxlHeads[0];//143 }144 contentJson = createTbContent(zxlHead0, "");//145 }146 contentJson = "[" + contentJson + "]";147 jQuery("#contentJson").val(contentJson);148}149/*150 * 图表内容值设置,单列设置,返回{}json格式151 */152function createTbContent(bblname, head2Code) {153 var contentJson = "";154 if (head2Code == null) {155 head2Code = "";156 }157 if (bblname == null) {158 bblname = "";159 }160 var theadName = "thead1";161 contentJson += "bblname:'" + bblname + "'";162 var tjxJson = jQuery("#tjxJson").val();163 var tjxJsonObj = eval(tjxJson);164 if (tjxJsonObj != null) {165 for ( var i = 0; i < tjxJsonObj.length; i++) {166 var zxlJson = "";167 var o = tjxJsonObj[i];168 var tjxCode = o.code;169 var tjxName = o.name;170 jQuery(171 "#" + theadName + " th[name^='" + theadName + FGF_BS172 + head2Code + "']").each(function(index) {173 var thName = jQuery(this).attr("name");174 var name = jQuery(this).text();// 表头字段名称175 var contentName = thName.substr(theadName.length);176 if (zxlJson != "") {177 zxlJson += ",";178 }179 zxlJson += getContentJson(name, tjxCode + contentName);180 });181 if (zxlJson == "") {// 不含一级纵向列182 zxlJson += getContentJson(tjxName, tjxCode);183 }184 contentJson += "," + tjxCode + ":[" + zxlJson + "]";185 }186 }187 contentJson = "{" + contentJson + "}";188 return contentJson;189}190/*191 * 用逗号拼接的内容显示列,json格式192 */193function getContentJson(name, contentName) {194 var contentJson = "";195 var content = jQuery(TBODY + " tr td[name^='" + contentName + "']").map(196 function() {197 var text = jQuery(this).text();198 return formatText(text);199 }).get().join(",");200 if (content != null && content != "") {201 contentJson = "{ name : '" + name + "',data:[" + content + "]}";202 }203 return contentJson;204}205/*206 * 格式化数值207 */208function formatText(text) {209 if (text == null || text == "null" || text == "") {210 text = "0";211 }212 text = text.replace("%", "");213 return text;214}215/*216 * 纵向列合计217 */218function createTbZxlhj() {219 contentJson = "";220 content = jQuery(221 TBODY + " tr td[name^='zxlhj"+FGF_BS+"']:not(td[name^='zxlhj"+FGF_BS+"hxlhj'])").map(222 function() {223 return jQuery(this).text();224 }).get().join(",");225 if (content != null && content != "") {226 contentJson = "[{ name : '" + ZXLHJ_CN + "',data:[" + content + "]}]";227 }228 jQuery("#zxlhjContentJson").val(contentJson);229}230/*231 * 横向列合计,或者 不包含横向列情况232 * 233 * 234 */235function createTbHxlContent(bblname, head2Code) {236 var contentJson = "";237 if (head2Code == null) {238 head2Code = "";239 }240 if (bblname == null) {241 bblname = "";242 }243 contentJson += "bblname:'" + bblname + "'";244 var tjxJson = jQuery("#tjxJson").val();//统计项,zs:总数,bfb_zs:百分比245 var tjxJsonObj = eval(tjxJson);246 if (tjxJsonObj != null) {247 var flag = false;248 for ( var i = 0; i < tjxJsonObj.length; i++) {249 var o = tjxJsonObj[i];250 var tjxCode = o.code;//zs251 var tjxName = o.name;//总数252 var data = jQuery("#dtjlh td[name^='" + tjxCode + FGF_BS+head2Code+"']").map(253 function() {// 不包含横向列,单行数据254 var text = jQuery(this).text();255 return formatText(text);256 }).get().join(",");257 if (data == null || data == "") {258 var hxlhjCode = "";259 if(tjxCode == "zs"){260 hxlhjCode = "hxlhj"+FGF_BS+"zs";261 }else if(tjxCode == "bfb"+FGF_BS+"zs"){262 hxlhjCode = "bfb"+FGF_BS+"hxlhj"+FGF_BS+"zs";263 }264 data = jQuery("#hxlhj td[name^='" + hxlhjCode + "']").map(265 function() {// 横向列合计266 var text = jQuery(this).text();267 return formatText(text);268 }).get().join(",");269 }270 if (data != null && data != "") {271 contentJson += "," + tjxCode + ":[{ name : '" + tjxName272 + "',data:[" + data + "]}]";273 }274 }275 }276 if (contentJson != "") {277 contentJson = "{" + contentJson + "}";278 }279 return contentJson;280}281function createTbHxlhj() {282 var contentJson = "";283 var theadName = "thead2";284 jQuery("#" + theadName + " th[name^='" + theadName + FGF_BS+"']").each(285 function(index) {286 var thName = jQuery(this).attr("name");287 var name = jQuery(this).text();// 表头字段名称,2011288 var head2Code = thName.substr(theadName.length + 1);//2011289 if (index > 0) {290 contentJson += ",";291 }292 contentJson += createTbHxlContent(name, head2Code);293 });294 if (contentJson == "") {// 仅一级表头295 var zxlHead = jQuery("#zxlHead").val();296 var zxlHeads = zxlHead.split(",");297 var zxlHead0 = "";298 if (zxlHeads != null) {299 zxlHead0 = zxlHeads[0];//300 }301 contentJson = createTbHxlContent(zxlHead0, "");//302 }303 if(contentJson != ""){304 contentJson = "[" + contentJson + "]";305 }306 jQuery("#hxlhjContentJson").val(contentJson);307}308/*309 * 纵向列头310 */311function createTbZxlHead() {312 var zxlHead = "";313 var zxlHeadCode = "";314 // 报表纵向列getZdsmFromZdmc(zdmc)315 if (bbzxlArr != null && bbzxlArr.length > 0) {316 for ( var i = 0; i < bbzxlArr.length; i++) {317 if (i > 0) {318 zxlHead += ",";319 }320 zxlHeadCode = bbzxlArr[i];321 zxlHead += getZdsmFromZdmc(bbzxlArr[i]);322 }323 }324 jQuery("#zxlHead").val(zxlHead);325 jQuery("#zxlHeadCode").val(zxlHeadCode);...

Full Screen

Full Screen

Auth.ts

Source:Auth.ts Github

copy

Full Screen

1import * as CONST from './Const'2import API from "./Api";3export default {4 forgotPasswordChange(email: string, newPassword: string, code: string): Promise<any> {5 const urlRequest = `${CONST.V1}/auth/forgot-password/change`6 const method = 'POST'7 let contentJson = {8 email,9 newPassword,10 code11 };12 let response = API.api(urlRequest, {13 method: method,14 contentJson: contentJson15 });16 return response;17 },18 forgotPasswordStart(email: string): Promise<any> {19 const urlRequest = `${CONST.V1}/auth/forgot-password/start`20 const method = 'POST'21 let contentJson = {22 email23 };24 let response = API.api(urlRequest, {25 method: method,26 contentJson: contentJson27 });28 return response;29 },30 login(email: string, password: string) {31 const urlRequest = `${CONST.V1}/auth/login`32 const method = 'POST'33 let contentJson = {34 email,35 password36 };37 let response = API.api(urlRequest, {38 method: method,39 contentJson: contentJson40 });41 return response;42 },43 logout() {44 const urlRequest = `${CONST.V1}/auth/logout`45 const method = 'POST'46 let contentJson = {};47 let response = API.api(urlRequest, {48 method: method,49 contentJson: contentJson50 });51 return response;52 },53 refresh(refreshToken: string) {54 const urlRequest = `${CONST.V1}/auth/refresh`55 const method = 'POST'56 let contentJson = {57 refreshToken58 };59 let response = API.api(urlRequest, {60 method: method,61 contentJson: contentJson62 });63 return response;64 },65 signUp(email: string, login: string, password: string) {66 const urlRequest = `${CONST.V1}/auth/sign-up`67 const method = 'POST'68 let contentJson = {69 email,70 login,71 password72 };73 let response = API.api(urlRequest, {74 method: method,75 contentJson: contentJson76 });77 return response;78 },...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var Apickli = require('apickli');2var apickli = new Apickli('http', 'localhost:3000');3apickli.addRequestHeader('Content-Type', 'application/json');4apickli.addRequestHeader('Accept', 'application/json');5apickli.addRequestHeader('Authorization', 'Bearer ' + accessToken);6apickli.contentJson = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var apickli = require('apickli');2var {defineSupportCode} = require('cucumber');3defineSupportCode(function({Given, When, Then}) {4 Given('I set the url to {stringInDoubleQuotes}', function(url, callback) {5 this.apickli.uri = url;6 callback();7 });8 When('I set the request header {stringInDoubleQuotes} to {stringInDoubleQuotes}', function(header, value, callback) {9 this.apickli.addRequestHeader(header, value);10 callback();11 });12 When('I set the request body to {stringInDoubleQuotes}', function(body, callback) {13 this.apickli.addRequestHeader('Content-Type', 'application/json');14 this.apickli.addRequestHeader('Accept', 'application/json');15 this.apickli.addRequestHeader('Accept-Charset', 'utf-8');16 this.apickli.setRequestBody(body);17 callback();18 });19 When('I set the request body to {stringInDoubleQuotes} with {stringInDoubleQuotes} as {stringInDoubleQuotes}', function(body, key, value, callback) {20 this.apickli.addRequestHeader('Content-Type', 'application/json');21 this.apickli.addRequestHeader('Accept', 'application/json');22 this.apickli.addRequestHeader('Accept-Charset', 'utf-8');23 this.apickli.setRequestBody(body);24 this.apickli.replaceInRequest(key, value);25 callback();26 });27 When('I set the request body to {stringInDoubleQuotes} with {stringInDoubleQuotes} as {stringInDoubleQuotes} and {stringInDoubleQuotes} as {stringInDoubleQuotes}', function(body, key1, value1, key2, value2, callback) {28 this.apickli.addRequestHeader('Content-Type', 'application/json');29 this.apickli.addRequestHeader('Accept', 'application/json');30 this.apickli.addRequestHeader('Accept-Charset', 'utf-8');31 this.apickli.setRequestBody(body);32 this.apickli.replaceInRequest(key1, value1);33 this.apickli.replaceInRequest(key2, value2);34 callback();35 });36 When('I set the request body to {stringInDoubleQuotes} with {stringInDoubleQuotes} as {stringInDoubleQuotes} and {stringIn

Full Screen

Using AI Code Generation

copy

Full Screen

1var apickli = require('apickli');2var {defineSupportCode} = require('cucumber');3defineSupportCode(function({Given, When, Then}) {4 Given('I set the request body to JSON', function(callback) {5 this.apickli.setContentJson();6 callback();7 });8});9var apickli = require('apickli');10var {defineSupportCode} = require('cucumber');11defineSupportCode(function({Given, When, Then}) {12 Given('I set the request body to JSON', function(callback) {13 this.apickli.setContentJson();14 callback();15 });16});17I am trying to use the setContentJson() method but I am getting the error that "this.apickli.setContentJson is not a function". I am using the apickli version 1.0.3. My code is below:18var apickli = require('apickli');19var {defineSupportCode} = require('cucumber');20defineSupportCode(function({Given, When, Then}) {21 Given('I set the request body to JSON', function(callback) {22 this.apickli.setContentJson();23 callback();24 });25});26I am trying to use the setContentJson() method but I am getting the error that "this.apickli.setContentJson is not a function". I am using the apickli version 1.0.3. My code is below:27var apickli = require('apickli');28var {defineSupportCode} = require('cucumber');29defineSupportCode(function({Given, When, Then}) {30 Given('I set the request body to JSON', function(callback) {31 this.apickli.setContentJson();32 callback();33 });34});35Thanks for the update. I am trying to use the setContentJson() method but I am getting the error that "this.apickli.setContentJson is not a function". I am using the apickli version 1.0.3. My code is below:36var apickli = require('apickli');37var {defineSupportCode} = require('cucumber');38defineSupportCode(function({Given, When, Then}) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var apickli = require('apickli');2var {Before, After, Given, When, Then, setDefaultTimeout} = require('cucumber');3setDefaultTimeout(60 * 1000);4var apickli = new apickli.Apickli('https', 'api.example.com');5Given('I set header {string} to {string}', function (string, string2) {6 this.apickli.addRequestHeader(string, string2);7 });8Then('the response status is {int}', function (int) {9 this.apickli.assertResponseCode(int);10 });11Then('the response body is', function (string) {12 this.apickli.assertResponseBodyEquals(string);13 });14Then('the response body contains {string}', function (string) {15 this.apickli.assertResponseBodyContains(string);16 });17Then('the response body does not contain {string}', function (string) {18 this.apickli.assertResponseBodyContains(string);19 });20Then('the response header {string} contains {string}', function (string, string2) {21 this.apickli.assertResponseHeaderContains(string, string2);22 });23Then('the response header {string} does not contain {string}', function (string, string2) {24 this.apickli.assertResponseHeaderContains(string, string2);25 });26Then('the response header {string} is {string}', function (string, string2) {27 this.apickli.assertResponseHeaderEquals(string, string2);28 });29Then('the response header {string} is not {string}', function (string, string2) {30 this.apickli.assertResponseHeaderNotEquals(string, string2);31 });32Then('the response header {string} is present', function (string) {33 this.apickli.assertResponseHeaderPresent(string);34 });35Then('the response header {string} is not present', function (string) {36 this.apickli.assertResponseHeaderNotPresent(string);37 });38Then('the response body is JSON', function () {39 this.apickli.assertResponseBodyIsJson();40 });41Then('the response body is JSON with schema', function (string) {42 this.apickli.assertResponseBodyMatchesJsonSchema(string);43 });44Then('the response body is JSON with schema {string} and {string}', function (string, string2) {45 this.apickli.assertResponseBodyMatchesJsonSchema(string, string

Full Screen

Using AI Code Generation

copy

Full Screen

1var apickli = require('apickli');2module.exports = function() {3 this.Given(/^I am using apickli$/, function (callback) {4 apickli.setContentJson();5 callback();6 });7 this.When(/^I send a request to "([^"]*)"$/, function (arg1, callback) {8 apickli.get(arg1, callback);9 });10 this.Then(/^I should get a response with status code "([^"]*)"$/, function (arg1, callback) {11 apickli.assertResponseCode(arg1);12 callback();13 });14}

Full Screen

Using AI Code Generation

copy

Full Screen

1var apickli = require('apickli');2var {defineSupportCode} = require('cucumber');3defineSupportCode(function ({Given, Then, When}) {4 Given('I set the request header value to', function (dataTable, callback) {5 var headers = dataTable.hashes();6 console.log(headers);7 for (var i = 0; i < headers.length; i++) {8 var key = headers[i].key;9 var value = headers[i].value;10 this.apickli.addRequestHeader(key, value);11 }12 callback();13 });14});15var apickli = require('apickli');16var {defineSupportCode} = require('cucumber');17defineSupportCode(function ({Given, Then, When}) {18 Given('I set the request header value to', function (dataTable, callback) {19 var headers = dataTable.hashes();20 console.log(headers);21 for (var i = 0; i < headers.length; i++) {22 var key = headers[i].key;23 var value = headers[i].value;24 this.apickli.addRequestHeader(key, value);25 }26 callback();27 });28});

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