How to use response2 method in wpt

Best JavaScript code snippet using wpt

index.js

Source:index.js Github

copy

Full Screen

1var driveId = document.getElementById('d');2var skillId = document.getElementById('s');3var growthId = document.getElementById('g');4var summaryId = document.getElementById('s1');56const form = document.querySelector('.form-input');78 var response1 = Number(document.getElementById("question1").value);9 // var response1 = document.getElementById("question1").value;10 var response2 = Number(document.getElementById("question2").value);11 var response3 = Number(document.getElementById("question3").value);1213 var x1 = response1*10;14 var y1 = response2*10;1516171819var output = document.getElementById('output');20var box = document.querySelector('.box');21var input1 = document.getElementById('input1');2223output.style.visibility = "hidden";24box.style.visibility = "hidden";25input1.style.visibility = "visible";2627var c = document.getElementById("myCanvas");28var ctx = c.getContext("2d");29ctx.beginPath();30ctx.rect(20, -90, 5, 5);31ctx.stroke();32ctx.fillStyle = "blue";33ctx.fill();3435function myFunction(){36 var response1 = Number(document.getElementById("question1").value);37 var response2 = Number(document.getElementById("question2").value);38 var response3 = Number(document.getElementById("question3").value);39 var text = document.querySelector('.invalid');40 var ques1 = document.querySelector('.ques1');41 var ques2 = document.querySelector('.ques2');42 var ques3 = document.querySelector('.ques3');43 /*if(response1==0 && response1!='null'){44 ques1.style.border = "2px solid red";45 text.style.display = "block";46 47 }else{48 ques1.style.border = "0px solid black";49 text.style.display = "none";50 }5152 if(response2==0){53 ques2.style.border = "2px solid red";54 text.style.display = "block";55 56 }else{57 ques2.style.border = "0px solid black";58 text.style.display = "none";59 }6061 if(response3==0){62 ques3.style.border = "2px solid red";63 text.style.display = "block";64 65 }else{66 ques3.style.border = "0px solid black";67 text.style.display = "none";68 }*/6970 if(response1>10 || response1<0){71 alert("Please Enter Numbers from 1 to 10");72 }else{7374 }7576 if(response2>10 || response2<0){77 alert("Please Enter Numbers from 1 to 10");78 }else{7980 }8182 if(response3>10 || response3<0){83 alert("Please Enter Numbers from 1 to 10");84 }else{8586 }8788 89}90function draw(){91 const triangle = document.querySelector('.triangle');92 const dot = document.querySelector('.dot');93 const dot1 = document.querySelector('.dot1');94 const dot2 = document.querySelector('.dot2');95 const dot3 = document.querySelector('.dot3');96 const dot4 = document.querySelector('.dot4');97 const dot5 = document.querySelector('.dot5');98 const dot6 = document.querySelector('.dot6');99 const dot7 = document.querySelector('.dot7');100 const dot8 = document.querySelector('.dot8');101 const dot9 = document.querySelector('.dot9');102 const dot10= document.querySelector('.dot10');103 const dot11= document.querySelector('.dot11');104 const dot12= document.querySelector('.dot12');105 const dot13= document.querySelector('.dot13');106 const side7 = document.querySelector('.side7');107 const side8 = document.querySelector('.side8');108 const side9 = document.querySelector('.side9');109 const side4 = document.querySelector('.side4');110 const side5 = document.querySelector('.side5');111 const side6 = document.querySelector('.side6');112 var response1 = Number(document.getElementById("question1").value);113 var response2 = Number(document.getElementById("question2").value);114 var response3 = Number(document.getElementById("question3").value);115116117 const num1 = response1*10;118 const num2 = response2*10;119 const num3 = response3*10;120121 triangle.style.borderBottom = num1 + "px solid #206a5d";122 triangle.style.borderLeft = num3+ "px solid transparent";123 triangle.style.borderRight = num2 + "px solid transparent";124125 side7.textContent = response1;126 side8.textContent = response2;127 side9.textContent = response3;128129 side4.textContent = response1;130 side5.textContent = response2;131 side6.textContent = response3;132133 /* if(response1<5 && response2<5){134 side5.style.top= "35px";135 side5.style.left= "50px";136 side6.style.top= "35px";137 side6.style.right= "50px";138 }if(response1>=5 && response2>=5){139 side5.style.top= "50px";140 side5.style.left= "60px";141 side6.style.top= "50px";142 side6.style.right= "60px";143 }if((response1==1||response1==2)&&(response2 == 1 || response2 == 2 || response2 ==3)&&(response3 == 1 || response3 == 2 || response3 ==3))144 {145 side5.style.top= "20px";146 side5.style.left= "40px";147 side6.style.top= "20px";148 side6.style.right= "40px";149 }if((response1==5 || response1==6) && (response2==7 || response2==8 || response2==9)150 && (response3==7 || response3==8 || response3==9)){151 152 side5.style.top= "50px";153 side5.style.left= "70px";154 side6.style.top= "50px";155 side6.style.right= "90px";156157 }*/158159 160161 if(response1>5 && response2<5){162 dot.style.display = "block";163 }else if(response1<5 && response2<5){164 dot1.style.display = "block";165 }else if(response1<5 && (response2>5 && response2<10)){166 dot3.style.display = "block";167 }else if((response1>5 && response1<10) && response2 === 5){168 dot4.style.display = "block";169 }else if(response1==5 && response2==5){170 dot5.style.display = "block";171 }else if(response1==5 && response2==10){172 dot6.style.display = "block";173 }else if(response1==10 && response2==10){174 dot7.style.display = "block";175 }else if(response1<=5 && response2<5){176 dot8.style.display = "block";177 }else if(response1<5 && response2==5){178 dot9.style.display="block";179 }else if(response1==5 && response2>5){180 dot10.style.display="block";181 }else if(response1>5 && response2==10){182 dot11.style.display = "block";183 }else if(response1<5 && response2==10){184 dot12.style.display = "block";185 }else if(response1==10 && response2==5){186 dot13.style.display = "block";187 }188 else{189 dot2.style.display = "block";190 }191 if(response1==10 && response2==10 && response3==10){192 triangle.style.right = "149px";193 } else if(response1==1 && response2==2 && response3==10){194 triangle.style.top= "-135px";195 triangle.style.right = "185px";196 }else if(response1==5 && response2==4 && response3==10){197 triangle.style.top= "-160px";198 triangle.style.right = "185px";199 }else if(response1==6 && response2==5 && response3==10){200 triangle.style.top= "-170px";201 triangle.style.right = "175px";202 }else if(response1==7 && response2==6 && response3==10){203 triangle.style.top= "-183px";204 triangle.style.right = "175px";205 }else if(response1==8 && response2==7 && response3==10){206 triangle.style.top= "-190px";207 triangle.style.right = "168px";208 }else if(response1==9 && response2==8 && response3==10){209 triangle.style.top= "-200px";210 triangle.style.right = "158px";211 }else if(response1==10 && response2==9 && response3==10){212 triangle.style.top= "-210px";213 triangle.style.right = "150px";214 }else if(response1==4 && response2==2 && response3==9){215 triangle.style.top= "-158px";216 triangle.style.right = "185px";217 triangle.style.transform="rotate(-5deg)";218 }else if(response1==4 && response2==1 && response3==9){219 triangle.style.top= "-158px";220 triangle.style.right = "185px";221 triangle.style.transform="rotate(-5deg)";222 }else if(response1==4 && response2==3 && response3==9){223 triangle.style.top= "-158px";224 triangle.style.right = "185px";225 triangle.style.transform="rotate(-5deg)";226 }else if(response1==4 && response2==4 && response3==9){227 triangle.style.top= "-158px";228 triangle.style.right = "180px";229 triangle.style.transform="rotate(-5deg)";230 }else if(response1==4 && response2==6 && response3==9){231 triangle.style.top= "-158px";232 triangle.style.right = "165px";233 triangle.style.transform="rotate(-5deg)";234 }else if(response1==4 && response2==7 && response3==9){235 triangle.style.top= "-158px";236 triangle.style.right = "158px";237 triangle.style.transform="rotate(-3deg)";238 }239 else if(response1==4 && response2==5 && response3==10){240 triangle.style.top= "-155px";241 triangle.style.right = "175px";242 }else if(response1==5 && response2==6 && response3==10){243 triangle.style.top= "-165px";244 triangle.style.right = "170px";245 }else if(response1==6 && response2==7 && response3==10){246 triangle.style.top= "-170px";247 triangle.style.right = "170px";248 }else if(response1==2 && response2==1 && response3==10){249 triangle.style.top= "-150px";250 triangle.style.right = "180px";251 }252 else if(response1<5 && response2<5 && response3>5){253 triangle.style.top = "-150px";254 triangle.style.right = "173px";255 }else if((response1==9 || response1==10) && response2<5 && response3<5){256 triangle.style.top = "-210px";257 }else if(response1==9 && response2==8 && response3==1){258 triangle.style.top = "-203px";259 triangle.style.right = "115px";260 }else if(response1==10 && response2==9 && response3==1){261 triangle.style.top = "-210px";262 triangle.style.right = "108px";263 }else if(response1==1 && response2==5 && response3==6){264 triangle.style.top= "-160px";265 }else if(response1==1 && response2==9 && response3==10){266 triangle.style.top= "-130px";267 }else if(response1==1 && response2==8 && response3==9){268 triangle.style.top= "-140px";269 }else if(response1==8 && response2==1 && response3==9){270 triangle.style.top= "-200px";271 triangle.style.right = "184px";272 }else if(response1==9 && response2==1 && response3==10){273 triangle.style.top= "-205px";274 triangle.style.right = "190px";275 }else if(response1==2 && response2==8 && response3==9){276 triangle.style.top= "-145px";277 }else if(response1==2 && response2==9 && response3==10){278 triangle.style.top= "-140px";279 }else if(response1==2 && response2==10 && response3==9){280 triangle.style.top= "-140px";281 }else if(response1==3 && response2==5 && response3==6){282 triangle.style.top= "-160px";283 }else if(response1==3 && response2==5 && response3>7){284 triangle.style.top= "-160px";285 }else if(response1==5 && response2==6 && response3==5){286 triangle.style.top= "-170px";287 }else if(response1==6 && response2==6 && response3==5){288 triangle.style.top= "-170px";289 }else if(response1==6 && response2==9 && response3==10){290 triangle.style.top= "-170px";291 }else if(response1==6 && response2==10 && response3==9){292 triangle.style.top= "-170px";293 }else if(response1==7 && response2==6 && response3==5){294 triangle.style.top= "-190px";295 triangle.style.right = "140px";296 }else if(response1==7 && response2==10 && response3==9){297 triangle.style.top= "-180px";298 }else if(response1==8 && response2==5 && response3==6)299 {300 triangle.style.top= "-200px";301 }else if(response1==8 && response2==9 && response3==10){302 triangle.style.top= "-195px";303 }else if(response1==8 && response2==6 && response3==5){304 triangle.style.top= "-195px";305 }else if(response1==9 && response2==4 && response3==5){306 triangle.style.top= "-205px";307 }else if(response1 ==9 && response2==5 && response3==6){308 triangle.style.top= "-205px";309 }else if(response1 ==9 && response2==6 && response3==7){310 triangle.style.top= "-205px";311 }else if(response1 ==9 && response2==7 && response3==8){312 triangle.style.top= "-205px";313 }else if(response1 ==9 && response2==8 && response3==9){314 triangle.style.top= "-205px";315 }else if(response1 ==9 && response2==9 && response3==10){316 triangle.style.top= "-205px";317 }else if(response1 ==9 && response2==5 && response3==4){318 triangle.style.top= "-205px";319 }else if(response1 ==9 && response2==8 && response3==7){320 triangle.style.top= "-205px";321 }else if(response1 ==9 && response2==9 && response3==8){322 triangle.style.top= "-205px";323 }else if(response1 ==9 && response2==10 && response3==9){324 triangle.style.top= "-205px";325 }else if(response1 ==9 && response2==10 && response3==10){326 triangle.style.top= "-205px";327 }else if(response1 ==10 && response2==4 && response3==5){328 triangle.style.top= "-205px";329 }else if(response1 ==10 && response2==5 && response3==5){330 triangle.style.top= "-205px";331 }else if(response1 ==10 && response2==5 && response3==4){332 triangle.style.top= "-206px";333 }else if(response1 ==8 && response2==1 && response3==7){334 triangle.style.top= "-206px";335 triangle.style.right = "175px";336 }else if(response1==9 && response2==1 && response3==8){337 triangle.style.top= "-206px";338 triangle.style.right = "175px";339 }else if(response1==10 && response2==1 && response3==9){340 triangle.style.top= "-207px";341 triangle.style.right = "185px";342 }else if(response1==8 && response2==2 && response3==9){343 triangle.style.top= "-200px";344 triangle.style.right = "172px";345 }else if(response1==9 && response2==2 && response3==10){346 triangle.style.top= "-200px";347 triangle.style.right = "175px";348 }else if(response1==8 && response2==2 && response3==7){349 triangle.style.top= "-205px";350 triangle.style.right = "175px";351 }else if(response1==9 && response2==2 && response3==8){352 triangle.style.top= "-205px";353 triangle.style.right = "175px";354 }else if(response1==10 && response2==2 && response3==9){355 triangle.style.top= "-208px";356 triangle.style.right = "183px";357 }else if(response1==10 && response2==2 && response3==10){358 triangle.style.top= "-208px";359 triangle.style.right = "183px";360 }else if(response1==8 && response2==3 && response3==9){361 triangle.style.top= "-200px";362 triangle.style.right = "172px";363 }else if(response1==9 && response2==3 && response3==10){364 triangle.style.top= "-200px";365 triangle.style.right = "175px";366 }else if(response1==8 && response2==3 && response3==7){367 triangle.style.top= "-200px";368 triangle.style.right = "175px";369 }else if(response1==9 && response2==3 && response3==8){370 triangle.style.top= "-200px";371 triangle.style.right = "175px";372 }else if(response1==10 && response2==3 && response3==9){373 triangle.style.top= "-210px";374 triangle.style.right = "175px";375 }else if(response1==8 && response2==4 && response3==9){376 triangle.style.top= "-200px";377 triangle.style.right = "175px";378 }else if(response1==9 && response2==4 && response3==10){379 triangle.style.top= "-200px";380 triangle.style.right = "175px";381 }else if(response1==10 && response2==4 && response3==10){382 triangle.style.top= "-210px";383 triangle.style.right = "175px";384 }else if(response1==8 && response2==4 && response3==7){385 triangle.style.top= "-200px";386 triangle.style.right = "160px";387 }else if(response1==9 && response2==4 && response3==8){388 triangle.style.top= "-200px";389 triangle.style.right = "160px";390 }else if(response1==10 && response2==4 && response3==9){391 triangle.style.top= "-210px";392 triangle.style.right = "170px";393 }else if(response1==8 && response2==5 && response3==9){394 triangle.style.top= "-200px";395 triangle.style.right = "170px";396 }else if(response1==9 && response2==5 && response3==10){397 triangle.style.top= "-200px";398 triangle.style.right = "170px";399 }else if(response1==10 && response2==5 && response3==10){400 //triangle.style.top= "-200px";401 triangle.style.right = "180px";402 }else if(response1==8 && response2==5 && response3==7){403 triangle.style.top= "-200px";404 //triangle.style.right = "180px";405 }else if(response1==9 && response2==5 && response3==8){406 triangle.style.top= "-200px";407 //triangle.style.right = "180px";408 }else if(response1==9 && response2==6 && response3==10){409 triangle.style.top= "-202px";410 triangle.style.right = "170px";411 }else if(response1==9 && response2==7 && response3==10){412 triangle.style.top= "-205px";413 triangle.style.right = "160px";414 }else if(response1==10 && response2==7 && response3==10){415 triangle.style.top= "-210px";416 triangle.style.right = "160px";417 }else if(response1==10 && response2==7 && response3==9){418 //triangle.style.top= "-210px";419 triangle.style.right = "160px";420 }else if(response1==5 && response2==8 && response3==5){421 triangle.style.top= "-160px";422 //triangle.style.right = "160px";423 }else if(response1==9 && response2==8 && response3==10){424 triangle.style.top= "-200px";425 //triangle.style.right = "160px";426 }else if(response1==10 && response2==8 && response3==10){427 triangle.style.top= "-210px";428 triangle.style.right = "160px";429 }else if(response1==5 && response2==8 && response3==4){430 triangle.style.top= "-180px";431 triangle.style.right = "140px";432 }else if(response1==6 && response2==8 && response3==5){433 triangle.style.top= "-180px";434 triangle.style.right = "140px";435 }else if(response1==9 && response2==8 && response3==8){436 triangle.style.top= "-205px";437 //triangle.style.right = "140px";438 }else if(response1==10 && response2==8 && response3==9){439 triangle.style.top= "-210px";440 triangle.style.right = "152px";441 }else if(response1==5 && response2==10 && response3==4){442 triangle.style.top= "-170px";443 triangle.style.right = "125px";444 }else if(response1==5 && response2==10 && response3==5){445 triangle.style.top= "-170px";446 triangle.style.right = "130px";447 }else if(response1==6 && response2==10 && response3==5){448 triangle.style.top= "-170px";449 triangle.style.right = "130px";450 }else if(response1==6 && response2==10 && response3==6){451 triangle.style.top= "-170px";452 triangle.style.right = "130px";453 }else if(response1==7 && response2==10 && response3==6){454 triangle.style.top= "-190px";455 triangle.style.right = "134px";456 }else if(response1==7 && response2==10 && response3==7){457 triangle.style.top= "-180px";458 triangle.style.right = "134px";459 }else if(response1==8 && response2==10 && response3==8){460 triangle.style.top= "-190px";461 triangle.style.right = "134px";462 }else if(response1==9 && response2==10 && response3==8){463 triangle.style.top= "-200px";464 triangle.style.right = "136px";465 }else if(response1==7 && response2==8 && response3==1){466 triangle.style.top= "-190px";467 triangle.style.right = "136px";468 }else if(response1==8 && response2==9 && response3==1){469 triangle.style.top= "-190px";470 triangle.style.right = "110px";471 }else if(response1==9 && response2==10 && response3==2){472 triangle.style.top= "-203px";473 triangle.style.right = "110px";474 }else if(response1==9 && response2==8 && response3==2){475 triangle.style.top= "-203px";476 triangle.style.right = "120px";477 }else if(response1==10 && response2==9 && response3==2){478 triangle.style.top= "-210px";479 triangle.style.right = "115px";480 }else if(response1==10 && response2==10 && response3==2){481 triangle.style.top= "-210px";482 triangle.style.right = "114px";483 }else if(response1==7 && response2==8 && response3==3){484 triangle.style.top= "-190px";485 triangle.style.right = "120px";486 }else if(response1==8 && response2==9 && response3==3){487 triangle.style.top= "-195px";488 triangle.style.right = "120px";489 }else if(response1==9 && response2==10 && response3==3){490 triangle.style.top= "-205px";491 triangle.style.right = "120px";492 }else if(response1==9 && response2==8 && response3==3){493 triangle.style.top= "-205px";494 triangle.style.right = "120px";495 }else if(response1==10 && response2==9 && response3==3){496 triangle.style.top= "-210px";497 triangle.style.right = "120px";498 }else if(response1==10 && response2==10 && response3==3){499 triangle.style.top= "-210px";500 triangle.style.right = "120px";501 }else if(response1==9 && response2==10 && response3==4){502 triangle.style.top= "-205px";503 triangle.style.right = "120px";504 }else if(response1==9 && response2==8 && response3==4){505 triangle.style.top= "-205px";506 triangle.style.right = "130px";507 }else if(response1==10 && response2==10 && response3==4){508 triangle.style.top= "-210px";509 triangle.style.right = "120px";510 }else if(response1==6 && response2==7 && response3==5){511 triangle.style.top= "-180px";512 triangle.style.right = "132px";513 }else if(response1==7 && response2==8 && response3==5){514 triangle.style.top= "-180px";515 triangle.style.right = "132px";516 }else if(response1==8 && response2==9 && response3==5){517 triangle.style.top= "-200px";518 triangle.style.right = "132px";519 }else if(response1==9 && response2==10 && response3==5){520 triangle.style.top= "-203px";521 triangle.style.right = "125px";522 }else if(response1==10 && response2==10 && response3==5){523 triangle.style.top= "-210px";524 triangle.style.right = "125px";525 }else if(response1==8 && response2==7 && response3==5){526 triangle.style.top= "-192px";527 triangle.style.right = "137px";528 }else if(response1==9 && response2==8 && response3==5){529 triangle.style.top= "-200px";530 triangle.style.right = "137px";531 }else if(response1==10 && response2==9 && response3==5){532 triangle.style.top= "-210px";533 triangle.style.right = "130px";534 }else if(response1==8 && response2==9 && response3==6){535 triangle.style.top= "-190px";536 triangle.style.right = "130px";537 }else if(response1==9 && response2==10 && response3==6){538 triangle.style.top= "-202px";539 triangle.style.right = "132px";540 }else if(response1==10 && response2==10 && response3==6){541 triangle.style.top= "-210px";542 triangle.style.right = "132px";543 }else if(response1==10 && response2==9 && response3==7){544 triangle.style.top= "-210px";545 triangle.style.right = "138px";546 }else if(response1==10 && response2==10 && response3==7){547 triangle.style.top= "-210px";548 triangle.style.right = "138px";549 }else if(response1==5 && response2==4 && response3==8){550 triangle.style.top= "-170px";551 triangle.style.right = "168px";552 }else if(response1==4 && response2==5 && response3==9){553 triangle.style.top= "-160px";554 triangle.style.right = "168px";555 }else if(response1==5 && response2==6 && response3==9){556 triangle.style.top= "-165px";557 triangle.style.right = "168px";558 }else if(response1==6 && response2==7 && response3==9){559 triangle.style.top= "-170px";560 triangle.style.right = "168px";561 }else if(response1==5 && response2==4 && response3==9){562 triangle.style.top= "-160px";563 triangle.style.right = "168px";564 }else if(response1==6 && response2==5 && response3==9){565 triangle.style.top= "-175px";566 triangle.style.right = "168px";567 }else if(response1==7 && response2==6 && response3==9){568 triangle.style.top= "-180px";569 triangle.style.right = "168px";570 }571 else if(response1==5 && response2==7 && response3==5){572 triangle.style.top= "-160px";573 //triangle.style.right = "170px";574 }else if(response1==10 && response2==6 && response3==10){575 triangle.style.top= "-210px";576 triangle.style.right = "170px";577 }else if(response1==9 && response2==6 && response3==8){578 triangle.style.top= "-200px";579 triangle.style.right = "160px";580 }else if(response1==10 && response2==6 && response3==9){581 triangle.style.top= "-210px";582 triangle.style.right = "165px";583 }else if(response1==9 && response2==6 && response3==9){584 triangle.style.top= "-200px";585 triangle.style.right = "165px";586 }587588 else if(response1==9 && response2==10 && response3==1){589 triangle.style.top = "-200px";590 triangle.style.right = "118px";591 }else if(response1==10 && response2==10 && response3==1){592 triangle.style.top = "-210px";593 triangle.style.right = "105px";594 }595 else if(response1==9 && response2==9 && response3==9)596 {597 triangle.style.top = "-205px";598 }else if(response1<=5 && response2<=5 && response3<=5){599 triangle.style.top = "-160px";600 }else if(response1==5 && response2>5 && response3>5){601 triangle.style.top = "-170px";602 }else if(response1>5 && response2<=5 && response3<=5){603 triangle.style.top = "-190px";604 }else if(response1==10 && response2>=5 && response3>=5){605 triangle.style.top = "-210px";606 triangle.style.right = "145px";607 }else if(response1==10 && response2>=5 && response3<5){608 triangle.style.top = "-210px";609 triangle.style.right = "128px";610 }611 else if(response1>5 && (response2>5 && response2<=9) && (response3>5 && response3<=9)){612 triangle.style.top = "-190px";613 }else if((response1>5 && response1<9) && (response2==9 || response2==10) && (response3==9)){614 triangle.style.top = "-195px";615 }else if(response1==8 && (response2==9||response2==10) && (response3==9 || response3==10)){616 triangle.style.top = "-200px";617 }else if(response1<5 && response2<5 && response3>5){618 triangle.style.top = "-180px";619 }else if(response1 == 5 && response2 == 10 && response3 <=5){620 triangle.style.top = "-185px";621 }622 623 else if((response1==5 || response1==6) && (response2==7 || response2==8 || response2==9)624 && (response3==7 || response3==8 || response3==9)){625 triangle.style.top = "-175px";626 }else if((response1==5 || response1==6||response1==7||response1==8)&&(response2==9 || response2==10)627 &&(response3==9 || response3==10)){628 triangle.style.top = "-180px";629 }else if(response1>5 && response2<=5 && response3>5){630 triangle.style.top = "-180px";631 triangle.style.right = "158px";632 }else if(response1>5 && (response2==9 ||response2==10) && (response3>=5 && response3<=7)){633 triangle.style.top = "-200px";634 triangle.style.right = "140px";635 }else if(response1<5 && response2>5 && response3<5){636 triangle.style.top = "-150px";637 }else if(response1<5 && response2>5 && response3>5 ){638 triangle.style.top = "-150px";639 }else if(response1<5 && response2>5 && response3==5){640 triangle.style.top = "-150px";641 }642 else if(response1<=5 && response2<=5 && response3>5)643 {644 triangle.style.top = "-180px";645 }else if(response1>=5 && response2>=5 && response3==10){646 triangle.style.top = "-180px";647 }else if(response1>=5 && response2>=5 && response3<5){648 triangle.style.top = "-190px";649 triangle.style.right = "135px";650 }651}652653/*function graph(){654 var c = document.getElementById("myCanvas");655var ctx = c.getContext("2d");656ctx.beginPath();657ctx.arc(100, 75, 2, 0, 2 * Math.PI);658ctx.stroke();659}*/660661662663form.addEventListener('submit',e => {664665 output.style.visibility = "visible";666 box.style.visibility = "visible";667 input1.style.visibility = "hidden";668 669 draw();670671 //graph();672673 var response1 = Number(document.getElementById("question1").value);674 var response2 = Number(document.getElementById("question2").value);675 var response3 = Number(document.getElementById("question3").value);676 var error= document.querySelector('.error');677 var drive = document.querySelector('.drive');678 var skill = document.querySelector('.skill');679 var growth = document.querySelector('.growth');680 var summary = document.querySelector('.summary');681682 if(response1==0 || response2==0 || response3==0){683 //alert("Please Enter the Values from 1 to 10");684 error.style.display="block";685 output.style.visibility = "hidden";686 box.style.visibility = "hidden";687 }688689 if(response1==1){690 driveId.style.backgroundColor = "#FF0000";691 }else if(response1==2 || response1==3){692 driveId.style.backgroundColor = "#f2ba49";693 }else if(response1==4){694 driveId.style.backgroundColor = "#FFFF00";695 }else if(response1==5 || response1==6 || response1==7){696 driveId.style.backgroundColor = "#90EE90";697 }else{698 driveId.style.backgroundColor = "#006400";699 }700701 if(response2==1){702 skillId.style.backgroundColor = "#FF0000";703 }else if(response2==2 || response2==3){704 skillId.style.backgroundColor = "#f2ba49";705 }else if(response2==4){706 skillId.style.backgroundColor = "#FFFF00";707 }else if(response2==5 || response2==6 || response2==7){708 skillId.style.backgroundColor = "#90EE90";709 }else{710 skillId.style.backgroundColor = "#006400";711 }712713 if(response3==1){714 growthId.style.backgroundColor = "#FF0000";715 }else if(response3==2 || response3==3){716 growthId.style.backgroundColor = "#f2ba49";717 }else if(response3==4){718 growthId.style.backgroundColor = "#FFFF00";719 }else if(response3==5 || response3==6 || response3==7){720 growthId.style.backgroundColor = "#90EE90";721 }else{722 growthId.style.backgroundColor = "#006400";723 }724725 //summaryId.createLinearGradient(0, 0, 170, 0);726 727728 if(response1<=4)729 {730 731 drive.innerHTML = "Your drive and motivation is relatively low. It appears that your interests, values and goals in life diverges from what you obtain from your work. There is a saying that goes like this 'Different Folks, Different Strokes.' All of us are unique and sometimes it takes a longer time to find what we are looking for. ";732733 }else if(response1>4 && response1<=7){734 735 drive.innerHTML = "You are motivated to do a good job but you could be still in the process of figuring out where your career is leading. Although you have some clues about it and you know how to make things work, you have to make some compromises which might drain you at times. Trying talking to your boss to get some perspective or hear some experience on how those kinks could be ironed out so that your full potential can be unleashed. ";736737 }else{738 739 drive.innerHTML = "It's great that you have found the connection between between your job and your passion. This will empower your with the motivation to continue your drive towards excellence in your role. "740 }741742 if(response2<=4)743 {744 745 skill.innerHTML = "Practice makes perfect. It takes patience, fortitude and perseverance to learn and get good at somethings Some of us get there faster, some take a longer time. But as long as you keep an open and positive mind and never give up, you will move forward. Sometimes, a change in perspective or paradigm can go a long way. Don't suffer alone and in silence. Discuss with your supervisor to look at what resouces or help you need to become more adept at your work. ";746747 }else if(response2>4 && response2<=7){748 749 skill.innerHTML = "You have some confidence in your ability and that is good. You feel that you have the skills, knowledge and competency to do your job well. It may be good for you to figure out how you can do it even better. Trying bouncing some ideas off your supervisor to see how you can accelerate your development. Growth can come in all forms. It can taking on new projects, mentoring a new comer or getting better at presentation or communication. Be open and strive to grow even more. ";750751 }else{752 skill.innerHTML = "It’s time to take the next step and push the envelop. How do you continue to improve further? It's OK if you do not have the answer. You may find it useful to tap on your supervisor for advice on how to sustain this momentum and also get another perspective to help you uncover blindspots and discover new potential within yourself."753 }754755 if(response3<=4)756 {757 758 growth.innerHTML = "You seem to be experiencing challenges in gaining new insights and build your skills and competencies in your current role. There may be possible circustances or roadblocks which derailed you from learning and growing in your job. Seek help and advice from your supervisor or HR to discuss possible solutions in taking things forward. ";759760 }else if(response3>4 && response3<=7){761 growth.innerHTML = "It good that you are experiencing reasonable growth in your role. Learning is a lifelong commitment and it always good to get better and know more. Maybe you can have a conversation with your boss to see what other development there are in store for you? Or both of you can work out a plan for your development together? ";762763 }else{764 growth.innerHTML = "Life is a journey of continuous learning. It’s great that you are growing. Reflect on how you achieve this and do your best to maintain this balance and harmony in your work and life. If you ever stumble or fall, don't let it get you down. Learn to forgive yourself and step right back up. Keep doing this because learning never ends."765 }766767 e.preventDefault();768769 var response4 = response1+response2+response3;770 var driveColor = driveId.style.backgroundColor;771 var skillColor=skillId.style.backgroundColor;772 var growthColor = growthId.style.backgroundColor;773774 if(response4==3 || response4==4 ||response4==5){775 summaryId.style.backgroundColor = "#FF0000";776777 }else if(response4==6 || response4==7 || response4==8 || response4==9){778 summaryId.style.backgroundColor = "#f2ba49";779780 }else if(response4==10 || response4==11 || response4==12){781 summaryId.style.backgroundColor = "#FFFF00";782783 }else if(response4>=13 && response4<=21){784 summaryId.style.backgroundColor = "#90EE90";785786 }else{787 summaryId.style.backgroundColor = "#006400";788789 }790791 if(response4<13){792 //summaryId.style.background = "linear-gradient" + "(" + driveId.style.backgroundColor + "," + skillId.style.backgroundColor+ "," + growthId.style.backgroundColor+")";793 //summaryId.style.backgroundColor = "#ffe05d";794 summary.innerHTML = "You are likely going through a difficult period in some areas of your work. You could be experiencing frustration and anxiety that hinder you from realizing your true potential. Have a discussion with your superivisor or HR to see how the misalignments can be resolved. ";795796 }else if(response4>13 && response4<=21){797 if(response1<5 || response2<5 || response3<5){798 //summaryId.style.background = "linear-gradient" + "(" + driveId.style.backgroundColor + "," + skillId.style.backgroundColor+ "," + growthId.style.backgroundColor+")";799 //summaryId.style.backgroundColor = "#b8de6f";800 summary.innerHTML = "Life is like a box of chocolate as Forrest Gump has so famoulsy said. There are ups and downs but we will get there if we perserve and keep an open mind. You might not be absolutely clear on your career path or face resistance in certain areas but you seem be moving along relatively well in some aspects. Talk more, learn more and in time to come, you will get closer to your goal. Feel free to go to your supervisor or HR anytime you need some help on how to move forward. ";801802 }else if(response1>4&&response2>4&&response3>4)803 {804 // summaryId.style.background = "linear-gradient" + "(" + driveId.style.backgroundColor + "," + skillId.style.backgroundColor+ "," + growthId.style.backgroundColor+")";805 //summaryId.style.backgroundColor = "#b8de6f";806 summary.innerHTML = "Although there might be areas that you are not too sure of, in general you are not too far off track. You might be at crossroads in certain areas but in others you could be nearer to your goals and doing well. Continue to make strides and seek clarity in your career and you are bound to make good progress in time. Never stop learning and never stop pushing ahead. You might want to accelerate this process by checking in with your supervisor for some tips or advice.";807808 }809 }else{810 if(response1<5 || response2<5 || response3<5)811 {812 //summaryId.style.background = "linear-gradient" + "(" + driveId.style.backgroundColor + "," + skillId.style.backgroundColor+ "," + growthId.style.backgroundColor+")";813 //summaryId.style.backgroundColor = "green";814 summary.innerHTML = "It is great that you feel excellent in some areas. But at the same time, there are areas that you are still reconciling. Reflect on how you might leverage on the positives and strength that you have to resolve the challenges that you face in those areas and greateness will be upon you fast and furious. ";815 }else if(response1>4&&response2>4&&response3>4){816 //summaryId.style.background = "linear-gradient" + "(" + driveId.style.backgroundColor + "," + skillId.style.backgroundColor+ "," + growthId.style.backgroundColor+")";817 //summaryId.style.backgroundColor = "green";818 summary.innerHTML = "What got you here won't get you there.' Words of wisdom by world renowed CEO coach, Marshall Goldsmith and also the eponymous title of his international bestseller that might best describe where you are right now. Continue to hone your craft and seek personal mastery. With your heart and goals aligned, you will defintely be able to scale even greater heights.";819 }820 821 }822 823824});825826function exportTableToExcel(tableID, filename = ''){827 var downloadLink;828 var dataType = 'application/vnd.ms-excel';829 var tableSelect = document.getElementById(tableID);830 var tableHTML = tableSelect.outerHTML.replace(/ /g, '%20');831 832 // Specify file name833 filename = filename?filename+'.xls':'excel_data.xls';834 835 // Create download link element836 downloadLink = document.createElement("a");837 838 document.body.appendChild(downloadLink);839 840 if(navigator.msSaveOrOpenBlob){841 var blob = new Blob(['\ufeff', tableHTML], {842 type: dataType843 });844 navigator.msSaveOrOpenBlob( blob, filename);845 }else{846 // Create a link to the file847 downloadLink.href = 'data:' + dataType + ', ' + tableHTML;848 849 // Setting the file name850 downloadLink.download = filename;851 852 //triggering the function853 downloadLink.click();854 }855}856857var radarChart = new Chart(document.getElementById("radarChart"), {858 type: 'radar',859 data: {860 labels: ["Drive", "SKill", "Growth"],861 datasets: [{862 label: "Cognizant Baseline",863 fill: true,864 backgroundColor:"rgba(179,180,198,0.1)", //"rgba(179,181,198,0.2)",865 borderColor: "black",//"rgba(179,181,198,1)",866 pointBorderColor: "#fff",867 pointBackgroundColor: "rgba(179,181,198,1)",868 //data: ['spaceScore', 'styleScore', 'scheduleScore']869 data: [0, 5, 10]870 },{871 label: "Assessment",872 fill: false,873 backgroundColor: "rgba(60, 179, 113,0)",//"rgba(255,99,132,0.2)",874 borderColor: "rgba(60, 179, 113,0)",//"rgba(255,99,132,1)",875 //pointBorderColor: "#fff",876 //pointBackgroundColor: "rgba(255,99,132,1)",877 data:[10,10,10]878 //data: ['spaceScore', 'styleScore', 'scheduleScore']879 }, {880 label: "Learner Centricity",881 fill: false,882 backgroundColor: "rgba(60, 179, 113,0)",//"rgba(114, 205, 244,0.2)",883 borderColor: "rgba(60, 179, 113,0)",//"black",//"rgba(114, 205, 244,1)",884 //pointBorderColor:"#fff",885 //pointBackgroundColor: "rgba(114, 205, 244,1)",886 data: [0, 5, 10]887 }]888 },889890891 options: {892 scale: {893 ticks: {894 display: false,895 maxTicksLimit: 1896 }897 },898 title: {899 display: false,900 },901 legend: {902 display: false903 },904 tooltips: {905 enabled: false906 }/*,907 fill:{908 enabled:true,909 color:red910 }*/911 },912 scale:{ pointLabels:{ fontSize: 0 }, },913 /*gridLines:{914 display:false915 },*/916 917918 });919920 // click handler of the update button921 $('.form-input').on('click', function() {922 getData();923 });924925 function getData() {926 // get new user-selected values927 var spaceScore = document.getElementById('question1').value;928 var styleScore = document.getElementById('question2').value;929 var scheduleScore = document.getElementById('question3').value;930 //var supplementScore = document.getElementById('supplementScore').value;931 // update chart dataset with new values932 radarChart.data.datasets[0].data[0] = spaceScore;933 radarChart.data.datasets[0].data[1] = styleScore;934 radarChart.data.datasets[0].data[2] = scheduleScore;935 //radarChart.Grid().palette(["red","green","yellow"]);936937 /* radarChart.yScale()938 .minimum(0)939 .maximum(10)940 .ticks({'interval':1});*/941942 //radarChart.yGrid().palette(["gray 0.1", "gray 0.2"]);943944 //radarChart.area(data).name('Hello World').markers(true).fill("#E55934", 0.3).stroke("#E55934");945 //radarChart.data.datasets[0].data[3] = supplementScore;946 // redraw chart947 radarChart.update();948 } ...

Full Screen

Full Screen

balance.test.ts

Source:balance.test.ts Github

copy

Full Screen

1import { app } from "../../../src/app";2import request from "supertest";3import { createConnection } from "../../../src/database";4import { getConnection } from "typeorm";5import { UserFactory, AccountFactory } from "../../factories";6import { User } from "../../../src/entities/User";7import jwt = require("jsonwebtoken");8import { Account } from "../../../src/entities/Account";9import moment from "moment";10let user1: User;11let mainAccount: Account;12let secondaryAccount: Account;13let user2: User;14let alternativeAccount1: Account;15let alternativeAccount2: Account;16describe("User Balance", () => {17 beforeAll(async () => {18 const connection = await createConnection();19 await connection.dropDatabase();20 await connection.runMigrations();21 const userFactory: UserFactory = new UserFactory();22 const accountFactory: AccountFactory = new AccountFactory();23 user1 = await userFactory.create({24 email: "user10@mail.com",25 name: "User #10",26 });27 mainAccount = await accountFactory.create({28 user_id: user1.id,29 name: "1 A Acc Origin"30 });31 secondaryAccount = await accountFactory.create({32 user_id: user1.id,33 name: "1 B Acc Destiny"34 });35 user2 = await userFactory.create({36 email: "user20@mail.com",37 name: "User #20",38 });39 alternativeAccount1 = await accountFactory.create({40 user_id: user2.id,41 name: "2 A Acc Origin"42 });43 });44 afterAll(async () => {45 const connection = getConnection();46 await connection.close();47 });48 it("should be able to return only accounts with at least one transaction", async () => {49 const response = await request(app)50 .get("/balance")51 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`);52 expect(response.status).toBe(200);53 expect(response.body).toHaveLength(0);54 });55 it("should be able to add input values", async () => {56 await request(app)57 .post("/transactions")58 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`)59 .send({60 description: "1",61 type: "I",62 amount: 100,63 account_id: mainAccount.id,64 status: true65 });66 const response2 = await request(app)67 .get("/balance")68 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`);69 expect(response2.status).toBe(200);70 expect(response2.body).toHaveLength(1);71 expect(response2.body[0].id).toBe(mainAccount.id);72 expect(response2.body[0].sum).toBe("100.00");73 });74 it("should be able to subtract output values", async () => {75 await request(app)76 .post("/transactions")77 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`)78 .send({79 description: "1",80 type: "O",81 amount: 200,82 account_id: mainAccount.id,83 status: true84 });85 const response2 = await request(app)86 .get("/balance")87 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`);88 expect(response2.status).toBe(200);89 expect(response2.body).toHaveLength(1);90 expect(response2.body[0].id).toBe(mainAccount.id);91 expect(response2.body[0].sum).toBe("-100.00");92 });93 it("should not be able to return pending values", async () => {94 await request(app)95 .post("/transactions")96 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`)97 .send({98 description: "1",99 type: "O",100 amount: 200,101 account_id: mainAccount.id,102 status: false103 });104 const response2 = await request(app)105 .get("/balance")106 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`);107 expect(response2.status).toBe(200);108 expect(response2.body).toHaveLength(1);109 expect(response2.body[0].id).toBe(mainAccount.id);110 expect(response2.body[0].sum).toBe("-100.00");111 });112 it("should not be able to return other accounts", async () => {113 await request(app)114 .post("/transactions")115 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`)116 .send({117 description: "1",118 type: "I",119 amount: 50,120 account_id: secondaryAccount.id,121 status: true122 });123 const response2 = await request(app)124 .get("/balance")125 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`);126 expect(response2.status).toBe(200);127 expect(response2.body).toHaveLength(2);128 expect(response2.body[0].id).toBe(mainAccount.id);129 expect(response2.body[0].sum).toBe("-100.00");130 expect(response2.body[1].id).toBe(secondaryAccount.id);131 expect(response2.body[1].sum).toBe("50.00");132 });133 it("should not be able to return accounts of other user", async () => {134 await request(app)135 .post("/transactions")136 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`)137 .send({138 description: "1",139 type: "I",140 amount: 200,141 account_id: alternativeAccount1.id,142 status: true143 });144 const response2 = await request(app)145 .get("/balance")146 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`);147 expect(response2.status).toBe(200);148 expect(response2.body).toHaveLength(2);149 expect(response2.body[0].id).toBe(mainAccount.id);150 expect(response2.body[0].sum).toBe("-100.00");151 expect(response2.body[1].id).toBe(secondaryAccount.id);152 expect(response2.body[1].sum).toBe("50.00");153 });154 it("should not be able to return pass transactions", async () => {155 await request(app)156 .post("/transactions")157 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`)158 .send({159 description: "1",160 type: "I",161 amount: 250,162 account_id: mainAccount.id,163 status: true,164 transaction_date: moment().subtract({ days: 5 }).toISOString()165 });166 const response2 = await request(app)167 .get("/balance")168 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`);169 expect(response2.status).toBe(200);170 expect(response2.body).toHaveLength(2);171 expect(response2.body[0].id).toBe(mainAccount.id);172 expect(response2.body[0].sum).toBe("150.00");173 expect(response2.body[1].id).toBe(secondaryAccount.id);174 expect(response2.body[1].sum).toBe("50.00");175 });176 it("should not be able to return future transactions", async () => {177 await request(app)178 .post("/transactions")179 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`)180 .send({181 description: "1",182 type: "I",183 amount: 250,184 account_id: mainAccount.id,185 status: true,186 transaction_date: moment().add({ days: 5 }).toISOString()187 });188 const response2 = await request(app)189 .get("/balance")190 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`);191 expect(response2.status).toBe(200);192 expect(response2.body).toHaveLength(2);193 expect(response2.body[0].id).toBe(mainAccount.id);194 expect(response2.body[0].sum).toBe("150.00");195 expect(response2.body[1].id).toBe(secondaryAccount.id);196 expect(response2.body[1].sum).toBe("50.00");197 });198 it("should not be able to consider future transactions", async () => {199 await request(app)200 .post("/transfers")201 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`)202 .send({203 description: "1",204 amount: 250,205 origin_acc_id: mainAccount.id,206 destiny_acc_id: secondaryAccount.id,207 });208 const response2 = await request(app)209 .get("/balance")210 .set("Authorization", `Bearer ${jwt.sign({ id: user1.id }, process.env.APP_SECRET)}`);211 expect(response2.status).toBe(200);212 expect(response2.body).toHaveLength(2);213 expect(response2.body[0].id).toBe(mainAccount.id);214 expect(response2.body[0].sum).toBe("-100.00");215 expect(response2.body[1].id).toBe(secondaryAccount.id);216 expect(response2.body[1].sum).toBe("300.00");217 });...

Full Screen

Full Screen

getAxiosData.js

Source:getAxiosData.js Github

copy

Full Screen

1import $axios from '@/utils/axios/axios.js';2export const getAxiosData = async () => {3 try {4 const postData1 = {5 xskf: true, // 批发客户分析是否有显示6 xshy: true, // 会员数量分析是否有显示7 xscgqs: true, // 采购趋势是否有显示8 xslrzs: true, // 利润趋势分析是否有显示9 xsrwsl: true, // 利润趋势分析是否有显示10 xsrwlr: true // 利润趋势分析是否有显示})11 };12 const response = await Promise.all([$axios.post('xsfx_bb.do', { lx: '1' }), $axios.post('xsfx_bb.do', postData1)]);13 const response1 = response[0];14 const response2 = response[1];15 // 今日销售与利润16 const todayStatistics = {17 xsbz: Boolean(response1.xsbz),18 xsdw: response1.xsdw || '',19 xsje: response1.xsje || '0',20 xslrje: response1.xslrje || '0'21 };22 // 销售分析23 const xsfxData = {24 bz: Number(response2.hjjea) >= 100000 ? parseInt(response2.hjjea) : Number(response2.hjjea).toFixed(2),25 sz: Number(response2.hjjeb) >= 100000 ? parseInt(response2.hjjeb) : Number(response2.hjjeb).toFixed(2),26 dataset: getOptionData(response2.rData, response2.wkday)27 };28 // 批发客户分析相关 【先判断是否有权限】29 const pfkhData = !response2.pfkhfx_permission30 ? false31 : {32 khsl: response2.khsl,33 xzkf: response2.xzkf,34 lskf: response2.lskf,35 xz: { value: response2.xzl, name: '本周新增率', color: '#05c32b', bg: 'rgba(0,255,135,0.1)' },36 ls: { value: response2.xzl, name: '本周流失率', color: '#ff2e31', bg: 'rgba(255,46,49,0.1)' }37 };38 // 采购趋势相关 【先判断是否有权限】39 const cgqsData = !response2.cgcs_permission40 ? false41 : {42 cghjjea: response2.cghjjea,43 cghjjeb: response2.cghjjeb,44 dataset: getOptionData(response2.cgData, response2.wkday)45 };46 // 利润趋势相关 【先判断是否有权限】47 const lrqsData = !response2.lrcsfx_permission48 ? false49 : {50 lrhjjea: response2.lrhjjea,51 lrhjjeb: response2.lrhjjeb,52 dataset: getOptionData(response2.lrData, response2.wkday)53 };54 // 会员分析相关 【先判断是否有权限】55 const hyfxData = !response2.hyslfx_permission56 ? false57 : {58 hysl: response2.hysl,59 hyxz: response2.hyxz,60 hyls: response2.hyls,61 xz: { value: response2.hyxzl, name: '本周新增率', color: '#05c32b', bg: 'rgba(0,255,135,0.1)' },62 ls: { value: response2.hylsl, name: '本周复购率', color: '#ff2e31', bg: 'rgba(255,46,49,0.1)' }63 };64 // 任务统计65 const { rwslData, rwlrData } = trimRWListData(response2.rwData, response2.rwtj_sl_permission, response2.rwtj_lr_permission);66 return Promise.resolve({67 xsfxData, // 本周和上周销售图表68 pfkhData, // 批发客户分析69 cgqsData, // 采购趋势70 lrqsData, // 利润趋势71 hyfxData, // 会员分析72 rwslData, // 任务数量73 rwlrData, // 任务利润74 todayStatistics75 });76 } catch (error) {77 return Promise.reject(error);78 }79};80/**81 * 得到图表配置的数据相关部分82 */83function getOptionData(arr, week) {84 const op = { series: [], xAxis: { data: week } };85 arr.forEach((item) => {86 op.series.push({ name: item.name, data: item.data.slice(0, 7) });87 });88 return op;89}90/**91 * 整理任务数据92 */93function trimRWListData(list, is_sl, is_lr) {94 if (Array.isArray(list) && list.length > 0) {95 let rw_zs_wcsl = 0;96 let rw_zs_rwsl = 0;97 let rw_zs_wclr = 0;98 let rw_zs_rwlr = 0;99 const rw_l_list = [];100 const rw_r_list = [];101 list.forEach((item) => {102 item.wcsl = item.wcsl !== '' && !isNaN(item.wcsl) ? Number(item.wcsl) : 0;103 item.rwsl = item.rwsl !== '' && !isNaN(item.rwsl) ? Number(item.rwsl) : 0;104 item.wclr = item.wclr !== '' && !isNaN(item.wclr) ? Number(item.wclr) : 0;105 item.rwlr = item.rwlr !== '' && !isNaN(item.rwlr) ? Number(item.rwlr) : 0;106 if (is_sl) {107 const wcl = item.wcsl === 0 || item.rwsl === 0 ? '0.00' : ((item.wcsl / item.rwsl) * 100).toFixed(2);108 rw_zs_wcsl += item.wcsl;109 rw_zs_rwsl += item.rwsl;110 rw_l_list.push({ name: item.name, wcsl: item.wcsl, rwsl: item.rwsl, wcl });111 }112 if (is_lr) {113 const wcl = item.wclr === 0 || item.rwlr === 0 ? '0.00' : ((item.wclr / item.rwlr) * 100).toFixed(2);114 rw_zs_wclr += item.wclr;115 rw_zs_rwlr += item.rwlr;116 rw_r_list.push({ name: item.name, wcsl: item.wclr, rwsl: item.rwlr, wcl });117 }118 });119 const obj = { rwslData: false, rwlrData: false };120 if (rw_l_list.length > 0) {121 obj.rwslData = { rw_zs_wcsl, rw_zs_rwsl, rw_l_list };122 }123 if (rw_r_list.length > 0) {124 obj.rwlrData = { rw_zs_wclr, rw_zs_rwlr, rw_r_list };125 }126 return obj;127 } else {128 return { rwslData: false, rwlrData: false };129 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.runTest('www.google.com', function(err, data) {4 if (err) return console.error(err);5 wpt.getResponse2(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log(data);8 });9});10var wpt = require('webpagetest');11var wpt = new WebPageTest('www.webpagetest.org');12wpt.runTest('www.google.com', function(err, data) {13 if (err) return console.error(err);14 wpt.getResponse2(data.data.testId, function(err, data) {15 if (err) return console.error(err);16 console.log(data);17 });18});19var wpt = require('webpagetest');20var wpt = new WebPageTest('www.webpagetest.org');21wpt.runTest('www.google.com', function(err, data) {22 if (err) return console.error(err);23 wpt.getResponse2(data.data.testId, function(err, data) {24 if (err) return console.error(err);25 console.log(data);26 });27});28var wpt = require('webpagetest');29var wpt = new WebPageTest('www.webpagetest.org');30wpt.runTest('www.google.com', function(err, data) {31 if (err) return console.error(err);32 wpt.getResponse2(data.data.testId, function(err, data) {33 if (err) return console.error(err);34 console.log(data);35 });36});37var wpt = require('webpagetest');38var wpt = new WebPageTest('www.webpagetest.org');39wpt.runTest('www.google.com', function(err, data) {40 if (err) return console.error(err);41 wpt.getResponse2(data.data.testId, function(err, data) {42 if (err) return console.error(err);43 console.log(data);44 });45});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 wpt.getTestResults(data.data.testId, function(err, data) {5 if (err) return console.error(err);6 console.log(data.data.average.firstView.SpeedIndex);7 });8});9var wpt = require('webpagetest');10var wpt = new WebPageTest('www.webpagetest.org');11for (var i = 0; i < url.length; i++) {12 wpt.runTest(url[i], { location: 'Dulles:Chrome', runs: 1 }, function(err, data) {13 if (err) return console.error(err);14 wpt.getTestResults(data.data.testId, function(err, data) {15 if (err) return console.error(err);16 console.log(data.data.average.firstView.SpeedIndex);17 });18 });19}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2 if (err) {3 console.log('Error: ' + err);4 } else {5 console.log('Test Status: ' + data.statusCode);6 if (data.statusCode == 200) {7 wpt.response2(data.data.testId, function(err, data) {8 if (err) {9 console.log('Error: ' + err);10 } else {11 console.log(data);12 }13 });14 }15 }16});

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = {2 response1: function (req, res) {3 res.send("response1");4 },5 response2: function (req, res) {6 res.send("response2");7 },8 response3: function (req, res) {9 res.send("response3");10 },11 response4: function (req, res) {12 res.send("response4");13 }14};15var fs = require("fs");16var text = fs.readFileSync("input.txt");17console.log(text.toString());18console.log("Program Ended");

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getTestResults('170504_3C_3d3f8e0b7a7e6a1f7b1d9a9f2b2ff3ef', function(err, data) {4if (err) return console.log(err);5console.log(data.response2);6});7{ [Error: connect ECONNREFUSED

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