Best JavaScript code snippet using wpt
TeacherPanel.ts
Source:TeacherPanel.ts
1import { BaseUI } from "../BaseUI";2import { UIManager } from "../../Manager/UIManager";3import SubmissionPanel from "./SubmissionPanel";4import { NetWork } from "../../Http/NetWork";5import { UIHelp } from "../../Utils/UIHelp";6import { ConstWord } from '../../Data/ConstWord';7import GamePanel from './GamePanel';8import { GameData } from '../../Data/GameData';9const { ccclass, property } = cc._decorator;10@ccclass11export default class TeacherPanel extends BaseUI {12 protected static className = "TeacherPanel";13 // onLoad () {}14 @property(cc.Node)15 private node_treeParent: cc.Node = null;16 @property(cc.Node)17 private node_fourParent: cc.Node = null;18 @property(cc.Node)19 private node_blockParent: cc.Node = null;20 @property(cc.Node)21 private node_typeParent: cc.Node = null;22 @property(cc.Prefab)23 private prefab_greenBlock: cc.Prefab = null;24 25 private List_treeData: Array<Array<cc.Node>> = null;26 private List_fourData: Array<Array<cc.Node>> = null;27 private v2_blockPos: Array<Array<cc.Vec2>> = null;28 private num_type: number = 3;29 30 private nowShowParent:cc.Node = null;31 start() {32 //this.getNet();33 this.List_treeData = new Array<Array<cc.Node>>(5);34 this.List_fourData = new Array<Array<cc.Node>>(5);35 this.init();36 this.AddListener();37 this.initPos();38 this.GetNetData();39 this.initParentPos(this.num_type);40 }41 init() {42 this.num_type = 3;43 this.node_treeParent.active = true;44 this.node_fourParent.active = false;45 }46 AddListener() {47 let treeCount = this.node_treeParent.childrenCount;48 for (let i = 0; i < treeCount; i++) {49 let editBox = this.node_treeParent.children[i];50 editBox.on("editing-did-ended", this.OnClickGetEditEndTree.bind(this, i));51 editBox.on("editing-return", this.OnClickGetEditEndTree.bind(this, i));52 }53 let foureCount = this.node_fourParent.childrenCount;54 for (let i = 0; i < foureCount; i++) {55 let editBox = this.node_fourParent.children[i];56 editBox.on("editing-did-ended", this.OnClickGetEditEndTree.bind(this, i));57 editBox.on("editing-return", this.OnClickGetEditEndTree.bind(this, i));58 }59 }60 initPos() {61 this.v2_blockPos = new Array<Array<cc.Vec2>>();62 for (let i = 0; i < 5; i++) {63 var PosX: Array<cc.Vec2> = new Array<cc.Vec2>();64 var StartPosX = -60 * i;65 var StartPosY = -35 * i;66 var x = 61;67 var y = -33;68 for (let j = 0; j < 5; j++) {69 PosX.push(cc.v2(StartPosX + (x * j), StartPosY + (y * j)));70 }71 this.v2_blockPos.push(PosX);72 }73 }74 initParentPos(type: number) {75 for (let index = 0; index < type; index++) {76 const posList = this.v2_blockPos[index];77 for (let i = 0; i < type; i++) {78 const pos = posList[i];79 let obj = this.node_blockParent.children[index * type + i];80 obj.setPosition(pos);81 }82 }83 }84 NodeClear(type: number) {85 for (let index = 0; index < type; index++) {86 for (let i = 0; i < type; i++) {87 let obj = this.node_blockParent.children[index * type + i];88 for (let j = 0; j < obj.childrenCount; j++) {89 obj.children[j].active = false;90 }91 }92 }93 }94 GetNetData(){95 try{96 NetWork.getInstance().httpRequest(NetWork.GET_TITLE + "?title_id=" + NetWork.title_id, "GET", "application/json;charset=utf-8", function (err, response) {97 if(Array.isArray( response.data)){98 99 }else{100 NetWork.courseware_id = response.data.courseware_id;101 if (NetWork.empty) {//å¦æURLéé¢å¸¦äºemptyåæ° å¹¶ä¸ä¸ºtrue å°±ç«å»æ¸
é¤æ°æ®102 this.ClearNet();103 return;104 }105 let courseware_content = JSON.parse(response.data.courseware_content);106 107 108 this.LoadData(courseware_content.type,courseware_content.topic);109 }110 111 }.bind(this));112 }catch(e){113 console.error(e.message);114 }115 116 }117 //å è½½æå¡å¨æ°æ®æ°æ®118 LoadData(type: number, data: Array<string>) {119 this.num_type = type;120 this.SetToggleTypeStr(type);121 this.loadEditData(data);122 this.LoadSHowAllBlock(data);123 }124 loadEditData(arrStr:Array<string>){125 let treeCount = this.nowShowParent.childrenCount;126 for (let i = 0; i < treeCount; i++) {127 let editBox = this.nowShowParent.children[i].getComponent(cc.EditBox);128 if(arrStr.length> i){129 editBox.string = arrStr[i];130 }131 }132 }133 LoadSHowAllBlock(arrStr:Array<string>) {134 let count = arrStr.length;135 for (let index = 0; index < count; index++) {136 let hength = parseInt(arrStr[index]);137 this.LoadSHowBlock(index,hength);138 }139 }140 LoadSHowBlock(CustmeEventData,blockCount:number){141 if (this.List_treeData[CustmeEventData] == null) {142 let blocklist = new Array<cc.Node>();143 this.List_treeData[CustmeEventData] = blocklist;144 }145 let startPos = this.GetPos(CustmeEventData, this.num_type);146 let data = this.List_treeData[CustmeEventData];147 let count = data.length;148 for (let index = 0; index < count; index++) {149 const element = data[index];150 if (element != null) {151 element.active = false;152 }153 }154 let offes = 70;155 for (let index = 0; index < blockCount; index++) {156 if (index < count) {157 data[index].setPosition(0, offes * index);158 data[index].active = true;159 } else {160 let obj = cc.instantiate(this.prefab_greenBlock);161 obj.setParent(this.node_blockParent.children[CustmeEventData]);162 obj.setPosition(0, offes * index);163 this.List_treeData[CustmeEventData].push(obj);164 obj.active = true;165 }166 }167 }168 setPanel() {//设置æå¸ç«¯çé¢169 }170 //ä¸ä¼ 课件æé®171 onBtnSaveClicked() {172 UIManager.getInstance().showUI(SubmissionPanel);173 }174 getNet() {175 NetWork.getInstance().httpRequest(NetWork.GET_TITLE + "?title_id=" + NetWork.title_id, "GET", "application/json;charset=utf-8", function (err, response) {176 console.log("æ¶æ¯è¿å" + response);177 if (!err) {178 let res = response;179 if (Array.isArray(res.data)) {180 this.setPanel();181 return;182 }183 let content = JSON.parse(res.data.courseware_content);184 NetWork.courseware_id = res.data.courseware_id;185 if (NetWork.empty) {//å¦æURLéé¢å¸¦äºemptyåæ° å¹¶ä¸ä¸ºtrue å°±ç«å»æ¸
é¤æ°æ®186 this.ClearNet();187 } else {188 if (content != null) {189 this.setPanel();190 } else {191 this.setPanel();192 }193 }194 }195 }.bind(this), null);196 }197 //å é¤è¯¾ä»¶æ°æ® ä¸è¬ä¸ºèæ°æ®æ¸
ç198 ClearNet() {199 let jsonData = { courseware_id: NetWork.courseware_id };200 NetWork.getInstance().httpRequest(NetWork.CLEAR, "POST", "application/json;charset=utf-8", function (err, response) {201 if (!err) {202 UIHelp.showTip("çæ¡å é¤æå");203 }204 }.bind(this), JSON.stringify(jsonData));205 }206 OnClickGetEditEndTree(CustmeEventData, editBox) {207 console.log("CustmeEventData:" + CustmeEventData);208 console.log("editBox:" + editBox.string);209 let creatorLength = this.examineValue(editBox.string);210 if (creatorLength == 0) {211 editBox.string = "";212 } else {213 editBox.string = creatorLength.toString();214 }215 if (this.List_treeData[CustmeEventData] == null) {216 let blocklist = new Array<cc.Node>();217 this.List_treeData[CustmeEventData] = blocklist;218 }219 let startPos = this.GetPos(CustmeEventData, this.num_type);220 let data = this.List_treeData[CustmeEventData];221 let count = data.length;222 for (let index = 0; index < count; index++) {223 const element = data[index];224 if (element != null) {225 element.active = false;226 }227 }228 let offes = 70;229 for (let index = 0; index < creatorLength; index++) {230 if (index < count) {231 data[index].setPosition(0, offes * index);232 data[index].active = true;233 //data[index].setSiblingIndex(CustmeEventData*10 +index);234 } else {235 let obj = cc.instantiate(this.prefab_greenBlock);236 obj.setParent(this.node_blockParent.children[CustmeEventData]);237 obj.setPosition(0, offes * index);238 this.List_treeData[CustmeEventData].push(obj);239 obj.active = true;240 }241 }242 }243 OnClickGetEditEndFour(event: cc.EditBox, CustmeEventData) {244 }245 //æ£æ¥246 examineValue(value) {247 if (value == "") return 0;248 if (isNaN(value)) return 0;249 if (this.num_type < parseInt(value)) { return this.num_type }250 else return parseInt(value);251 }252 //253 SetToggleType(event: any) {254 this.NodeClear(this.num_type);255 var name = event.node.name;256 let parent = null;257 switch (name) {258 case "1":259 this.num_type = 3;260 this.node_treeParent.active = true;261 this.node_fourParent.active = false;262 parent = this.node_treeParent;263 break;264 case "2":265 this.num_type = 4;266 this.node_treeParent.active = false;267 this.node_fourParent.active = true;268 parent = this.node_fourParent;269 break;270 default:271 break;272 }273 this.initParentPos(this.num_type);274 this.ChengTypeLoadBlock(parent);275 }276 SetToggleTypeStr(type:number){277 let parent = null;278 let name = "";279 if(type == 3){280 this.node_typeParent.children[0].getComponent(cc.Toggle).isChecked = true;281 name = "1";282 }else if( type ==4){283 name ="2";284 this.node_typeParent.children[1].getComponent(cc.Toggle).isChecked = true;285 }286 switch (name) {287 288 case "1":289 this.num_type = 3;290 this.node_treeParent.active = true;291 this.node_fourParent.active = false;292 this.nowShowParent = this.node_treeParent;293 break;294 case "2":295 this.num_type = 4;296 this.node_treeParent.active = false;297 this.node_fourParent.active = true;298 this.nowShowParent = this.node_fourParent;299 break;300 default:301 break;302 }303 }304 //305 ChengTypeLoadBlock(nodeParent: cc.Node) {306 let count = nodeParent.childrenCount;307 for (let index = 0; index < count; index++) {308 const element = nodeParent.children[index];309 let editBox = element.getComponent(cc.EditBox);310 this.OnClickGetEditEndTree(index, editBox);311 }312 }313 /* è·åèµ·å§åæ ç¹ */314 GetPos(index: number, type: number) {315 let numX = index % type;316 let numY = parseInt((index / type).toString());317 return this.v2_blockPos[numY][numX];318 }319 OnClickDetection() {320 //321 let parent: cc.Node = null;322 if (this.num_type == 3) {323 parent = this.node_treeParent;324 } else {325 parent = this.node_fourParent;326 }327 let result = 0;328 //é«329 for (let index = 0; index < parent.childrenCount; index++) {330 const editBox = parent.children[index].getComponent(cc.EditBox);331 if (parseInt(editBox.string) == this.num_type) {332 result = 1;333 break;334 }335 }336 if (result == 0) {337 UIHelp.showTip(ConstWord._001);338 return;339 }340 result = 0;341 //é¿342 for (let index = 0; index < this.num_type; index++) {343 let have = true;344 for (let i = 0; i < this.num_type; i++) {345 const editBox = parent.children[index * this.num_type + i].getComponent(cc.EditBox);346 if (editBox.string == "") {347 have = false;348 break;349 }350 }351 if (have) {352 result = 1;353 break;354 }355 }356 if (result == 0) {357 UIHelp.showTip(ConstWord._001);358 return;359 }360 result = 0;361 //é¿362 for (let index = 0; index < this.num_type; index++) {363 let have = true;364 for (let i = 0; i < this.num_type; i++) {365 const editBox = parent.children[i * this.num_type + index].getComponent(cc.EditBox);366 if (editBox.string == "") {367 have = false;368 break;369 }370 }371 if (have) {372 result = 1;373 break;374 }375 }376 if (result == 0) {377 UIHelp.showTip(ConstWord._001);378 return;379 }380 let SaveData = new Array<string>();381 for (let index = 0; index < parent.childrenCount; index++) {382 const editBox = parent.children[index].getComponent(cc.EditBox);383 SaveData.push(editBox.string);384 }385 GameData.getInstance().topic = SaveData;386 GameData.getInstance().type = this.num_type;387 UIManager.getInstance().showUI(GamePanel);388 }389 ...
analysisParams.js
Source:analysisParams.js
1'use strict';2module.exports = {3 tabList: {4 title: 'ä»è´¹æ
åµ',5 subList: [6 {7 title: 'å
å¼æ¶å
¥',8 key: 'count',9 data: [10 {11 'meta_id': '2819',12 'name': 'å
å¼æ¶å
¥ ',13 'self_weidu': 'ALL'14 }15 ]16 },17 {18 title: 'ä»è´¹è§è²',19 key: 'cash',20 data: [21 {22 'meta_id': '2818',23 'name': 'ä»è´¹è§è² '24 },25 {26 'meta_id': '2914',27 'name': 'é¦æ¬¡ä»è´¹è§è²æ° '28 }29 ]30 },31 {32 title: 'ä»è´¹ç',33 key: 'cash_percent',34 role: 'true',35 data: [36 {37 'meta_id': '2874',38 'name': 'è§è²ä»è´¹ç ',39 'num_type': 'percent'40 },41 {42 'meta_id': '2816',43 'name': 'ç»å½è§è²'44 },45 ]46 },47 {48 title: 'ARRPU',49 key: 'arrpu',50 role: 'true',51 data: [52 {53 'meta_id': '2816',54 'name': 'è§è²ARPU',55 'num_type': 'fixed_2'56 },57 {58 'meta_id': '2875',59 'name': 'è§è²ARPPU',60 'num_type': 'fixed_2'61 },62 ]63 },64 {65 title: 'VIPç级åå¸',66 key: 'vip',67 dimensionName: 'VIPç级',68 data: [69 {70 'meta_id': '2916',71 'name': 'æ¶å
¥'72 },73 {74 'meta_id': '2917',75 'name': 'VIP人æ°'76 },77 ]78 },79 {80 title: 'å
å¼é¢åº¦åå¸',81 key: 'cash_limit',82 dimensionName: 'å
å¼é¡¹ç®',83 data: [84 {85 'meta_id': '2918',86 'name': 'ç°é'87 },88 {89 'meta_id': '2919',90 'name': 'è§è²æ°'91 },92 {93 'meta_id': '2920',94 'name': 'å
å®'95 },96 {97 'meta_id': '2921',98 'name': 'å
å¼æ¬¡æ°'99 },100 ]101 },102 {103 title: 'åä½æ¶é´ä»·æ ¼',104 key: 'price_date',105 data: [106 {107 'meta_id': '2922',108 'name': 'åä½æ¶é´ï¼ä»·æ ¼/å°æ¶ï¼',109 'num_type': 'fixed_2'110 },111 {112 'meta_id': '2923',113 'name': '7æ¥å¹³å',114 'num_type': 'fixed_2'115 },116 {117 'meta_id': '2924',118 'name': '30æ¥å¹³å',119 'num_type': 'fixed_2'120 },121 ]122 }123 ]124 },125 playUser: {126 title: 'ç©å®¶åæ',127 subList: [128 // {129 // title: 'åæå¡å¨ç©å®¶åå¸',130 // key: 'play_map',131 // dimensionName: 'æå¡å¨',132 // stockItem: ['ç»å½è§è²æ°', 'æ°å¢è§è²æ°'],133 // data: [134 // {135 // 'meta_id': '2925',136 // 'name': 'æ°å¢è§è²æ°'137 // },138 // {139 // 'meta_id': '2926',140 // 'name': 'ç»å½è§è²æ°'141 // }142 // ]143 // },144 {145 title: 'å¹³åå¯å¨æ¬¡æ°',146 key: 'start_num',147 lineItem: ['å¹³åå¯å¨æ¬¡æ°'],148 stockItem: ['å¹³åå¯å¨æ¬¡æ°'],149 chartShow: 'single',150 data: [151 {152 'meta_id': '2927',153 'name': 'å¹³åå¯å¨æ¬¡æ°',154 'num_type': 'fixed_2'155 }156 ]157 },158 {159 title: 'ç级åå¸',160 key: 'level',161 dimensionName: 'ç级',162 lineItem: ['ç级åå¸'],163 stockItem: ['ç级åå¸'],164 chartShow: 'single',165 data: [166 {167 'meta_id': '2928',168 'name': 'ç级åå¸',169 }170 ]171 }172 ]173 },174 channelAnalysis: {175 title: 'æ¸ éåæ',176 role: true,177 subList: [178 {179 title: 'ç»å½',180 key: 'play_login',181 dimensionName: 'æ¸ é',182 showRange: ['ç»å½', 'æ°å¢'],183 stockItem: ['ç»å½', 'æ°å¢'],184 data: [185 {186 'meta_id': '2929',187 'name': 'ç»å½è§è²'188 },189 {190 'meta_id': '2930',191 'name': 'æ°å¢è§è²æ°'192 },193 {194 'meta_id': '2931',195 'name': 'ä»è´¹ç',196 'num_type': 'percent'197 },198 {199 'meta_id': '2932',200 'name': 'æ¸ éå
å¼å æ¯',201 'num_type': 'percent'202 },203 {204 'meta_id': '2933',205 'name': 'å
å¼æ»éé¢'206 },207 {208 'meta_id': '2934',209 'name': 'ARPU',210 'num_type': 'fix_2'211 },212 {213 'meta_id': '2935',214 'name': 'ARPPU',215 'num_type': 'fix_2'216 },217 {218 'meta_id': '2930',219 'name': 'æ°å¢è§è²æ°'220 },221 {222 'meta_id': '2936',223 'name': '次æ¥çå',224 'num_type': 'percent'225 },226 {227 'meta_id': '2937',228 'name': '第3æ¥çå',229 'num_type': 'percent'230 },231 {232 'meta_id': '2938',233 'name': '第7æ¥çå',234 'num_type': 'percent'235 }236 ]237 },238 {239 title: 'ä»è´¹',240 key: 'play_cash',241 dimensionName: 'æ¸ é',242 stockItem: ['å
å¼æ»éé¢'],243 lineItem: ['ä»è´¹ç', 'æ¸ éå
å¼å æ¯'],244 percent: true,245 data: [246 {247 'meta_id': '2929',248 'name': 'ç»å½è§è²'249 },250 {251 'meta_id': '2930',252 'name': 'æ°å¢è§è²æ°'253 },254 {255 'meta_id': '2931',256 'name': 'ä»è´¹ç',257 'num_type': 'percent'258 },259 {260 'meta_id': '2932',261 'name': 'æ¸ éå
å¼å æ¯',262 'num_type': 'percent'263 },264 {265 'meta_id': '2933',266 'name': 'å
å¼æ»éé¢'267 },268 {269 'meta_id': '2934',270 'name': 'ARPU',271 'num_type': 'fix_2'272 },273 {274 'meta_id': '2935',275 'name': 'ARPPU',276 'num_type': 'fix_2'277 },278 {279 'meta_id': '2930',280 'name': 'æ°å¢è§è²æ°'281 },282 {283 'meta_id': '2936',284 'name': '次æ¥çå',285 'num_type': 'percent'286 },287 {288 'meta_id': '2937',289 'name': '第3æ¥çå',290 'num_type': 'percent'291 },292 {293 'meta_id': '2938',294 'name': '第7æ¥çå',295 'num_type': 'percent'296 }297 ]298 },299 {300 title: 'ARPU',301 key: 'play_arpu',302 dimensionName: 'æ¸ é',303 stockItem: ['ARPU', 'ARPPU'],304 data: [305 {306 'meta_id': '2929',307 'name': 'ç»å½è§è²'308 },309 {310 'meta_id': '2930',311 'name': 'æ°å¢è§è²æ°'312 },313 {314 'meta_id': '2931',315 'name': 'ä»è´¹ç',316 'num_type': 'percent'317 },318 {319 'meta_id': '2932',320 'name': 'æ¸ éå
å¼å æ¯',321 'num_type': 'percent'322 },323 {324 'meta_id': '2933',325 'name': 'å
å¼æ»éé¢'326 },327 {328 'meta_id': '2934',329 'name': 'ARPU',330 'num_type': 'fix_2'331 },332 {333 'meta_id': '2935',334 'name': 'ARPPU',335 'num_type': 'fix_2'336 },337 {338 'meta_id': '2930',339 'name': 'æ°å¢è§è²æ°'340 },341 {342 'meta_id': '2936',343 'name': '次æ¥çå',344 'num_type': 'percent'345 },346 {347 'meta_id': '2937',348 'name': '第3æ¥çå',349 'num_type': 'percent'350 },351 {352 'meta_id': '2938',353 'name': '第7æ¥çå',354 'num_type': 'percent'355 }356 ]357 },358 {359 title: 'çå',360 key: 'play_save',361 dimensionName: 'æ¸ é',362 stockItem: ['æ°å¢'],363 lineItem: ['次æ¥çå', '第3æ¥çå', '第7æ¥çå'],364 chartShow:'line',365 percent: true,366 data: [367 {368 'meta_id': '2929',369 'name': 'ç»å½è§è²'370 },371 {372 'meta_id': '2930',373 'name': 'æ°å¢è§è²æ°'374 },375 {376 'meta_id': '2931',377 'name': 'ä»è´¹ç',378 'num_type': 'percent'379 },380 {381 'meta_id': '2932',382 'name': 'æ¸ éå
å¼å æ¯',383 'num_type': 'percent'384 },385 {386 'meta_id': '2933',387 'name': 'å
å¼æ»éé¢'388 },389 {390 'meta_id': '2934',391 'name': 'ARPU',392 'num_type': 'fix_2'393 },394 {395 'meta_id': '2935',396 'name': 'ARPPU',397 'num_type': 'fix_2'398 },399 {400 'meta_id': '2930',401 'name': 'æ°å¢è§è²æ°'402 },403 {404 'meta_id': '2936',405 'name': '次æ¥çå',406 'num_type': 'percent'407 },408 {409 'meta_id': '2937',410 'name': '第3æ¥çå',411 'num_type': 'percent'412 },413 {414 'meta_id': '2938',415 'name': '第7æ¥çå',416 'num_type': 'percent'417 }418 ]419 }420 ]421 },422 economy: {423 title: 'ç»æµæ
åµ',424 subList: [425 {426 title: 'å
å®åæ¶äº§åºæ¯',427 key: 'gold_back',428 stockItem: ['å
å®åæ¶é', 'å
å®äº§åºé'],429 lineItem: ['å
å®åæ¶äº§åºæ¯'],430 data: [431 {432 'meta_id': '2939',433 'name': 'å
å®åæ¶é',434 },435 {436 'meta_id': '2940',437 'name': 'å
å®äº§åºé',438 },439 {440 'meta_id': '2941',441 'num_type':'fixed_2',442 'name': 'å
å®åæ¶äº§åºæ¯',443 }444 ]445 },446 {447 title: 'å
å®äº§åºéå¾',448 key: 'gold_product',449 dimensionName: 'éå¾',450 stockItem: ['产åºå
å®æ°é'],451 lineItem: ['产åºå
å®è§è²æ°', '产åºå
å®æ¬¡æ°'],452 chartShow:'line',453 data: [454 {455 'meta_id': '2942',456 'name': '产åºå
å®æ°é',457 },458 {459 'meta_id': '2943',460 'name': '产åºå
å®æ¬¡æ°',461 },462 {463 'meta_id': '2944',464 'name': '产åºå
å®è§è²æ°',465 }466 ]467 },468 {469 title: 'å
å®åæ¶éå¾',470 key: 'gold_back_approach',471 dimensionName: 'éå¾',472 stockItem: ['åæ¶å
å®æ°é'],473 lineItem: ['åæ¶å
å®æ¬¡æ°', 'åæ¶å
å®è§è²æ°'],474 chartShow:'line',475 data: [476 {477 'meta_id': '2945',478 'name': 'åæ¶å
å®æ°é',479 },480 {481 'meta_id': '2946',482 'name': 'åæ¶å
å®æ¬¡æ°',483 },484 {485 'meta_id': '2947',486 'name': 'åæ¶å
å®è§è²æ°',487 }488 ]489 }490 ]491 }...
spiralContainer.js
Source:spiralContainer.js
1/**2 * Container class for the different layers in the canvas representing different3 * types of numbers to show on the screen.4 */5import Integer from "./integer.js";6import {NUM_TYPE} from "./integer.js";78// color hex value based off the IBM color blind safe palette9const color_tints = {10 'prime': 0xffffff,11 'composite': 0x785ef0,12 'square': 0xdc267f,13 'triangular': 0xffb000,14 'fibonacci': 0x648fff,15 'centerTriangular': 0xffffff,16 'pentagonal': 0xffffff,17 'centerSquare': 0xffffff,18 'twinPrime': 0x20aeff19}2021class SpiralContainer {2223 constructor(texture) {24 this.collection = new PIXI.Container();25 this.containers = {};26 this.texture = texture;2728 for (const prop in NUM_TYPE) {29 this.containers[NUM_TYPE[prop]] = new PIXI.Container();30 this.containers[NUM_TYPE[prop]].visible = false;3132 // color tint containers33 let color_tint = new PIXI.filters.ColorMatrixFilter();34 color_tint.tint(color_tints[NUM_TYPE[prop]]);35 this.containers[NUM_TYPE[prop]].filters = [color_tint];36 37 this.collection.addChild(this.containers[NUM_TYPE[prop]]);38 }3940 // toggle primes spiral container to show41 this.containers[NUM_TYPE.PRIME].visible = true;42 }434445 // toggle type visibility46 toggleType(name) {47 this.containers[name].visible 48 = !this.containers[name].visible;49 this.containers[name].updateTransform();50 }515253 // add num from integer obj to correct containers54 addNumber(int) {55 // loop over flags in int56 for (const [key, value] of Object.entries(int.type)) {57 if (value) {58 this.addCircle(key, int);59 }60 }6162 }636465 // add a circle to indicated container66 addCircle(type, int) {67 let circle = new PIXI.Sprite(this.texture);68 circle.name = int.num;69 circle.x = int.x;70 circle.y = int.y;71 circle.interactive = true;72 circle.on('pointerover', SpiralContainer.hover);73 circle.on('tap', SpiralContainer.hover);7475 if (type == NUM_TYPE.COMPOSITE) {76 circle.height = 1 + int.nfactors * 2;77 circle.width = 1 + int.nfactors * 2;78 }7980 this.containers[type].addChild(circle);81 }828384 // pointer hover event for spites85 static hover() {86 $('#current-value').html('Current: ' + this.name);87 }8889}90
...
Using AI Code Generation
1var wpt = require('wpt');2var num_type = wpt.num_type;3console.log(num_type(123));4console.log(num_type(12.3));5console.log(num_type("123"));6console.log(num_type("12.3"));7console.log(num_type(123.45));8console.log(num_type(123.45, 2));9console.log(num_type(123.45, 1));10console.log(num_type(123.45, 0));11console.log(num_type(123.45, 3));12console.log(num_type(123.45, -1));
Using AI Code Generation
1var wpt = require('wpt');2wpt.num_type(6, function(err, data) {3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9### 3.1.3. `num_type()` method
Using AI Code Generation
1var wpt = require('wpt');2var num = 123.456;3console.log(wpt.num_type(num));4var wpt = require('wpt');5var num = 123.456;6console.log(wpt.num_type(num));7var wpt = require('wpt');8var num = 123.456;9console.log(wpt.num_type(num));10var wpt = require('wpt');11var num = 123.456;12console.log(wpt.num_type(num));13var wpt = require('wpt');14var num = 123.456;15console.log(wpt.num_type(num));16var wpt = require('wpt');17var num = 123.456;18console.log(wpt.num_type(num));19var wpt = require('wpt');20var num = 123.456;21console.log(wpt.num_type(num));22var wpt = require('wpt');23var num = 123.456;24console.log(wpt.num_type(num));25var wpt = require('wpt');26var num = 123.456;27console.log(wpt.num_type(num));
Using AI Code Generation
1var wpt = require('wpt');2module.exports = function() {3 wpt.num_type(1, function(err, data) {4 if (!err) {5 console.log(data);6 } else {7 console.log(err);8 }9 });10};11### num_type(number, callback)12MIT © [Shubham Singh](
Using AI Code Generation
1var num = wpt.num_type(123);2console.log(num);3### `wpt.num_type()` method4wpt.num_type(number);5var num = wpt.num_type(123);6console.log(num);7### `wpt.obj_type()` method8wpt.obj_type(object);9var obj = wpt.obj_type({name: "John", age: 30, city: "New York"});10console.log(obj);11### `wpt.str_type()` method12wpt.str_type(string);13var str = wpt.str_type("Hello World!");14console.log(str);15### `wpt.undef_type()` method
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!