How to use parseKey method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

store.js

Source:store.js Github

copy

Full Screen

...156 let sArr = uniqueArr(store.stables);157 let cArr = [];//重叠的g158 //找出重叠的g,这里有优化的空间,可剪短sArr的长度159 Object.keys(group.state).forEach(key => {160 let realKey = parseKey(key, {x: group.x, y: group.y}).key;161 if (group.state[key] === 1) {162 if (parseKey(realKey).x < 0 || parseKey(realKey).x > config.COL - 1) {163 //超出左右164 //console.log('超出左右');165 cArr.push(parseKey(key).x);166 }167 sArr.forEach(sg => {168 if (realKey === sg) {169 //发生重叠170 cArr.push(parseKey(key).x);171 }172 })173 }174 });175 //修正到合适位置, 只有左、右需要修正,上下不需要.176 uniqueArr(cArr).forEach(x => {177 if (origin === 0) {178 //旋转后修复179 if (x < 2) {180 //这里的2是因为16个方块,从小于第2列开始是左方,以此类推181 //左边重叠,将右移182 console.log('修复左边');183 group.x += 1;184 }185 if (x > 1) {186 //右边重叠,将左移187 console.log('修复右边');188 group.x -= 1;189 }190 } else if (origin === 1) {191 //左右移动后修复192 if (x <= 2) {193 //这里的2是因为16个方块,从小于第2列开始是左方,以此类推194 //左边重叠,将右移195 console.log('修复左边');196 group.x += 1;197 }198 } else if (origin === 2) {199 if (x >= 1) {200 //右边重叠,将左移,I类型从1列开始201 console.log('修复右边');202 group.x -= 1;203 }204 }205 });206 return group;207}208/**209 * 将key转换成坐标210 * @param key211 * @param offset 偏移量212 * @returns {{}}213 */214function parseKey(key, offset) {215 offset = offset || {x: 0, y: 0};216 let x = parseInt(key.split('*')[0]) + offset.x;217 let y = parseInt(key.split('*')[1]) + offset.y;218 return {x: x, y: y, key: x + '*' + y};219}220/**221 * 获取最大可下落的距离222 * @param group223 * @returns {number}224 */225function getEndGroupGap(group) {226 let arr = groupToArray(group);227 let minGap = config.ROW;228 let sArr = uniqueArr(store.stables);229 arr.forEach(a => {230 //取一个最小间隔231 if (config.ROW - parseKey(a).y < minGap) {232 minGap = config.ROW - parseKey(a).y;233 }234 //当底部还有其他稳定的方块235 sArr.forEach(s => {236 if (parseKey(a).x === parseKey(s).x && parseKey(s).y > parseKey(a).y && parseKey(s).y - parseKey(a).y < minGap) {237 minGap = parseKey(s).y - parseKey(a).y;238 }239 })240 });241 return minGap - 1;//去除重复后242}243/**244 * 筛选出所有实心块245 * @param group246 * @returns {Array}247 */248function groupToArray(group) {249 let arr = [];250 for (let key in group.state) {251 if (group.state[key] > 0) {252 let x = parseInt(key.split('*')[0]);253 let y = parseInt(key.split('*')[1]);254 x += group.x;255 y += group.y;256 arr.push(x + '*' + y);257 }258 }259 return arr;260}261/**262 * 结束本轮263 */264function completeRound() {265 //本轮结束,暂停tick。266 store.isIng = false;267 //消去行后的稳定组268 store.stables = cleanAndDecline(store.stables.concat(store.actives));269 if (mobx.toJS(store.actives).some(item => parseKey(item).y <= 0)) {270 console.log('触顶');271 gameOver();272 } else {273 console.log('新一轮');274 newRound();275 }276}277/**278 * 消除掉填满的行279 * @param arr280 * @param onCleanEveryLine281 * @returns {*[]|*}282 */283function cleanAndDecline(arr, onCleanEveryLine) {284 arr = uniqueArr(arr);285 //找出已经填满的行286 let fulls = [];287 let obj = {};288 for (let k in arr) {289 let row = parseKey(arr[k]).y;290 if (!obj[row]) {291 obj[row] = 1;292 //console.log('get one:', row);293 } else {294 obj[row] += 1;295 if (obj[row] >= config.COL) {296 fulls.push(row);297 }298 }299 }300 scroe = Math.pow(config.EACH_S, fulls.length);301 store.totalScore += scroe;302 //console.log(roundScroe);303 fulls.forEach(row => {304 //console.log('将消去行:', row);305 //消除306 arr = arr.filter(item => parseKey(item).y !== row);307 //下落308 arr = arr.map(v => {309 let locx = parseKey(v).x;310 let locy = parseKey(v).y;311 if (locy < parseInt(row)) {312 locy += 1;313 return locx + '*' + locy;314 } else {315 return v;316 }317 });318 });319 //console.log('本轮得分:', roundScroe);320 return arr;321}322/**323 *324 */...

Full Screen

Full Screen

cycleOfFifths.spec.js

Source:cycleOfFifths.spec.js Github

copy

Full Screen

1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3const chai_1 = require("chai");4const parsekeySignature_1 = require("../parsekeySignature");5describe("finds key signatures", function () {6 it("gets correct key signature alterations", function () {7 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:C]")).to.eql([]);8 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:A minor]")).to.eql([]);9 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:G]")).to.eql(["^F"]);10 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:E minor]")).to.eql(["^F"]);11 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:D]")).to.eql(["^F", "^C"]);12 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:B minor]")).to.eql(["^F", "^C"]);13 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:A]")).to.eql(["^F", "^C", "^G"]);14 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:F# minor]")).to.eql(["^F", "^C", "^G"]);15 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:F]")).to.eql(["_B"]);16 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:Bb]")).to.eql(["_B", "_E"]);17 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:G minor]")).to.eql(["_B", "_E"]);18 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:Eb]")).to.eql(["_B", "_E", "_A"]);19 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:C minor]")).to.eql(["_B", "_E", "_A"]);20 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:Ab]")).to.eql(["_B", "_E", "_A", "_D"]);21 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:F minor]")).to.eql(["_B", "_E", "_A", "_D"]);22 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:Gb]")).to.eql([23 "_B",24 "_E",25 "_A",26 "_D",27 "_G",28 "_C",29 ]);30 (0, chai_1.expect)((0, parsekeySignature_1.findKeySignature)("[K:Eb minor]")).to.eql([31 "_B",32 "_E",33 "_A",34 "_D",35 "_G",36 "_C",37 ]);38 });39 it("finds notes in major key", function () {40 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:C]")).to.eql([41 "c",42 "d",43 "e",44 "f",45 "g",46 "a",47 "b",48 ]);49 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:Db]")).to.eql([50 "c",51 "_d",52 "_e",53 "f",54 "_g",55 "_a",56 "_b",57 ]);58 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:D]")).to.eql([59 "^c",60 "d",61 "e",62 "^f",63 "g",64 "a",65 "b",66 ]);67 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:Eb]")).to.eql([68 "c",69 "d",70 "_e",71 "f",72 "g",73 "_a",74 "_b",75 ]);76 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:E]")).to.eql([77 "^c",78 "^d",79 "e",80 "^f",81 "^g",82 "a",83 "b",84 ]);85 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:F]")).to.eql([86 "c",87 "d",88 "e",89 "f",90 "g",91 "a",92 "_b",93 ]);94 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:Gb]")).to.eql([95 "_c",96 "_d",97 "_e",98 "f",99 "_g",100 "_a",101 "_b",102 ]);103 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:G]")).to.eql([104 "c",105 "d",106 "e",107 "^f",108 "g",109 "a",110 "b",111 ]);112 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:Ab]")).to.eql([113 "c",114 "_d",115 "_e",116 "f",117 "g",118 "_a",119 "_b",120 ]);121 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:A]")).to.eql([122 "^c",123 "d",124 "e",125 "^f",126 "^g",127 "a",128 "b",129 ]);130 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:Bb]")).to.eql([131 "c",132 "d",133 "_e",134 "f",135 "g",136 "a",137 "_b",138 ]);139 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:B]")).to.eql([140 "^c",141 "^d",142 "e",143 "^f",144 "^g",145 "^a",146 "b",147 ]);148 });149 it("finds notes in minor key", function () {150 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:C minor]")).to.eql([151 "c",152 "d",153 "_e",154 "f",155 "g",156 "_a",157 "_b",158 ]);159 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:C# minor]")).to.eql([160 "^c",161 "^d",162 "e",163 "^f",164 "^g",165 "a",166 "b",167 ]);168 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:D minor]")).to.eql([169 "c",170 "d",171 "e",172 "f",173 "g",174 "a",175 "_b",176 ]);177 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:Eb minor]")).to.eql([178 "_c",179 "_d",180 "_e",181 "f",182 "_g",183 "_a",184 "_b",185 ]);186 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:E minor]")).to.eql([187 "c",188 "d",189 "e",190 "^f",191 "g",192 "a",193 "b",194 ]);195 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:F minor]")).to.eql([196 "c",197 "_d",198 "_e",199 "f",200 "g",201 "_a",202 "_b",203 ]);204 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:F# minor]")).to.eql([205 "^c",206 "d",207 "e",208 "^f",209 "^g",210 "a",211 "b",212 ]);213 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:G minor]")).to.eql([214 "c",215 "d",216 "_e",217 "f",218 "g",219 "a",220 "_b",221 ]);222 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:G# minor]")).to.eql([223 "^c",224 "^d",225 "e",226 "^f",227 "^g",228 "^a",229 "b",230 ]);231 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:A minor]")).to.eql([232 "c",233 "d",234 "e",235 "f",236 "g",237 "a",238 "b",239 ]);240 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:Bb minor]")).to.eql([241 "c",242 "_d",243 "_e",244 "f",245 "_g",246 "_a",247 "_b",248 ]);249 (0, chai_1.expect)((0, parsekeySignature_1.findNotesInKey)("[K:B minor]")).to.eql([250 "^c",251 "d",252 "e",253 "^f",254 "g",255 "a",256 "b",257 ]);258 });...

Full Screen

Full Screen

deta.js

Source:deta.js Github

copy

Full Screen

...45 const conditions = {};46 const _isArrayKeys = [];47 for (let k in where) {48 if (think.isString(where[k])) {49 conditions[parseKey(k)] = where[k];50 continue;51 }52 if (where[k] === undefined) {53 conditions[parseKey(k)] = null;54 }55 if (!think.isArray(where[k]) || !where[k][0]) {56 continue;57 }58 const handler = where[k][0].toUpperCase();59 switch (handler) {60 case 'IN':61 conditions[parseKey(k)] = where[k][1];62 if (think.isArray(where[k][1])) {63 _isArrayKeys.push(parseKey(k));64 }65 break;66 case 'NOT IN':67 /**68 * deta base doesn't support not equal with multiple value query69 * so we have to transfer it into equal with some value in most of scene70 */71 if (Array.isArray(where[k][1]) && parseKey(k) === 'status') {72 const STATUS = ['approved', 'waiting', 'spam'];73 let val = STATUS.filter((s) => !where[k][1].includes(s));74 if (val.length === 1) {75 val = val[0];76 }77 conditions[parseKey(k)] = val;78 }79 conditions[parseKey(k) + '?ne'] = where[k][1];80 break;81 case 'LIKE': {82 const first = where[k][1][0];83 const last = where[k][1].slice(-1);84 if (first === '%' && last === '%') {85 conditions[parseKey(k) + '?contains'] = where[k][1].slice(1, -1);86 } else if (first === '%') {87 conditions[parseKey(k) + '?contains'] = where[k][1].slice(1);88 } else if (last === '%') {89 conditions[parseKey(k) + '?pfx'] = where[k][1].slice(0, -1);90 }91 break;92 }93 case '!=':94 conditions[parseKey(k) + '?ne'] = where[k][1];95 break;96 case '>':97 conditions[parseKey(k) + '?gt'] = where[k][1];98 break;99 }100 }101 if (_isArrayKeys.length === 0) {102 return conditions;103 }104 return this.complex(conditions, _isArrayKeys);105 }106 async select(where, { limit, offset, field } = {}) {107 const conditions = this.where(where);108 if (think.isArray(conditions)) {109 return Promise.all(110 conditions.map((condition) =>111 this.select(condition, { limit, offset, field })...

Full Screen

Full Screen

steps.js

Source:steps.js Github

copy

Full Screen

...3const JSON5 = require('json5')4const DB = require('../../lib')5Given('database containing', async function (table) {6 for (const row of table.hashes()) {7 await this.db.set(parseKey(row.Key), parseValue(row.Value))8 }9 this.events = []10})11When('I create a new database {string} with default options', async function (name) {12 if (!this.dbs) this.dbs = {}13 this.dbs[name] = new DB()14})15When('I use {string} as a prefix', function (prefix) {16 this.db = this.db.prefix(prefix)17})18When('I unprefix once', function () {19 this.db = this.db.unprefix()20})21When('I unprefix twice', function () {22 this.db = this.db.unprefix().unprefix()23})24When(/^I store (.+)=(.+) in the database$/, async function (key, value) {25 return await this.db.set(parseKey(key), parseValue(value))26})27When(/^I store (.+)=(.+) with TTL=(-?\d+)$/, async function (key, value, ttl) {28 return await this.db.set(parseKey(key), parseValue(value), { ttl })29})30When(/^I rename (.+) to (.+)$/, async function (from, to) {31 return await this.db.rename(parseKey(from), parseKey(to))32})33When(/^I delete (.+)$/, async function (key) {34 return await this.db.delete(parseKey(key))35})36When(/^I clear the database$/, async function () {37 return await this.db.clear()38})39When('wait {int} milliseconds', async function (delay) {40 return await new Promise(r => setTimeout(r, delay))41})42When('wait {int} seconds', async function (delay) {43 return await new Promise(r => setTimeout(r, delay * 1000))44})45Then('the type of {string} database should be {string}', async function (name, type) {46 assert(this.dbs[name].uri === type || this.dbs[name].uri.startsWith(`${type}:`))47})48Then('I can verify that there are {int} keys in the database', async function (count) {49 assert.equal(count, await this.db.count())50})51Then(/^I can verify that (.+)=(.+) is in the database$/, async function (key, value) {52 assert(await this.db.has(parseKey(key)))53 assert.deepEqual(parseValue(value), await this.db.get(parseKey(key)))54})55Then(/^I can verify that (.+) is NOT in the database$/, async function (key) {56 assert.equal(false, await this.db.has(parseKey(key)))57 assert.equal(undefined, await this.db.get(parseKey(key)))58})59Then('iterating should return', async function (table) {60 const results = await this.db.entries()61 for (let i = 0; i < results.length; i++) {62 const [ key, value ] = results[i]63 const row = table.hashes()[i]64 assert.deepEqual(parseKey(row.Key), key)65 assert.deepEqual(parseValue(row.Value), value)66 }67})68Then('iterating keys should return', async function (table) {69 const results = await this.db.keys()70 for (let i = 0; i < results.length; i++) {71 const key = results[i]72 const row = table.hashes()[i]73 assert.deepEqual(parseKey(row.Key), key)74 }75})76Then('iterating values should return', async function (table) {77 const results = await this.db.values()78 for (let i = 0; i < results.length; i++) {79 const value = results[i]80 const row = table.hashes()[i]81 assert.deepEqual(parseValue(row.Value), value)82 }83})84Then('iterating on prefix {string} should return', async function (prefix, table) {85 const results = await this.db.entries({ prefix })86 for (let i = 0; i < results.length; i++) {87 const [ key, value ] = results[i]88 const row = table.hashes()[i]89 assert.deepEqual(parseKey(row.Key), key)90 assert.deepEqual(parseValue(row.Value), value)91 }92})93Then('iterating on prefix {string} with a limit of {int} should return', async function (prefix, limit, table) {94 const results = await this.db.entries({ prefix, limit })95 for (let i = 0; i < results.length; i++) {96 const [ key, value ] = results[i]97 const row = table.hashes()[i]98 assert.deepEqual(parseKey(row.Key), key)99 assert.deepEqual(parseValue(row.Value), value)100 }101})102Then('decoding keys while iterating on prefix {string} should return', async function (prefix, table) {103 const results = await this.db.entries({ prefix, decodeKeys: true })104 for (let i = 0; i < results.length; i++) {105 const [ key, value ] = results[i]106 const row = table.hashes()[i]107 assert.deepEqual(parseKey(row.Key), key)108 assert.deepEqual(parseValue(row.Value), value)109 }110})111Then(/^I am notified of (.+)=(.+) having been stored$/, async function (key, value) {112 assert.equal(1, this.events.length)113 assert.equal('set', this.events[0].type)114 assert.equal(parseKey(key), this.events[0].key)115 assert.equal(parseValue(value), this.events[0].value)116})117Then(/^I am notified of (.+) having been deleted$/, async function (key) {118 assert.equal(1, this.events.length)119 assert.equal('deleted', this.events[0].type)120 assert.equal(parseKey(key), this.events[0].key)121})122Then(/^I am notified of (.+) having been renamed to (.+)$/, async function (before, after) {123 assert.equal(1, this.events.length)124 assert.equal('renamed', this.events[0].type)125 assert.equal(parseKey(before), this.events[0].before)126 assert.equal(parseKey(after), this.events[0].after)127})128Then(/^I am notified of all of the following having been deleted in this order$/, async function (table) {129 assert.equal(table.hashes().length + 1, this.events.length)130 for (const [i, row] of table.hashes().entries()) {131 assert.equal('deleted', this.events[i].type)132 assert.equal(row.Key, this.events[i].key)133 }134 assert.equal('cleared', this.events[this.events.length - 1].type)135})136//137// Support functions138//139function parseKey(str) {140 if (str[0] === '[') return toArray(str, parseKey)141 const number = Number(str)142 if (!isNaN(number)) return number143 return str144}145function parseValue(str) {146 if (str[0] === '[') return toArray(str, parseValue)147 if (str[0] === '{') return toObject(str)148 if (str === 'true') return true149 if (str === 'false') return false150 const number = Number(str)151 if (!isNaN(number)) return number152 return str153}...

Full Screen

Full Screen

parseHub.js

Source:parseHub.js Github

copy

Full Screen

1'use strict';2/**3 * @ngdoc overview4 * @name unitSchedulingApp5 * @description6 * # unitSchedulingApp7 *8 * Main module of the application.9 */10angular11 .module('ParseHubApp', [12 'ngAnimate',13 'ngCookies',14 'ngResource',15 'ngRoute',16 'ngSanitize',17 'ngTouch'18 ], function($interpolateProvider) {19 $interpolateProvider.startSymbol('[[');20 $interpolateProvider.endSymbol(']]');21 });22angular.module('ParseHubApp')23 .controller('ParseHubCtrl', ['$scope', '$http', '$window', function($scope, $http, $window) {24 $http.get('https://www.parsehub.com/api/v2/projects/'+ parsepkey + '?api_key=' + parsekey + '&offset=0')25 .success(function(data) {26 console.log(data);27 $scope.results = data;28 })29 $scope.reset = function() {30 $scope.keyword = "";31 $scope.relatedKeywords = 1;32 $scope.domains = {};33 $scope.domainArray = [];34 $scope.complete = false;35 $scope.searching = false;36 $scope.status = "";37 $scope.region = "us";38 }39 $scope.search = function() {40 $scope.searching = true;41 $scope.keywordsArr = [];42 $scope.status = "Checking " + $scope.keyword.trim() + "...";43 var check = encodeURIComponent($scope.keyword.trim().replace(" ", "+"));44 parseHubKeyword(check);45 }46 //store value in local storage so that it can be reloaded agai47 $scope.storeKey = function() {48 if ($scope.store){49 $window.localStorage['parsekey'] = $scope.parsekey; 50 }51 else52 {53 $window.localStorage.removeItem('parsekey'); 54 }55 }56 $scope.storeKey1 = function() {57 if ($scope.store1){58 $window.localStorage['parsepkey'] = $scope.parsepkey; 59 }60 else61 {62 $window.localStorage.removeItem('parsepkey'); 63 }64 }65 //store value in local storage as user types66 $scope.onChange = function () {67 if ($scope.parsekey){68 $window.localStorage['parsekey'] = $scope.parsekey; 69 }70 if ($scope.parsepkey){71 $window.localStorage['parsepkey'] = $scope.parsepkey; 72 }73 }74 function parseHubKeyword(keyword) {75 var newRequest = new xdRequest;76 console.log("Requesting Phrase Related Keywords");77 console.log("https://www.parsehub.com/api/v2/projects/"+ parsepkey + "?api_key=" + parsekey + "&offset=0");78 newRequest.setURL("https://www.parsehub.com/api/v2/projects/"+ parsepkey + "?api_key=" + parsepkey + "&offset=0");79 newRequest.get(function(response) {80 var keywords = parseHubData(response.html);81 $scope.$apply(function() {82 $scope.keywords = keywords;83 });84 SEMRushOrganic();85 });86 }87 function parseHubData(data) {88 var resp = [];89 if (data.indexOf("ERROR") > -1) {90 console.log(data);91 $scope.status_update = data;92 $scope.error_message = data;93 return resp;94 }95 var lines = data.split("\n");96 var headers = [];97 if(lines.length>1){98 for (var i = 0; i < lines.length; i++) {99 if (lines[i].trim().length > 0) {100 var vals = lines[i].trim().split(";");101 if (i == 0) {102 //Headers103 headers = vals;104 } else {105 var elem = {};106 for (var j = 0; j < headers.length; j++) {107 elem[headers[j]] = vals[j];108 }109 resp.push(elem);110 }111 }112 }113 }114 return resp;115 }116 $scope.dump = function() {117 console.log($scope);118 }119 $scope.json = function () {120 var result;121 $.getJSON("https://www.parsehub.com/api/v2/projects/"+ parsepkey + "?api_key=" + parsekey + "&offset=0"), 122 function(data) {123 result = data;124 };125 for (var k=0; k<result.length; k++)126 for (var name in result[k]) {127 console.log("keyword: "+start_value);128 console.log("Status: "+result[k][name].statuss);129 }130 }131 $window.localStorage['parsekey'] == undefined ? $scope.parsekey = "" : $scope.parsekey = $window.localStorage['parsekey'];132 $window.localStorage['parsepkey'] == undefined ? $scope.parsepkey = "" : $scope.parsepkey = $window.localStorage['parsepkey'];133 134 // $scope.parsekey = $window.localStorage['parsekey'];135 $scope.store = $window.localStorage['parsekey'] != undefined;136 $scope.store1 = $window.localStorage['parsepkey'] != undefined;137 $scope.reset();...

Full Screen

Full Screen

adminViewRecordObject.js

Source:adminViewRecordObject.js Github

copy

Full Screen

...8export const parseKey = (key, content) => {9 return key.split('.').reduce((prev, curr) => prev && prev[curr], content);10};11export const authorAffiliates = (key, content) => {12 const authorAffiliate = parseKey(key, content) ?? null;13 if (!!!authorAffiliate || !Array.isArray(authorAffiliate)) return 'No';14 return !!authorAffiliate.length > 0 ? 'Yes' : 'No';15};16export const getDefaultDrawerDescriptorObject = () => {17 return (18 (config?.viewRecord?.adminViewRecordDefaultContent?.object && {19 ...config.viewRecord.adminViewRecordDefaultContent.object,20 }) ||21 /* istanbul ignore next */22 undefined23 );24};25export const getDefaultDrawerDescriptorIndex = () => {26 return (27 (config?.viewRecord?.adminViewRecordDefaultContent?.index && {28 ...config.viewRecord.adminViewRecordDefaultContent.index,29 }) ||30 /* istanbul ignore next */31 undefined32 );33};34/* istanbul ignore next */35export const createDefaultDrawerDescriptorObject = (locale = {}, content = [], fields = {}) => {36 const adminViewRecordDefaultContentObject = getDefaultDrawerDescriptorObject();37 const adminViewRecordDefaultContentIndex = getDefaultDrawerDescriptorIndex();38 if (!adminViewRecordDefaultContentObject || !adminViewRecordDefaultContentIndex) return {};39 // Notes40 const parsedNotesKey = formattedString(parseKey(fields.notes, content));41 // don't ReactHtmlParse notes if they're empty and the above function has returned '-',42 // otherwise ReactHtmlParse will return an array and will cause issues when rendering to screen.43 const parsedNotes = parsedNotesKey !== '-' ? ReactHtmlParser(parsedNotesKey) : parsedNotesKey;44 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.notes][0].value = locale.notes;45 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.notes][1].value = parsedNotes;46 // Authors47 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.authors][0].value =48 locale.authorAffiliations;49 adminViewRecordDefaultContentObject.sections[50 adminViewRecordDefaultContentIndex.authors51 ][1].value = authorAffiliates(fields.authorAffiliates, content);52 // WoS53 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.wos][0].value = locale.wosId;54 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.wos][1].value = formattedString(55 parseKey(fields.wosId, content) ?? undefined,56 );57 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.wos][2].value = locale.wosDocType;58 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.wos][3].value = formattedString(59 parseKey(fields.wosDocType, content) ?? undefined,60 parseKey(fields.wosDocTypeLookup, content) ?? undefined,61 );62 // Scopus63 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.scopus][0].value = locale.scopusId;64 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.scopus][1].value = formattedString(65 parseKey(fields.scopusId, content) ?? undefined,66 );67 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.scopus][2].value =68 locale.scopusDocType;69 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.scopus][3].value = formattedString(70 parseKey(fields.scopusDocType, content) ?? undefined,71 parseKey(fields.scopusDocTypeLookup, content) ?? undefined,72 );73 // Pubmed74 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.pubmed][0].value = locale.pubmedId;75 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.pubmed][1].value = formattedString(76 parseKey(fields.pubMedId, content) ?? undefined,77 );78 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.pubmed][2].value =79 locale.pubmedCentralId;80 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.pubmed][3].value = formattedString(81 parseKey(fields.pubMedCentralId, content) ?? undefined,82 );83 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.pubmed][4].value =84 locale.pubmedDocType;85 adminViewRecordDefaultContentObject.sections[adminViewRecordDefaultContentIndex.pubmed][5].value = formattedString(86 parseKey(fields.pubMedDocType, content) ?? undefined,87 parseKey(fields.pubMedDocTypeLookup, content) ?? undefined,88 );89 return adminViewRecordDefaultContentObject;90};91createDefaultDrawerDescriptorObject.propTypes = {92 locale: PropTypes.object.isRequired,93 content: PropTypes.array.isRequired,94 fields: PropTypes.object.isRequired,...

Full Screen

Full Screen

utils.js

Source:utils.js Github

copy

Full Screen

...53 var row = document.createElement("tr");54 row.id = "Row" + i + k + j;55 var column = document.createElement("td");56 column.id = "Key" + i + k + j;57 var parseKey = _krnFileSystemDriver.parseKey(key);58 column.innerHTML = parseKey.i + ":" + parseKey.k + ":" + parseKey.j;59 row.appendChild(column);60 column = document.createElement("td");61 column.id = "Use" + i + k + j;62 row.appendChild(column);63 column = document.createElement("td");64 column.id = "Next" + i + k + j;65 row.appendChild(column);66 column = document.createElement("td");67 column.id = "Data" + i + k + j;68 row.appendChild(column);69 body.appendChild(row);70 }71 }72 }73 };74 //Update a specific row in the disk display75 Utils.updateDiskRow = function (key) {76 var parseKey = _krnFileSystemDriver.parseKey(key);77 var block = sessionStorage.getItem(key);78 var use = document.getElementById("Use" + parseKey.i + parseKey.k + parseKey.j);79 var inUse = _krnFileSystemDriver.blockFree(block);80 if (inUse) {81 use.innerHTML = "0";82 }83 else {84 use.innerHTML = "1";85 }86 var next = document.getElementById("Next" + parseKey.i + parseKey.k + parseKey.j);87 var blockPointer = _krnFileSystemDriver.getBlockPointer(block);88 var parsePointer = _krnFileSystemDriver.parseKey(blockPointer);89 next.innerHTML = parsePointer.i + parsePointer.k + parsePointer.j;90 var data = document.getElementById("Data" + parseKey.i + parseKey.k + parseKey.j);91 data.innerHTML = _krnFileSystemDriver.getBlockDataRaw(block);92 };93 return Utils;94 }());95 TSOS.Utils = Utils;...

Full Screen

Full Screen

xmlParser.js

Source:xmlParser.js Github

copy

Full Screen

1const parser = require('xml-js')2const myParser = {}3/**4 * The main function5 * @param {string} xml xml which needs to be parsed6 * @param {object} [xmlns] contains all namespaces7 * @return {object} parsed js object8 */9myParser.xml2js = function (xml, xmlns) {10 let parsed = parser.xml2js(xml, {11 compact: true12 })13 if (xmlns) {14 // Keep Namespace15 parsed = keepNamespace(parsed, xmlns)16 }17 parsed = cleanseJson(parsed)18 return parsed19}20/**21 * Keeps the namespace22 * @param {object} json In which to replace namespace23 * @param {object} ns Namespace object24 * @return {object} Namespace replaced object25 */26function keepNamespace (json, ns) {27 const nsKeys = Object.keys(ns)28 for (const key in json) {29 const parseKey = parseKeyNS(key)30 if (key.indexOf(':') > -1 && nsKeys.indexOf(parseKey) > -1) {31 const index = nsKeys.indexOf(parseKey)32 const prop = '{' + ns[nsKeys[index]] + '}' + key.split(':')[1]33 json[prop] = json[key]34 json[prop] = recursiveNS(json[prop], ns)35 } else {36 json[key] = recursiveNS(json[key], ns)37 }38 }39 json = deleteDuplicates(json, ns)40 return json41}42/**43 * Intermediate of keepNamespace()44 */45function deleteDuplicates (json, ns) {46 let ret = {}47 const nsKeys = Object.keys(ns)48 if (json.constructor === Array) {49 ret = []50 }51 if (typeof (json) !== 'object') {52 return json53 }54 for (const key in json) {55 if (json.constructor === Array) {56 ret.push(recursiveDeleteDuplicates(json[key], ns))57 } else {58 const parseKey = parseKeyNS(key)59 if (parseKey && nsKeys.indexOf(parseKey) === -1) {60 ret[key] = recursiveDeleteDuplicates(json[key], ns)61 }62 }63 }64 return ret65}66/**67 * This function removes the "_text" attribute introduced by the XML parser68 * For more info, check the NPM page of "xml-js", and see response format of the parser69 * @param {object} json object to cleanse70 * @return {object} cleaned object71 */72function cleanseJson (json) {73 for (const key in json) {74 json[key] = recursiveCleanse(json[key])75 }76 return json77}78/**79 * HELPER FOR keepNamespace()80 */81function recursiveNS (json, ns) {82 if (typeof (json) !== 'object') {83 return json84 }85 const nsKeys = Object.keys(ns)86 for (const key in json) {87 const parseKey = parseKeyNS(key)88 if (key.indexOf(':') > -1 && nsKeys.indexOf(parseKey) > -1) {89 const index = nsKeys.indexOf(parseKey)90 const prop = '{' + ns[nsKeys[index]] + '}' + key.split(':')[1]91 json[prop] = json[key]92 json[prop] = recursiveNS(json[prop], ns)93 } else {94 json[key] = recursiveNS(json[key], ns)95 }96 }97 return json98}99/**100 * HELPER FOR deleteDuplicates()101 */102function recursiveDeleteDuplicates (json, ns) {103 if (typeof (json) !== 'object') {104 return json105 }106 const nsKeys = Object.keys(ns)107 let ret = {}108 if (json.constructor === Array) {109 ret = []110 }111 for (const key in json) {112 if (json.constructor === Array) {113 ret.push(recursiveDeleteDuplicates(json[key], ns))114 } else {115 const parseKey = parseKeyNS(key)116 if (parseKey && nsKeys.indexOf(parseKey) === -1) {117 ret[key] = recursiveDeleteDuplicates(json[key], ns)118 }119 }120 }121 return ret122}123/**124 * HELPER FOR cleanseJson()125 */126function recursiveCleanse (json) {127 if (typeof (json) !== 'object') {128 return json129 }130 for (const key in json) {131 if (key === '_text') {132 return json[key]133 }134 json[key] = recursiveCleanse(json[key])135 }136 return json137}138/**139 * parses a key from d: to d and {DAV:} to DAV140 * @param {string} key key to be parsed141 * @return {string} parsed key142 */143function parseKeyNS (key) {144 let parseKey = key145 if (parseKey.indexOf('{') > -1 && parseKey.indexOf('}') > -1) {146 parseKey = parseKey.split('{')[1].split('}')[0]147 } else if (parseKey.indexOf(':') > -1) {148 parseKey = parseKey.split(':')[0]149 }150 return parseKey151}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver'),2 XCUITestDriver = require('appium-xcuitest-driver').Driver,3 until = webdriver.until;4var driver = new webdriver.Builder()5 .forBrowser('XCUITest')6 .build();7driver.findElement(By.name('q')).sendKeys('webdriver');8driver.findElement(By.name('btnG')).click();9driver.wait(until.titleIs('webdriver - Google Search'), 1000);10driver.quit();11var webdriverio = require('webdriverio'),12 XCUITestDriver = require('appium-xcuitest-driver').Driver,13 until = webdriverio.until;14var driver = new webdriverio.Builder()15 .forBrowser('XCUITest')16 .build();17driver.findElement(By.name('q')).sendKeys('webdriver');18driver.findElement(By.name('btnG')).click();19driver.wait(until.titleIs('webdriver - Google Search'), 1000);20driver.quit();21var webdriverio = require('webdriverio'),22 XCUITestDriver = require('appium-xcuitest-driver').Driver,23 until = webdriverio.until;24var driver = new webdriverio.Builder()25 .forBrowser('XCUITest')26 .build();27driver.findElement(By.name('q')).sendKeys('webdriver');28driver.findElement(By.name('btnG')).click();29driver.wait(until.titleIs('webdriver - Google Search'), 1000

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var driver = wd.promiseChainRemote();3var caps = {4};5driver.init(caps)6 .then(function () {7 return driver.parseKey("name", "value");8 })9 .then(function (keycode) {10 console.log("Keycode: " + keycode);11 })12 .fin(function () {13 return driver.quit();14 })15 .done();

Full Screen

Using AI Code Generation

copy

Full Screen

1var xcu = require('appium-xcuitest-driver');2var key = xcu.parseKey('a');3console.log(key);4var xcu = require('appium-xcuitest-driver');5var key = xcu.parseKey('a');6console.log(key);7var xcu = require('appium-xcuitest-driver');8var key = xcu.parseKey('a');9console.log(key);10var xcu = require('appium-xcuitest-driver');11var key = xcu.parseKey('a');12console.log(key);13var xcu = require('appium-xcuitest-driver').driver;14var key = xcu.parseKey('a');15console.log(key);16var xcu = require('appium-xcuitest-driver');

Full Screen

Using AI Code Generation

copy

Full Screen

1let parseKey = require('appium-xcuitest-driver').parseKey;2let key = parseKey('a');3console.log(key);4let parseKey = require('appium-xcuitest-driver').parseKey;5let key = parseKey('a');6console.log(key);7let parseKey = require('appium-xcuitest-driver').parseKey;8let key = parseKey('a');9console.log(key);10let parseKey = require('appium-xcuitest-driver').parseKey;11let key = parseKey('a');12console.log(key);13let parseKey = require('appium-xcuitest-driver').parseKey;14let key = parseKey('a');15console.log(key);16let parseKey = require('appium-xcuitest-driver').parseKey;17let key = parseKey('a');18console.log(key);19let parseKey = require('appium-xcuitest-driver').parseKey;20let key = parseKey('a');21console.log(key);22let parseKey = require('appium-xcuitest-driver').parseKey;

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parseKey } = require('appium-xcuitest-driver/lib/commands/keys');2const key = parseKey('a', 'en-US');3console.log(key);4const { parseKey } = require('appium-xcuitest-driver/lib/commands/keys');5const key = parseKey('a', 'en-US');6console.log(key);7const { parseKey } = require('appium-xcuitest-driver/lib/commands/keys');8const key = parseKey('a', 'en-US');9console.log(key);10const { parseKey } = require('appium-xcuitest-driver/lib/commands/keys');11const key = parseKey('a', 'en-US');12console.log(key);13const { parseKey } = require('appium-xcuitest-driver/lib/commands/keys');14const key = parseKey('a', 'en-US');15console.log(key);16const { parseKey } = require('appium-xcuitest-driver/lib/commands/keys');17const key = parseKey('a', 'en-US');18console.log(key);19const { parseKey } = require('appium-xcuitest-driver/lib/commands/keys');20const key = parseKey('a', 'en-US');21console.log(key);22const { parseKey } = require('appium-xcuitest-driver/lib/commands/keys');23const key = parseKey('a', 'en-US');24console.log(key);25const { parseKey } = require('appium-xcuitest-driver/lib/commands/keys');26const key = parseKey('a', 'en-US');27console.log(key);28const { parseKey } = require('appium-xcuitest-driver/lib/commands/keys');

Full Screen

Using AI Code Generation

copy

Full Screen

1var xcuitestDriver = require('appium-xcuitest-driver');2var keyParser = new xcuitestDriver.helpers.KeyParser();3var key = keyParser.parseKey('a');4console.log(key);5var xcuitestDriver = require('appium-xcuitest-driver');6var keyParser = new xcuitestDriver.helpers.KeyParser();7var keys = keyParser.parseKeys('a');8console.log(keys);9var xcuitestDriver = require('appium-xcuitest-driver');10var keyParser = new xcuitestDriver.helpers.KeyParser();11var keys = keyParser.parseKeys('aA');12console.log(keys);13var xcuitestDriver = require('appium-xcuitest-driver');14var keyParser = new xcuitestDriver.helpers.KeyParser();15var keys = keyParser.parseKeys('aaA');16console.log(keys);17var xcuitestDriver = require('appium-xcuitest-driver');18var keyParser = new xcuitestDriver.helpers.KeyParser();19var keys = keyParser.parseKeys('ab');20console.log(keys);21var xcuitestDriver = require('

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 Appium Xcuitest Driver automation tests on LambdaTest cloud grid

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

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful