This repository was archived by the owner on Aug 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSelectorJavaScript.html
More file actions
62 lines (57 loc) · 2.21 KB
/
SelectorJavaScript.html
File metadata and controls
62 lines (57 loc) · 2.21 KB
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
<script>
(function() {
var accountHierarchy = {};
var addProperties = function(e) {
var aid = e.value;
var propertySelect = document.querySelector('#properties');
var start = document.querySelector('#start');
var temp;
propertySelect.disabled = true;
propertySelect.innerHTML = '';
start.disabled = true;
accountHierarchy[aid].webProperties.forEach(function(prop) {
temp = document.createElement('option');
temp.value = prop.id;
temp.innerHTML = prop.name;
propertySelect.appendChild(temp);
});
document.querySelector('#fetching').style.display = 'none';
document.querySelector('#accountWrapper').style.display = 'block';
document.querySelector('#propertyWrapper').style.display = 'block';
propertySelect.disabled = false;
start.disabled = false;
};
var addAccounts = function(accountSummary) {
var accountSelect = document.querySelector('#accounts');
var temp;
accountSummary.items.forEach(function(acct) {
temp = document.createElement('option');
temp.value = acct.id;
temp.innerHTML = acct.name;
accountSelect.appendChild(temp);
accountHierarchy[acct.id] = {
webProperties: acct.webProperties
};
});
accountSelect.addEventListener('change', function(e) {
addProperties(e.target);
});
addProperties(accountSelect.options[accountSelect.selectedIndex]);
};
google.script.run.withSuccessHandler(addAccounts).fetchAccounts();
document.querySelector('#close').addEventListener('click', function() {
google.script.host.close();
});
document.querySelector('#start').addEventListener('click', function() {
var accounts = document.querySelector('#accounts');
var properties = document.querySelector('#properties');
google.script.run
.withSuccessHandler(function() { google.script.host.close(); })
.startProcess(
accounts.options[accounts.selectedIndex].value,
properties.options[properties.selectedIndex].value,
document.querySelector('[name="howManyMetrics"]:checked').value
);
});
})();
</script>