-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.html
56 lines (55 loc) · 1.94 KB
/
index.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
<html>
<head>
<base target="_top">
<script>
var localEmails={}
google.script.run.withSuccessHandler(onsuccess)
.withFailureHandler(onFailure)
.pullSegment(null);
var lastPageToken;
function onsuccess(data){
// Kick off the next page if needed
if(data.nextPageToken){
lastPageToken=data.nextPageToken;
google.script.run.withSuccessHandler(onsuccess)
.pullSegment(data.nextPageToken)
}
// Merge local emails with newly retrieved emails
for(const email in data.emails){
localEmails[email]=1
}
var div = document.getElementById('output');
// Check for empty final list:
if(Object.keys(localEmails).length==0 && data.nextPageToken==null){
div.innerHTML='Search complete: No users found.'
} else {
// Format current list for copy paste
finalOutput='<table><tbody>'
for(key in localEmails){
finalOutput=finalOutput+'<tr><td>'+key+'</td></tr>'
}
finalOutput=finalOutput+'</tbody></table>'
// Indicate if still working
if(data.nextPageToken){
finalOutput=finalOutput+'... (Still working)'
}
// Update the UI
div.innerHTML = finalOutput;
}
}
function onFailure(error){
var debug=document.getElementById('debug');
debug.innerHTML=`The script encountered an error. Please try again later.
Debug info:
${JSON.stringify(error)}`
}
</script>
</head>
<body>
<h1>Backup and Sync User Identification</h1>
<div>This script identifies users who have used Backup and Sync within your domain in the last 180 days.</div>
<div>Emails of the users will appear below. Please note, this script may take a while to complete.</div><br>
<div id="output">Loading...</div>
<div id="debug"></div>
</body>
</html>