-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmeeting.js
53 lines (50 loc) · 1.31 KB
/
meeting.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
47
48
49
50
51
52
53
var MAX_COST = 2000;
var MAX_ATTENDEES = 100;
var Cost = new (function() {
var $current,
cost = 0,
attendees = 0,
incrementTime = 70,
currentTime = 0,
init = function() {
$current = $('#current');
Cost.Timer = $.timer(updateTimer, incrementTime, false);
},
updateTimer = function() {
$current.html(formatCost(currentTime).toFixed(2));
currentTime += incrementTime / 10;
},
formatCost = function(time) {
return attendees * cost / 60 / 60 * time / 100;
};
this.setCost = function(c) {
cost = c;
};
this.setAttendees = function(a) {
attendees = a;
};
$(init);
});
$(document).ready(function() {
new Dragdealer("cost-slider", {
x: queryValue("cost", MAX_COST, 0.1),
animationCallback: function(x, y) {
var val = Math.round(x * MAX_COST);
$("#cost-slider .value").text(val);
Cost.setCost(val);
}
});
new Dragdealer("attendees-slider", {
x: queryValue("attendees", MAX_ATTENDEES, 0.1),
animationCallback: function(x, y) {
var val = Math.round(x * MAX_ATTENDEES);
$("#attendees-slider .value").text(val);
Cost.setAttendees(val);
}
});
$("#current").fitText(0.5);
});
var queryValue = function(param, max, fallback) {
var v = $.url().param(param);
return (v && parseInt(v) == v && v <= max) ? v/max : fallback;
}