blob: 18ec74d79e5c010f6662afaa5d56f1d4f44bdd3d (
plain)
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
|
<!doctype html>
<html>
<head>
<style>
/* 402 is the project code name used in the content loaded by this page.
* We need to override their focus behavior to improve keyboard focus
* accessibility.
*/
.t402-prompt-websat .t402-prompt-root .t402-button:focus {
outline-style: auto;
}
.t402-css-theme-hats-material1 .t402-titlebar-title-alt:focus {
outline-style: auto;
}
:focus {
/* Needs to override dynamically loaded, more specific styles. */
outline-color: rgb(77, 144, 254) !important;
}
</style>
<script>
/**
* Close the window when the survey is submitted or when the survey
* has already been submitted in the past. It is called through HaTS
* javascript library's accessGrantedCallback function.
* @param {boolean} isFirstRun Will be true when the user just earned
* access to the content and false if the user had already had access
* previously.
*/
function didFinishSurvey(isFirstRun) {
if (!isFirstRun) {
return;
}
// HaTS 1 library will post the answer through a form to an iframe.
// Once the iframe is loaded, it will be disposed. We can not listen to
// the iframe's load event since the previous listener will dispose the
// iframe so our listener will not be notified. Instead, we listen to
// the iframe's disposal to make sure the iframe is already loaded,
// which means the answer has been posted to the server.
// TODO(weili): Once this issue is fixed in HaTS library
// (https://b.corp.google.com/issues/143494318), remove the following
// work around.
const element = document.querySelector(`iframe[id^='closure_frame']`);
if (element === null) {
// No iframe found.
window.close();
}
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
for (let i = 0; i < mutation.removedNodes.length; i++) {
if (element === mutation.removedNodes[i]) {
window.close();
}
}
})
});
// Watch for the iframe disposal event.
observer.observe(element.parentNode, {childList: true});
}
/**
* Called after the survey HTML is injected into the page.
* It is called through HaTS javascript library's afterShowCallback
* function.
*/
function onSurveyShown() {
// Don't show logo on the survey.
const elements = document.getElementsByClassName('t402-prompt-logo');
for (const element of elements)
element.style.display = 'none';
}
</script>
<script src="$i18n{scriptSrc}"></script>
</head>
<body>
</body>
</html>
|