-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
101 lines (91 loc) · 2.56 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!doctype html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<title>gs to http</title>
<style>
.main {
max-width: 1200px;
margin: auto;
}
#gs, input.submit {
padding: 10px 20px;
font-size: 1.6em;
border: 1px solid black;
border-radius: 4px;
}
#gs {
margin-top: 20px;
margin-bottom: 10px;
font-family: monaco, monospace;
min-width: 300px;
}
#result {
font-size: 1.2em;
padding-left: 2px;
}
input.submit {
margin-left: 10px;
padding-top: 11px;
background-color: #2ECC40;
}
input.submit:hover {
background-color: #2FCF45;
}
input.submit:active {
position: relative;
top: 1px;
padding-bottom: 9px;
}
@media (min-width: 420px) { #gs { min-width: 400px; } }
@media (min-width: 768px) {
#gs {
margin-top: 40px;
margin-bottom: 20px;
min-width: 640px;
}
}
@media (min-width: 1200px) { #gs { min-width: 900px; } }
</style>
</head>
<body>
<div class="main">
<h1><code>gs://</code> to <code>https://</code></h1>
<form action="#" id="form">
<input type="url" name="gs" id="gs" placeholder="gs://..." autocomplete="off" autofocus />
<input type="submit" value="Go" class="submit" />
</form>
<pre><a id="result" href="#"></a></pre>
</div>
<script>
(function() {
var gsInput = document.getElementById("gs"),
result = document.getElementById("result"),
gsProtocol_re = /^gs:\/\//;
function gs2https_directory(gs) {
return gs.replace(gsProtocol_re, "https://console.cloud.google.com/storage/browser/");
}
function gs2https_file(gs) {
return gs.replace(gsProtocol_re, "https://storage.cloud.google.com/");
}
function gs2https(value) {
if (value[value.length-1] == "/") {
return gs2https_directory(value);
}
if (/\.[a-z]{2,}(?:-\d+-of-\d+)?$/.test(value)) {
return gs2https_file(value);
}
// default
return gs2https_directory(value);
}
function run_gs2https(e) {
var gs = gs2https(gsInput.value) || "";
e.preventDefault();
result.setAttribute("href", gs);
result.textContent = gs;
}
document.getElementById("form").onsubmit = run_gs2https;
})();
</script>
</body>
</html>