-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathExample1.js
More file actions
32 lines (29 loc) · 768 Bytes
/
Example1.js
File metadata and controls
32 lines (29 loc) · 768 Bytes
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
var vote_change = function (old_vote, new_vote) {
var weight = get_weight();
// if (new_vote !== old_vote) {
// if (new_vote === 'Up') {
// weight += (old_vote === 'Up' ? 2 : 1);
// } else if (new_vote === 'Down') {
// weight -= (old_vote === 'Up' ? 2 : 1);
// } else if (new_vote === '') {
// weight += (old_vote === 'Up' ? -1 : 1);
// }
// set_weight(weight);
// }
weight -= get_vote_value(old_vote);
weight += get_vote_value(new_vote);
set_weight(weight);
};
function get_vote_value(vote) {
if(vote === 'Up'){
return +1;
}
if(vote === 'Down'){
return -1;
}
return 0;
}
function get_weight() {
}
function set_weight(weight) {
}