-
Notifications
You must be signed in to change notification settings - Fork 0
/
decision.html
127 lines (116 loc) · 4.76 KB
/
decision.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Storm</title>
<link rel="stylesheet" href="stylesheets/styles.css">
<link rel="stylesheet" href="stylesheets/github-dark.css">
<link rel="stylesheet" href="stylesheets/custom.css">
<script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="javascripts/main.js"></script>
<script src="javascripts/util.js"></script>
<script src="javascripts/clock.js"></script>
<script src="javascripts/transcript.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
</head>
<body>
<div class="container">
<div id="topbar">
<span id="goal"></span>
</div>
<div id="sidebar">
<div id="clock">--:--</div>
<div id="definition" class="stage">1) Definition</div>
<div id="ideation" class="stage">2) Ideation</div>
<div id="discussion" class="stage">3) Discussion</div>
<div id="election" class="stage">4) Election</div>
<div id="decision" class="stage active">5) Decision</div>
<div class="criteria-list">
Criteria
<ol>
<li id="criteria1">one</li>
<li id="criteria2">two</li>
<li id="criteria3">three</li>
</ol>
</div>
</div>
<div id="main">
<div id="predecision" class="centered">
Collecting votes from your group...
</div>
<div id="decision-box">
<div id="decision-title"></div>
<div id="decision-description" class="centered"></div>
</div>
<div class="bottom-right">
<a id="download" download="transcript.txt" href="transcript.html" class="big-button button"><span>Download Transcript</span></a>
<br><br><br><br><br>
<a id="survey-button" href="survey.html" class="big-button button"><span>Feedback Survey</span></a>
</div>
<script>
$("#download").hide();
$("#decision-box").hide();
$("#survey-button").hide();
var key = getFirebaseKey();
var ref = new Firebase(getSessionUrl(key));
ref.once("value", function(snapshot) {
var session = snapshot.val();
initDecisionClock(session.date, session.time, session.duration);
$("#goal").html(session.goal);
$("#criteria1").html(session.criteria1);
$("#criteria2").html(session.criteria2);
$("#criteria3").html(session.criteria3);
}, function (errorObject) {
console.log("The read failed: " + errorObject.code);
});
function displayDecision() {
var key = getFirebaseKey();
var ref = new Firebase(getSessionUrl(key));
ref.once("value", function(snapshot) {
var session = snapshot.val();
var ideas = session.ideas;
var winningIdea = selectWinningIdea(ideas);
$("#predecision").html("The winner is");
$("#decision-box").show();
$("#decision-title").html(winningIdea.title);
$("#decision-description").html(winningIdea.description);
var download = $("#download");
var transcript = generateTranscript(session, winningIdea);
download.attr("href", makeTextFile(transcript));
download.show();
var survey = $("#survey-button");
survey.attr("href", "survey.html?session="+key);
survey.show();
}, function (errorObject) {
console.log("The read failed: " + errorObject.code);
});
}
/* Given the list of ideas, return the idea with the most votes */
function selectWinningIdea(ideas) {
var currWinner = ideas[0];
for (i = 0; i < ideas.length; i++) {
if (ideas[i] && ideas[i].votes > currWinner.votes || currWinner.votes == null) {
currWinner = ideas[i];
}
}
return currWinner;
}
/* Creates a txt file transcript of the brainstorm session and
* returns a URL to download the file. */
function makeTextFile(text) {
var data = new Blob([text], {type: 'text/plain'});
return window.URL.createObjectURL(data);
};
</script>
</div>
</div>
<div class="wrapper">
</div>
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
</body>
</html>