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
Generates an array of random RGB values
function generateRandomColours( numberOfColours ) { var collectionOfColours = []; for ( let index = 0; index < numberOfColours; index++ ) { console.log( "Game mode when generating random colors " + gameMode ); if ( gameMode === "RGB" ) { collectionOfColours[ index ] = randomRGBColour(); console.log( collectionOfColours[ index ] ); } else { collectionOfColours[ index ] = randomHexColour(); console.log( collectionOfColours[ index ] ); } // if the selected mode is hex then do this } return collectionOfColours; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function randomize(){\n let rgb = [];\n for(let i = 0; i < 3; i++){\n rgb.push(Math.floor(Math.random() * 255));\n }\n return rgb;\n}", "function colorGeneration () {\n\tvar rgb = []; \n\tfor (var i=0; i<3;i++){\n\t\trgb[i] = Math.floor(Math.random() * 256); // gera numeros aleatorios entre 0 e 255\n\t}\...
[ "0.8451863", "0.8363187", "0.8301722", "0.8296034", "0.8279981", "0.8236854", "0.8229413", "0.8191082", "0.81658345", "0.8059936", "0.7982774", "0.7980677", "0.7929162", "0.7921505", "0.789211", "0.7884192", "0.7878391", "0.787127", "0.78471607", "0.7827145", "0.7808459", "...
0.0
-1
Generates a random single rgb colour value
function randomRGBColour() { var red = Math.floor( Math.random() * 256 ), green = Math.floor( Math.random() * 256 ), blue = Math.floor( Math.random() * 256 ); return "rgb(" + red + ", " + green + ", " + blue + ")"; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getRandomColorRGB() {\n return 'rgb(' + calcRndGen(255, true).toString() + \",\" + calcRndGen(255, true).toString() + \",\" + calcRndGen(255, true).toString() + ')';\n }", "function random_rgb() {\n var o = Math.round, r = Math.random, s = 255;\n return 'rgb(' + o(...
[ "0.8674331", "0.8651737", "0.86215556", "0.86164194", "0.86136794", "0.8609892", "0.86017644", "0.86017644", "0.86017644", "0.85962564", "0.8583133", "0.85607415", "0.8543566", "0.8543566", "0.85199463", "0.84953976", "0.8476258", "0.8470508", "0.8468981", "0.843563", "0.8426...
0.82922524
51
Generates a random single hex colour value
function randomHexColour() { return '#' + Math.floor( Math.random() * 16777215 ).toString( 16 ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function colorValue() {\n return randomHex() + randomHex();\n}", "randomHexValue() {\n var color = '#';\n var c = '0123456789ABCDEF'.split('');\n\n for (var i = 0; i < 6; i++) {\n color += c[Math.floor(Math.random() * c.length)];\n }\n\n return color;\n }", "function randNum...
[ "0.858751", "0.85277116", "0.849936", "0.8491263", "0.84761614", "0.8454928", "0.8437184", "0.84336334", "0.84302276", "0.83963996", "0.83932394", "0.83909225", "0.8387933", "0.8377157", "0.8360406", "0.83570504", "0.83555096", "0.83335924", "0.83247507", "0.8311982", "0.8303...
0.87015545
0
Parse entry properties from triples to a simple object with the triple values
parseEntryProperties(entryProperties) { let entry = {}; if ( entryProperties.find( (entry) => entry.predicate.value == existingStaffPredicate.value ) ) entry.existingStaff = entryProperties.find( (entry) => entry.predicate.value == existingStaffPredicate.value ).object.value; if ( entryProperties.find( (entry) => entry.predicate.value == additionalStaffPredicate.value ) ) entry.additionalStaff = entryProperties.find( (entry) => entry.predicate.value == additionalStaffPredicate.value ).object.value; if ( entryProperties.find( (entry) => entry.predicate.value == volunteersPredicate.value ) ) entry.volunteers = entryProperties.find( (entry) => entry.predicate.value == volunteersPredicate.value ).object.value; return entry; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function entriesToObject(entries) {\n var o = {};\n for (var i = 0; i < entries.length; i += 1) {\n var key = entries[i][0];\n var values = entries[i][1];\n var value = void 0;\n if (values.length === 1) {\n ...
[ "0.56831944", "0.5600491", "0.557593", "0.54726326", "0.54039145", "0.53568774", "0.531575", "0.531575", "0.5285814", "0.52527374", "0.5237511", "0.52307427", "0.52277464", "0.51439357", "0.5093094", "0.5053285", "0.5013192", "0.5004285", "0.49392167", "0.4936615", "0.4936615...
0.62475586
0
User Logic user interaction with the Frontend part / Form
function myFunction() { var a = parseInt(document.getElementById("one").value); var b = parseInt(document.getElementById("two").value); var c = parseInt(document.getElementById("three").value); // console.log(a); // console.log(b); // console.log(c); var result = triangles(a, b, c); alert(result) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "submitForm(){\n\t\tlet instance = this;\n\t\tconst\tdata = JSON.stringify({\n\t\t\tinterest: instance.dropdownData.interest,\n\t\t\tloan: instance.calculatorData,\n\t\t\tnumberOfMonths: instance.dropdownData.months,\n\t\t\ttotalDebt: instance.debt\n\t\t});\n\t\t\n\t\t\n\t\tfetch(instance.endpoint, {\n\t\t\tmethod:...
[ "0.6580028", "0.6413481", "0.6317126", "0.62134796", "0.6209155", "0.60833365", "0.6058248", "0.60526645", "0.6014929", "0.6014402", "0.5979565", "0.5969447", "0.5963322", "0.594814", "0.5942248", "0.59067667", "0.5906492", "0.5895638", "0.588755", "0.5886605", "0.58790237", ...
0.0
-1
Randomly select a shape and animate it falling downwards
function startShapesFalling() { var currentOption = createShape(shapeNames[Math.floor(Math.random() * shapeNames.length)]); $('#shapes').prepend(currentOption); shapeX = Math.floor(Math.random() * $('body').width()); shapeSpeed = Math.floor(Math.random() + 5000); currentOption.css({'left': shapeX + 'px'}); currentOption.animate({ top: "2000px", }, shapeSpeed, function(){ $(this).remove(); startShapesFalling(); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function moveShape() {\n \n var x = Math.floor(Math.random() * 300);\n \n var y = Math.floor(Math.random() * 500);\n \n document.getElementById(\"shape\").style.position = \"relative\";\n \n docu...
[ "0.72463655", "0.7226107", "0.6984788", "0.68644243", "0.6829808", "0.671251", "0.668993", "0.6630156", "0.66218156", "0.6620933", "0.65962166", "0.65492123", "0.6532907", "0.6459125", "0.64437413", "0.642273", "0.6421105", "0.6421105", "0.63777095", "0.63559866", "0.6333973"...
0.739509
0
delegates actions from server to respective handler
setUpMessageHandler(id) { const socket = io.connect(); return socket.on(id, msg => { //based on what the message is, dispatch an action //msg must be an actionType: { type: TYPE, data: ... } switch(msg.type) { case MSG_LEFT_LINE: return this.handleLineLeave(msg); case MSG_ENTER_LINE: return this.handleServerActionDispatch(msg); case MSG_RECEIVED_CUT_MESSAGE: return this.handleServerActionDispatch(msg); case MSG_RANK_UPDATED: return this.handleMessageReceivedRankUpdated(msg); case MSG_BATHROOM_CREATED: return this.handleMessageReceivedNewNearbyBathrooms(msg); default: break; } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "handleServerAction(action: Action): void {\n this.dispatch({\n source: constants.SERVER_ACTION,\n action: action\n });\n }", "function Handler() {}", "function Handler() {}", "function Handler() {}", "function Handler() {}", "function Handler() {}", "function Hand...
[ "0.6851484", "0.6496148", "0.6496148", "0.6496148", "0.6496148", "0.6496148", "0.6496148", "0.6496148", "0.6496148", "0.6496148", "0.6496148", "0.6496148", "0.64044225", "0.634501", "0.62624305", "0.61504024", "0.60954523", "0.60506505", "0.6040927", "0.60228664", "0.6007837"...
0.56657684
50
dispatches actions issued by the server via a socket
handleServerActionDispatch(msg) { const { socketMessageDispatcher, } = this.props; socketMessageDispatcher(msg); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function onSocketMessage(message) {\n var action = actions[message.action + \"Action\"];\n if(action) action(message);\n }", "handleServerAction(action: Action): void {\n this.dispatch({\n source: constants.SERVER_ACTION,\n action: action\n });\n }", "_dispatch(msg...
[ "0.64386755", "0.63697267", "0.63293135", "0.6167895", "0.61445975", "0.60967386", "0.6090227", "0.6089335", "0.6089335", "0.6089335", "0.6089335", "0.6089335", "0.6089335", "0.6074545", "0.60487086", "0.6041879", "0.5911897", "0.5910375", "0.5884274", "0.58259356", "0.581958...
0.6280452
3
updates client state when server returns with nearby bathroom data
newNearbyBathroomsHandler(nearbyBathrooms) { return nearbyBathrooms.map(b => { const marker = new google.maps.Marker({ position: { lat: b.latitude, lng: b.longitude }, map: this.map, }); const infoWindow = new google.maps.InfoWindow({ content: ReactDOMServer.renderToString(<div id={ `${b.id}-tooltip` } className="gmaps-infowindow"/>), }); const boundListener = this.handleBathroomClick.bind(this, b); google.maps.event.addListener(marker, 'click', () => { infoWindow.open(this.map, marker); boundListener(b); }); return { marker, infoWindow, unmountHandler: () => { //TODO this won't work google.maps.event.removeEventListener(marker, 'click', boundListener); }, lat: b.latitude, lng: b.longitude, showTooltip: false, lineLength: b.lineLength, id: b.id, name: b.name, address: b.address, }; }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "onRegionChange(region)\n{\n //console.log(region.latitude, region.longitude)\n\n/*\n\n TODO: a) combine two requests in one, b) support tokens and flowd ids\n\n*/\n\n // Make all local changes\n\n this.latA = region.latitude;\n this.lonA = region.longitude;\n this.setState({ region2 : {latitude: region.latit...
[ "0.6087548", "0.5875658", "0.5646742", "0.55613667", "0.55456597", "0.55367804", "0.551602", "0.5489717", "0.54336107", "0.54116255", "0.5402483", "0.5299673", "0.52884656", "0.5267746", "0.52624387", "0.52512646", "0.522876", "0.5226168", "0.5219938", "0.52017397", "0.517110...
0.0
-1
when other user leaves a line near the current user this handles the push notification and updates client line data
handleLineLeave(msg) { const { socketMessageDispatcher, nearbyBathrooms, lines, userId, } = this.props; const updatedBathroomId = msg.data.bathroomId; const bathroomId = nearbyBathrooms.find(b => b.id === updatedBathroomId).id; if (typeof bathroomId === "number") { if (typeof lines[updatedBathroomId] === "number") { //if in line and looking at tooltip, get current rank and then update state const url = `routes/linemember/${bathroomId}/${userId}`; $.ajax({ url, success: lm => { socketMessageDispatcher(messageReceivedUpdateLineLineMember(msg.data.bathroomId, lm.rank, msg.data.lineLength)); }, error: err => { console.log('error', err); } }); } else { //if not in line but looking at tooltip, update data //will handle line length socketMessageDispatcher(msg); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "onLeave(client, consented) {\n\t\tthis.state.history.push(`${client.sessionId} left AreaRoom.`);\n\t}", "function onUserOut(id) {\n\n for(var i=0; i<users.length; i++) {\n\n if (users[i].bodyId == id) {\n users[i].line.remove();\n users.splice(i, 1);\n break;\n }\n }\n}", "onLeave(client...
[ "0.6119252", "0.60084856", "0.5951121", "0.5904566", "0.5798986", "0.57780045", "0.57304794", "0.56377006", "0.5514331", "0.5468415", "0.54465103", "0.5446168", "0.5440707", "0.54405946", "0.5402662", "0.54004866", "0.53829217", "0.5320575", "0.531992", "0.5302565", "0.526009...
0.6077815
1
handles updating client state with browser location
getBrowserLocation(callback) { navigator.geolocation.getCurrentPosition(locationData => { let userLocation = this.props.userLocation; if (locationData && locationData.coords) { const { longitude, latitude, } = locationData.coords; userLocation = [latitude, longitude]; } callback(userLocation); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function respondToState(){\n\t\t_oldUrl = _currentUrl;\n\t\tif(_useAPI) _currentUrl = cleanUrl(window.location.pathname || \"\");\n\t\telse _currentUrl = cleanUrl(window.location.hash || \"\");\n\t\t//Remove slash in beginning\n\t\tif(_currentUrl == \"/\") _currentUrl = \"\";\n\t\telse if(_currentUrl.indexOf(\"/\"...
[ "0.6742826", "0.6627724", "0.64492404", "0.6404856", "0.6362169", "0.6300507", "0.61684036", "0.60758996", "0.6018716", "0.5937272", "0.59354454", "0.59342855", "0.59154195", "0.5914567", "0.5910043", "0.58935857", "0.5887844", "0.58628595", "0.58618027", "0.5847021", "0.5842...
0.0
-1
handles batch updates necessary when this component mounts
setInitialState(userId, callback) { const { bulkUpdatePrimitives, } = this.props; const url = `routes/messages/${userId}`; $.ajax({ url, success: messages => { this.getBrowserLocation(userLocation => { bulkUpdatePrimitives({ userId, userLocation, messages }); callback(); }); }, error: err => { console.log('error', err); } }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "reactifyYourApp() {\n ///////////\n // Mount //\n ///////////\n for (let [component, fields, opts] of this.subscribedComponents) {\n // This proxy wrapping code should be the same as the update. So we'll likely want to\n // abstract the code out.\n const...
[ "0.7031596", "0.68872917", "0.6788372", "0.65457946", "0.65457946", "0.6530517", "0.6511909", "0.64202636", "0.64168394", "0.6399759", "0.6399759", "0.6399759", "0.6399759", "0.6377911", "0.6377911", "0.6377911", "0.6377911", "0.6377911", "0.6377911", "0.6377911", "0.6377911"...
0.0
-1
returns user Id which is appended at end of url
getUserIdFromURL() { const url = window.location.href; let userId = url.match(endNumberPattern); if (userId) { userId = parseInt(userId[1]); } else { userId = 0; } return userId; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getUserId()\n{\n\tvar url = window.location.href;\n\treturn url.split(\"=\")[1].split('#')[0];\n}", "function getUserId(req) {\n //TODO rewrite\n var reqParams = req.originalUrl.split('/');\n return reqParams[reqParams.indexOf('users') + 1];\n}", "_extractUserIdentifier(path) {\n\n\t\tlet extractor...
[ "0.8230834", "0.78776836", "0.7563731", "0.7407244", "0.7262968", "0.7128588", "0.69244653", "0.69244653", "0.6845083", "0.6715887", "0.6707111", "0.6681862", "0.66590357", "0.66449106", "0.6612845", "0.6579729", "0.6574954", "0.6566715", "0.6562823", "0.6540766", "0.6528449"...
0.7813864
2
import Navbar from "../Components/navbar"; import "../Styles/contact.css";
function contact() { return ( <div> <h1 style ={{color:"red"}}> This is to contact</h1> <Navbar /> </div> ) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function App() {\n return (\n <>\n <GlobalStyle />\n {/*<Navbar />*/}\n <Landing />\n </>\n );\n}", "render() {\n return (\n <div className='App'>\n <Navbar />\n </div>\n );\n }", "function Navbar () {\n return (\n <nav id=\"navbar\" className=\"navbar navbar-...
[ "0.6407014", "0.6303039", "0.62873775", "0.61489487", "0.61366636", "0.60776865", "0.6075823", "0.60595506", "0.6010887", "0.60102844", "0.5974441", "0.5967125", "0.59501743", "0.5940738", "0.5933107", "0.59084404", "0.5904645", "0.59011394", "0.5891898", "0.588651", "0.58788...
0.65988946
0
tnego que poner la variable de dev en el transform si es dev tiene que convertir los pug a pug en dist, sino que les haga build a html con pug, posiblemente quitar el pug plugin
function notFound (response, filePath) { response.writeHead(404) response.end('404 Not Found' + '\n\n' + filePath + '\n\n(rollup-plugin-serve)', 'utf-8') }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function TareaJade(rutaOrigen,rutaDestinoVista) {\n \n function compilarVistas()\n { \n console.log(\"vistas html\");\n gulp.src(rutaOrigen)\n .pipe(jade({\n pretty: true\n }))\n .pipe(rename({extname:'.html'}))\n .pipe(gulp.dest(r...
[ "0.63028276", "0.62013143", "0.61329526", "0.57768065", "0.56864893", "0.5645178", "0.53718543", "0.5365995", "0.53345245", "0.5324732", "0.5323338", "0.53168046", "0.53041166", "0.524392", "0.52400184", "0.5215843", "0.5201555", "0.51580054", "0.513038", "0.5119082", "0.5119...
0.0
-1
Algorithm Approach 1: In this question you need to run two loops, pick an element from the first loop and then in the inner loop check if the element appears once again or not, if yes then return that element, otherwise move to the next element. Approach 2: Using XOR operator, we can solve this problem in one traversal only. The following facts about XOR operation: 1. If we XOR a number by itself, even number of times then it will give you 0. 2. If we XOR a number with itself, odd number of times, then it will give you the number itself. 3. Also XOR of a number with 0 gives you that number again. Approach 3: Another approach is to make use of the condition that all elements lies between 0 and n2. So first calculate the sum of all natural numbers between 0 to n2 by using the direct formula ((n 1) (n 2)) / 2 and sum of all elements of the array. Now, subtract the sum of all natural numbers between 0 to n2 from sum of all elements of the array. This will give you the duplicate element present in the array. Psedo Code
function findDuplicateUsingXOR(arr) { let xorOfArr = 0; for(let i =0; i< arr.length; i++){ xorOfArr =xorOfArr ^ arr[i]; } for (let i =0; i<= arr.length-2; i++){ xorOfArr = xorOfArr ^ i; } return xorOfArr; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function solution2(A) {\n let x1 = A[0]; // xor all elements in array\n let x2 = 1; // xor all elements from 1 to n+1 (n+1 since 1 number is missing)\n for (let i = 1; i < A.length; i++) {\n x1 ^= A[i];\n }\n for (let i = 2; i <= A.length + 1; i++) {\n x2 ^= i;\n }\n\n return x2 ^ x1;\n}", "function...
[ "0.73941416", "0.6679825", "0.6577543", "0.65614754", "0.6521074", "0.65167046", "0.64515865", "0.64435637", "0.64321274", "0.6420403", "0.6416857", "0.6407368", "0.6361466", "0.633869", "0.63358015", "0.6326547", "0.6299287", "0.6293768", "0.62874424", "0.62701815", "0.62592...
0.72448885
1
Unshallow the git repository (retriving every commits and tags).
async function unshallow() { await execa('git', ['fetch', '--unshallow', '--tags'], {reject: false}); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function wipeGit() {\n return fsp.remove(path.join(__dirname, '.git'))\n .then(() => {\n return new Promise((resolve, reject) => {\n git.init(() => {\n if (remote) {\n git.addRemote('origin', remote, resolve);\n } else...
[ "0.58163726", "0.55213517", "0.5243422", "0.5094238", "0.5026744", "0.49878788", "0.49865547", "0.48312357", "0.48295334", "0.4813351", "0.47339877", "0.47065708", "0.47005132", "0.46524456", "0.4644404", "0.46442938", "0.46333915", "0.4627247", "0.46199828", "0.4584651", "0....
0.85807866
1
replaces prompts in a str by elements in the responses array in ascending order
function replacePromptsWithResponses(str, responses){ for(var i=0; i<responses.length; i++){ var regex = new RegExp(regexPattern); str = str.replace(regex, responses[i].value); } return str; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function playerPopulate(){\r\n\t for(i=0; i<toReplace; i++){\r\n\t\t console.log(sentence + replacements[i]);\r\n\t\t replacement=prompt(\"Enter a \"+sentence[replacements[i]]);\r\n\t\t sentence[replacements[i]]=replacement;\r\n\t }\r\n\t displayResult();\r\n }", "function authorSetup(){\r\n\t se...
[ "0.6231008", "0.6052366", "0.58853525", "0.57944065", "0.56250155", "0.5599105", "0.5567942", "0.5541108", "0.55402213", "0.5534468", "0.5510018", "0.5485955", "0.5447425", "0.54445165", "0.5356102", "0.5348778", "0.529386", "0.52877957", "0.52617323", "0.5240718", "0.5233298...
0.73612404
0
Gets "responses" or values provided by the user for madlib prompts
function getResponses(){ return $("#prompt-responses").serializeArray(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function promptThem() {\n\tvar userResponse = prompt(\"Type something:\");\n}", "async get(prompt) {\n return await this.question(prompt);\n }", "function getIntern() {\n\n inquirer \n .prompt([\n \n\n ])\n .then(answers =>{\n \n })\n\n}", "function get...
[ "0.6376399", "0.6342821", "0.6334616", "0.62471384", "0.6228964", "0.61803246", "0.6112388", "0.6068689", "0.6061958", "0.6060807", "0.60574996", "0.60524404", "0.6039578", "0.6012001", "0.59889305", "0.5958519", "0.5958457", "0.5955617", "0.5930722", "0.5894548", "0.58725053...
0.5940626
18
Loads required libs dynamically
function loadJS (done, location=document.querySelector('body')){ if (typeof d34 === 'undefined') { //url is URL of external file, implementationCode is the code //to be called from the file, location is the location to //insert the <script> element var scriptTag = document.createElement('script'); scriptTag.src = d34_LIB_URL; var callback = function(success) { window.d34 = window.d3; window.d3 = null; console.log(d34.verion, 'was loaded successfully!'); done(success); }; scriptTag.onload = callback(); scriptTag.onreadystatechange = callback(); location.appendChild(scriptTag); } else { console.log(d34.version, ' is already loaded'); done(true); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function loadAdditionalLibraries() {\n additionalLibraries.forEach(function(each) {\n importScripts(each);\n });\n }", "function loadAllLibs() {\n const files = [\n // list library\n '/externalLibs/list.js',\n // sound\n '/externalLibs/sound/sounds.js',\n '/externalLib...
[ "0.6951596", "0.68560094", "0.66626054", "0.66244614", "0.6494399", "0.64403486", "0.6339625", "0.6316384", "0.6301311", "0.6297209", "0.6260298", "0.625694", "0.6240294", "0.6150834", "0.61358696", "0.61282665", "0.6048268", "0.60231525", "0.59876704", "0.59158754", "0.58811...
0.0
-1
Creates the required style classes and appends them to the document head
function addStyles() { var style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = ".line { fill: none; stroke: steelblue; stroke-width: 1.5px; }"; document.getElementsByTagName('head')[0].appendChild(style); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function cjAddHeadStyle(styles) {\n var st = document.createElement(\"style\");\n st.type = \"text/css\";\n if (st.styleSheet) {\n st.styleSheet.cssText = styles;\n } else {\n st.appendChild(document.createTextNode(styles));\n }\n //st.innerHTML=styles;\n var ht = document.getEle...
[ "0.7072858", "0.7067768", "0.69466215", "0.68238074", "0.67754585", "0.67624545", "0.67371094", "0.67214406", "0.66885924", "0.66801786", "0.66759485", "0.66642094", "0.66597056", "0.6623243", "0.6610095", "0.65444005", "0.64599127", "0.6455767", "0.64467573", "0.6446509", "0...
0.5956801
64
Returns buffer object with stringified JSON object. The buffer object prevents Express.js to add 'charset=utf8', which is against JSON spec.
function toJSON(obj) { return new Buffer(JSON.stringify(obj, null, 2)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function contentify(obj) {\n return new Buffer(JSON.stringify(obj));\n}", "function asBuffer(body, options) {\n\n var ret;\n if (Buffer.isBuffer(body)) {\n ret = body;\n } else if (typeof body === 'object') {\n ret = new Buffer(JSON.stringify(body), options.reqBodyEncoding);\n } else if (typeof body =...
[ "0.67073584", "0.6634128", "0.65623724", "0.63365144", "0.61933404", "0.61933404", "0.6113649", "0.60673463", "0.6057507", "0.6030719", "0.58639777", "0.58187234", "0.57345086", "0.57062876", "0.5694445", "0.5567927", "0.55305594", "0.55305594", "0.5516857", "0.55041265", "0....
0.70621365
0
The GroceryItem and related functions. GroceryItem is used in one shopping list.
function GroceryItem(name, amount) { this.name = name; this.amount = amount; this.purchased = false; this.id = name + Math.floor((Math.random()*100)+1); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function purchaseItem() {}", "function purchaseItem() {}", "function purchaseItem() {}", "function purchaseItem() {}", "function purchaseItem() {}", "function purchaseItem() {}", "function createItems(){\n\t//Library Items\n\tancientBook = new Item('Ancient Book', 'Wow looks like it is a thousand years...
[ "0.649964", "0.649964", "0.649964", "0.649964", "0.649964", "0.649964", "0.64740807", "0.645044", "0.6373991", "0.62744266", "0.6183131", "0.61730605", "0.61690944", "0.61277884", "0.6083648", "0.6018389", "0.60090446", "0.6007531", "0.6000392", "0.5993339", "0.5991099", "0...
0.6838462
0
Get a groceryItem from array based on
function getGroceryItem(id) { for( var index in groceryItems) { if (id == groceryItems[index].id) return groceryItems[index]; } return null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getItem(item, id) {\n for( var i = 0; i < item.length; i++){\n\n if(id == item[i].id){\n return item[i];\n }\n }\n}", "getBasketItem(id) {\n for(let i = 0; i < this.basket.length; ++i) {\n if(this.basket[i].id == id) {\n return JSON.parse(JSON.stringify(this...
[ "0.5951206", "0.5896923", "0.58534086", "0.57022095", "0.5635417", "0.5632701", "0.56096315", "0.5596448", "0.5590011", "0.5572346", "0.5550642", "0.55493325", "0.5545586", "0.5513404", "0.5512766", "0.54996693", "0.5485232", "0.5472218", "0.5455099", "0.5442689", "0.54398197...
0.7191881
0
The ListItem and related functions. ListItems are collected from all GroceryItems entered. The idea is to be able to maintain an all time favourite item list.
function ListItem(name, count) { this.name = name; this.count = count; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function ListItem() {}", "function ListItem() {}", "function ListItem() {}", "function ListItem() { }", "function addToFavoriteList() {\r\n var favItemDesc = this.parentNode.firstElementChild.innerText;\r\n var favItemURL = this.parentNode.firstElementChild.getAttribute('href');\r\n var unsavedFavItem =...
[ "0.6809707", "0.6809707", "0.6809707", "0.6758541", "0.6620012", "0.6606659", "0.6559595", "0.65518194", "0.6551677", "0.6535073", "0.63668525", "0.635326", "0.634089", "0.63272566", "0.6296714", "0.6280828", "0.62641037", "0.6253099", "0.62469935", "0.6240118", "0.62313575",...
0.0
-1
Compare function for ListItems. Used when sorting.
function compareListItems(a,b) { if (a.count < b.count) return -1; if (a.count > b.count) return 1; return 0; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sortListItems()\r\n{\r\n\tallItems.sort(compareListItems);\r\n}", "static compare(itemA, itemB) {\r\n return itemA.value - itemB.value;\r\n }", "function flist_cmp(a, b) {\n\tif (a.name.toLowerCase() > b.name.toLowerCase()) {\n\t\treturn 1;\n\t}\n\treturn -1;\n}", "function compareFunction...
[ "0.7101541", "0.7022904", "0.7007451", "0.68397075", "0.67213356", "0.656595", "0.6381562", "0.63478243", "0.6339173", "0.6299038", "0.6299038", "0.622961", "0.6164412", "0.61463517", "0.6103007", "0.6065325", "0.60398203", "0.6022998", "0.5995426", "0.5974481", "0.5972062", ...
0.7279797
0
Sort ListItems based on count
function sortListItems() { allItems.sort(compareListItems); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function compareListItems(a,b) \r\n{\r\n if (a.count < b.count)\r\n return -1;\r\n if (a.count > b.count)\r\n return 1;\r\n return 0;\r\n}", "sortListItems() {\n let sortedItems = this.props.listItems.slice();\n return sortedItems.sort((a, b) => {\n if (a.value > b.value) {\n ...
[ "0.71348685", "0.69969445", "0.68414974", "0.6825937", "0.6799466", "0.65932715", "0.6502349", "0.6272727", "0.6222541", "0.6198015", "0.6198015", "0.6122538", "0.61144304", "0.6055383", "0.594004", "0.5921518", "0.58808124", "0.5874777", "0.58557856", "0.5855503", "0.5832894...
0.68542194
2
Helper to flatten ListItems to string array
function getListItemName(listItem) { return listItem.name; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function deepFlatten(strList, array) {\n for (const item of array) {\n if (Array.isArray(item)) {\n deepFlatten(strList, item);\n } // else if (item instanceof Declaration) {\n // strList.push(item.toString());\n // }\n else {\n strLis...
[ "0.6415873", "0.6402342", "0.63890904", "0.6388714", "0.6257417", "0.6257417", "0.6257417", "0.61084634", "0.6087226", "0.6087226", "0.6087226", "0.60640335", "0.60449076", "0.6040341", "0.5963033", "0.5959086", "0.5939458", "0.5939458", "0.5933218", "0.5921291", "0.5807136",...
0.0
-1
Remove one list item and store the rest.
function removeListItem(name) { for( var index in allItems) { if (name == allItems[index].name) { allItems.splice(index, 1); localStorage.setObject("goods", allItems); return; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function remove(){\n\t\tif(this.items.length === 0) return null;\n\t\tif(this.items.length === 1) return this.items.shift();\n\t\tlet element = this.items[0];\n\t\tthis.items[0] = this.items.pop();\n\t\t_siftDown.call(this);\n\t\treturn element;\n\t}", "function removeItem(item){\n // Remove the item from the...
[ "0.70739186", "0.70596236", "0.70211077", "0.7007762", "0.69584256", "0.6885097", "0.6874249", "0.6789379", "0.6750378", "0.6715312", "0.66844547", "0.668236", "0.66744417", "0.6672918", "0.6672848", "0.66516256", "0.6646632", "0.6625035", "0.66196907", "0.661693", "0.6611231...
0.6488073
32
GroceryItems CRUD functions Store all grocery items.
function storeGroceryItems() { localStorage.setObject("shoppinglist", groceryItems); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function ItemsController(){\n\t\n\n\tthis.index = function(req,res){\n\t\tconsole.log('ItemsController index');\n\t\tItem.find({}, function(err, items) {\n \t\t// This is the method that finds all of the items from the database\n\t \tif(err) {\n\t \t\tconsole.log('Item.index error');\n\t \t\tres.st...
[ "0.6213552", "0.6199448", "0.6176019", "0.61637783", "0.5964204", "0.5941081", "0.59004647", "0.5822284", "0.57876694", "0.5742582", "0.57247597", "0.57032883", "0.56881905", "0.5685881", "0.5674755", "0.56602013", "0.56414616", "0.56266946", "0.56266946", "0.562123", "0.5616...
0.6566024
0
GroceryItems CRUD functions Remove one grocery item and store the rest.
function removeGroceryItem(id) { for(var index in groceryItems) { if (id == groceryItems[index].id) { groceryItems.splice(index, 1); localStorage.setObject("shoppinglist", groceryItems); return; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function deleteGroceryProduct(index) {\r\n let getLocalStorageData = localStorage.getItem(\"groceryListItem\");\r\n groceryListItem = JSON.parse(getLocalStorageData);\r\n groceryListItem.splice(index, 1);\r\n localStorage.setItem(\"groceryListItem\", JSON.stringify(groceryListItem));\r\n showGrocery...
[ "0.67422986", "0.6710769", "0.658854", "0.65568125", "0.6424576", "0.642102", "0.6410153", "0.6395075", "0.63610715", "0.63471806", "0.6301564", "0.62329584", "0.6232015", "0.62317026", "0.620703", "0.62047344", "0.62041825", "0.62039685", "0.61794555", "0.6175213", "0.616628...
0.69264835
0
GroceryItems CRUD functions Load all grocery items from local storage.
function loadGroceryItems() { var items = localStorage.getObject("shoppinglist"); if( items != null ) { //check if items is an array if(_.isArray(items)) { groceryItems = items; } else { // This will happen on first run //alert("Kauppalistan lataus ei onnistunut"); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function storeGroceryItems()\r\n{\r\n\tlocalStorage.setObject(\"shoppinglist\", groceryItems);\r\n}", "function loadItems() {\n $itemList.empty();\n\n SDK.Items.getItems((err, items) => {\n if (err) throw err;\n\n\n items.forEach((item) => {\n\n //Sort items to ...
[ "0.7174986", "0.68544275", "0.67579544", "0.67044705", "0.6639573", "0.66317415", "0.6430692", "0.6339278", "0.6293281", "0.62848234", "0.6253951", "0.6227913", "0.61964196", "0.61918867", "0.61916155", "0.6180556", "0.61627203", "0.615435", "0.61412567", "0.61053777", "0.608...
0.75191754
0
Add new GroceryItem via form input
function addItemViaUi(form) { var inputText = $('#nameInput'); var amountText = $('#amountInput'); //add here the item and amount var item = new GroceryItem(inputText.val(), amountText.val()); groceryItems.push(item); storeGroceryItems(); updateListItem(inputText.val()); addNewUiItem(item); //empty the input text field inputText.val(""); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function insertItem(){\n item = capitalizeFirstLetter(getInput())\n checkInputLength()\n myGroceryList.push(item)\n groceryItem.innerHTML += `\n <div class=\"item\">\n <p>${item}</p>\n <div class=\"item-btns\">\n <i class=\"fa fa-edit\"></i>\n <i class=\"fa fa-trash-o\"></i>\n </div>\n </d...
[ "0.7251927", "0.7158581", "0.6990115", "0.69748384", "0.693759", "0.69231933", "0.6894868", "0.6881885", "0.6855786", "0.68001854", "0.67854905", "0.67785716", "0.6761972", "0.674216", "0.67225087", "0.6650959", "0.6646519", "0.6637863", "0.6613238", "0.6609874", "0.6586687",...
0.7773762
0
Update the counts in allItems list and store the results
function updateListItem(itemName) { //make sure that we have up to date list loadListItems(); //Now search for ListItem with same name and append count if found var result = $.grep(allItems, function(e){ return e.name == itemName; }); if( result.length > 0) { result[0].count++; } else { //If not found then add new ListItem var listItem = new ListItem(itemName, 1); allItems.push(listItem); } storeListItems(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function fnUpdateCounts() {\n\t\t\t\tvar oSmartTable = oState.oMultipleViewsHandler[oCurrentSection.key].oSmartTable;\n\t\t\t\tvar oModel = oSmartTable.getModel();\n\t\t\t\tvar oBindingContext = oSmartTable.getBindingContext();\n\t\t\t\tvar sContextPath = oBindingContext.getPath();\n\t\t\t\tvar sTableBindingPath =...
[ "0.7393488", "0.6906131", "0.6788317", "0.6772621", "0.67108995", "0.6663189", "0.65556204", "0.6501223", "0.64688104", "0.64493555", "0.64291483", "0.6406242", "0.63972586", "0.63708466", "0.63653135", "0.6330409", "0.63231987", "0.6305957", "0.629338", "0.6276228", "0.62711...
0.6410591
11
The most important UI related function. This is called whenever the grocery items list changes. The idea is to keep up two lists in UI. One with items not yet picked and other with picked up items. Clicking on each row toggles the placement of the item.
function addNewUiItem(groceryItem) { //list rows with label and count bubble var li = $('<li></li>').text(groceryItem.name); li.attr("id", groceryItem.id); //For the life of me I can't figure out why this is not rendering correctly //in desktop Chrome. Looks like a bug in Chrome or jQuery Mobile. var span = $('<span class="ui-li-count"></span>').text(groceryItem.amount); li.append(span); var ul1 = $('#ulPicked'); var ul2 = $('#ulNonPicked'); if(groceryItem.purchased) { ul1.append(li); } else { ul2.append(li); } // Bind an event to an anonymous event listener function $(li).bind("click", function(event) { var id = $(this).attr("id"); //toggle the groceryItem purchased state toggleItem(getGroceryItem(id)); //now trigger to refresh the UI lists $('#ulNonPicked').empty(); $('#ulPicked').empty(); for( var index in groceryItems) { addNewUiItem(groceryItems[index]); } }); // Refreshing magic apparently required by the jQuery Mobile if (ul1.hasClass('ui-listview')) { ul1.listview('refresh'); } else { ul1.trigger('create'); } if (ul2.hasClass('ui-listview')) { ul2.listview('refresh'); } else { ul2.trigger('create'); } // And remember to update the autocompleter list too $("#nameInput").autocomplete("update", { source: allItems.map(getListItemName), }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function handleItemCheckClicked() {\n //check for when an item has been checked-off/clicked\n //iterate through store and target item that was clicked\n //toggle checked property - change value in field\n //re-render list - to refelct updates\n $('.js-shopping-list').on('click', `.js-item-toggle`, e...
[ "0.64914685", "0.6307355", "0.6243819", "0.6148691", "0.6128149", "0.61266965", "0.6075938", "0.6074532", "0.603831", "0.6025817", "0.5996866", "0.5994919", "0.5911118", "0.5910846", "0.5908818", "0.5896436", "0.58942133", "0.58795244", "0.5878454", "0.5873967", "0.58639985",...
0.68740404
0
Toggle and save purchased state
function toggleItem(item) { if( item != null) { item.purchased = !item.purchased; } storeGroceryItems(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function saleToggle(event) {\n // console.log(event);\n if (event.target.name === 'sale') {\n currentInventory.beers[event.target.id].toggleSale();\n currentInventory.saveToLocalStorage();\n // console.log(currentInventory);\n }\n}", "function toggleReceipt(){\n\tvar caller = document.getElementById(...
[ "0.6640614", "0.6201834", "0.6122308", "0.60965633", "0.6079788", "0.6079384", "0.60002863", "0.588627", "0.58723336", "0.5856902", "0.5856902", "0.5856902", "0.5856902", "0.5856902", "0.5856902", "0.58417934", "0.58417827", "0.5803337", "0.5787874", "0.5752887", "0.5742164",...
0.6571064
1
Removal of groceryItems. UI and logic/engine not as decoupled as it should be.
function clearGroceryList() { //empty the array and store groceryItems = []; storeGroceryItems(); var form = document.getElementById("addItemForm"); var list = document.getElementById("itemListDiv"); form.itemName.value = ""; form.itemAmount.value = ""; var ul = $('#ulNonPicked'); ul.empty(); var ul2 = $('#ulPicked'); ul2.empty(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function remove_item() {\n for (var i=0; i<selected_items.length; i++) {\n items.splice(selected_items[i],1);\n }\n $('#inventory_grid').html('');\n populate_inventory_grid();\n $('#item_action_menu').hide();\n selected_items = [];\n }", "function removeGroceryItem(id)\r\n{\r\n\tfor(var ...
[ "0.7109734", "0.679115", "0.6697018", "0.6596691", "0.6541277", "0.65392613", "0.65292066", "0.65128213", "0.6463294", "0.64235705", "0.6369042", "0.6361066", "0.6287033", "0.626986", "0.6263215", "0.62592584", "0.6258997", "0.6255625", "0.62536496", "0.6249941", "0.6225385",...
0.63221866
12
Common Async fetch function
async function fetchAPI(url, callbck) { try { const resp = await fetch(url); if (!resp.ok) throw new Error(`${resp.status}`); const data = await resp.json(); callbck(data); } catch (error) { alert("Error in fetching data , Getting " + error); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async fetchAsync() {\n // await response of fetch call\n let response = await fetch(this.restApiUrl + this.params);\n // only proceed once promise is resolved\n return await response.json();\n }", "async function executeHardAsync() {\n const r1 = await fetchUrlData(apis[0]);\n co...
[ "0.7167178", "0.70629245", "0.7042535", "0.70252335", "0.7006194", "0.68574464", "0.6716772", "0.6659964", "0.66044736", "0.6589966", "0.6510836", "0.65044314", "0.64798045", "0.6474589", "0.64671415", "0.64663035", "0.6466041", "0.64128417", "0.64109653", "0.64075875", "0.64...
0.6092716
72
for displaying DOM for movies
function displayMovies({ results: data }) { console.log(data); rowDiv.innerHTML = ""; data.forEach((el) => { rowDiv.innerHTML += ` <div class="col-3 m-2 d-flex"> <div class="card bg-dark text-warning"> <img src="https://i.pinimg.com/564x/dd/a2/0a/dda20a2031f4ff11572dce69a356b7db.jpg" class="card-img" alt="..."> <div class="card-img-overlay font-weight-bolder"> <h5 class="card-title">${el.title}</h5> <p class="card-text">${ el.opening_crawl.slice(0, 190) + "..." }</p> </div> </div> </div> `; }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function renderDOM(movieInfo){\n loaderEl.classList.toggle(\"invisible\");\n console.log(\"Rendering movie results\");\n var article = document.querySelector(\"article\");\n article.innerHTML = \"\";\n movieInfo.forEach(function(movie){\n var section = document.createElement('section');\n var title = do...
[ "0.74310344", "0.7373555", "0.7276907", "0.7202683", "0.717885", "0.71189845", "0.70385873", "0.70245725", "0.7009954", "0.6969456", "0.6960769", "0.69242036", "0.68266284", "0.67893827", "0.67539376", "0.6685809", "0.66789347", "0.6654403", "0.6642738", "0.6633725", "0.66285...
0.615804
82
for displaying DOM for characters
function displayCharacters({ results: data }) { rowDiv.innerHTML = ""; data.forEach((el) => { rowDiv.innerHTML += ` <div class="col-3 m-2 d-flex"> <div class="card border-warning mb-3 bg-warning" style="max-width: 18rem;"> <div class="card-header text-white text-center">CHARACTER</div> <div class="card-body text-white"> <h5 class="card-title">${el.name}</h5> <p class="card-text">has height ${el.height} and mass ${el.mass}. has skin color ${el.skin_color} and eye color ${el.eye_color} and born in ${el.birth_year}</p> </div> </div> </div> `; }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function displayDOM(){\r\n\t\tvar str = '';\r\n\t\tcontainer.getChildren().each(function(item){\r\n\t\t\tstr += '<div style=\"' + item.style.cssText + '\">' + item.get('text') + '</div>\\n';\r\n\t\t});\r\n\t\tdocument.id('output').set('text', str);\r\n\t}", "function _getRulaiHtml(content){\n\n}", "function c...
[ "0.6462422", "0.6180795", "0.60931736", "0.60899043", "0.5996753", "0.59818316", "0.59798557", "0.5913255", "0.58871835", "0.5864064", "0.58455527", "0.58188194", "0.5813025", "0.5809126", "0.57974833", "0.5795635", "0.57791024", "0.57791024", "0.57791024", "0.57791024", "0.5...
0.0
-1
for displaying DOM for planets
function displayPlanets({ results: data }) { rowDiv.innerHTML = ""; data.forEach((el) => { rowDiv.innerHTML += ` <div class="col-3 m-2 d-flex"> <div class="card border-success mb-3 bg-success" style="max-width: 18rem;"> <div class="card-header text-white text-center">PLANET</div> <div class="card-body text-white"> <h5 class="card-title">${el.name}</h5> <p class="card-text">has diameter ${el.diameter} and climate ${el.climate}. has ${el.terrain} terrain and population ${el.population}</p> </div> </div> </div> `; }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function populateSolarSystem(planet){\n var el = document.getElementById(\"planets\");\n el.innerHTML += '<div>' + planet + '</div>'\n}", "function Planets(){\n\t// Heliocentric Osculating Orbital Elements Referred to the Mean Equinox and Ecliptic of Date for 2013: http://asa.usno.navy.mil/static/files/2013/Os...
[ "0.6450906", "0.6314949", "0.6300873", "0.6282003", "0.6044119", "0.6044119", "0.6044119", "0.6044119", "0.6025902", "0.5966472", "0.5963442", "0.5959372", "0.5945893", "0.5944377", "0.5940851", "0.58242494", "0.579576", "0.5783829", "0.5781431", "0.5777222", "0.5765223", "...
0.65302455
0
for displaying DOM for starships
function displayStarships({ results: data }) { rowDiv.innerHTML = ""; data.forEach((el) => { rowDiv.innerHTML += ` <div class="col-3 m-2 d-flex"> <div class="card border-info mb-3 bg-info" style="max-width: 18rem;"> <div class="card-header text-white text-center font-weight-bold">STARSHIP</div> <div class="card-body text-white"> <h5 class="card-title">${el.name}</h5> <p class="card-text">Manufactured by ${el.manufacturer} and costs ${el.cost_in_credits}.It can attain maximum speed of ${el.max_atmosphering_speed} and hold ${el.crew} crew and ${el.passengers} passengers and has cargo capacity of ${el.cargo_capacity} and ship belongs to ${el.starship_class} class</p> </div> </div> </div> `; }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function displayStars(star){\n star.setAttribute(\"class\", \"stars\");\n global.starsDiv.appendChild(star);\n}", "function dispStars() {\n let starsOnPage = generateStars();\n document.querySelector('.stars').innerHTML = starsOnPage;\n}", "function render_stars(){\n \n}", "function drawTableStarsh...
[ "0.7123827", "0.70032483", "0.6913762", "0.6868963", "0.6861025", "0.67854404", "0.67039883", "0.6552185", "0.65387106", "0.647762", "0.6466342", "0.6433724", "0.6411823", "0.6318343", "0.63134444", "0.6306008", "0.6293579", "0.62625486", "0.62576693", "0.62261623", "0.622480...
0.657334
7
Fix bug in 40x40 on lose, only half the screen is "ended" fix bug in flags... currently cannot remove them. You clicked on a mine.
function gameOver() { for(var i = 0; i < game.size; i++) { for(var j = 0; j < game.size; j++) { var cell = document.getElementById("cell" + i + "_" + j); // if the cell is flagged, and there is no mine, place an x. // if(!game.mines[x][y] && game.flagged[x][y]) if(cell.isFlagged && !game.mines[i][j]) { cell.style.backgroundImage = "url(images/redx.gif)"; cell.style.backgroundRepeat = "no-repeat"; cell.style.backgroundPosition = "center"; } if(!game.clicked[i][j]) { clickCell(i,j); } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function lose() {\n if ((currentTime === 0) || (squares[index].classList.contains('c1')) ||\n (squares[index].classList.contains('l5')) ||\n (squares[index].classList.contains('l4'))\n ) {\n result.innerHTML = 'Thanos snapped fingers😢'\n squares[index].cla...
[ "0.6708968", "0.6411986", "0.63470155", "0.63454556", "0.63312566", "0.62767684", "0.6276246", "0.62734693", "0.62171596", "0.61796474", "0.6166963", "0.61498654", "0.61090004", "0.60969526", "0.607955", "0.6075843", "0.6067581", "0.6052249", "0.6025679", "0.6025321", "0.6024...
0.0
-1
AW4.Logger.log(message) > No return value message (String): A check for if window.console is defined is performed, and if window.console is defined, then message will be sent to console.log. TODO: Support multiple arguments
function log(message) { if(typeof window.console !== 'undefined') { console.log(message); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function consoleLog() {\n if (typeof(console) == 'object' && typeof(console[\"log\"]) != \"undefined\") {\n console.log.apply(console, arguments);\n }\n}", "static log() {\n var str;\n str = Util.toStrArgs('', arguments);\n Util.consoleLog(str);\n }", "function log(msg, useInBrow...
[ "0.7745783", "0.76681614", "0.7597342", "0.75778437", "0.75726646", "0.7517488", "0.7515555", "0.7500589", "0.74482787", "0.74482787", "0.74023247", "0.74023247", "0.73960346", "0.7383152", "0.7348608", "0.73450404", "0.73141205", "0.7296113", "0.729192", "0.7277668", "0.7276...
0.731346
17
AW4.Logger.warn(message) > No return value message (String): A check for if window.console is defined is performed, and if window.console is defined, then message will be sent to console.warn. TODO: Support multiple arguments
function warn(message) { if(typeof window.console !== 'undefined') { console.warn(message); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static warn(...args) {\n if (this.toLog('WARN')) {\n console.warn.apply(console, arguments);\n }\n }", "function warn() {\n var messages = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n messages[_i] = arguments[_i];\n }\n if (console) {\n console.war...
[ "0.7904975", "0.78241384", "0.76855195", "0.7582896", "0.7572712", "0.7500429", "0.7428229", "0.73933005", "0.73642147", "0.7343254", "0.7325556", "0.7296467", "0.72964436", "0.7076384", "0.7076384", "0.70733565", "0.7062092", "0.7062092", "0.7043117", "0.7023904", "0.7017066...
0.74192995
7
AW4.Logger.error(message) > No return value message (String): A check for if window.console is defined is performed, and if window.console is defined, then message will be sent to console.error. TODO: Support multiple arguments
function error(message) { if(typeof window.console !== 'undefined') { console.error(message); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function err() {\n logWithProperFormatting(out.console.error, '(ERROR)', arguments);\n}", "static error(...args) {\n if (this.toLog('ERROR')) {\n console.error.apply(console, arguments);\n }\n }", "error(message, ...params) {\n console.error.apply(console, arguments);\n ...
[ "0.7925214", "0.7526377", "0.74398774", "0.7329743", "0.6999763", "0.6986417", "0.6974708", "0.6965081", "0.6944478", "0.6911218", "0.68945915", "0.68827933", "0.68746495", "0.6854733", "0.68275243", "0.680545", "0.6789013", "0.67724454", "0.6765642", "0.6749899", "0.67226875...
0.69943666
5
AW4.Utils.utoa(inputString) > String inputString: The inputString can be utf8 or unicode. The output string is a base64 string.
function utoa(inputString) { if(window.btoa){ return window.btoa(unescape(encodeURIComponent(inputString))); } else { return inputString; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function utoa(str) {\n return btoa(unescape(encodeURIComponent(str)));\n}", "utoa(str) {\n return window.btoa(unescape(encodeURIComponent(str)));\n }", "function utoa(data) {\n return btoa(unescape(encodeURIComponent(data)));\n}", "function atou(inputString) {\n if (window.atob) {\n ...
[ "0.7823711", "0.7382929", "0.71013993", "0.6990338", "0.66636753", "0.66384375", "0.6538567", "0.64838755", "0.6418238", "0.6345552", "0.63169825", "0.6314616", "0.6265884", "0.62326443", "0.62326443", "0.62326443", "0.62150776", "0.6199463", "0.61816764", "0.61773944", "0.61...
0.8440103
0
AW4.Utils.atou(inputString) > String inputString: The input string is a base64 string. The output is a unicode string.
function atou(inputString) { if (window.atob) { return decodeURIComponent(escape(window.atob(inputString))); } else { return inputString; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function utoa(inputString) {\n if(window.btoa){\n return window.btoa(unescape(encodeURIComponent(inputString)));\n } else {\n return inputString;\n }\n }", "function utoa(str) {\n return btoa(unescape(encodeURIComponent(str)));\n}", "atou(s...
[ "0.7478999", "0.686106", "0.68504506", "0.67986727", "0.67014015", "0.6632679", "0.6632679", "0.63656646", "0.6357858", "0.62902915", "0.6272092", "0.6269597", "0.62670803", "0.61012405", "0.600476", "0.5977111", "0.58825684", "0.58099866", "0.57522464", "0.57221067", "0.5706...
0.7518563
0
Called to initialize the plugin, it creates a new instance by appending an element to the DOM and runs the callback with the status
function initNPAPIPlugin(options) { var onLoadCallback = options.callback || function(){}; try { if (!isSupportedByBrowser()) { //Browser does not support Netscape Plugin API } else if (npapiPlugin == null) { if ((AW4.Utils.BROWSER.IE && (new ActiveXObject("Aspera.AsperaWebCtrl.1"))) || navigator.mimeTypes[mimeType()] !== undefined) { listenerId = options.containerId; pluginId = options.pluginId; createNPAPIPlugin(options.initializeTimeout); /* Safari needs a timeout to finish loading the plugin * Firefox if prompts user to allow plugin will take as much as * the user takes to allow the plugin to initialize the object, * so we just put an interval and keep trying until the object is * initialized and has the expected call */ var npapiWaitPluginLoadedID = setInterval(function() { if (!npapiPlugin || !npapiPlugin.queryBuildVersion) { return null; } clearInterval(npapiWaitPluginLoadedID); //Check version is correct if (AW4.Utils.versionLessThan(npapiPlugin.queryBuildVersion(), '3.6')) { npapiPlugin = null; onLoadCallback(AW4.Connect.STATUS.FAILED); } else { onLoadCallback(AW4.Connect.STATUS.RUNNING); } }, 500); } else { //If plugin is still null, it means it is not installed if (npapiPlugin == null) { onLoadCallback(AW4.Connect.STATUS.FAILED); } } } } catch (error) { //IE 10 ActiveXObject instantiation error recovery onLoadCallback(AW4.Connect.STATUS.FAILED); } return null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "connectedCallback() {\n\t\n\tlet elem=$(statusbartext);\n\tthis.appendChild(elem[0]);\n }", "_spawn() {\n const parentElement = document.querySelector(this.parentSelector);\n parentElement.appendChild(this.sliderElement);\n this.ready = true;\n }", "_init() {\n this.add(t...
[ "0.59744924", "0.59215236", "0.5856296", "0.5853536", "0.5795047", "0.57685643", "0.5766428", "0.56807005", "0.56694174", "0.5636327", "0.5581427", "0.5512413", "0.55041105", "0.5485796", "0.5436889", "0.54157245", "0.54129386", "0.54005265", "0.5388412", "0.5382168", "0.5377...
0.0
-1
Add the default "load" and "message" event listeners to the element with id "listener". The "load" event is sent when the module is successfully loaded. The "message" event is sent when the naclModule posts a message using PPB_Messaging.PostMessage() (in C) or pp::Instance().PostMessage() (in C++).
function createListenerDiv(listenerId) { var listenerDiv = document.getElementById(listenerId); if (listenerDiv == null) { listenerDiv = document.createElement('div'); listenerDiv.setAttribute('id', listenerId); listenerDiv.setAttribute('style', "display:inline-block;height:1px;width:1px;"); } else { //Remove all elements of the wrapper while (listenerDiv.firstChild) { listenerDiv.removeChild(listenerDiv.firstChild); } } return listenerDiv; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function attachDefaultListeners(listenerDiv) {\n listenerDiv.addEventListener('load', moduleDidLoad, true);\n listenerDiv.addEventListener('message', handleMessage, true);\n listenerDiv.addEventListener('error', handleError, true);\n listenerDiv.addEventListener('crash', handleCrash, tr...
[ "0.7274127", "0.67004335", "0.66056156", "0.645656", "0.6259429", "0.6193459", "0.6138622", "0.60621035", "0.6056356", "0.59588027", "0.5958004", "0.59564286", "0.59564286", "0.5953509", "0.5926793", "0.5925481", "0.59163356", "0.58962137", "0.5887626", "0.5887626", "0.588326...
0.0
-1
Add the default "load" and "message" event listeners to the element with id "listener". The "load" event is sent when the module is successfully loaded. The "message" event is sent when the naclModule posts a message using PPB_Messaging.PostMessage() (in C) or pp::Instance().PostMessage() (in C++).
function attachDefaultListeners(listenerDiv) { listenerDiv.addEventListener('load', moduleDidLoad, true); listenerDiv.addEventListener('message', handleMessage, true); listenerDiv.addEventListener('error', handleError, true); listenerDiv.addEventListener('crash', handleCrash, true); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function load(){\n\t\t\t\t\t// dec 2015 seems not to be called at all even with add listener in place\n\t\t\t\t\tif (CONST_SHOW_INIT_ALERTS)\n\t\t\t\t\t alert('inONLOADINIT#3.5 in addEventListener load in function load(){');\n\n\t\t\t\t\t//var el = document.getElementById(\"foo\");\n\t\t\t\t\t//alert(el);\n\t\t...
[ "0.6700577", "0.6606578", "0.6458738", "0.62614715", "0.61922395", "0.6140562", "0.6061487", "0.60592395", "0.59603447", "0.5957826", "0.59576917", "0.59576917", "0.59542686", "0.5927538", "0.5924778", "0.5918582", "0.58977693", "0.58866227", "0.58866227", "0.588635", "0.5883...
0.7274345
0
Called when the NaCl module fails to load. This event listener is registered in createNaClModule above.
function handleError(event) { // We can't use common.naclModule yet because the module has not been // loaded. }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function NaClModuleError(event)\n{\n NaClRestartModule();\n AddTextStatus(\"Module Load/start Error ! Restarting ...\");\n}", "function NaClLoadingInit()\n{\n HideProgressStatus(false);\n //Page did load before NaCl module\n if (!g_embed_module)\n AddTextStatus('Please wait for module loadi...
[ "0.77593607", "0.6282221", "0.6072994", "0.60244846", "0.58652115", "0.58132577", "0.57636225", "0.5633213", "0.5599228", "0.5539235", "0.55237347", "0.5516494", "0.5488744", "0.54619133", "0.5395556", "0.53943974", "0.5286247", "0.5281936", "0.52816176", "0.52603394", "0.510...
0.724533
1
Called when the Browser can not communicate with the Module This event listener is registered in attachDefaultListeners above.
function handleCrash(event) { }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "onDetectError() {\n\t\tthis.removeEventListeners();\n\t\tthis.onError();\n\t}", "disconnectedCallback() {\n this.setupWindowEvents(false);\n super.disconnectedCallback();\n }", "handleUnableToConnectToChannelDataSocketMessage(message) {\n // Pass on this information to the upper controls\n ...
[ "0.63186765", "0.6302935", "0.6241428", "0.5982368", "0.5962737", "0.5961247", "0.59557354", "0.5791024", "0.57363516", "0.5718313", "0.5704501", "0.5702755", "0.56849396", "0.56723", "0.5671249", "0.56611407", "0.5653324", "0.56453985", "0.5644656", "0.5641317", "0.56261927"...
0.0
-1
Called when the NaCl module is loaded. This event listener is registered in attachDefaultListeners above.
function moduleDidLoad() { naclModule = document.getElementById(pluginId); onLoadCallback(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function NaClLoadingInit()\n{\n HideProgressStatus(false);\n //Page did load before NaCl module\n if (!g_embed_module)\n AddTextStatus('Please wait for module loading');\n RegisterListener();\n}", "function NaClModuleDidLoad()\n{\n if (!g_embed_module)\n NaClInitModuleVar();\n\n /...
[ "0.776558", "0.69528604", "0.68001455", "0.6612015", "0.64014035", "0.6275153", "0.61816937", "0.6145893", "0.6114118", "0.6077327", "0.6055524", "0.6025819", "0.6014637", "0.60140455", "0.59998804", "0.59985787", "0.59484637", "0.5921104", "0.5877067", "0.58742106", "0.58683...
0.70820576
1
Called to initialize the plugin, it creates a new instance by appending an element to the DOM and runs the callback with the status
function initPPAPIPlugin(options) { if (!isSupportedByBrowser()) { //Browser does not support NaCl (pnacl), or NaCl is disabled } else if (naclModule == null) { //Register onLoadCallback onLoadCallback = options.callback || function(){}; pluginId = options.pluginId; var parent = createListenerDiv(options.containerId); attachDefaultListeners(parent); var NaClModule = createNaClModule(options.sdkLocation); // The <EMBED> element is wrapped inside a <DIV>, which has both a 'load' // and a 'message' event listener attached. This wrapping method is used // instead of attaching the event listeners directly to the <EMBED> element // to ensure that the listeners are active before the NaCl module 'load' // event fires. parent.appendChild(NaClModule); document.body.appendChild(parent); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "connectedCallback() {\n\t\n\tlet elem=$(statusbartext);\n\tthis.appendChild(elem[0]);\n }", "_spawn() {\n const parentElement = document.querySelector(this.parentSelector);\n parentElement.appendChild(this.sliderElement);\n this.ready = true;\n }", "ready() {\n super.read...
[ "0.5977479", "0.59216064", "0.58538246", "0.58528674", "0.57953316", "0.57689", "0.57666963", "0.5681493", "0.5668263", "0.56326514", "0.55818194", "0.5508453", "0.550437", "0.5481984", "0.5435431", "0.54170173", "0.5412128", "0.5401464", "0.53847486", "0.5383464", "0.5378656...
0.0
-1
Manage Connect Status and high level logic
function notifyStatusListeners(notifyStatus) { for (var i = 0; i < statusListeners.length; i++) { var listener = statusListeners[i](AW4.Connect.EVENT.STATUS, notifyStatus); }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function connectionStatus(err,ok){\n \n if(err){\n \n console.log(err.message);\n \n }\n else{\n \n console.log(\"We are connected!\");\n }\n}", "function connectionStatus() {\n if (!window.connecting || retry == 20) {\n window.forci...
[ "0.71956915", "0.7157725", "0.71376854", "0.70295405", "0.68338335", "0.68122184", "0.67601204", "0.6741779", "0.65228933", "0.651691", "0.65002865", "0.64359194", "0.64226425", "0.6422087", "0.64018404", "0.6343964", "0.6325272", "0.6275586", "0.626878", "0.62572044", "0.625...
0.0
-1
Takes input of form of output (y)
function move(x, y){ var a; switch (y.val){ case "": a = new Board([], ""); break; case "x": a = new Board([], "x"); break; case "o": a = new Board([], "o"); break; } a.next = y.next; for (var i = 0; i < 9; i++){ switch (y.spaces[i].val){ case "": a.spaces[i] = new Board([], ""); break; case "x": a.spaces[i] = new Board([], "x"); break; case "o": a.spaces[i] = new Board([], "o"); break; } for (var j = 0; j < 9; j++){ switch (y.spaces[i].spaces[j].val){ case "": a.spaces[i].spaces[j] = new space("", 9*i + j); break; case "x": a.spaces[i].spaces[j] = new space("x", 9*i + j); break; case "o": a.spaces[i].spaces[j] = new space("o", 9*i + j); break; } } } var b; if (clicks%2 == 0){ b = "x"; } else{ b = "o"; } var c = x%9; var d = Math.floor(x/9); a.spaces[d].spaces[c].val = b; if(a.spaces[d].val == ""){ if(check5(c, bool, a.spaces[d])){ a.spaces[d].val = b; if(check5(d, bool, a)){ a.val = b; } } } if (empty(a.spaces[c]).length == 0){ a.next = -1; } else{ a.next = c; } return a }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function output(xv, yhat, ux, uy) {\n const n = xv.length, out = [];\n let i = 0, cnt = 0, prev = [], v;\n\n for (; i<n; ++i) {\n v = xv[i] + ux;\n if (prev[0] === v) {\n // average output values via online update\n prev[1] += (yhat[i] - prev[1]) / (++cnt);\n } else {\n // add new output...
[ "0.5823159", "0.5766679", "0.5732664", "0.56184053", "0.55826324", "0.55339074", "0.55276585", "0.5444977", "0.5441574", "0.53236115", "0.5317111", "0.5317111", "0.5310599", "0.52806", "0.52410305", "0.5237052", "0.5210941", "0.5209942", "0.5206243", "0.52017665", "0.5198456"...
0.0
-1
check5 is a helper function for check3 and 4 to see if a 3x3 board is filled
function check5(x, y, z){ switch (x){ case 0: if(z.spaces[x].val == z.spaces[x+1].val && z.spaces[x].val == z.spaces[x+2].val){ return y[2]; } else if(z.spaces[x].val == z.spaces[x+3].val && z.spaces[x].val == z.spaces[x+6].val){ return y[3]; } else if(z.spaces[x].val == z.spaces[x+4].val && z.spaces[x].val == z.spaces[x+8].val){ return y[0]; } break; case 1: if(z.spaces[x].val == z.spaces[x-1].val && z.spaces[x].val == z.spaces[x+1].val){ return y[2]; } else if(z.spaces[x].val == z.spaces[x+3].val && z.spaces[x].val == z.spaces[x+6].val){ return y[3]; } break; case 2: if(z.spaces[x].val == z.spaces[x-1].val && z.spaces[x].val == z.spaces[x-2].val){ return y[2]; } else if(z.spaces[x].val == z.spaces[x+3].val && z.spaces[x].val == z.spaces[x+6].val){ return y[3]; } else if(z.spaces[x].val == z.spaces[x+2].val && z.spaces[x].val == z.spaces[x+4].val){ return y[1]; } break; case 3: if(z.spaces[x].val == z.spaces[x+1].val && z.spaces[x].val == z.spaces[x+2].val){ return y[2]; } else if(z.spaces[x].val == z.spaces[x+3].val && z.spaces[x].val == z.spaces[x-3].val){ return y[3]; } break; case 4: if(z.spaces[x].val == z.spaces[x+1].val && z.spaces[x].val == z.spaces[x-1].val){ return y[2]; } else if(z.spaces[x].val == z.spaces[x+3].val && z.spaces[x].val == z.spaces[x-3].val){ return y[3]; } else if(z.spaces[x].val == z.spaces[x+4].val && z.spaces[x].val == z.spaces[x-4].val){ return y[0]; } else if(z.spaces[x].val == z.spaces[x+2].val && z.spaces[x].val == z.spaces[x-2].val){ return y[1]; } break; case 5: if(z.spaces[x].val == z.spaces[x-1].val && z.spaces[x].val == z.spaces[x-2].val){ return y[2]; } else if(z.spaces[x].val == z.spaces[x+3].val && z.spaces[x].val == z.spaces[x-3].val){ return y[3]; } break; case 6: if(z.spaces[x].val == z.spaces[x+1].val && z.spaces[x].val == z.spaces[x+2].val){ return y[2]; } else if(z.spaces[x].val == z.spaces[x-6].val && z.spaces[x].val == z.spaces[x-3].val){ return y[3]; } else if(z.spaces[x].val == z.spaces[x-2].val && z.spaces[x].val == z.spaces[x-4].val){ return y[1]; } break; case 7: if(z.spaces[x].val == z.spaces[x+1].val && z.spaces[x].val == z.spaces[x-1].val){ return y[2]; } else if(z.spaces[x].val == z.spaces[x-6].val && z.spaces[x].val == z.spaces[x-3].val){ return y[3]; } break; case 8: if(z.spaces[x].val == z.spaces[x-2].val && z.spaces[x].val == z.spaces[x-1].val){ return y[2]; } else if(z.spaces[x].val == z.spaces[x-6].val && z.spaces[x].val == z.spaces[x-3].val){ return y[3]; } else if(z.spaces[x].val == z.spaces[x-4].val && z.spaces[x].val == z.spaces[x-8].val){ return y[0]; } break; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function checkBoard(i1, i2, i3, i4, i5) {\n if (checkArray(i1, clickedSquares)) {\n if (checkArray(i2, clickedSquares)) {\n if (checkArray(i3, clickedSquares)) {\n if (checkArray(i4, clickedSquares)) {\n if (checkArray(i5, clickedSquares)) {\n return true;\n }\n ...
[ "0.77500504", "0.7426429", "0.7153218", "0.69494236", "0.6838821", "0.6758398", "0.6720942", "0.6717369", "0.6713835", "0.6704113", "0.66935766", "0.66505206", "0.6628895", "0.6622871", "0.6619519", "0.6609219", "0.6599571", "0.65916944", "0.6589297", "0.6576129", "0.657405",...
0.0
-1
check4 checks whether or not the entire board is finished
function check4(){ if(check5(num2, bool, W)){ if(Player == 0){ W.val = "x"; } else{ W.val = "o"; } } if(W.val != ""){ if(Player == 0){ alert("WINNER: PLAYER 1"); } else{ alert("WINNER: PLAYER 2"); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "checkCompletedBoard(){\n let totalSquares = board.columnCount * board.rowCount;\n let dustedSquaresCount = 0;\n for(let checkColumn=0; checkColumn<board.columnCount; checkColumn++) {\n for(let checkRow=0; checkRow<board.rowCount; checkRow++) {\n let s = board.squares[...
[ "0.76263773", "0.7209189", "0.71142435", "0.6995599", "0.69557774", "0.6913705", "0.69042474", "0.6875021", "0.68453753", "0.6830001", "0.6826673", "0.66988456", "0.6677639", "0.6663204", "0.6661953", "0.6578312", "0.6543066", "0.6514801", "0.6503623", "0.6491095", "0.6488040...
0.59682125
94
unCheck returns which of the large boards you are in
function unCheck(){ return "." + wboxes[num2]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "cleanBoard(treeCheck) {\n for (let cell of this.board) {\n if (!treeCheck.includes(cell.index)) {\n cell.hasTree = false;\n cell.myTree = false;\n cell.ennemyTree = false;\n }\n }\n }", "function unconstrained(board) {\n var bits = figurebits(board);\n var results = [];\n ...
[ "0.5998941", "0.59455794", "0.5922628", "0.58939195", "0.58285314", "0.5810276", "0.5797866", "0.57577205", "0.5617066", "0.5587637", "0.55687565", "0.5552454", "0.551784", "0.5497654", "0.5486879", "0.5479771", "0.5471713", "0.5442328", "0.5429593", "0.54264605", "0.54258114...
0.60791045
0
addLine draws a line through a completed row/column/diagonal
function addLine(){ var x = unCheck(); var y = check5(num3, line, W.spaces[num2]); switch (y){ case "diagonal1": $(x + ".TL").addClass("diagonal1"); $(x + ".MM").addClass("diagonal1"); $(x + ".BR").addClass("diagonal1"); line2 = 1; break; case "diagonal2": $(x + ".TR").addClass("diagonal2"); $(x + ".MM").addClass("diagonal2"); $(x + ".BL").addClass("diagonal2"); line2 = 2; break; case "horizontal": if(num%9 < 3){ $(x + ".TL").addClass("horizontal"); $(x + ".TM").addClass("horizontal"); $(x + ".TR").addClass("horizontal"); } else if(num%9 < 6){ $(x + ".ML").addClass("horizontal"); $(x + ".MM").addClass("horizontal"); $(x + ".MR").addClass("horizontal"); } else{ $(x + ".BL").addClass("horizontal"); $(x + ".BM").addClass("horizontal"); $(x + ".BR").addClass("horizontal"); } line2 = 3; break; case "vertical": if (num%3 == 0){ $(x + ".TL").addClass("vertical"); $(x + ".ML").addClass("vertical"); $(x + ".BL").addClass("vertical"); } else if(num%3 == 1){ $(x + ".TM").addClass("vertical"); $(x + ".MM").addClass("vertical"); $(x + ".BM").addClass("vertical"); } else{ $(x + ".TR").addClass("vertical"); $(x + ".MR").addClass("vertical"); $(x + ".BR").addClass("vertical"); } line2 = 4; break; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function addline() {\n line(0,sz,sz*3,sz);\n line(0,sz*2,sz*3,sz*2);\n line(sz,0,sz,sz*3);\n line(sz*2,0,sz*2,sz*3);\n}", "addLineTo(nPoint) {\n this.nLine[this.nLines] = nPoint\n this.nLines++\n }", "addLine() {\n this.chart.append(\"path\")\n .datum(this.dataset) // Binds data to...
[ "0.7340348", "0.6899158", "0.68432015", "0.67454743", "0.67243296", "0.66277677", "0.66255695", "0.6610308", "0.65740377", "0.656282", "0.6435089", "0.64208174", "0.6415634", "0.6392888", "0.6383595", "0.6319213", "0.6314868", "0.6178435", "0.6161926", "0.61600596", "0.615369...
0.65361804
10
check3 checks whether or not the small board is finished and fills the over array
function check3(){ if(W.spaces[num2].val == ""){ end = check5(num3, bool, W.spaces[num2]); if(end){ if(Player == 0){ W.spaces[num2].val = "x"; } else{ W.spaces[num2].val = "o"; } end = false; addLine(); line2 = 0; check4(); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function checkRowForThree() {\n for (i = 0; i < 62; i++) {\n //if we use indexes to draw our row, it would look like this\n let rowOfThree = [i, i + 1, i + 2];\n //this is the color to eliminate\n let decidedColor = squares[i].style.backgroundImage;\n\n //below is a variable to confirm ...
[ "0.7030347", "0.6933374", "0.67135054", "0.67006177", "0.66580075", "0.6590619", "0.65760607", "0.6563667", "0.6557479", "0.6542673", "0.65252924", "0.65067905", "0.6483336", "0.6390077", "0.6358247", "0.630284", "0.6275712", "0.6263661", "0.6241032", "0.62304884", "0.6230087...
0.6024741
50
check2 is a helper function of check
function check2(x){ for (var i = 0; i < 9; i++){ if ($(x).hasClass(boxes[i])){ num += i; num2 = Math.floor(num/9); num3 = num%9 break; } } if(Player == 0){ W.spaces[num2].spaces[num3].val = "x"; } else{ W.spaces[num2].spaces[num3].val = "o"; } check3(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function check() {}", "function check1() {\n\n}", "function check3 (){\n\n}", "function checkStep2()\n {\n var validData = true;\n\n //alert(\"Alert Data 1:\" + validData);\n validData = checkUserFname(validData);\n //alert(\"Alert Data 2:\" + validData);\n ...
[ "0.76564896", "0.70168316", "0.6720201", "0.6490095", "0.6425672", "0.6245725", "0.6172545", "0.6132455", "0.60829526", "0.60496753", "0.6023427", "0.60185784", "0.59998", "0.5982703", "0.5893855", "0.5887611", "0.5870424", "0.58684015", "0.5863929", "0.58556545", "0.5852602"...
0.5644601
36
check finds the square selected and fills the corresponding element of the fill array (with the help of check2)
function check(x){ for (var i = 0; i < 9; i++){ if ($(x).hasClass(wboxes[i])){ num = 9*i; break; } } check2(x); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "isFilled(i_check, j_check){\n let currentView = this.state.layout.length-1;\n if(i_check>=8 || j_check>=8 || i_check<0 || j_check<0){\n return \"stop\";\n }\n let square_value = this.state.layout[currentView][i_check][j_check];\n if(square_value === 32){\n return \"empty\";\n }\n if(...
[ "0.6593022", "0.64697504", "0.6435962", "0.6433834", "0.62961864", "0.62484646", "0.6209653", "0.60543966", "0.601789", "0.59898496", "0.5969202", "0.59510005", "0.59311235", "0.59132", "0.58991814", "0.588958", "0.5877396", "0.5854163", "0.58496344", "0.5839149", "0.5835832"...
0.0
-1
returnClass adds onto the w variables (for the next move) and adjusts next
function returnClass(x){ check(x); for (var v = 0; v < 9; v++){ if($(x).hasClass(boxes[v])){ if(empty(W.spaces[v]).length == 0){ W.next = -1; } else{ W.next = v; } break; } } clicks++; ////////////////////////////////////////////////////////////////////// if(W.val == ""){ num = sim(difficulty); num2 = Math.floor(num/9); num3 = num%9; clicks=clicks-difficulty; var m = move(num, W); clicks++; if (Player == 0){ $("." + wboxes[num2] + "." + boxes[num3]).text("o"); } else{ $("." + wboxes[num2] + "." + boxes[num3]).text("x"); } $("." + wboxes[num2] + "." + boxes[num3]).css("background-color", "lightgreen") ; if(W.spaces[num2].val != m.spaces[num2].val){ W = m; addLine(); switch(line2){ case 1: $("." + wboxes[num2] + "." + boxes[num3]).removeClass("diagonal1"); $("." + wboxes[num2] + "." + boxes[num3]).addClass("green1"); break; case 2: $("." + wboxes[num2] + "." + boxes[num3]).removeClass("diagonal2"); $("." + wboxes[num2] + "." + boxes[num3]).addClass("green2"); break; case 3: $("." + wboxes[num2] + "." + boxes[num3]).removeClass("horizontal"); $("." + wboxes[num2] + "." + boxes[num3]).addClass("green3"); break; case 4: $("." + wboxes[num2] + "." + boxes[num3]).removeClass("vertical"); $("." + wboxes[num2] + "." + boxes[num3]).addClass("green4"); break; } } else{ W = m; } if (W.val != ""){ if (Player == 0){ alert("WINNER: PLAYER 2"); } else{ alert("WINNER: PLAYER 1"); } } } ////////////////////////////////////////////////////////////////////// if(clicks==81){ W.val = -1; alert("TIE"); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function returnClass(x){\n\t\t\tcheck(x);\n\t\t\tif($(x).hasClass(\"TL\")){\n\t\t\t\tif(wTL == 9){\n\t\t\t\t\tnext = \"\"\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tnext = \"wTL\";\n\t\t\t\t\twTL++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if($(x).hasClass(\"TM\")){\n\t\t\t\tif(wTM == 9){\n\t\t\t\t\tnext = \"\";\n\t\t\t\t}\n\t\t...
[ "0.6339678", "0.56523997", "0.5621782", "0.55583286", "0.55083793", "0.54640955", "0.54467124", "0.53802097", "0.5359343", "0.5338864", "0.5338864", "0.52569836", "0.52497625", "0.5244416", "0.51935565", "0.5187655", "0.51815116", "0.51745206", "0.5158595", "0.5155648", "0.51...
0.6575696
0
fait sortir les personnages de trous
function startGame() { audio.play(); if(!(popup.classList.contains('cache'))){ popup.classList.add('cache'); } randompresident(); window.setInterval(function a(){ if(mich > 0){ mich-- temps.textContent= mich}}, 1000); scoreBoard.textContent = 0; timeUp = false; score = 0; sortietrou(); setTimeout(function time(){ timeUp = true; popup.classList.remove('cache'); audio.pause(); },15000) var mich = 15; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function ordenPorTitulos(misPeliculas){\n var titulos=misPeliculas.slice(0);\n titulos.sort(function(a,b){\n var x=a.titulo.toLowerCase();\n var y=b.titulo.toLowerCase();\n return x < y?-1:x>y?1:0;\n });\n console.log(titulos);\n}", "function doSortObjHighestToLowest() {\n const...
[ "0.7103467", "0.6845953", "0.6699951", "0.65770364", "0.65251935", "0.6513755", "0.64386827", "0.6431689", "0.64142376", "0.64010614", "0.6392934", "0.63754696", "0.6374938", "0.6373113", "0.63708633", "0.63673806", "0.6337563", "0.6329734", "0.6324969", "0.6323394", "0.63081...
0.0
-1
contructor gets the id and name of the shop
constructor(id, name) { this.id = id; this.name = name; this.items = []; this.totalPrice = 0; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Shopping(productId) {\n this.productId = productId.split('.')[0];\n this.urlImage = `img/${productId}`;\n this.appear = 0;\n this.clickTime = 0;\n product.push(this);\n \n}", "function Shop(){\n\tshoppingCart.call(this);\n}", "constructor(id){\n this.id = id\n this.products = []\n ...
[ "0.672061", "0.6581166", "0.6539932", "0.644553", "0.6402559", "0.6359393", "0.63431466", "0.631847", "0.63094974", "0.62772155", "0.6253027", "0.6232807", "0.62272596", "0.6212881", "0.6185895", "0.6183018", "0.6176028", "0.6163537", "0.6140855", "0.6119831", "0.60743916", ...
0.6709184
1
end getters public methods returns the index of the item by item id, if it doesn't exist it returns '1'.
indexOfItem(itemId) { let index = -1; if (this.items.length !== 0) { this.items.forEach((item, i) => { if (itemId === item.id) { index = i; } }); } return index; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "getItemIndex(id) {\n if (!id) {\n throw new Error(`An id must be provided to getItemIndex`);\n }\n if (typeof id !== 'string') {\n throw new Error(\n `The id provided to getItemIndex must be a string. Received ${id}(${typeof id})`\n );\n }\n const index = this.#items.findIndex(...
[ "0.82584035", "0.82019436", "0.7764107", "0.7290153", "0.7236267", "0.721617", "0.7114263", "0.7082757", "0.7074107", "0.7060599", "0.7059671", "0.7040884", "0.70156956", "0.6958422", "0.6942392", "0.6822852", "0.68166214", "0.68061864", "0.67867446", "0.6778315", "0.6748303"...
0.7828435
2
this methed invoked after rendering home component and it send a get request to api and api send response with all trains
componentDidMount() { document.title = "New Courses"; console.log(sessionStorage.getItem('UserID')); axios.get('http://localhost:4000/node/course/all') .then(response => { console.log(response); this.setState({ courses: response.data.courses }); }) .catch(function (error) { console.log(error); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_sendRequest() {\n fetch(this._apiUrl)\n .then((response) => {\n return response.json();\n }).then((json) => {\n this.data = json;\n\n // Render the template to the DOM\n this._render();\n });\n }", "getall(){\nreturn this.get(Config.API_URL + Constant.AGENT_GETALL)...
[ "0.6478902", "0.6429257", "0.63532805", "0.6273454", "0.62654686", "0.6240518", "0.62111336", "0.6194718", "0.61702853", "0.6170137", "0.6139464", "0.6112625", "0.6106373", "0.61042756", "0.60952586", "0.60764575", "0.6045605", "0.60160816", "0.5948226", "0.5928089", "0.59079...
0.0
-1
Function which returns true if all the fields are not empty. Otherwise, this function returns false. This trims leading and trailing blank spaces then checks if the values are not empty.
function isFilled() { /* gets the value of a specific field in the signup form then removes leading and trailing blank spaces */ var username = validator.trim($('#username').val()); var pw = validator.trim($('#pw').val()); /* checks if the trimmed values in fields are not empty */ var usernameEmpty = validator.isEmpty(username); var pwEmpty = validator.isEmpty(pw); return !usernameEmpty && !pwEmpty; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "is_empty()\n\t{\n\t\tconst { value } = this.props\n\t\treturn !value || !value.trim()\n\t}", "function isBlank(val) {\r\n if (val == null) { return true; }\r\n for (var i=0; i < val.length; i++) {\r\n if ((val.charAt(i) != ' ') && (val.charAt(i) != \"\\t\") && (val.charAt(i) != \"...
[ "0.76251644", "0.73302364", "0.7129093", "0.7108797", "0.7058447", "0.6984293", "0.6892009", "0.68730915", "0.686763", "0.6819827", "0.67504424", "0.6735881", "0.6719453", "0.6708794", "0.66770697", "0.6636236", "0.6632446", "0.66131765", "0.6609844", "0.66009015", "0.6598761...
0.62788135
63
Function which returns true if value of `pw` is a valid ID number. Otherwise, this function returns false. A valid password must contain AT LEAST 8 characters. The function has 1 parameter: field refers to the current field calling this function
function isValidPassword(field) { // sets initial value of return variable to false var validPassword = false; /* gets the value of `pw` in the signup form removes leading and trailing blank spaces then checks if it contains at least 8 characters. */ var password = validator.trim($('#pw').val()); var isValidLength = validator.isLength(password, { min: 8 }); // if the value of `pw` contains at least 8 characters if (isValidLength) { /* check if the <input> field calling this function is the `pw` <input> field */ if (field.is($('#pw'))) // remove the error message in `idNumError` $('#pwError').text(''); /* since the value of `pw` contains at least 8 characters set the value of the return variable to true. */ validPassword = true; } // else if the value of `pw` contains less than 8 characters else { /* check if the <input> field calling this function is the `pw` <input> field */ if (field.is($('#pw'))) // display appropriate error message in `pwError` $('#pwError').text(`Passwords should contain at least 8 characters.`); } // return value of return variable return validPassword; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function idPassLength(user, pw) {\n\treturn user.length >= 6 && pw.length >= 6;\n}", "function idPassCheck(user, pw) {\n\treturn user !== pw;\n}", "function validarPassword(pPassword) {\n return pPassword.trim().length >= 8;\n}", "function password() {\n var errors = document.querySelector(\"#errors\")...
[ "0.7421728", "0.7026761", "0.7016711", "0.69969225", "0.6979715", "0.6900325", "0.68847644", "0.6846741", "0.6846741", "0.68190354", "0.6793684", "0.67862415", "0.6785592", "0.67833114", "0.6775209", "0.67535895", "0.66933846", "0.6683222", "0.6664278", "0.66621566", "0.66540...
0.70803666
1
Function which checks if the `field` is empty. This also calls functions isFilled(), isValidPassword(), and isValidID(). This is attached to the `keyup` event of each field in the signup form. This activates the `submit` button if: value returned by function isFilled() is true value returned by function isValidPassword() is true value returned by function usValidID() is true The function has 3 parameters: field refers to the current field calling this function fieldName the `placeholder` of the current field calling this function error the corresponding element to display the error of the current field calling this function
function validateField(field, fieldName, error) { /* gets the value of `field` in the signup form removes leading and trailing blank spaces then checks if the trimmed value is empty. */ var value = validator.trim(field.val()); var empty = validator.isEmpty(value); // if the value of `field` is empty if (empty) { /* set the current value of `field` to an empty string this is applicable if the user just entered spaces as value to the `field` */ field.prop('value', ''); // display approriate error message in `error` error.text(fieldName + ' should not be empty.'); } else error.text(''); var filled = isFilled(); var validPassword = isValidPassword(field); isValidUsername(field, function (validUsername) { if (filled && validPassword && validUsername) $('#submit').prop('disabled', false); else $('#submit').prop('disabled', true); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isFilled() {\r\n\r\n /*\r\n gets the value of a specific field in the signup form\r\n then removes leading and trailing blank spaces\r\n */\r\n var username = validator.trim($('#username').val());\r\n var pw = validator.trim($('#pw').val());\r\n\r\n\r\n ...
[ "0.7006075", "0.6828532", "0.681491", "0.67100173", "0.65256065", "0.65156454", "0.6491049", "0.6456067", "0.6436928", "0.64086235", "0.64083016", "0.64046896", "0.6370492", "0.6360299", "0.63237834", "0.63004035", "0.6274222", "0.62429374", "0.62012255", "0.6174992", "0.6174...
0.70799905
0
We are creating a function that takes in an unsorted array of integers and returns a new array containing only the prime numbers sorted in descending order Helper Functions (Optional)
function isPrime(num){ if (num === 1 || num ===2 || num===3){ return true; } for(var i =2 ; i<=num/2 ; i++){ if (num%i === 0){ return false; } } return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function primeSort(arr) {\r\n // -------------------- Your Code Here --------------------\r\n var pArray = primeArray(arr);\r\n var sortArr = bubleSort(pArray);\r\n\r\n\r\n return sortArr;\r\n\r\n\r\n // --------------------- End Code Area --------------------\r\n}", "function primeMover(num) {\n\t var fir...
[ "0.7733044", "0.7232042", "0.70905024", "0.70055443", "0.69120336", "0.68752235", "0.6701163", "0.6610996", "0.6564417", "0.6549415", "0.64137673", "0.64049757", "0.64042723", "0.6402489", "0.637361", "0.63408345", "0.6318471", "0.63121504", "0.62690675", "0.62632155", "0.625...
0.0
-1
End Code Area Sort Function
function primeSort(arr) { // -------------------- Your Code Here -------------------- var pArray = primeArray(arr); var sortArr = bubleSort(pArray); return sortArr; // --------------------- End Code Area -------------------- }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Sort() {}", "function sortAssets2() {\r\n\t//}\r\n\tchangeList();\r\n\t}", "sort() {\n\t}", "sort() {\n\t}", "static finalSort(a, b){ return 0 }", "Sort() {\n\n }", "function sortAlpha(a, b){\r\n\t if(a < b) return -1;\r\n\t if(a > b) return 1;\r\n\t return 0;\r\n}//sortAlpha", "...
[ "0.6892754", "0.6447602", "0.6290146", "0.6290146", "0.6173859", "0.6059692", "0.5982473", "0.59756577", "0.59284776", "0.5898652", "0.58924836", "0.5891215", "0.5801455", "0.5765329", "0.57522887", "0.57477105", "0.5722611", "0.57040703", "0.5647876", "0.5625825", "0.5614503...
0.55713415
23
Class for Doubt Object id : Unique Id for the object user : Username who submitted the doubt content : Textual part of doubt timeStamp : Time at which doubt submitted count : Number of upvotes received
function Doubt(user,content,timeStamp){ this.id = totalDoubts; this.user = user; this.content = content; this.timeStamp = timeStamp; this.count = 0; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function idTrackerObj()\n{\n this.latest = -1;\n this.oldest = -1;\n this.gapHigh = -1;\n this.gapLow = -1;\n\n // getRequest method creates a single user item of getposts rpc list parameter\n this.getRequest = function (mode) {\n if( mode == 'latest' || mode == 'latestFirstTime' ) {\n ...
[ "0.600364", "0.59761703", "0.57663816", "0.5702039", "0.55716836", "0.5557444", "0.55313003", "0.5503507", "0.54916257", "0.53696686", "0.53507483", "0.53375185", "0.5333003", "0.5310717", "0.5280486", "0.5274427", "0.5269269", "0.5266776", "0.5233705", "0.5214144", "0.520125...
0.7565343
0
Function to broadcast the count of users to all clients
function reloadUsers(){ io.sockets.emit('nbUsers',{"nb": users}); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function broadcastUsercount(){\n const message = {type: 'updateUserCount', userCount: wss.clients.size}\n wss.broadcast (JSON.stringify(message))\n}", "function broadcastCount() {\n const message = {\n type: 'userCount',\n size: wss.clients.size,\n }\n conso...
[ "0.8614792", "0.8606663", "0.7582298", "0.7062108", "0.6665482", "0.6650293", "0.6646965", "0.6338722", "0.63151443", "0.6268375", "0.623957", "0.6224609", "0.62201416", "0.61835265", "0.6182313", "0.6136182", "0.6106123", "0.6042001", "0.60325825", "0.6020041", "0.60145605",...
0.6379156
7
Check is a username has been alloted to this client
function pseudoSet(socket){ var test; socket.get('pseudo',function(err, name){ if(name==null) test = false; else test = true; }); return test; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function checkUsername(message) {\n // If the username has been taken, and a new one (with a number on the end) has been assigned\n // try to Ghost the other user\n if (client.nick.match(new RegExp(settings.client.user + '[0-9]+'))) {\n client.say('nickserv', 'ghost ' + settings.client.user + ' ' + settings....
[ "0.71719134", "0.7101972", "0.70523703", "0.70296836", "0.7026287", "0.695576", "0.69361275", "0.691036", "0.68728924", "0.6869642", "0.68357235", "0.6819096", "0.676836", "0.67475206", "0.67433023", "0.67215616", "0.6721276", "0.6685518", "0.6660574", "0.6637808", "0.6619648...
0.0
-1
Function to get username of this client
function returnPseudo(socket){ var pseudo; socket.get('pseudo',function(err, name) { if(name==null) pseudo = false; else pseudo = name; }); return pseudo; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getUserName() {\n return _userInformation.UserName;\n }", "function getUserName(){\n\t\tuserName = $cookies.get('userName');\n\t\treturn userName;\n\t}", "get username() { // get uinique username. In your api use ${utils.username}\n return new Date().getTime().toString();\n }", ...
[ "0.72693735", "0.72670484", "0.72315645", "0.7197961", "0.70688206", "0.6942476", "0.69093984", "0.6860902", "0.6860902", "0.6860902", "0.6860902", "0.68355733", "0.6813067", "0.67603505", "0.6748595", "0.67382824", "0.67382824", "0.67382824", "0.67382824", "0.67382824", "0.6...
0.0
-1
and returns them sorted from highest to lowest. example with 12 and 18: factors of 12 are 12, 6, 4, 3, 2, 1 factors of 18 are 18, 9, 6, 3, 2, 1 so the common factors of 12 and 18 are 6, 3, 2, 1 another example: console.log(commonFactors(20, 25)) // => [5, 1]
function commonFactors(num1, num2) { const factors = [] let max max = num1 > num2 ? num1 : num2 for (let i = max; i >= 1; i--) { if (num1 % i === num2 % i) { factors.push(i) } } return factors }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function commonFactors(num1, num2) {\n var num1Factors = factors(num1);\n var num2Factors = factors(num2);\n var result = [];\n\n for (var i = 0; i < num1Factors.length; i++) {\n var ele1 = num1Factors[i];\n\n for (var j = 0; j < num2Factors.length; j++) {\n var ele2 = num2Factors[j];\n\n if (e...
[ "0.7350011", "0.7154945", "0.69402754", "0.68563575", "0.67549324", "0.67519283", "0.66979146", "0.65985125", "0.6589847", "0.6567213", "0.6539636", "0.65334666", "0.65182006", "0.6470467", "0.64627683", "0.6451249", "0.6445561", "0.64407074", "0.6434299", "0.64117014", "0.64...
0.796893
0
Function used to update the table
function tableInit(my_data) { // Find the table // Use D3 to select the table var table = d3.select("#ufo-table"); //Remove the las tbody to avoid unwanted data var my_tbody = table.select('tbody'); my_tbody.remove(); //Create e new tbody entity to append the data var tbody = table.append("tbody"); // Build the table my_data.forEach((sighting) => { var row = tbody.append("tr"); Object.entries(sighting).forEach(([key, value]) => { var cell = row.append("td"); cell.text(value); }); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getTableUpdate() {\n\n}", "update(){}", "update(){}", "update(){}", "function updateTable(s)\n{\n // stuff\n}", "update(tableName, id, data){\n\t\t\tif(this.hasTable(tableName)){\n\t\t\t\tlet index = this.mapping[tableName][id];\n\t\t\t\tlet tableData = this.tableData[tableName][index];\n\n\t\t...
[ "0.7672743", "0.7135577", "0.7135577", "0.7135577", "0.70561373", "0.68832165", "0.67219424", "0.67004156", "0.66621006", "0.66518056", "0.66459906", "0.6595871", "0.6569728", "0.65637416", "0.65075636", "0.65045154", "0.6500869", "0.64585155", "0.643895", "0.64147794", "0.64...
0.0
-1
Function used to calculate and condition for filter if the input is not define the condition will be ignored returning true for further logical condition
function andCond(input, data){ var flag = false; if(input){ if(data === input){ flag = true; } }else { flag = true; } return flag; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function compFilter(filtered){\n return function(d){\n // check if result array is empty\n var filt_party = (d.results.length != 0) ? filterParty(d.results[0].party) : true;\n var filt_party_ru = (d.results.length != 0) ? filterRUParty(d.results[1].party) : true;\n var filt_VM = (d.results.l...
[ "0.67976165", "0.6682668", "0.6573128", "0.63161653", "0.61834294", "0.6182964", "0.6079107", "0.6076014", "0.6070129", "0.606772", "0.6042588", "0.60191536", "0.59684086", "0.5959828", "0.59418654", "0.5923709", "0.5902815", "0.5868289", "0.58598715", "0.5847401", "0.5822457...
0.6298606
4
Function used to calculate or condition for filter if the input is not define the condition will be ignored returning true for further logical condition
function orCond(input, data){ var flag = false; if(input){ if(data === input){ flag = true; } } return flag; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function compFilter(filtered){\n return function(d){\n // check if result array is empty\n var filt_party = (d.results.length != 0) ? filterParty(d.results[0].party) : true;\n var filt_party_ru = (d.results.length != 0) ? filterRUParty(d.results[1].party) : true;\n var filt_VM = (d.results.l...
[ "0.68234456", "0.6653376", "0.65808815", "0.65020734", "0.6331576", "0.6173327", "0.616713", "0.5933061", "0.59326386", "0.59131026", "0.5912537", "0.5897684", "0.5877033", "0.5856084", "0.58439326", "0.5836944", "0.5835902", "0.5812768", "0.58019805", "0.5767187", "0.5763535...
0.6482056
4
Used for dropdoen menu to update the filter format
function getData(dataset) { filter_format=dataset; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateFilter(data) {\n var selectize = $position_filter[0].selectize;\n selectize.clearOptions();\n for(var i=0;i< data.length; i++) {\n selectize.addOption(data[i]);\n } \n selectize.refreshOptions(false);\n}", "function updateFilter(){\n $(\"#visab-table\").tabulator(...
[ "0.6890614", "0.66347027", "0.6449733", "0.6436066", "0.64273363", "0.62986386", "0.62961423", "0.6293862", "0.62536925", "0.62408525", "0.6214619", "0.6210753", "0.62075555", "0.61765313", "0.61627436", "0.61525863", "0.6144248", "0.6087489", "0.60599494", "0.60377836", "0.6...
0.0
-1
Function to get querystring
function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getQueryString() {\n var result = {}, queryString = location.search.substring(1),\n re = /([^&=]+)=([^&]*)/g, m;\n\n while (m = re.exec(queryString)) {\n result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);\n }\n\n return result;\n }", "function QueryString...
[ "0.801083", "0.7985512", "0.7985512", "0.79728645", "0.7941351", "0.7850239", "0.7836554", "0.7831883", "0.7824628", "0.7719082", "0.7697943", "0.7681372", "0.76499736", "0.7647214", "0.76317525", "0.75803554", "0.75788915", "0.7573077", "0.75465834", "0.7514835", "0.7514835"...
0.0
-1
Set prosthetics history class and attribute.
function hide_show_prosthetics_history() { if($("[data-fieldname=is_experience_prosthetics]").val() == 'No') { $("[data-fieldname=prosthetics_history]").parent().hide(); $("[data-fieldname=prosthetics_history]").parent().removeClass("has-error"); $("[data-fieldname=prosthetics_history]").removeAttr("data-reqd"); } else { $("[data-fieldname=prosthetics_history]").parent().show(); $("[data-fieldname=prosthetics_history]").parent().addClass("has-error"); $("[data-fieldname=prosthetics_history]").attr("data-reqd",1); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "set classHistory(classHistory) {\n\t\tif (Array.isArray(classHistory)) {\n\t\t\tthis._classHistory = classHistory.map((i) => new ClassHistory(i));\n\t\t} else {\n\t\t\tthis._classHistory = [new ClassHistory(classHistory)];\n\t\t}\n\t}", "set classHistoryClass(classHistoryClass) {\n\t\tthis._classHistoryClass = n...
[ "0.6310619", "0.6044309", "0.55804145", "0.525803", "0.5185518", "0.5170386", "0.5168484", "0.5141534", "0.5114461", "0.51065254", "0.5100928", "0.50924855", "0.5067461", "0.50479406", "0.50287825", "0.50269294", "0.50122297", "0.50026", "0.49921036", "0.49879053", "0.4924080...
0.0
-1
Cube with only top and bottom
function makeCube2(){ var vertexBuf = []; var triBuf = []; var normBuf = []; var vertices = [[0,0,1],[1,0,1],[1,1,1],[0,1,1],[0,0,0],[1,0,0],[1,1,0],[0,1,0]]; var triangles = [[6,2,3],[3,7,6],[4,0,1],[1,5,4]]; var normals = [[0,1,0],[0,1,0],[0,-1,0],[0,-1,0],[0,1,0],[0,1,0],[0,-1,0],[0,-1,0]]; for(var i=0; i<vertices.length; i++) { vertexBuf.push(vertices[i][0],vertices[i][1],vertices[i][2]); } for(var i=0; i<triangles.length; i++) { triBuf.push(triangles[i][0],triangles[i][1],triangles[i][2]); } for(var i=0; i<normals.length; i++) { normBuf.push(normals[i][0],normals[i][1],normals[i][2]); } //triBufSize = triangles.length; return({vertices:vertexBuf, normals:normBuf, triangles:triBuf, triSize:triangles.length}); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function makeCube(x, y, z) {\n return [\n { x: x - 1, y: y, z: z + 1 }, // FRONT TOP LEFT\n { x: x - 1, y: 0, z: z + 1 }, // FRONT BOTTOM LEFT\n { x: x + 1, y: 0, z: z + 1 }, // FRONT BOTTOM RIGHT\n { x: x + 1, y: y, z: z + 1 }, // FRONT TOP RI...
[ "0.7082511", "0.69899994", "0.69577575", "0.68553406", "0.68336827", "0.6817514", "0.6812175", "0.6775607", "0.6756457", "0.6684495", "0.6636237", "0.6600198", "0.65546125", "0.6533426", "0.6527143", "0.6510508", "0.65079165", "0.6462767", "0.6452618", "0.64385426", "0.643852...
0.62250394
37
parse n, M and T from instance file
getNMT() { let unparseNMT = this.#rawtext[0].split("\n"); this.productsLength = parseFloat(unparseNMT[0].split('\t')[1]); this.maintenanceTime = parseFloat(unparseNMT[1].split('\t')[1]); this.timeForMaintenance = parseFloat(unparseNMT[2].split('\t')[1]); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function processFile(contents,fullFileName) {\n let splitter = \"Instance:\"\n //let arResults = []\n let arInstances = contents.split(splitter); //the instances defined in this file\n\n arInstances.forEach(function(i) { //check each instance\n\n let fileContents = splitter + i //a...
[ "0.55974305", "0.5444449", "0.5286516", "0.51946735", "0.5032579", "0.49666542", "0.4934296", "0.49196362", "0.49102905", "0.49102905", "0.49102905", "0.48748845", "0.4857718", "0.48537317", "0.48495486", "0.48303416", "0.48002583", "0.47933203", "0.47577745", "0.4730843", "0...
0.52972746
2
parse p from instance file
getP() { let p = []; let unparseP = this.#rawtext[2]; for(let line of unparseP.split('\n')) { if(line.split('\t').length == 2) { p.push(parseFloat(line.split('\t')[1])); } } this.processingTimes = p; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function parse(p, s) {\n var ps = new ParserState(s);\n return p.parse(ps);\n }", "function processFile(contents,fullFileName) {\n let splitter = \"Instance:\"\n //let arResults = []\n let arInstances = contents.split(splitter); //the instances defined in this file\n\n arInstance...
[ "0.55926394", "0.54561406", "0.5303535", "0.51415354", "0.5107409", "0.5107409", "0.5107409", "0.5100295", "0.5100295", "0.5100295", "0.5100295", "0.5100295", "0.5057519", "0.5051985", "0.5049878", "0.5032408", "0.50149405", "0.49832317", "0.49823847", "0.49610525", "0.492939...
0.5125081
4
parse s from instance file
getS() { let unparseS = this.#rawtext[4]; let unparseMatrix = []; let s = []; for(let line of unparseS.split('\n')) { unparseMatrix.push(line.split('\t')); } for(let i in unparseMatrix) { if(i > 2) { s.push(unparseMatrix[i].slice(1).map(value => parseFloat(value))); } } this.preparationTimes = s.slice(0, s.length-1) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function processFile(contents,fullFileName) {\n let splitter = \"Instance:\"\n //let arResults = []\n let arInstances = contents.split(splitter); //the instances defined in this file\n\n arInstances.forEach(function(i) { //check each instance\n\n let fileContents = splitter + i //a...
[ "0.61409533", "0.5618173", "0.5538137", "0.54337376", "0.5399113", "0.5320626", "0.5320601", "0.53157365", "0.51233196", "0.5090132", "0.50889856", "0.5045389", "0.5045389", "0.5045389", "0.5045389", "0.5045389", "0.50447404", "0.50447404", "0.50447404", "0.50369537", "0.5030...
0.45749423
78
This is for the button that turns on the microscope
function turnonoff() { if (!beamon){ beamon = true; onoff.html("Turn off"); return } if (beamon){ beamon = false; onoff.html("Turn on"); return } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function switchOnFn(scope) {\n\t/** Iniatialy the switch on flag set as false, in the click event of button 'Switch On Light' the flag will be set as true */\n\tif ( switch_on_flag == false ) {\n\t\tgetChild(\"current_display\", side_view_container).alpha = 1; /** Display the current value in machine */\n\t\tswitc...
[ "0.7026267", "0.6864934", "0.67100686", "0.66701156", "0.6666136", "0.66421133", "0.6630308", "0.6626772", "0.6608971", "0.66052496", "0.6585908", "0.6576897", "0.65677017", "0.6562103", "0.655946", "0.65588635", "0.65583503", "0.6554493", "0.6530682", "0.6524301", "0.6518054...
0.0
-1
General Reverse a string
function strReverse ( a ) { return a.split('').reverse().join(''); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function reverseString(stringToReverse) {}", "function reverse(str) {\n \n}", "function reverse(str) {\n \n}", "function reverseInPlace(str) {}", "function reverseString(str) {\n\n}", "function reverse2(str) {\n\t// todo validate input\n\n\treturn str.split('').reverse().join('');\n}", "function re...
[ "0.8588957", "0.831534", "0.8312834", "0.82807887", "0.8237923", "0.79851097", "0.7929442", "0.7904794", "0.789119", "0.78871536", "0.78718334", "0.786652", "0.78581595", "0.78397965", "0.78360075", "0.78162867", "0.78023815", "0.7785895", "0.7777752", "0.7777329", "0.7769139...
0.0
-1
Check if a string starts with a specified prefix.
function strStartsWith ( input, match ) { return input.substring(0, match.length) === match; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function startswith (string, prefix)\n{\n\treturn string.indexOf(prefix) == 0;\n}", "function doesStringStartWith(s, prefix) {\n return s.substr(0, prefix.length) === prefix;\n}", "function startsWith(str, prefix) {\n\t str = toString(str);\n\t prefix = toString(prefix);\n\n\t return st...
[ "0.90355664", "0.8987196", "0.89807296", "0.89777946", "0.89777946", "0.8966099", "0.89559287", "0.89347476", "0.88738996", "0.88620603", "0.8846368", "0.88383657", "0.86552", "0.81523544", "0.78044397", "0.7795277", "0.7694824", "0.76809865", "0.7667051", "0.76496047", "0.76...
0.74349207
28
Check is a string ends in a specified suffix.
function strEndsWith ( input, match ) { return input.slice(-1 * match.length) === match; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function checkIfStringEndsWithSuffix(string, suffix) {\n return string.slice((string.length - suffix.length), string.length) === suffix;\n}", "function endsWith(str, suffix) {\n\t str = toString(str);\n\t suffix = toString(suffix);\n\n\t return str.indexOf(suffix, str.length - suffix.lengt...
[ "0.8755031", "0.8743279", "0.8698413", "0.8692976", "0.8692976", "0.8692976", "0.8692976", "0.8692976", "0.8692976", "0.8692976", "0.8686119", "0.86806846", "0.86718106", "0.86718106", "0.8631656", "0.86030185", "0.8435751", "0.83851814", "0.83851814", "0.765447", "0.76434594...
0.6974308
47
Throw an error if formatting options are incompatible.
function throwEqualError( F, a, b ) { if ( (F[a] || F[b]) && (F[a] === F[b]) ) { throw new Error(a); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function handleIncorrectFormatting () {\n console.log(colors.red('ERR: The input-file is incorrectly formatted.\\n'))\n process.exit(0)\n}", "static validateFormat (stringDefinition = '') {\n if(stringDefinition != CSSValdef.format (stringDefinition)){\n throw new Error(`Impropper CSS Value Definition ...
[ "0.652021", "0.600073", "0.5746464", "0.5688907", "0.5688907", "0.5628107", "0.5613745", "0.5588399", "0.5565274", "0.5543997", "0.5513667", "0.5508199", "0.54784656", "0.5469984", "0.5437266", "0.54318774", "0.5393413", "0.5389102", "0.5344517", "0.5342421", "0.5337357", "...
0.0
-1
Check if a number is finite and not NaN
function isValidNumber ( input ) { return typeof input === 'number' && isFinite( input ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function _is_finite(val) {\n return Number.isFinite(val);\n}", "function isInfinite(val) {\n return val === Infinity;\n}", "function isFiniteNumber(val) {\n return isValidNumber(val) && val !== Infinity && val !== -Infinity;\n }", "function isFinite(value) {\n return window.isFinite(value) && !w...
[ "0.78432333", "0.7800399", "0.7740732", "0.7445211", "0.7406799", "0.73654795", "0.7275233", "0.7227926", "0.72106934", "0.7202506", "0.7202506", "0.7182599", "0.7142756", "0.7132786", "0.7122629", "0.7122629", "0.7122629", "0.71115446", "0.7057735", "0.70555425", "0.7040568"...
0.0
-1
Provide roundingaccurate toFixed method. Borrowed:
function toFixed ( value, exp ) { value = value.toString().split('e'); value = Math.round(+(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp))); value = value.toString().split('e'); return (+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp))).toFixed(exp); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function toFixed (value, precision, roundingFunction, optionals) {\n\t var power = Math.pow(10, precision),\n\t optionalsRegExp,\n\t output;\n\t\n\t //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round);\n\t // Multiply up by precision, rou...
[ "0.75894976", "0.75846523", "0.75846523", "0.75007087", "0.7497219", "0.7421292", "0.7421292", "0.7421292", "0.74076253", "0.7310071", "0.7310071", "0.7310071", "0.7310071", "0.7249132", "0.716695", "0.7107328", "0.70014405", "0.69317204", "0.69317204", "0.6925078", "0.692507...
0.6387089
44
Formatting Accept a number as input, output formatted string.
function formatTo ( decimals, thousand, mark, prefix, suffix, encoder, decoder, negativeBefore, negative, edit, undo, input ) { var originalInput = input, inputIsNegative, inputPieces, inputBase, inputDecimals = '', output = ''; // Apply user encoder to the input. // Expected outcome: number. if ( encoder ) { input = encoder(input); } // Stop if no valid number was provided, the number is infinite or NaN. if ( !isValidNumber(input) ) { return false; } // Rounding away decimals might cause a value of -0 // when using very small ranges. Remove those cases. if ( decimals !== false && parseFloat(input.toFixed(decimals)) === 0 ) { input = 0; } // Formatting is done on absolute numbers, // decorated by an optional negative symbol. if ( input < 0 ) { inputIsNegative = true; input = Math.abs(input); } // Reduce the number of decimals to the specified option. if ( decimals !== false ) { input = toFixed( input, decimals ); } // Transform the number into a string, so it can be split. input = input.toString(); // Break the number on the decimal separator. if ( input.indexOf('.') !== -1 ) { inputPieces = input.split('.'); inputBase = inputPieces[0]; if ( mark ) { inputDecimals = mark + inputPieces[1]; } } else { // If it isn't split, the entire number will do. inputBase = input; } // Group numbers in sets of three. if ( thousand ) { inputBase = strReverse(inputBase).match(/.{1,3}/g); inputBase = strReverse(inputBase.join( strReverse( thousand ) )); } // If the number is negative, prefix with negation symbol. if ( inputIsNegative && negativeBefore ) { output += negativeBefore; } // Prefix the number if ( prefix ) { output += prefix; } // Normal negative option comes after the prefix. Defaults to '-'. if ( inputIsNegative && negative ) { output += negative; } // Append the actual number. output += inputBase; output += inputDecimals; // Apply the suffix. if ( suffix ) { output += suffix; } // Run the output through a user-specified post-formatter. if ( edit ) { output = edit ( output, originalInput ); } // All done. return output; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "formatNumber (format: string, number: number): string {\n return numeral(number).format(format)\n }", "function format(number) {\n if (number < 10) {\n return \"0\" + number;\n } else {\n return number;\n }\n }", "function formatNumber(number) {\n var finalNumber = \"\";\n if (num...
[ "0.79228175", "0.7599494", "0.7505307", "0.74808156", "0.74554163", "0.7439547", "0.7400445", "0.7187377", "0.7177842", "0.71775573", "0.71775573", "0.71757084", "0.7150881", "0.71484995", "0.7130486", "0.7130486", "0.7130486", "0.7130486", "0.7120442", "0.71065015", "0.70649...
0.0
-1
Accept a sting as input, output decoded number.
function formatFrom ( decimals, thousand, mark, prefix, suffix, encoder, decoder, negativeBefore, negative, edit, undo, input ) { var originalInput = input, inputIsNegative, output = ''; // User defined pre-decoder. Result must be a non empty string. if ( undo ) { input = undo(input); } // Test the input. Can't be empty. if ( !input || typeof input !== 'string' ) { return false; } // If the string starts with the negativeBefore value: remove it. // Remember is was there, the number is negative. if ( negativeBefore && strStartsWith(input, negativeBefore) ) { input = input.replace(negativeBefore, ''); inputIsNegative = true; } // Repeat the same procedure for the prefix. if ( prefix && strStartsWith(input, prefix) ) { input = input.replace(prefix, ''); } // And again for negative. if ( negative && strStartsWith(input, negative) ) { input = input.replace(negative, ''); inputIsNegative = true; } // Remove the suffix. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice if ( suffix && strEndsWith(input, suffix) ) { input = input.slice(0, -1 * suffix.length); } // Remove the thousand grouping. if ( thousand ) { input = input.split(thousand).join(''); } // Set the decimal separator back to period. if ( mark ) { input = input.replace(mark, '.'); } // Prepend the negative symbol. if ( inputIsNegative ) { output += '-'; } // Add the number output += input; // Trim all non-numeric characters (allow '.' and '-'); output = output.replace(/[^0-9\.\-.]/g, ''); // The value contains no parse-able number. if ( output === '' ) { return false; } // Covert to number. output = Number(output); // Run the user-specified post-decoder. if ( decoder ) { output = decoder(output); } // Check is the output is valid, otherwise: return false. if ( !isValidNumber(output) ) { return false; } return output; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sc_symbol2number(s, radix) {\n return sc_jsstring2number(s.slice(1), radix);\n}", "function st(t) {\n // TODO(bjornick): Handle int64 greater than 53 bits.\n return \"number\" == typeof t ? t : \"string\" == typeof t ? Number(t) : 0;\n}", "function convert(num) {\n\n\n}", "function convertn...
[ "0.63005054", "0.5983884", "0.5873118", "0.5798763", "0.5781437", "0.5781437", "0.5695613", "0.5687389", "0.5652488", "0.5588158", "0.5569438", "0.55665404", "0.55413723", "0.5531879", "0.5473936", "0.5461826", "0.54573834", "0.54546386", "0.54423255", "0.5441699", "0.5435226...
0.0
-1
Framework Validate formatting options
function validate ( inputOptions ) { var i, optionName, optionValue, filteredOptions = {}; if ( inputOptions['suffix'] === undefined ) { inputOptions['suffix'] = inputOptions['postfix']; } for ( i = 0; i < FormatOptions.length; i+=1 ) { optionName = FormatOptions[i]; optionValue = inputOptions[optionName]; if ( optionValue === undefined ) { // Only default if negativeBefore isn't set. if ( optionName === 'negative' && !filteredOptions.negativeBefore ) { filteredOptions[optionName] = '-'; // Don't set a default for mark when 'thousand' is set. } else if ( optionName === 'mark' && filteredOptions.thousand !== '.' ) { filteredOptions[optionName] = '.'; } else { filteredOptions[optionName] = false; } // Floating points in JS are stable up to 7 decimals. } else if ( optionName === 'decimals' ) { if ( optionValue >= 0 && optionValue < 8 ) { filteredOptions[optionName] = optionValue; } else { throw new Error(optionName); } // These options, when provided, must be functions. } else if ( optionName === 'encoder' || optionName === 'decoder' || optionName === 'edit' || optionName === 'undo' ) { if ( typeof optionValue === 'function' ) { filteredOptions[optionName] = optionValue; } else { throw new Error(optionName); } // Other options are strings. } else { if ( typeof optionValue === 'string' ) { filteredOptions[optionName] = optionValue; } else { throw new Error(optionName); } } } // Some values can't be extracted from a // string if certain combinations are present. throwEqualError(filteredOptions, 'mark', 'thousand'); throwEqualError(filteredOptions, 'prefix', 'negative'); throwEqualError(filteredOptions, 'prefix', 'negativeBefore'); return filteredOptions; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function validate(inputOptions) {\n var i, optionName, optionValue,\n filteredOptions = {};\n for (i = 0; i < FormatOptions.length; i += 1) {\n optionName = FormatOptions[i];\n optionValue = inputOptions[optionName];\n if (optionValue === undefined) {\n // Only defaul...
[ "0.6598257", "0.65541685", "0.65332896", "0.6531401", "0.645495", "0.6448904", "0.6374132", "0.6334743", "0.6046988", "0.6017768", "0.59519273", "0.5910039", "0.5899956", "0.58887464", "0.58887464", "0.584618", "0.5824895", "0.58135927", "0.58025426", "0.58025426", "0.5771699...
0.653161
3
Pass all options as function arguments
function passAll ( options, method, input ) { var i, args = []; // Add all options in order of FormatOptions for ( i = 0; i < FormatOptions.length; i+=1 ) { args.push(options[FormatOptions[i]]); } // Append the input, then call the method, presenting all // options as arguments. args.push(input); return method.apply('', args); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_callHandler() {\n let args = [].slice.call( arguments );\n let name = args.length ? args.shift() : '';\n\n if ( name && typeof this._options[ name ] === 'function' ) {\n this._options[ name ].apply( this, args );\n }\n }", "function ExtraOptions(){}", "function ExtraOptions() {}", "functio...
[ "0.67628413", "0.66020846", "0.654875", "0.654875", "0.6481142", "0.64681435", "0.6450323", "0.6390077", "0.6390077", "0.63862735", "0.6368631", "0.6328672", "0.6325625", "0.6300719", "0.62783927", "0.62783927", "0.6256579", "0.6193819", "0.61163473", "0.61103475", "0.6088878...
0.6344974
12