wwwjdic 16.0.0 → 16.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +10 -1
- data/Gemfile +2 -4
- data/README.md +5 -4
- data/Rakefile +2 -4
- data/copyright.md +5 -5
- data/examples/basics.rb +2 -4
- data/examples/translate.rb +2 -4
- data/examples/uri.rb +2 -6
- data/html/CHANGELOG.html +34 -24
- data/html/COPYING_md.html +22 -23
- data/html/Gemfile.html +23 -24
- data/html/Object.html +393 -394
- data/html/README_md.html +27 -28
- data/html/Rakefile.html +23 -24
- data/html/WWWJDic.html +42 -43
- data/html/WWWJDic/ParsableDuckType.html +35 -36
- data/html/WWWJDic/Parser.html +47 -48
- data/html/WWWJDic/Parsers.html +28 -29
- data/html/WWWJDic/Parsers/Dict.html +47 -48
- data/html/WWWJDic/Parsers/Display.html +42 -43
- data/html/WWWJDic/Parsers/Key.html +42 -43
- data/html/WWWJDic/Parsers/Search.html +38 -39
- data/html/WWWJDic/Parsers/Server.html +42 -43
- data/html/WWWJDic/Splitter.html +76 -77
- data/html/WWWJDic/Utils.html +29 -30
- data/html/WWWJDic/Utils/Downloader.html +40 -35
- data/html/WWWJDic/Utils/Downloader/Downloader.html +52 -45
- data/html/WWWJDic/Utils/Raisers.html +43 -44
- data/html/WWWJDic/WWWJDic.html +162 -163
- data/html/copyright_md.html +27 -28
- data/html/created.rid +33 -33
- data/html/css/rdoc.css +638 -619
- data/html/index.html +26 -27
- data/html/js/darkfish.js +84 -84
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +109 -110
- data/html/js/search_index.js +1 -1
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js +228 -229
- data/html/js/searcher.js.gz +0 -0
- data/html/table_of_contents.html +10 -10
- data/lib/wwwjdic.rb +3 -5
- data/lib/wwwjdic/application.rb +4 -5
- data/lib/wwwjdic/constants.rb +11 -5
- data/lib/wwwjdic/locales/de.yml +2 -2
- data/lib/wwwjdic/locales/en.yml +2 -2
- data/lib/wwwjdic/locales/es.yml +2 -2
- data/lib/wwwjdic/locales/fr.yml +2 -2
- data/lib/wwwjdic/locales/hu.yml +2 -2
- data/lib/wwwjdic/locales/it.yml +2 -2
- data/lib/wwwjdic/locales/ja.yml +4 -4
- data/lib/wwwjdic/locales/nl.yml +2 -2
- data/lib/wwwjdic/locales/ru.yml +2 -2
- data/lib/wwwjdic/locales/sl.yml +2 -2
- data/lib/wwwjdic/locales/sv.yml +2 -2
- data/lib/wwwjdic/parser.rb +3 -5
- data/lib/wwwjdic/parsers/dict.rb +3 -5
- data/lib/wwwjdic/parsers/display.rb +3 -5
- data/lib/wwwjdic/parsers/key.rb +3 -5
- data/lib/wwwjdic/parsers/search.rb +3 -5
- data/lib/wwwjdic/parsers/server.rb +3 -5
- data/lib/wwwjdic/utils/downloader.rb +14 -8
- data/lib/wwwjdic/utils/raisers.rb +4 -6
- data/lib/wwwjdic/utils/splitter.rb +4 -5
- data/lib/wwwjdic/version.rb +10 -4
- data/test/test_helper.rb +2 -4
- data/test/test_wwwjdic.rb +2 -4
- data/test/wwwjdic/locales/de.yml +2 -2
- data/test/wwwjdic/locales/en.yml +2 -2
- data/test/wwwjdic/locales/es.yml +2 -2
- data/test/wwwjdic/locales/fr.yml +2 -2
- data/test/wwwjdic/locales/hu.yml +2 -2
- data/test/wwwjdic/locales/it.yml +2 -2
- data/test/wwwjdic/locales/ja.yml +4 -4
- data/test/wwwjdic/locales/nl.yml +2 -2
- data/test/wwwjdic/locales/ru.yml +2 -2
- data/test/wwwjdic/locales/sl.yml +2 -2
- data/test/wwwjdic/locales/sv.yml +2 -2
- data/test/wwwjdic/locales/test_locales.rb +2 -4
- data/test/wwwjdic/parsers/test_dict.rb +2 -4
- data/test/wwwjdic/parsers/test_display.rb +2 -4
- data/test/wwwjdic/parsers/test_key.rb +2 -4
- data/test/wwwjdic/parsers/test_server.rb +2 -4
- data/test/wwwjdic/test_application.rb +3 -5
- data/test/wwwjdic/test_parsable_duck_type.rb +4 -5
- data/test/wwwjdic/utils/test_downloader.rb +2 -4
- data/test/wwwjdic/utils/test_raisers.rb +2 -4
- data/wwwjdic.gemspec +2 -4
- metadata +11 -11
data/html/index.html
CHANGED
@@ -4,27 +4,27 @@
|
|
4
4
|
<head>
|
5
5
|
<meta charset="UTF-8">
|
6
6
|
|
7
|
-
<title>wwwjdic 16.
|
7
|
+
<title>wwwjdic 16.1.0</title>
|
8
8
|
|
9
9
|
<script type="text/javascript">
|
10
10
|
var rdoc_rel_prefix = "./";
|
11
11
|
var index_rel_prefix = "./";
|
12
12
|
</script>
|
13
13
|
|
14
|
-
<script src="./js/navigation.js"
|
15
|
-
<script src="./js/search.js"
|
16
|
-
<script src="./js/search_index.js"
|
17
|
-
<script src="./js/searcher.js"
|
18
|
-
<script src="./js/darkfish.js"
|
14
|
+
<script defer src="./js/navigation.js"></script>
|
15
|
+
<script defer src="./js/search.js"></script>
|
16
|
+
<script defer src="./js/search_index.js"></script>
|
17
|
+
<script defer src="./js/searcher.js"></script>
|
18
|
+
<script defer src="./js/darkfish.js"></script>
|
19
19
|
|
20
20
|
<link href="./css/fonts.css" rel="stylesheet">
|
21
21
|
<link href="./css/rdoc.css" rel="stylesheet">
|
22
22
|
|
23
23
|
|
24
|
-
<body id="top" role="document"
|
24
|
+
<body class="file" id="top" role="document">
|
25
25
|
<nav role="navigation">
|
26
26
|
<div id="project-navigation">
|
27
|
-
<div id="home-section" role="region" title="Quick navigation"
|
27
|
+
<div class="nav-section" id="home-section" role="region" title="Quick navigation">
|
28
28
|
<h2>
|
29
29
|
<a href="./index.html" rel="home">Home</a>
|
30
30
|
</h2>
|
@@ -37,26 +37,26 @@
|
|
37
37
|
</div>
|
38
38
|
|
39
39
|
|
40
|
-
<div
|
41
|
-
<form action="#" method="get"
|
40
|
+
<div class="project-section initially-hidden" id="search-section" role="search">
|
41
|
+
<form accept-charset="utf-8" action="#" method="get">
|
42
42
|
<div id="search-field-wrapper">
|
43
|
-
<input
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
<input aria-autocomplete="list" aria-controls="search-results" aria-label="Search"
|
44
|
+
id="search-field" name="search"
|
45
|
+
placeholder="Search" role="combobox" spellcheck="false" title="Type to search, Up and Down to navigate, Enter to load"
|
46
|
+
type="text">
|
47
47
|
</div>
|
48
48
|
|
49
|
-
<ul
|
50
|
-
aria-
|
51
|
-
|
49
|
+
<ul aria-atomic="false" aria-busy="false"
|
50
|
+
aria-expanded="false" aria-label="Search Results"
|
51
|
+
class="initially-hidden" id="search-results"></ul>
|
52
52
|
</form>
|
53
53
|
</div>
|
54
54
|
|
55
55
|
</div>
|
56
56
|
|
57
57
|
<div id="project-metadata">
|
58
|
-
|
59
|
-
<div
|
58
|
+
|
59
|
+
<div class="nav-section" id="fileindex-section">
|
60
60
|
<h3>Pages</h3>
|
61
61
|
|
62
62
|
<ul class="link-list">
|
@@ -69,7 +69,7 @@
|
|
69
69
|
</ul>
|
70
70
|
</div>
|
71
71
|
|
72
|
-
<div
|
72
|
+
<div class="nav-section" id="classindex-section">
|
73
73
|
<h3>Class and Module Index</h3>
|
74
74
|
|
75
75
|
<ul class="link-list">
|
@@ -100,7 +100,7 @@
|
|
100
100
|
<!--
|
101
101
|
wwwjdic
|
102
102
|
|
103
|
-
|
103
|
+
© 2014-2021 Marco Bresciani
|
104
104
|
|
105
105
|
This file is part of wwwjdic.
|
106
106
|
|
@@ -117,7 +117,7 @@ more details.
|
|
117
117
|
You should have received a copy of the GNU General Public License along
|
118
118
|
with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
119
119
|
|
120
|
-
SPDX-FileCopyrightText: 2014 Marco Bresciani
|
120
|
+
SPDX-FileCopyrightText: 2014-2021 Marco Bresciani
|
121
121
|
|
122
122
|
SPDX-License-Identifier: GFDL-1.3-or-later
|
123
123
|
-->
|
@@ -164,7 +164,7 @@ SPDX-License-Identifier: GFDL-1.3-or-later
|
|
164
164
|
|
165
165
|
<p><a href="WWWJDic.html"><code>WWWJDic</code></a> is an online Japanese translation server made by Jim Breen and available at <a href="http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic?1C">www.edrdg.org/cgi-bin/wwwjdic/wwwjdic?1C</a>.</p>
|
166
166
|
|
167
|
-
<p>Jim Breen's Japanese Page lists this gem: <a href="http://nihongo.monash.edu/japanese.html#links_software">nihongo.monash.edu/japanese.html#links_software</a
|
167
|
+
<p>Jim Breen's Japanese Page lists this gem: <a href="http://nihongo.monash.edu/japanese.html#links_software">nihongo.monash.edu/japanese.html#links_software</a> and has allowed the use of the same name.</p>
|
168
168
|
|
169
169
|
<p>GNU GPLv3 license; source code available through anonymous checkout: <code>hg clone http://hg.savannah.nongnu.org/hgweb/wwwjdic/</code> or write me, and I'll send it.</p>
|
170
170
|
|
@@ -176,7 +176,7 @@ SPDX-License-Identifier: GFDL-1.3-or-later
|
|
176
176
|
|
177
177
|
<p>RubyGems is the preferred easy install method for <a href="WWWJDic.html"><code>WWWJDic</code></a>. <a href="WWWJDic.html"><code>WWWJDic</code></a> should be installed via the <a href="http://rubyforge.org/projects/rubygems/">RubyGems</a> system. To get the latest version, simply enter the following into your command prompt: <code>gem install wwwjdic</code>.</p>
|
178
178
|
|
179
|
-
<p>Because <a href="WWWJDic.html"><code>WWWJDic</code></a> is pure Ruby, it should run pretty much anywhere, including Rubinius, JRuby, MacRuby, etc. Officially the support is for >=
|
179
|
+
<p>Because <a href="WWWJDic.html"><code>WWWJDic</code></a> is pure Ruby, it should run pretty much anywhere, including Rubinius, JRuby, MacRuby, etc. Officially the support is for >= 3.0 MJIT.</p>
|
180
180
|
|
181
181
|
<h4 id="label-Savannah">Savannah<span><a href="#label-Savannah">¶</a> <a href="#top">↑</a></span></h4>
|
182
182
|
<ul><li>
|
@@ -460,7 +460,7 @@ here.</pre>
|
|
460
460
|
|
461
461
|
<p>Please make your posts to the list as specific as possible, including code samples and output where relevant. Do not post any information that should not be shared publicly, and be sure to reduce your example code as much as possible so that those who are responding to your question can more easily see what the issue might be.</p>
|
462
462
|
|
463
|
-
<p>If you've found a bug, want to submit a patch, or have a feature request, please enter a ticket into our bug tracker: <code>https://savannah.nongnu.org/bugs/?func=additem&group=wwwjdic</code></p>
|
463
|
+
<p>If you've found a bug, want to submit a patch, or have a feature request, please enter a ticket into our bug tracker: <code>https://savannah.nongnu.org/bugs/?func=additem&group=wwwjdic</code></p>
|
464
464
|
|
465
465
|
<p>We strongly encourage adding bug reports with failing tests or at least a reduced example that demonstrates the problem.</p>
|
466
466
|
|
@@ -489,7 +489,6 @@ here.</pre>
|
|
489
489
|
|
490
490
|
<footer id="validator-badges" role="contentinfo">
|
491
491
|
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
492
|
-
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.3.
|
492
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.3.2.
|
493
493
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
494
494
|
</footer>
|
495
|
-
|
data/html/js/darkfish.js
CHANGED
@@ -1,84 +1,84 @@
|
|
1
|
-
/**
|
2
|
-
*
|
3
|
-
* Darkfish Page Functions
|
4
|
-
* $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
|
5
|
-
*
|
6
|
-
* Author: Michael Granger <mgranger@laika.com>
|
7
|
-
*
|
8
|
-
*/
|
9
|
-
|
10
|
-
/* Provide console simulation for firebug-less environments */
|
11
|
-
/*
|
12
|
-
if (!("console" in window) || !("firebug" in console)) {
|
13
|
-
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
|
14
|
-
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
15
|
-
|
16
|
-
window.console = {};
|
17
|
-
for (var i = 0; i < names.length; ++i)
|
18
|
-
window.console[names[i]] = function() {};
|
19
|
-
};
|
20
|
-
*/
|
21
|
-
|
22
|
-
|
23
|
-
function showSource( e ) {
|
24
|
-
var target = e.target;
|
25
|
-
while (!target.classList.contains('method-detail')) {
|
26
|
-
target = target.parentNode;
|
27
|
-
}
|
28
|
-
if (typeof target !== "undefined" && target !== null) {
|
29
|
-
target = target.querySelector('.method-source-code');
|
30
|
-
}
|
31
|
-
if (typeof target !== "undefined" && target !== null) {
|
32
|
-
target.classList.toggle('active-menu')
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
function hookSourceViews() {
|
37
|
-
document.querySelectorAll('.method-heading').forEach(function (codeObject) {
|
38
|
-
codeObject.addEventListener('click', showSource);
|
39
|
-
});
|
40
|
-
}
|
41
|
-
|
42
|
-
function hookSearch() {
|
43
|
-
var input = document.querySelector('#search-field');
|
44
|
-
var result = document.querySelector('#search-results');
|
45
|
-
result.classList.remove("initially-hidden");
|
46
|
-
|
47
|
-
var search_section = document.querySelector('#search-section');
|
48
|
-
search_section.classList.remove("initially-hidden");
|
49
|
-
|
50
|
-
var search = new Search(search_data, input, result);
|
51
|
-
|
52
|
-
search.renderItem = function(result) {
|
53
|
-
var li = document.createElement('li');
|
54
|
-
var html = '';
|
55
|
-
|
56
|
-
// TODO add relative path to <script> per-page
|
57
|
-
html += '<p class="search-match"><a href="' + index_rel_prefix + result.path + '">' + this.hlt(result.title);
|
58
|
-
if (result.params)
|
59
|
-
html += '<span class="params">' + result.params + '</span>';
|
60
|
-
html += '</a>';
|
61
|
-
|
62
|
-
|
63
|
-
if (result.namespace)
|
64
|
-
html += '<p class="search-namespace">' + this.hlt(result.namespace);
|
65
|
-
|
66
|
-
if (result.snippet)
|
67
|
-
html += '<div class="search-snippet">' + result.snippet + '</div>';
|
68
|
-
|
69
|
-
li.innerHTML = html;
|
70
|
-
|
71
|
-
return li;
|
72
|
-
}
|
73
|
-
|
74
|
-
search.select = function(result) {
|
75
|
-
window.location.href = result.firstChild.firstChild.href;
|
76
|
-
}
|
77
|
-
|
78
|
-
search.scrollIntoView = search.scrollInWindow;
|
79
|
-
}
|
80
|
-
|
81
|
-
document.addEventListener('DOMContentLoaded', function() {
|
82
|
-
hookSourceViews();
|
83
|
-
hookSearch();
|
84
|
-
});
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Darkfish Page Functions
|
4
|
+
* $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
|
5
|
+
*
|
6
|
+
* Author: Michael Granger <mgranger@laika.com>
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
/* Provide console simulation for firebug-less environments */
|
11
|
+
/*
|
12
|
+
if (!("console" in window) || !("firebug" in console)) {
|
13
|
+
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
|
14
|
+
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
15
|
+
|
16
|
+
window.console = {};
|
17
|
+
for (var i = 0; i < names.length; ++i)
|
18
|
+
window.console[names[i]] = function() {};
|
19
|
+
};
|
20
|
+
*/
|
21
|
+
|
22
|
+
|
23
|
+
function showSource( e ) {
|
24
|
+
var target = e.target;
|
25
|
+
while (!target.classList.contains('method-detail')) {
|
26
|
+
target = target.parentNode;
|
27
|
+
}
|
28
|
+
if (typeof target !== "undefined" && target !== null) {
|
29
|
+
target = target.querySelector('.method-source-code');
|
30
|
+
}
|
31
|
+
if (typeof target !== "undefined" && target !== null) {
|
32
|
+
target.classList.toggle('active-menu')
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
function hookSourceViews() {
|
37
|
+
document.querySelectorAll('.method-heading').forEach(function (codeObject) {
|
38
|
+
codeObject.addEventListener('click', showSource);
|
39
|
+
});
|
40
|
+
}
|
41
|
+
|
42
|
+
function hookSearch() {
|
43
|
+
var input = document.querySelector('#search-field');
|
44
|
+
var result = document.querySelector('#search-results');
|
45
|
+
result.classList.remove("initially-hidden");
|
46
|
+
|
47
|
+
var search_section = document.querySelector('#search-section');
|
48
|
+
search_section.classList.remove("initially-hidden");
|
49
|
+
|
50
|
+
var search = new Search(search_data, input, result);
|
51
|
+
|
52
|
+
search.renderItem = function(result) {
|
53
|
+
var li = document.createElement('li');
|
54
|
+
var html = '';
|
55
|
+
|
56
|
+
// TODO add relative path to <script> per-page
|
57
|
+
html += '<p class="search-match"><a href="' + index_rel_prefix + result.path + '">' + this.hlt(result.title);
|
58
|
+
if (result.params)
|
59
|
+
html += '<span class="params">' + result.params + '</span>';
|
60
|
+
html += '</a>';
|
61
|
+
|
62
|
+
|
63
|
+
if (result.namespace)
|
64
|
+
html += '<p class="search-namespace">' + this.hlt(result.namespace);
|
65
|
+
|
66
|
+
if (result.snippet)
|
67
|
+
html += '<div class="search-snippet">' + result.snippet + '</div>';
|
68
|
+
|
69
|
+
li.innerHTML = html;
|
70
|
+
|
71
|
+
return li;
|
72
|
+
}
|
73
|
+
|
74
|
+
search.select = function(result) {
|
75
|
+
window.location.href = result.firstChild.firstChild.href;
|
76
|
+
}
|
77
|
+
|
78
|
+
search.scrollIntoView = search.scrollInWindow;
|
79
|
+
}
|
80
|
+
|
81
|
+
document.addEventListener('DOMContentLoaded', function() {
|
82
|
+
hookSourceViews();
|
83
|
+
hookSearch();
|
84
|
+
});
|
data/html/js/navigation.js.gz
CHANGED
Binary file
|
data/html/js/search.js
CHANGED
@@ -1,110 +1,109 @@
|
|
1
|
-
Search = function(data, input, result) {
|
2
|
-
this.data = data;
|
3
|
-
this.input = input;
|
4
|
-
this.result = result;
|
5
|
-
|
6
|
-
this.current = null;
|
7
|
-
this.view = this.result.parentNode;
|
8
|
-
this.searcher = new Searcher(data.index);
|
9
|
-
this.init();
|
10
|
-
}
|
11
|
-
|
12
|
-
Search.prototype = Object.assign({}, Navigation, new function() {
|
13
|
-
var suid = 1;
|
14
|
-
|
15
|
-
this.init = function() {
|
16
|
-
var _this = this;
|
17
|
-
var observer = function(e) {
|
18
|
-
switch(e.keyCode) {
|
19
|
-
case 38: // Event.KEY_UP
|
20
|
-
case 40: // Event.KEY_DOWN
|
21
|
-
return;
|
22
|
-
}
|
23
|
-
_this.search(_this.input.value);
|
24
|
-
};
|
25
|
-
this.input.addEventListener('keyup', observer);
|
26
|
-
this.input.addEventListener('click', observer); // mac's clear field
|
27
|
-
|
28
|
-
this.searcher.ready(function(results, isLast) {
|
29
|
-
_this.addResults(results, isLast);
|
30
|
-
})
|
31
|
-
|
32
|
-
this.initNavigation();
|
33
|
-
this.setNavigationActive(false);
|
34
|
-
}
|
35
|
-
|
36
|
-
this.search = function(value, selectFirstMatch) {
|
37
|
-
value = value.trim().toLowerCase();
|
38
|
-
if (value) {
|
39
|
-
this.setNavigationActive(true);
|
40
|
-
} else {
|
41
|
-
this.setNavigationActive(false);
|
42
|
-
}
|
43
|
-
|
44
|
-
if (value == '') {
|
45
|
-
this.lastQuery = value;
|
46
|
-
this.result.innerHTML = '';
|
47
|
-
this.result.setAttribute('aria-expanded', 'false');
|
48
|
-
this.setNavigationActive(false);
|
49
|
-
} else if (value != this.lastQuery) {
|
50
|
-
this.lastQuery = value;
|
51
|
-
this.result.setAttribute('aria-busy', 'true');
|
52
|
-
this.result.setAttribute('aria-expanded', 'true');
|
53
|
-
this.firstRun = true;
|
54
|
-
this.searcher.find(value);
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
this.addResults = function(results, isLast) {
|
59
|
-
var target = this.result;
|
60
|
-
if (this.firstRun && (results.length > 0 || isLast)) {
|
61
|
-
this.current = null;
|
62
|
-
this.result.innerHTML = '';
|
63
|
-
}
|
64
|
-
|
65
|
-
for (var i=0, l = results.length; i < l; i++) {
|
66
|
-
var item = this.renderItem.call(this, results[i]);
|
67
|
-
item.setAttribute('id', 'search-result-' + target.childElementCount);
|
68
|
-
target.appendChild(item);
|
69
|
-
}
|
70
|
-
|
71
|
-
if (this.firstRun && results.length > 0) {
|
72
|
-
this.firstRun = false;
|
73
|
-
this.current = target.firstChild;
|
74
|
-
this.current.classList.add('search-selected');
|
75
|
-
}
|
76
|
-
//TODO: ECMAScript
|
77
|
-
//if (jQuery.browser.msie) this.$element[0].className += '';
|
78
|
-
|
79
|
-
if (isLast) this.result.setAttribute('aria-busy', 'false');
|
80
|
-
}
|
81
|
-
|
82
|
-
this.move = function(isDown) {
|
83
|
-
if (!this.current) return;
|
84
|
-
var next = isDown ? this.current.nextElementSibling : this.current.previousElementSibling;
|
85
|
-
if (next) {
|
86
|
-
this.current.classList.remove('search-selected');
|
87
|
-
next.classList.add('search-selected');
|
88
|
-
this.input.setAttribute('aria-activedescendant', next.getAttribute('id'));
|
89
|
-
this.scrollIntoView(next, this.view);
|
90
|
-
this.current = next;
|
91
|
-
this.input.value = next.firstChild.firstChild.text;
|
92
|
-
this.input.select();
|
93
|
-
}
|
94
|
-
return true;
|
95
|
-
}
|
96
|
-
|
97
|
-
this.hlt = function(html) {
|
98
|
-
return this.escapeHTML(html).
|
99
|
-
replace(/\u0001/g, '<em>').
|
100
|
-
replace(/\u0002/g, '</em>');
|
101
|
-
}
|
102
|
-
|
103
|
-
this.escapeHTML = function(html) {
|
104
|
-
return html.replace(/[&<>]/g, function(c) {
|
105
|
-
return '&#' + c.charCodeAt(0) + ';';
|
106
|
-
});
|
107
|
-
}
|
108
|
-
|
109
|
-
});
|
110
|
-
|
1
|
+
Search = function(data, input, result) {
|
2
|
+
this.data = data;
|
3
|
+
this.input = input;
|
4
|
+
this.result = result;
|
5
|
+
|
6
|
+
this.current = null;
|
7
|
+
this.view = this.result.parentNode;
|
8
|
+
this.searcher = new Searcher(data.index);
|
9
|
+
this.init();
|
10
|
+
}
|
11
|
+
|
12
|
+
Search.prototype = Object.assign({}, Navigation, new function() {
|
13
|
+
var suid = 1;
|
14
|
+
|
15
|
+
this.init = function() {
|
16
|
+
var _this = this;
|
17
|
+
var observer = function(e) {
|
18
|
+
switch(e.keyCode) {
|
19
|
+
case 38: // Event.KEY_UP
|
20
|
+
case 40: // Event.KEY_DOWN
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
_this.search(_this.input.value);
|
24
|
+
};
|
25
|
+
this.input.addEventListener('keyup', observer);
|
26
|
+
this.input.addEventListener('click', observer); // mac's clear field
|
27
|
+
|
28
|
+
this.searcher.ready(function(results, isLast) {
|
29
|
+
_this.addResults(results, isLast);
|
30
|
+
})
|
31
|
+
|
32
|
+
this.initNavigation();
|
33
|
+
this.setNavigationActive(false);
|
34
|
+
}
|
35
|
+
|
36
|
+
this.search = function(value, selectFirstMatch) {
|
37
|
+
value = value.trim().toLowerCase();
|
38
|
+
if (value) {
|
39
|
+
this.setNavigationActive(true);
|
40
|
+
} else {
|
41
|
+
this.setNavigationActive(false);
|
42
|
+
}
|
43
|
+
|
44
|
+
if (value == '') {
|
45
|
+
this.lastQuery = value;
|
46
|
+
this.result.innerHTML = '';
|
47
|
+
this.result.setAttribute('aria-expanded', 'false');
|
48
|
+
this.setNavigationActive(false);
|
49
|
+
} else if (value != this.lastQuery) {
|
50
|
+
this.lastQuery = value;
|
51
|
+
this.result.setAttribute('aria-busy', 'true');
|
52
|
+
this.result.setAttribute('aria-expanded', 'true');
|
53
|
+
this.firstRun = true;
|
54
|
+
this.searcher.find(value);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
this.addResults = function(results, isLast) {
|
59
|
+
var target = this.result;
|
60
|
+
if (this.firstRun && (results.length > 0 || isLast)) {
|
61
|
+
this.current = null;
|
62
|
+
this.result.innerHTML = '';
|
63
|
+
}
|
64
|
+
|
65
|
+
for (var i=0, l = results.length; i < l; i++) {
|
66
|
+
var item = this.renderItem.call(this, results[i]);
|
67
|
+
item.setAttribute('id', 'search-result-' + target.childElementCount);
|
68
|
+
target.appendChild(item);
|
69
|
+
}
|
70
|
+
|
71
|
+
if (this.firstRun && results.length > 0) {
|
72
|
+
this.firstRun = false;
|
73
|
+
this.current = target.firstChild;
|
74
|
+
this.current.classList.add('search-selected');
|
75
|
+
}
|
76
|
+
//TODO: ECMAScript
|
77
|
+
//if (jQuery.browser.msie) this.$element[0].className += '';
|
78
|
+
|
79
|
+
if (isLast) this.result.setAttribute('aria-busy', 'false');
|
80
|
+
}
|
81
|
+
|
82
|
+
this.move = function(isDown) {
|
83
|
+
if (!this.current) return;
|
84
|
+
var next = isDown ? this.current.nextElementSibling : this.current.previousElementSibling;
|
85
|
+
if (next) {
|
86
|
+
this.current.classList.remove('search-selected');
|
87
|
+
next.classList.add('search-selected');
|
88
|
+
this.input.setAttribute('aria-activedescendant', next.getAttribute('id'));
|
89
|
+
this.scrollIntoView(next, this.view);
|
90
|
+
this.current = next;
|
91
|
+
this.input.value = next.firstChild.firstChild.text;
|
92
|
+
this.input.select();
|
93
|
+
}
|
94
|
+
return true;
|
95
|
+
}
|
96
|
+
|
97
|
+
this.hlt = function(html) {
|
98
|
+
return this.escapeHTML(html).
|
99
|
+
replace(/\u0001/g, '<em>').
|
100
|
+
replace(/\u0002/g, '</em>');
|
101
|
+
}
|
102
|
+
|
103
|
+
this.escapeHTML = function(html) {
|
104
|
+
return html.replace(/[&<>]/g, function(c) {
|
105
|
+
return '&#' + c.charCodeAt(0) + ';';
|
106
|
+
});
|
107
|
+
}
|
108
|
+
|
109
|
+
});
|