-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSotM_9-Everyone_has_an_opinion.js
46 lines (38 loc) · 1.29 KB
/
SotM_9-Everyone_has_an_opinion.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
/*
* Ask users to vote on important things like staying in the EU
*
* Read more at https://www.selectec.com/script-of-the-month-9-everyone-has-an-opinion/
*/
function printJobHook(inputs,actions) {
// Prompt Title
var TITLE = "Referendum on the United Kingdom's membership of the European Union";
// What question are we going to ask?
var QUESTION = "Should the United Kingdom remain a member of the European Union or leave the European Union?";
// Array of possible choices
var CHOICES = ["Remain", "Leave", "Undecided"];
// Dictionary containing Prompt options
var OPTIONS = {
'defaultChoice' : 'Undecided',
'hideJobDetails' : true,
'dialogDesc' : QUESTION,
'dialogTitle' : TITLE
}
// Analysis has not completed return
if (!inputs.job.isAnalysisComplete) {
return;
}
// Show the prommpt and set the response to vote
var vote = actions.client.promptForChoice('', CHOICES, OPTIONS);
// We are not bothered by Timeouts or those who don't want to vote
if (vote == "TIMEOUT" || vote == "CANCEL") {
return;
}
// Loop choices
for (i = 0; i < CHOICES.length; i++) {
// If vote = choice
if (vote == CHOICES[i]) {
// increase vote.[users-choice] by 1
actions.utils.onCompletionIncrementNumberProperty('vote.' + vote, 1);
}
}
}