-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcb_ui.html
123 lines (107 loc) · 4.15 KB
/
cb_ui.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
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
html *{
font-size: 2.1vh !important;
/* font-size: 2.3vh; */
/* color: #000 !important; */
font-family: Lucida Console !important;
}
table, th, td{
font-size: 1.5vh !important;
border: 1px solid black;
}
table {
table-layout: fixed;
width: 100%;
/* height: 40vh; */
border-collapse: collapse;
}
#full_wrapper{
position: fixed;
width: 95%;
}
#cmd_history{
height: 25vh;
overflow-y: scroll;
}
</style>
</head>
<body>
<div id="full_wrapper">
<form id="chatbot">
<span class="block form-group">
<span> <label for="pf">PF</label> </span>
<input type="text" size="1" maxlength="1" name="pf" id="pf" required="required">
</span>
<span class="block form-group">
<span> <label for="rm">RM</label> </span>
<input type="text" size="1" maxlength="1" name="rm" id="rm" required="required">
</span>
<span class="block form-group">
<span> <label for="st">ST</label> </span>
<input type="text" size="1" maxlength="1" name="st" id="st" required="required">
</span>
<div id="status" name="status" >
<br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
</div>
<div id="cmd_history" name="cmd_history">
<br><br><br><br><br><br><br><br><br><br><br>
</div>
<span class="block form-group">
<span> <label for="cmd" id="cmd_descriptor">...</label> <span>
<input type="text" size="7" name="cmd" id="cmd">
</span>
<span class="block">
<button type="submit" class="action" id="submit">[>]</button>
</span>
<div id="condition" name="condition" style="font-size:10px;text-align:right;">[-----------]</div>
<hr>
<div id="tooltip" name="tooltip" style="font-size:13px;">Select PF/RM/ST</div>
</form>
</div>
<script>
function populate_descriptor(id) {
document.getElementById('cmd_descriptor').innerHTML = `${id.slice(0,10)}>>`;
}
google.script.run.withSuccessHandler(populate_descriptor).user_get_id();
//run [getUserID()], if succeeded, run populate_descriptor with the return value as input.
function write(items) {
document.getElementById('status' ).innerHTML = items[0];
document.getElementById('cmd_history' ).innerHTML = items[1];
document.getElementById('tooltip' ).innerHTML = items[2];
// document.getElementById('button').value = 'submit';
document.getElementById("cmd_history").scrollTop = document.getElementById("cmd_history").scrollHeight;
// window.scrollTo(0,document.body.scrollHeight);
document.getElementById('condition').innerHTML = '<span style="color:green;">[----standby]</span>';
document.getElementById('submit').innerHTML = '[>]';
document.getElementById('submit').disabled = false;
}
function fail(err){
document.getElementById('condition').innerHTML = '<span style="color:red;">[-----failed]</span>';
document.getElementById('submit').innerHTML = '[>]';
document.getElementById('submit').disabled = false;
// google.script.run.get_ui().alert(err);
}
document.querySelector("#chatbot").addEventListener("submit",
function(event){
event.preventDefault();
document.getElementById('submit').disabled = true;
document.getElementById('condition').innerHTML = '<span style="color:blue;">[-processing]</span>';
document.getElementById('submit').innerHTML = '...';
google.script.run.withSuccessHandler(write).withFailureHandler(fail).onSubmit(this);
document.getElementById('cmd').value = ''; // clear cmd input block
}
);
// document.getElementById("cmd").addEventListener("keyup",
// function(event) {
// // if enter is pressed, press the "submit" button.
// if (event.keyCode === 13) {document.getElementById("submit").click();}
// }
// );
</script>
<body>
</html>