forked from binary-com/binary-static
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbet.js
More file actions
131 lines (119 loc) · 4.48 KB
/
Copy pathbet.js
File metadata and controls
131 lines (119 loc) · 4.48 KB
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
128
129
130
131
var trade_contract_back = function () {
$('#find_another_contract').on('click', function (e) {
if (page.url.history_supported) {
e.preventDefault();
window.history.back();
}
}).addClass('unbind_later');
};
var toggleStreaming = function() {
if (document.hidden || document.webkitHidden) {
BetForm.spot.clear();
BetPrice.streaming.stop();
BetPrice.order_form.hide_buy_button();
} else {
BetPrice.streaming.start();
}
};
pjax_config_page('/trade', function() {
return {
onLoad: function() {
trade_contract_back();
BetForm.init();
BetAnalysis.register_actions();
BetForm.restore();
if (typeof document.webkitHidden !== 'undefined') {
if (document.addEventListener) {
document.addEventListener("webkitvisibilitychange", toggleStreaming, false);
}
} else if (typeof document.hidden !== 'undefined') {
if (document.addEventListener) {
document.addEventListener("visibilitychange", toggleStreaming);
}
}
},
onUnload: function() {
BetForm.unregister_actions();
BetPrice.deregister();
BetPrice.clear_buy_results();
BetPrice.streaming.stop();
BetAnalysis.reset();
if (typeof document.webkitHidden !== 'undefined') {
document.removeEventListener("webkitvisibilitychange", toggleStreaming);
} else if (typeof document.hidden !== 'undefined') {
document.removeEventListener("visibilitychange", toggleStreaming);
}
}
};
});
pjax_config_page('rise_fall_table', function() {
var duration_amount;
var duration_unit;
return {
onLoad: function() {
var trading_time = new BetForm.TradingTime();
var duration = new BetForm.Time.Duration(trading_time);
trading_time.init();
//Perform as if we are pricing R_100 bets.
trading_time.underlying = function() {
return 'R_100';
};
var selected_duration;
//We dont want to read/pollute our betform durations.
trading_time.value = function(value) {
if(value) {
selected_duration = value;
}
if(!selected_duration) {
var duration = page.url.param('duration_amount');
var units = page.url.param('duration_units');
if(typeof duration_amount === 'undefined' || typeof duration_amount === 'undefined') {
var min_unit = this.min_unit();
duration = min_unit.min;
unit = min_unit.units;
}
selected_duration = duration + unit;
}
return selected_duration;
};
duration.init();
duration.register();
duration.update_ui();
$('#atleast').on('change', function () {
duration.update_units_select();
duration.update_ui();
}).addClass('unbind_later');
$('#rise_fall_calculate').on('click', function (event) {
event.preventDefault();
var calculate_button = this;
$(this).hide();
$('#rise_fall_calculating').show();
var form = $('form[name=rise_fall]').get(0);
var url = page.url.url_for('rise_fall_table.cgi', getFormParams(form));
$('#rise_fall_prices_div').html('');
$.ajax({
url: url,
data: {
ajax_only: 1,
prices_only: 1,
},
}).done(function(response) {
$('#rise_fall_prices_div').html(response);
page.url.update(url);
$('#rise_fall_calculating').hide();
$('#rise_fall_calculate').show();
});
}).addClass('unbind_later');
},
};
});
pjax_config_page('portfolio|trade.cgi|statement|f_manager_statement|f_manager_history|f_profit_table', function() {
return {
onLoad: function() {
BetSell.register();
},
onUnload: function() {
BetSell.cleanup();
}
};
});