-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathjavascript.html
More file actions
76 lines (69 loc) · 1.74 KB
/
javascript.html
File metadata and controls
76 lines (69 loc) · 1.74 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
<script>
function appReady() {
$("#loader").remove();
$("#main-content").removeClass("hidden");
}
function bindAddButton() {
$("#add-to-sheet").click(function() {
type = $("#type").val();
coin = $("#coin-list").val();
currency = $("#currency-list").val();
google.script.run
.withSuccessHandler(
function(supportedCoins) {
console.log("Success!")
})
.withFailureHandler(
function(msg) {
console.error(msg);
})
.insertGeckoScript(type, coin, currency);
});
}
function loadCoins() {
google.script.run
.withSuccessHandler(
function(supportedCoins) {
setupCoinList(supportedCoins);
appReady();
})
.withFailureHandler(
function(msg) {
console.error(msg);
})
.getSupportedCoins();
}
function loadCurrencies() {
var select = $('#currency-list');
var options = select.prop('options');
$('option', select).remove();
getCurrencyList().forEach(function(coin) {
options[options.length] = new Option(coin.name, coin.id);
});
select.selectize({
sortField: 'text',
items: ["usd"]
});
}
function setupCoinList(coins) {
var select = $('#coin-list');
var options = select.prop('options');
$('option', select).remove();
coins.forEach(function(coin) {
options[options.length] = new Option(coin.name, coin.id);
});
select.selectize({
sortField: 'text'
});
}
function setupType() {
var select = $('#type');
select.selectize();
}
window.addEventListener('load', function() {
loadCoins();
loadCurrencies();
setupType();
bindAddButton();
});
</script>