-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
278 lines (251 loc) · 7.51 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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="favicon.svg">
<title>Random YC</title>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-FHSM67JBMW"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
function initGtag(){
gtag('js', new Date());
gtag('config', 'G-FHSM67JBMW');
}
</script>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
.header {
background-color: #fafafa;
color: #333333;
font-family: sans-serif;
padding: 20px;
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
z-index: 100;
}
.headerContainer {
display: flex;
justify-content: space-between;
align-items: center;
max-width: 960px;
margin: 0 auto;
}
.bodyContainer {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
}
#companyDescription {
padding-left: 8px;
display: -webkit-box; /* Required for Safari */
display: -moz-box; /* Required for Firefox */
display: box;
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
box-orient: vertical;
-webkit-line-clamp: 4; /* Truncates text after 3 lines */
-moz-line-clamp: 4;
line-clamp: 4;
overflow: hidden; /* Hides any overflowing text */
text-overflow: ellipsis; /* Adds an ellipsis (...) to indicate truncated text */
}
.logo {
font-weight: bold;
font-size: 24px;
text-decoration: none;
color: #fff;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
text-align: right;
text-justify: auto;
}
nav ul li {
margin: 0 10px;
}
nav ul li a {
text-decoration: none;
color: rgb(38 139 210);
display: flex;
}
nav ul li div {
padding-right: 4px;
}
nav ul li a:hover {
text-decoration: underline;
}
.verticalDivider {
height: 24px;
border-left: 1px solid #ccc;
margin: 0 8px;
}
.horizontalDivider {
width: 50%;
border-top: 1px solid #ccc;
margin: 16px 0;
}
#nextURL {
margin-top: 8px;
display: flex;
justify-content: flex-end;
text-align: center;
align-items: center;
}
#companyURL {
display: flex;
justify-content: flex-end;
text-align: center;
align-items: center;
}
</style>
<script>
const NO_IFRAME_SUPPORT = new Set([
0, 2, 6, 13, 15, 23, 24, 28, 37, 41, 52, 67, 78, 80, 83, 96, 111,
125, 131, 132, 136, 140, 141, 142, 145, 147, 150, 153, 165, 177,
187, 199, 207, 212, 213, 217, 220, 228, 229, 234, 248, 257, 260,
261,
]);
const MISSING_LOGO = new Set([
18, 60, 75, 241
])
const FOUR_NIL_FOUR = new Set([98, 195]);
const queryParams = new URLSearchParams(window.location.search);
function getChosenCompany() {
const companyId = parseInt(queryParams.get("cid"), 10);
return companyId;
}
if (queryParams.get('debug') != null) {
document.addEventListener('keypress', function(e) {
if (e.code === 'Space') {
const cid = parseInt(queryParams.get('cid')) || 0;
queryParams.set('cid', cid + 1);
const url = new URL(window.location.href);
url.search = queryParams.toString();
window.location.href = url.toString();
}
});
}
// Load /yc-w23-clear.json
fetch('./yc-w23-clear.json', { cache: "force-cache" })
.then(response => response.json())
.then(data => {
const keys = Object.keys(data.companyURL);
const companyId = getChosenCompany();
let key = isNaN(companyId) ?
keys[Math.floor(Math.random() * keys.length)] : companyId;
let keyInt = parseInt(key, 10);
while (
NO_IFRAME_SUPPORT.has(keyInt) ||
FOUR_NIL_FOUR.has(keyInt) ||
MISSING_LOGO.has(keyInt))
{
key = keys[Math.floor(Math.random() * keys.length)]
keyInt = parseInt(key, 10);
}
const iframeURL = data.companyURL[key];
const companyLogo = data.logoURL[key];
const iframe = document.querySelector('iframe');
iframe.src = iframeURL;
const logoURL = document.getElementById("logoURL");
logoURL.src = companyLogo;
logoURL.onload = function () {
document.getElementById("logoURL").style = '';
}
const companyDescription = document.getElementById("companyDescription");
companyDescription.innerText = data.description[key];
const companyURL = document.getElementById("companyURL");
companyURL.href = iframeURL;
const companyURLText = document.getElementById("companyURLText");
companyURLText.innerText = data.title[key];
// Makes these elements visible
document.getElementById("companyDescription").style = '';
document.getElementById("companyURLIcon").style = '';
document.getElementById("companyURLText").style = '';
document.title = "Random YC: " + data.title[key];
initGtag();
})
.catch(error => {
console.error(error);
});
</script>
</head>
<body style="margin:0px;padding:0px;overflow:hidden">
<div class="bodyContainer">
<header class="header">
<div class="headerContainer">
<img
style="visibility:hidden"
id="logoURL"
src="#"
width="48"
height="48"
/>
<div
style="visibility:hidden"
id="companyDescription"
>
</div>
<nav>
<ul>
<li>
<a target="_blank" id="companyURL" href="#">
<div
style="visibility:hidden"
id="companyURLText"
>
</div>
<svg
style="visibility:hidden"
id="companyURLIcon"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="2"
stroke="currentColor"
aria-hidden="true"
width="1.25em"
height="1.25em"
class="-mt-px inline-block h-4 w-4 group-hover:underline"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
>
</path>
</svg>
</a>
</li>
<li>
<a id="nextURL" href="/">
<div>Next</div>
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="24" viewBox="0 96 960 960" width="24"><path d="m375 816-43-43 198-198-198-198 43-43 241 241-241 241Z"/></svg>
</a>
</li>
</ul>
</nav>
</div>
</header>
<iframe
id="myIframe"
sandbox="allow-same-origin allow-top-navigation allow-scripts allow-popups allow-forms"
frameborder="0"
style="display:flex;overflow:hidden;width:100%"
height="100%"
>
</iframe>
</div>
</body>
</html>