superbara 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +4 -0
- data/docs/_FontAwesome/css/font-awesome.css +4 -0
- data/docs/_FontAwesome/fonts/FontAwesome.ttf +0 -0
- data/docs/_FontAwesome/fonts/fontawesome-webfont.eot +0 -0
- data/docs/_FontAwesome/fonts/fontawesome-webfont.svg +640 -0
- data/docs/_FontAwesome/fonts/fontawesome-webfont.ttf +0 -0
- data/docs/_FontAwesome/fonts/fontawesome-webfont.woff +0 -0
- data/docs/_FontAwesome/fonts/fontawesome-webfont.woff2 +0 -0
- data/docs/ayu-highlight.css +71 -0
- data/docs/book.css +1454 -0
- data/docs/book.js +590 -0
- data/docs/clipboard.min.js +7 -0
- data/docs/elasticlunr.min.js +10 -0
- data/docs/favicon.png +0 -0
- data/docs/getting_started/index.html +243 -0
- data/docs/getting_started/shell.png +0 -0
- data/docs/highlight.css +69 -0
- data/docs/highlight.js +2 -0
- data/docs/index.html +221 -0
- data/docs/install.html +227 -0
- data/docs/mark.min.js +7 -0
- data/docs/print.html +336 -0
- data/docs/reference/assert.html +258 -0
- data/docs/reference/dialogs/alert.html +225 -0
- data/docs/reference/dialogs/confirm.html +225 -0
- data/docs/reference/dialogs/index.html +230 -0
- data/docs/reference/dialogs/prompt.html +217 -0
- data/docs/reference/find.html +235 -0
- data/docs/reference/tests/has_text.html +241 -0
- data/docs/reference/tests/index.html +225 -0
- data/docs/reference/wait.html +245 -0
- data/docs/reference.html +225 -0
- data/docs/searcher.js +461 -0
- data/docs/searchindex.js +1 -0
- data/docs/superbara.html +222 -0
- data/docs/tomorrow-night.css +96 -0
- data/docs-src/book.toml +11 -0
- data/docs-src/src/SUMMARY.md +18 -0
- data/docs-src/src/getting_started/index.md +38 -0
- data/docs-src/src/getting_started/shell.png +0 -0
- data/docs-src/src/install.md +5 -0
- data/docs-src/src/reference/assert.md +48 -0
- data/docs-src/src/reference/dialogs/alert.md +1 -0
- data/docs-src/src/reference/dialogs/confirm.md +1 -0
- data/docs-src/src/reference/dialogs/index.md +5 -0
- data/docs-src/src/reference/dialogs/prompt.md +1 -0
- data/docs-src/src/reference/find.md +21 -0
- data/docs-src/src/reference/results.md +53 -0
- data/docs-src/src/reference/tests/has_text.md +24 -0
- data/docs-src/src/reference/tests/index.md +1 -0
- data/docs-src/src/reference/wait.md +33 -0
- data/docs-src/src/reference.md +2 -0
- data/docs-src/src/superbara.md +7 -0
- data/lib/capybara_monkey.rb +10 -5
- data/lib/selenium_monkey.rb +2 -17
- data/lib/superbara/cli.rb +16 -8
- data/lib/superbara/context.rb +5 -6
- data/lib/superbara/dsl.rb +25 -8
- data/lib/superbara/helpers.rb +24 -1
- data/lib/superbara/version.rb +1 -1
- data/lib/superbara.rb +12 -2
- data/superbara.gemspec +1 -0
- data/tests/features/screenshot.rb +30 -0
- metadata +55 -2
data/docs/book.js
ADDED
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
// Fix back button cache problem
|
|
2
|
+
window.onunload = function () { };
|
|
3
|
+
|
|
4
|
+
// Global variable, shared between modules
|
|
5
|
+
function playpen_text(playpen) {
|
|
6
|
+
let code_block = playpen.querySelector("code");
|
|
7
|
+
|
|
8
|
+
if (window.ace && code_block.classList.contains("editable")) {
|
|
9
|
+
let editor = window.ace.edit(code_block);
|
|
10
|
+
return editor.getValue();
|
|
11
|
+
} else {
|
|
12
|
+
return code_block.textContent;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
(function codeSnippets() {
|
|
17
|
+
// Hide Rust code lines prepended with a specific character
|
|
18
|
+
var hiding_character = "#";
|
|
19
|
+
var request = fetch("https://play.rust-lang.org/meta/crates", {
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': "application/json",
|
|
22
|
+
},
|
|
23
|
+
method: 'POST',
|
|
24
|
+
mode: 'cors',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
function handle_crate_list_update(playpen_block, playground_crates) {
|
|
28
|
+
// update the play buttons after receiving the response
|
|
29
|
+
update_play_button(playpen_block, playground_crates);
|
|
30
|
+
|
|
31
|
+
// and install on change listener to dynamically update ACE editors
|
|
32
|
+
if (window.ace) {
|
|
33
|
+
let code_block = playpen_block.querySelector("code");
|
|
34
|
+
if (code_block.classList.contains("editable")) {
|
|
35
|
+
let editor = window.ace.edit(code_block);
|
|
36
|
+
editor.addEventListener("change", function (e) {
|
|
37
|
+
update_play_button(playpen_block, playground_crates);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// updates the visibility of play button based on `no_run` class and
|
|
44
|
+
// used crates vs ones available on http://play.rust-lang.org
|
|
45
|
+
function update_play_button(pre_block, playground_crates) {
|
|
46
|
+
var play_button = pre_block.querySelector(".play-button");
|
|
47
|
+
|
|
48
|
+
// skip if code is `no_run`
|
|
49
|
+
if (pre_block.querySelector('code').classList.contains("no_run")) {
|
|
50
|
+
play_button.classList.add("hidden");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// get list of `extern crate`'s from snippet
|
|
55
|
+
var txt = playpen_text(pre_block);
|
|
56
|
+
var re = /extern\s+crate\s+([a-zA-Z_0-9]+)\s*;/g;
|
|
57
|
+
var snippet_crates = [];
|
|
58
|
+
while (item = re.exec(txt)) {
|
|
59
|
+
snippet_crates.push(item[1]);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// check if all used crates are available on play.rust-lang.org
|
|
63
|
+
var all_available = snippet_crates.every(function (elem) {
|
|
64
|
+
return playground_crates.indexOf(elem) > -1;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (all_available) {
|
|
68
|
+
play_button.classList.remove("hidden");
|
|
69
|
+
} else {
|
|
70
|
+
play_button.classList.add("hidden");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function run_rust_code(code_block) {
|
|
75
|
+
var result_block = code_block.querySelector(".result");
|
|
76
|
+
if (!result_block) {
|
|
77
|
+
result_block = document.createElement('code');
|
|
78
|
+
result_block.className = 'result hljs language-bash';
|
|
79
|
+
|
|
80
|
+
code_block.append(result_block);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let text = playpen_text(code_block);
|
|
84
|
+
|
|
85
|
+
var params = {
|
|
86
|
+
channel: "stable",
|
|
87
|
+
mode: "debug",
|
|
88
|
+
crateType: "bin",
|
|
89
|
+
tests: false,
|
|
90
|
+
code: text,
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (text.indexOf("#![feature") !== -1) {
|
|
94
|
+
params.channel = "nightly";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
result_block.innerText = "Running...";
|
|
98
|
+
|
|
99
|
+
var request = fetch("https://play.rust-lang.org/execute", {
|
|
100
|
+
headers: {
|
|
101
|
+
'Content-Type': "application/json",
|
|
102
|
+
},
|
|
103
|
+
method: 'POST',
|
|
104
|
+
mode: 'cors',
|
|
105
|
+
body: JSON.stringify(params)
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
request
|
|
109
|
+
.then(function (response) { return response.json(); })
|
|
110
|
+
.then(function (response) { result_block.innerText = response.success ? response.stdout : response.stderr; })
|
|
111
|
+
.catch(function (error) { result_block.innerText = "Playground communication" + error.message; });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Syntax highlighting Configuration
|
|
115
|
+
hljs.configure({
|
|
116
|
+
tabReplace: ' ', // 4 spaces
|
|
117
|
+
languages: [], // Languages used for auto-detection
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
if (window.ace) {
|
|
121
|
+
// language-rust class needs to be removed for editable
|
|
122
|
+
// blocks or highlightjs will capture events
|
|
123
|
+
Array
|
|
124
|
+
.from(document.querySelectorAll('code.editable'))
|
|
125
|
+
.forEach(function (block) { block.classList.remove('language-rust'); });
|
|
126
|
+
|
|
127
|
+
Array
|
|
128
|
+
.from(document.querySelectorAll('code:not(.editable)'))
|
|
129
|
+
.forEach(function (block) { hljs.highlightBlock(block); });
|
|
130
|
+
} else {
|
|
131
|
+
Array
|
|
132
|
+
.from(document.querySelectorAll('code'))
|
|
133
|
+
.forEach(function (block) { hljs.highlightBlock(block); });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Adding the hljs class gives code blocks the color css
|
|
137
|
+
// even if highlighting doesn't apply
|
|
138
|
+
Array
|
|
139
|
+
.from(document.querySelectorAll('code'))
|
|
140
|
+
.forEach(function (block) { block.classList.add('hljs'); });
|
|
141
|
+
|
|
142
|
+
Array.from(document.querySelectorAll("code.language-rust")).forEach(function (block) {
|
|
143
|
+
|
|
144
|
+
var code_block = block;
|
|
145
|
+
var pre_block = block.parentNode;
|
|
146
|
+
// hide lines
|
|
147
|
+
var lines = code_block.innerHTML.split("\n");
|
|
148
|
+
var first_non_hidden_line = false;
|
|
149
|
+
var lines_hidden = false;
|
|
150
|
+
|
|
151
|
+
for (var n = 0; n < lines.length; n++) {
|
|
152
|
+
if (lines[n].trim()[0] == hiding_character) {
|
|
153
|
+
if (first_non_hidden_line) {
|
|
154
|
+
lines[n] = "<span class=\"hidden\">" + "\n" + lines[n].replace(/(\s*)# ?/, "$1") + "</span>";
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
lines[n] = "<span class=\"hidden\">" + lines[n].replace(/(\s*)# ?/, "$1") + "\n" + "</span>";
|
|
158
|
+
}
|
|
159
|
+
lines_hidden = true;
|
|
160
|
+
}
|
|
161
|
+
else if (first_non_hidden_line) {
|
|
162
|
+
lines[n] = "\n" + lines[n];
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
first_non_hidden_line = true;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
code_block.innerHTML = lines.join("");
|
|
169
|
+
|
|
170
|
+
// If no lines were hidden, return
|
|
171
|
+
if (!lines_hidden) { return; }
|
|
172
|
+
|
|
173
|
+
var buttons = document.createElement('div');
|
|
174
|
+
buttons.className = 'buttons';
|
|
175
|
+
buttons.innerHTML = "<button class=\"fa fa-expand\" title=\"Show hidden lines\" aria-label=\"Show hidden lines\"></button>";
|
|
176
|
+
|
|
177
|
+
// add expand button
|
|
178
|
+
pre_block.prepend(buttons);
|
|
179
|
+
|
|
180
|
+
pre_block.querySelector('.buttons').addEventListener('click', function (e) {
|
|
181
|
+
if (e.target.classList.contains('fa-expand')) {
|
|
182
|
+
var lines = pre_block.querySelectorAll('span.hidden');
|
|
183
|
+
|
|
184
|
+
e.target.classList.remove('fa-expand');
|
|
185
|
+
e.target.classList.add('fa-compress');
|
|
186
|
+
e.target.title = 'Hide lines';
|
|
187
|
+
e.target.setAttribute('aria-label', e.target.title);
|
|
188
|
+
|
|
189
|
+
Array.from(lines).forEach(function (line) {
|
|
190
|
+
line.classList.remove('hidden');
|
|
191
|
+
line.classList.add('unhidden');
|
|
192
|
+
});
|
|
193
|
+
} else if (e.target.classList.contains('fa-compress')) {
|
|
194
|
+
var lines = pre_block.querySelectorAll('span.unhidden');
|
|
195
|
+
|
|
196
|
+
e.target.classList.remove('fa-compress');
|
|
197
|
+
e.target.classList.add('fa-expand');
|
|
198
|
+
e.target.title = 'Show hidden lines';
|
|
199
|
+
e.target.setAttribute('aria-label', e.target.title);
|
|
200
|
+
|
|
201
|
+
Array.from(lines).forEach(function (line) {
|
|
202
|
+
line.classList.remove('unhidden');
|
|
203
|
+
line.classList.add('hidden');
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
Array.from(document.querySelectorAll('pre code')).forEach(function (block) {
|
|
210
|
+
var pre_block = block.parentNode;
|
|
211
|
+
if (!pre_block.classList.contains('playpen')) {
|
|
212
|
+
var buttons = pre_block.querySelector(".buttons");
|
|
213
|
+
if (!buttons) {
|
|
214
|
+
buttons = document.createElement('div');
|
|
215
|
+
buttons.className = 'buttons';
|
|
216
|
+
pre_block.prepend(buttons);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
var clipButton = document.createElement('button');
|
|
220
|
+
clipButton.className = 'fa fa-copy clip-button';
|
|
221
|
+
clipButton.title = 'Copy to clipboard';
|
|
222
|
+
clipButton.setAttribute('aria-label', clipButton.title);
|
|
223
|
+
clipButton.innerHTML = '<i class=\"tooltiptext\"></i>';
|
|
224
|
+
|
|
225
|
+
buttons.prepend(clipButton);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// Process playpen code blocks
|
|
230
|
+
Array.from(document.querySelectorAll(".playpen")).forEach(function (pre_block) {
|
|
231
|
+
// Add play button
|
|
232
|
+
var buttons = pre_block.querySelector(".buttons");
|
|
233
|
+
if (!buttons) {
|
|
234
|
+
buttons = document.createElement('div');
|
|
235
|
+
buttons.className = 'buttons';
|
|
236
|
+
pre_block.prepend(buttons);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
var runCodeButton = document.createElement('button');
|
|
240
|
+
runCodeButton.className = 'fa fa-play play-button';
|
|
241
|
+
runCodeButton.hidden = true;
|
|
242
|
+
runCodeButton.title = 'Run this code';
|
|
243
|
+
runCodeButton.setAttribute('aria-label', runCodeButton.title);
|
|
244
|
+
|
|
245
|
+
var copyCodeClipboardButton = document.createElement('button');
|
|
246
|
+
copyCodeClipboardButton.className = 'fa fa-copy clip-button';
|
|
247
|
+
copyCodeClipboardButton.innerHTML = '<i class="tooltiptext"></i>';
|
|
248
|
+
copyCodeClipboardButton.title = 'Copy to clipboard';
|
|
249
|
+
copyCodeClipboardButton.setAttribute('aria-label', copyCodeClipboardButton.title);
|
|
250
|
+
|
|
251
|
+
buttons.prepend(runCodeButton);
|
|
252
|
+
buttons.prepend(copyCodeClipboardButton);
|
|
253
|
+
|
|
254
|
+
runCodeButton.addEventListener('click', function (e) {
|
|
255
|
+
run_rust_code(pre_block);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
let code_block = pre_block.querySelector("code");
|
|
259
|
+
if (window.ace && code_block.classList.contains("editable")) {
|
|
260
|
+
var undoChangesButton = document.createElement('button');
|
|
261
|
+
undoChangesButton.className = 'fa fa-history reset-button';
|
|
262
|
+
undoChangesButton.title = 'Undo changes';
|
|
263
|
+
undoChangesButton.setAttribute('aria-label', undoChangesButton.title);
|
|
264
|
+
|
|
265
|
+
buttons.prepend(undoChangesButton);
|
|
266
|
+
|
|
267
|
+
undoChangesButton.addEventListener('click', function () {
|
|
268
|
+
let editor = window.ace.edit(code_block);
|
|
269
|
+
editor.setValue(editor.originalCode);
|
|
270
|
+
editor.clearSelection();
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
request
|
|
276
|
+
.then(function (response) { return response.json(); })
|
|
277
|
+
.then(function (response) {
|
|
278
|
+
// get list of crates available in the rust playground
|
|
279
|
+
let playground_crates = response.crates.map(function (item) { return item["id"]; });
|
|
280
|
+
Array.from(document.querySelectorAll(".playpen")).forEach(function (block) {
|
|
281
|
+
handle_crate_list_update(block, playground_crates);
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
})();
|
|
286
|
+
|
|
287
|
+
(function themes() {
|
|
288
|
+
var html = document.querySelector('html');
|
|
289
|
+
var themeToggleButton = document.getElementById('theme-toggle');
|
|
290
|
+
var themePopup = document.getElementById('theme-list');
|
|
291
|
+
var themeColorMetaTag = document.querySelector('meta[name="theme-color"]');
|
|
292
|
+
var stylesheets = {
|
|
293
|
+
ayuHighlight: document.querySelector("[href='ayu-highlight.css']"),
|
|
294
|
+
tomorrowNight: document.querySelector("[href='tomorrow-night.css']"),
|
|
295
|
+
highlight: document.querySelector("[href='highlight.css']"),
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
function showThemes() {
|
|
299
|
+
themePopup.style.display = 'block';
|
|
300
|
+
themeToggleButton.setAttribute('aria-expanded', true);
|
|
301
|
+
themePopup.querySelector("button#" + document.body.className).focus();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function hideThemes() {
|
|
305
|
+
themePopup.style.display = 'none';
|
|
306
|
+
themeToggleButton.setAttribute('aria-expanded', false);
|
|
307
|
+
themeToggleButton.focus();
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function set_theme(theme) {
|
|
311
|
+
let ace_theme;
|
|
312
|
+
|
|
313
|
+
if (theme == 'coal' || theme == 'navy') {
|
|
314
|
+
stylesheets.ayuHighlight.disabled = true;
|
|
315
|
+
stylesheets.tomorrowNight.disabled = false;
|
|
316
|
+
stylesheets.highlight.disabled = true;
|
|
317
|
+
|
|
318
|
+
ace_theme = "ace/theme/tomorrow_night";
|
|
319
|
+
} else if (theme == 'ayu') {
|
|
320
|
+
stylesheets.ayuHighlight.disabled = false;
|
|
321
|
+
stylesheets.tomorrowNight.disabled = true;
|
|
322
|
+
stylesheets.highlight.disabled = true;
|
|
323
|
+
|
|
324
|
+
ace_theme = "ace/theme/tomorrow_night";
|
|
325
|
+
} else {
|
|
326
|
+
stylesheets.ayuHighlight.disabled = true;
|
|
327
|
+
stylesheets.tomorrowNight.disabled = true;
|
|
328
|
+
stylesheets.highlight.disabled = false;
|
|
329
|
+
|
|
330
|
+
ace_theme = "ace/theme/dawn";
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
setTimeout(function () {
|
|
334
|
+
themeColorMetaTag.content = getComputedStyle(document.body).backgroundColor;
|
|
335
|
+
}, 1);
|
|
336
|
+
|
|
337
|
+
if (window.ace && window.editors) {
|
|
338
|
+
window.editors.forEach(function (editor) {
|
|
339
|
+
editor.setTheme(ace_theme);
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
var previousTheme;
|
|
344
|
+
try { previousTheme = localStorage.getItem('mdbook-theme'); } catch (e) { }
|
|
345
|
+
if (previousTheme === null || previousTheme === undefined) { previousTheme = 'light'; }
|
|
346
|
+
|
|
347
|
+
try { localStorage.setItem('mdbook-theme', theme); } catch (e) { }
|
|
348
|
+
|
|
349
|
+
document.body.className = theme;
|
|
350
|
+
html.classList.remove(previousTheme);
|
|
351
|
+
html.classList.add(theme);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Set theme
|
|
355
|
+
var theme;
|
|
356
|
+
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
|
357
|
+
if (theme === null || theme === undefined) { theme = 'light'; }
|
|
358
|
+
|
|
359
|
+
set_theme(theme);
|
|
360
|
+
|
|
361
|
+
themeToggleButton.addEventListener('click', function () {
|
|
362
|
+
if (themePopup.style.display === 'block') {
|
|
363
|
+
hideThemes();
|
|
364
|
+
} else {
|
|
365
|
+
showThemes();
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
themePopup.addEventListener('click', function (e) {
|
|
370
|
+
var theme = e.target.id || e.target.parentElement.id;
|
|
371
|
+
set_theme(theme);
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
themePopup.addEventListener('focusout', function(e) {
|
|
375
|
+
// e.relatedTarget is null in Safari and Firefox on macOS (see workaround below)
|
|
376
|
+
if (!!e.relatedTarget && !themePopup.contains(e.relatedTarget)) {
|
|
377
|
+
hideThemes();
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
// Should not be needed, but it works around an issue on macOS & iOS: https://github.com/rust-lang-nursery/mdBook/issues/628
|
|
382
|
+
document.addEventListener('click', function(e) {
|
|
383
|
+
if (themePopup.style.display === 'block' && !themeToggleButton.contains(e.target) && !themePopup.contains(e.target)) {
|
|
384
|
+
hideThemes();
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
document.addEventListener('keydown', function (e) {
|
|
389
|
+
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { return; }
|
|
390
|
+
if (!themePopup.contains(e.target)) { return; }
|
|
391
|
+
|
|
392
|
+
switch (e.key) {
|
|
393
|
+
case 'Escape':
|
|
394
|
+
e.preventDefault();
|
|
395
|
+
hideThemes();
|
|
396
|
+
break;
|
|
397
|
+
case 'ArrowUp':
|
|
398
|
+
e.preventDefault();
|
|
399
|
+
var li = document.activeElement.parentElement;
|
|
400
|
+
if (li && li.previousElementSibling) {
|
|
401
|
+
li.previousElementSibling.querySelector('button').focus();
|
|
402
|
+
}
|
|
403
|
+
break;
|
|
404
|
+
case 'ArrowDown':
|
|
405
|
+
e.preventDefault();
|
|
406
|
+
var li = document.activeElement.parentElement;
|
|
407
|
+
if (li && li.nextElementSibling) {
|
|
408
|
+
li.nextElementSibling.querySelector('button').focus();
|
|
409
|
+
}
|
|
410
|
+
break;
|
|
411
|
+
case 'Home':
|
|
412
|
+
e.preventDefault();
|
|
413
|
+
themePopup.querySelector('li:first-child button').focus();
|
|
414
|
+
break;
|
|
415
|
+
case 'End':
|
|
416
|
+
e.preventDefault();
|
|
417
|
+
themePopup.querySelector('li:last-child button').focus();
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
})();
|
|
422
|
+
|
|
423
|
+
(function sidebar() {
|
|
424
|
+
var html = document.querySelector("html");
|
|
425
|
+
var sidebar = document.getElementById("sidebar");
|
|
426
|
+
var sidebarLinks = document.querySelectorAll('#sidebar a');
|
|
427
|
+
var sidebarToggleButton = document.getElementById("sidebar-toggle");
|
|
428
|
+
var firstContact = null;
|
|
429
|
+
|
|
430
|
+
function showSidebar() {
|
|
431
|
+
html.classList.remove('sidebar-hidden')
|
|
432
|
+
html.classList.add('sidebar-visible');
|
|
433
|
+
Array.from(sidebarLinks).forEach(function (link) {
|
|
434
|
+
link.setAttribute('tabIndex', 0);
|
|
435
|
+
});
|
|
436
|
+
sidebarToggleButton.setAttribute('aria-expanded', true);
|
|
437
|
+
sidebar.setAttribute('aria-hidden', false);
|
|
438
|
+
try { localStorage.setItem('mdbook-sidebar', 'visible'); } catch (e) { }
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function hideSidebar() {
|
|
442
|
+
html.classList.remove('sidebar-visible')
|
|
443
|
+
html.classList.add('sidebar-hidden');
|
|
444
|
+
Array.from(sidebarLinks).forEach(function (link) {
|
|
445
|
+
link.setAttribute('tabIndex', -1);
|
|
446
|
+
});
|
|
447
|
+
sidebarToggleButton.setAttribute('aria-expanded', false);
|
|
448
|
+
sidebar.setAttribute('aria-hidden', true);
|
|
449
|
+
try { localStorage.setItem('mdbook-sidebar', 'hidden'); } catch (e) { }
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// Toggle sidebar
|
|
453
|
+
sidebarToggleButton.addEventListener('click', function sidebarToggle() {
|
|
454
|
+
if (html.classList.contains("sidebar-hidden")) {
|
|
455
|
+
showSidebar();
|
|
456
|
+
} else if (html.classList.contains("sidebar-visible")) {
|
|
457
|
+
hideSidebar();
|
|
458
|
+
} else {
|
|
459
|
+
if (getComputedStyle(sidebar)['transform'] === 'none') {
|
|
460
|
+
hideSidebar();
|
|
461
|
+
} else {
|
|
462
|
+
showSidebar();
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
document.addEventListener('touchstart', function (e) {
|
|
468
|
+
firstContact = {
|
|
469
|
+
x: e.touches[0].clientX,
|
|
470
|
+
time: Date.now()
|
|
471
|
+
};
|
|
472
|
+
}, { passive: true });
|
|
473
|
+
|
|
474
|
+
document.addEventListener('touchmove', function (e) {
|
|
475
|
+
if (!firstContact)
|
|
476
|
+
return;
|
|
477
|
+
|
|
478
|
+
var curX = e.touches[0].clientX;
|
|
479
|
+
var xDiff = curX - firstContact.x,
|
|
480
|
+
tDiff = Date.now() - firstContact.time;
|
|
481
|
+
|
|
482
|
+
if (tDiff < 250 && Math.abs(xDiff) >= 150) {
|
|
483
|
+
if (xDiff >= 0 && firstContact.x < Math.min(document.body.clientWidth * 0.25, 300))
|
|
484
|
+
showSidebar();
|
|
485
|
+
else if (xDiff < 0 && curX < 300)
|
|
486
|
+
hideSidebar();
|
|
487
|
+
|
|
488
|
+
firstContact = null;
|
|
489
|
+
}
|
|
490
|
+
}, { passive: true });
|
|
491
|
+
|
|
492
|
+
// Scroll sidebar to current active section
|
|
493
|
+
var activeSection = sidebar.querySelector(".active");
|
|
494
|
+
if (activeSection) {
|
|
495
|
+
sidebar.scrollTop = activeSection.offsetTop;
|
|
496
|
+
}
|
|
497
|
+
})();
|
|
498
|
+
|
|
499
|
+
(function chapterNavigation() {
|
|
500
|
+
document.addEventListener('keydown', function (e) {
|
|
501
|
+
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { return; }
|
|
502
|
+
if (window.search && window.search.hasFocus()) { return; }
|
|
503
|
+
|
|
504
|
+
switch (e.key) {
|
|
505
|
+
case 'ArrowRight':
|
|
506
|
+
e.preventDefault();
|
|
507
|
+
var nextButton = document.querySelector('.nav-chapters.next');
|
|
508
|
+
if (nextButton) {
|
|
509
|
+
window.location.href = nextButton.href;
|
|
510
|
+
}
|
|
511
|
+
break;
|
|
512
|
+
case 'ArrowLeft':
|
|
513
|
+
e.preventDefault();
|
|
514
|
+
var previousButton = document.querySelector('.nav-chapters.previous');
|
|
515
|
+
if (previousButton) {
|
|
516
|
+
window.location.href = previousButton.href;
|
|
517
|
+
}
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
})();
|
|
522
|
+
|
|
523
|
+
(function clipboard() {
|
|
524
|
+
var clipButtons = document.querySelectorAll('.clip-button');
|
|
525
|
+
|
|
526
|
+
function hideTooltip(elem) {
|
|
527
|
+
elem.firstChild.innerText = "";
|
|
528
|
+
elem.className = 'fa fa-copy clip-button';
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
function showTooltip(elem, msg) {
|
|
532
|
+
elem.firstChild.innerText = msg;
|
|
533
|
+
elem.className = 'fa fa-copy tooltipped';
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
var clipboardSnippets = new Clipboard('.clip-button', {
|
|
537
|
+
text: function (trigger) {
|
|
538
|
+
hideTooltip(trigger);
|
|
539
|
+
let playpen = trigger.closest("pre");
|
|
540
|
+
return playpen_text(playpen);
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
Array.from(clipButtons).forEach(function (clipButton) {
|
|
545
|
+
clipButton.addEventListener('mouseout', function (e) {
|
|
546
|
+
hideTooltip(e.currentTarget);
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
clipboardSnippets.on('success', function (e) {
|
|
551
|
+
e.clearSelection();
|
|
552
|
+
showTooltip(e.trigger, "Copied!");
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
clipboardSnippets.on('error', function (e) {
|
|
556
|
+
showTooltip(e.trigger, "Clipboard error!");
|
|
557
|
+
});
|
|
558
|
+
})();
|
|
559
|
+
|
|
560
|
+
(function scrollToTop () {
|
|
561
|
+
var menuTitle = document.querySelector('.menu-title');
|
|
562
|
+
|
|
563
|
+
menuTitle.addEventListener('click', function () {
|
|
564
|
+
document.scrollingElement.scrollTo({ top: 0, behavior: 'smooth' });
|
|
565
|
+
});
|
|
566
|
+
})();
|
|
567
|
+
|
|
568
|
+
(function autoHideMenu() {
|
|
569
|
+
var menu = document.getElementById('menu-bar');
|
|
570
|
+
|
|
571
|
+
var previousScrollTop = document.scrollingElement.scrollTop;
|
|
572
|
+
|
|
573
|
+
document.addEventListener('scroll', function () {
|
|
574
|
+
if (menu.classList.contains('folded') && document.scrollingElement.scrollTop < previousScrollTop) {
|
|
575
|
+
menu.classList.remove('folded');
|
|
576
|
+
} else if (!menu.classList.contains('folded') && document.scrollingElement.scrollTop > previousScrollTop) {
|
|
577
|
+
menu.classList.add('folded');
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
if (!menu.classList.contains('bordered') && document.scrollingElement.scrollTop > 0) {
|
|
581
|
+
menu.classList.add('bordered');
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
if (menu.classList.contains('bordered') && document.scrollingElement.scrollTop === 0) {
|
|
585
|
+
menu.classList.remove('bordered');
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
previousScrollTop = document.scrollingElement.scrollTop;
|
|
589
|
+
}, { passive: true });
|
|
590
|
+
})();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* clipboard.js v1.6.1
|
|
3
|
+
* https://zenorocha.github.io/clipboard.js
|
|
4
|
+
*
|
|
5
|
+
* Licensed MIT © Zeno Rocha
|
|
6
|
+
*/
|
|
7
|
+
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Clipboard=e()}}(function(){var e,t,n;return function e(t,n,o){function i(a,c){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!c&&l)return l(a,!0);if(r)return r(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var s=n[a]={exports:{}};t[a][0].call(s.exports,function(e){var n=t[a][1][e];return i(n?n:e)},s,s.exports,e,t,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a<o.length;a++)i(o[a]);return i}({1:[function(e,t,n){function o(e,t){for(;e&&e.nodeType!==i;){if(e.matches(t))return e;e=e.parentNode}}var i=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}t.exports=o},{}],2:[function(e,t,n){function o(e,t,n,o,r){var a=i.apply(this,arguments);return e.addEventListener(n,a,r),{destroy:function(){e.removeEventListener(n,a,r)}}}function i(e,t,n,o){return function(n){n.delegateTarget=r(n.target,t),n.delegateTarget&&o.call(e,n)}}var r=e("./closest");t.exports=o},{"./closest":1}],3:[function(e,t,n){n.node=function(e){return void 0!==e&&e instanceof HTMLElement&&1===e.nodeType},n.nodeList=function(e){var t=Object.prototype.toString.call(e);return void 0!==e&&("[object NodeList]"===t||"[object HTMLCollection]"===t)&&"length"in e&&(0===e.length||n.node(e[0]))},n.string=function(e){return"string"==typeof e||e instanceof String},n.fn=function(e){var t=Object.prototype.toString.call(e);return"[object Function]"===t}},{}],4:[function(e,t,n){function o(e,t,n){if(!e&&!t&&!n)throw new Error("Missing required arguments");if(!c.string(t))throw new TypeError("Second argument must be a String");if(!c.fn(n))throw new TypeError("Third argument must be a Function");if(c.node(e))return i(e,t,n);if(c.nodeList(e))return r(e,t,n);if(c.string(e))return a(e,t,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function i(e,t,n){return e.addEventListener(t,n),{destroy:function(){e.removeEventListener(t,n)}}}function r(e,t,n){return Array.prototype.forEach.call(e,function(e){e.addEventListener(t,n)}),{destroy:function(){Array.prototype.forEach.call(e,function(e){e.removeEventListener(t,n)})}}}function a(e,t,n){return l(document.body,e,t,n)}var c=e("./is"),l=e("delegate");t.exports=o},{"./is":3,delegate:2}],5:[function(e,t,n){function o(e){var t;if("SELECT"===e.nodeName)e.focus(),t=e.value;else if("INPUT"===e.nodeName||"TEXTAREA"===e.nodeName){var n=e.hasAttribute("readonly");n||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),n||e.removeAttribute("readonly"),t=e.value}else{e.hasAttribute("contenteditable")&&e.focus();var o=window.getSelection(),i=document.createRange();i.selectNodeContents(e),o.removeAllRanges(),o.addRange(i),t=o.toString()}return t}t.exports=o},{}],6:[function(e,t,n){function o(){}o.prototype={on:function(e,t,n){var o=this.e||(this.e={});return(o[e]||(o[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){function o(){i.off(e,o),t.apply(n,arguments)}var i=this;return o._=t,this.on(e,o,n)},emit:function(e){var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),o=0,i=n.length;for(o;o<i;o++)n[o].fn.apply(n[o].ctx,t);return this},off:function(e,t){var n=this.e||(this.e={}),o=n[e],i=[];if(o&&t)for(var r=0,a=o.length;r<a;r++)o[r].fn!==t&&o[r].fn._!==t&&i.push(o[r]);return i.length?n[e]=i:delete n[e],this}},t.exports=o},{}],7:[function(t,n,o){!function(i,r){if("function"==typeof e&&e.amd)e(["module","select"],r);else if("undefined"!=typeof o)r(n,t("select"));else{var a={exports:{}};r(a,i.select),i.clipboardAction=a.exports}}(this,function(e,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(t),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),c=function(){function e(t){o(this,e),this.resolveOptions(t),this.initSelection()}return a(e,[{key:"resolveOptions",value:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function e(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function e(){var t=this,n="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=document.body.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[n?"right":"left"]="-9999px";var o=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=o+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,document.body.appendChild(this.fakeElem),this.selectedText=(0,i.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function e(){this.fakeHandler&&(document.body.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function e(){this.selectedText=(0,i.default)(this.target),this.copyText()}},{key:"copyText",value:function e(){var t=void 0;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}},{key:"handleResult",value:function e(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function e(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function e(){this.removeFake()}},{key:"action",set:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function e(){return this._action}},{key:"target",set:function e(t){if(void 0!==t){if(!t||"object"!==("undefined"==typeof t?"undefined":r(t))||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function e(){return this._target}}]),e}();e.exports=c})},{select:5}],8:[function(t,n,o){!function(i,r){if("function"==typeof e&&e.amd)e(["module","./clipboard-action","tiny-emitter","good-listener"],r);else if("undefined"!=typeof o)r(n,t("./clipboard-action"),t("tiny-emitter"),t("good-listener"));else{var a={exports:{}};r(a,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=a.exports}}(this,function(e,t,n,o){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function l(e,t){var n="data-clipboard-"+e;if(t.hasAttribute(n))return t.getAttribute(n)}var u=i(t),s=i(n),f=i(o),d=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),h=function(e){function t(e,n){r(this,t);var o=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return o.resolveOptions(n),o.listenClick(e),o}return c(t,e),d(t,[{key:"resolveOptions",value:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText}},{key:"listenClick",value:function e(t){var n=this;this.listener=(0,f.default)(t,"click",function(e){return n.onClick(e)})}},{key:"onClick",value:function e(t){var n=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new u.default({action:this.action(n),target:this.target(n),text:this.text(n),trigger:n,emitter:this})}},{key:"defaultAction",value:function e(t){return l("action",t)}},{key:"defaultTarget",value:function e(t){var n=l("target",t);if(n)return document.querySelector(n)}},{key:"defaultText",value:function e(t){return l("text",t)}},{key:"destroy",value:function e(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],n="string"==typeof t?[t]:t,o=!!document.queryCommandSupported;return n.forEach(function(e){o=o&&!!document.queryCommandSupported(e)}),o}}]),t}(s.default);e.exports=h})},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* elasticlunr - http://weixsong.github.io
|
|
3
|
+
* Lightweight full-text search engine in Javascript for browser search and offline search. - 0.9.5
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2017 Oliver Nightingale
|
|
6
|
+
* Copyright (C) 2017 Wei Song
|
|
7
|
+
* MIT Licensed
|
|
8
|
+
* @license
|
|
9
|
+
*/
|
|
10
|
+
!function(){function e(e){if(null===e||"object"!=typeof e)return e;var t=e.constructor();for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.9.5",lunr=t,t.utils={},t.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),t.utils.toString=function(e){return void 0===e||null===e?"":e.toString()},t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var e=Array.prototype.slice.call(arguments),t=e.pop(),n=e;if("function"!=typeof t)throw new TypeError("last argument must be a function");n.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},t.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);-1!==n&&(this.events[e].splice(n,1),0==this.events[e].length&&delete this.events[e])}},t.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){var t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)},this)}},t.EventEmitter.prototype.hasHandler=function(e){return e in this.events},t.tokenizer=function(e){if(!arguments.length||null===e||void 0===e)return[];if(Array.isArray(e)){var n=e.filter(function(e){return null===e||void 0===e?!1:!0});n=n.map(function(e){return t.utils.toString(e).toLowerCase()});var i=[];return n.forEach(function(e){var n=e.split(t.tokenizer.seperator);i=i.concat(n)},this),i}return e.toString().trim().toLowerCase().split(t.tokenizer.seperator)},t.tokenizer.defaultSeperator=/[\s\-]+/,t.tokenizer.seperator=t.tokenizer.defaultSeperator,t.tokenizer.setSeperator=function(e){null!==e&&void 0!==e&&"object"==typeof e&&(t.tokenizer.seperator=e)},t.tokenizer.resetSeperator=function(){t.tokenizer.seperator=t.tokenizer.defaultSeperator},t.tokenizer.getSeperator=function(){return t.tokenizer.seperator},t.Pipeline=function(){this._queue=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in t.Pipeline.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[n]=e},t.Pipeline.getRegisteredFunction=function(e){return e in t.Pipeline.registeredFunctions!=!0?null:t.Pipeline.registeredFunctions[e]},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var i=t.Pipeline.getRegisteredFunction(e);if(!i)throw new Error("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i+1,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i,0,n)},t.Pipeline.prototype.remove=function(e){var t=this._queue.indexOf(e);-1!==t&&this._queue.splice(t,1)},t.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,i=this._queue.length,o=0;n>o;o++){for(var r=e[o],s=0;i>s&&(r=this._queue[s](r,o,e),void 0!==r&&null!==r);s++);void 0!==r&&null!==r&&t.push(r)}return t},t.Pipeline.prototype.reset=function(){this._queue=[]},t.Pipeline.prototype.get=function(){return this._queue},t.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.DocumentStore,this.index={},this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var e=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},t.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;n._fields=e.fields,n._ref=e.ref,n.documentStore=t.DocumentStore.load(e.documentStore),n.pipeline=t.Pipeline.load(e.pipeline),n.index={};for(var i in e.index)n.index[i]=t.InvertedIndex.load(e.index[i]);return n},t.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new t.InvertedIndex,this},t.Index.prototype.setRef=function(e){return this._ref=e,this},t.Index.prototype.saveDocument=function(e){return this.documentStore=new t.DocumentStore(e),this},t.Index.prototype.addDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.addDoc(i,e),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));this.documentStore.addFieldLength(i,n,o.length);var r={};o.forEach(function(e){e in r?r[e]+=1:r[e]=1},this);for(var s in r){var u=r[s];u=Math.sqrt(u),this.index[n].addToken(s,{ref:i,tf:u})}},this),n&&this.eventEmitter.emit("add",e,this)}},t.Index.prototype.removeDocByRef=function(e){if(e&&this.documentStore.isDocStored()!==!1&&this.documentStore.hasDoc(e)){var t=this.documentStore.getDoc(e);this.removeDoc(t,!1)}},t.Index.prototype.removeDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.hasDoc(i)&&(this.documentStore.removeDoc(i),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));o.forEach(function(e){this.index[n].removeToken(e,i)},this)},this),n&&this.eventEmitter.emit("remove",e,this))}},t.Index.prototype.updateDoc=function(e,t){var t=void 0===t?!0:t;this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},t.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;if(Object.prototype.hasOwnProperty.call(this._idfCache,n))return this._idfCache[n];var i=this.index[t].getDocFreq(e),o=1+Math.log(this.documentStore.length/(i+1));return this._idfCache[n]=o,o},t.Index.prototype.getFields=function(){return this._fields.slice()},t.Index.prototype.search=function(e,n){if(!e)return[];e="string"==typeof e?{any:e}:JSON.parse(JSON.stringify(e));var i=null;null!=n&&(i=JSON.stringify(n));for(var o=new t.Configuration(i,this.getFields()).get(),r={},s=Object.keys(e),u=0;u<s.length;u++){var a=s[u];r[a]=this.pipeline.run(t.tokenizer(e[a]))}var l={};for(var c in o){var d=r[c]||r.any;if(d){var f=this.fieldSearch(d,c,o),h=o[c].boost;for(var p in f)f[p]=f[p]*h;for(var p in f)p in l?l[p]+=f[p]:l[p]=f[p]}}var v,g=[];for(var p in l)v={ref:p,score:l[p]},this.documentStore.hasDoc(p)&&(v.doc=this.documentStore.getDoc(p)),g.push(v);return g.sort(function(e,t){return t.score-e.score}),g},t.Index.prototype.fieldSearch=function(e,t,n){var i=n[t].bool,o=n[t].expand,r=n[t].boost,s=null,u={};return 0!==r?(e.forEach(function(e){var n=[e];1==o&&(n=this.index[t].expandToken(e));var r={};n.forEach(function(n){var o=this.index[t].getDocs(n),a=this.idf(n,t);if(s&&"AND"==i){var l={};for(var c in s)c in o&&(l[c]=o[c]);o=l}n==e&&this.fieldSearchStats(u,n,o);for(var c in o){var d=this.index[t].getTermFrequency(n,c),f=this.documentStore.getFieldLength(c,t),h=1;0!=f&&(h=1/Math.sqrt(f));var p=1;n!=e&&(p=.15*(1-(n.length-e.length)/n.length));var v=d*a*h*p;c in r?r[c]+=v:r[c]=v}},this),s=this.mergeScores(s,r,i)},this),s=this.coordNorm(s,u,e.length)):void 0},t.Index.prototype.mergeScores=function(e,t,n){if(!e)return t;if("AND"==n){var i={};for(var o in t)o in e&&(i[o]=e[o]+t[o]);return i}for(var o in t)o in e?e[o]+=t[o]:e[o]=t[o];return e},t.Index.prototype.fieldSearchStats=function(e,t,n){for(var i in n)i in e?e[i].push(t):e[i]=[t]},t.Index.prototype.coordNorm=function(e,t,n){for(var i in e)if(i in t){var o=t[i].length;e[i]=e[i]*o/n}return e},t.Index.prototype.toJSON=function(){var e={};return this._fields.forEach(function(t){e[t]=this.index[t].toJSON()},this),{version:t.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),index:e,pipeline:this.pipeline.toJSON()}},t.Index.prototype.use=function(e){var t=Array.prototype.slice.call(arguments,1);t.unshift(this),e.apply(this,t)},t.DocumentStore=function(e){this._save=null===e||void 0===e?!0:e,this.docs={},this.docInfo={},this.length=0},t.DocumentStore.load=function(e){var t=new this;return t.length=e.length,t.docs=e.docs,t.docInfo=e.docInfo,t._save=e.save,t},t.DocumentStore.prototype.isDocStored=function(){return this._save},t.DocumentStore.prototype.addDoc=function(t,n){this.hasDoc(t)||this.length++,this.docs[t]=this._save===!0?e(n):null},t.DocumentStore.prototype.getDoc=function(e){return this.hasDoc(e)===!1?null:this.docs[e]},t.DocumentStore.prototype.hasDoc=function(e){return e in this.docs},t.DocumentStore.prototype.removeDoc=function(e){this.hasDoc(e)&&(delete this.docs[e],delete this.docInfo[e],this.length--)},t.DocumentStore.prototype.addFieldLength=function(e,t,n){null!==e&&void 0!==e&&0!=this.hasDoc(e)&&(this.docInfo[e]||(this.docInfo[e]={}),this.docInfo[e][t]=n)},t.DocumentStore.prototype.updateFieldLength=function(e,t,n){null!==e&&void 0!==e&&0!=this.hasDoc(e)&&this.addFieldLength(e,t,n)},t.DocumentStore.prototype.getFieldLength=function(e,t){return null===e||void 0===e?0:e in this.docs&&t in this.docInfo[e]?this.docInfo[e][t]:0},t.DocumentStore.prototype.toJSON=function(){return{docs:this.docs,docInfo:this.docInfo,length:this.length,save:this._save}},t.stemmer=function(){var e={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},t={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[^aeiou]",i="[aeiouy]",o=n+"[^aeiouy]*",r=i+"[aeiou]*",s="^("+o+")?"+r+o,u="^("+o+")?"+r+o+"("+r+")?$",a="^("+o+")?"+r+o+r+o,l="^("+o+")?"+i,c=new RegExp(s),d=new RegExp(a),f=new RegExp(u),h=new RegExp(l),p=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,g=/^(.+?)eed$/,m=/^(.+?)(ed|ing)$/,y=/.$/,S=/(at|bl|iz)$/,x=new RegExp("([^aeiouylsz])\\1$"),w=new RegExp("^"+o+i+"[^aeiouwxy]$"),I=/^(.+?[^aeiou])y$/,b=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,E=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,D=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,F=/^(.+?)(s|t)(ion)$/,_=/^(.+?)e$/,P=/ll$/,k=new RegExp("^"+o+i+"[^aeiouwxy]$"),z=function(n){var i,o,r,s,u,a,l;if(n.length<3)return n;if(r=n.substr(0,1),"y"==r&&(n=r.toUpperCase()+n.substr(1)),s=p,u=v,s.test(n)?n=n.replace(s,"$1$2"):u.test(n)&&(n=n.replace(u,"$1$2")),s=g,u=m,s.test(n)){var z=s.exec(n);s=c,s.test(z[1])&&(s=y,n=n.replace(s,""))}else if(u.test(n)){var z=u.exec(n);i=z[1],u=h,u.test(i)&&(n=i,u=S,a=x,l=w,u.test(n)?n+="e":a.test(n)?(s=y,n=n.replace(s,"")):l.test(n)&&(n+="e"))}if(s=I,s.test(n)){var z=s.exec(n);i=z[1],n=i+"i"}if(s=b,s.test(n)){var z=s.exec(n);i=z[1],o=z[2],s=c,s.test(i)&&(n=i+e[o])}if(s=E,s.test(n)){var z=s.exec(n);i=z[1],o=z[2],s=c,s.test(i)&&(n=i+t[o])}if(s=D,u=F,s.test(n)){var z=s.exec(n);i=z[1],s=d,s.test(i)&&(n=i)}else if(u.test(n)){var z=u.exec(n);i=z[1]+z[2],u=d,u.test(i)&&(n=i)}if(s=_,s.test(n)){var z=s.exec(n);i=z[1],s=d,u=f,a=k,(s.test(i)||u.test(i)&&!a.test(i))&&(n=i)}return s=P,u=d,s.test(n)&&u.test(n)&&(s=y,n=n.replace(s,"")),"y"==r&&(n=r.toLowerCase()+n.substr(1)),n};return z}(),t.Pipeline.registerFunction(t.stemmer,"stemmer"),t.stopWordFilter=function(e){return e&&t.stopWordFilter.stopWords[e]!==!0?e:void 0},t.clearStopWords=function(){t.stopWordFilter.stopWords={}},t.addStopWords=function(e){null!=e&&Array.isArray(e)!==!1&&e.forEach(function(e){t.stopWordFilter.stopWords[e]=!0},this)},t.resetStopWords=function(){t.stopWordFilter.stopWords=t.defaultStopWords},t.defaultStopWords={"":!0,a:!0,able:!0,about:!0,across:!0,after:!0,all:!0,almost:!0,also:!0,am:!0,among:!0,an:!0,and:!0,any:!0,are:!0,as:!0,at:!0,be:!0,because:!0,been:!0,but:!0,by:!0,can:!0,cannot:!0,could:!0,dear:!0,did:!0,"do":!0,does:!0,either:!0,"else":!0,ever:!0,every:!0,"for":!0,from:!0,get:!0,got:!0,had:!0,has:!0,have:!0,he:!0,her:!0,hers:!0,him:!0,his:!0,how:!0,however:!0,i:!0,"if":!0,"in":!0,into:!0,is:!0,it:!0,its:!0,just:!0,least:!0,let:!0,like:!0,likely:!0,may:!0,me:!0,might:!0,most:!0,must:!0,my:!0,neither:!0,no:!0,nor:!0,not:!0,of:!0,off:!0,often:!0,on:!0,only:!0,or:!0,other:!0,our:!0,own:!0,rather:!0,said:!0,say:!0,says:!0,she:!0,should:!0,since:!0,so:!0,some:!0,than:!0,that:!0,the:!0,their:!0,them:!0,then:!0,there:!0,these:!0,they:!0,"this":!0,tis:!0,to:!0,too:!0,twas:!0,us:!0,wants:!0,was:!0,we:!0,were:!0,what:!0,when:!0,where:!0,which:!0,"while":!0,who:!0,whom:!0,why:!0,will:!0,"with":!0,would:!0,yet:!0,you:!0,your:!0},t.stopWordFilter.stopWords=t.defaultStopWords,t.Pipeline.registerFunction(t.stopWordFilter,"stopWordFilter"),t.trimmer=function(e){if(null===e||void 0===e)throw new Error("token should not be undefined");return e.replace(/^\W+/,"").replace(/\W+$/,"")},t.Pipeline.registerFunction(t.trimmer,"trimmer"),t.InvertedIndex=function(){this.root={docs:{},df:0}},t.InvertedIndex.load=function(e){var t=new this;return t.root=e.root,t},t.InvertedIndex.prototype.addToken=function(e,t,n){for(var n=n||this.root,i=0;i<=e.length-1;){var o=e[i];o in n||(n[o]={docs:{},df:0}),i+=1,n=n[o]}var r=t.ref;n.docs[r]?n.docs[r]={tf:t.tf}:(n.docs[r]={tf:t.tf},n.df+=1)},t.InvertedIndex.prototype.hasToken=function(e){if(!e)return!1;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return!1;t=t[e[n]]}return!0},t.InvertedIndex.prototype.getNode=function(e){if(!e)return null;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return null;t=t[e[n]]}return t},t.InvertedIndex.prototype.getDocs=function(e){var t=this.getNode(e);return null==t?{}:t.docs},t.InvertedIndex.prototype.getTermFrequency=function(e,t){var n=this.getNode(e);return null==n?0:t in n.docs?n.docs[t].tf:0},t.InvertedIndex.prototype.getDocFreq=function(e){var t=this.getNode(e);return null==t?0:t.df},t.InvertedIndex.prototype.removeToken=function(e,t){if(e){var n=this.getNode(e);null!=n&&t in n.docs&&(delete n.docs[t],n.df-=1)}},t.InvertedIndex.prototype.expandToken=function(e,t,n){if(null==e||""==e)return[];var t=t||[];if(void 0==n&&(n=this.getNode(e),null==n))return t;n.df>0&&t.push(e);for(var i in n)"docs"!==i&&"df"!==i&&this.expandToken(e+i,t,n[i]);return t},t.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},t.Configuration=function(e,n){var e=e||"";if(void 0==n||null==n)throw new Error("fields should not be null");this.config={};var i;try{i=JSON.parse(e),this.buildUserConfig(i,n)}catch(o){t.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(n)}},t.Configuration.prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},t.Configuration.prototype.buildUserConfig=function(e,n){var i="OR",o=!1;if(this.reset(),"bool"in e&&(i=e.bool||i),"expand"in e&&(o=e.expand||o),"fields"in e)for(var r in e.fields)if(n.indexOf(r)>-1){var s=e.fields[r],u=o;void 0!=s.expand&&(u=s.expand),this.config[r]={boost:s.boost||0===s.boost?s.boost:1,bool:s.bool||i,expand:u}}else t.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,o,n)},t.Configuration.prototype.addAllFields2UserConfig=function(e,t,n){n.forEach(function(n){this.config[n]={boost:1,bool:e,expand:t}},this)},t.Configuration.prototype.get=function(){return this.config},t.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){var e,t;for(e=0;e<arguments.length;e++)t=arguments[e],~this.indexOf(t)||this.elements.splice(this.locationFor(t),0,t);this.length=this.elements.length},lunr.SortedSet.prototype.toArray=function(){return this.elements.slice()},lunr.SortedSet.prototype.map=function(e,t){return this.elements.map(e,t)},lunr.SortedSet.prototype.forEach=function(e,t){return this.elements.forEach(e,t)},lunr.SortedSet.prototype.indexOf=function(e){for(var t=0,n=this.elements.length,i=n-t,o=t+Math.floor(i/2),r=this.elements[o];i>1;){if(r===e)return o;e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o]}return r===e?o:-1},lunr.SortedSet.prototype.locationFor=function(e){for(var t=0,n=this.elements.length,i=n-t,o=t+Math.floor(i/2),r=this.elements[o];i>1;)e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o];return r>e?o:e>r?o+1:void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,i=0,o=this.length,r=e.length,s=this.elements,u=e.elements;;){if(n>o-1||i>r-1)break;s[n]!==u[i]?s[n]<u[i]?n++:s[n]>u[i]&&i++:(t.add(s[n]),n++,i++)}return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){var t,n,i;this.length>=e.length?(t=this,n=e):(t=e,n=this),i=t.clone();for(var o=0,r=n.toArray();o<r.length;o++)i.add(r[o]);return i},lunr.SortedSet.prototype.toJSON=function(){return this.toArray()},function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.elasticlunr=t()}(this,function(){return t})}();
|
data/docs/favicon.png
ADDED
|
Binary file
|