-
Notifications
You must be signed in to change notification settings - Fork 11
/
template.html
60 lines (54 loc) · 1.93 KB
/
template.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
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<title>HTML Templating demo</title>
<style>
body {
margin: 10px;
}
#btn {
text-decoration: underline;
cursor: pointer;
}
#github_img {
height: 300px;
width: 300px;
}
</style>
</head>
<body>
<h1>Applicants</h1>
<form>
<p><em>Select an applicant from the list to see their details</em></p>
<select id="select">
<option disabled selected value> -- select -- </option>
<? var options = getApplicants()
for (var i = 0; i < options.length; i++) { ?>
<option><?= options[i] ?></option>
<? } ?>
</select>
<a id="btn">Display</a>
</form>
<hr>
<p><strong>Name:</strong> <span id ="devName">-</span></p>
<p><strong>GitHub:</strong> <span id="devGithub">-</span></p>
<p><strong>Role:</strong> <span id="devRole">-</span></p>
<p><strong>Favourite programming language:</strong> <span id="devLanguage">-</span></p>
<p><strong>GitHub avatar</strong></p>
<img id="github_img" src="https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png">
<footer><a href="https://github.com/emilyb7/html-templating-with-google-apps-script" target="blank">About this page</a></footer>
<script>
document.querySelector('#btn').addEventListener("click", function () {
var name = document.getElementById("select").value;
var data = google.script.run.withSuccessHandler(function (data) {
document.querySelector("#devName").innerHTML = data.name;
document.querySelector("#devGithub").innerHTML = data.github;
document.querySelector("#devRole").innerHTML = data.role;
document.querySelector("#devLanguage").innerHTML = data.language;
document.querySelector("#github_img").src = data.img;
}).getData(name);
});
</script>
</body>
</html>