Search is not available for this dataset
query
stringlengths
7
355k
document
stringlengths
9
341k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
given the collection of standup reports, collates the entire report
function getReportDisplay(standupReports) { if (!standupReports) { return "*There is no standup data to report.*"; } var totalReport = "*Standup Report*\n\n"; for (var user in standupReports) { var report = standupReports[user]; totalReport += getSingleReportDisplay(report); } return totalReport; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static merge(reports) {\n const valid = reports.every((report) => report.valid);\n const merged = {};\n reports.forEach((report) => {\n report.results.forEach((result) => {\n const key = result.filePath;\n if (key in merged) {\n merge...
[ "0.5859966", "0.5847742", "0.5773973", "0.56990427", "0.55929637", "0.5524131", "0.5523469", "0.5456793", "0.5411935", "0.540643", "0.54032606", "0.54032606", "0.53966814", "0.53822637", "0.52842146", "0.5282263", "0.5263722", "0.5193387", "0.51875335", "0.5161858", "0.515795...
0.5408388
9
builds a string that displays a single user's standup report
function getSingleReportDisplay(standupReport) { var report = "*" + standupReport.userName + "* did their standup at " + standupReport.datetime + "\n"; report += "_What did you work on yesterday:_ `" + standupReport.yesterdayQuestion + "`\n"; report += "_What are you working on today:_ `" + standupReport.todayQuestion + "`\n"; report += "_Any obstacles:_ `" + standupReport.obstacleQuestion + "`\n\n"; return report; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getReportDisplay(standupReports) {\n \n if (!standupReports) {\n return \"*There is no standup data to report.*\";\n }\n\n var totalReport = \"*Standup Report*\\n\\n\";\n for (var user in standupReports) {\n var report = standupReports[user];\n totalReport += getSingleR...
[ "0.68696153", "0.67091095", "0.58703655", "0.58037055", "0.5690617", "0.56840926", "0.56504303", "0.5626813", "0.55754954", "0.5566497", "0.55646896", "0.5559293", "0.54887426", "0.5483268", "0.5476705", "0.5465037", "0.54605424", "0.5443541", "0.54333824", "0.5423004", "0.54...
0.75525874
0
Obtengo los medicamentos de un determinado paciente
function getMedicamentosPaciente(req, res){ console.log('- GET MEDICAMENTOS PACIENTE -'); var query = Paciente.findById(req.params.idPaciente); query.populate({ path: 'medicamentos', model: 'Medicamento' }) .exec(function (err, paciente) { if (err) { return res.status(400).json({ title: 'An error occurred', error: err }); } if (!paciente) { return res.status(404).json({ title: 'Error', error: 'Paciente no encontrado' }); } res.status(200).json({ message: 'Success', obj: paciente.medicamentos }); }); /*console.log("El paciente: "+paciente); //preguntar como itero y obtengo los valores.. console.log("id paciente: "+paciente._id+" Consumicion paciente: "+paciente.consumiciones); paciente.consumiciones.forEach(element => { Medicamento.findById(element.medicamento, function (err, medicamentos) { if (err) { return res.status(400).json({ title: 'Error', error: err }); } if (!medicamentos) { return res.status(404).json({ title: 'Error', error: err }); } res.status(200).json({ message: 'Success', obj: medicamentos }); }); });*/ }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function diasMonitoradosPaciente() {\n\tvar diasMonitorados = pacientesJson[numIdPacAtual].diasMonitorados;\n\n\treturn diasMonitorados;\n}", "function obtenerPacientes() {\n return pacientes;\n}", "function getMissionMeta () {\n Mission.getMissionMeta(vm.missionID) \n .then(function (missionDat...
[ "0.66760886", "0.6577735", "0.5897365", "0.58847046", "0.586581", "0.5826479", "0.5785089", "0.57821685", "0.5718523", "0.5701656", "0.5685478", "0.5684123", "0.56406814", "0.5619061", "0.5607755", "0.55937815", "0.55599284", "0.55578953", "0.55327165", "0.5508442", "0.550071...
0.6068864
2
Handles a value change within this application's top controller.
function handleTopChanged () { org.fftlab.APPLICATION.transformTopToBottom(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "change() {\n this._updateValueProperty();\n\n this.sendAction('action', this.get('value'), this);\n }", "function valueChanged() {\n debug && console.log( \"ManageWorkOrderRepairDetails: value changed\" );\n JSONData.setUnsavedChanges( true, \"manageWorkOrderSave\" );\n }", "function ha...
[ "0.70386714", "0.6580312", "0.645076", "0.6419568", "0.6363013", "0.63515925", "0.63312304", "0.6284234", "0.6241777", "0.6241287", "0.62380415", "0.61897504", "0.6117865", "0.6097524", "0.6079965", "0.60366", "0.60191476", "0.5981911", "0.59660035", "0.59660035", "0.59653836...
0.0
-1
Handles a value change within this application's bottom controller.
function handleBottomChanged () { org.fftlab.APPLICATION.transformBottomToTop(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "change() {\n this._updateValueProperty();\n\n this.sendAction('action', this.get('value'), this);\n }", "_valueChanged() {\n // Send a global refresh to the bapge body.\n var event = new Event(\"change\");\n this._root.dispatchEvent(event);\n }", "function valueChanged() {\n ...
[ "0.6967543", "0.6920667", "0.6835909", "0.6658889", "0.6596557", "0.65901476", "0.65281105", "0.64454955", "0.6380449", "0.63738567", "0.6373579", "0.6373579", "0.6352901", "0.63458955", "0.62582105", "0.6220317", "0.61975396", "0.6194963", "0.6180379", "0.6146054", "0.614286...
0.0
-1
Fonction pour inverser la couleur HEX
function invertColor(col){ if (col == "#808080") return "#999999"; const colors = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']; let inverseColor = '#'; col.replace('#','').split('').forEach(i => { const index = colors.indexOf(i); inverseColor += colors.reverse()[index]; }); return inverseColor; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function inverseHex(h){\n var hex = h.substr(1).toUpperCase();\n var inv_val = \"#\";\n\n var h_vals = {\"A\": 5, \"B\": 4, \"C\": 3, \"D\": 2, \"E\": 1, \"F\": 0};\n var inv_h_vals = [\"F\", \"E\", \"D\", \"C\", \"B\", \"A\", \"9\", \"8\", \"7\", \"6\", \"5\", \"4\", \"3\", \"2\", \"1\", \"0\"];\n\n ...
[ "0.74479896", "0.6967258", "0.66854167", "0.6680756", "0.65849745", "0.65136343", "0.6486934", "0.6454508", "0.6443687", "0.6441389", "0.6441389", "0.64271116", "0.64229", "0.6422503", "0.63987625", "0.6343833", "0.63082755", "0.6298101", "0.6191495", "0.6168584", "0.6165069"...
0.5779988
95
let table10PositionX = 5; let table10PositionY = 7; let table10 = new Table(table10PositionX, table10PositionY, 10);
function Table(i, j, n) { this.i = i; this.j = j; this.n = n; this.edges = []; this.searched = false; this.parent = null; this.f = 0; this.g = 0; this.h = 0; this.weight = 1; this.show = () => { let x = i * w; let y = j * w; // draw a cell with table and it's number stroke(250); fill('#e4e4e4'); rect(x, y, w, w); image(tableImg, x + 8, y + 14, img.width / 1.3, img.height / 1.3); } this.addEdges = arr => { /* tables don't have edges */ } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Table() {\r\n}", "function Table() {\n\tthis.commonCards = [];\n\n\t//make table deck from cards class\n\tthis.deck = new Cards();\n\tthis.players = [];\n\tthis.myPosition = Math.floor(Math.random() * (10 - 1)) + 1;\n\tthis.myHand = [];\n\tthis.othersHands = [];\n\tthis.communityCards = [];\n\n}", "fu...
[ "0.72494125", "0.71040285", "0.6949791", "0.6908907", "0.6726849", "0.6726039", "0.6655984", "0.6645612", "0.65821755", "0.6503481", "0.64891595", "0.6433516", "0.64133537", "0.63974714", "0.63968617", "0.63934374", "0.6389266", "0.63639504", "0.6294264", "0.62737", "0.627180...
0.6282029
19
text configuration for start, game over and win
function startGame() { var screen = new GameScreen("HK Space Police","press space to start", function() { Game.loadBoard(new GameBoard(1)); }); Game.loadBoard(screen); Game.loop(); /* game background song */ myAudio = new Audio('sound/spacebattle2.wav'); if (typeof myAudio.loop == 'boolean') { myAudio.loop = true; } myAudio.play(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Instructions() {\n background(colorList[0]);\n \n textSize(100);\n textAlign(CENTER);\n fill(colorList[2]);\n text(\"How to Play\", width/2, 100);\n\n textSize(50);\n textAlign(LEFT);\n fill(colorList[4]);\n text(\"Hold W to toggle the Head\\nHold s to toggle the middle body\\nHold a to toggle t...
[ "0.6804581", "0.673038", "0.6643339", "0.65729374", "0.6440953", "0.6354138", "0.63337165", "0.6326226", "0.63208", "0.63196033", "0.62945724", "0.6240662", "0.6229601", "0.6215396", "0.621333", "0.6199451", "0.6170604", "0.6163665", "0.6155735", "0.61370057", "0.61261034", ...
0.0
-1
return "Hello, " + person; }
function greeter(person) { return "Hi " + person.firstName + " " + person.lastName; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function person(name) {\n return \"I think\" + name + \"is a cool guy\";\n}", "function greeter2(person) {\n return \"Aloha \" + person + \"!\";\n}", "function greeter(person) {\n return \"Hello, \" + person;\n}", "hello(someone) {\n return \"hello, \"+ someone\n }", "function sayName(pers...
[ "0.83308357", "0.82673615", "0.82393354", "0.7925421", "0.7888341", "0.7842417", "0.7716826", "0.7624223", "0.76173675", "0.7573261", "0.7572713", "0.7570779", "0.7568589", "0.75617194", "0.7533274", "0.751613", "0.7516", "0.75083584", "0.75056255", "0.74988335", "0.74911076"...
0.8291874
1
Game logic// Makes sure there is no winner before the game starts
function startGame(){ document.winner = null; setMessage(player1 + " gets to start!"); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "checkForWinner() {\n if (this.primaryWinConditionsCheck()) {\n this.endGame();\n }\n }", "checkForWin() {\n if (this.numMafia <= 0) { this.gameState = TOWN_WIN; }\n if (this.getInnocentPlayerCount() <= 0) { this.gameState = MAFIA_WIN; }\n }", "checkForWin() {\n i...
[ "0.7918461", "0.7475996", "0.7290871", "0.72637683", "0.71598727", "0.7147194", "0.71239096", "0.7073445", "0.70607746", "0.7053345", "0.7046313", "0.70215315", "0.7016849", "0.700809", "0.6997564", "0.69965994", "0.6990546", "0.6960273", "0.6958654", "0.6956176", "0.69518536...
0.67979187
50
Creates messages for who's turn it is or whoever won. Displayed in html
function setMessage(msg){ document.getElementById('gameMessage').innerHTML = msg; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_createDynamicMessage(){\n this._$dynamicMsg.empty();\n\n let currentPlayer;\n if(this.model.currentPlayer == \"x\") currentPlayer = \"<span class='x'>Player 1</span>\";\n else currentPlayer = \"<span class='o'>Player 2</span>\";\n let string = \"<h3>\";\n\n ...
[ "0.708287", "0.70616657", "0.69162214", "0.668206", "0.66761035", "0.6496092", "0.6471226", "0.64240366", "0.6389482", "0.63814694", "0.6356439", "0.63405174", "0.6333448", "0.63231534", "0.6306881", "0.62951624", "0.6269166", "0.62655324", "0.62344044", "0.6232538", "0.62221...
0.0
-1
Determine whose turn it is.
function switchTurn(){ if (checkForWinner (player1)){ setMessage (player1 + " wins!!"); document.winner = player1; } else if (player1 == "X") { player1 = "O"; setMessage(player1 + "'s turn to pick!"); }else { player1 = "X" setMessage(player1 + "'s turn to pick!"); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isMyTurn() {\n return playerId == turn;\n}", "getNextTurn () {\n // continue turn for same player if they just ate an enemy coin\n if (this._didEatEnemyCoin) {\n this._didEatEnemyCoin = false // reset flag\n return this.currentTurn\n }\n\n // continue turn for same player if the...
[ "0.66927385", "0.65845907", "0.65520275", "0.65097505", "0.649565", "0.6448989", "0.6443287", "0.63881946", "0.63446903", "0.6259162", "0.6243585", "0.6233513", "0.622928", "0.62070465", "0.61267364", "0.61267364", "0.611822", "0.6101008", "0.6097121", "0.60262924", "0.599816...
0.0
-1
This determines if the move has already resulted in the person winning or if a cell has already been occupied.
function playerMove(cell) { if (document.winner != null) { setMessage(document.winner + " has already won the game!"); } else if (cell.innerHTML == ""){ cell.innerHTML = player1; switchTurn(); } else { setMessage("Position already taken."); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isWinningMove() {\n var hori = count(0, -1) + count(0, 1) - 1;\n var vert = count(-1, 0) + count(1, 0) - 1;\n var diag = count(1, -1) + count(-1, 1) - 1;\n var antd = count(1, 1) + count(-1, -1) - 1;\n // console.log(\"horizontal: \" + hori);\n // console.log(\"vertical: \" + vert);\n ...
[ "0.70196646", "0.6976245", "0.6952398", "0.6924065", "0.69226193", "0.6917704", "0.6907018", "0.68547726", "0.6847678", "0.6834587", "0.6819364", "0.68186", "0.6812699", "0.6812083", "0.6801315", "0.6797841", "0.67967856", "0.67956686", "0.67941564", "0.6793112", "0.67795557"...
0.65262496
69
Winning combinations Determines which cell number is clicked so that it can be used for the checkRow function
function getBox (number) { return document.getElementById("cell"+number).innerHTML; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function handleClick (evt) {\n //Checks game for win, if one player wins, ends game.\n if (checkForWin ()) {\n return endGame (\n `Game Over. Player ${currPlayer} won. Hit refresh to play again!`\n );\n }\n // get x from ID of clicked cell\n //row = top -> ID -> tr -> #column-top -> height -> y\n ...
[ "0.6866995", "0.68578416", "0.6837854", "0.6822141", "0.6803706", "0.6794932", "0.6773249", "0.67554885", "0.6738475", "0.6737375", "0.67291284", "0.6723694", "0.6717159", "0.6660504", "0.66520005", "0.6643504", "0.66336966", "0.66101444", "0.6609261", "0.6593005", "0.6572265...
0.0
-1
Check to see if the moves have resulted in 3 in a row.
function checkRow (a, b, c, move) { var result = false; if (getBox(a) == move && getBox(b) == move && getBox(c) == move) { result = true; }; return result; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function checkWiningRowMove(p) {\n //0,1,2 3,4,5 6,7,8\n var ret = false;\n var r1 = _matrix[0][0] + _matrix[0][1] + _matrix[0][2];\n var r2 = _matrix[1][0] + _matrix[1][1] + _matrix[1][2];\n var r3 = _matrix[2][0] + _matrix[2][1] + _matrix[2][2];\n\n if (r1 === p.repeat...
[ "0.7784433", "0.7537197", "0.74251866", "0.74220955", "0.7318096", "0.7291771", "0.7284944", "0.72652704", "0.7221565", "0.71908194", "0.7190789", "0.71839005", "0.71588254", "0.7136651", "0.70757294", "0.7030792", "0.6985195", "0.69706374", "0.69657284", "0.69411016", "0.691...
0.75067693
2
Determines if the row is one of the winning combinations
function checkForWinner(move) { var result = false; if (checkRow(1, 2, 3, move) || checkRow(4, 5, 6, move) || checkRow(7, 8, 9, move) || checkRow(1, 4, 7, move) || checkRow(2, 5, 8, move) || checkRow(3, 6, 9, move) || checkRow(1, 5, 9, move) || checkRow(3, 5, 7, move)) { result = true; }; return result; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function checkWin() {\n for (let i = 0; i < winningCombinations.length; i++) {\n let pattern = winningCombinations[i];\n let [a, b, c] = pattern;\n if ( currentCells[a] === currentCells[b] && currentCells[b] === currentCells[c] ) {\n return true;\n }\n }\n return false;\n}", "function checkWi...
[ "0.75367916", "0.7323091", "0.73075527", "0.72247434", "0.7200272", "0.7142273", "0.71399826", "0.7033779", "0.69245094", "0.69237643", "0.68896663", "0.6887292", "0.68794304", "0.6865423", "0.6860089", "0.682167", "0.6817677", "0.67861307", "0.6779591", "0.67776483", "0.6771...
0.0
-1
COUNT items in each brand
countItemsInBrand(getBrandArr, getItemsArr) { for (let i = 0; i < getBrandArr.length; i++) { var tmp = getItemsArr.filter((item) => item.subcategoryArr.id === getBrandArr[i].id).length; getBrandArr[i].itemCount = tmp; } return getBrandArr; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "countOfItems() {\n var count = 0\n for (var sku in this.items) {\n var li = this.items[sku]\n count = Number(count) + Number(li.quantity)\n }\n return count\n }", "itemsCount() {\n return this._checkoutProducts\n .map((checkoutProduct) => checkoutProdu...
[ "0.67231584", "0.6563493", "0.63034475", "0.62030816", "0.6187013", "0.60876316", "0.60441923", "0.6032323", "0.59975", "0.59230274", "0.5913571", "0.59081304", "0.590752", "0.5882206", "0.5869655", "0.5868861", "0.5865619", "0.5865054", "0.58574206", "0.5835562", "0.5833918"...
0.7266751
0
OFF FULLSCREEN OVERLAY MENU
function handleFullscreenMenu() { $('#off-fullscreen-menu li').each(function() { if ($(this).hasClass('menu-item-has-children')) { $(this).children().first().attr('href', '#'); if ($(this).hasClass('mega-menu')) { $(this).removeClass('mega-menu'); } } }); $('#off-fullscreen-menu li.menu-item-has-children > a').append('<span class="fullscreen-dropdown-toggle"></span>'); $('body').on('click', '[data-toggle="fullscreen-menu"]', function(e) { //$('.toggle-menu').toggleClass('active'); e.preventDefault(); e.stopPropagation(); $('body').toggleClass('full-menu-open'); $('#off-fullscreen-menu').toggleClass('full-menu-open'); $('body').on('click', '#off-fullscreen-menu nav > ul li > a', function(e) { e.preventDefault(); e.stopPropagation(); var targetLink = $(this).attr('href'); if (targetLink != '#' && targetLink != '') { $('body').fadeOut(350, function() { window.location.href = targetLink; }); } if ($(this).hasClass('is-open')) { $(this).removeClass('is-open'); $(this).next().slideUp(300); } else { $(this).parent('.submenu').parent().find('.is-open').next().slideUp(300); $(this).parent('.submenu').parent().find('.is-open').removeClass('is-open'); $(this).addClass('is-open'); $(this).next().slideDown(300); } }); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function OCM_fullscreenAltOpen() {\r\n\t\t\t\t\t\r\n\t\t\t\t\tif ($('body.material').length > 0) {\r\n\t\t\t\t\t\t$('header#top .slide-out-widget-area-toggle a').addClass('menu-push-out');\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\t$('header#top .slide-out-widget-area-toggle:not(.std-menu) .lines-button').addClass(...
[ "0.6833504", "0.6828152", "0.67699605", "0.67699605", "0.67699605", "0.67404884", "0.67333907", "0.66932297", "0.66915023", "0.659659", "0.65687484", "0.6520185", "0.6515098", "0.6515098", "0.6515098", "0.64546734", "0.6447622", "0.6357631", "0.6350292", "0.63362837", "0.6332...
0.59259
67
MANAGE NAVIGATION LOGO / BACKGROUND COLOR Header on Scroll
function navbarScroll() { if ( windowWidth > 1000 && topnav.length > 0 ) { var topScroll = $(window).scrollTop(); var logoImg = $('body').find('#logo a img'); var logoLight = $('body').find('#logo a').data('logo-light'); var logoDark = $('body').find('#logo a').data('logo-dark'); var $navSelectors = $('.main-nav,.main-nav ul.nav > li > a,.main-nav .nav-tools li a'); if ( wrapper.hasClass('onepage-special') ) return; if ( wrapper.hasClass('header-light') ) { logoImg.attr('src', logoDark); } if ( wrapper.hasClass('header-dark') ) { logoImg.attr('src', logoLight); } if ( wrapper.hasClass('transparent-dark') ) { logoImg.attr('src', logoDark); } if ( wrapper.hasClass('nav-bottom') ) { return; } if ( wrapper.hasClass('header-transparent') && wrapper.hasClass('transparent-dark') ) { logoImg.attr('src', logoDark); } var scrollHeight = header.data('scroll-height'); var finalScroll = topnavHeight - headerScrollHeight; var zeroScroll = 0; if ( $('#topbar').length > 0 ) { finalScroll = finalScroll + topbarHeight; zeroScroll = topbarHeight; } if ( topScroll > zeroScroll && topScroll <= finalScroll ) { $navSelectors.css({ 'height' : topnavHeight - ( topScroll - zeroScroll ) }); } else if ( topScroll > finalScroll ) { if ( !wrapper.hasClass( 'header-scroll-full' ) ) { $navSelectors.css({ 'height' : scrollHeight }); wrapper.addClass('header-scroll-full'); header.removeClass( headerSkin ).addClass( headerScrollSkin ); wrapper.removeClass('topnav-top'); } } else { // Initial State $navSelectors.css({ 'height' : '' }); wrapper.addClass('topnav-top'); wrapper.removeClass('header-scroll-full'); header.removeClass( headerScrollSkin ).addClass( headerSkin ); } if (wrapper.hasClass('dark-skin')) { if (wrapper.hasClass('header-light')) { wrapper.removeClass('header-light').addClass('header-dark'); } else { logoImg.attr('src', logoLight); } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function style_header() {\n if ($(document).scrollTop() > $('#lead-content>h1').offset().top ) {\n $('header').css({\"background-color\":\"#000\",\"border-bottom\":\"2.5px solid #3498db\"});\n $('.logo').css(\"visibility\",\"visible\");\n } \n else {\n $('header').cs...
[ "0.7169707", "0.71389514", "0.7040095", "0.6822407", "0.6800498", "0.6783916", "0.6780022", "0.67553127", "0.6737385", "0.6737385", "0.67184144", "0.66696876", "0.66277003", "0.6626935", "0.66197735", "0.6611527", "0.65977097", "0.65884733", "0.65774775", "0.6560479", "0.6552...
0.67566824
7
TOPBAR HIDE ON SCROLL
function handleTopNav() { var $upperNav = $('.upper-nav-wrapper'); var upperNavHeight; var classOut = 'nav-out'; if ( $upperNav.length && $(window).width() > 768 ) { upperNavHeight = $upperNav.height(); if ( scrollPos > 0 && scrollPos <= upperNavHeight ) { $upperNav.css( 'margin-top', - scrollPos ); $upperNav.removeClass( classOut ); //$('#main-navigation').css('top', 0); } else if ( scrollPos > topbarHeight ) { if ( !$upperNav.hasClass( classOut ) ) { $upperNav.addClass( classOut ); $upperNav.css('margin-top', - upperNavHeight ); } } else { $upperNav.removeClass( classOut ); $upperNav.css('margin-top', 0); //$('#main-navigation').css('top', topbarHeight); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function initTopBar(){\n\tvar header = jQuery('#header')\n\tvar animSpeed = 400;\n\tvar win = jQuery(window);\n\tjQuery('.top-bar').each(function(){\n\t\tvar bar = jQuery(this);\n\t\tbar.css({\n\t\t\ttop: -bar.outerHeight()\n\t\t}).hide();\n\t\twin.bind('scroll resize orientationchange load', function(){\n\t\t\tif...
[ "0.71608293", "0.68470377", "0.67728347", "0.67573625", "0.66268724", "0.66119576", "0.6596977", "0.6503522", "0.65002173", "0.65002173", "0.6441368", "0.64310133", "0.64081085", "0.640179", "0.64012665", "0.63919926", "0.6389622", "0.63764936", "0.6369483", "0.63693047", "0....
0.0
-1
NAVIGATION VISIBLE ONLY ON SCROLL TO TOP
function stickyNav() { if ( $( '#sticky-nav' ).length ) { var stickyNav = $('#sticky-nav'); var windowScrollTop = $(window).scrollTop(); if ( windowScrollTop >= stickyNav.data( 'scroll-amount' ) ) { stickyNav.addClass( 'sticky-nav-visible' ); } else { stickyNav.removeClass('sticky-nav-visible'); } if ( windowScrollTop >= stickyNav.data( 'scroll-amount' ) - 250 ) { header.removeClass( 'header-' + header.data( 'skin' ) ).addClass( 'header-' + header.data( 'scroll-skin' ) ); $('#wrapper').removeClass( 'topnav-top' ); } else { header.removeClass( 'header-' + header.data( 'scroll-skin' ) ).addClass( 'header-' + header.data( 'skin' ) ).addClass( 'topnav-top' ); $('#wrapper').addClass( 'topnav-top' ); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function scroll_style() {\n var window_top = $(window).scrollTop();\n var div_top = 1;\n\n if (window_top > div_top){\n console.log('show navigation');\n $('#splash').slideUp(\"slow\");\n $('#loadSecond').fadeIn(\"slow\");\n $('#navbar').slideDown(\"slow\");\n } else {\n...
[ "0.7086939", "0.70821786", "0.69970965", "0.6987205", "0.69347805", "0.68816125", "0.68556464", "0.68534666", "0.6806813", "0.67682844", "0.66906655", "0.66817236", "0.66751194", "0.667185", "0.6640746", "0.66287", "0.66236174", "0.66222817", "0.6605184", "0.6589516", "0.6587...
0.6193265
100
HEADER NO STICKY EFFECT
function headerNoSticky() { scrollPos = $(window).scrollTop(); if ($('.header-no-sticky #main-navigation:not(.header-2)').length) { var st = $(this).scrollTop(); if (st > lastScrollTop) { $('.header-no-sticky #main-navigation').removeClass('nav-visible'); } else { $('.header-no-sticky #main-navigation').addClass('nav-visible'); } if (st > 0) { $('#main-navigation .main-nav-wrapper').css('background', '#fff'); } else { $('#main-navigation .main-nav-wrapper').css('background', ''); } lastScrollTop = st; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function hhunHeaderEffect() {\r\n\t\t\t\t\t\r\n\t\t\t\t\tvar previousScroll = 0, // previous scroll position\r\n\t\t\t\t\tmenuOffset = 250, // height of menu (once scroll passed it, menu is hidden)\r\n\t\t\t\t\thideShowOffset = 6; // scrolling value after which triggers hide/show menu\r\n\t\t\t\t\t\...
[ "0.73440796", "0.6939821", "0.6848647", "0.6740718", "0.67094404", "0.6666176", "0.6661954", "0.66477185", "0.6628086", "0.6621007", "0.6601639", "0.6601639", "0.65870315", "0.65706724", "0.6547743", "0.65205896", "0.6520242", "0.6499889", "0.64820725", "0.6475748", "0.646631...
0.0
-1
TOPBAR HIDE ON SCROLL
function handleTopbar() { if ($('#topbar').length && $(window).width() > 768 && !wrapper.hasClass('header-no-sticky')) { if ($('#header').hasClass('header-2')) { var header2Height = $('.header-2 .main-nav-wrapper').height(); var windowScrollTop = $(window).scrollTop(); if (windowScrollTop >= topbarHeight + header2Height) { $('.header-2 .main-nav-wrapper').css('position', 'fixed').css('width', '100%').css('top', 0); } else { $('.header-2 .main-nav-wrapper').attr('style', ''); } } else { if (scrollPos > 0 && scrollPos <= topbarHeight) { $('#topbar').css('margin-top', - scrollPos); $('#topbar').removeClass( 'topbar-out' ); //$('#main-navigation').css('top', 0); } else if (scrollPos > topbarHeight ) { if ( !$('#topbar').hasClass( 'topbar-out' ) ) { $('#topbar').addClass( 'topbar-out' ); $('#topbar').css('margin-top', - topbarHeight); } } else { $('#topbar').removeClass( 'topbar-out' ); $('#topbar').css('margin-top', 0); //$('#main-navigation').css('top', topbarHeight); } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function initTopBar(){\n\tvar header = jQuery('#header')\n\tvar animSpeed = 400;\n\tvar win = jQuery(window);\n\tjQuery('.top-bar').each(function(){\n\t\tvar bar = jQuery(this);\n\t\tbar.css({\n\t\t\ttop: -bar.outerHeight()\n\t\t}).hide();\n\t\twin.bind('scroll resize orientationchange load', function(){\n\t\t\tif...
[ "0.71608293", "0.68470377", "0.67728347", "0.67573625", "0.66268724", "0.66119576", "0.6596977", "0.6503522", "0.65002173", "0.65002173", "0.6441368", "0.64310133", "0.64081085", "0.640179", "0.64012665", "0.63919926", "0.6389622", "0.63764936", "0.6369483", "0.63693047", "0....
0.60453784
61
Page Title Vertical Align
function pageTitle(){ if ( $(window).width() >= 1000 && pageTitleResized == false ) { $('#ins-page-title').each(function() { var marginTop = 55; var extra = 0; var titleInner = $(this).find( '.ins-page-title-inner' ); var titleInnerHeight = titleInner.height(); if( $('#header').length ) { extra = 80 / 2; } if( $('#topbar').length ) { extra += $('#topbar').height() / 2; } if( $('.bottom-nav-wrapper').length ) { extra += $('.bottom-nav-wrapper').height() / 2; } marginTop = extra; $(this).find( '.ins-page-title-inner' ).css( 'margin-top', marginTop ); pageTitleResized = true; }); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function fTitlePlacement (elem, ht, vPos) {\n fAnimateHeight (elem, ht);\n fAnimateTop (elem, vPos);\n }", "function fTitlePlacement (elem, ht, vPos) {\n fAnimateHeight (elem, ht);\n fAnimateTop (elem, vPos);\n }", "function getPageTitle () {\n return title;\n }", "function createTitlePages...
[ "0.6289992", "0.6289992", "0.620483", "0.6144102", "0.6076659", "0.597595", "0.5893578", "0.586862", "0.5790285", "0.575313", "0.5747338", "0.5740914", "0.5738883", "0.5738883", "0.5716012", "0.57087487", "0.5697498", "0.56831956", "0.5679236", "0.5669497", "0.5648148", "0....
0.6583696
0
Create a new zbDigitalClock object.
constructor() { // Must call super first super(); // Create the CSS parts for the shadow DOM const style = document.createElement('style'); // Set style style.textContent = ` :host { display: inline-block; } .root12 { min-width: 280px; min-height: 100px; height: 100%; width: 100%; background-color: rgb(48, 48, 48); display: grid; grid-template-columns: 4fr 4fr 1fr 4fr 4fr 2fr; grid-template-rows: 1fr; grid-column-gap: 0.5em; padding: 0.4em; } .root24 { min-width: 280px; min-height: 100px; height: 100%; width: 100%; background-color: rgb(48, 48, 48); display: grid; grid-template-columns: 4fr 4fr 1fr 4fr 4fr; grid-template-rows: 1fr; grid-column-gap: 0.5em; padding: 0.4em; } .digit { height: 100%; display: grid; grid-template-columns: 1fr 2fr 1fr; grid-template-rows: 1fr 2fr 1fr 2fr 1fr; grid-column-gap: 1px; grid-row-gap: 1px; } .digit-line-on { background-color: rgb(248, 248, 248); } .digit-line-off { background-color: rgb(55, 55, 55); } .digit-gap { background-color: rgb(48, 48, 48); } .dots { height: 100%; display: grid; grid-template-columns: 1fr; grid-template-rows: 2fr 1fr 3fr 1fr 2fr; grid-column-gap: 1px; grid-row-gap: 1px; } .dot { background-color: rgb(248, 248, 248); border-radius: 50%; } .ampm { height: 100%; display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; grid-column-gap: 1px; grid-row-gap: 1px; font-family: "Lucida Console", Courier, monospace; font-size: 1em; } .ampm-parent { position: relative; width: 100%; height: 100%; } .ampm-child { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } .ampm-on { color: rgb(248, 248, 248); } .ampm-off { color: rgb(55, 55, 55); } @keyframes blink { 50% { opacity: 0.0; } } .blink { animation: blink 1s step-start 0s infinite; }`; // Attach shadow DOM root this._shadowRoot = this.attachShadow({mode: 'open'}); // Add styles this._shadowRoot.appendChild(style); // Bind update event to this this._update = this._update.bind(this); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_create() {\n // Set show 24 hour clock\n let show24HourClock = false;\n\n // If there is a show 24 hour clock attribute\n if (this.hasAttribute('show24hour') === true) {\n // Set to show 24 hour clock\n show24HourClock = true;\n }\n\n // Create root ...
[ "0.5641572", "0.5471911", "0.53663963", "0.52661705", "0.52459407", "0.5147853", "0.5140225", "0.51113576", "0.5110032", "0.50638914", "0.4969592", "0.49694657", "0.49343893", "0.4905503", "0.4877259", "0.48505768", "0.48271105", "0.48216093", "0.48194742", "0.47990417", "0.4...
0.0
-1
Override connectedCallback function to handle when component is attached into the DOM.
connectedCallback() { // Create parts this._create(); // Update to the current time this._update(); // Start clock this._timerId = setInterval(this._update, 1000); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "connectedCallback() {\n // Do things when component is added to the DOM\n }", "connectedCallback() {\r\n\t\t\tthis._domAttached = true;\r\n\t\t}", "connectedCallback(){\n\n //Though here DOM is inserted, but not rendered, so you can change the attribute \n //but you cannot manipulate the ...
[ "0.8603147", "0.81673336", "0.8071765", "0.8056886", "0.79146945", "0.78885263", "0.78766465", "0.7840403", "0.78308374", "0.7818974", "0.7813992", "0.76180124", "0.7584181", "0.7568622", "0.7550421", "0.7505771", "0.7474685", "0.7424241", "0.7381253", "0.7378645", "0.7378645...
0.0
-1
Override disconnectedCallback function to handle when component is detached from the DOM.
disconnectedCallback() { // If timer exists if (this.timerId) { // Clear timer clearInterval(this._timerId); // Remove timer id delete this._timerId; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "disconnectedCallback () {\r\n console.log('Component disconnect!')\r\n }", "disconnectedCallback() {\n // Detect super?\n if (this.removeEvents) this.removeEvents();\n }", "disconnectedCallback () {\n this._shadowElement = null;\n this._listeners.forEach(([evt, f]) => this.removeEventListener(...
[ "0.80025643", "0.7850981", "0.7760064", "0.7722052", "0.7703584", "0.75908214", "0.7568651", "0.7538355", "0.7447083", "0.7447083", "0.7447083", "0.74400645", "0.74290204", "0.7419395", "0.7408694", "0.7400944", "0.7372546", "0.7362139", "0.73553926", "0.7346556", "0.73222655...
0.0
-1
Create the DOM elements.
_create() { // Set show 24 hour clock let show24HourClock = false; // If there is a show 24 hour clock attribute if (this.hasAttribute('show24hour') === true) { // Set to show 24 hour clock show24HourClock = true; } // Create root DIV const rootDiv = document.createElement('div'); // Set root class if (show24HourClock === true) { // Set to use the root24 class rootDiv.setAttribute('class', 'root24'); } else { // Set to use the root12 class rootDiv.setAttribute('class', 'root12'); } // Create digit line element list this._digit = [4]; this._digit[0] = {}; this._digit[1] = {}; this._digit[2] = {}; this._digit[3] = {}; // Create digit DOM elements const digit1DomElement = this._createDigit(0); const digit2DomElement = this._createDigit(1); const dotsDomElement = this._createDots(); const digit3DomElement = this._createDigit(2); const digit4DomElement = this._createDigit(3); // Append DOM elements to the root DIV rootDiv.appendChild(digit1DomElement); rootDiv.appendChild(digit2DomElement); rootDiv.appendChild(dotsDomElement); rootDiv.appendChild(digit3DomElement); rootDiv.appendChild(digit4DomElement); // If showing 12 hour clock if (show24HourClock === false) { // Create AM PM DOM elements const ampmDomElement = this._createAmpm(); // Append to the root DIV rootDiv.appendChild(ampmDomElement); } // If there is a current root DIV if (this._rootDiv) { // Remove current root DIV from shadow DOM this._shadowRoot.removeChild(this._rootDiv); } // Set the new current root DIV this._rootDiv = rootDiv; // Add root DIV to shadow DOM this._shadowRoot.appendChild(this._rootDiv); // If there is a current time then remove it if (this._currentTime) delete this._currentTime; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_createDOMElements() {\n\t\tthis.$control = $( this.template( this.controlOptions ) );\n\t\tthis.$sliderGroup = this.$control.find( '.slider-group' );\n\t\tthis.$units = this.$control.find( '.unit' );\n\t\tthis.$revert = this.$control.find( '.undo' );\n\t\tthis.$deleteSaved = this.$control.find( '.delete-saved .re...
[ "0.75377023", "0.73833424", "0.68896383", "0.67572", "0.6748092", "0.67387784", "0.6619444", "0.65832704", "0.6501774", "0.64914566", "0.64770895", "0.6474412", "0.6446111", "0.6435074", "0.6425917", "0.6410774", "0.64088136", "0.640828", "0.63849884", "0.6360732", "0.6358413...
0.0
-1
Update the time shown.
_update() { // Get time now const time = zbTime.getNow(); // If there is a current time if (this._currentTime) { // If nothing has changed then stop here if (this._currentTime.hour === time.hour && this._currentTime.minute === time.minute) return; } // Update current time this._currentTime = time; // Set show 24 hour clock let show24HourClock = false; // If there is a show 24 hour clock attribute if (this.hasAttribute('show24hour') === true) { // Set to show 24 hour clock show24HourClock = true; } // Set hour let hour = time.hour; // If showing 12 hour clock and over 12 hours if (show24HourClock === false && hour > 12) { // Minus 12 hours hour -= 12; } // Set digit numbers let digit1Number = Math.floor(hour / 10); const digit2Number = hour % 10; const digit3Number = Math.floor(time.minute / 10); const digit4Number = time.minute % 10; // If showing 12 hour clock and digit 1 number is zero if (show24HourClock === false && digit1Number === 0) { // Set the digit 1 number so that it hides the number digit1Number = -1; } // Set the digit lines this._setDigitLines(this._digit[0], digit1Number); this._setDigitLines(this._digit[1], digit2Number); this._setDigitLines(this._digit[2], digit3Number); this._setDigitLines(this._digit[3], digit4Number); // If 12 hour clock shown if (show24HourClock === false) { // If AM if (this._currentTime.hour < 12) { // Show AM this._amChildDomElement.className = 'ampm-child ampm-on'; this._pmChildDomElement.className = 'ampm-child ampm-off'; } else { // Show PM this._amChildDomElement.className = 'ampm-child ampm-off'; this._pmChildDomElement.className = 'ampm-child ampm-on'; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateDisplayTime() {\n\t\tvar date = new Date();\n\n\t\tvar hours = date.getHours();\n\t\tvar minutes = date.getMinutes();\n\t\tvar seconds = date.getSeconds();\n\t\tvar year = date.getFullYear();\n\t\tvar month = date.getMonth() + 1;\n\t\tvar day = date.getDate();\n\t\tvar ampm = \"AM\";\n\n\t\tif (hour...
[ "0.8220673", "0.81059754", "0.81059754", "0.81020766", "0.8086411", "0.80284166", "0.8005713", "0.79568255", "0.78277886", "0.7800676", "0.77455884", "0.7718477", "0.77026117", "0.76925457", "0.7666346", "0.7655977", "0.7650111", "0.7639872", "0.75995934", "0.7588122", "0.758...
0.0
-1
Write password to the password input
function writePassword() { var password = generatePassword(); var passwordText = document.querySelector("#password"); passwordText.value = password; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function writePassword() {}", "function writePassword() {\n var password = getPasswordOptions();\n var passwordText = document.querySelector('#password');\n \n passwordText.value = password;\n }", "function writePassword() {\n var password = generatePassword();\n var passwordText = document.qu...
[ "0.8859371", "0.85438496", "0.8511671", "0.8501158", "0.8490387", "0.848501", "0.8472282", "0.8468989", "0.845468", "0.8444224", "0.84319127", "0.8420268", "0.8419394", "0.84066415", "0.8404136", "0.8400749", "0.8393203", "0.83766234", "0.83703816", "0.83647054", "0.83603424"...
0.0
-1
Function to randomize the contents of an array using a FisherYates shuffle.
function shuffle(array) { var m = array.length, t, i; while (m) { i = Math.floor(Math.random() * m--); t = array[m]; array[m] = array[i]; array[i] = t; } return array; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function fisherYates( array ){\n var count = array.length,\n randomnumber,\n temp;\n let lastTime = performance.now();\n while( count ){\n randomnumber = Math.random() * count-- | 0;\n temp = array[count];\n array[count] = array[randomnumber];\n array[randomnumber] = temp\n if (count % ...
[ "0.79371905", "0.79177195", "0.7914589", "0.78819424", "0.7864475", "0.7863797", "0.7858038", "0.7857936", "0.78462774", "0.7832736", "0.7829921", "0.78258395", "0.78240955", "0.78211397", "0.78141314", "0.7805906", "0.7805508", "0.78050596", "0.7803428", "0.7800158", "0.7793...
0.7824302
12
Function to create random integer
function getRandomInt(max) { return Math.floor(Math.random() * Math.floor(max)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function generateNumber() {\n return Math.floor(Math.random() * 256);\n }", "function getRandomInt(){\n return Math.floor(Math.random() * 10);\n}", "function randomInt_1_10(){\n\treturn Math.floor(Math.random()*(10-1))+1;\n}", "function getRandomNumber () {}", "function randomint(){\n\tvar x = M...
[ "0.80871224", "0.78889674", "0.786766", "0.78554755", "0.78318495", "0.7823074", "0.7811263", "0.7799612", "0.77730757", "0.7770198", "0.7757815", "0.7737801", "0.7731033", "0.7724623", "0.7718095", "0.77123886", "0.7706171", "0.7704853", "0.7704505", "0.7671307", "0.766843",...
0.0
-1
start in null instead of false to start with spinner
componentWillMount() { firebase.initializeApp( { apiKey: Config.API_KEY, authDomain: Config.AUTH_DOMAIN, databaseURL: Config.DATABASE_URL, projectId: Config.PROJECT_ID, storageBucket: Config.STORAGE_BUCKET, messagingSenderId: Config.MESSAGING_SENDER_ID }); firebase.auth().onAuthStateChanged((user) => { if (user) { this.setState({ loggedIn: true }); } else { this.setState({ loggedIn: false }); } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function showSpinner(){\n \tspinTarget.show();\n\t\tspinner.spin(spinTarget[0]);\n }", "function spinner_modifier(fn){return function(){var previous=this.element.val();fn.apply(this,arguments);this._refresh();if(previous!==this.element.val()){this._trigger(\"change\")}}}", "function spinner_modifier(fn){...
[ "0.6735049", "0.66097325", "0.65607125", "0.65552855", "0.652931", "0.64487964", "0.6442305", "0.63579625", "0.63573855", "0.6344712", "0.6260593", "0.62505543", "0.621469", "0.6212818", "0.62084234", "0.62026036", "0.61600375", "0.6154299", "0.6154299", "0.6154299", "0.61526...
0.0
-1
Like user by ID. sender_id is generated from localStorage, receiver_id is typed in in frontend
function likeUser(like) { return new Promise((resolve, reject) => { var sql = `INSERT INTO [GK7].likes (sender_id, receiver_id) VALUES (@sender_id, @receiver_id)` const request = new Request(sql, (err) => { if (err) { reject(err) console.log(err) } }); request.addParameter('sender_id', TYPES.Int, like.sender_id) request.addParameter('receiver_id', TYPES.Int, like.receiver_id) request.on('requestCompleted', (row) => { resolve('Like inserted', row) console.log('like inserted') // checkMatch() }); connection.execSql(request); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function like() {\n LikeService.post(vm.user.username, $stateParams.id, vm.currentUser)\n .then(() => {\n loadLikes();\n vm.isLiked = true;\n\n // send notification to the given user\n if (vm.user._id != vm.currentUser._id) {\n ...
[ "0.7226867", "0.6882414", "0.6686427", "0.6437629", "0.63383657", "0.62563604", "0.6171645", "0.6171558", "0.61456615", "0.6130881", "0.6097248", "0.60502404", "0.60463125", "0.6009326", "0.5979843", "0.5970867", "0.59693384", "0.5932927", "0.59296644", "0.5920503", "0.591449...
0.61116666
10
Boot up the Native Messaging and establish a connection with the host, indicated by hostName
function connect() { var hostName = "com.google.chrome.example.echo"; port = chrome.runtime.connectNative(hostName); port.onMessage.addListener(onNativeMessage); port.onDisconnect.addListener(onDisconnected); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "connect() {\n\t\tthis._communicator.connect();\n\t}", "function connect() {\n console.log(\"Connecting to `\" + localStorage.broker + \"` on port `\" + localStorage.port + \"`\");\n var clientId = \"myclientid_\" + parseInt(Math.random() * 100, 10);\n\n client = new Messaging.Client(localStorage.broker,...
[ "0.5986448", "0.58668643", "0.5841325", "0.5841325", "0.5785808", "0.57438385", "0.5655347", "0.5622621", "0.56021273", "0.55080324", "0.54482317", "0.54211783", "0.5416453", "0.54157996", "0.5405801", "0.535047", "0.53294265", "0.5316533", "0.5309893", "0.5305062", "0.530001...
0.60736364
0
Send a Native Message to the Python Application, containing the URL of the current tab
function sendNativeMessage(message) { // If port is open, send message if (port) { port.postMessage(message); console.log("Sent message: " + JSON.stringify(message)); } // Else, start up a connection and then send the message else { connect(); port.postMessage(message); console.log("Sent message: " + JSON.stringify(message)); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sendMessageToActiveTab(message, function_) {\n browser.tabs.query({\n currentWindow: true,\n active: true\n }).then(tabs => {\n for (let tab of tabs) {\n browser.tabs.sendMessage(\n tab.id,\n message\n ...
[ "0.66210353", "0.65937024", "0.6558327", "0.6447561", "0.64204913", "0.6333605", "0.63186896", "0.62911415", "0.6269889", "0.6247669", "0.62449896", "0.6198687", "0.61555487", "0.61379516", "0.61308444", "0.61081505", "0.60728145", "0.6053696", "0.60473967", "0.604059", "0.60...
0.0
-1
When it receives a message, update the fields accordingly
function onNativeMessage(message) { document.getElementById('username').value = message['username']; document.getElementById('passwd').value = message['password']; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function messageChanged(event) {\r\n var value = (event ? event.target.value : undefined);\r\n // Update data\r\n updateMessage(value);\r\n // Update settings\r\n settings.msg = value;\r\n piSaveSettings();\r\n }", "function handleMessageChange(event) {\n const nam...
[ "0.68784744", "0.6605492", "0.65390354", "0.6449496", "0.641622", "0.6282208", "0.62541574", "0.61743677", "0.6152933", "0.61390966", "0.61259294", "0.6114855", "0.6113724", "0.6100701", "0.6077725", "0.6067522", "0.605933", "0.6027558", "0.59991044", "0.5992268", "0.59915566...
0.0
-1
When disconnected from host, set port to null value so that it may reconnect at the next request
function onDisconnected() { console.log("Failed to connect: " + chrome.runtime.lastError.message); port = null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static set port(value) {}", "repickHost() {\n this.host = null;\n var newHostId = Object.keys(this.socketNames)[0];\n this.host = newHostId ? newHostId : null;\n }", "reset() {\n this.socket = this._newSocket();\n }", "get port() { return this._port; }", "reassignHostSocke...
[ "0.66604096", "0.6570076", "0.64096314", "0.6310094", "0.6273757", "0.6256183", "0.6221901", "0.6196667", "0.6173534", "0.6066822", "0.6055589", "0.6055589", "0.6052514", "0.6027057", "0.60181713", "0.60075426", "0.5991197", "0.5986552", "0.5976626", "0.5960655", "0.59246415"...
0.6781185
0
Flip between a hidden password field and a regular text field
function showPassword() { let button = document.getElementById('show-button'); let password_field = document.getElementById('passwd'); // If currently showing the password if (password_field.type == 'text') { password_field.type = 'password'; button.innerHTML = 'Show'; } else { password_field.type = 'text'; button.innerHTML = 'Hide'; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function showHiddenPassword() {\n let passwordInputField = document.getElementById(\"password\");\n if (passwordInputField.type === \"password\") {\n passwordInputField.type = \"text\";\n } else {\n passwordInputField.type = \"password\";\n }\n}", "function showHidePass() {\n var x =...
[ "0.7626358", "0.7535852", "0.74935126", "0.74562305", "0.7447047", "0.7408543", "0.7390033", "0.7378369", "0.7378205", "0.7374696", "0.7314512", "0.7306947", "0.7304331", "0.73033947", "0.7260504", "0.7230187", "0.72220725", "0.7171458", "0.7159209", "0.71274465", "0.71120465...
0.73151886
10
After 5 hours of debugging, I found out that sometimes the content script does not get automatically injected. Therefore, I ensure that the content script becomes injected by executing it explicitly.
function ensureSendMessage(tabId, message, callback){ chrome.tabs.executeScript(tabId, {file: "cscript.js"}, function(){ if(chrome.runtime.lastError) { console.error(chrome.runtime.lastError); throw Error("Unable to inject script into tab " + tabId); } // Now it's injected and ready, so send the message to the correct tab chrome.tabs.sendMessage(tabId, message, callback); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function injectScript() {\n log('Content script injected a \"detectable\" script');\n\n const injectScript = document.createElement('script');\n injectScript.type = 'text/javascript';\n injectScript.innerHTML = `\n (function() {\n // just for logging\n const msg = 'Content script executed the \"...
[ "0.6764311", "0.67226905", "0.6652307", "0.65300083", "0.648088", "0.63694453", "0.6362446", "0.6333144", "0.60529995", "0.6031968", "0.598077", "0.5952544", "0.59380627", "0.59284914", "0.5928205", "0.5913311", "0.5912139", "0.5906892", "0.5904725", "0.5849885", "0.58398265"...
0.5210339
82
Search Bar Dont Touch
function myFunction() { input = document.getElementById("myInput"); filter = input.value.toUpperCase(); table = document.getElementById("donorContents"); tr = table.getElementsByTagName("tr"); for (i = 0; i < tr.length; i++) { td = tr[i].getElementsByTagName("td")[0]; if (td) { txtValue = td.textContent || td.innerText; if (txtValue.toUpperCase().indexOf(filter) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function searchthis(e){\n $.search.value = \"keyword to search\";\n $.search.blur();\n focused = false;\n needclear = true;\n}", "function focusSearchBoxListener(){ $('#query').val('').focus() }", "search(e){\n \n\t e.preventDefault();\n\t let input = document.querySelector('#photo-search');\n\t ...
[ "0.74653494", "0.7185204", "0.71799463", "0.7064914", "0.70223504", "0.70223504", "0.7007839", "0.69741684", "0.6968857", "0.69623065", "0.69113153", "0.6891925", "0.68889374", "0.6871818", "0.6863558", "0.6846418", "0.68369764", "0.68369764", "0.68369764", "0.6825098", "0.68...
0.0
-1
const comments_data = comments.comments;
render() { if (this.props.comments !== []) { return ( <Fragment> <AddComment /> <div className='container-sm '> {this.props.comments.map(comment => ( <div className=' card border-secondary mb-3' key={comment.id} > <div className="card-header"> <div className="text-info">@ {comment.author} </div> </div> <div className="card-body mx-4"> <div>{comment.content}</div> <div className=" font-weight-light text-muted text-right mr-5">{comment.created_at}</div> </div> </div> ))} </div> </Fragment> ) } else { return null; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "getAll() {\n return {\n comments: _comments\n };\n }", "getComments(){\n\n }", "_getComments() {\n const caption = this.caption.value.trim();\n\n if (!caption) return {};\n\n const { uid, username } = this.props.currentUser;\n const commentId = generateID('comment-');\n console.log(...
[ "0.77555406", "0.7206142", "0.6863943", "0.67627776", "0.6723962", "0.66820943", "0.6641964", "0.6530375", "0.65296185", "0.65054595", "0.64678425", "0.64259714", "0.63972294", "0.6388312", "0.6386385", "0.6211964", "0.61944175", "0.61944175", "0.61881816", "0.6176987", "0.61...
0.0
-1
take avg speed in min
componentWillReceiveProps(nextProps) { }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_getAverageSpeed()\r\n {\r\n let endTime = Date.now()\r\n // Get elapsed time in seconds.\r\n let elapsedTime = (endTime - this._startTime) / 1000;\r\n\r\n // Return average speed in m/s.\r\n return this._totalDistance / elapsedTime;\r\n }", "averageSpeed(){\n var ...
[ "0.7375608", "0.7062403", "0.6942398", "0.6856782", "0.67140955", "0.664992", "0.65732014", "0.6550614", "0.64540654", "0.63804847", "0.628317", "0.6246495", "0.6246305", "0.6243768", "0.6196168", "0.6167225", "0.60871404", "0.60601366", "0.6036089", "0.60248196", "0.59943926...
0.0
-1
move_state return run state snake_state up: draw down:
constructor(cur) { this.cur = cur; this.state = "runnable"; this.move_state = "null"; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function snakeMove() {\n\t\t\n\t\tif (snake.direction.x == UP.x && snake.direction.y == UP.y && NEXT_DIRECTION.x != DOWN.x && NEXT_DIRECTION.y != DOWN.y)\n\t\t\tsnake.direction = NEXT_DIRECTION;\n\n\t\tif (snake.direction.x == DOWN.x && snake.direction.y == DOWN.y && NEXT_DIRECTION.x != UP.x && NEXT_DIRECTION.y !=...
[ "0.7366036", "0.71729314", "0.7159492", "0.71536195", "0.7135584", "0.7105555", "0.6987568", "0.6974797", "0.69314945", "0.69286644", "0.6908212", "0.68527406", "0.6848052", "0.67981833", "0.67261535", "0.67235726", "0.6669215", "0.6637938", "0.6611165", "0.6589315", "0.65816...
0.0
-1
Update minicart qty on add to cart
function update_cqty(){ $.get("/wp-admin/admin-ajax.php", { action: 'cart_qty' }).then(function(res){ $('i#cqty').text(res); if (res != 0) $('i#cqty').addClass('visible'); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateQuantity() {\n let prod = this.closest(\".cart-item\");\n let prod_cost = prod.children[2].innerText.slice(1);\n prod.children[4].innerText = `$${Number(prod_cost)*this.value}`\n\n let z = JSON.parse(localStorage.getItem(\"CartItem\"));\n arr = [];\n for (let k = 0; k < Object.keys(z).length; ...
[ "0.76549107", "0.7472356", "0.73232776", "0.7242217", "0.7199553", "0.71862316", "0.71473205", "0.7066441", "0.7063071", "0.7050778", "0.70344615", "0.70184684", "0.7004955", "0.69976413", "0.697558", "0.6970132", "0.6938334", "0.69203526", "0.68757105", "0.6842128", "0.68308...
0.6294214
96
fjx end make room for footer
function giveFooterSomeRoom() { footer = $('footer#footer'); padding = footer.outerHeight(); $('body').css('padding-bottom',padding); // console.log('padding applied'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "renderFooter() {\n return null;\n }", "function footerBottom(){\n\tvar $footer = $('.footer');\n\tif($footer.length){\n\t\tvar $tplSpacer = $('<div />', {\n\t\t\tclass: 'spacer'\n\t\t});\n\n\t\t$('.main').after($tplSpacer.clone());\n\n\t\t$(window).on('load resizeByWidth', function () {\n\t\t\tvar foot...
[ "0.70745045", "0.7056424", "0.6899682", "0.6763985", "0.67632914", "0.67584825", "0.6733473", "0.6693147", "0.66610134", "0.6659243", "0.6631205", "0.6611675", "0.658502", "0.6520414", "0.65194154", "0.6506234", "0.6481181", "0.6459485", "0.64218056", "0.64146936", "0.6388369...
0.6587514
12
======================= load Game Data =======================
function loadGameData() { $.ajaxSetup({ cache: true}); $.getJSON(cavsSchedFeed, function(data){ gamenum=3; // SET GLOBAL VARIABLES game = data.gscd.g; status = game[gamenum].st; arena = game[gamenum].an; //ARENA gamedate = game[gamenum].gdte; //GAME DATE gametime = game[gamenum].etm; //GAME TIME EST DATE&TIME gameID = game[gamenum].gid; //GAME ID gcode = game[gamenum].gcode; //GAME CODE gametimeFormatted = moment(game[gamenum].etm).format('dddd, MMMM D, YYYY') + ' AT ' + moment(game[gamenum].etm).format('h:mm A')+' (ET)'; if (cavsTID == data.gscd.g[gamenum].h.tid){ cavsHOME = 1; } else { cavsHOME = 0; } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function loadGameData()\n\t\t\t{\n\t\t\t\tif(gameName == \"fatcat7\")\n\t\t\t\t{\n\t\t\t\t\tgame = new FatCat7Game();\n\t\t\t\t\tisFreeSpinGame = true;\n\t\t\t\t}\n\t\t\t\telse if(gameName == \"bounty\")\n\t\t\t\t{\n\t\t\t\t\tgame = new BountyGame();\n\t\t\t\t\tisFreeSpinGame = true;\n\t\t\t\t}\n\t\t\t\telse if(ga...
[ "0.832943", "0.7465807", "0.74487615", "0.7436724", "0.72135866", "0.7212503", "0.71787655", "0.71692055", "0.716024", "0.715377", "0.71502906", "0.7088876", "0.70205617", "0.6937962", "0.69130236", "0.6887177", "0.68501824", "0.6840369", "0.67668706", "0.6748402", "0.674673"...
0.0
-1
end function / ======================= /load Game Data ======================= / ======================= gameIsOn =======================
function gameIsOn() { $.ajaxSetup({ cache: true}); $.getJSON("http://data.nba.com/data/v2015/json/mobile_teams/nba/2016/scores/gamedetail/" + gameID + "_gamedetail.json", function(data){ var period = data.g.p; var gamestatus = data.g.stt; gameStatus = data.g["st"]; if (period === null || period == "0") { loadScoreboardPregame(); } else { loadScoreboardInGame(); if (gamestatus != "Final") { setInterval("loadScoreboardInGame()",10000); } if (gamestatus == "Final") { clearInterval("loadScoreboardInGame"); //clear interval } } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function loadGameData()\n\t\t\t{\n\t\t\t\tif(gameName == \"fatcat7\")\n\t\t\t\t{\n\t\t\t\t\tgame = new FatCat7Game();\n\t\t\t\t\tisFreeSpinGame = true;\n\t\t\t\t}\n\t\t\t\telse if(gameName == \"bounty\")\n\t\t\t\t{\n\t\t\t\t\tgame = new BountyGame();\n\t\t\t\t\tisFreeSpinGame = true;\n\t\t\t\t}\n\t\t\t\telse if(ga...
[ "0.75656825", "0.70133024", "0.69153625", "0.68950796", "0.68268734", "0.6727736", "0.6632979", "0.6601244", "0.65660226", "0.65291476", "0.6516658", "0.6509726", "0.6483329", "0.64826924", "0.6466582", "0.6435801", "0.64244217", "0.6415155", "0.6414446", "0.6345895", "0.6344...
0.6176463
34
end function / ======================= /gameIsOn ======================= / ======================= clearInterval =======================
function stopFunction(variabletoclear) { clearInterval(variabletoclear); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function endgame() {\n \tclearInterval(intervalId);\n }", "function endOfGame() {\n clearInterval(gameInterval)\n}", "function overEnd(){\n\tif(game_state === false){\n\t\tdocument.getElementById(\"status\").innerHTML = \"you wON!!! in \"+ Math.round(10*totaltime)/10 + \" seconds .... congrats\";\n\t\tc...
[ "0.85136807", "0.80926424", "0.8078578", "0.8032116", "0.80034727", "0.7834107", "0.77534765", "0.769874", "0.7694725", "0.766323", "0.7648194", "0.76449883", "0.7633983", "0.762984", "0.76265484", "0.75887346", "0.75628215", "0.75583", "0.7530165", "0.7516167", "0.75114644",...
0.0
-1
======================= /clearInterval ======================= / ======================= loadScoreboardPregame =======================
function loadScoreboardPregame() { $.ajaxSetup({ cache: true}); $.getJSON("http://data.nba.com/data/v2015/json/mobile_teams/nba/2016/teams/cavaliers_schedule_" + seasontype + ".json", function(data){ var game = data.gscd.g; var status = game[gamenum].st; var status = game[gamenum].st; var cavsscore; var oppscore; if (cavsHOME == 1){ cavsscore = game[gamenum].h["re"]; oppscore = game[gamenum].v["re"]; } else { cavsscore = game[gamenum].v["re"]; oppscore = game[gamenum].h["re"]; } document.getElementById("opp-score").innerHTML="2-1"; document.getElementById("cavs-score").innerHTML="3-0"; }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function stopScoreCounter() {\n\tclearInterval(scoreCounterID);\n}", "function endGame() {\n clearInterval(interval);\n console.log('ended');\n pointsEl.innerText = score;\n resultEl.classList.toggle('hide');\n containerEl[0].classList.toggle('hide');\n var savedGames = localStorage.getItem('la...
[ "0.67429125", "0.6598286", "0.654588", "0.64863074", "0.6381481", "0.6356312", "0.62945443", "0.6277964", "0.62753737", "0.6270995", "0.6263602", "0.6252848", "0.62359345", "0.62089753", "0.61955774", "0.6189881", "0.61882865", "0.6148888", "0.61374825", "0.61360276", "0.6125...
0.6020974
33
end function / ======================= /loadScoreboardPregame ======================= / ======================= loadScoreboardInGame =======================
function loadScoreboardInGame() { $.ajaxSetup({ cache: true}); $.getJSON("http://data.nba.com/data/v2015/json/mobile_teams/nba/2016/scores/gamedetail/" + gameID + "_gamedetail.json", function(data){ var gamestatus = data.g["stt"]; var clock = data.g["cl"]; if (cavsHOME == 1){ var oppBox = data.g.vls["s"]; var cavsBox = data.g.hls["s"]; } else { var oppBox = data.g.hls["s"]; var cavsBox = data.g.vls["s"]; } if (gamestatus == "Halftime" || gamestatus == "Final") { var status = gamestatus; } else { var status = clock + ' - '+ gamestatus; //clock + ' - '+ gamestatus } document.getElementById("opp-score").innerHTML=oppBox; document.getElementById("cavs-score").innerHTML=cavsBox; document.getElementById("api-gameday").innerHTML=status; }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "load() {\n if (!!this.saveArray) {\n this.board = this.saveArray[0];\n this.currentColour = this.saveArray[1];\n this.currentColour == 'white' ? this.otherColour = 'black' : this.otherColour = 'white';\n this.displayBoard();\n console.log(\"game loaded\...
[ "0.67326576", "0.66934097", "0.6648998", "0.6632899", "0.66081715", "0.65841883", "0.65496093", "0.6536842", "0.6523126", "0.6519258", "0.6493572", "0.64858127", "0.6477509", "0.64551646", "0.64450794", "0.6436424", "0.64295477", "0.63991106", "0.63955563", "0.6362934", "0.63...
0.6201317
33
possibly pass the field from the home page to state dynamically render these buttons i.e application sent field is not null sent to state somehow lift clicks to info block
handleInProgressClick() { this.setState({status:"in progress"}); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "buttonHandler(){\n\t\tvar items = this.props.hey.questions.present;\n\t\tlet conditions = this.props.hey.conditions.present;\n\t\tlet counter = this.props.hey.counter.present;\n\t\tconst action = this.props.action;\n\t\tconst increment = this.props.increment;\n\t\tconst hide = this.props.hideState;\n\t\tsendButton...
[ "0.6089963", "0.59777766", "0.5933643", "0.58554906", "0.5790299", "0.5788316", "0.5788304", "0.5757041", "0.57564163", "0.57531714", "0.5730086", "0.5710133", "0.56823206", "0.5656171", "0.56537056", "0.5647323", "0.56417894", "0.5635744", "0.56275254", "0.5616315", "0.56158...
0.0
-1
O(n) = n creates an array of fibonaci sequence up num elements var array = []
function fibonacci(num) { console.log(num) if (num <= 1) { // todo investigate the time complexity of .push() //array.push(num) return 1 } return fibonacci(num - 1) + fibonacci(num - 2) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function fibonacciArray(n) {\n var fibArr = [0, 1];\n for(i = 0; i<n; i++){\n if(i>fibArr[0])\n fibArr.push(fibArr[i] + fibArr[i-1])\n }\n\n return fibArr;\n}", "function fibonacci(n) {\r\nvar arr=[];\r\n for(let i=0; i<n;i++){\r\n arr.push(i);\r\n }\r\n for(let i=2;i<n;i++)...
[ "0.81787026", "0.8122116", "0.8078144", "0.8035182", "0.8009666", "0.8007194", "0.80036074", "0.79910487", "0.7983444", "0.7926307", "0.786116", "0.78486824", "0.7833397", "0.7828305", "0.780592", "0.77885205", "0.7776408", "0.77759063", "0.7675666", "0.7638117", "0.76378965"...
0.0
-1
lets you read chars, and optionally reset the cursor to where it was before reading
function createCharReader (nextChar, rewind) { let charsRead = 0 return { nextChar () { charsRead += 1 return nextChar() }, reset () { rewind(charsRead) charsRead = 0 }, rewind (n = 1) { rewind(n) charsRead -= n } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "read() {\n if (this.pos < this.size) {\n this.ch = this.input.charCodeAt(this.pos++);\n } else {\n this.ch = -1;\n }\n }", "function reconsumeCurrentCharacter() {\n charIdx--;\n }", "function reconsumeCurrentCharacter() {\n charIdx--;\n }", "consumeChar() {\n th...
[ "0.68927795", "0.6730734", "0.6730292", "0.66110456", "0.60455966", "0.6025901", "0.60009164", "0.5993873", "0.59305906", "0.58947945", "0.5889436", "0.5819896", "0.5789997", "0.5736562", "0.5698434", "0.5668249", "0.5667952", "0.563466", "0.5617069", "0.5617069", "0.5615207"...
0.5672642
15
Essa function deve adicionar o valor digitado ao vetor valores e ao select:
function adicionar() { if(!isNumber(txtNumero.value) || inList(txtNumero.value, valores)) { // Lê-se: Se *txtNumero* não for um número válido (function isNumber) ou *txtNumero* for encontrado no vetor valores (function inList), então: window.alert('Valor inválido ou já encontrado na lista.') } else { // senão var numero = Number(txtNumero.value) // Não precisa criar essa variável convertida em Number valores.push(numero) var item = document.createElement('option') item.text = `Valor ${numero} adicionado.` item.value = numero listagem.appendChild(item) resultado.innerHTML = '' // Limpa os valores do resultado. } txtNumero.value = '' // Limpar a caixa de entrada ao final da execução da function adicionar() txtNumero.focus() // Colocar o cursor na caixa de entrada ao final da execução da function adicionar() clearButton.style.display = null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validarSelect(texto, identificador) {\n\n if (texto != '') {\n $(identificador).val(texto);\n }\n}", "function fillDataModal(codigo, grado, seccion, nivel) {\n \n $(\"#modaltxtCodigo\").val(codigo);\n $(\"#modaltxtGrado\").val(grado);\n $(\"#modaltxtSeccion\").val(seccion);\n ...
[ "0.63570154", "0.6355307", "0.6221464", "0.62008387", "0.6125581", "0.6115057", "0.6102905", "0.60735846", "0.6062825", "0.6053935", "0.60302675", "0.6024002", "0.6011378", "0.5986135", "0.59816086", "0.59796655", "0.59340286", "0.59290844", "0.5920496", "0.59200454", "0.5916...
0.5626096
68
Checks if user exists
userExists(user) { // Temp variable for storing the user if found let temp = ''; for (let i of this.users) { if (i === user) { console.log('user: ' + user + ' exists'); temp = user; } } let exists = (temp !== '' && temp === user); if(temp === '') console.log('user: ' + user + ' does not exist'); return exists; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function checkIfUserExists (callback) { \n connection.query(`SELECT * FROM user WHERE userid=${connection.escape(id)}`, (err, res)=>{\n if (err) {message.channel.send(embeds.errorOccured(message, err));}\n callback(res[0] !== undefined); \n });\n }", "do...
[ "0.79687506", "0.7584125", "0.75582564", "0.74154276", "0.7377348", "0.735639", "0.73032147", "0.7255049", "0.72392005", "0.7198557", "0.7176431", "0.71550107", "0.71477497", "0.7145939", "0.7123984", "0.711027", "0.7105413", "0.7101344", "0.70521605", "0.70515674", "0.704523...
0.6704347
40
Gets index of an element in an array
idx(element, array) { let cont=0; for (let i of array) { if (i === element) { return cont; } cont += 1; } return cont; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function indexOfArray(arr,index){\r\n\treturn arr[index]\r\n}", "function indexOfArray(arr,i){\n \n return arr[i];\n }", "function getIndex (item, array) {\n for (var i = 0; i < array.length; i++){\n if (item==array[i][1]){\n return i;\n }\n }\n return undefined;\n...
[ "0.7871964", "0.780925", "0.7764285", "0.7756045", "0.7736787", "0.7694301", "0.765524", "0.7620825", "0.75880283", "0.7522415", "0.74995375", "0.74845576", "0.7444055", "0.74311584", "0.74198276", "0.73977965", "0.7361471", "0.73556465", "0.73540646", "0.73262554", "0.732247...
0.76458997
7
!svg4everybody v2.1.9 | github.com/jonathantneal/svg4everybody
function e(e, t, n) { if (n) { var i = document.createDocumentFragment(), a = !t.hasAttribute("viewBox") && n.getAttribute("viewBox"); a && t.setAttribute("viewBox", a); for (var o = n.cloneNode(!0); o.childNodes.length; ) i.appendChild(o.firstChild); e.appendChild(i); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function SVGShape() {}", "drawSvg() {\n \n\t}", "function SVGWrap() {}", "function SigmaEnableSVG() {\n return null;\n}", "function downloadPNG4x() {\n document.getElementById('svg').removeAttribute('style');\n panZoomInstance.moveTo(0, 0);\n panZoomInstance.zoomAbs(0, 0, 1);\n saveSvgA...
[ "0.681207", "0.6802218", "0.6594786", "0.6592946", "0.65826154", "0.65720546", "0.65580416", "0.6555005", "0.64601684", "0.6428496", "0.6428496", "0.6428496", "0.6428496", "0.6428496", "0.6428496", "0.64047587", "0.62305236", "0.622013", "0.6213995", "0.6213662", "0.6190503",...
0.0
-1
The `wrapper` function encapsulates all of the throttling / debouncing functionality and when executed will limit the rate at which `callback` is executed.
function wrapper() { var that = this, elapsed = +new Date() - last_exec, args = arguments; // Execute `callback` and update the `last_exec` timestamp. function exec() { last_exec = +new Date(); callback.apply( that, args ); }; // If `debounce_mode` is true (at_begin) this is used to clear the flag // to allow future `callback` executions. function clear() { timeout_id = undefined; }; if ( debounce_mode && !timeout_id ) { // Since `wrapper` is being called for the first time and // `debounce_mode` is true (at_begin), execute `callback`. exec(); } // Clear any existing timeout. timeout_id && clearTimeout( timeout_id ); if ( debounce_mode === undefined && elapsed > delay ) { // In throttle mode, if `delay` time has been exceeded, execute // `callback`. exec(); } else if ( no_trailing !== true ) { // In trailing throttle mode, since `delay` time has not been // exceeded, schedule `callback` to execute `delay` ms after most // recent execution. // // If `debounce_mode` is true (at_begin), schedule `clear` to execute // after `delay` ms. // // If `debounce_mode` is false (at end), schedule `callback` to // execute after `delay` ms. timeout_id = setTimeout( debounce_mode ? clear : exec, debounce_mode === undefined ? delay - elapsed : delay ); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function wrapper () {\n\t\n\t\t\tvar self = this;\n\t\t\tvar elapsed = Number(new Date()) - lastExec;\n\t\t\tvar args = arguments;\n\t\n\t\t\t// Execute `callback` and update the `lastExec` timestamp.\n\t\t\tfunction exec () {\n\t\t\t\tlastExec = Number(new Date());\n\t\t\t\tcallback.apply(self, args);\n\t\t\t}\n\...
[ "0.765537", "0.7569833", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.75173116", "0.7513246", ...
0.72283226
26
Execute `callback` and update the `last_exec` timestamp.
function exec() { last_exec = +new Date(); callback.apply( that, args ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function exec() {\n lastExec = Date.now();\n callback.apply(self, arguments_);\n }", "function exec() {\n lastExec = Date.now();\n callback.apply(self, arguments_);\n }", "function exec() {\n\t lastExec = Date.now();\n\t callback.apply(self, arguments_);\n\t }", "functi...
[ "0.745563", "0.745563", "0.73525447", "0.73505646", "0.7145095", "0.713012", "0.713012", "0.713012", "0.713012", "0.713012", "0.713012", "0.713012", "0.713012", "0.713012", "0.713012", "0.713012", "0.713012", "0.713012", "0.713012", "0.713012", "0.713012", "0.713012", "0....
0.73532254
2
If `debounce_mode` is true (at_begin) this is used to clear the flag to allow future `callback` executions.
function clear() { timeout_id = undefined; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function exec(){lastExec=Number(new Date());callback.apply(self,args);}// If `debounceMode` is true (at begin) this is used to clear the flag", "function exec(){lastExec=Number(new Date());callback.apply(self,args);}// If `debounceMode` is true (at begin) this is used to clear the flag", "function debounce(cal...
[ "0.75560945", "0.75560945", "0.6904754", "0.6462211", "0.6396409", "0.6329464", "0.6309382", "0.62771076", "0.62468845", "0.61616087", "0.6072329", "0.6065627", "0.59272814", "0.59272814", "0.59272814", "0.5901284", "0.5894402", "0.58854216", "0.58772767", "0.585909", "0.5831...
0.0
-1
Update Total calculate total of items in the cart
updateTotal() { let total = 0; for (let index in this.items) { let item = this.items[index]; total += item.price * item.quantity; } this.total = total; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function total() {\n let totalVal = 0;\n for (var i = 0; i < cartItems.length; i++) {\n totalVal += cartItems[i].price * cartItems[i].quantity\n }\n setCartTotal(totalVal)\n }", "function updateTotal() {\n var total = 0;\n $('.cart-item-price').each(function() {\n total...
[ "0.8479078", "0.84645617", "0.8419032", "0.8037263", "0.79097944", "0.7671906", "0.7626656", "0.7609956", "0.76039535", "0.7600465", "0.7585691", "0.7503699", "0.7468547", "0.7467062", "0.74488014", "0.7448752", "0.74331045", "0.74086994", "0.74055725", "0.7384999", "0.736265...
0.8257361
3
Add Item add an item to the cart
addItem(newItem) { for (let index in this.items) { let item = this.items[index]; if (item.id === newItem.id) { item.quantity += newItem.quantity; this.updateTotal(); return; } } this.items.push(newItem); this.updateTotal(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addItemToCart() {}", "function addItemToCart() {}", "function addItemToCart(user, item) {}", "function addToCart(item) {\n\t// create item in cart\n\tconst row = document.createElement('tr');\n\n\trow.innerHTML = `\n\t\t<td>\n\t\t\t<img src=\"${item.image}\">\n\t\t</td>\n\t\t<td>\n\t\t\t${item.title...
[ "0.8870365", "0.8870365", "0.8317082", "0.80768555", "0.80542094", "0.8030135", "0.7986383", "0.7953447", "0.7953234", "0.7932324", "0.7927464", "0.78722477", "0.78524226", "0.7743222", "0.7735881", "0.77150446", "0.76887846", "0.7688012", "0.76775503", "0.76739985", "0.76161...
0.7096832
70
To JSON get a json representation of the cart data
toJson() { return { items: this.items, total: this.total } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function packIntoJson(userId, ingredientId, ingredientName, quantity){\n\tvar cartJson = new Object();\n\tcartJson.userId = userId;\n\tcartJson.ingredientId = ingredientId;\n\tcartJson.ingredientName = ingredientName;\n\tcartJson.quantity = quantity;\n\tconsole.log(\"JSON\");\n\tconsole.log(cartJson);\n\t//console...
[ "0.71448916", "0.65240455", "0.6489727", "0.64562005", "0.64469624", "0.64362985", "0.64188296", "0.64175403", "0.6333861", "0.6271095", "0.6180868", "0.6175653", "0.6166541", "0.61517256", "0.61146414", "0.6060924", "0.60552514", "0.60545826", "0.60484165", "0.60267586", "0....
0.62578374
10
removing listener to prevent memory leaks
componentWillUnmount() { this.props.firebase .land() .orderByChild("userID") .equalTo(this.props.firebase.auth.currentUser.uid) .off(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "removeListeners() {}", "removeListeners() {}", "removeListeners() {}", "function removeEventListeners(){\n _.forEach(unlistenCallbacks, function(unlisten){\n unlisten();\n });\n unlistenCallbacks = [];\n }", "removeAllListeners() {\n this.listen...
[ "0.7938648", "0.7938648", "0.7938648", "0.7649334", "0.76439846", "0.75743467", "0.75743467", "0.75743467", "0.75743467", "0.75743467", "0.75559336", "0.75544506", "0.7526184", "0.7483317", "0.7450182", "0.74224734", "0.7407818", "0.73894876", "0.73651236", "0.73651236", "0.7...
0.0
-1
TODO: same as trip selection
function setMouseOver (polyline, streetname) { polyline.on('mouseover', function (e) { let layer = e.target; layer.setStyle({ color: '#000', opacity: 1}); layer.bindTooltip('<strong>Activate ' + streetname + '</strong>'); }); return; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "copyAirwaySelections() {\n const temporaryFPWaypoints = this.flightPlanManager.getWaypoints(1);\n const activeFPWaypoints = this.flightPlanManager.getWaypoints(0);\n for (let i = 0; i < activeFPWaypoints.length; i++) {\n if (activeFPWaypoints[i].infos && temporaryFPWaypoints[i] && a...
[ "0.5501157", "0.5169022", "0.5119497", "0.51169765", "0.5084151", "0.50048494", "0.49870422", "0.4983171", "0.4978363", "0.49504626", "0.4941138", "0.49386263", "0.49356747", "0.49257678", "0.49112976", "0.49091542", "0.4908651", "0.48787922", "0.4844551", "0.48374882", "0.48...
0.0
-1
uploaded images on mobile are typically oriented incorrectly. loadImage corrects the image orientation.
orientImage(file, callback) { window.loadImage( file, img => callback(img.toDataURL("image/png")), { canvas: true, orientation: true } ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function loadImage(image) {\n if (artwork.orientation == 'landscape') {\n context.drawImage(\n image,\n Math.abs(canvas.width / 2 - artwork.longDimension/2),\n Math.abs(canvas.height / 2 - artwork.shortDimension / 2),\n artwork.longDimension,\n artwo...
[ "0.7144427", "0.6631277", "0.645808", "0.6393823", "0.6194077", "0.60488397", "0.59705955", "0.59705955", "0.59020543", "0.5868273", "0.5816981", "0.58118296", "0.58105105", "0.5767477", "0.57385", "0.57257855", "0.5700381", "0.5699242", "0.5688993", "0.5681487", "0.5679571",...
0.687945
1
Passes the uploaded file object as well as a base 64 of the image to the onUpload callback
uploadImage(e) { const { onUpload } = this.props; let file = e.target.files[0] this.orientImage(file, (src) => { onUpload({ file, name: file.name, src }) }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "handleFile(e) {\n const reader = new FileReader();\n const file = e.target.files[0];\n\n if (!file) return;\n\n //useful for debugging base64 to images http://codebeautify.org/base64-to-image-converter\n reader.onload = function () {\n this.setState({\n cropperOpen: true,\n upload...
[ "0.69902676", "0.6935119", "0.6765236", "0.6727766", "0.6721871", "0.6705777", "0.6676353", "0.6668043", "0.66410273", "0.6615347", "0.6575097", "0.65480185", "0.6494769", "0.64868236", "0.6479687", "0.64705485", "0.6443938", "0.6443938", "0.6442665", "0.64375377", "0.6433047...
0.69668007
1
sets the functions parameter
function calcCir(r){ //var to store the math to find the circumference of a circle var circumference = 2 * Math.PI * r; //spits out the information to the outside of the function and stores it in var result return circumference; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function settingFunc() {\n\n}", "setearParams(kv, ma, md, fltr, anod) {\n\n //console.log(\"seteo nuevos parametros\");\n this.kilovolt = kv;\n this.miliamperios = ma;\n this.modo = md;\n this.filtro = fltr;\n this.anodo = anod;\n }", "function funcionParametro(fn) {\n\tfn();\n}", "addFunct...
[ "0.7052007", "0.623415", "0.61816263", "0.6029982", "0.59901214", "0.59831303", "0.5971659", "0.59289944", "0.5911817", "0.5870064", "0.58582574", "0.5833273", "0.58080906", "0.5798954", "0.57646316", "0.5731322", "0.5723741", "0.57216406", "0.57110864", "0.56904", "0.5673824...
0.0
-1
heapify the data structure around max values
maxHeapify(arr, n, i) { let largest = i; let leftIndex = 2 * i + 1; let rightIndex = 2 * i + 2; if (leftIndex < n && arr[leftIndex] > arr[largest]) { largest = leftIndex; } if (rightIndex < n && arr[rightIndex] > arr[largest]) { largest = rightIndex; } if (largest != i) { let temp = arr[i]; arr[i] = arr[largest]; arr[largest] = temp; this.maxHeapify(arr, n, largest); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function maxHeapify(arr){\n\n}", "heapify() {\n\t\t// last index is one less than the size\n\t\tlet index = this.size() - 1;\n\n\t\t/*\n Property of ith element in binary heap - \n left child is at = (2*i)th position\n right child is at = (2*i+1)th position\n parent is at ...
[ "0.76425755", "0.7590268", "0.7411874", "0.71795857", "0.7164551", "0.7093145", "0.70451295", "0.7003762", "0.6964044", "0.6957051", "0.69474083", "0.69140154", "0.6902639", "0.6899539", "0.689424", "0.68331915", "0.6778727", "0.6763307", "0.67618555", "0.67281747", "0.672785...
0.6298618
50
insert a value into the heap
insert(data) { const size = this.heap.length; if (size === 0) { this.heap.push(data); } else { this.heap.push(data); for (let i = parseInt(this.heap.length / 2 - 1); i >= 0; i--) { this.maxHeapify(this.heap, this.heap.length, i); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "insert(value) {\n // Insert value to the end of array\n // Perform siftUp to correct position of value in the heap tree\n this.heap.push(value);\n this.siftUp(this.heap.length - 1, this.heap);\n }", "insert(value) {\n\t\tthis.heap.push(value);\n\t\t// calling heapify function to reconstruct array to...
[ "0.863833", "0.8331561", "0.8072703", "0.8005249", "0.7808851", "0.7681502", "0.765279", "0.75567305", "0.75504696", "0.7541238", "0.751654", "0.74698555", "0.7361416", "0.734068", "0.71542877", "0.7149954", "0.71396136", "0.7095043", "0.70502484", "0.70256126", "0.6946853", ...
0.7637742
7
remove a specific value from the heap
remove(data) { const size = this.heap.length; let i; for (i = 0; i < size; i++) { if (data === this.heap[i]) { break; } } [this.heap[i], this.heap[size - 1]] = [this.heap[size - 1], this.heap[i]]; this.heap.splice(size - 1); for (let i = parseInt(this.heap.length / 2 - 1); i >= 0; i--) { this.maxHeapify(this.heap, this.heap.length, i); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "remove() {\n // Swap root value with last element in the heap\n // Pop the last element from heap array\n // Perform siftDown to correct position of swapped value\n // Return popped value\n this.swap(0, this.heap.length - 1, this.heap);\n const valueToRemove = this.heap.pop();\n this.siftDown(...
[ "0.80592644", "0.771712", "0.75571394", "0.75185335", "0.748075", "0.7324977", "0.7206284", "0.7075653", "0.7057192", "0.7057192", "0.6849966", "0.67913896", "0.66329116", "0.65866756", "0.6565453", "0.64938587", "0.64443773", "0.6443872", "0.6382864", "0.6373806", "0.6357709...
0.77889985
1
returns the max value from the heap
findMax() { return this.heap[0]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "extractMax() {\n\t\tconst max = this.heap[0];\n\t\tconst tmp = this.heap.pop();\n\t\tif (!this.empty()) {\n\t\t\tthis.heap[0] = tmp;\n\t\t\tthis.sinkDown(0);\n\t\t}\n\t\treturn max;\n\t}", "extractMax() {\r\n\t\tconst max = this.heap[0];\r\n\t\tthis.remove(max);\r\n\t\treturn max;\r\n\t}", "function maxHeap(va...
[ "0.82991564", "0.7957347", "0.78086686", "0.7646159", "0.7423833", "0.73725516", "0.7348753", "0.72745484", "0.72237366", "0.72114444", "0.7197894", "0.7177174", "0.7163383", "0.7146565", "0.70919085", "0.70852536", "0.70802695", "0.7070464", "0.7062798", "0.7037336", "0.7013...
0.84279215
0
removes the max value from the heap
removeMax() { this.remove(this.heap[0]); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "deleteMax() {\n // recall that we have an empty position at the very front of the array, \n // so an array length of 2 means there is only 1 item in the heap\n\n if (this.array.length === 1) return null;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// edge case- if no nodes in tree, exit\n\n if (this.array.lengt...
[ "0.8018191", "0.76265055", "0.7623531", "0.7504439", "0.74354666", "0.72889215", "0.7252715", "0.71510285", "0.71128887", "0.7089084", "0.69999665", "0.6982427", "0.6941861", "0.68232596", "0.6717149", "0.67013896", "0.6697178", "0.66557425", "0.6639741", "0.6616899", "0.6611...
0.88509464
0
stores the max value and then removes it from the heap
extractMax() { const max = this.heap[0]; this.remove(max); return max; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "removeMax() {\r\n\t\tthis.remove(this.heap[0]);\r\n\t}", "deleteMax() {\n // recall that we have an empty position at the very front of the array, \n // so an array length of 2 means there is only 1 item in the heap\n\n if (this.array.length === 1) return null;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// edge...
[ "0.8409695", "0.7879714", "0.7587512", "0.73521113", "0.7306259", "0.7145239", "0.70757776", "0.704312", "0.7007635", "0.6922104", "0.69028175", "0.6883229", "0.6675872", "0.66631365", "0.6653203", "0.6634924", "0.6612459", "0.6608291", "0.6604799", "0.6594207", "0.65926903",...
0.7318626
4
return the size of the heap
size() { return this.heap.length; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "size() {\n\t\treturn this.heap.length;\n\t}", "getHeap() {\r\n\t\treturn this.heap;\r\n\t}", "getHeap() {\r\n\t\treturn this.heap;\r\n\t}", "get size() {\n let size = 0;\n for (let i = 0; i < this.children.length; i++)\n size += this.children[i].size;\n return size;\n }", "function size() {\...
[ "0.823258", "0.6719874", "0.6719874", "0.6594933", "0.65847397", "0.6490526", "0.6471409", "0.64260876", "0.641185", "0.63683355", "0.6361953", "0.6324604", "0.6305498", "0.6303767", "0.62501025", "0.6240314", "0.62244964", "0.61938465", "0.61566305", "0.6134111", "0.6093153"...
0.8242203
1
check if the heap is empty
isEmpty() { return this.heap.length === 0; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function heapisEmpty() {\n return this.size == 0 ? true : false;\n}", "isEmpty() {\n return !this.heapContainer.length;\n }", "function isEmpty() {\n return this.top === 0;\n}", "heapHasIndex(index){\r\n if(index>=0 && index<this.heapContainer.length)\r\n return true;\r\n \r\n return ...
[ "0.8801127", "0.7740314", "0.69832236", "0.6907285", "0.6777653", "0.6752135", "0.6746486", "0.67290246", "0.65971357", "0.6547033", "0.65308535", "0.6521938", "0.6514921", "0.65049946", "0.6492355", "0.64725035", "0.64722633", "0.6470793", "0.64603376", "0.64533764", "0.6418...
0.82852596
1
returns the heap structure
getHeap() { return this.heap; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Heap()\n{\n\t// h[0] not used, heap initially empty\n\n\tthis.h = [null]; // heap of integer keys\n\tthis.h_item = [null]; // corresponding heap of data-items (any object)\n\tthis.size = 0; // 1 smaller than array (also index of last child)\n\n\n\t// ----...
[ "0.7372717", "0.7307348", "0.7011272", "0.6944502", "0.69332767", "0.6875817", "0.6830716", "0.6772608", "0.6742784", "0.6742784", "0.6671171", "0.66410375", "0.6612922", "0.6560505", "0.6552577", "0.65003353", "0.6475312", "0.6475312", "0.6475312", "0.6475312", "0.6440758", ...
0.74754506
0
heapify the data structure around min values
minHeapify(arr, n, i) { let smallest = i; let leftIndex = 2 * i + 1; let rightIndex = 2 * i + 2; if (leftIndex < n && arr[leftIndex] < arr[smallest]) { smallest = leftIndex; } if (rightIndex < n && arr[rightIndex] < arr[smallest]) { smallest = rightIndex; } if (smallest != i) { let temp = arr[i]; arr[i] = arr[smallest]; arr[smallest] = temp; this.minHeapify(arr, n, smallest); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "MinHeapify(index) {\n let left = this.left(index);\n let right = this.right(index);\n let smallest = index;\n if (left < this.size && this.data[left] < this.data[index]) smallest = left;\n if (right < this.size && this.data[right] < this.data[smallest])\n smallest = right;\n if (smallest != ...
[ "0.720125", "0.7082232", "0.7045268", "0.69386554", "0.68683213", "0.6864061", "0.68334186", "0.68217164", "0.6809871", "0.67274594", "0.67023855", "0.6699346", "0.6672485", "0.66363895", "0.6628925", "0.6590176", "0.6588476", "0.6567027", "0.6564876", "0.653676", "0.65211815...
0.6279518
33
insert a value into the heap
insert(data) { const size = this.heap.length; if (size === 0) { this.heap.push(data); } else { this.heap.push(data); for (let i = parseInt(this.heap.length / 2 - 1); i >= 0; i--) { this.minHeapify(this.heap, this.heap.length, i); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "insert(value) {\n // Insert value to the end of array\n // Perform siftUp to correct position of value in the heap tree\n this.heap.push(value);\n this.siftUp(this.heap.length - 1, this.heap);\n }", "insert(value) {\n\t\tthis.heap.push(value);\n\t\t// calling heapify function to reconstruct array to...
[ "0.863833", "0.8331561", "0.8072703", "0.8005249", "0.7808851", "0.7681502", "0.7637742", "0.75567305", "0.75504696", "0.7541238", "0.751654", "0.74698555", "0.7361416", "0.734068", "0.71542877", "0.7149954", "0.71396136", "0.7095043", "0.70502484", "0.70256126", "0.6946853",...
0.765279
6
remove a specific value from the heap
remove(data) { const size = this.heap.length; let i; for (i = 0; i < size; i++) { if (data === this.heap[i]) { break; } } [this.heap[i], this.heap[size - 1]] = [this.heap[size - 1], this.heap[i]]; this.heap.splice(size - 1); for (let i = parseInt(this.heap.length / 2 - 1); i >= 0; i--) { this.minHeapify(this.heap, this.heap.length, i); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "remove() {\n // Swap root value with last element in the heap\n // Pop the last element from heap array\n // Perform siftDown to correct position of swapped value\n // Return popped value\n this.swap(0, this.heap.length - 1, this.heap);\n const valueToRemove = this.heap.pop();\n this.siftDown(...
[ "0.80592644", "0.77889985", "0.75571394", "0.75185335", "0.748075", "0.7324977", "0.7206284", "0.7075653", "0.7057192", "0.7057192", "0.6849966", "0.67913896", "0.66329116", "0.65866756", "0.6565453", "0.64938587", "0.64443773", "0.6443872", "0.6382864", "0.6373806", "0.63577...
0.771712
2
returns the max value from the heap
findMin() { return this.heap[0]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "findMax() {\r\n\t\treturn this.heap[0];\r\n\t}", "extractMax() {\n\t\tconst max = this.heap[0];\n\t\tconst tmp = this.heap.pop();\n\t\tif (!this.empty()) {\n\t\t\tthis.heap[0] = tmp;\n\t\t\tthis.sinkDown(0);\n\t\t}\n\t\treturn max;\n\t}", "extractMax() {\r\n\t\tconst max = this.heap[0];\r\n\t\tthis.remove(max)...
[ "0.84279215", "0.82991564", "0.7957347", "0.78086686", "0.7646159", "0.7423833", "0.73725516", "0.7348753", "0.72745484", "0.72237366", "0.72114444", "0.7197894", "0.7177174", "0.7163383", "0.7146565", "0.70919085", "0.70852536", "0.70802695", "0.7070464", "0.7062798", "0.703...
0.0
-1
removes the max value from the heap
removeMin() { this.remove(this.heap[0]); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "removeMax() {\r\n\t\tthis.remove(this.heap[0]);\r\n\t}", "deleteMax() {\n // recall that we have an empty position at the very front of the array, \n // so an array length of 2 means there is only 1 item in the heap\n\n if (this.array.length === 1) return null;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// edge...
[ "0.88500553", "0.8017225", "0.762636", "0.7623454", "0.7433278", "0.728619", "0.72537774", "0.71495926", "0.71142554", "0.70889926", "0.69997257", "0.6982289", "0.69431186", "0.6823337", "0.67177093", "0.67000633", "0.66962206", "0.6652222", "0.6639554", "0.6618666", "0.66110...
0.7505327
4
stores the max value and then removes it from the heap
extractMin() { const min = this.heap[0]; this.remove(min); return min; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "removeMax() {\r\n\t\tthis.remove(this.heap[0]);\r\n\t}", "deleteMax() {\n // recall that we have an empty position at the very front of the array, \n // so an array length of 2 means there is only 1 item in the heap\n\n if (this.array.length === 1) return null;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// edge...
[ "0.8409095", "0.7877608", "0.7585467", "0.73500264", "0.73173934", "0.7304062", "0.7143545", "0.70733887", "0.7040378", "0.7005794", "0.69212705", "0.69015676", "0.6883216", "0.6674372", "0.6661336", "0.6651813", "0.66323894", "0.6611787", "0.6607657", "0.6603595", "0.6594041...
0.0
-1
return the size of the heap
size() { return this.heap.length; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "size() {\n\t\treturn this.heap.length;\n\t}", "getHeap() {\r\n\t\treturn this.heap;\r\n\t}", "getHeap() {\r\n\t\treturn this.heap;\r\n\t}", "get size() {\n let size = 0;\n for (let i = 0; i < this.children.length; i++)\n size += this.children[i].size;\n return size;\n }", "function size() {\...
[ "0.8232244", "0.6720662", "0.6720662", "0.6595036", "0.658402", "0.6490136", "0.6471042", "0.64250314", "0.64119965", "0.636866", "0.6362219", "0.6324369", "0.6306118", "0.6303182", "0.62492096", "0.62391216", "0.62245953", "0.6194299", "0.61576664", "0.61351967", "0.6093203"...
0.8241832
0
check if the heap is empty
isEmpty() { return this.heap.length === 0; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function heapisEmpty() {\n return this.size == 0 ? true : false;\n}", "isEmpty() {\n return !this.heapContainer.length;\n }", "function isEmpty() {\n return this.top === 0;\n}", "heapHasIndex(index){\r\n if(index>=0 && index<this.heapContainer.length)\r\n return true;\r\n \r\n return ...
[ "0.8801127", "0.7740314", "0.69832236", "0.6907285", "0.6777653", "0.6752135", "0.6746486", "0.67290246", "0.65971357", "0.6547033", "0.65308535", "0.6521938", "0.6514921", "0.65049946", "0.6492355", "0.64725035", "0.64722633", "0.6470793", "0.64603376", "0.64533764", "0.6418...
0.82852596
2
returns the heap structure
getHeap() { return this.heap; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Heap()\n{\n\t// h[0] not used, heap initially empty\n\n\tthis.h = [null]; // heap of integer keys\n\tthis.h_item = [null]; // corresponding heap of data-items (any object)\n\tthis.size = 0; // 1 smaller than array (also index of last child)\n\n\n\t// ----...
[ "0.7372717", "0.7307348", "0.7011272", "0.6944502", "0.69332767", "0.6875817", "0.6830716", "0.6772608", "0.6742784", "0.6742784", "0.6671171", "0.66410375", "0.6612922", "0.6560505", "0.6552577", "0.65003353", "0.6475312", "0.6475312", "0.6475312", "0.6475312", "0.6440758", ...
0.74754506
1
function that sets time and displays on screen
function setTime() { //set interval function var timerInterval = setInterval(function () { secondsLeft--; timeEl.textContent = secondsLeft + " seconds left till game ends."; if (secondsLeft === 0) { clearInterval(timerInterval); endGame(); //displays message at end of game } }, 1000); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "set_time( t ){ this.current_time = t; this.draw_fg(); return this; }", "function displayTime() {\n var today = new Date();\n \n //gathers information about current hour, min and sec. \n //Add zero at the head if it is a single digit number.\n var currentHour = addZero(today.get...
[ "0.79061556", "0.7867804", "0.7833104", "0.78100234", "0.76912004", "0.76705134", "0.7659492", "0.7658845", "0.76162374", "0.76118803", "0.76050484", "0.75970423", "0.7594395", "0.758446", "0.7583648", "0.756783", "0.7565811", "0.755161", "0.7543307", "0.7523902", "0.7521322"...
0.0
-1
function that starts the game
function start() { setTime(); //set timer //next question function next(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function startGame() { }", "function start()\r\n{\r\ninit();\r\ngame.start();\r\n}", "function startGame() {\n init();\n}", "function startGame() {\n\tsetup();\n\tmainLoop();\n}", "function startgame() {\t\r\n\tloadImages();\r\nsetupKeyboardListeners();\r\nmain();\r\n}", "function startGame(){\n in...
[ "0.8947497", "0.853883", "0.85360265", "0.846057", "0.83268464", "0.8302629", "0.82855785", "0.8213439", "0.81400234", "0.80515915", "0.8041017", "0.80409956", "0.8034612", "0.8003582", "0.7985927", "0.79599327", "0.79583174", "0.7946285", "0.78813124", "0.78753716", "0.78651...
0.0
-1
function that clears messages and displays a picture onscreen
function endGame() { questions1El.textContent = "Game Over"; button1El.textContent = ""; button2El.textContent = ""; button3El.textContent = ""; button4El.textContent = ""; startEl.textContent = ""; //append img to questions window var imgEl = document.createElement("img"); imgEl.setAttribute("src", "assets/congrats.png"); questions1El.appendChild(imgEl); //create item to append to high scores var highScoresEl = document.getElementById("highScores"); var item = document.createElement("p"); item.textContent = prompt("Enter Initals")+" : "+ score;//put score in item //highScoresEl.setAttribute("visibility","visible"); highScoresEl.append(item); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function clearChat() {\n $(\"gameOutputField\").innerHTML = \"\";\n displayMessage(\"<a href='images/how-about-no-bear.jpg' target='_blank'>see chat history</a>\");\n $(\"gameInputField\").focus();\n }", "function clearMessages() {\n hint.textContent = \"\";\n hold.textContent = \...
[ "0.69447803", "0.68114084", "0.67741245", "0.66152513", "0.6483633", "0.6464599", "0.6451905", "0.6437282", "0.639263", "0.63876086", "0.6363084", "0.6359913", "0.6336804", "0.63157374", "0.6287178", "0.62681925", "0.6220877", "0.6217493", "0.6178756", "0.6162305", "0.6160375...
0.0
-1
possible reset button implementation
function reset() { location.reload(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function resetButtonPressed() {\n reset();\n}", "function pressReset(){\n events.emit('resetBtn', true);\n }", "function reset(e){\n \n}", "_reset() {\r\n\t\tthis._pressed = false;\r\n\t}", "function resetButton() {\n\tvar r = getProgress();\n\tsetProgress(r = 0);\n}", "function reset() {\n ...
[ "0.8312869", "0.8204711", "0.7796093", "0.7780912", "0.7737174", "0.77306217", "0.76953423", "0.76022285", "0.75823927", "0.7568529", "0.74940425", "0.7462029", "0.7458716", "0.7446697", "0.7443668", "0.7379343", "0.73692", "0.73537445", "0.7319036", "0.72946703", "0.72922176...
0.0
-1
Alyssa postulates the existence of an abstract object called an interval that has two endpoints: a lower bound and an upper bound. She also presumes that, given the endpoints of an interval, she can construct the interval using the data constructor make_interval. Alyssa first writes a function for adding two intervals. She reasons that the minimum value the sum could be is the sum of the two lower bounds and the maximum value it could be is the sum of the two upper bounds:
function addInterval(x, y) { return makeInterval( lowerBound(x) + lowerBound(y), upperBound(x) + upperBound(y) ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addTwo(range1, range2) {\n if (range1.overlaps(range2, {adjacent: true})) {\n var start = moment.min(range1.start, range2.start);\n var end = moment.max(range1.end, range2.end);\n var sum = moment.range(start, end);\n return sum;\n } else {\n return null;\n }\n}...
[ "0.66479737", "0.6616013", "0.652245", "0.6456774", "0.6433727", "0.6431704", "0.6426851", "0.6387165", "0.6342265", "0.63171923", "0.63106346", "0.62977326", "0.62505305", "0.6249269", "0.6243401", "0.62178606", "0.61666274", "0.60571927", "0.6051225", "0.6029278", "0.602211...
0.73323363
0
Alyssa also works out the product of two intervals by finding the minimum and the maximum of the products of the bounds and using them as the bounds of the resulting interval. (math_min and math_max are primitives that find the minimum or maximum of any number of arguments.)
function mulInterval(x, y) { const p1 = lowerBound(x) * lowerBound(y); const p2 = lowerBound(x) * upperBound(y); const p3 = upperBound(x) * lowerBound(y); const p4 = upperBound(x) * upperBound(y); return makeInterval(Math.min(p1, p2, p3, p4), Math.max(p1, p2, p3, p4)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function iclamp(a, min, max) {\n\treturn Math.max(min, Math.min(a, max));\n}", "function product_Range(a,b) {\n var prd = a,i = a;\n\n while (i++< b) {\n prd*=i;\n }\n return prd;\n}", "function map(x, in_min, in_max, out_min, out_max,checkRanges) {\n if ((typeof checkRanges != 'undefined') && checkR...
[ "0.63497293", "0.6287785", "0.6074114", "0.6001888", "0.5925367", "0.5914643", "0.58827174", "0.5819397", "0.58159214", "0.5801726", "0.5793916", "0.5776489", "0.5767991", "0.57658136", "0.576004", "0.5758149", "0.5742974", "0.5724646", "0.57046723", "0.5695718", "0.5684329",...
0.69145757
0
To divide two intervals, Alyssa multiplies the first by the reciprocal of the second. Note that the bounds of the reciprocal interval are the reciprocal of the upper bound and the reciprocal of the lower bound, in that order.
function divInterval(x, y) { return mulInterval(x, makeInterval(1.0 / upperBound(y), 1.0 / upperBound(y))); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function divide(a, b) {\n\t\ta = a + 0.0;\n\t\tb = b + 0.0;\n\t\tif(Math.abs(b) < 0.00001) {\n\t\t\tb = 0.0001;\n\t\t}\t\n\t\treturn a / b;\n\t}", "function divide1(a, b) {\n return a / b; \n}", "function divide(a, b) {\n return divide(a, b);\n}", "function division(a, b) {\r\n\treturn a / b;\r\n}", "fun...
[ "0.6556227", "0.6140319", "0.6107507", "0.6097738", "0.60297906", "0.5959053", "0.59564245", "0.5914174", "0.5869834", "0.5859574", "0.5777394", "0.5768386", "0.57455504", "0.5718051", "0.5714318", "0.5704635", "0.5701839", "0.5690303", "0.56748295", "0.5670914", "0.5670283",...
0.6592287
0
it is not clear what it means to divide by an interval that spans zero. Modify the program to check for this condition and to signal an error if it occurs.
function log(x) { return console.log(x); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function divide (dividend, divisor) {\r\n// -------------------- Your Code Here --------------------\r\nif (divisor === 0) {\r\n console.log(\"Divide by 0 ERROR\");\r\n}\r\n\r\n\r\n\r\n\r\n// --------------------- End Code Area --------------------\r\n}", "function caml_raise_zero_divide () {\n caml_raise_co...
[ "0.7107541", "0.6943888", "0.66407484", "0.66097045", "0.62188107", "0.6172213", "0.6009928", "0.596499", "0.5939883", "0.58870673", "0.5883719", "0.5857439", "0.581766", "0.57899725", "0.5774233", "0.5692952", "0.5684881", "0.5644853", "0.56400067", "0.5629245", "0.56149054"...
0.0
-1
Define a constructor make_center_percent that takes a center and a percentage tolerance and produces the desired interval. You must also define a selector percent that produces the percentage tolerance for a given interval. The center selector is the same as the one shown above.
function makeCenterPercent(center, percent, width = center * (percent / 100)) { return makeCenterWidth(center, width); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getCubicBezierXYatPercent(startPt,controlPt1,controlPt2,endPt,percent){\n var x=CubicN(percent,startPt.x,controlPt1.x,controlPt2.x,endPt.x);\n var y=CubicN(percent,startPt.y,controlPt1.y,controlPt2.y,endPt.y);\n return({x:x,y:y});\n }", "percent(val) {\n this._percent ...
[ "0.5441083", "0.5423155", "0.53515947", "0.51415503", "0.5099301", "0.50814635", "0.50578564", "0.50578564", "0.50578564", "0.50578564", "0.5045009", "0.50370234", "0.50069755", "0.50069755", "0.50069755", "0.4975419", "0.49723375", "0.4970372", "0.49646857", "0.49646857", "0...
0.7483115
0
I DON'T HAVE ENOUGH TIIIIIME FOR THIS
function buildTable(toBuildFrom1) { console.log('building'); let table = document.querySelector('table'); table.innerHTML = ''; let tableHeader = document.createElement('thead'); let tableBody = document.createElement('tbody'); let tableHeaderRow = document.createElement('tr'); let tableHeaderID = document.createElement('th'); let tableHeaderReporter = document.createElement('th'); let tableHeaderManufacturer = document.createElement('th'); let tableHeaderSerialNumber = document.createElement('th'); let tableHeaderDescription = document.createElement('th'); let tableHeaderDate = document.createElement('th'); let tableHeaderActions = document.createElement('th'); table.appendChild(tableHeader); table.appendChild(tableBody); tableHeader.appendChild(tableHeaderRow); tableHeaderID.appendChild(document.createTextNode('ID')); tableHeaderReporter.appendChild(document.createTextNode('Reporter')); tableHeaderManufacturer.appendChild(document.createTextNode('Manufacturer')); tableHeaderSerialNumber.appendChild(document.createTextNode('Serial number')); tableHeaderDescription.appendChild(document.createTextNode('Description')); tableHeaderDate.appendChild(document.createTextNode('Date')); tableHeaderActions.appendChild(document.createTextNode('Actions')); tableHeaderRow.appendChild(tableHeaderID); tableHeaderRow.appendChild(tableHeaderReporter); tableHeaderRow.appendChild(tableHeaderManufacturer); tableHeaderRow.appendChild(tableHeaderSerialNumber); tableHeaderRow.appendChild(tableHeaderDescription); tableHeaderRow.appendChild(tableHeaderDate); tableHeaderRow.appendChild(tableHeaderActions); toBuildFrom1.forEach((e, i) => { let tableBodyRow = document.createElement('tr'); let tableCellID = document.createElement('td'); let tableCellReporter = document.createElement('td'); let tableCellManufacturer = document.createElement('td'); let tableCellSerialNumber = document.createElement('td'); let tableCellDescription = document.createElement('td'); let tableCellDate = document.createElement('td'); let tableCellActions = document.createElement('td'); tableBody.appendChild(tableBodyRow); tableBodyRow.appendChild(tableCellID); tableBodyRow.appendChild(tableCellReporter); tableBodyRow.appendChild(tableCellManufacturer); tableBodyRow.appendChild(tableCellSerialNumber); tableBodyRow.appendChild(tableCellDescription); tableBodyRow.appendChild(tableCellDate); tableBodyRow.appendChild(tableCellActions); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private internal function m248() {}", "private public function m246() {}", "static private internal function m121() {}", "protected internal function m252() {}", "transient protected internal function m189() {}", "transient private internal function m185() {}", "static transient private protected inter...
[ "0.692721", "0.66386545", "0.64107764", "0.640672", "0.63495654", "0.6288914", "0.61102325", "0.6092448", "0.60191995", "0.6005097", "0.592703", "0.5926077", "0.5923283", "0.59065974", "0.59034216", "0.5902647", "0.58892524", "0.5886282", "0.5871479", "0.5857213", "0.58538973...
0.0
-1
in "normal" function you have arguments
function main() { return argumentsAsString(...arguments) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function args() {\n\n}", "function SimpleArgs() {\r\n}", "function argsFor() {\n\n}", "function functionWithArgs (para1, para2) {\nconsole.log(para1 + para2);\n}", "function functionWithArgs(a,b){\n console.log(a+b);\n }", "function imprimeArguemntos(){\n console.log(arguments);\n}", "function b...
[ "0.7216065", "0.7063855", "0.69777256", "0.6775883", "0.67742324", "0.6650073", "0.6642892", "0.66353196", "0.66227317", "0.6579017", "0.65786034", "0.65367085", "0.6509908", "0.65036905", "0.64986616", "0.64883626", "0.6445828", "0.6445764", "0.6444234", "0.64341795", "0.642...
0.0
-1
validate number function, ensure user input is greater than 0
function validateNumber(value) { var valid = Number.isInteger(parseFloat(value)); var sign = Math.sign(value); if (valid && (sign === 1)) { return true; } else { return "Please enter a number"; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validInput(input) {\n return isInteger(input) && input > 0\n}", "function validNumber(input){\r\n\treturn (input.length == 10 || input[0] == \"0\");\r\n}", "function validateInput(value) {\n\tvar integer = Number.isInteger(parseFloat(value));\n\tvar sign = Math.sign(value);\n\tif (integer && (sign ...
[ "0.7979747", "0.7878278", "0.7802421", "0.77656823", "0.7717826", "0.7703171", "0.7676109", "0.7575973", "0.7508404", "0.7434431", "0.74314135", "0.7429841", "0.7421819", "0.74133444", "0.7400117", "0.7379163", "0.73684", "0.7354481", "0.735385", "0.73500985", "0.73500985", ...
0.7191338
28
user prompt function to capture and validate the id/quantity they would like to purchase
function purchase() { inquirer.prompt([{ name: "item_id", type: "input", message: "What is the ID of the item you would like to purchase?", validate: validateNumber, filter: Number }, { name: "quantity", type: "input", message: "How many units would you like to purchase?", validate: validateNumber, filter: Number } ]).then(function (input) { //capture user response in variables var chosenID = input.item_id; var userAmount = input.quantity; //query mysql table to grab selected item information var queryStr = 'SELECT * FROM products WHERE ?'; connection.query(queryStr, { item_id: chosenID }, function (err, data) { if (err) throw err; //display item selected to verify user input is being captured and correctly pulled from database // console.log(res); // if user amount requested is less than or equal to stock quantity value, subtract value from stock quantity else { var itemData = data[0]; //if the requested amount is less than or equal to the quantity in stock, purchase is valid if (userAmount <= itemData.stock_quantity) { console.log("Sending out your order!"); //capture query string to update table where the item is equal to the user chosen id var updateQueryStr = 'UPDATE products SET stock_quantity = ' + (itemData.stock_quantity - userAmount) + ' WHERE item_id = ' + chosenID; //update the table stock quantity connection.query(updateQueryStr, function (err, data) { if (err) throw err; console.log("Your order is on it's way! The total price is $" + itemData.price * userAmount); connection.end(); }); } else { console.log("Sorry! There is not enough product in stock"); //display table after values are updated start(); } } }); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function userPurchase() {\n inquirer\n .prompt([\n {\n name: \"id\",\n type: \"input\",\n message: \"\\nWhat's the item ID of the product you would like to buy? \",\n filter: Number\n },\n {\n name: \"quantity\",\n type: \"input\",\n m...
[ "0.80536026", "0.8019164", "0.8015831", "0.7915313", "0.7897343", "0.7864858", "0.7813461", "0.7811712", "0.77833486", "0.7760087", "0.77232844", "0.77152956", "0.7707057", "0.7700719", "0.7656809", "0.76543355", "0.7651184", "0.7633634", "0.76255906", "0.7605903", "0.758634"...
0.7197916
56