-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.template.html
412 lines (345 loc) · 9.52 KB
/
index.template.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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rust Cheatsheet</title>
<link rel="stylesheet" type="text/css" href="rustdoc.css">
<link rel="stylesheet" type="text/css" href="main.css">
<style type="text/css">
body {
}
.hide {
display: none;
}
.clear_right {
clear: right;
}
span.out-of-band {
display: none;
}
section {
font-family: Arial, Helvetica, Sans;
font-size: 1em;
border: 1px solid black;
//border-collapse: collapse;
//display: table;
width: 20%;
box-shadow: inset 0px 0px 4px #666;
padding: 0 0 2px 0;
float: left;
}
section h6 {
padding: 0px;
margin: 4px 0px 0px;
color: rgb(187, 51, 51);
text-align: center;
text-decoration: underline;
}
section > header {
font-family: "Nimbus Sans L";
font-weight: bold;
text-align: center;
border-bottom: 1px solid black;
padding: 3px;
font-size: 0.8em;
}
section > div {
padding: 0px 8px ;
clear: right;
}
section > div.rarelyused {
display: none;
background-color: rgba(0, 0, 0, 0.08) !important;
}
section > div.rarelyused:nth-child(even) {
background-color: rgba(0, 0, 0, 0.10) !important;
}
section > div:nth-child(even) {
background-color: rgba(0, 0, 0, 0.02);
}
section > div code {
white-space: pre;
font-size: 0.7em;
font-family: "Nimbus Sans L";
font-weight: bold;
line-height: 0.4em;
}
section > div code a {
white-space: normal;
}
a {
cursor: pointer;
}
a:hover {
text-decoration: underline;
}
section > div span {
color: #ae3a3c;
}
section > div details {
display: block;
//line-height: 0.4em;
float: right;
padding-top: 0.4em;
font-size: 0.7em;
color: #555;
text-align: right;
}
section > hr {
margin: 0px 0px -2px 0px;
border: 0;
height: 0;
border-top: 1px solid rgba(0, 0, 0, 0.3);
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
clear: right;
}
section p {
padding: 3px 10px;
margin: 0;
font-size: 0.7em;
}
section a {
color: black;
}
/* COLORS */
section.red header {
background-image: linear-gradient(to right bottom, #E07F7F 0%, #FFAB7A 51%);
}
section.red {
background-color: #f7dcdc;
}
section.green header {
background-image: linear-gradient(to right bottom, #62C958 0%, #BFF2E9 100%);
}
section.green {
background-color: #e3ede1;
}
div.unstable code {
color: #999;
}
div.outerdoc {
display: none;
}
div#overlay {
display: none;
position: fixed;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
background-color: rgba(0,0,0,0.5);
}
div#overlayclose {
position: fixed;
top: 30px;
left: 50%;
margin-left: 413px;
margin-top: 20px;
font-size: 20px;
z-index: 20; /* keep on top of other elements on the page */
}
div#overlaycontent {
position: fixed;
top: 30px;
left: 50%;
width: 900px;
/* line-height: 200px; */
height: 80%;
overflow-y: auto;
margin-left: -450px;
padding: 20px;
background-color: #f3f3f3;
border: 1px solid gray;
border-radius: 4px;
/* needed styles for the overlay */
z-index: 10; /* keep on top of other elements on the page */
}
div.impl-items {
margin-left: 20px;
}
div.since {
float: right;
}
pre.rust {
background-color: #E0E0E0;
}
div#overlaycontent {
display: block !important;
}
div#hiddendocs {
display: none;
}
div#search {
position: fixed;
top:0;
left:0;
right: 0;
height: 20;
}
div#search input {
margin: 2px;
padding: 2px;
}
body {
margin-top: 25px;
}
</style>
</head>
<body>
<div id="search">
<input type="text" name="filter" placeholder="Click or press 's' or Ctrl+P to filter, 'Escape' to reset.">
</div>
<section id="vec" class="red filterable">
<header><a data-doc="vec.vec">Variable sized arrays / Vectors</a></header>
{VEC}
</section>
<section id="vec" class="green filterable">
<header><a data-doc="hm.hm">Hashmaps / Dicts</a></header>
{HASHMAP}
</section>
<section id="vec" class="red filterable">
<header><a data-doc="option.option">Option</a></header>
{OPTION}
</section>
<section id="vec" class="green filterable">
<header><a data-doc="result.result">Result</a></header>
{RESULT}
</section>
<section class="next_row">
<header>Rust Cheatsheet</header>
<p>Contribute at <a href="http://github.com/phaiax/rust-cheatsheet">github.com/phaiax/rust-cheatsheet</a></p>
<div><a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" /></a>
<details>This work is licensed under a<br> <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-<br>ShareAlike 4.0 International License</a>.</details>
</div>
<div class="clear_right"></div>
</section>
<div id="hiddendocs">
{{DOC}}
</div>
<div id="overlay">
<div id="overlayclose">X</div>
<div id="overlaycontent"></div>
</div>
<script src="jquery-2.2.3.min.js"></script>
<script src="fuse.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("a[data-doc]").each(function() {
var a = $(this);
a.click(function() {
var doc_id = a.attr("data-doc").replace('.', '\\.');
var doc = $('div.outerdoc#' + doc_id);
var overlay = $("#overlay");
$("#overlaycontent").html(doc.html());
overlay.show();
});
});
// $("div.docblock").each(function() {
// var docblock = $(this);
// $(this).prev().click(function() {
// var overlay = $("#overlay");
// $("#overlaycontent").html(docblock.html());
// overlay.show();
// });
// $(this).prev().css("cursor", "pointer");
// });
$("#overlayclose").click(function() {
$("#overlay").hide();
});
$("#overlay").click(function() {
$("#overlay").hide();
});
$("#overlaycontent").click(function(event) {
event.stopPropagation();
});
$("#overlaycontent").addClass("docblock");
document.rarelyused_are_hidden = true;
$(document).keypress(function(event) {
if (event.key == "Escape") {
if (!$("#overlay").is(":hidden")) {
$("#overlay").hide();
} else if ($("div#search input").val().length != 0) {
$("div#search input").val("");
filter("");
}
} else if (event.key == "s" || (event.key == "p" && event.ctrlKey)) {
if ($("div#search input").is(":focus")) {
return;
}
event.preventDefault();
$("div#search input").val("");
$("div#search input").focus();
} else if (event.key == "h" || (event.key == "h" && event.ctrlKey)) {
if ($("div#search input").is(":focus")) {
return;
}
event.preventDefault();
if (document.rarelyused_are_hidden) {
$("section > div.rarelyused").slideDown();
document.rarelyused_are_hidden = false;
} else {
$("section > div.rarelyused").slideUp();
document.rarelyused_are_hidden = true;
}
}
});
function prepare() {
var texts = [];
$("section.filterable > div").each(function() {
var line = this;
texts.push( {"text" : line.innerText,
"dom" : line,
"tags" : $(line).attr("data-tags"),
"visible" : 0 } );
});
document.texts = texts;
return texts;
}
function make_fuse(index) {
var options = {
caseSensitive: false,
shouldSort: false,
tokenize: false,
threshold: 0.2,
location: 0,
distance: 10000,
maxPatternLength: 32,
keys: [
"text",
"tags"
]
};
return new Fuse(index, options); // "list" is the item array
}
var visible = 0;
var index = prepare();
var fuse = make_fuse(index);
function filter(str) {
visible++;
document.rarelyused_are_hidden = false;
if (str.length == 0) {
index.forEach(function(f) {
f.visible = visible;
});
} else {
var result = fuse.search(str);
document.r = result;
result.forEach(function(f) {
f.visible = visible;
});
}
index.forEach(function(f) {
if (f.visible == visible) {
$(f.dom).show();
} else {
$(f.dom).hide();
}
});
}
$("div#search input").keyup(function () {
filter($("div#search input").val());
});
});
</script>
</body>
</html>