-
Notifications
You must be signed in to change notification settings - Fork 0
/
perms-js.html
63 lines (55 loc) · 1.57 KB
/
perms-js.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
<script>
<!-- when page loads run the iniitalization code -->
if( document.readyState !== 'loading' ) {
console.log( 'document is already ready, just execute code here' );
myInitCode();
} else {
document.addEventListener('DOMContentLoaded', function () {
console.log( 'document was not ready, place code here' );
myInitCode();
});
}
function myInitCode() {
document.getElementById("btn-close").addEventListener("click",closeIt);
document.getElementById("btn-authorize").addEventListener("click",authorize);
}
//'pick' is a "factory" send the function that you want to run with the args in an array...
function aMessage(){
google.script.run
.withSuccessHandler(onSuccess)
.withFailureHandler(showError)
.pick('callLibrary');
}
function authorize(){
let shortLink1 = "https://bit.ly/2RZsImw";
let w = 500;
let h = 600;
let authWindow = window.open(shortLink1,"Authorize","width=" + w + ",height=" + h +'"');
moveWin(w,h,authWindow);
}
function moveWin(width,heigth,windowName){
let w = width;
let h = heigth;
var top;
var left = (window.screen.width/2)-(w/2);
if(screenY<0){
top = -(window.screen.height/2)-(h/2);
}
else{
top = (window.screen.height/2)-(h/2);
}
console.log(top, screenY);
windowName.moveTo(left, top);
windowName.focus();
}
function onSuccess(theText){
document.getElementById('result').innerHTML = theText;
}
function showError(err){
console.log(err);
document.getElementById('result').innerHTML = "The error is " + err;
}
function closeIt(){
google.script.host.close();
}
</script>