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
// Search form component | |
window.Ui = window.Ui || {}; | |
Ui.SearchForm = (function() { | |
return flight.component(SearchForm); | |
function SearchForm() {} | |
}()); | |
// validation mixin |
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
// Scenario: | |
// Compnonent BAR requests data from the server via an action `REQ_BAR` | |
// Component FOO receives data from a previous request `REQ_FOO_SUCCESS` | |
// --- Cannot dispatch in the middle of a dispatch. --- error is triggered | |
// `WaitFor` doesn't seem right, since the stores for these two components aren't related e.g: | |
// The store used for component FOO does not need any data from the store used for component BAR | |
// ActionsCreators | |
// =================== | |
var ActionCreators = { |
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
!function() { | |
var doc = document, | |
htm = doc.documentElement, | |
lct = null, // last click target | |
nearest = function(elm, tag) { | |
while (elm && elm.nodeName != tag) { | |
elm = elm.parentNode; | |
} | |
return elm; | |
}; |
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
Math[flag ? "min" : "max"](a, b) | |
// from uglifyjs | |
if (foo) bar(); else baz(); ==> foo?bar():baz(); | |
if (!foo) bar(); else baz(); ==> foo?baz():bar(); | |
if (foo) bar(); ==> foo&&bar(); | |
if (!foo) bar(); ==> foo||bar(); |
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 nodeunit = require('nodeunit'); | |
exports['API'] = nodeunit.testCase({ | |
'The show() API method returns a specific thread by title and its replies by threadid': function(test) { | |
test.expect(4); | |
// our mock data | |
var posts = [{post: 'test'}, {post: 'test2'}]; | |
var thread = {_id: '1234', title: 'my thread'}; |
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
/* The API controller | |
Exports 3 methods: | |
* post - Creates a new thread | |
* list - Returns a list of threads | |
* show - Displays a thread and its posts | |
*/ | |
var Thread = require('../models/thread.js'); | |
var Post = require('../models/post.js'); |
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
module.exports = function(Thread, Post) { | |
return { | |
post: function(req, res) { | |
new Thread({title: req.body.title, author: req.body.author}).save(); | |
}, | |
list: function(req, res) { | |
Thread.find(function(err, threads) { | |
res.send(threads); | |
}); |
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
/** | |
* Configuration. This file is read only | |
* | |
* @api private | |
*/ | |
module.exports = Object.freeze({ | |
pewpew: "moo" | |
}); |
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 time = +new Date(); // get time | |
var d = new Date(); | |
var month = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'][d.getMonth()]; | |
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
app.get('/help', function(req, res){ | |
res.send('some help'); | |
}); | |
app.get('/search/:query/p:page', function(req, res){ | |
var query = req.params.query | |
, page = req.params.page; | |
res.send('search "' + query + '", page ' + (page || 1)); | |
}); |
OlderNewer