This file contains 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
/* Card basic structure and positioning (Including front and back) */ | |
/* Slightly modified version from the original: http://selfthinker.github.io/CSS-Playing-Cards/ (CC BY-SA) */ | |
.card-group { | |
transform-style: preserve-3d; | |
transform-origin: 3em 4.5em; /* half of card size */ | |
} | |
.card { | |
width: 6em; | |
height: 9em; |
This file contains 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
// Calculates the Rank of a 5 card Poker hand using bit manipulations. | |
// Adapted from the original CPOL-Licensed code by subskybox | |
// In-depth article explaining how the rank function works available here: | |
// http://www.codeproject.com/Articles/569271/A-Poker-hand-analyzer-in-JavaScript-using-bit-math | |
rankPokerHand(hand) { | |
if(hand.length < 5) return; | |
let v, i, o, s = 1 << hand[0].rank | 1 << hand[1].rank | 1 << hand[2].rank | 1 << hand[3].rank | 1 << hand[4].rank; | |
for (i = 0, v = o = 0; i < 5; i++) { | |
o = Math.pow(2, hand[i].rank * 4); | |
v += o * ((v / o & 15) + 1); |
This file contains 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 Dispatcher = require('flux').Dispatcher; | |
/* | |
* Do not create helper methods such as "handleViewAction" unless you have a use case in your app | |
var AppDispatcher = new Dispatcher(); | |
AppDispatcher.handleViewAction = function(action) { | |
this.dispatch({ | |
source: 'VIEW_ACTION', | |
action: action | |
}); |
This file contains 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
create: function(text) { | |
// Instead of using the helper | |
// AppDispatcher.handleViewAction(...) | |
// Dispatch directly | |
AppDispatcher.dispatch({ | |
actionType: TodoConstants.TODO_CREATE, | |
text: text | |
}); | |
} |
This file contains 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 TodoStore = assign({}, EventEmitter.prototype, { | |
/* | |
* These aren't really necessary: | |
* | |
addChangeListener: function(callback) { | |
this.on(CHANGE_EVENT, callback); | |
}, | |
removeChangeListener: function(callback) { | |
this.removeListener(CHANGE_EVENT, callback); | |
} |
This file contains 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
componentDidMount: function() { | |
// Instead of TodoStore.addChangeListener(this._onChange); | |
TodoStore.addListener(StoreConstants.CHANGE, this._onChange); | |
}, | |
componentWillUnmount: function() { | |
// Instead of TodoStore.removeChangeListener(this._onChange); | |
TodoStore.removeListener(StoreConstants.CHANGE,this._onChange); | |
}, |
This file contains 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 contacts = {}; | |
var handleAddContact = (action) => { | |
contacts.assign(contacts, action.contact); | |
ContactsStore.emitChange(); | |
} | |
var handleRemoveContact = (action) => { | |
var updatedContacts = state.contacts.filter((contact) => { | |
return contact.id !== action.contact.id; |
This file contains 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 keyMirror = require('react/lib/keyMirror'); | |
module.exports = { | |
API: 'http://my-rest-api.com', | |
ActionTypes: keyMirror({ | |
ADD_CONTACT: null, | |
DELETE_CONTACT: null | |
}) | |
}; |
This file contains 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 events = new EventEmitter(); | |
var CHANGE_EVENT = 'CHANGE'; | |
var todos = {}; | |
var TodoStore = { | |
addChangeListener: function(callback) { | |
events.addListener(CHANGE_EVENT, callback); | |
}, |
This file contains 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'; | |
class Voucher extends Component { | |
constructor() { | |
super(…arguments) | |
this.state = { | |
passengers: [ | |
'Simmon, Robert A.', | |
'Taylor, Kathleen R.' | |
], |
OlderNewer