-
Notifications
You must be signed in to change notification settings - Fork 45
/
proxy_config.html
42 lines (38 loc) · 1.24 KB
/
proxy_config.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
<!DOCTYPE html>
<!--
Copied directly from:
http://clay.pebble.com.s3-website-us-west-2.amazonaws.com/
See https://github.com/pebble/clay/blob/4a6382/index.js#L152-L182
and app.js to understand its purpose.
//-->
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Config Page Emulator</title>
</head>
<script>
function getQueryParam(variable, defaultValue) {
var query = location.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (pair[0] === variable) {
return decodeURIComponent(pair[1]);
}
}
return defaultValue || null;
}
var returnTo = getQueryParam('return_to');
var data = decodeURIComponent(location.hash.substring(1));
// Check if we dealing with a base64 encoded URI
if (data && data.charAt(0) !== '<') {
data = window.atob(data).replace('$$RETURN_TO$$', returnTo);
window.location.href = 'data:text/html;base64,' + encodeURIComponent(window.btoa(data));
} else if (data) {
data = data.replace('$$RETURN_TO$$', returnTo);
window.location.href = 'data:text/html;charset=utf-8,' + encodeURIComponent(data);
}
</script>
<body>
</body>
</html>