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 copyProperties = require('react/lib/copyProperties'), | |
Dispatcher = require('flux').Dispatcher, | |
util = require('util'); | |
function AppDispatcher() { | |
Dispatcher.call(this); | |
this._queue = []; | |
} | |
util.inherits(AppDispatcher, Dispatcher); |
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
<!-- http://joakimbeng.eu01.aws.af.cm/a-javascript-router-in-20-lines/ --> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Building a router</title> | |
<script> | |
// Put John's template engine code here... |
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 arrayData = [...]; | |
var arrayOfItems = arrayData.map(function(item, i) { | |
return ( | |
<item key={i}>{item}</item> | |
); | |
}); |
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 React = require('react'); | |
var Medium = require("medium.js"); | |
function setupEditable(self) { | |
var editable = self.props.editable; | |
var extraOptions = self.props.extraOptions; |
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
// http://stackoverflow.com/a/18368720 | |
// http://codepen.io/mrmoje/pen/lkLez | |
// HTML | |
<div contentEditable=true data-placeholder="My Placeholder String"></div> | |
// CSS |
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 http = require("http"), | |
url = require("url"), | |
path = require("path"), | |
fs = require("fs") | |
port = process.argv[2] || 8888; | |
http.createServer(function(request, response) { | |
var uri = url.parse(request.url).pathname | |
, filename = path.join(process.cwd(), uri); |
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
/** | |
* Return true/false if key is found in Object (one level) | |
* @param {object} object where to try find key | |
* @param {string} key - string to find in object | |
* @return {boolean} true/false if key is found | |
*/ | |
var foundInObject = function (object, key) { | |
var keyFound = null; |
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
/** | |
* Merge objects (recursively merge deep objects) | |
* @param {object} objects as arguments to merge merge(object, object2,..) | |
*/ | |
var merge = function() { | |
var res = {}; | |
for (var i = 0; i < arguments.length; ++i) { | |
if (arguments[i]) { |
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
// https://speakerdeck.com/vjeux/react-css-in-js | |
function m() { | |
var res = {}; | |
for (var i = 0; i < arguments.length; ++i) { | |
if (arguments[i]) { | |
Object.assign(res, arguments[i]); | |
} | |
} | |
return res; |
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 React = require('react'); | |
var Input = React.createClass({ | |
getInitialState: function() { | |
return { | |
value: this.props.value || '' | |
}; | |
}, |