How to use nKey method in Best

Best JavaScript code snippet using best

multiple-select.js

Source:multiple-select.js Github

copy

Full Screen

1FrontendCore.define('multiple-select', ['devicePackage' ], function () {2 return {3 onStart: function () {45 var aTargets = FrontendTools.getDataModules('multiple-select'),6 self = this,7 oData,8 oSelects;910 FrontendTools.trackEvent('JS_Libraries', 'call', 'multiple-select');1112 $('select[multiple="multiple"]', aTargets).each(function (nKey) {13 $(aTargets[nKey]).hide().before(self.createGrid( self.createSelect( self.getElements(this) , aTargets[nKey]) ));14 });1516 self.bindSelect();1718 },19 bindSelect : function( oTarget ){20 $('select','.js-select-multiple').change( function(){21 var sId = $(this).attr('data-rel'),22 sValue = this.value,23 sLabel = $(this).attr('data-group');2425 $( 'option', 'optgroup[label="'+ sLabel + '"]').each( function(){26 if ( this.value == sValue) {27 this.selected = true;28 } else {29 this.selected = false;30 }31 });32 });33 },34 createGrid : function(oSelects) {3536 var oGrid = document.createElement('div'),37 nTotal = oSelects.length,38 nGrid = nTotal < 4 ? nTotal : 4;3940 oGrid.className = 'grid js-select-multiple';4142 for (var nKey = 0; oSelects.length > nKey; nKey++) {4344 var oCol = document.createElement('div');4546 oCol.className = 'col-1-' + nTotal;4748 oCol.innerHTML = '<div class="pr-l"><label>'+ oSelects[nKey].label + '</label>' + oSelects[nKey].outerHTML + '</div>';4950 oGrid.appendChild(oCol);5152 }5354 return oGrid;5556 },57 createSelect: function( oData) {5859 var oSelects = [],60 oOption;6162 for ( var nCounter = 0; oData.data.length > nCounter; nCounter++ ) {6364 oSelects[nCounter] = document.createElement('select');6566 oSelects[nCounter].setAttribute('data-rel', oData.properties.id );67 oSelects[nCounter].setAttribute('data-group', oData.data[nCounter].properties.name );68 oSelects[nCounter].setAttribute('id', 'select-' + oData.data[nCounter].properties.name );6970 oOption = document.createElement('option');71 oOption.value = '';72 oOption.innerHTML = '---';73 oSelects[nCounter].appendChild(oOption);7475 for (var nKey = 0; oData.data[nCounter].data.length > nKey; nKey++) {7677 oOption = document.createElement('option');78 oOption.value = oData.data[nCounter].data[nKey].value;79 oOption.innerHTML = oData.data[nCounter].data[nKey].label;80 if (oData.data[nCounter].data[nKey].selected){81 oOption.setAttribute('selected','selected');82 }83 oSelects[nCounter].appendChild(oOption);8485 oOption = null;86 }8788 oSelects[nCounter].label = oData.data[nCounter].properties.name;8990 }9192 return oSelects;939495 },96 getElements: function(oTarget) {9798 var oData = [],99 sLabel;100101 oData.properties = [];102 oData.properties.name = oTarget.name;103 oData.properties.id = oTarget.id;104105 oData.data = [];106107 $('optgroup' , oTarget).each( function( nCounter ) {108109 sLabel = this.label;110111 oData.data[ nCounter ] = [];112 oData.data[ nCounter ].data = [];113 oData.data[ nCounter ].properties = [];114 oData.data[ nCounter ].properties.name = sLabel;115116117 $('option' , this).each( function( nKey ) {118 oData.data[ nCounter].data[ nKey ] = [];119 oData.data[ nCounter].data[ nKey ].value = this.value;120 oData.data[ nCounter].data[ nKey ].label = this.innerHTML;121 oData.data[ nCounter].data[ nKey ].selected = this.selected;122 });123 });124125 return oData;126127 }128 };129}); ...

Full Screen

Full Screen

Home.js

Source:Home.js Github

copy

Full Screen

1import { useCallback, useState, useEffect } from "react";2import { useNavigate } from "react-router-dom";3import IconButton from "../components/IconButton";4import { MdWindow, MdSports, MdQuestionAnswer } from "react-icons/md";5import { IoMdChatbubbles } from "react-icons/io";6import { RiQuestionMark, RiTimerFill } from "react-icons/ri";7import { GiJuggler, GiPuzzle } from "react-icons/gi";8import "./Home.css";9import { useGlobalContext } from "../contexts/Global";10import Score from "../components/Score";11export default function Home() {12 const {13 quickQuestion,14 setQuickQuestion,15 audienceQuesion,16 rightsTurn,17 turned,18 DATA,19 setAudienceQuestion,20 setDiscussionCounter,21 } = useGlobalContext();22 const navigate = useNavigate();23 const [active, setActive] = useState(0);24 const handleKeyDown = useCallback(25 (e) => {26 console.log(e.key);27 const nkey = parseInt(e.key);28 if (nkey >= 0 && nkey <= 7) {29 if (nkey === active && nkey !== 0) {30 if (nkey === 1) {31 navigate(`/question/1/${quickQuestion + 1}/0`);32 setQuickQuestion(1);33 } else if (nkey === 2) navigate(`/windows`);34 else if (nkey === 3) {35 navigate(`/question/3/1/0`);36 setDiscussionCounter(1);37 } else if (nkey === 4) {38 navigate(`/question/4/1/0`);39 setDiscussionCounter(1);40 } else if (nkey === 5) {41 navigate(`/questionpicker/7`);42 } else if (nkey === 6) {43 navigate(`/question/6/1/0`);44 } else if (nkey === 7 && audienceQuesion < DATA.parts[6].length) {45 navigate(`/question/7/${audienceQuesion + 1}/0`);46 setAudienceQuestion((e) => e + 1);47 }48 } else setActive(nkey);49 } else50 switch (e.key) {51 default:52 break;53 }54 },55 [active, navigate, audienceQuesion, DATA.parts, quickQuestion, setQuickQuestion, setDiscussionCounter, setAudienceQuestion]56 );57 useEffect(() => {58 document.addEventListener("keydown", handleKeyDown);59 return () => {60 document.removeEventListener("keydown", handleKeyDown);61 };62 }, [handleKeyDown]);63 return (64 <div className="Home">65 <Score right turn={rightsTurn && turned} />66 <Score turn={!rightsTurn && turned} />67 <span className="Question-title Question-title-6 Home-title">مسابقة سامراء الأولى</span>68 <div className="Home-container">69 <IconButton70 title="سؤال السرعة"71 Icon={MdSports}72 width="25rem"73 height="25rem"74 color="tomato"75 fontSize={"4rem"}76 active={active === 1}77 />78 <IconButton79 title="النوافذ"80 Icon={MdWindow}81 width="25rem"82 height="25rem"83 fontSize={"4rem"}84 active={active === 2}85 />86 <IconButton87 title="المناظرة"88 Icon={IoMdChatbubbles}89 width="25rem"90 height="25rem"91 fontSize={"4rem"}92 active={active === 3}93 />94 <IconButton95 title="الرشق السريع"96 Icon={RiTimerFill}97 width="25rem"98 height="25rem"99 fontSize={"4rem"}100 active={active === 4}101 />102 <IconButton103 title="الحزورات"104 Icon={RiQuestionMark}105 width="25rem"106 height="25rem"107 fontSize={"4rem"}108 active={active === 5}109 />110 <IconButton111 title="المواهب"112 Icon={GiJuggler}113 width="25rem"114 height="25rem"115 fontSize={"4rem"}116 active={active === 6}117 />118 </div>119 </div>120 );...

Full Screen

Full Screen

popup.js

Source:popup.js Github

copy

Full Screen

1function start(nkey,save_interval) {2 b.innerText='Cancel';3 //console.log(b.innerText);4 b.className="btn-danger";5 //alert("stop set");6 chrome.storage.local.set({7 'flag': 18 9 10});11 chrome.storage.local.set({12 'nkey': nkey13 14 15});16chrome.storage.local.set({17 'pso': pso18 19 20});21if(save_interval!='null')22{23 chrome.storage.local.set({24 'save_interval':save_interval 25 26 27 });28}29chrome.storage.local.set({30 'mob': mob31 32 33});34 35chrome.tabs.executeScript({36 file: 'online.js'37 }); 38 39}40function stop() {41 chrome.storage.local.set({42 'flag': 043 44});45 46}47save_interval=0;48function get()49{50 51 var nkey=document.getElementById('nkey').value;52 53 save_interval=document.getElementById('interval').value;54 chrome.storage.sync.set({"nkey": nkey}, function() {55 document.getElementById('nkey').value=nkey;56 });57 pso=document.querySelector('input[name="ps"]:checked').value; 58 b=document.getElementById('start')59 60 61 //alert(b.innerText);62 //console.log(nkey,pso,b);63 if(b.innerText=='OK'){start(nkey,save_interval);}64 else{stop();b.innerText='OK';b.className="btn-success";}65 66}67document.getElementById('start').addEventListener('click', get);68try {69 chrome.storage.sync.get(['nkey'], function(result) {70 71 document.getElementById('nkey').value=result.nkey;72 });73 74} catch (error) {75 76 chrome.storage.sync.get(['nkey'], function(result) {77 document.getElementById('nkey').value=result.nkey;78 });79}80function mobchat()81{82 mob=document.getElementById('mob').value;83chrome.storage.local.set({84 'mob': mob85 86 87});88chrome.tabs.executeScript({89 file: 'mobchat.js'90 }); 91 92}93document.getElementById('mobchat').addEventListener('click', mobchat);94try{95 al=document.querySelectorAll('#userbtn')[0].innerHTML96 97}98catch(err){99 chrome.tabs.executeScript({100 file: 'websocket.js'101 }); 102chrome.tabs.executeScript({103 file: 'protobuf.js'104 });105chrome.tabs.executeScript({106 file: 'main.js'107 });108 109}110document.addEventListener('DOMContentLoaded', function () {111 var links = document.getElementsByTagName("a");112 for (var i = 0; i < links.length; i++) {113 (function () {114 var ln = links[i];115 var location = ln.href;116 ln.onclick = function () {117 chrome.tabs.create({active: true, url: location});118 };119 })();120 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var spawn = require('child_process').spawn;2var fs = require('fs');3var path = require('path');4var async = require('async');5var config = require('./config');6var logger = require('./logger');7var util = require('./util');8var crypto = require('crypto');9var key = config.key;10var password = config.password;11var file = config.file;12var encryptedFile = config.encryptedFile;13var decryptedFile = config.decryptedFile;14var nKey = config.nKey;15var args = config.nKeyArgs;16var args2 = config.nKeyArgs2;17var args3 = config.nKeyArgs3;18var args4 = config.nKeyArgs4;19var args5 = config.nKeyArgs5;20var args6 = config.nKeyArgs6;21var args7 = config.nKeyArgs7;22var args8 = config.nKeyArgs8;23var args9 = config.nKeyArgs9;24var args10 = config.nKeyArgs10;25var args11 = config.nKeyArgs11;26var args12 = config.nKeyArgs12;27var args13 = config.nKeyArgs13;28var args14 = config.nKeyArgs14;29var args15 = config.nKeyArgs15;30var args16 = config.nKeyArgs16;31var args17 = config.nKeyArgs17;32var args18 = config.nKeyArgs18;33var args19 = config.nKeyArgs19;

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