-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.php
97 lines (87 loc) · 3.57 KB
/
index.php
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
<?php
//setup autoloading
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
$config = include 'config.php';
//setup cloudmine
require_once 'lib/cloudmine/CloudMine.php';
$cloudmine = new CloudMine($config['cloudmine']['user'], $config['cloudmine']['pass']);
//get data
$data = $cloudmine->get('a2sw');
//render 'n stuff
?>
<html>
<head>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css">
<script type="text/javascript" src=" https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="lib/highcharts/highcharts.js" type="text/javascript"></script>
<script type="text/javascript">
var app = {};
$(document).ready(function() {
votes = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column'
},
title: {
text: 'SWAnnArbor Popular Vote'
},
xAxis: {
categories: ['Votes']
},
yAxis: {
title: {
text: 'Votes'
}
},
series: [
<?php $teams = array(); $first = true; foreach($data['a2sw']['votes'] as $id => $votes):?>
<?php if(empty($id)) continue;?>
<?php $teams[] = "$id: " . count($votes);?>
<?php if(!$first)echo ','?>{
id: '<?php echo $id?>',
name: '<?php echo $id?>',
data: [<?php echo count($votes);?>]
}
<?php $first = false; endforeach;?>]
});
//simple app
app = {
teams : {<?php echo implode(',', $teams)?>},
addVote : function(team){
if(!votes.get(team)){
votes.addSeries({animation: true, id: team, name: team});
app.teams[team] = 0;
}
app.teams[team]++;
votes.get(team).setData(app.teams[team]);
}
};
});
</script>
<title>SWAnn Arbor Voting</title>
</head>
<body style="background-color: #333333;">
<div>
<div id="container" style="height:85%; margin: 10px;"></div>
</div>
<div sub-key="<?php echo $config['pubnub']['sub']?>" ssl="off" origin="pubsub.pubnub.com" id="pubnub"></div>
<div style='padding: 20px;'>
<span style='float: right;'>
<img src="http://www.nexmo.com/img/logo_nexmo.png" height='30px' />
<img src="http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/powered-by-pubnub-200.png" height='50px'/>
<img src="https://cloudmine.me/assets/cloudmine_logo-c2f0670f4b46084cd993e61366a7ac63.png" height='50px'/>
</span>
<h1 style='color: #FFFFFF;'>Text Your Vote To: <?php echo $config['nexmo']['number']?></h1>
</div>
<script src="http://cdn.pubnub.com/pubnub-3.1.min.js"></script>
<script>(function(){
PUBNUB.subscribe({
channel : "a2sw", // CONNECT TO THIS CHANNEL.
callback : function(message) { // RECEIVED A MESSAGE.
app.addVote(message);
}
})
})();</script>
</body>
</html>