How to use itemDecode method in wpt

Best JavaScript code snippet using wpt

font_renderer.js

Source:font_renderer.js Github

copy

Full Screen

...100 return (data[offset] << 9) | (data[offset + 1] << 1);101 };102 }103 var glyphs = [];104 var startOffset = itemDecode(loca, 0);105 for (var j = itemSize; j < loca.length; j += itemSize) {106 var endOffset = itemDecode(loca, j);107 glyphs.push(glyf.subarray(startOffset, endOffset));108 startOffset = endOffset;109 }110 return glyphs;111 }112 function lookupCmap(ranges, unicode) {113 var code = unicode.charCodeAt(0);114 var l = 0, r = ranges.length - 1;115 while (l < r) {116 var c = (l + r + 1) >> 1;117 if (code < ranges[c].start) {118 r = c - 1;119 } else {120 l = c;...

Full Screen

Full Screen

loginServer.js

Source:loginServer.js Github

copy

Full Screen

1import storage from './storage';2import { Base64 } from 'js-base64';3const decodeToken = () =>{4 let deCodeArray = {};5 let token_json = storage.get("token_users");6 for(var i in token_json){7 let item = token_json[i].split(".")[1];8 let itemDecode = JSON.parse(Base64.decode(item));9 deCodeArray[itemDecode["userName"]] = itemDecode;10 };11 12 return deCodeArray;13}14const curName = () =>{15 let name = "";16 let curUserName = storage.get("cur_username");17 if(!!curUserName){18 name = decodeToken()[curUserName]["name"];19 return name;20 }21 22}23const curId = (type) =>{24 let curId = "";25 let token_json = decodeToken();26 let curUserName = storage.get("cur_username");27 if(type == "clazzId"){28 curId = decodeToken()[curUserName]["clazzId"];29 }else{30 curId = decodeToken()[curUserName]["sub"];31 }32 33 return curId;34}35const curUserId = () =>{36 let curUserId = "";37 let token_json = decodeToken();38 let curUserName = storage.get("cur_username");39 curUserId = decodeToken()[curUserName]["sub"];40 return curUserId;41}42const curTelId = (type) =>{43 let clazzId = "";44 let curUserName = "";45 let token_json = decodeToken();46 for(var i in token_json){47 curUserName = i;48 }49 if(type == "clazzId"){50 clazzId = decodeToken()[curUserName]["clazzId"];51 }else{52 clazzId = decodeToken()[curUserName]["sub"];53 }54 55 return clazzId;56}57const curTelUername = () =>{58 let curUserName = "";59 let token_json = decodeToken();60 for(var i in token_json){61 curUserName = i;62 }63 return curUserName;64}65const curGetToken = () =>{66 let curToken = '';67 let token_json = storage.get("token_users");68 let decodeToken_json = decodeToken();69 //获取当前的用户id70 let curName = storage.get("cur_username");71 72 let curUserId = decodeToken_json[curName]["sub"];73 curToken = token_json[curUserId];74 //当前账号75 // let item = curToken.split(".")[1];76 // let itemDecode = JSON.parse(Base64.decode(item));77 // console.log(itemDecode);78 return curToken;79}80const curLastToken = () =>{81 let lastToken = '';82 let token_json = storage.get("token_users");83 for(var i in token_json){84 lastToken = token_json[i];85 }86 //当前账号的token87 let item = lastToken.split(".")[1];88 let itemDecode = JSON.parse(Base64.decode(item));89 return lastToken;90}91const userIds = () =>{92 let userIds = "";93 let userArray = [];94 let token_json = decodeToken();95 for(var i in token_json){96 let users = token_json[i]["sub"]97 userArray.push(users); 98 }99 if(userArray.length > 0){100 userArray.forEach((user,index)=>{101 if(index == 0){102 userIds += "userIds=" + user;103 }else{104 userIds += "&userIds=" + user;105 }106 })107 }108 return userIds;109}110const onlyOneClass = () =>{111 let num = 0;112 let token_json = storage.get("token_users");113 for(var i in token_json){114 num++;115 }116 if(num == 1){117 return num = 1;118 }else if(num > 1){119 return num = 2;120 }else{121 return num;122 }123}124const userObj = {125 //解析账号token126 detoken:decodeToken,127 //账号 -- 获取当前姓名128 curname:curName,129 //账号 -- 获取当前id clazzId or userId130 curId:curId,131 //账号 -- 当前token132 curGetToken:curGetToken,133 //账号 -- 当前userId134 curUserId:curUserId,135 //手机号 -- 获取当前Id clazzId or userId136 curTelId:curTelId,137 //手机号 -- 存储当前账号138 curTelUername:curTelUername,139 //手机号 -- 存储用户最后一个token140 curLastToken:curLastToken,141 //获取所有的userIds142 userIds:userIds,143 //是否为1个班级144 onlyOneClass:onlyOneClass,145 146}...

Full Screen

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