-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
180 lines (167 loc) · 5.67 KB
/
index.html
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!doctype html>
<html>
<head>
<title>CodeDojo</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.96.1/css/materialize.min.css">
</head>
<body>
<div id="mountNode"></div>
<script type="text/javascript" src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script>
<script>
var socket = io();
socket.on('round', function(participants){
var event = new CustomEvent('onRound', {'detail': participants});
window.dispatchEvent(event);
console.log(participants);
});
</script>
<script type="text/jsx">
var Card = React.createClass({
render: function () {
return (
<div className="col s12">
<div className={'card blue-grey darken-1 ' + this.props.size} >
<img src={this.props.image} width="200px" />
<div className="card-content white-text">
<span className="card-title">{this.props.username}</span>
<p>
{this.props.title}
</p>
</div>
<div className="card-content">
<p>
</p>
</div>
<div className="card-action">
<a href="#">GitHub</a>
</div>
</div>
</div>
);
}
});
var teste;
var getData = function(dataUrl){
teste = dataUrl;
}
var DojoPilot = React.createClass({
getInitialState: function () {
return {
username: '',
img: ''
};
},
componentDidMount: function() {
var _this = this;
window.addEventListener('onRound', function(e) {
_this.setState({ username: e.detail.pilot.username, image: e.detail.pilot.img});
});
},
render: function () {
return (
<Card title="Pilot" size="large" username={this.state.username} image={this.state.image}/>
);
}
});
var DojoCoPilot = React.createClass({
getInitialState: function () {
return {
username: '',
img: ''
};
},
componentDidMount: function() {
var _this = this;
window.addEventListener('onRound', function(e) {
_this.setState({ username: e.detail.coPilot.username, image: e.detail.coPilot.img });
});
},
render: function () {
return (
<Card title="Co-Pilot" username={this.state.username} image={this.state.image}/>
);
}
});
var DojoGetReady = React.createClass({
getInitialState: function () {
return {
username: '',
img: ''
};
},
componentDidMount: function() {
var _this = this;
window.addEventListener('onRound', function(e) {
_this.setState({ username: e.detail.getReady.username, image: e.detail.getReady.img});
});
},
render: function () {
return (
<Card title="Get Ready" username={this.state.username} image={this.state.image}/>
);
}
});
var DojoCountDown = React.createClass({
getInitialState: function() {
return {
startTime: Date.now(),
remaining: this.props.time
};
},
tick: function() {
this.setState({
remaining: this.props.time - (~~((Date.now() - this.state.startTime)/1000))
});
},
componentDidMount: function() {
var _this = this;
window.addEventListener('onRound', function(e) {
_this.setState({startTime: Date.now()});
});
this.tick();
this.interval = setInterval(this.tick, 1000);
},
componentWillUnmount: function() {
clearInterval(this.interval);
},
render: function() {
return (
<div className="row blue-grey-text darken-3 ">
<div className="col s6 right-align ">
<i className="large mdi-action-alarm"></i>
</div>
<div className="col s6 left-align">
<h1 className="">{this.state.remaining}</h1>
</div>
</div>
);
}
});
var Dojo = React.createClass({
componentDidMount: function() {
socket.emit('update');
},
render: function() {
return (
<section>
<div className="row">
<div className="col s5 offset-s1">
<DojoPilot/>
</div>
<div className="col s3 offset-s1">
<DojoCoPilot/>
<DojoGetReady/>
</div>
</div>
<DojoCountDown time={this.props.time}/>
</section>
);
}
});
var mountNode = document.getElementById('mountNode');
React.render(<Dojo time="15"/>, mountNode);
</script>
</body>
</html>