This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createContext, useContext, FC, ReactNode, useState } from 'react' | |
interface State { | |
loading: boolean, | |
currentRound: number, | |
} | |
interface IContext { | |
state: State, | |
setState: React.Dispatch<React.SetStateAction<State>> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
import './button.scss'; | |
export default class Something extends Component { | |
let lastData; | |
render() { | |
const { price } = this.props; | |
const lastPrice = lastData; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('should render a random id everytime', () => { | |
const lastId = component.find('input').prop('id'); | |
const secondComponent = shallow(<Input />); | |
expect(secondComponent.find('input').prop('id')).to.equal(lastId); | |
}); | |
it('should link the id between label and input', () => { | |
const labelHtmlFor = component.find('label').prop('htmlFor'); | |
const inputId = component.find('input').prop('id'); | |
expect(labelHtmlFor).to.equal(inputId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"data":{"banks":[{"value":801041,"label":"ABN AMRO BANK N.V. HONG KONG"},{"value":18810,"label":"AMERICAN EXPRESS BANK LTD."},{"value":840652,"label":"AUSTRALIA AND NEW ZEALAND BANK"},{"value":87261,"label":"BANK OF CHINA"},{"value":107352,"label":"BANK OF CHINA (HONG KONG) LTD"},{"value":542972,"label":"BANK OF COMMUNICATIONS"},{"value":888083,"label":"BANK OF COMMUNICATIONS CO LTD"},{"value":679566,"label":"BSI LTD HONG KONG BRANCH"},{"value":681878,"label":"CHINA CITIC BANK INTERNATIONAL"},{"value":208627,"label":"CHINA CONSTRUCTION BANK (ASIA)"},{"value":93775,"label":"CHIYU BANKING CORPORATION LTD"},{"value":336843,"label":"CHONG HING BANK LIMITED"},{"value":617031,"label":"CITIBANK (HONG KONG) LIMITED"},{"value":507117,"label":"CITIC BANK INTERNATIONAL LIMIT"},{"value":26740,"label":"CITIC KA WAH BANK LIMITED"},{"value":747741,"label":"CREDIT SUISSE AG, HONG KONG BR"},{"value":27574,"label":"DAH SING BANK LIMITED"},{"value":343439,"label":"DBS BANK (HK) LTD"},{"value":94288,"label":"DBS BANK (HONG KONG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#register').submit(function(event){ | |
event.preventDefault(); | |
var data = { | |
username: $('#username').val(), | |
password: $('#password').val(), | |
email: $('#email').val() | |
} | |
$.post('https://fewd20.herokuapp.com/register', data, function(data){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var url = 'https://fewd20.herokuapp.com/data'; | |
var usedNames = []; | |
$('#send').click(function(){ | |
$.get(url, function(data, status){ | |
for (var i = 0; i < data.length; i++) { | |
if (usedNames.indexOf(data[i].name) === -1) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="box"></div> | |
<div class="box"></div> | |
<div class="box"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var images = ['images/food1.jpg', 'images/food2.jpg', 'images/food3.jpg']; | |
var votes = [0, 0, 0]; //This is the average | |
var vote; | |
var imageNum = 0; | |
var average | |
$('#back').click(function(){ | |
if (imageNum !== 0){ | |
imageNum --; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('app', []).directive('ngDebounce', function($timeout) { | |
return { | |
restrict: 'A', | |
require: 'ngModel', | |
priority: 99, | |
link: function(scope, elm, attr, ngModelCtrl) { | |
if (attr.type === 'radio' || attr.type === 'checkbox') return; | |
elm.unbind('input'); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('app', []).directive('ngDebounce', function($timeout) { | |
return { | |
restrict: 'A', | |
require: 'ngModel', | |
priority: 99, | |
link: function(scope, elm, attr, ngModelCtrl) { | |
var debounce; | |
var maxLength; //maximum length for debounce to take effect | |
if (attr.type === 'radio' || attr.type === 'checkbox') return; |