forked from jstogether/jstogether
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
60 lines (51 loc) · 1.42 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React from 'react';
import $ from 'jquery';
import _ from 'lodash';
import moment from 'moment-timezone';
import ExecutionEnvironment from 'react/lib/ExecutionEnvironment';
import AppComponent from './component/app';
import AppActions from './action/app';
if (ExecutionEnvironment.canUseDOM) {
window.$ = $;
window._ = _;
window.moment = moment;
window.AppActions = AppActions;
}
let App = React.createFactory(AppComponent);
let json = 'application/json; charset=utf-8';
$.ajaxSetup({
contentType: json,
accepts: {
json: 'application/json'
},
dataType: 'json',
processData: false,
beforeSend (req, options) {
// This ensures that requests using JSON stringify their content before sending
if (options.contentType === json && options.data && typeof options.data !== 'string') {
options.data = JSON.stringify(options.data);
}
}
});
if (!Array.prototype.find) {
Array.prototype.find = function(predicate) {
if (this == null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;
for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value;
}
}
return undefined;
};
}
React.render(App({user}), $('#react-mount')[0]);