-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVerjaardagenUI.html
128 lines (115 loc) · 3.56 KB
/
VerjaardagenUI.html
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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
<!-- The CSS package above applies Google styling to buttons and other elements. -->
<style>
.branding-below {
bottom: 56px;
top: 0;
}
.branding-text {
left: 7px;
position: relative;
top: 3px;
}
.logo {
vertical-align: middle;
}
</style>
</head>
<body>
<div class="sidebar branding-below">
<form>
<div class="block form-group">
<label for="select">Kies het kwartaal</label>
<select id="kwartaal">
<option selected value=1>1ste kwartaal</option>
<option value=2>2de kwartaal</option>
<option value=3>3de kwartaal</option>
<option value=4>4de kwartaal</option>
</select>
</div>
<div class="block form-group">
<label for="select">Kies het jaar</label>
<select id="jaar">
</select>
</div>
<div class="block" id="button-bar">
<button id="vul-verjaardagenlijst" class="action">Vul verjaardagenlijst</button>
<button id="maak-leeg">Maak leeg</button>
</div>
</form>
</div>
<div class="sidebar bottom">
<img alt="Add-on logo" class="logo" src="https://drive.google.com/thumbnail?id=1Z9Z8oUbgtJNovUoP39_eV4nFJldOOnl4" width="30" height="30"/>
<span class="gray branding-text">Eerste Twelose Toerclub</span>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script>
/**
* On document load, assign click handlers to the button
* Populate the Years with the current & next year
*/
$(function() {
$('#vul-verjaardagenlijst').click(vulVerjaardagenlijst);
$('#maak-leeg').click(maakLeeg);
var thisYear = (new Date()).getFullYear();
var nextYear = thisYear + 1;
$('#jaar').append('<option selected>' + thisYear + '</option>');
$('#jaar').append('<option>' + nextYear + '</option>');
});
/**
* Runs server-side toonVerjaardagenLijst
*/
function vulVerjaardagenlijst() {
console.log("vulverjaardagen")
this.disabled = true;
$('#error').remove();
var kwartaal = $('#kwartaal').val();
if (!(kwartaal >= 1 && kwartaal <= 4)) {
showError("Kies een kwartaal", $('#button-bar'));
} else {
var jaar = $('#jaar').val();
google.script.run
.withSuccessHandler(
function() {
$('#vul-verjaardagenlijst').prop("disabled", false);
})
.withFailureHandler(
function(msg, element) {
showError(msg, $('#button-bar'));
element.disabled = false;
})
.toonVerjaardagenLijst(kwartaal, jaar);
}
}
function maakLeeg() {
this.disabled = true;
$('#error').remove();
google.script.run
.withSuccessHandler(
function() {
$('#maak-leeg').prop("disabled", false);
})
.withFailureHandler(
function(msg, element) {
showError(msg, $('#button-bar'));
element.disabled = false;
})
.maakLijstLeeg();
}
/**
* Inserts a div that contains an error message after a given element.
*
* @param msg The error message to display.
* @param element The element after which to display the error.
*/
function showError(msg, element) {
var div = $('<div id="error" class="error">' + msg + '</div>');
$(element).after(div);
}
</script>
</body>
</html>