-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.html
More file actions
150 lines (137 loc) · 3.28 KB
/
template.html
File metadata and controls
150 lines (137 loc) · 3.28 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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<html>
<head>
<title>copher | TITLE</title>
<style>
body {
margin: 0;
font-family: monospace;
}
table {
border-collapse: collapse;
empty-cells: show;
table-layout: fixed;
}
tr {
border: none;
}
td:first-child {
text-align: center;
min-width: 1em;
background: lightgray;
font-weight:bold;
}
td:nth-child(2) {
min-width: 70ch;
}
td {
padding-left: 0.2em;
padding-right: 0.2em;
font-size: x-large;
white-space: pre-wrap;
height: 1em;
vertical-align: top;
}
abbr {
text-decoration: none;
}
a {
text-decoration: none;
}
a._text abbr:after { content: "\1F4C3"; }
a._menu abbr:after { content: "\2630"; }
a._mac-file abbr:after { content: "\1F80B"; }
a._dos-file abbr:after { content: "\1F80B"; }
a._uu-file abbr:after { content: "\1F80B"; }
a._search abbr:after { content: "\1F50D"; }
a._telnet abbr:after { content: "\1F5B3"; }
a._bin abbr:after { content: "\1F80B"; }
a._gif abbr:after { content: "\1F5BC"; }
a._image abbr:after { content: "\1F5BC"; }
a._3270 abbr:after { content: "\1F5B3"; }
a._html abbr:after { content: "\1F310"; }
a._sound abbr:after { content: "\1F50A"; }
a._png abbr:after { content: "\1F5BC"; }
a._pdf abbr:after { content: "\1F80B"; }
a._download abbr:after { content: "\1F80B"; }
a._unknown abbr:after { content: "\1F80B"; }
/* these next ones should never occur, but just in case */
a._mirror abbr:after { content: "+"; }
a._info abbr:after { content: "i"; }
a._error abbr:after { content: "3"; }
a._cso abbr:after { content: "2"; }
a._end abbr:after { content: "."; }
.error:after {
color: red;
content: "3"
}
@media (prefers-color-scheme: dark) {
body {
background: black;
color: lightgrey;
}
td:first-child {
background: #5a5a5a;
}
}
</style>
<script>
{
function cleanUrl(urlString) {
if (!urlString.includes('://')) {
urlString = 'gopher://';
}
if (urlString.startsWith('gophers://')) {
urlString = urlString.replace(/^gophers:\/\//, 'gopher://secure@');
}
let [url0, url1, hostAndPort, ...rest] = urlString.split('/');
let [host, port] = hostAndPort.split(':');
if (port) {
port = Number(port);
if (port / 100000 >= 1) {
port = port % 100000;
if (!host.startsWith('secure@')) {
host = 'secure@' + host;
}
}
}
hostAndPort = port ? `${host}:${port}` : host;
urlString = [url0, url1, hostAndPort, ...rest].join('/');
return urlString;
}
window.search = function search(url) {
const query = prompt('Please enter your search term(s):');
if (query) {
window.location.href = url + "%09" + query;
}
}
window.addEventListener("beforeunload", () => {
document.title = '[Loading ...]';
});
window.addEventListener("keyup", event => {
if (event.code === 'ArrowLeft') {
window.history.back();
}
if (event.code === 'ArrowRight') {
window.history.forward();
}
if (event.code === 'KeyG') {
const url = prompt('Enter a valid Gopher or S/Gopher URL:', document.title.split(' ')[2]);
if (url) {
window.location.href = cleanUrl(url);
}
}
if (event.code === 'KeyR') {
location.reload(true);
}
}, false);
window.copherVersion = 'COPHER_VERSION';
}
USER_JS
</script>
</head>
<body>
<div>
REPLACE_ME
</div>
</body>
</html>