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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
34a005eeb64bc0f037835b2816fcb3cf0e5ce4db | JavaScript | HibaADJ/TP- | /TPs_js/EXO objet/TP26/TP26.js | UTF-8 | 3,831 | 3.1875 | 3 | [] | no_license | const nomInput = document.querySelector("#nom");
const prenomInput = document.querySelector("#prenom");
const ageInput = document.querySelector("#age");
const genreInput = document.querySelector("#genre");
const paysInput = document.querySelector("#pays");
const optionInput = document.querySelector("#option");
const li... | true |
0cc969b734f46e64efcf5adabdfd548d2c6b5ed6 | JavaScript | jps725/zoigl | /frontend/src/store/images.js | UTF-8 | 2,418 | 2.59375 | 3 | [] | no_license | import { csrfFetch } from "./csrf";
const LOAD = "images/LOAD";
const ADD_ONE = "images/ADD_ONE";
const UPDATE_ONE = "images/UPDATE_ONE";
const REMOVE_ONE = "images/REMOVE_ONE";
const loadImage = (image) => ({
type: LOAD,
image,
});
const addImage = (image) => ({
type: ADD_ONE,
image,
});
const editImage = ... | true |
088a5a8f603819854ab93a4286fe07d601975284 | JavaScript | freebebe/skyhand | /DOM/ag1/p2/ass/js/quanJu_var.js | UTF-8 | 180 | 2.90625 | 3 | [] | no_license | function ceShi(tak) {
var test = tak * tak; //没有var为全局
return test;
}
var test = 50;
var trying = ceShi(20); //ceShi(20*20)
alert(trying);
| true |
140c3e984cc199e725ada42c89930e18bb1e4110 | JavaScript | programmer-prashant/TQ_React_Assignments | /src/hooks/useContext_useCallback/ContextDemo.jsx | UTF-8 | 648 | 2.578125 | 3 | [] | no_license | // 2. Create a context and provide a value
// Provide the object as provider value
// Consume in the nested component using useContext
// 7.Create two context and provide a value ‘web_developer’ and
// ‘react’repectively
// 10. WAP to show use of UseContext hook for sharing a theme (e.g. color,
// paddings, margins, fo... | true |
f8310c1aa5ce1693c63af3a696dab3942db5051f | JavaScript | lucyj204/react-weather-app | /src/CitySearch.js | UTF-8 | 3,088 | 2.703125 | 3 | [] | no_license | import React, { useState, useRef } from "react";
import "./App.css";
import WeatherReport from "./WeatherReport";
import axios from "axios";
import Loader from "react-loader-spinner";
export default function CitySearch(props) {
const [weatherData, setWeatherData] = useState(null);
const [city, setCity] = useState(... | true |
7be2f41d564cd561f7cadf1823863d03a7b81e14 | JavaScript | keirahela/Discord-Suggest-Feedback-Bot | /commands/suggest.js | UTF-8 | 834 | 2.59375 | 3 | [] | no_license | const Discord = require('discord.js')
const { suggestId } = require('../data/channelIDs.json')
module.exports = {
name: "suggest",
description: "suggestion command (embed style)",
async run (bot, message, args) {
if(!args[0]) return message.reply('Please add a reason to suggestion!')
... | true |
cecf49da519f40ffb689a49e88571b6b020300c4 | JavaScript | ShellGoldfish0/HseAdventSappP7 | /advent.js | UTF-8 | 2,095 | 2.828125 | 3 | [] | no_license | console.log('Winter Break is almost here!!!');
let icons = [
'🛷',
'🌨',
'🐻',
'🌲',
'🎁',
'🤶',
'🧤',
'🧣',
'🥶',
'🌟',
'⛸',
'🍪',
'🦌',
'🏂',
... | true |
76f72ccf95454afa63f1f60b8c7f7ad203491f3e | JavaScript | openluck/Demo | /nodeDemo/爬虫/test2/test2.js | UTF-8 | 893 | 2.5625 | 3 | [] | no_license | /*
* @Descripttion:
* @version:
* @Author: OpenLcuk
* @Date: 2021-05-31 10:33:19
* @LastEditors: OpenLcuk
* @LastEditTime: 2021-05-31 10:35:49
*/
var http = require("http");
var https = require("https");
var fs = require("fs");
var cheerio = require("cheerio");
//保存网络图片
function saveImage(imageUrl) {
http.ge... | true |
7a764d39ff88ab4853db705bef8d96f3fe7b7e9e | JavaScript | zhenchai/mall | /mall_site/src/main/webapp/js_max/customer/goodcomm.js | UTF-8 | 941 | 2.875 | 3 | [
"MIT"
] | permissive | /**
*
*/
function checkComment (id){
if(! checkScore(id)){
return;
}
if(! checkContext(id)){
return;
}
$("#commForm"+id).submit();
}
function checkScore(id){
if(!$(".des li").hasClass("on")){
alert("请您给商品描述评分");
return false;
}
return true;
}
function checkContext(id){
var str = $("#complaincon"+... | true |
286f9427c0a98c9a68dcd507367b5e1f6aa4e8a6 | JavaScript | Nate1546/learning-p5-js | /lesson-3/ch-8-objects/exercise-8.5-simple-gravity-OOP/ball.js | UTF-8 | 466 | 3.4375 | 3 | [] | no_license | class Ball {
constructor(x, y, w) {
this.x = x;
this.y = y;
this.w = w;
this.speed = 0;
}
display() {
fill(255);
noStroke();
ellipseMode(CENTER);
ellipse(this.x, this.y, this.w, this.w);
}
move() {
// Add speed to y location
this.y += this.speed;
// Add gravity to speed
this.speed += gra... | true |
f9bc652ac97365dd7a0863c962b06a1fa30c7f0a | JavaScript | richard2018/es | /JavaScript王者归来 源代码/第21章 面向对象/example-21.39-bind方法.js | GB18030 | 672 | 3.40625 | 3 | [] | no_license | Function.prototype.bind = function(owner) //PrototypeʵֹƵbind
{
//ԭͬһһֻǻһʽ
var $fun = this;
return function(){
$fun.apply(owner, arguments);
}
}
//һfoo
var foo = {};
//bind(foo)foo.barõذΪfooĶΪ
//Ҳıthisõֵ
foo.bar = (function(){
alert(this == foo);
}).bind(foo);
//setTimeout첽foo.barһ£thisֵӦ... | true |
01706abdd396b5239da6f37977668ba72b90d446 | JavaScript | gerkenv/webpack-example | /js/module2.js | UTF-8 | 630 | 3.359375 | 3 | [] | no_license | // example module #2
var _ = require('lodash');
var people = [
{
"id": 1,
"gender": "male",
"age": 31
},
{
"id": 2,
"gender": "female",
"age": 32
},
{
"id": 3,
"gender": "male",
"age": 33
},
{
"id": 4,
"... | true |
1a07cc2fc0486b2318ee369336e9aa72bae8a8ea | JavaScript | hagitbu/Remez-finalProject | /pages/clue/static/js/clue.js | UTF-8 | 1,655 | 2.828125 | 3 | [] | no_license | //
//
//
// //
// // function tg(t){
// // t.fontWeight=t.fontWeight=="bold"?"normal":"bold";
// // t.textDecoration =t.textDecoration =="none"?"underline ":"none";
// //
// // }
//
//
// function clickLi(Pelement) {
//
// var nestedList = Pelement.childNodes[1];
//
// Pelement.style.fontWeight=Pelement... | true |
92d47d23b7f35acc339726d89245776ef406965d | JavaScript | sschneeberg/callbacks-timing-iterators | /hello.js | UTF-8 | 1,291 | 2.6875 | 3 | [] | no_license | function sayHello(name) {
let msg = 'Hello,' + name + '. How are you?';
return msg;
}
console.log(sayHello('Simone'));
function sayHello(name) {
let msg = 'Hello,' + name + '. How are you?';
return msg;
}
console.log(sayHello('Rome'));
function sayHello(name) {
let msg = 'Hello,' + name + '. How... | true |
60f267093038646b2bd772ee2b63d3287c3e44b9 | JavaScript | Laradejpl/sugarV10-2 | /swpp.js | UTF-8 | 1,442 | 2.78125 | 3 | [] | no_license | function like(){
$.ajax({
url:'like.php',
success:function(data)
{
}
});
};
$(document).ready(function(){
$(".buddy").on("swiperight",function(){
$(this).addClass('rotate-left').delay(700).fadeOut(1);
console.log("right");
document.... | true |
8404b80441284ad1de46d4e7647a6b30e11ad99b | JavaScript | bretthannigan/e-man | /public/main.js | UTF-8 | 925 | 2.9375 | 3 | [] | no_license | var update = document.getElementById('update');
var del = document.getElementById('delete');
update.addEventListener('click', function () {
fetch('edit', {
method: 'put',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
'full_name': 'Modified-Name!',
... | true |
1c0232e0b3923b90d382ae3077622ca0a5f1e600 | JavaScript | link89/oboe.js | /test/specs/lists.unit.spec.js | UTF-8 | 5,943 | 3.40625 | 3 | [
"BSD-2-Clause-Views"
] | permissive | import { cons, emptyList, foldR1, foldR, list, applyEach, without, listAsArray, all, map, head, tail, reverseList, arrayAsList } from '../../src/lists'
describe('Lists', function () {
'use strict'
var listA = cons('a', emptyList)
var listBA = cons('b', listA)
var listCBA = cons('c', listBA)
it('can use con... | true |
00504d27694ee25686f432e20dac73cc737d5005 | JavaScript | KiralyTamas/CodeBerryMarsExpedition | /js/main.js | UTF-8 | 545 | 2.796875 | 3 | [] | no_license | function uzemanyag() {
let atlagFogyasztas = document.getElementById("atlagFogyasztas").value;
let foldTavolsag = document.getElementById("foldTavolsag").value;
let tartaly = document.getElementById("tartaly").value;
let szuksegesUzemanyag = atlagFogyasztas / 100 * foldTavolsag;
let folosUzemanyag = tartaly -... | true |
6ecfdaa001319eac5d1aedf065cf19a27827b1e3 | JavaScript | beewhoo/oinker_v2 | /app/assets/javascripts/welcome.js | UTF-8 | 7,179 | 2.96875 | 3 | [] | no_license |
document.addEventListener("DOMContentLoaded", function(event) {
console.log("DOM fully loaded and parsed");
// quantity of seats and participants
var plus = document.querySelector('.qtyplus');
var minus = document.querySelector('.qtyminus');
var quantity = document.querySelector('.qty');
if ... | true |
63dfa8f4a5ddaaf9bea3a90b20f2fd2e58eb35c6 | JavaScript | brainstormflash/trivia | /public/js/helpers.js | UTF-8 | 2,134 | 3.203125 | 3 | [] | no_license | function startTimer(duration, callback) {
var timer = duration, minutes, seconds;
repeat = setInterval(function () {
minutes = parseInt(timer / 60, 10);
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds :... | true |
62b455a75e41d73cde212de3e5c5338db3cfe9fd | JavaScript | iOSHaven/v4 | /plist.js | UTF-8 | 3,036 | 2.5625 | 3 | [] | no_license | const plist = require('simple-plist');
const fetch = require('node-fetch');
const commandLineArgs = require('command-line-args')
const https = require('https')
const exec = require('child-process-promise').exec
const fs = require('fs')
const options = commandLineArgs([
{ name: 'url', alias: 'u', type: String}
])
... | true |
46b322d3e009f224d0db5055c7594e3868bf5d63 | JavaScript | lGatl/Puissance4 | /p4/p4.js | UTF-8 | 5,208 | 2.625 | 3 | [] | no_license |
xi=1
bgi={}
jo={xi,bgi}
cd=true
changj(xi)
j=0
/*ANIMER LE JETON*/
/*Cree un tableau de 8*8 et le remplie de 0 */
function init(){
tab=[[],[],[],[],[],[],[],[]]
for (i=0;i<8;i++){for(j=0;j<8;j++){tab[i][j]=0}}
lig=0
}
function changj(x){
if (xi==1){xi=2}else{xi=1}
joueur(x)
initp($(".ti"))
}
function joueu... | true |
6b252d5b99449a2614884eb28dc9e8e55fa80e6a | JavaScript | emily-li/pig-game | /pig-game-0.0.1.js | UTF-8 | 3,249 | 3.234375 | 3 | [] | no_license | class PigGame {
constructor(cli) {
this.cli = cli;
this.pigNumber = 28;
this.pig = new Pig(cli);
this.state = new GameState();
}
run(userInput) {
this[this.state.state](userInput);
}
init() {
this.pig.introduce(this.pigNumber);
this.getNumPlayers();
}
getNumPlayers(userInput) {
if (userInpu... | true |
0ec1861ec87df22da2921b3e70da194dcd1af40a | JavaScript | manojown/javascript-pollyfill-example- | /stringify.js | UTF-8 | 837 | 3.546875 | 4 | [] | no_license | function stringify(value) {
let start = "";
if (typeof value === "object") {
let isLast = Object.keys(value).pop();
start += Array.isArray(value) ? "[" : "{";
for (let key in value) {
start += Array.isArray(value) ? "" : `"${key}":`;
let val = value[key];
start += `${stringify(val)}`;
if (key !== is... | true |
aec5e8942c0d310f681dfb40cff4901713d93acf | JavaScript | dbrizov/TelerikHomeworks | /JavaScript/JS Part 2/JS Advanced Functions HW/AdvancedFunctions/01. DOM Module/dom-module.js | UTF-8 | 3,280 | 3.53125 | 4 | [] | no_license | var domModule = (function () {
// Appends childElem to the parent/s with a given selector
function appendChild(childElem, parentSelector) {
var parents = document.querySelectorAll(parentSelector);
for (var i = 0; i < parent.length; i++) {
parent[i].appendChild(childElem.cloneNode(tr... | true |
a61259541689c1c3e00f625601f390dd23516e5c | JavaScript | xalmasin/JS-img-slider | /main.js | UTF-8 | 592 | 3.265625 | 3 | [] | no_license |
var images = ["https://source.unsplash.com/random/100x100",
"https://source.unsplash.com/user/erondu/100x100",
"https://source.unsplash.com/collection/190727/100x100"];
//Track the slide
var slide = 0;
var img = document.getElementById('img');
var slider = function(){
if(slide === 0){... | true |
b9980d9deec9294817f100c3d0776503f7a14ebe | JavaScript | Lt-Lowlander/join_practice | /app/javascript/react/containers/ChallengeIndexContainer.js | UTF-8 | 1,232 | 2.515625 | 3 | [] | no_license | import React, { Component } from 'react';
import { Link } from 'react-router';
import ChallengeIndexTile from '../components/ChallengeIndexTile';
class ChallengeIndexContainer extends Component {
constructor(props) {
super(props)
this.state = {
challengesArray: []
}
}
componentDidMount(){
... | true |
95fbb87fe479561c3220ea69f9ee12dcd54275a7 | JavaScript | zhynidexiaoyuge/component-set | /src/store/module/theme.js | UTF-8 | 1,635 | 2.765625 | 3 | [] | no_license | // let name = "default";
// if (window.globalConfig.theme) {
// name = window.globalConfig.theme;
// }
// if (window.globalConfig.showChangeTheme) {
// const tmp = localStorage.getItem("theme");
// if (themeExist(tmp)) {
// name = tmp;
// }
// }
// function themeExist(name) {
// if (!name) return false;
... | true |
b8fddd5cc976c2ceebd0f9098c27d276f5ac1d9f | JavaScript | roylanceMichael/compling_570_shallowprocessing_washington | /homework1/hw1_dir/source/vocabulary.js | UTF-8 | 703 | 2.953125 | 3 | [] | no_license | function Vocabulary() {
this.frequencyHash = {};
}
Vocabulary.prototype = {
parseLine: function(line) {
if(line.trim() == "") {
return;
}
var tokens = line.trim().split(/\s+/);
for(var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if(this.frequencyHash[token] != undefined) {
this.... | true |
b48247ff8bd120c55cbcdd7d152851efda5af016 | JavaScript | Mariam1994/Periodic | /periodic/scripts/main.js | UTF-8 | 980 | 2.921875 | 3 | [
"MIT"
] | permissive | function main(){
document.querySelector( "#nav-toggle" ).addEventListener( "click", menu);
var popUp = false,
menuItem = document.getElementsByTagName('a'),
prev = menuItem[3];
$( prev ).toggleClass( "press" );
for(var i=0; i<5; i++)
menuItem[i].addEventLis... | true |
af538da9efac0ed258d0c0c42ef0987e0daaa057 | JavaScript | 56kz/345678 | /clase3java.js | UTF-8 | 3,235 | 4.0625 | 4 | [] | no_license | // var factorial = function (n) {
// if (n == 0) {
// return 1;
// } else {
// return n * factorial(n - 1);
// }
// };
//funcion de forma recursiva d iga si el numer es par o impar
// function is_even_recursion(number) {
// if (number < 0) {
// number.Math.abs(number);
// }
// if (number ===... | true |
92dd1d04624a90d07df813975ecf037f7ada4a01 | JavaScript | ElliotG98/MessagingApp | /app.js | UTF-8 | 1,156 | 2.78125 | 3 | [] | no_license | const express = require('express')
const socketio = require('socket.io')
const app = express()
//uses ejs as template engine - allows static template files reduces template into HTML file sent to the client
app.set('view engine', 'ejs')
app.use(express.static('public'))
//routing method - handle GET requests
app.get(... | true |
9921965822562e8af1d28c4d3e3bb7a1a3c0c729 | JavaScript | TrainingByPackt/Professional-Node.js | /Lesson05/exercises/01_read/streams-read.js | UTF-8 | 564 | 2.84375 | 3 | [
"MIT"
] | permissive | 'use strict';
const crypto = require('crypto');
const fs = require('fs');
const readStream = fs.createReadStream('./images/input/dilbert.jpg');
const hash = crypto.createHash('sha1');
const writeStream = fs.createWriteStream('./images/output/dilbert.jpg');
readStream
.on('readable', function() {
let chunk;
... | true |
7b2a5c648b8c755ef4634df6375833225f92bed1 | JavaScript | jskelcy/RegEx | /operations.js | UTF-8 | 1,360 | 3.125 | 3 | [] | no_license | function Or(re1, re2){
this.re1 = re1;
this.re2 = re2;
this.match = function(currentString){
var rest = this.re1.match(currentString);
if(rest !== undefined){
return rest;
}else{
return this.re2.match(currentString);
}
}
}
function Concat(re1, re2){
this.re1 = re1;
this.re2 = re2;
this.match = ... | true |
6422dc91f5207ab1e917a55afe0f6f7e5f6f90c3 | JavaScript | plumhly/vue_mall | /mall/Ex/ex.js | UTF-8 | 386 | 3.0625 | 3 | [] | no_license | // const a = {f: 'hillo', g: 'g'};
// const {f} = a;
// console.log(f);
// const a = 'plum';
// console.log({a});
// export var a = () => {};
exports.a = 1;
// export const b = 2;
// export const c = 3;
// export default {
// a: 1,
// }
// var poromiss = new Promise((resolve, inject) => {
// resolve(1);
// ... | true |
12c474016a804ae09b4011ad69edd43afd02f882 | JavaScript | Rahul-kumar828/Java--Script | /24_JS_Arrow_Function/app.js | UTF-8 | 2,075 | 4.6875 | 5 | [] | no_license | //1st how many way we can declare a function
/*
Function Type
1)Normal Function
2)Function Expression
3)Arrow Function
*/
let result='';
function printNumberNf(){
let msg='';
for(let i=0;i<=10; i++)
{
msg +=`${i} `;
}
return msg;
}
result=printNumberNf();
console.lo... | true |
407e54162800656b6cc90f21341401a46dda0f6b | JavaScript | baiyecha404/JWT-attack | /routes/index.js | UTF-8 | 1,804 | 2.5625 | 3 | [] | no_license | const express = require('express');
const path = require('path');
const jwt = require('jwt-simple');
const config = require('../config');
const router = express.Router();
const createToken = (username, creds) => {
const body = { "username": username, 'isAdmin': creds };
return jwt.encode(body, config.private... | true |
b8d966163382f47e4d21e35759622f4291150b89 | JavaScript | ethereumdegen/wallstreetbets-bot | /lib/util/ServerConfigurationHelper.js | UTF-8 | 579 | 2.828125 | 3 | [] | no_license |
module.exports = class ServerConfigurationHelper {
static getServerEnvMode(){
let mode = ServerConfigurationHelper.findArgParamStartingWith('--servermode=')
if(mode == 'production'){
return 'production'
}
if(mode == 'staging'){
return 'staging'
}
return 'development'
}
... | true |
1309e369230da304a56b94fc78ce0ed3b0afc1e8 | JavaScript | ml20101992/server_p1 | /scripts/overview.js | UTF-8 | 15,250 | 2.609375 | 3 | [] | no_license | var endpoint = "";
var success_function = null;
var current_page = 0;
parseLocation();
ajaxGetRequest(endpoint + current_page,success_function,fail);
function parseLocation(){
let location = window.location.href;
let selector = location.split('/');
selector = selector[selector.length - 2];
//console... | true |
ec54d77b7d899c21635cab68eceb903b9002173d | JavaScript | mkirvela/massikassi | /public/js/utils.js | UTF-8 | 3,060 | 2.609375 | 3 | [] | no_license | "use strict";
function _filterPayer(users, payer_id) {
return users.filter(function(user) {
return user.id == payer_id;
})
.map(function(u) {
return { id: u.id, name: u.name, payer: true };
});
}
function resolve(payments) {
var totalMoneySpent = payments.map(function(payment) ... | true |
e80a1c10ba3ddf7e7bdfbbe126c1d554b08cdd8c | JavaScript | Bunlong/react-papaparse | /docs/src/components/screens/indexes/RemoteFile.js | UTF-8 | 1,132 | 2.515625 | 3 | [
"MIT"
] | permissive | import React from 'react';
const RemoteFile = () => {
return (
<section id="remote-files">
<div className="grid-container narrow-grid">
<div className="grid-100">
<h4>Remote Files</h4>
<h5>"No — I mean, the file isn't on my computer."</h5>
<p>
Oh, wel... | true |
eb8f8b890f297c8aaffe884a244453687e822d69 | JavaScript | Vlad-Udovenko/Step-Project_Oop | /src/js/index.js | UTF-8 | 11,490 | 3.0625 | 3 | [] | no_license | // Get DOM Elements
const modal = document.querySelector('#visit-modal');
const modalBtn = document.querySelector('#modal-btn');
const closeBtn = document.querySelector('.close');
const createBtn = document.querySelector('.modal-footer button');
const mainBlock = document.querySelector('.main-block');
const clearAllBtn... | true |
64bc2bb4702aa8d9aed328f751ec7665292b7602 | JavaScript | Esteban-Rocha/codefights | /js/build/add/add.js | UTF-8 | 535 | 3.09375 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-dco-1.1"
] | permissive | "use strict";
// @ts-check
/**
* JavaScript Add Challenge
* @author Esteban Rocha
* @link https://github.com/Esteban-Rocha
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.test = void 0;
/**
* @param input1 number
* @param input2 number
* @return boolean
*/
function add(in... | true |
245cc47fceb10277453b0a1103f5522f64669580 | JavaScript | luiscarlossf/how-to-contribute | /code/python/08-redirect-and-errors/app/static/validate.js | UTF-8 | 242 | 2.546875 | 3 | [] | no_license | function validate() {
uid = document.getElementById('userID');
pwd = document.getElementById("loginPassword");
cpwd = document.getElementById("loginPassword2");
if (cpwd.value != pwd.value) {
alert("Both Passwords must match!");
}
}
| true |
ed99b8fa148567f4d4d18339f9244012739867b9 | JavaScript | shawbena/react | /guid/src/display-data/app.js | UTF-8 | 7,205 | 3.578125 | 4 | [] | no_license | /*
展示数据
UI 要做的基本的东西就是展示一些数字。React 使得展示数据和数据更新时保持页面更新变得简单。
*/
/*
响应式的更新
在浏览器中打开 hello-react.html,在文本域中键入你的名子。注意 React UI 中的时间字符串——文本域中输入的任何值都会保留,即使你没有写任何代码管理这种行为。React 为你计算并做正确的事情。
除非需要 React 是不会操作 DOM 的。React 用内部的 mock DOM 执行比较并为你计算出效率最高的 DOM 修改。
这个组件的输入叫做 props —— "properties" 的简写。在 JSX 语法中,他们是作为属性传递的。在组件中你应该把这些... | true |
7624673f90aa7848a2243e7bc0832460d4659711 | JavaScript | GerardoSant/Finbook | /src/main/resources/public/javascript/websocketControl.js | UTF-8 | 488 | 2.828125 | 3 | [
"MIT"
] | permissive | function openWebSocket(textToSign){
var textToSign= textToSign;
console.log(textToSign);
let socket = new WebSocket("ws://localhost:8080/echo");
socket.onopen = function(e) {
};
socket.onmessage = function(e){
if(JSON.parse(e.data).id==textToSign){
submitLogInForm();
... | true |
d7aed622a7ba5259c5832da52d2000f116ea5782 | JavaScript | ahiguti/ase | /ase/misc/java/cltest.js | UTF-8 | 463 | 2.734375 | 3 | [
"MIT"
] | permissive |
var Comparable = Java["java.lang.Comparable"];
var JDate = Java["java.util.Date"];
var Arrays = Java["java.util.Arrays"];
var JClass = Java["java.lang.Class"];
var arr = JClass.NewArray(10);
arr[0] = JClass;
arr[1] = JDate;
arr[2] = Comparable;
print("A1: " + arr[0].getName());
print("A2: " + arr[1].getName());
print(... | true |
3daf9bd9f2eba5c3f19b5f57bfd049a00d961282 | JavaScript | LemonPrefect/sDelivr | /js/IsNight.js | UTF-8 | 1,716 | 2.6875 | 3 | [] | no_license | let timeNow = new Date();
let timestampNow = timeNow.getTime();
if($.cookie('sunrise') === undefined || $.cookie('sunset') === undefined || returnCitySN["cip"] !== $.cookie('ip')) {
console.log("IsNight? Run!");
var details = {};
details["TIME"] = parseInt(new Date().getTime() / 1000);
details["IP_ADDRE... | true |
4b4d8062b6954aa71092def3953508362e0f0a0e | JavaScript | MLT-NYC/leetcode | /plusOne.js | UTF-8 | 2,075 | 4.375 | 4 | [] | no_license | // Given a non-empty array of digits representing a non-negative integer, plus one to the integer.
// The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit.
// You may assume the integer does not contain any leading zero, except the... | true |
6a0f0fa36c70c341fc8af91789d36df13955e780 | JavaScript | tnmnv/firstrep | /main5.js | UTF-8 | 193 | 2.71875 | 3 | [] | no_license | window.addEventListener('click', function(e) {
console.log(e.value);
let text = document.getElementById('text').value;
localStorage.setItem('key.value', text);
});
| true |
4636062d3d7b66ce13169d5a28ae91e091031556 | JavaScript | saiphanindra1010/RITO-PDF | /index.js | UTF-8 | 2,423 | 2.75 | 3 | [] | no_license | var primaryPdf = null
var mergePdf = null
// Uploaders
document.getElementById("fileUpload").onchange = event => fileUploader(event, loadPrimaryPdf);
document.getElementById("mergeFileUpload").onchange = event => fileUploader(event, loadMergePdf);
function fileUploader(event, onloadCallback) {
var input = event.t... | true |
f06417df4b520baac0e604168732953c4bcb15b6 | JavaScript | dwiyanscg/react | /bissmillah_belajar/src/App.js | UTF-8 | 1,943 | 2.78125 | 3 | [] | no_license | import React from 'react';
import logo from './logo.svg';
import './App.css';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
username: '',
age: null,
send: null,
errormessage: ''
};
}
myChangeHandler = (event) => {
let nam = event.tar... | true |
996d41289715ad104156a04335f054be3937b0f8 | JavaScript | mrgareth/MaquinaVirtual | /pweb2/SQLite/consulta.js | UTF-8 | 585 | 3.0625 | 3 | [] | no_license | function search(kind, term){
console.log(kind);
console.log(term);
var url = 'cgi-bin/consulta.py?kind='+kind+'?term'+term;
console.log(url);
loadDoc(url,render);
}
}
function render(data){
//Aqui leemos los datos y los devolveremos hacia el html
}
function loadDoc(url, cFunction){
var xhttp;
xhttp = new XML... | true |
dbb171816a57f9a266832daff7150b1035b148b7 | JavaScript | mariakang/clever-cat | /search-algorithms/search-algorithms.js | UTF-8 | 14,447 | 4.09375 | 4 | [] | no_license | /*
Search Algorithms
This application defines two search functions: linear search and binary
search. Each function takes two arguments: N and x, and will try to find x
in the range 1 to N (inclusive). If a match is found, the number of guesses
is returned, otherwise false is returned.
For a given test size N, this ap... | true |
77e7e685e9117326a0ec4a910c200ba9a6b16522 | JavaScript | rokydas/js-event | /callback.js | UTF-8 | 580 | 3.578125 | 4 | [] | no_license | function explainCallBack(name, age, task){
console.log("Hello ", name);
console.log("your age is ", age);
//console.log("your task is ", task);
task();
}
function washHand(){
console.log('Wash hand with soap');
}
function takeShower(){
console.log('Take Shower');
}
explainCallBack('Roky Das',... | true |
7f7c0ae5e4ba877ad3def88e447412436a0d6ba3 | JavaScript | eric-dowty/eric-dowty.github.io | /apps/rails-pub-sub-node-server/lib/chat.js | UTF-8 | 1,840 | 3.140625 | 3 | [
"MIT"
] | permissive | //initiate socket using const io from server
var socket = io();
//get DOM elements
var messages = document.getElementById('message-view');
var messageButton = document.getElementById('new-message-submit');
var nameButton = document.getElementById('name-submit');
var userName = 'Guest';
var userColor =... | true |
405ed7728f5fda48d6fed3c63f82d1a64de776bd | JavaScript | eddie0329/Study__React | /redux-practice/src/reducers.js | UTF-8 | 914 | 2.765625 | 3 | [] | no_license | import { ADD_TODO, COMPLETE_TODO } from "./action";
export function todos(previousState, action) {
if (previousState === undefined) {
return [];
}
if (action.type === ADD_TODO) {
return [...previousState, { text: action.text, completed: false }];
}
if (action.type === COMPLETE_TODO) {
const newSt... | true |
b3c255480db860aea9884c2f0b42ba4eea97a23e | JavaScript | andyemnem63/node_book | /Chapter05/10_async_parallel.js | UTF-8 | 381 | 2.609375 | 3 | [] | no_license | var async = require("async");
async.parallel({
numbers: function (callback) {
setTimeout(function () {
callback(null, [ 1, 2, 3 ]);
}, 1500);
},
strings: function (callback) {
setTimeout(function () {
callback(null, [ "a", "b", "c" ]);
}, 2000);
... | true |
581ba7c5f4f8f93a50f690c035266df23c902a3b | JavaScript | RadostinGerdzhikov/SOF-UNI-JS-APP-MODULE | /JS TECH MODULE SOFT UNI/06- DATA TYPES and VARIABLES-more EXERCUSIES/03-Cone.js | UTF-8 | 363 | 3.59375 | 4 | [] | no_license | 'use strict';
function cone(radius,height) {
let slantHeight = Math.sqrt(radius ** 2 + height ** 2);
let area = Math.PI * radius ** 2 + Math.PI * radius * slantHeight;
let volume = Math.PI * radius * radius * (height / 3);
console.log("volume = " + volume.toFixed(4));
console.log("area = "... | true |
07dfa85e39e4753a759e614794ddde3f23de2e87 | JavaScript | ysbaddaden/wyme | /src/support/alpha-core.js | UTF-8 | 73,605 | 3.21875 | 3 | [
"MIT"
] | permissive | /**
* http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array
*/
// JavaScript 1.6
if (!Array.prototype.indexOf)
{
Array.prototype.indexOf = function(elt /*, from*/)
{
var len = this.length;
var from = Number(arguments[1]) || 0;
from = (from < 0) ? Math.ceil(from) : Math.floor(fr... | true |
5ea0f36ec6d35fa69a56366c808d46ce10ca0304 | JavaScript | jonfreihofer/contacts-app | /src/Components/Context/index.js | UTF-8 | 2,857 | 2.625 | 3 | [] | no_license | import React, { useState, useRef, useEffect } from "react";
import Contact from "../Contact";
const Context = React.createContext();
function ContextProvider({ children }) {
//todo: refactor colors as vars
const inputRef = useRef(null);
const [inputData, setInputData] = useState({
id: 0,
editName: "",
... | true |
4d90de728ee217c07c799a8f9f2396678ef324dd | JavaScript | Lorandi/Codewars | /7kyu/33.js | UTF-8 | 408 | 3.5 | 4 | [] | no_license | //Reverse words
const reverseWords = s => s.split(" ").map(x => x.split("").reverse().join("")).join(" ")
console.log(reverseWords('The quick brown fox jumps over the lazy dog.'))//'ehT kciuq nworb xof spmuj revo eht yzal .god');
console.log(reverseWords('apple')) //'elppa');
console.log(reverseWords('a b c d'))//'... | true |
8d0f3eb32c19acb3a76883877ee0976238a54d3b | JavaScript | mnicolai20/project-2-quiz-generator | /public/js/signup.js | UTF-8 | 2,227 | 3.03125 | 3 | [] | no_license | $(document).ready(() => {
// Getting references to our form and input
const signUpForm = $("form.signup");
// const adminUserInput = $("input#adminUser-input");
const usernameInput = $("input#username-input");
const passwordInput = $("input#password-input");
const firstNameInput = $("input#firstName-input"... | true |
963cd0ac7d85b5b08ca334a21508bd5faf5d29de | JavaScript | anoldwebsite/clothstore-graphql-version | /src/redux/cart/cart.utils.js | UTF-8 | 1,361 | 3.390625 | 3 | [] | no_license | export const addItemToCart = (cartItems, cartItemToAdd) => {
const existingCartItem = cartItems.find(
cartItem => cartItem.id === cartItemToAdd.id
);
if (existingCartItem) {//Item already exists in the cart.
//Function map returns a new array
return cartItems.map(cartItem =>
... | true |
55d896ad3d78d443bf06e55b7f3b6f81a4e35f00 | JavaScript | Devancn/my-service-worker | /app.js | UTF-8 | 3,085 | 2.75 | 3 | [] | no_license | // service worker 注册
if ("serviceWorker" in navigator) {
navigator.serviceWorker
.register("/sw.js", { scope: "./" })
.then((registration) => {
console.log(registration, "registration");
if (registration.installing) {
console.log("Service worker 安装中");
} else if (registration.waiting... | true |
8f765f522f033f68b0855bc536f218b034475c49 | JavaScript | JING-Bio/unipept | /app/assets/javascripts/components/amount_table.js | UTF-8 | 16,650 | 2.734375 | 3 | [
"MIT"
] | permissive | import {toCSVString, downloadDataByForm} from "../utils.js";
/**
* @typedef {Object} AmountTableSettings
* @property {D3.selection} el
* The target container
* @property {string} title
* A string naming the table (used for export name)
* @property {any[]} data
* array of data to display (valu... | true |
5049297da47a9dc3f13fb5df4eb94937bc499b61 | JavaScript | AlexHarris-Charlotte/React-Memory | /src/Store/reducer.js | UTF-8 | 905 | 2.828125 | 3 | [] | no_license | const initialState = {
score : 0,
totalScore : 0,
clickedImages : [] ,
images : [
"/images/Brow.jpg","/images/Butler.jpg", "/images/lebron.jpg",
"/images/Harden.jpg", "/images/KD.jpg", "/images/KP.jpg",
"/images/Kyle.jpg", "/images/Kyrie.jpg", "/images/Embiid.jp... | true |
97dbdcc9a68afa6f4a7c77cfe201d57caf9606de | JavaScript | imashish1705/CodingBlockAssignmentWebDev | /calculator/app.js | UTF-8 | 579 | 3.390625 | 3 | [] | no_license | const buttons = document.querySelectorAll("button");
const inputKiValue = document.getElementById("inputKiValue");
for(let btn of buttons) {
btn.addEventListener("click", function(e) {
let buttonText = e.target.innerText;
if(buttonText == 'X') {
inputKiValue.value += '*';
... | true |
ce5e339b12667f57ea1e96c0523812d6c1d37786 | JavaScript | David-Ward-Ellis/JS-Programing-Foundations | /Easy_Problems4/letterCounter.js | UTF-8 | 1,090 | 3.75 | 4 | [] | no_license | function letterCounter(str) {
let letterCount = {};
let strArray = str.toLowerCase().split(' ');
if (str === '') return letterCount;
for(let idx = 0; idx < strArray.length; idx += 1) {
let newWord = removeNonLetter(strArray[idx]);
strArray[idx] = newWord;
}
for (let idx = 0; idx < strArray.lengt... | true |
20b52ff0a1858e1cedc3b5a490bec4d1a3fae16f | JavaScript | carlosvpi/genuflex | /toArray.js | UTF-8 | 199 | 2.8125 | 3 | [
"MIT"
] | permissive | const toArray = (generator) => {
let array = []
let next
while (!(next = generator.next()).done) {
array.push(next.value)
}
return array
}
module.exports = toArray
| true |
d42033ad70bd763881fbb48dad001d20d168820f | JavaScript | sameersaini12/custum-cart | /app/config/passport.js | UTF-8 | 1,118 | 2.546875 | 3 | [] | no_license | const LocalStatergy = require("passport-local").Strategy;
const User = require("../models/user");
const bcrypt = require("bcrypt");
const init =async (passport) => {
passport.use(new LocalStatergy({usernameField : 'email'},async (email , password ,done)=> {
const user = await User.findOne({email : email}... | true |
d7f5d12b76a6dea4681e0a059d203c0ff80c25ed | JavaScript | mariska12/BST_mocha | /src/bst.js | UTF-8 | 3,980 | 3.5625 | 4 | [] | no_license | function Node(name, value){
this.value = value;
this.name = name;
}
Node.prototype.setLeft = {
constructor: Node,
left:function(left) {
this.left = left;
}
};
Node.prototype.setRight = {
constructor: Node,
right:function(right) {
this.right = right;
}
};
function ins... | true |
613ef4de879ea9489e7e06edb18425af1b23f643 | JavaScript | bubykay/algorithm | /staircase.js | UTF-8 | 320 | 3.4375 | 3 | [] | no_license | function staircase (n){
let s = '[', b =[], line = ' ';
for(let i = 0; i<=n; i++){
b.push(s.repeat(i))
}
b.map(
x =>{
if(x.length>0){
let lengtho = n - x.length;
console.log(line.repeat(lengtho)+x)
}
}
)
}
staircase(20); | true |
66d813cc47754a2d0b15adfcc9c6e771750bb42b | JavaScript | Rashy98/ds-assignment-web-client | /src/App.js | UTF-8 | 5,984 | 2.59375 | 3 | [] | no_license | import React,{Component} from 'react';
import './App.css';
import axios from 'axios';
import {Row,Col, Container, Jumbotron} from "react-bootstrap";
class App extends Component{
constructor(props) {
super(props);
this.state = {
sensors: [],
interval : null,
}
}
getSensorData() {
... | true |
9c82b21c1edf0e56c5bc07fc3a7d5d859459f60a | JavaScript | anthonyjshaw/tester | /app/javascript/packs/change_text_box.js | UTF-8 | 455 | 2.671875 | 3 | [] | no_license |
const changeTextBox = () => {
const messageContainer = document.querySelectorAll('.message-container')
if (messageContainer) {
const isCurrentUser = messageContainer.forEach((element) => {
if (element.dataset.chatroomMessengerId === "true") {
console.log(element.dataset.chatroomMessengerId)
elem... | true |
46087ecf0a8751e07fb96bf5d7bcbc82d266ee93 | JavaScript | tomekadamczyk/lang-app | /views/favorites/weather/weather.js | UTF-8 | 1,397 | 3.265625 | 3 | [
"MIT"
] | permissive | const getWeather = async(lat, lon) => {
const response = await fetch(`http://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&lang=pl&APPID=a22810cb3d31368b80b58499e952408b`);
if (response.status === 200) {
const data = await response.json();
return data;
}
else {
... | true |
25f925be4f6fc253e33f201d06b1ad4c1c15a4f5 | JavaScript | Kolafim/wxapp-i-reply | /util/ReTime.js | UTF-8 | 3,788 | 3.046875 | 3 | [] | no_license | /**
* 倒计时
* new ReTime()
* .uploadEndDate(endtime) 更新截止时间
*/
export default class ReTime {
constructor(){
this.date = {
default:0,
isUpdate:1,
redate:0,
endTimeLoading:0,
timeend:-1
}
this.uploadDate();
setInterval(()=>this.uploadDate(),5000);
}
/**
* 更新本地时间
... | true |
91e15de3d49c1fb6dbd49611527a31b45093ffb7 | JavaScript | swimauger/googlefuncs | /DOMAINPRICE.gs | UTF-8 | 907 | 2.859375 | 3 | [] | no_license | /**
* Fetch the price of a domain from GoDaddy
*
* @param {string} input The value of the domain you are searching.
* @return data information on the domain
* @customfunction
*/
function DOMAINPRICE(domain) {
if (domain) {
domain = domain;
var url = "https://api.godaddy.com/v1/domains/available?domain="... | true |
c772499516f3eda81dad9d4ad8cc4c5a14a09202 | JavaScript | alvinb/practice-problems | /two-sum.js | UTF-8 | 379 | 3.46875 | 3 | [] | no_license | const twoSum = (nums, target) => {
const map = new Map();
if (nums.length === 2) {
return [0, 1];
}
for (let i = 0; i < nums.length; i++) {
const complement = target - nums[i];
const index = map.get(complement);
if (map.has(complement) && index !== i) {
return [i, index];
}
map.se... | true |
4f0d191d5d5b7b893888a6d391c0d4a130ede08b | JavaScript | Matt-GitHub/Sprint-Challenge-Single-Page-Apps | /src/components/CharacterList.js | UTF-8 | 2,658 | 2.78125 | 3 | [] | no_license | import React, { useEffect, useState } from "react";
import axios from "axios";
import { Card, Image } from "semantic-ui-react";
import styled from "styled-components";
// Styled
const CardBox = styled.div`
display: flex;
flex-direction: row;
border: 1px solid black;
padding: 1px;
max-width: 100%;
width: 70... | true |
5dd9dbf241852a3f541fc0834394632c0a815964 | JavaScript | PSU-Capstone-Winter-Spring-2021/Eviction-Sponge | /src/frontend/src/components/FillForm.jsx | UTF-8 | 31,121 | 2.5625 | 3 | [
"MIT"
] | permissive | import React from 'react';
import axios from 'axios';
import InvalidInputs from "./InvalidInputs";
import fileDownload from "js-file-download";
// const testProps = {
// county_name: 'Clark',
// case_number: '11001001',
// case_name: 'Charles Cheese v Caesar Jr',
// date_of_judgment: '6/26/11',
// ... | true |
b0477e0454378bbc2f737e7c66b99cb9705b231f | JavaScript | hugentoblerd/JavaScript-Review | /arrayReview.js | UTF-8 | 6,259 | 4.78125 | 5 | [] | no_license | var threeItems = [1,2,3];
//create a function named 'last' that returns the last item from 'threeItems'
//alert the result of your function
// _____My Code______________________________________________________________
var last = function(arr){
var answer = arr[arr.length - 1]
return answer
}
alert(last(threeItems... | true |
f656a18a633ad48dc3e21c3ded759e13ec8c85a2 | JavaScript | mmomen/coding-challenges | /compression.js | UTF-8 | 249 | 3.140625 | 3 | [] | no_license | var str = "aaaaabb"
var compress = function(str) {
var len = str.length;
var first = str.charAt(0);
var next = function(index) {
for (var i=0,count=0; i<len; i++) {
if (first === str.charAt(i)) {
count++;
}
}
}
} | true |
e6eb4a344b7badeae0bfc3241e9e96f89c4ed2b7 | JavaScript | ifty64bit/WT_Final_SUM21 | /Project/WT_PROJECT/Controller/js/requestLoan.js | UTF-8 | 560 | 2.984375 | 3 | [] | no_license | var a_err = false;
function get(id)
{
return document.getElementById(id);
}
function checkA(e)
{
if (e.value == "")
{
a_err = true;
get('a_err').innerHTML = "Value is Empty";
}
else if (isNaN(e.value))
{
a_err = true;
get('a_err').innerHTML = "Value is not numaric"... | true |
d43745d3cb863efa9f161468b83a3776b1467781 | JavaScript | chrisbonifacio/Web-Application-Testing | /baseball-app/src/App.test.js | UTF-8 | 1,820 | 2.9375 | 3 | [] | no_license | import React from "react";
import App from "./App";
import { render, fireEvent } from "@testing-library/react";
import Dashboard from "./components/Dashboard";
import Display from "./components/Display";
// Initial State
test("App renders with intial state of Balls set to 0", () => {
const container = render(<App />... | true |
07d118a4c68cdf99bc02a644579f817f8e4d9ab7 | JavaScript | zhangjiquan1/phpsourcecode | /lookingdreamer/AutomationManagement/Public/Echarts/Public/pages/select/data.js | UTF-8 | 219 | 2.84375 | 3 | [] | no_license | var contents = [];
for (var i = 0; i < 4; i++) {
var content = {};
content.title = "第" + (i + 1) + "个";
content.value = i + 1;
content.selected = i == 0 ? true : false;
contents.push(content);
} | true |
3569699e23138cd510fa34ffb0db74748a8e00d6 | JavaScript | adventistchurch/validate-core | /src/validators/email.js | UTF-8 | 425 | 2.609375 | 3 | [
"MIT"
] | permissive | import { isDefined, isString } from '../utils'
import REGEXP from '../regexp'
export const defaults = {
message: 'is not a valid email',
pattern: REGEXP.EMAIL
}
export default (value, options) => {
const { message, pattern } = { ...defaults, ...options }
const isNotDefined = !isDefined(value)
if (isNotDef... | true |
07a01217c4e3d1a5bad61c996d72c480300b5e37 | JavaScript | a4heng/challenges | /balancedParens.js | UTF-8 | 510 | 3.4375 | 3 | [] | no_license | const balancedParens = (input) => {
let stack = [];
for (let i = 0; i < input.length; i++) {
if (input[i] === "{" || input[i] === "[" || input[i] === "(") {
stack.push(input[i]);
} else if (input[i] === "}" || input[i] === "]" || input[i] === ")") {
if (stack.length === 0) return false;
le... | true |
99ac43b50770d7ea613ada742e5a0b143087e1db | JavaScript | philomath242/Love-Calculator | /js/main.js | UTF-8 | 550 | 3.03125 | 3 | [] | no_license | function validate() {
var username = document.getElementById('username').value;
var password = document.getElementById('password').value;
if (username.includes('@') && username.includes('.')) {
if (password == "") {
alert('Password cannot be empty!');
return false;
}... | true |
49dde6471a3b4529d96d318e8fc6d5ab9143b149 | JavaScript | fabriciocintras/numerosRondomicos | /src/App.js | UTF-8 | 1,114 | 2.765625 | 3 | [] | no_license | import React, {useState} from "react";
import {
Text,
SafeAreaView,
TouchableOpacity,
StyleSheet,
} from "react-native";
const App = ()=>{
const [numero, setNumero] = useState(10)
function handleNumero(){
const novoNumero = Math.floor(Math.random() * 10);
setNumero(novoNume... | true |
14dfdea58e739483047876ae87e5b973dca416b6 | JavaScript | OlenaChupryna/About_me | /Project_in_JS/script.js | UTF-8 | 8,282 | 3.046875 | 3 | [] | no_license | "use strict";
class Switcher {
static turn(state) {
if (state == true) {
return false;
}
return true;
}
}
class WarningMaker {
static alarm (alarmText) {
alert(alarmText);
}
}
class SimpleEquipment {
constructor (name){
this._name = name;
this._OnOffState = false;
}
changeState() {
this._O... | true |
5f568718450c237231280aae6c4ee60330ed6cff | JavaScript | Tcooper920/fetchingPosts | /index.js | UTF-8 | 2,328 | 3.578125 | 4 | [] | no_license | /* Fetching Posts & Displaying Comments */
// Get all users
const getAllUsers = async () => {
const getUsers = await fetch(`https://jsonplaceholder.typicode.com/users`);
const retrievedUsers = await getUsers.json();
return retrievedUsers;
};
// Get all posts
const getAllPosts = async () => {
const getPosts = awa... | true |
715d130f52bf7372a94e2c5077d9f3ddd8e836a0 | JavaScript | econavi/hexlet | /front/14/04-reduce.js | UTF-8 | 915 | 3.03125 | 3 | [] | no_license | /*
reduce.js
Реализуйте и экспортируйте по умолчанию функцию-редьюсер обрабатывающую файловые деревья.
const tree = mkdir('/', [
mkdir('etc', [
mkdir('nginx'),
mkdir('consul', [
mkfile('config.json'),
]),
]),
mkfile('hosts'),
]);
reduce((acc, n) => acc + 1, tree, 0); // => 6
*/
// BEGIN (write... | true |
98d17d4bfdaaa0a7c2bebcdaa51ad2f7aca6e2bd | JavaScript | iprutkovsky/Codewars_-_Codesignal_-_Leetcode | /knightOnBoardProbability.js | UTF-8 | 626 | 3.34375 | 3 | [] | no_license | function knightOnBoardProbability(m, n, steps, x, y) {
let mem = {};
let dfs = (steps, x, y) => {
let k = `${steps}:${x}:${y}`,
c = 0;
if (mem[k]) return mem[k];
if (x < 0 || x >= m || y < 0 || y >= n) return 0;
if (steps == 0) return 1;
for (let [... | true |
2fc165e02e7d2d609573ecb9ddfd3e59313bad57 | JavaScript | gutzy/pixel-editor | /src/utils/CanvasUtils.js | UTF-8 | 5,308 | 3.4375 | 3 | [] | no_license | /**
* Get Center Rect - get the coordinates for a rectangle of a given width/height/scale/offset positioned in the
* center of a target canvas
*
* @param {HTMLCanvasElement} canvas - target canvas, represents full size
* @param {number} width - rect width
* @param {number} height - rect height
* @param {number} ... | true |
1ab53ed1b4987d776824fc6cd9f8cd81b4dd0d5c | JavaScript | wapinpana/wapinpana.github.io | /week5/calculator-box/js/project.js | UTF-8 | 552 | 2.609375 | 3 | [] | no_license | $(document).ready(function(){
$(".combine").click(function(){
var currentTotal = parseInt($("#white").html());
var num = parseInt( $(this).html() );
$("#white").html(currentTotal + num);
});
$(".change-color").click(function(){
$("#white").css("background-color", $(this).attr("id"));
if ($(this).attr(... | true |
7d51304e089e536d29941772e7e0b07d0b94e0a6 | JavaScript | vinaynag/atthackgame | /twolists.js | UTF-8 | 9,380 | 2.78125 | 3 | [] | no_license | var TwoLists = function()
{
var ret = {'dmg':17};
var isActive = false;
var c=0;
var ctx=0;
var size = 35;
var diffX = 40;
var bigX = 20;
var bigY = 20;
var coord = new Array();
var ans = new Array();
var chosen = new Array();
var numb = new Array();
function creatediv(... | true |
6f52a144eeac289f8d520730144bd648db4c4f61 | JavaScript | gin-vtc/node-api | /index.js | UTF-8 | 6,110 | 2.65625 | 3 | [] | no_license | const express = require('express');
const dbFunc = require('./func');
const app = express();
const port = 3000
// デフォルト
app.use(function (req, res, next) {
// Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', '*');
// Request methods you wish to allow
res.setHeader('Ac... | true |
0fca959999f3d25d4bb042921571125e37ef2d8d | JavaScript | victor-gu/material | /vue/axios/httpclient.js | UTF-8 | 1,420 | 2.515625 | 3 | [
"MIT"
] | permissive | import axios from 'axios';
const basrUrl = "http://localhost:888";
function filterUrl(url){
if(url.startsWith('http') || url.startsWith('https')){
return url;
};
return basrUrl+"/"+url;
}
export default {
get(url, params){
return new Promise((resolve, reject) => {
axios({
... | true |
2205c76544501d9e18020f5853bc957081a33539 | JavaScript | cvegar/myPage | /Index.js | UTF-8 | 2,578 | 3 | 3 | [] | no_license | /* const { Pool } = require('pg');
const config={
user: 'postgres',
host: 'localhost',
password:'pgsql',
database: 'postgres'
}
const pool =new Pool(config);
const getUsers=async () =>
{
try {
const response =await pool.query('select * from ... | true |