blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 132 | path stringlengths 3 236 | src_encoding stringclasses 29
values | length_bytes int64 8 7.94M | score float64 2.52 5.72 | int_score int64 3 5 | detected_licenses listlengths 0 142 | license_type stringclasses 2
values | text stringlengths 8 7.94M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
8b88c9dc9ffabda372ae784e0b19bf62392bfbaa | JavaScript | JakubTesar/Pexeso | /src/com/company/Main.js | UTF-8 | 3,028 | 3.046875 | 3 | [] | no_license | let cards, cards2, pexesoContainer, div, div2;
let divCon;
let smajliciVPoli = [];
let prekryvaciDiv = [];
let smajl = [];
let counter = 0;
let good = [];
let targetArr = [];
let resBut;
let span;
let modal;
let divs1 = [];
let divConArr = [];
let onloadFun = function () {
pexesoContainer = document.getElementByI... | true |
c94ce71ffadc2fcd8b59e0ae61b004e5018e7463 | JavaScript | jsknoweb/javaScriptOOPMosh | /2. Objects/11_gettersAndSetters.js | UTF-8 | 1,214 | 3.9375 | 4 | [] | no_license |
console.log('----OLD WAY TO ACCESS PRIVATE PROPERTY---');
function Circle(radius) {
this.radius = radius;
let defaultLocation = {x: 0, y: 0};
this.getDefaultLocation = function() {
return defaultLocation;
}
this.draw = function() {
console.log(defaultLocation);
console... | true |
db4ce0098057feb91407263f476268a0578e3e57 | JavaScript | themaleem/Js-learning-track | /track/themaleem/js-data-types/app.js | UTF-8 | 2,114 | 4.8125 | 5 | [
"MIT"
] | permissive | "use strict";
// A variable can at one moment be a string and at another be a number
let message = "hello";
message = 123456;
// we have 7 basic data types in javascript
// 1. Number (represents number and floating points)
// and is able to perform basic arithmetic operations
let n = 23;
n = 123.45;
alert(n) //123.45... | true |
0ca67f636b99d03e8e0279b66075f5c376f6eeb5 | JavaScript | amitsinha280/bookmarks.dev-api | /src/routes/admin/admin.service.js | UTF-8 | 4,515 | 2.8125 | 3 | [
"MIT"
] | permissive | const Bookmark = require('../../model/bookmark');
const NotFoundError = require('../../error/not-found.error');
const ValidationError = require('../../error/validation.error');
const BookmarkInputValidator = require('../../common/bookmark-input.validator');
/* GET all bookmarks */
let getBookmarksWithFilter = async (... | true |
cb20688b26efbff37a6eb8736e2ab7960fb61656 | JavaScript | M1CH43L-S1M30N/Projects | /W11D5/Arguments Exercises/arguments.js | UTF-8 | 1,836 | 3.765625 | 4 | [] | no_license | function sum1() {
let total = 0;
for (let i = 0; i < arguments.length; i++) {
total += arguments[i];
}
return total;
}
function sum2(...nums) {
let total = 0;
for (let i = 0; i < nums.length; i++) {
total += nums[i];
}
return total;
}
Function.prototype.myBind1 = function (context) {
const f... | true |
f85b81614e5c67770d7e1c41391f569071785b22 | JavaScript | Botche/SoftUni | /C08_JSApplications-February-2020/T20_PrototypesAndInheritance/P04_ClassHierarchy.js | UTF-8 | 5,636 | 3.59375 | 4 | [] | no_license | function generateClasses() {
class Figure {
constructor(unit) {
if (new.target === Figure) {
throw new Error('Abstract class cannot be instantiated');
}
this.unit = unit;
this.unitMultiplier = 1;
}
get area() {
}
... | true |
fd182e2e030b2687e93125bce4b3b129c027aa9d | JavaScript | P1antain/petProject | /ColorFlipper/index.js | UTF-8 | 557 | 3.546875 | 4 | [] | no_license | let background = document.querySelector('.color');
let color = document.querySelector('.color__pick')
let btnColor = document.querySelector('.color__button')
const hex = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F"];
btnColor.addEventListener('click', () =>{
let tegHex = '#';
for(let i=0; i < 6... | true |
9d34f47ee3eb967564c3bcd9f99a892e7fd4f199 | JavaScript | NyctibiusVII/CursoJS-DevAprender | /miniProjeto-3/index.js | UTF-8 | 756 | 4.46875 | 4 | [
"MIT"
] | permissive | // FizzBuzz
/** Divisível por 3 => Fizz
/* Divisível por 5 => Buzz
/* Divisível por 15 => FizzBuzz
/* Não divisível por 3 ou 5 => entrada
/* Não é um número => 'Não é um número'
**/
let dataInputUser = 15
const result = fizzBuzz(dataInputUser)
function fizzBuzz(dataInput) {
let isNumber = false
typeof dat... | true |
86774485288b1b371a1a7209acbc54a5a8e8c0e4 | JavaScript | keune/aoc-2020 | /41.js | UTF-8 | 2,453 | 3.21875 | 3 | [] | no_license | const fs = require('fs');
const intersect = (a, b) => {
return a.filter(elA => b.includes(elA));
};
const diff = (a, b) => {
return a.filter(elA => !b.includes(elA));
};
const uniq = arr => {
return arr.filter((el, i) => arr.indexOf(el) === i);
};
const getAnswer = () => {
let data = fs.readFileSync('./inpu... | true |
e90b3c66ed9a974c09e8ca3ce151794dd14acad2 | JavaScript | ryansebastian0828/SFRA | /cartridges/app_storefront_base/cartridge/models/search/suggestions/searchPhrase.js | UTF-8 | 1,669 | 2.734375 | 3 | [] | no_license | "use strict";
var URLUtils = require("dw/web/URLUtils");
var ACTION_ENDPOINT = "Search-Show";
/**
* Compile a list of relevant suggested phrases
*
* @param {dw.util.Iterator.<dw.suggest.SuggestedPhrase>} suggestedPhrases - Iterator to retrieve
* ... | true |
d15c978d08d463642811d3c68343ba9e69925602 | JavaScript | CodingDojoDallas/mean-sept-2016 | /Thomas_Edstrom/Node/math-module/mathlib.js | UTF-8 | 460 | 2.96875 | 3 | [] | no_license | module.exports = function (){
return {
add: function(num1, num2) {
return num1 + num2;
},
multiply: function(num1, num2) {
return num1 * num2
},
square: function(num) {
return num * num
},
random: function(num1, num2) {
var arg1 = null;
var arg2 = null;
if (num1>num2){
arg1 = num1;... | true |
5c1c884317636b24b41c27bcaecd11d976fa1ffb | JavaScript | amjadalmutairi/weird_translator | /app/models/translator.js | UTF-8 | 1,897 | 2.984375 | 3 | [] | no_license | Object.prototype.getKey = function(value) {
var object = this;
return Object.keys(object).find(key => object[key] === value);
};
const mac_dict = {
"Q" : "ض",
"W" : "ص",
"E" : "ث",
"R" : "ق",
"T" : "ف",
"Y" : "غ",
"U" : "ع",
"I" : "ه",
"O" : "خ",
"P" : "ح",
"A" : "ش",
"S" : "س",
"D" : "ي",
"F" : "ب",... | true |
6c641b983f6dec9af5e47a35820226ff9e5ae7fd | JavaScript | marcelo-vp/modules-app | /src/vehicles/Motorcycle.js | UTF-8 | 627 | 2.75 | 3 | [] | no_license | import Bicycle from './Bicycle';
const knockOver = Symbol('knockOver');
class Motorcycle extends Bicycle {
constructor(brand, model) {
super(brand, model);
}
showCurrentGear() {
return `Driving on gear ${this.currentGear} and speeding up!`;
}
pressHorn() {
return `Makes ann... | true |
86a45ea3db7fbd77f3e6b110ecef23ca47fd2dbe | JavaScript | Alvindelito/Dice-State-Exercise | /src/RollDice.js | UTF-8 | 1,035 | 2.765625 | 3 | [] | no_license | import React, { Component } from 'react';
import Die from './Die';
import './RollDice.css'
class RollDice extends Component {
static defaultProps = {
dieNum : [
"fas fa-dice-one",
"fas fa-dice-two",
"fas fa-dice-three",
"fas fa-dice-four",
"fas fa-dice-five",
"fas fa-dice-six"... | true |
c7cf4aedd300dee6b37dfe3841ce41fe19f91e55 | JavaScript | Ojka91/js_basics | /conditionals.js | UTF-8 | 572 | 4.71875 | 5 | [] | no_license | //conditions
//if create a condition and what to do in different cases
var y=80;
if (y<10){
console.log("its smaller");
}else if(y==10){
console.log("its equal to 10");
}else{
console.log("its bigger")
}
//"for" can create loops
//and for example, make them work with arrays
//it... | true |
e042d3cd96a49438a7c897164eff1210b92ca290 | JavaScript | TACONEO/liceo | /js/materias.js | UTF-8 | 732 | 2.9375 | 3 | [] | no_license | var formulario = document.getElementById("materias");
formulario.codigo.addEventListener("keypress",function(e){
if (!soloNumeros(event)){
e.preventDefault();
}
})
function soloNumeros(e){
var key = e.charCode;
return key >= 48 && key <= 57;
}
formulario.addEventListener("submit", func... | true |
aa74a0f343410b75b898e68a47b9653fe34ff1b1 | JavaScript | nstrayer/workout_react | /src/components/SetEntry.js | UTF-8 | 1,977 | 2.78125 | 3 | [] | no_license | import React, { Component } from 'react';
import { connect } from 'react-redux'
import { addCompletedLift, removeCompletedLift } from '../redux/actions';
import './SetEntry.css';
const day_getter = () => {
const d = new Date();
return `${d.getMonth() + 1}/${d.getDate()}/${d.getFullYear()}`
}
class SetEntry extend... | true |
0c0f442c719ebcd1c52c291c48c62cf20be5c467 | JavaScript | GangamR/MyCodeSamples | /src/components/validator.js | UTF-8 | 716 | 2.703125 | 3 | [] | no_license | export const required = value => (value ? undefined : 'Required')
export const number = value => value && isNaN(Number(value)) ? 'Must be a number' : undefined
export const email = value =>
value && !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(value) ? 'Invalid email address' : undefined
export const alphaNume... | true |
d2f6060dec35b844a27a4afd32c7c22d37414254 | JavaScript | RogerZZZZZ/leetcode_js | /RotateFunction.js | UTF-8 | 964 | 3.484375 | 3 | [] | no_license | /**
* @param {number[]} A
* @return {number}
*/
var maxRotateFunction = function(A) {
if(A.length === 0) return 0;
var len = A.length,
F = 0,
sum = 0;
for(var i = 0; i < len; i++){
F += i * A[i];
sum += A[i];
}
var max = F;
for(var j = len - 1; j >= 1; j--){
... | true |
496b707f7edbe15558663a18e996f7580b4e7388 | JavaScript | Ulyzses/forestoration | /js/script.js | UTF-8 | 1,587 | 2.625 | 3 | [] | no_license | var scroll = 0;
var locs = [
"home",
"science",
"status",
"sdg",
"help",
"tree-vias",
"about"
];
var width = $(window).width();
var speed = $('.content').data('speed');
var current = 0;
var dom = 0;
function plusSlides(n) {
var left, right;
dom = Math.round(current);
left = Math.floor(current);
... | true |
f502b60790c4f2b61db68817c28d9da0870061f1 | JavaScript | jclopez8/clinica | /target/sanantial/js/altaTratamiento.js | UTF-8 | 704 | 2.6875 | 3 | [] | no_license | /**
*
*/
window.onload = function () {
resetForm(document.altaTratamientoForm);
};
function guardarTratamiento(){
//alert("guardar tratamiento...");
if(validNonEmptyFieldsTratamiento() && validateInputsForm(document.altaTratamientoForm)){
document.altaTratamientoForm.submit();
}
}
function val... | true |
b673b970a04ebb0a7a907f24094763d924979156 | JavaScript | WafaMohessin/timed-coding-quiz | /script.js | UTF-8 | 3,988 | 3.515625 | 4 | [] | no_license | var questions = [
{
question: "What is console.log doing?",
choices: [
"External files make your code organized and easier to maintain",
"Internal drive",
"Internal memory",
"Medical tool",
],
answer: "External files make your code organized and easier to maintain",
},
{
... | true |
4d148768d6cd71ee6195aa16ab90a80b1aea49ed | JavaScript | dubspeed/shootyJS | /game/utils.js | UTF-8 | 1,199 | 2.5625 | 3 | [
"CC-BY-3.0"
] | permissive | /*
* Utils
*/
(function( global ) {
global.utils = {};
timeout = function( method, context, callback, delay ) {
var originalArguments = Array.prototype.slice.call( arguments, 3 );
return window[ method ]( function() {
callback.apply( context, originalArguments );
}, delay... | true |
fed689b2e7f242039383fed59067316eccaadec8 | JavaScript | TalAdivi/thirdYearSemesterA-RESTful | /mern2020-master-all-course-code/7_mongo/asyncProgramming/async.js | UTF-8 | 439 | 3.359375 | 3 | [] | no_license | const promiseMsg = () => new Promise((resolve, reject) => {
const error = false;
if (!error)
return setTimeout(() => resolve('Message: 🤡'), 2000); // Message: 🤡 <-- after 2 seconds
return reject(new Error('Message: 👿'));
});
const clown = async () => {
console.log('Before: 🤡');
try {
console.lo... | true |
a4954865b7759870e46d577548d5fcf5fbebd514 | JavaScript | pmgl/microstudio | /server/gamify/levels.js | UTF-8 | 426 | 2.78125 | 3 | [
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | this.Levels = (function() {
function _Class() {
var i, j, sum;
this.total_cost = [];
sum = 0;
for (i = j = 0; j <= 499; i = j += 1) {
sum += this.costOfLevelUp(i);
this.total_cost[i] = sum;
}
}
_Class.prototype.costOfLevelUp = function(from_level) {
var xp;
return xp = (fr... | true |
7472f2eb7de1ac2a8ccc285562ab80b424cb8068 | JavaScript | dfitzgerald7/js-ajax-ajax-and-callbacks-lab-online-web-ft-092418 | /index.js | UTF-8 | 1,321 | 2.84375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | $(document).ready(function (){
// searchRepositories();
});
function searchRepositories() {
const mySearchTerm = $("#searchTerms").val();
console.log(mySearchTerm)
$.get(`https://api.github.com/search/repositories?q=${mySearchTerm}`, function(data){
showRepositories(data);
}).fail(function(error) {
d... | true |
469a99dfae6a49a72a4d7a42a4fcb3f0e52808ac | JavaScript | ReplicantOnTheRun/TylerPewarskiTestFirst | /04_loops/loops.js | UTF-8 | 1,425 | 3.46875 | 3 | [] | no_license | function repeat(word, times){
var logString = "";
for(var i = 0; i < times; i++){
logString += word;
};
return logString;
};
function sum(arr){
var total = 0;
for(var i=0; i<arr.length; i++){
total += arr[i];
}
return total;
}
function gridGenerator(num){
var finalStr = "";
for(var i=0;... | true |
3e9c4bfbae75c6444750330c217f17038060a2bd | JavaScript | zzmin13/DataStructure | /4. 연결 리스트/linkedlist.js | UTF-8 | 3,884 | 4.5 | 4 | [] | no_license | //연결 리스트 만들기
class Node{
constructor(element){
this.element = element;
this.next = null;
}
}
class LinkedList{
constructor(){
this.head = null;
this.length = 0;
}
//1. append(element) : 가장 뒤에서 원소를 삽입
append(element){
let node = new Node(element);
... | true |
33c1ee4c8c7a41285113442a2d66324fe8f4ea2d | JavaScript | onceinteractive/taffer-api | /defaultTips.js | UTF-8 | 13,500 | 2.546875 | 3 | [] | no_license | var tips =
[
{ category: 'Human Resources', title: 'Hiring Requirements' , tip: "Hire for personality not experience."},
{ category: 'Human Resources', title: 'Dress the Part' , tip: "Maintain your appearance standards. Your employees should always look better than your guests. "},
{ category: 'Human... | true |
2ee4f29f0fbe86cc3a70072781c11af11b796d6b | JavaScript | roan1088/employee-management-system | /index.js | UTF-8 | 2,230 | 3.46875 | 3 | [
"MIT"
] | permissive | // Importing inquirer and orm modules
const inquirer = require("inquirer");
const orm = require("./config/orm");
// Main function
async function main() {
// Variable to store users action
let action = "";
// Keep repeating until user chooses
while (action !== "Exit") {
// Ask user their choice... | true |
0d5771ff7e1746b2fc0b497ac1a65dbb813fc5e2 | JavaScript | CristianCastellanos22/fundamentosJavascript | /clase1.js | UTF-8 | 798 | 4.28125 | 4 | [] | no_license | // console permite realizar una impresión
//console.log('Hola Mundo JS!');
// para declarar una variable se usa var
// se pueden definir n variables en una sola línea
var nombre = 'Cristian', apellido = 'Basto';
// para imprimir algo en mayúsculas se llama método toUpperCase()
var nombreMayusculas = nombre.toUpperCas... | true |
f1c8ae19c9e0e695229ee82e5871f68e0b4d79ce | JavaScript | ChrisJHatfield/MERN-Assignments | /JavaScript/Class_Assignments/Ninja/ninja.js | UTF-8 | 563 | 3.859375 | 4 | [] | no_license | class Ninja {
constructor(name, health, speed=3, strength=3) {
this.name = name;
this.health = health;
this.speed = speed;
this.strength = strength;
}
sayName() {
const name = this.name;
console.log(name);
}
showStats() {
console.log(`Ninja stats: name: ${ thi... | true |
3fddef82c513ea46e0861992a9082b28e9b907f6 | JavaScript | Reelwens/BomberMario | /src/scripts/cl_game.js | UTF-8 | 2,212 | 3.21875 | 3 | [] | no_license | var bomber = {}; //object
bomber.game_elem = document.querySelector(".game");
bomber.enemies;
// insertion des valeurs 0 dans le tableau (grille)
bomber.map = function()
{
this.wanted = document.body.querySelector("#size");
this.length_array = this.wanted.value;
this.game = new Array(this.length_array); // js array... | true |
04d54701354445c388fc07746b56087a548da3e9 | JavaScript | konykon/github-user-search | /script.js | UTF-8 | 1,354 | 3.015625 | 3 | [] | no_license | $("#search-button").click(() => {
displayContent().catch((e) => {
$("#exist").hide();
$("#notExist").show();
});
$('#search').val("");
});
const get = async (url) => {
let response = await fetch(url, {
method: "GET",
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
r... | true |
dfc8cbc0fd1fdb2cb9ab2c14daf46ac9943fef66 | JavaScript | khoakids/7thuchanh | /ứng dụng máy tính/calculator.js | UTF-8 | 880 | 3.359375 | 3 | [] | no_license | function cong(){
let x = +document.getElementById('sotruoc').value;
let y = +document.getElementById('sosau').value;
let z = x + y;
document.getElementById('result').innerHTML = 'Kết quả là ' + z;
}
function tru(){
let x = +document.getElementById('sotruoc').value;
let y = +document.getElementBy... | true |
4a61fae7dcfc630ce06afe99e0744aa7ac1e60c0 | JavaScript | OmBews/Iconemy | /app_server/web3_addons/capped_crowdsale_web3.js | UTF-8 | 8,728 | 2.5625 | 3 | [] | no_license | import { default as Web3} from 'web3';
import { default as contract } from 'truffle-contract'
// Import our contract artifacts and turn them into usable abstractions.
import kyc_artifact from '../../build/contracts/KYCCrowdsale.json'
import token_artifact from '../../build/contracts/PickToken.json'
// MetaCoin is our... | true |
6bd9dc69d1fd4de885de5f88d0be534196a30750 | JavaScript | BykovIlya/web_course_tetris | /js/my_scripts/tetris.js | UTF-8 | 8,029 | 2.890625 | 3 | [] | no_license | const canvas = document.getElementById('tetris');
const context = canvas.getContext('2d');
context.scale(20,20);
context.fillStyle = '#FFF';
context.fillRect(0, 0, canvas.width, canvas.height);
const figure = document.getElementById('figure');
const ctx = figure.getContext('2d');
ctx.scale(20,20);
ctx.fillStyle = '#F... | true |
16feb4bb2a69f66958a705bfce011ffd7d5b7670 | JavaScript | dnewcome/js-xml-serializer | /js-xml-ser.js | UTF-8 | 3,060 | 3.03125 | 3 | [
"MIT"
] | permissive | /**
* js-xml-serializer is free software provided under the MIT license.
* See LICENSE file for full text of the license.
* Copyright 2010 Dan Newcome.
*/
var jxs = (function()
{
function serialize( parent, member, obj, rules, namespaces ) {
if( rules == undefined ) {
return serialize_default( obj );
}
// w... | true |
f76fca18fc1d425d44488ae977a827dc3c43c998 | JavaScript | Cyrillo46/Project_local_library_2 | /public/src/accounts.js | UTF-8 | 1,570 | 3.25 | 3 | [] | no_license | // find the account by id number
function findAccountById(accounts, id) {
// for each account, if account id matches id number return true
let found = accounts.find((account) => account.id === id);
// return matching account
return found;
}
function sortAccountsByLastName(accounts) {
// if the last name sele... | true |
7818f8bc034067dbd513d024e3682e1feca600dc | JavaScript | anahigo/Trybe_Exercise_Front-End_React_Redux_Hooks | /16_01/Exercise_01.js | UTF-8 | 283 | 3.078125 | 3 | [] | no_license | /*
1 - Defina uma função chamada actionCreator()que retorne o actionobjeto quando chamada.
const action = {
type: 'LOGIN'
}
// Define an action creator here:
*/
const action = {
type: 'LOGIN'
}
// Define an action creator here:
function actionCreator() {
return action
}
| true |
8cb2ab3e8045004ab126b699d9d973022de0d918 | JavaScript | aydearcas/ejercicio-fetch | /src/components/UserCard.js | UTF-8 | 3,408 | 2.9375 | 3 | [] | no_license | import { Developer } from '../js/Developer.js';
import { Designer } from '../js/Designer.js';
class UserCard extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
createUser() {
const newUser = fetch('https://randomuser.me/api/') // Se hace una petición al servidor
... | true |
f38cde8247aa7c47ef86cb66afc0a789baee3705 | JavaScript | jhoicas/catsList | /main.js | UTF-8 | 1,804 | 3.265625 | 3 | [] | no_license | window.addEventListener('load', () => {
// arreglo de elementos
var elements ;
var btn = document.querySelector('button');
btn.addEventListener("click", ()=>{
fetch('https://api.thecatapi.com/v1/breeds')
.then(function(response) {
return response.json();
}).then(function(myJson) {... | true |
9432231c5be0c7b48191bd506b1e88a0aabe5353 | JavaScript | razed1/DatabaseWiki | /TableSearch.Mockup/content/script/view/control/foundContainer.js | UTF-8 | 1,959 | 2.71875 | 3 | [] | no_license | (function() {
window.foundContainer = (function() {
function foundContainer(thePassedInElement, itemList, callMethod) {
var itemPrefix;
if (!(thePassedInElement != null)) {
throw new Error("dragAndDropList: No element was passed in.");
}
itemPrefix = "buttonFoundSearchItem_";
... | true |
3585d012dc20c14232eb66e6ceeb1c428bff8df9 | JavaScript | KirilDinev/Programing-Basic | /ConditionalStatements/workingHours.js | UTF-8 | 1,408 | 3.21875 | 3 | [] | no_license | function workingHours(hour, day) {
let time = Number(hour);
switch (day) {
case "Monday":
if (time >= 10 && time < 18) {
console.log("open");
} else {
console.log("closed");
}
break;
case "Tuesday":
if (... | true |
0d6152d0e135633976a03ce9be2983b58d580fbd | JavaScript | zacharymargolies/guessinggame | /GuessingGame.js | UTF-8 | 3,545 | 3.703125 | 4 | [] | no_license | function generateWinningNumber() {
return Math.floor(Math.random() * 100) + 1;
}
function shuffle(arr) {
var length = arr.length;
var original;
var swap;
while(length) {
swap = Math.floor(Math.random() * length);
length--;
original = arr[length];
arr[length] = arr[... | true |
54650e1346f074adb11a150a7a27faf4b95e1922 | JavaScript | gooler/JD | /js/function1.js | UTF-8 | 456 | 2.78125 | 3 | [] | no_license |
function $(selcter,content){
content=content||document;
if( typeof selcter=="string"){
if(selcter.charAt(0)=="."){
return document.getElementById(selcter.substr(1));
}else if(selcter.charAt(0)=="#"){
return getClass(selcter.substr(1),content)
}else if(/^[a-zA-Z][A-Za-z1-6]*$/.text(selcter)){
return c... | true |
3c15054c3b316e7da31ff9852cad578332f9fc6b | JavaScript | nnnzzz000/nnnzzz000.github.io | /move-eye/js/main.js | UTF-8 | 1,152 | 2.578125 | 3 | [
"MIT"
] | permissive | $(function(){
var $leftEye = $('.left-eye');
var $rightEye = $('.right-eye');
var $mouth = $('.mouth');
var $win = $(window)
$('body').on('mousemove',function(e){
var center_x = $win.width() / 2;
if (e.clientX >= center_x){
$leftEye.css('left', '70px')
$rightEye.css('left', '70px')
... | true |
cb6d3716306924cba5323ae6e0dd1df7eb7ed1f0 | JavaScript | yorkshireandrew/pythonage | /pythonage1/pythonagejavascript/pythonage_rectangle.js | UTF-8 | 1,275 | 3 | 3 | [
"MIT"
] | permissive | class pythonage_rectangle{
constructor(object_id, width, height, style, visible){
this.object_id = object_id;
this.width = width;
this.height = height;
this.style = style;
this.visible = visible;
this.layer = 0;
this.scale = 1.0;
}
render(context){
if(this.visible){
var sc = this... | true |
07556b292537e119b5fdde6df59a276bfc6e5b81 | JavaScript | nudiasipvc/TM-2020 | /Aula 3/exercicio4/Nuno Dias - 20800/script.js | UTF-8 | 1,106 | 3.59375 | 4 | [] | no_license | var counterImages = 1;
function addImage() {
var image = document.createElement("img");
var list = document.getElementById("imagesList");
image.src = "https://placeimg.com/250/150/" + counterImages;
list.appendChild(image);
var counter = document.getElementById("imageCounter");
counter.inne... | true |
4fee9865bfa5ca819c54240d31a0a18873de64e6 | JavaScript | LitusAlina/OKR-labs | /lab3/app.js | UTF-8 | 2,677 | 3.21875 | 3 | [] | no_license | document.querySelector('#t1').onclick = task1
document.querySelector('#t2').onclick = task2
document.querySelector('#t3').onclick = task3
document.querySelector('#t4').onclick = task4
document.querySelector('#t5').onfocus = task5_1
document.querySelector('#t5').onblur = task5_2
window.onload = () => {
paint... | true |
0d4966e00f5be00ca87a58d98f469fd6f0a2a442 | JavaScript | Jethet/ironhack-prep | /exercises/phoneExer.js | UTF-8 | 1,095 | 3.5 | 4 | [] | no_license | let phone = {
brand: "Apple",
type: "iPhone",
model: "X",
characteristics: {
capacity: "256 GB",
size: {
height: "xxx inch",
width: "yyy inch",
depth: "zz inch"
}
},
chip: ["bionic", "neural engine", "embedded processor"]
};
function g... | true |
e838b7d8c75b6d60203d7bca78eb9d90bebefcb8 | JavaScript | rozenshi/fp-avantgarde | /ramda-exercises/lens/over-11/exercise.js | UTF-8 | 962 | 2.625 | 3 | [] | no_license | const { lensProp, over } = require("ramda");
const x = {
employees: {
bestEmployee: {
name: "Lucas",
username: "Skywalker",
avatar: "https://avatar.com/3713137",
email: "lucasskywalker@gmail.com",
phone: "887.902.1264",
address: {
street: "Louie Mission",
suite... | true |
1713ebcac244df19daab1ed77b87c7a3756276f6 | JavaScript | birdsarah/atmo_alert | /atmo_alert.js | UTF-8 | 1,269 | 2.765625 | 3 | [] | no_license | const PUSHBULLET_API = "https://api.pushbullet.com/v2/pushes";
let stillLaunching = false;
function onStorageError(error) {
console.log(`Error: ${error}`);
}
function onPushbuttonGot(item) {
let pushbullet = item.pushbullet;
if (!pushbullet) {
return;
}
let requestBody = {
"type":... | true |
66eefd768b82e23b9e04158365bcc52df4c06257 | JavaScript | BaraaSoft/algorithm-refresher | /Mooc/Course1/week2/5_fibonacci_number_again/fibonacci_huge.js | UTF-8 | 1,345 | 3.390625 | 3 | [] | no_license | // fibonacci_huge.js
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
terminal: false
});
process.stdin.setEncoding('utf8');
rl.on('line', readLine);
function readLine(line) {
if (line !== "\n") {
const n = parseInt(line.toString().split(' ')[0], 1... | true |
77b95e9e767b541a201449161aa946e643e7579f | JavaScript | MonikaGerova/Landing-pages | /js/script.js | UTF-8 | 8,765 | 2.625 | 3 | [] | no_license | function app() {
this.templates = ko.observableArray();
this.getTemplates = ko.computed(function () {
var self = this;
getRequest("getTemplates.php").then(function (resolve) {
console.log(resolve);
self.templates(JSON.parse(resolve));
});
},this);
this.a... | true |
34a84849fa8a390fa995dedd00226cdaceb310d4 | JavaScript | AC-greener/service-workers-offline | /web/js/sw.js | UTF-8 | 1,197 | 2.640625 | 3 | [] | no_license | "use strict";
// TODO
const version = 1
var isOnline = true;
var isLoggedIn = false;
self.addEventListener('install', onInstall)
self.addEventListener('activate', onActive)
self.addEventListener("message", onMessage);
main().catch(console.error)
async function main() {
await sendMessage({ statusUpdateRequest: true... | true |
14f5294bf2cf6b82b3a922f8a38deb4371778f49 | JavaScript | Programming-Systems-Lab/archived-trikx.old | /openjoda/content/javascript/config.js | UTF-8 | 2,544 | 2.65625 | 3 | [] | no_license | function moveItem(element,moveUp)
{
index = element.selectedIndex;
if (index != -1 && element.options[index].value > "") {
aText = element.options[index].text;
aValue = element.options[index].value;
if (element.options[index].value > "" && index > 0 && moveUp)
{
element.options[inde... | true |
0c60b04aa3b6b60b2b0064fbe91aaa0d6be75f7d | JavaScript | nanochess/basic-computer-games | /52 Kinema/javascript/kinema.js | UTF-8 | 2,882 | 3.734375 | 4 | [
"Unlicense"
] | permissive | // KINEMA
//
// Converted from BASIC to Javascript by Oscar Toledo G. (nanochess)
//
function print(str)
{
document.getElementById("output").appendChild(document.createTextNode(str));
}
function input()
{
var input_element;
var input_str;
return new Promise(function (resolve) {
... | true |
ecdf95377092353210da36c7aa8d5195c81c5c13 | JavaScript | mrp301/pocketaReference | /#0031_pi/pi.js | UTF-8 | 133 | 2.78125 | 3 | [] | no_license | //#0031_円周率
var txt = "円周率=" +Math.PI; //円周率を表示する。
document.getElementById("result").innerHTML = txt;
| true |
6798e99e395e96ada5dbc67c645bd0c2e44398bb | JavaScript | fieldchester/javascript-functional | /02listMonadDiffType.js | UTF-8 | 1,762 | 3.328125 | 3 | [] | no_license | Array.prototype.flatten = function() { return this.reduce((acc, x) => acc.concat(x), [] )}
function of(a) { return Array.of(a) }
Array.prototype.chain = function(f) { return this.map(f).flatten() }
// Array.prototype.chain = function (f) { return this.reduce( (acc, x) => acc.concat(f(x)), []) }
Array.prototype.skip = f... | true |
a2e1a0448aa7ebad563e1bc29aebca2c1b94444c | JavaScript | lmy01/snake | /贪吃蛇/map.js | UTF-8 | 889 | 3.125 | 3 | [] | no_license | (function (window) {
function Map() {
//需求:创建地图,并且渲染到页面
this.row = 20;
this.col = 30;
this.size = 25;
this.color = "cyan";
this.map = null;
this.render();
}
Map.prototype = {
construstor:Map,
render:function () { //渲染页面
//根据行列和宽度,创建背景大盒子div,并且设置背景色和宽高
var div = d... | true |
266aaaf6afac8f09c9fd64f4ccb621fb2f81abab | JavaScript | eQueue/GetMovieRank | /Get_Movie_Rank/js/searchRank.js | UTF-8 | 1,477 | 2.703125 | 3 | [
"MIT"
] | permissive | var xhr;
function enterkey() {
if (window.event.keyCode == 13) {
// 엔터키가 눌렸을 때 실행할 내용
load();
}
}
function load(){
//alert('load run');
var div=document.getElementById("result");
var date=document.getElementById("date").value;
xhr = new XMLHttpRequest();
var url='h... | true |
67feaf2e5ef897321da7dd5689a26c3e625b5efd | JavaScript | nweller-dc/mixsln | /test/model.js | UTF-8 | 1,929 | 2.90625 | 3 | [] | no_license | function testModel() {
var data1 = {
'L1_1': 1,
'L1_2': '1',
'L1_3': {
'L2_1': 2,
'L2_2': '2',
'L2_3': {
'L3_1': 3,
'L3_2': '3'
}
},
'L1_4': {
'L2_4': '4',
'L2_5': {
'L3_3': '5',
'L3_4': '6'
}
}
},
data2 = {
a: 1,
b: 2
},
model = new app.m... | true |
003873971c9b11ca45aa9dd3663b8bad9b765e64 | JavaScript | suldashi/prioqueue | /index.js | UTF-8 | 768 | 2.6875 | 3 | [
"MIT"
] | permissive | var PriorityQueue = require("./priorityqueue.js");
var p = new PriorityQueue();
p.push(75);
p.push(74);
p.push(6);
p.push(96);
p.push(4);
p.push(82);
p.push(54);
p.push(87);
p.push(55);
p.push(72);
p.push(73);
p.push(100);
p.push(91);
p.push(9);
p.push(22);
p.push(24);
p.push(75);
p.push(15);
p.push(37);
p.push(53);
p.... | true |
ad45aff906fb728fe86673124b82b8dbab03078e | JavaScript | arsytamawisa/ReimburseWeb | /src/reducers/billReducer.js | UTF-8 | 2,182 | 2.546875 | 3 | [] | no_license | import {
UPLOAD_FILE, UPLOAD_FILE_SUCCESS, UPLOAD_FILE_FAILURE,
UPDATE_BILL, UPDATE_BILL_SUCCESS, UPDATE_BILL_FAILURE,
FIND_BILL_BY_ID, FIND_BILL_BY_ID_FAILURE, FIND_BILL_BY_ID_SUCCESS
} from '../constants/actionConstant'
const initialState = {
data: null,
error: null,
isLoading: false
}
expo... | true |
db90879738f7615a39eb25708994f4b369fc36cf | JavaScript | Koredotcom/web-kore-sdk | /UI-JAVASCRIPT/custom/customTemplate.js | UTF-8 | 4,133 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | function customTemplate(data) {
this.cfg = data;
this.helpers = null;
this.extension = null;
}
/**
* purpose: Function to render bot message for a given custom template
* input : Bot Message
* output : Custom template HTML
*/
customTemplate.prototype.renderMessage = function (msgData) {
/* For your referenc... | true |
f9df12c2573802063c760e76185f6ddb7ac34827 | JavaScript | AAI-USZ/FixJS | /input/50/after/d2f64f5343b00d1c9df6b4a4102dcdc908854690_1_1.js | UTF-8 | 228 | 2.578125 | 3 | [
"MIT"
] | permissive | function() {
var ch = this.peek();
this.nextCol();
if (this.col >= this.buffer.code[this.line].length)
this.nextLine();
return ch;
} | true |
bd022e66838cff75ffa60c71addde9a3289dec82 | JavaScript | AAKonkin/ToDosAPI | /Controller/todoController.js | UTF-8 | 2,173 | 2.75 | 3 | [] | no_license | import ToDo from '../Model/ToDo.js';
class todoController {
async addNew(req, res) {
try{
if(!req.body) return res.status(400).json('EMPTY_REQUEST_BODY');
const {active, content} = req.body;
const NewToDo = new ToDo({active, content});
NewToDo.save(err => {
... | true |
4029723501ae2c8ade40895b4992a21068b9d12c | JavaScript | AmiraNasrullah/Notes-App | /api/server.js | UTF-8 | 712 | 2.515625 | 3 | [] | no_license | // Importing Node modules and initializing Express
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var logger = require('morgan');
var router = require('./router');
var mongoose = require('mongoose');
var settings = require('./config/settings');
// Database Setup
mongoos... | true |
faeba27b0bd7deef9b012e47d2781d45246ff3da | JavaScript | AbderrhmanAbdellatif/advanced-programing-Homeworks | /Lab/CW7_/sw.js | UTF-8 | 539 | 2.6875 | 3 | [] | no_license | const CACHE ='JS'
function installCB(e) {
console.log('install oldu', e.request);
}
self.addEventListener('install', installCB)
function save(req, resp) {
return caches.open(CACHE)
.then(cache => {
cache.put(req, resp.clone());
return resp;
})
.catch(console.log)
}
function fetchCB(e) { //fetch first... | true |
0783a8c2e3160e439627ac177c26c2ce339a489d | JavaScript | micuzo/TileEditor | /tile_editor_app/src/store/reducers/editorReducer.js | UTF-8 | 4,971 | 2.640625 | 3 | [] | no_license | import * as tools from '../../containers/ControllerPanel/tools';
import * as actionTypes from '../actions/actionsTypes';
import GridTiles from '../../classes/GridTiles';
import Tile from '../../classes/Tile';
import image from '../../assets/images/grassCenter.png';
import image2 from '../../assets/images/grassMid.png'... | true |
e5d0c68a45c545b84195af98865bb9ee63306587 | JavaScript | keenanpayne/thecraftofcoffee.com | /assets/js/app.js | UTF-8 | 1,284 | 3.84375 | 4 | [] | no_license | /**
* ReadingTime()
*
* Calculates the reading time for any given article and outputs that as a
* reading time for the user.
*/
const ReadingTime = function() {
/**
* @function calculateReadingTime()
*
* Counts all of the "words" inside of our article content by splitting
* characters apart by spaces... | true |
65ea6e9e36f330a5faf15d460c2394be8f582a3f | JavaScript | InceptionCode/tododay | /src/components/App/CompletedList.jsx | UTF-8 | 1,801 | 2.53125 | 3 | [] | no_license | "use strict";
import React, {Component} from "react";
import axios from "axios";
import ListPanel from "./ListPanel.jsx";
import { deleteTodo, uncompleteTodo } from "../../Utils/api.js";
const url ="http://67.205.174.156:3000/todos?completed=1";
export default class CompletedList extends Component {
componentWillM... | true |
c7aa24e982dbddc127684be3f4f72633ff5870d1 | JavaScript | dblodorn/wtssb | /store/index.js | UTF-8 | 1,967 | 2.640625 | 3 | [] | no_license | import { options } from './../scripts/site_data.json'
export const state = () => ({
api: options,
popup: false,
currentScene: 'center',
animating: false,
info: false,
muted: false,
videoDone: false,
scenes: [
{
title: 'Touch',
loaded: false
},{
title: 'Taste',
loaded: fa... | true |
d2a80ca56be9267e5497b69372e18e5cf78df70f | JavaScript | pablitar/2019-react-redux-todo-list | /src/components/addTodoForm/AddTodoForm.js | UTF-8 | 656 | 2.5625 | 3 | [] | no_license | import React from 'react';
import './AddTodoForm.css'
export default class AddTodoForm extends React.Component {
constructor(props) {
super(props);
this.state = {
todoDescription: ''
};
}
onInputChange(event) {
this.setState({...this.state, todoDescription: event.target.value})
}
addT... | true |
625700b1f80c52b5cbcbf0204a4542428ba97290 | JavaScript | jamesmargaryan/programming3project | /class/Mirg.js | UTF-8 | 1,033 | 2.78125 | 3 | [] | no_license | var LivingCreature = require('./class1.js');
module.exports = class Mirg extends LivingCreature{
constructor(x, y, index) {
super(x, y, index);
}
choosenewKordinats() {
this.directions = [
[this.x - 1, this.y - 1],
[this.x, this.y - 1],
[this.x + 1, thi... | true |
c6b25e4303e9a0a1c5a9855cb71ac004c46265eb | JavaScript | RyanPan-SW/React-StudyTest | /src/index.js | UTF-8 | 1,203 | 2.90625 | 3 | [] | no_license | // import '../wdyr';
import React from "react";
import ReactDOM from "react-dom";
import { Map } from "immutable";
class App extends React.Component {
constructor(props) {
super(props);
// this.state = { number: 0, counter: { number: -1 } }; // default
this.state = { number: 0, counter: Map({ number: -1 ... | true |
e9936ee8c864390a425077bd587a5d08c1284ff3 | JavaScript | myVarEquals/portfolio.v3 | /src/js/index.es6 | UTF-8 | 935 | 2.90625 | 3 | [] | no_license | $(document).ready(function () {
const pairs = $('.eye-pair');
pairs.each(function(index, pair) {
pair = $(pair)
pair.css({'top': '30px', 'left': '30px'})
});
// $('.eye-pair').css('top', '30px');
$(document).mousemove(function(e) {
lookAt(e.pageX, e.pageY);
});
... | true |
17c1b7c22eef25e4e05a5ea56efaee42a0321769 | JavaScript | chitwant82/beat-the-king-app | /static/js/tictactoe/Game.js | UTF-8 | 871 | 3.546875 | 4 | [] | no_license | function Game(playerX = "X", playerO = "O") {
this.board = new Board();
this.playerX = new Player(Square.X_STATE, playerX);
this.playerO = new Player(Square.O_STATE)
this.currentMovePlayer = this.playerX;
}
Game.prototype.makeMove = function(row, column) {
if(this.board.empty(row, column) && this.board.setSquare(... | true |
8b76aec1f6b975742d5b82ec67e111fbd3e106cc | JavaScript | copaceticandy/JavaScript | /First_Script/name_function.js | UTF-8 | 107 | 3.484375 | 3 | [] | no_license | var name = prompt("What is your full name?");
function print_name(){
console.log(name);
}
print_name(); | true |
b6a2f43e833dac38e97f684fadaa9bda73beebf6 | JavaScript | RifqiSubchan02/Bootcamp-Quiz | /W01-D01/n14.js | UTF-8 | 653 | 3.6875 | 4 | [] | no_license | let progress = 0;
function getProsentase(income1, income2) {
if (isNaN(income1) || isNaN(income2)) return `${income1} or ${income2} must be number`;
if (income1 > income2) {
progress = Math.round(100 / (income2 / (income1 - income2)));
return `Total penurunan income -${progress}%`;
} else if (income1 < in... | true |
bd4e22bc389ce7e5bd6f72f73b49c07c53d04ac9 | JavaScript | NCJ1979/NodeJS | /childprocess/server_child.js | UTF-8 | 547 | 2.875 | 3 | [] | no_license |
var counter = 0;
process.on('message', function(m, server)
{
if (m === 'server')
{
server.on('connection', function (socket)
{
//socket.end('handled by child ' + counter++);
//socket.end('hello'); //NOT ALLOWED; END IS EQUIVALUENT TO WRITE+END
socket.write('handled by child ' + counte... | true |
701f1ecc0e639ded270e517542a99c39da51fced | JavaScript | oscarcalderon402/todo-react | /src/components/TodoCounter.jsx | UTF-8 | 363 | 2.578125 | 3 | [] | no_license | import React from 'react';
import '../styles/TodoCounter.css';
const TodoCounter = ({ todos }) => {
const completed = todos.reduce((sum, item) => {
if (item.completed) {
sum++;
}
return sum;
}, 0);
return (
<h2 className="TodoCounter">{`has completado ${completed} de ${todos.length} TODO`}... | true |
4c541a6f8d2331dbf371dc18e5b282d449477c1c | JavaScript | CodingDojo-MEAN-03-18/ryin_MEAN | /JS_OOP/Deck_of_Cards.js | UTF-8 | 2,335 | 3.75 | 4 | [] | no_license | class Deck{
constructor(){
this.deck = [];
let suits = ['clubs', 'diamonds', 'hearts', 'spades'];
let ranks = ['ace', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'jack', 'queen', 'king'];
for (const suit in suits){
for (const rank in ranks){
this.deck.push(`${ranks[rank]... | true |
a7ea8fb1e7593a2f40f25fd935274b266020212f | JavaScript | robherley/p5-sockets-demo | /public/sketch.js | UTF-8 | 820 | 3.390625 | 3 | [] | no_license | const HOST = 'http://localhost:8080';
let socket;
function setup() {
// Make a canvas, with a bg
createCanvas(900, 800);
background('#5d707f');
// Connect to our socket server
socket = io.connect(HOST);
// When we recieve mouse data from the server, draw it!
socket.on('mouse', data => {
fill('#03A9FC... | true |
fec5a9bbaec473c4ccd9e5acf2b56ddb02d6eb40 | JavaScript | berniechiu/pagy | /lib/pagy/extras/javascripts/pagy-items.js | UTF-8 | 1,011 | 3.0625 | 3 | [
"MIT"
] | permissive | // See the Pagy documentation: https://ddnexus.github.io/pagy/extras/items
function PagyItems(id, marker, from){
var pagyNav = document.getElementById('pagy-items-'+id),
input = pagyNav.getElementsByTagName('input')[0],
current = input.value,
link = pagyNav.getElementsByTagName('a')[0];
thi... | true |
7dd987dda516c368f2cc4aa5493f9e2f8d3ab65c | JavaScript | AlexTrLeonid/learn.javascript.ru | /1. Основы JavaScript/26. Вопрос про if.js | UTF-8 | 1,039 | 4.1875 | 4 | [] | no_license | /*
Задание 26.
Вопрос про "if"
важность: 5
Какие из этих if верны, т.е. выполнятся?
Какие конкретно значения будут результатами выражений в условиях if(...)?
if (-1 || 0) alert( 'первое' );
if (-1 && 0) alert( 'второе' );
if (null || -1 && 1) alert( 'третье' );
http://learn.javascript.ru/task/if-questi... | true |
3269d9c98b3ffd5e468bb3907d8635666d0ec7cb | JavaScript | Encaik/reg-parser | /index.js | UTF-8 | 1,297 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | var fs = require("fs");
fs.readFile('./code.cn', (err, data) => {
if (err) {
return console.error(err);
}
console.log("异步读取: " + data.toString());
let variable = data.toString().split("\r\n")
console.log(variable)
for (let index = 0; index < variable.length; index++) {
let msg =... | true |
1b28ab6b76f95ae57691bc07348d73a1c68ef07f | JavaScript | lmcowry/portfolioSite | /quotidian/ajaxson/js/script.js | UTF-8 | 2,114 | 3.0625 | 3 | [] | no_license | $(document).ready(function(evt){
$("#gifSearch").submit(function(evt) {
evt.preventDefault();
if (captchaValid()){
$("#whereTheGifGoes").attr("hidden", true);
$("#loading").attr("hidden", false);
var query = $("#userSearchText").val();
searchGifs(qu... | true |
cc9d1337ef517cc74646619637b6c06d04b8ae48 | JavaScript | prozack/Fwibble | /app/components/gameview/GameTimer.js | UTF-8 | 1,662 | 2.796875 | 3 | [
"MIT"
] | permissive | var React = require('react');
var ReactDOM = require('react-dom');
var io = require('socket.io-client');
var socket = io.connect();
module.exports = React.createClass({
getInitialState: function() {
return { secondsLeft: 240, minutes: 4, seconds: '00'};
},
componentDidMount: function() {
this.interv... | true |
7d236ce0b6a7d4c2bb55e14572543f0d38a08724 | JavaScript | tcandarli/protractorTestScripts | /CtekProject/keyboardAndMouse.js | UTF-8 | 5,896 | 2.578125 | 3 | [] | no_license | describe('Keyboard and Mouse Action Suite', () => {
// First write something on inputbox and clear what you've written
// and write something new
it('clear method', () => {
browser.get("http://www.way2automation.com/angularjs-protractor/registeration/#/login");
element(by.id("userna... | true |
5271c45aac850c266072d17b12ab1cd5606a2ecd | JavaScript | liumiaowilson/storefront | /src/reducers/cartReducer.js | UTF-8 | 645 | 2.578125 | 3 | [
"MIT"
] | permissive | import { types } from '../actions';
const cartReducer = (state = {}, action) => {
const amount = state[action.productId] || 0;
switch (action.type) {
case types.ADD_TO_CART:
return {
...state,
[action.productId]: amount + action.amount
};
case types.REMOVE_FROM_CART:
if (a... | true |
9e327795c59178f7d24bcd2e3143f0ed472631c9 | JavaScript | ankitvashisht12/image-gallery-app | /src/customHooks/useSearchImage/useSearchImage.js | UTF-8 | 1,794 | 2.59375 | 3 | [] | no_license | import { useState, useEffect } from 'react';
import axios from 'axios';
const useSearchImage = (searchTerm, pageNo) => {
const [loading, setLoading] = useState(true);
const [photos, setPhotos] = useState([]);
const [hasMore, setHasMore] = useState(true);
const [hasError, setHasError] = useState(false);
const [e... | true |
71bbd5084399035a3bd2e1c5406b1007e512078a | JavaScript | vishalbhatd123456/Node-JS-startup | /MiddleWare1.js | UTF-8 | 431 | 2.671875 | 3 | [] | no_license |
const express = require('express');
const app = express();
//next acts as a ponter to execute the next middleware
//put it above
app.use('/add-product',(req, res, next) => {
console.log('In another middleware!');
res.send('<h1>Hello from Add Product</h1>');
})
app.use('/',(req, res, next) => {
con... | true |
db0a14761ba35136a2cb3a6eb948c6e4b4b4719f | JavaScript | istar0me/js6 | /js6/ma6/src/space.js | UTF-8 | 8,682 | 2.859375 | 3 | [] | no_license | const S = module.exports = {}
S.cosineSimilarity = function (v1, v2) {
return v1.vdot(v2) / (v1.norm() * v2.norm())
}
S.euclidDistance = function (v1, v2) { // sqrt((v1-v2)*(v1-v2)T)
let dv = v1.sub(v2)
return Math.sqrt(dv * (dv.tr()))
}
S.manhattanDistance = function (v1, v2) { // sum(|v1-v2|)
return v1.sub... | true |
ac9c31d5a958c0d2d2aec41d3f5555315f058dd0 | JavaScript | atiffanyvalens/csproject.heliohost.org | /count/change.js | UTF-8 | 702 | 2.765625 | 3 | [] | no_license | /*window.setInterval(function(){
window.setTimeout(function(){
$('div').css('background-image','url(http://us.cdn291.fansshare.com/photo/backgroundhd/fd-288004178.jpg)');
},1000);
$('div').css('background-image','url(http://us.cdn200.fansshare.com/photo/backgroundhd/background-hd-836761420.jpg)');... | true |
754d5c760478d6dbc00d3845d2ff33ffc26b75a2 | JavaScript | brandonsean08/climate_changr | /climate_changr_frontend/src/reducers/rootReducer.js | UTF-8 | 1,191 | 3.125 | 3 | [] | no_license | /**
* For the purpose of this application we will only have one reducer. In a larger application there will be mutiple reducers for the
* different entities
*/
/**
* The initial state of our application
*/
const initState = {
actualClimateData: [],
predictedClimateData: [],
selectedCountry: "United Kingdom"... | true |
a450ae36de6ac15936d0244142bb5dc6ed9576fc | JavaScript | radnerus/project-euler | /problem-7-10001st-prime.js | UTF-8 | 489 | 3.96875 | 4 | [] | no_license | function nthPrime(n) {
// Good luck!
let count = 2;
let currentNum = 2;
let lastPrime = 3;
while(count !== n) {
if (currentNum % 2 !== 0 && currentNum % 3 !== 0 && isPrime(currentNum)) {
count++;
lastPrime = currentNum;
}
currentNum++;
}
return lastPrime;
}
function isPrime(number... | true |
adb8a6f9cee4493624fe581741e198bd64ba9dd5 | JavaScript | BeneCollyridam/vue-component-library-boilerplate | /src/components/index.js | UTF-8 | 1,746 | 2.546875 | 3 | [] | no_license | import Vue from 'vue';
// Look for component files ("c-") in the current directory
const requireComponent = require.context('.', false, /c-[\w-]+\.vue$/);
// Look for layout files ("l-") in the current directory
const requireLayout = require.context('.', false, /l-[\w-]+\.vue$/);
const registerComponents = (
// Set... | true |
cdfa5a515eb26af1d56f3bd6580204e7c2f5d3e2 | JavaScript | rjoxford/classmonster-app | /app/components/scores/objective-average-score.js | UTF-8 | 1,979 | 2.859375 | 3 | [] | no_license | // Returns the average score a class get for a given objective
import Ember from 'ember';
export default Ember.Component.extend({
store: Ember.inject.service(),
averageScore: 0,
displayScore: Ember.computed('averageScore', function(){
let score = this.get('averageScore');
if (score>0) {... | true |