-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJavascript.html
49 lines (39 loc) · 1.25 KB
/
Javascript.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
<script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.15.0/cdn/shoelace-autoloader.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
initialize();
});
function initialize(){
showAlert( data.msg );
if(data.status === 200){
document.getElementById("book-name").innerHTML= data.bookName;
google.script.run.withSuccessHandler(loadReceipt)
.withFailureHandler(showAlert)
.getReceipt();
} else {
showProgressBar(false)
return
}
};
// Open the receipt.pdf
function loadReceipt(encoded){
showProgressBar(false)
let pdfWindow = window.open("")
pdfWindow.document.write("<iframe width='100%' height='100%' src='data:application/pdf;base64, " + encodeURI(encoded.document) + "'></iframe>")
}
// Progressbar handling
function showProgressBar(handle) {
const pb = document.getElementById('progresssBar');
pb.indeterminate = handle;
}
function showAlert(msg){
const alert = document.getElementById("alert");
if(msg){const message = document.getElementById("alert_msg").innerHTML= msg;
alert.open = true;
setTimeout(function() {
if(message){message.innerHTML=""};
alert.open =false;
}, 11000);
}
}
</script>