wwwjdic 13.0.1 → 16.1.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/CHANGELOG +60 -1
- data/Gemfile +7 -1
- data/README.md +500 -225
- data/Rakefile +10 -3
- data/copyright.md +17 -29
- data/examples/basics.rb +53 -45
- data/examples/translate.rb +159 -86
- data/examples/uri.rb +46 -78
- data/html/CHANGELOG.html +90 -35
- data/html/COPYING_md.html +26 -38
- data/html/Gemfile.html +25 -35
- data/html/Object.html +838 -74
- data/html/README_md.html +322 -175
- data/html/Rakefile.html +28 -38
- data/html/WWWJDic.html +63 -104
- data/html/WWWJDic/ParsableDuckType.html +38 -58
- data/html/WWWJDic/Parser.html +52 -92
- data/html/WWWJDic/Parsers.html +29 -35
- data/html/WWWJDic/Parsers/Dict.html +50 -76
- data/html/WWWJDic/Parsers/Display.html +45 -69
- data/html/WWWJDic/Parsers/Key.html +46 -70
- data/html/WWWJDic/Parsers/Search.html +41 -61
- data/html/WWWJDic/Parsers/Server.html +45 -69
- data/html/WWWJDic/Splitter.html +81 -175
- data/html/WWWJDic/Utils.html +30 -36
- data/html/WWWJDic/Utils/Downloader.html +41 -41
- data/html/WWWJDic/Utils/Downloader/Downloader.html +65 -92
- data/html/WWWJDic/Utils/Raisers.html +46 -98
- data/html/WWWJDic/WWWJDic.html +166 -348
- data/html/copyright_md.html +219 -239
- data/html/created.rid +33 -58
- data/html/css/rdoc.css +638 -590
- data/html/index.html +313 -182
- data/html/js/darkfish.js +84 -161
- data/html/js/navigation.js +4 -40
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +109 -109
- 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 +161 -200
- data/lib/wwwjdic.rb +14 -15
- data/lib/wwwjdic/application.rb +68 -36
- data/lib/wwwjdic/constants.rb +56 -12
- data/lib/wwwjdic/locales/de.yml +9 -4
- data/lib/wwwjdic/locales/en.yml +9 -4
- data/lib/wwwjdic/locales/es.yml +9 -4
- data/lib/wwwjdic/locales/fr.yml +9 -4
- data/lib/wwwjdic/locales/hu.yml +9 -4
- data/lib/wwwjdic/locales/it.yml +9 -4
- data/lib/wwwjdic/locales/ja.yml +11 -5
- data/lib/wwwjdic/locales/nl.yml +9 -4
- data/lib/wwwjdic/locales/ru.yml +9 -4
- data/lib/wwwjdic/locales/sl.yml +9 -4
- data/lib/wwwjdic/locales/sv.yml +9 -4
- data/lib/wwwjdic/parser.rb +13 -8
- data/lib/wwwjdic/parsers/dict.rb +11 -8
- data/lib/wwwjdic/parsers/display.rb +8 -3
- data/lib/wwwjdic/parsers/key.rb +9 -3
- data/lib/wwwjdic/parsers/search.rb +10 -3
- data/lib/wwwjdic/parsers/server.rb +8 -3
- data/lib/wwwjdic/utils/downloader.rb +37 -34
- data/lib/wwwjdic/utils/raisers.rb +12 -15
- data/lib/wwwjdic/utils/splitter.rb +32 -18
- data/lib/wwwjdic/version.rb +22 -8
- data/test/test_helper.rb +10 -1
- data/test/test_wwwjdic.rb +10 -4
- data/test/wwwjdic/locales/de.yml +9 -1
- data/test/wwwjdic/locales/en.yml +9 -1
- data/test/wwwjdic/locales/es.yml +9 -1
- data/test/wwwjdic/locales/fr.yml +9 -1
- data/test/wwwjdic/locales/hu.yml +9 -1
- data/test/wwwjdic/locales/it.yml +10 -1
- data/test/wwwjdic/locales/ja.yml +11 -2
- data/test/wwwjdic/locales/nl.yml +9 -1
- data/test/wwwjdic/locales/ru.yml +9 -1
- data/test/wwwjdic/locales/sl.yml +9 -1
- data/test/wwwjdic/locales/sv.yml +9 -1
- data/test/wwwjdic/locales/test_locales.rb +41 -24
- data/test/wwwjdic/parsers/test_dict.rb +65 -37
- data/test/wwwjdic/parsers/test_display.rb +11 -5
- data/test/wwwjdic/parsers/test_key.rb +10 -4
- data/test/wwwjdic/parsers/test_server.rb +11 -5
- data/test/wwwjdic/test_application.rb +199 -149
- data/test/wwwjdic/test_parsable_duck_type.rb +9 -5
- data/test/wwwjdic/utils/test_downloader.rb +7 -1
- data/test/wwwjdic/utils/test_raisers.rb +46 -29
- data/wwwjdic.gemspec +44 -26
- metadata +55 -43
- data/acknowledgements.md +0 -55
- data/authors.md +0 -67
- data/html/acknowledgements_md.html +0 -149
- data/html/authors_md.html +0 -181
- data/html/js/jquery.js +0 -4
- data/html/wwwjdic_gemspec.html +0 -161
data/html/js/search_index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var search_data = {"index":{"searchIndex":["object","wwwjdic","parsableducktype","parser","parsers","dict","display","key","search","server","splitter","utils","downloader","downloader","raisers","wwwjdic","breener()","content()","dictionary()","dictionary=()","download_file()","json_translate()","json_uri()","lines()","load_yaml_file()","message()","new()","new()","new()","parse()","parse()","parse()","parse()","parse()","parse()","raiser_array()","raiser_downcase()","raiser_to_i()","raw_uri()","reset()","server()","server=()","test_parsable_duck_type()","title()","to_s()","translate()","translation()","uri()","changelog","copying","gemfile","readme","rakefile","acknowledgements","authors","copyright","wwwjdic.gemspec"],"longSearchIndex":["object","wwwjdic","wwwjdic::parsableducktype","wwwjdic::parser","wwwjdic::parsers","wwwjdic::parsers::dict","wwwjdic::parsers::display","wwwjdic::parsers::key","wwwjdic::parsers::search","wwwjdic::parsers::server","wwwjdic::splitter","wwwjdic::utils","wwwjdic::utils::downloader","wwwjdic::utils::downloader::downloader","wwwjdic::utils::raisers","wwwjdic::wwwjdic","wwwjdic::breener()","wwwjdic::splitter#content()","wwwjdic::wwwjdic#dictionary()","wwwjdic::wwwjdic#dictionary=()","wwwjdic::utils::downloader::downloader::download_file()","wwwjdic::wwwjdic#json_translate()","wwwjdic::wwwjdic#json_uri()","wwwjdic::splitter#lines()","object#load_yaml_file()","wwwjdic::splitter#message()","wwwjdic::parser::new()","wwwjdic::splitter::new()","wwwjdic::wwwjdic::new()","wwwjdic::parser#parse()","wwwjdic::parsers::dict#parse()","wwwjdic::parsers::display#parse()","wwwjdic::parsers::key#parse()","wwwjdic::parsers::search#parse()","wwwjdic::parsers::server#parse()","wwwjdic::utils::raisers#raiser_array()","wwwjdic::utils::raisers#raiser_downcase()","wwwjdic::utils::raisers#raiser_to_i()","wwwjdic::wwwjdic#raw_uri()","wwwjdic::wwwjdic#reset()","wwwjdic::wwwjdic#server()","wwwjdic::wwwjdic#server=()","wwwjdic::parsableducktype#test_parsable_duck_type()","wwwjdic::splitter#title()","wwwjdic::wwwjdic#to_s()","wwwjdic::wwwjdic#translate()","wwwjdic::splitter#translation()","wwwjdic::wwwjdic#uri()","","","","","","","","",""],"info":[["Object","","Object.html","",""],["WWWJDic","","WWWJDic.html","","<p>Author — Marco Bresciani\n<p>Copyright — Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani\n<p>License … — "],["WWWJDic::ParsableDuckType","","WWWJDic/ParsableDuckType.html","","<p>This module represents the parsable duck type element for testing purposes.\n<p>Author — Marco Bresciani\n<p>Copyright … — "],["WWWJDic::Parser","","WWWJDic/Parser.html","","<p>This class is a simple utility that is used to parse and filter parameters for wwwjdic.\n<p>Author — Marco Bresciani …\n"],["WWWJDic::Parsers","","WWWJDic/Parsers.html","",""],["WWWJDic::Parsers::Dict","","WWWJDic/Parsers/Dict.html","","<p>This class is an implementation of the Parsable duck type that checks the dictionary type. The only needed …\n"],["WWWJDic::Parsers::Display","","WWWJDic/Parsers/Display.html","","<p>This class is an implementation of the Parsable duck type that checks the display type. The only needed …\n"],["WWWJDic::Parsers::Key","","WWWJDic/Parsers/Key.html","","<p>This class is an implementation of the Parsable duck type that checks the display type. The only needed …\n"],["WWWJDic::Parsers::Search","","WWWJDic/Parsers/Search.html","","<p>This class is an implementation of the Parsable duck type that checks the display type. The only needed …\n"],["WWWJDic::Parsers::Server","","WWWJDic/Parsers/Server.html","","<p>This class is an implementation of the Parsable duck type that checks the display type. The only needed …\n"],["WWWJDic::Splitter","","WWWJDic/Splitter.html","","<p>This class is a simple API to interact with WWWJDic Backboor Entry/API.\n<p>Author — Marco Bresciani\n<p>Copyright … — "],["WWWJDic::Utils","","WWWJDic/Utils.html","","<p>This module is a simple collection of useful things and methods that I prefer to keep as DRYer as possible. …\n"],["WWWJDic::Utils::Downloader","","WWWJDic/Utils/Downloader.html","","<p>This module is a simple wrapper container for Peter R. Marreck's gist.\n<p>Author — Jon Maken\n<p>License — 3-clause …\n"],["WWWJDic::Utils::Downloader::Downloader","","WWWJDic/Utils/Downloader/Downloader.html","","<p>!/usr/bin/env ruby\n\n<pre>An HTTP/HTTPS/FTP file downloader library/CLI based upon\nMiniPortile's HTTP implementation. ...</pre>\n"],["WWWJDic::Utils::Raisers","","WWWJDic/Utils/Raisers.html","","<p>This module contains some utility method to raise errors according to (possibly) common conditions.\n<p>Author … — "],["WWWJDic::WWWJDic","","WWWJDic/WWWJDic.html","","<p>This class is a simple API to interact with WWWJDic Backboor Entry/API.\n<p>Author — Marco Bresciani\n<p>Copyright … — "],["breener","WWWJDic","WWWJDic.html#method-c-breener","()","<p>Creates a new WWWJDic object (from the verb 'to Breen'… :) ).\n<p>Usage — <p><code>new_wwwjdic = WWWJDic::breener</code> …\n\n"],["content","WWWJDic::Splitter","WWWJDic/Splitter.html#method-i-content","()",""],["dictionary","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-dictionary","()","<p>Return the default used dictionary string, if any.\n<p>Returns — a String with the dictionary full name.\n\n"],["dictionary=","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-dictionary-3D","(dict)","<p>Configure the default used dictionary using either code/number or (exact) string.\n<p>Usage — <tt>new_wwwjdic.dictionary= …\n"],["download_file","WWWJDic::Utils::Downloader::Downloader","WWWJDic/Utils/Downloader/Downloader.html#method-c-download_file","(url, full_path, count = 3)",""],["json_translate","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-json_translate","(word = nil, args = {}, filename = nil)","<p>Save a file, with specified <code>filename</code>, that contains the current wwwjdic configuration, in JSON format. …\n"],["json_uri","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-json_uri","(word = nil, args = {})","<p>Create the reference uri for a <code>word</code> translation, according to specified parameters, with JSON output. …\n"],["lines","WWWJDic::Splitter","WWWJDic/Splitter.html#method-i-lines","()",""],["load_yaml_file","Object","Object.html#method-i-load_yaml_file","(locale)",""],["message","WWWJDic::Splitter","WWWJDic/Splitter.html#method-i-message","()",""],["new","WWWJDic::Parser","WWWJDic/Parser.html#method-c-new","(args = {})",""],["new","WWWJDic::Splitter","WWWJDic/Splitter.html#method-c-new","(translation)","<p>Creates a <code>Splitter</code> object.\n<p>Usage — <code>new_splitter = Splitter.new translation_content</code>\n<p>Returns — a <code>Splitter</code> object. …\n"],["new","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-c-new","(parser)","<p>Creates a <code>WWWJDic</code> object. This constructor should be used through the WWWJDic::breener method only.\n<p>Usage … — "],["parse","WWWJDic::Parser","WWWJDic/Parser.html#method-i-parse","(method = nil, value = nil)","<p>Provides the duck type for a generic parsing object.\n"],["parse","WWWJDic::Parsers::Dict","WWWJDic/Parsers/Dict.html#method-i-parse","(value = '1')","<p>The parsable duck type interface to every parser usage.\n"],["parse","WWWJDic::Parsers::Display","WWWJDic/Parsers/Display.html#method-i-parse","(value = :display)","<p>The parsable duck type interface to every parser usage.\n"],["parse","WWWJDic::Parsers::Key","WWWJDic/Parsers/Key.html#method-i-parse","(value = :exact)","<p>The parsable duck type interface to every parser usage.\n"],["parse","WWWJDic::Parsers::Search","WWWJDic/Parsers/Search.html#method-i-parse","(value = '')","<p>The parsable duck type interface to every parser usage.\n"],["parse","WWWJDic::Parsers::Server","WWWJDic/Parsers/Server.html#method-i-parse","(value = :edrdg)","<p>The parsable duck type interface to every parser usage.\n"],["raiser_array","WWWJDic::Utils::Raisers","WWWJDic/Utils/Raisers.html#method-i-raiser_array","(name = 'error.value', value = nil, array = nil)","<p>Raises an <code>ArgumentError</code> according to parameters, unless the <code>array</code> contains the exact <code>value</code>.\n"],["raiser_downcase","WWWJDic::Utils::Raisers","WWWJDic/Utils/Raisers.html#method-i-raiser_downcase","(name = 'error.value', value = nil, array = nil)","<p>Raises an <code>ArgumentError</code> according to parameters, unless the <code>array</code> contains a downcased <code>value</code>.\n"],["raiser_to_i","WWWJDic::Utils::Raisers","WWWJDic/Utils/Raisers.html#method-i-raiser_to_i","(name = 'error.value', value = nil, array = nil)","<p>Raises an <code>ArgumentError</code> according to parameters, unless the <code>array</code> contains the number of the <code>value</code>.\n"],["raw_uri","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-raw_uri","(word = nil, args = {})","<p>Create the reference uri for a <code>word</code> translation, according to specified parameters, overriding for raw …\n"],["reset","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-reset","()","<p>Restores the original status cleaning up the (possibly) previously saved URIs restoring the default …\n"],["server","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-server","()","<p>Return the selected server URI\n<p>Returns — a String with the dictionary full name.\n\n"],["server=","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-server-3D","(server = :edrdg)","<p>Store the Backdoor Entry/API server name, default to EDRDG.Org (:edrdg) instead of Monash (:monash). …\n"],["test_parsable_duck_type","WWWJDic::ParsableDuckType","WWWJDic/ParsableDuckType.html#method-i-test_parsable_duck_type","()","<p>The method that tests the parsable duck type interface and its <code>parse</code> method.\n"],["title","WWWJDic::Splitter","WWWJDic/Splitter.html#method-i-title","()",""],["to_s","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-to_s","()",""],["translate","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-translate","(word = nil, args = {}, filename = nil)","<p>Save a file, with specified <code>filename</code>, that contains the current wwwjdic configuration. Uses the internal …\n"],["translation","WWWJDic::Splitter","WWWJDic/Splitter.html#method-i-translation","()",""],["uri","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-uri","(word = nil, args = {})","<p>Create the reference uri for a <code>word</code> translation, according to specified parameters.\n<p>Usage — <tt>new_wwwjdic.uri …\n\n"],["CHANGELOG","","CHANGELOG.html","","<p>Version 13.0.1\n\n<pre>* PATCH updating gem dependencies.\n* IN PROGRESS: translation example.\n* IN PROGRESS: restoring ...</pre>\n"],["COPYING","","COPYING_md.html","","<p>GNU GENERAL PUBLIC LICENSE\n<p>Version 3, 29 June 2007\n<p>Copyright (C) 2007 Free Software Foundation, Inc.\nfsf.org ...\n"],["Gemfile","","Gemfile.html","","<p># wwwjdic # Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani # # This file is part of …\n"],["README","","README_md.html","","<p>WWWJDic\n<p><img src=\"https://img.shields.io/gem/v/wwwjdic.svg?style=plastic\">\n<img src=\"https://img.shields.io/gem/dt/wwwjdic.svg?style=plastic\"> ...\n"],["Rakefile","","Rakefile.html","","<p># wwwjdic # Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani # # This file is part of …\n"],["acknowledgements","","acknowledgements_md.html","","<p>Acknowledgements\n<p>FSIJ理事会の理事長、新部裕さんの日本語の翻訳。 Japanese translation by\nYutaka Niibe, President of Free Software ...\n"],["authors","","authors_md.html","","<p>Project and gem owned by\n<p><em>Author</em>: Marco Bresciani\n\n<p>Authors list (in appearing order)\n"],["copyright","","copyright_md.html","","<p>Copyright Notes\n<p>2019-02-26 update.\n<p>wwwjdic\n"],["wwwjdic.gemspec","","wwwjdic_gemspec.html","","<p># wwwjdic # Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani # # This file is part of …\n"]]}}
|
1
|
+
var search_data = {"index":{"searchIndex":["object","wwwjdic","parsableducktype","parser","parsers","dict","display","key","search","server","splitter","utils","downloader","downloader","raisers","wwwjdic","breener()","content()","dictionary()","dictionary=()","download_file()","json_translate()","json_uri()","lines()","load_yaml_file()","message()","new()","new()","new()","parse()","parse()","parse()","parse()","parse()","parse()","parser()","raiser_array()","raiser_downcase()","raiser_to_i()","raw_uri()","reset()","server()","server=()","test_ask_translation()","test_ask_uri()","test_dictionary_code()","test_dictionary_name()","test_en_it()","test_get_dictionary()","test_get_translation()","test_invalid_param()","test_invalid_parameter()","test_invalid_server()","test_multilanguage()","test_multiple_languages()","test_no_raise()","test_one_locale()","test_override_custom_params()","test_parsable_duck_type()","test_raise()","test_raise_error_param()","test_raise_invalid_server_error()","test_raiser()","test_return_json()","test_return_test_reference()","test_select_server()","test_server()","test_translation()","test_wrong_code()","test_wrong_name()","title()","to_s()","translate()","translation()","uri()","changelog","copying","gemfile","readme","rakefile","copyright"],"longSearchIndex":["object","wwwjdic","wwwjdic::parsableducktype","wwwjdic::parser","wwwjdic::parsers","wwwjdic::parsers::dict","wwwjdic::parsers::display","wwwjdic::parsers::key","wwwjdic::parsers::search","wwwjdic::parsers::server","wwwjdic::splitter","wwwjdic::utils","wwwjdic::utils::downloader","wwwjdic::utils::downloader::downloader","wwwjdic::utils::raisers","wwwjdic::wwwjdic","wwwjdic::breener()","wwwjdic::splitter#content()","wwwjdic::wwwjdic#dictionary()","wwwjdic::wwwjdic#dictionary=()","wwwjdic::utils::downloader::downloader::download_file()","wwwjdic::wwwjdic#json_translate()","wwwjdic::wwwjdic#json_uri()","wwwjdic::splitter#lines()","object#load_yaml_file()","wwwjdic::splitter#message()","wwwjdic::parser::new()","wwwjdic::splitter::new()","wwwjdic::wwwjdic::new()","wwwjdic::parser#parse()","wwwjdic::parsers::dict#parse()","wwwjdic::parsers::display#parse()","wwwjdic::parsers::key#parse()","wwwjdic::parsers::search#parse()","wwwjdic::parsers::server#parse()","wwwjdic::parser()","wwwjdic::utils::raisers#raiser_array()","wwwjdic::utils::raisers#raiser_downcase()","wwwjdic::utils::raisers#raiser_to_i()","wwwjdic::wwwjdic#raw_uri()","wwwjdic::wwwjdic#reset()","wwwjdic::wwwjdic#server()","wwwjdic::wwwjdic#server=()","object#test_ask_translation()","object#test_ask_uri()","object#test_dictionary_code()","object#test_dictionary_name()","object#test_en_it()","object#test_get_dictionary()","object#test_get_translation()","object#test_invalid_param()","object#test_invalid_parameter()","object#test_invalid_server()","object#test_multilanguage()","object#test_multiple_languages()","object#test_no_raise()","object#test_one_locale()","object#test_override_custom_params()","wwwjdic::parsableducktype#test_parsable_duck_type()","object#test_raise()","object#test_raise_error_param()","object#test_raise_invalid_server_error()","object#test_raiser()","object#test_return_json()","object#test_return_test_reference()","object#test_select_server()","object#test_server()","object#test_translation()","object#test_wrong_code()","object#test_wrong_name()","wwwjdic::splitter#title()","wwwjdic::wwwjdic#to_s()","wwwjdic::wwwjdic#translate()","wwwjdic::splitter#translation()","wwwjdic::wwwjdic#uri()","","","","","",""],"info":[["Object","","Object.html","",""],["WWWJDic","","WWWJDic.html","","<p>Author — Marco Bresciani\n<p>Copyright — © 2014-2021 Marco Bresciani\n<p>License — GNU General Public License version …\n"],["WWWJDic::ParsableDuckType","","WWWJDic/ParsableDuckType.html","","<p>This module represents the parsable duck type element for testing purposes.\n<p>Author — Marco Bresciani\n<p>Copyright … — "],["WWWJDic::Parser","","WWWJDic/Parser.html","","<p>This class is a simple utility that is used to parse and filter parameters for wwwjdic.\n<p>Author — Marco Bresciani …\n"],["WWWJDic::Parsers","","WWWJDic/Parsers.html","",""],["WWWJDic::Parsers::Dict","","WWWJDic/Parsers/Dict.html","","<p>This class is an implementation of the Parsable duck type that checks the dictionary type. The only needed …\n"],["WWWJDic::Parsers::Display","","WWWJDic/Parsers/Display.html","","<p>This class is an implementation of the Parsable duck type that checks the display type. The only needed …\n"],["WWWJDic::Parsers::Key","","WWWJDic/Parsers/Key.html","","<p>This class is an implementation of the Parsable duck type that checks the display type. The only needed …\n"],["WWWJDic::Parsers::Search","","WWWJDic/Parsers/Search.html","","<p>This class is an implementation of the Parsable duck type that checks the display type. The only needed …\n"],["WWWJDic::Parsers::Server","","WWWJDic/Parsers/Server.html","","<p>This class is an implementation of the Parsable duck type that checks the display type. The only needed …\n"],["WWWJDic::Splitter","","WWWJDic/Splitter.html","","<p>This class is a simple API to interact with WWWJDic Backboor Entry/API.\n<p>Author — Marco Bresciani\n<p>Copyright … — "],["WWWJDic::Utils","","WWWJDic/Utils.html","","<p>This module is a simple collection of useful things and methods that I prefer to keep as DRYer as possible. …\n"],["WWWJDic::Utils::Downloader","","WWWJDic/Utils/Downloader.html","","<p>This module is a simple wrapper container for Jon Maken gist.\n<p>Author — Marco Bresciani\n\n<p>rubocop:disable Style/AsciiComments …\n"],["WWWJDic::Utils::Downloader::Downloader","","WWWJDic/Utils/Downloader/Downloader.html","","<p>rubocop:disable Style/AsciiComments\n<p>Copyright — © 2012 Jon Maken\n\n<p>rubocop:enable Style/AsciiComments see …\n"],["WWWJDic::Utils::Raisers","","WWWJDic/Utils/Raisers.html","","<p>This module contains some utility method to raise errors according to (possibly) common conditions.\n<p>Author … — "],["WWWJDic::WWWJDic","","WWWJDic/WWWJDic.html","","<p>This class is a simple API to interact with WWWJDic Backboor Entry/API.\n<p>Author — Marco Bresciani\n<p>Copyright … — "],["breener","WWWJDic","WWWJDic.html#method-c-breener","()","<p>Creates a new WWWJDic object (from the verb 'to Breen'… :) ).\n<p>Usage — <p><code>new_wwwjdic = WWWJDic::breener</code> …\n\n"],["content","WWWJDic::Splitter","WWWJDic/Splitter.html#method-i-content","()","<p>@return [Array] the arrays of elements containing the answer\n"],["dictionary","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-dictionary","()","<p>Return the default used dictionary string, if any.\n<p>Returns — a String with the dictionary full name.\n\n"],["dictionary=","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-dictionary-3D","(dict)","<p>Configure the default used dictionary using either code/number or (exact) string.\n<p>Usage — <tt>new_wwwjdic.dictionary= …\n"],["download_file","WWWJDic::Utils::Downloader::Downloader","WWWJDic/Utils/Downloader/Downloader.html#method-c-download_file","(url, full_path, count = 3)",""],["json_translate","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-json_translate","(word = nil, args = {}, filename = nil)","<p>Save a file, with specified <code>filename</code>, that contains the current wwwjdic configuration, in JSON format. …\n"],["json_uri","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-json_uri","(word = nil, args = {})","<p>Create the reference uri for a <code>word</code> translation, according to specified parameters, with JSON output. …\n"],["lines","WWWJDic::Splitter","WWWJDic/Splitter.html#method-i-lines","()",""],["load_yaml_file","Object","Object.html#method-i-load_yaml_file","(locale)",""],["message","WWWJDic::Splitter","WWWJDic/Splitter.html#method-i-message","()",""],["new","WWWJDic::Parser","WWWJDic/Parser.html#method-c-new","(args = {})",""],["new","WWWJDic::Splitter","WWWJDic/Splitter.html#method-c-new","(translation)","<p>Creates a <code>Splitter</code> object.\n<p>Usage — <code>new_splitter = Splitter.new translation_content</code>\n<p>Returns — a <code>Splitter</code> object. …\n"],["new","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-c-new","(parser)","<p>Creates a <code>WWWJDic</code> object. This constructor should be used through the WWWJDic::breener method only.\n<p>Usage … — "],["parse","WWWJDic::Parser","WWWJDic/Parser.html#method-i-parse","(method = nil, params = nil)","<p>Provides the duck type for a generic parsing object.\n"],["parse","WWWJDic::Parsers::Dict","WWWJDic/Parsers/Dict.html#method-i-parse","(value = '1')","<p>The parsable duck type interface to every parser usage.\n"],["parse","WWWJDic::Parsers::Display","WWWJDic/Parsers/Display.html#method-i-parse","(value = :display)","<p>The parsable duck type interface to every parser usage.\n"],["parse","WWWJDic::Parsers::Key","WWWJDic/Parsers/Key.html#method-i-parse","(value = :english)","<p>The parsable duck type interface to every parser usage.\n"],["parse","WWWJDic::Parsers::Search","WWWJDic/Parsers/Search.html#method-i-parse","(value = '')","<p>The parsable duck type interface to every parser usage.\n"],["parse","WWWJDic::Parsers::Server","WWWJDic/Parsers/Server.html#method-i-parse","(value = :edrdg)","<p>The parsable duck type interface to every parser usage.\n"],["parser","WWWJDic","WWWJDic.html#method-c-parser","()","<p>Provides the parameters' parsers object.\n"],["raiser_array","WWWJDic::Utils::Raisers","WWWJDic/Utils/Raisers.html#method-i-raiser_array","(name = 'error.value', value = nil, array = nil)","<p>Raises an <code>ArgumentError</code> according to parameters, unless the <code>array</code> contains the exact <code>value</code>.\n"],["raiser_downcase","WWWJDic::Utils::Raisers","WWWJDic/Utils/Raisers.html#method-i-raiser_downcase","(name = 'error.value', value = nil, array = nil)","<p>Raises an <code>ArgumentError</code> according to parameters, unless the <code>array</code> contains a downcased <code>value</code>.\n"],["raiser_to_i","WWWJDic::Utils::Raisers","WWWJDic/Utils/Raisers.html#method-i-raiser_to_i","(name = 'error.value', value = nil, array = nil)","<p>Raises an <code>ArgumentError</code> according to parameters, unless the <code>array</code> contains the number of the <code>value</code>.\n"],["raw_uri","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-raw_uri","(word = nil, args = {})","<p>Create the reference uri for a <code>word</code> translation, according to specified parameters, overriding for raw …\n"],["reset","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-reset","()","<p>Restores the original status cleaning up the (possibly) previously saved URIs restoring the default …\n"],["server","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-server","()","<p>Return the selected server URI\n<p>Returns — a String with the dictionary full name.\n\n"],["server=","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-server-3D","(server = :edrdg)","<p>Store the Backdoor Entry/API server name, default to EDRDG.Org (:edrdg) instead of Monash (:monash). …\n"],["test_ask_translation","Object","Object.html#method-i-test_ask_translation","()",""],["test_ask_uri","Object","Object.html#method-i-test_ask_uri","()",""],["test_dictionary_code","Object","Object.html#method-i-test_dictionary_code","()",""],["test_dictionary_name","Object","Object.html#method-i-test_dictionary_name","()",""],["test_en_it","Object","Object.html#method-i-test_en_it","()",""],["test_get_dictionary","Object","Object.html#method-i-test_get_dictionary","()",""],["test_get_translation","Object","Object.html#method-i-test_get_translation","()",""],["test_invalid_param","Object","Object.html#method-i-test_invalid_param","()",""],["test_invalid_parameter","Object","Object.html#method-i-test_invalid_parameter","(a_word)",""],["test_invalid_server","Object","Object.html#method-i-test_invalid_server","()",""],["test_multilanguage","Object","Object.html#method-i-test_multilanguage","(a_method)",""],["test_multiple_languages","Object","Object.html#method-i-test_multiple_languages","()",""],["test_no_raise","Object","Object.html#method-i-test_no_raise","()",""],["test_one_locale","Object","Object.html#method-i-test_one_locale","()",""],["test_override_custom_params","Object","Object.html#method-i-test_override_custom_params","(a_word, dict)",""],["test_parsable_duck_type","WWWJDic::ParsableDuckType","WWWJDic/ParsableDuckType.html#method-i-test_parsable_duck_type","()","<p>The method that tests the parsable duck type interface and its <code>parse</code> method.\n"],["test_raise","Object","Object.html#method-i-test_raise","()",""],["test_raise_error_param","Object","Object.html#method-i-test_raise_error_param","(param)",""],["test_raise_invalid_server_error","Object","Object.html#method-i-test_raise_invalid_server_error","(a_server)",""],["test_raiser","Object","Object.html#method-i-test_raiser","()",""],["test_return_json","Object","Object.html#method-i-test_return_json","(a_word, dict)",""],["test_return_test_reference","Object","Object.html#method-i-test_return_test_reference","()",""],["test_select_server","Object","Object.html#method-i-test_select_server","()",""],["test_server","Object","Object.html#method-i-test_server","()",""],["test_translation","Object","Object.html#method-i-test_translation","(locale, translation)",""],["test_wrong_code","Object","Object.html#method-i-test_wrong_code","()",""],["test_wrong_name","Object","Object.html#method-i-test_wrong_name","()",""],["title","WWWJDic::Splitter","WWWJDic/Splitter.html#method-i-title","()",""],["to_s","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-to_s","()",""],["translate","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-translate","(word = nil, args = {}, filename = nil)","<p>Save a file, with specified <code>filename</code>, that contains the current wwwjdic configuration. Uses the internal …\n"],["translation","WWWJDic::Splitter","WWWJDic/Splitter.html#method-i-translation","()",""],["uri","WWWJDic::WWWJDic","WWWJDic/WWWJDic.html#method-i-uri","(word = nil, args = {})","<p>Create the reference uri for a <code>word</code> translation, according to specified parameters.\n<p>Usage — <tt>new_wwwjdic.uri …\n\n"],["CHANGELOG","","CHANGELOG.html","","<p>Version 16.1.0\n\n<pre>* PATCH update gem dependencies.\n* PATCH fix somw Rubocop offenses\n* IN PROGRESS: improving ...</pre>\n"],["COPYING","","COPYING_md.html","","<p>GNU GENERAL PUBLIC LICENSE\n<p>Version 3, 29 June 2007\n<p>Copyright (C) 2007 Free Software Foundation, Inc.\nfsf.org ...\n"],["Gemfile","","Gemfile.html","","<p># frozen_string_literal: true\n<p># wwwjdic # © 2014-2021 Marco Bresciani # # This file is part of wwwjdic. …\n"],["README","","README_md.html","","<p>WWWJDic\n<p><img src=\"https://badgen.net/rubygems/n/wwwjdic\">\n<img src=\"https://badgen.net/rubygems/v/wwwjdic/latest\"> ...\n"],["Rakefile","","Rakefile.html","","<p># frozen_string_literal: true\n<p># wwwjdic # © 2014-2021 Marco Bresciani # # This file is part of wwwjdic. …\n"],["copyright","","copyright_md.html","","<p>Copyright Notes\n<p>2021-08-06 update.\n<p>wwwjdic\n"]]}}
|
data/html/js/search_index.js.gz
CHANGED
Binary file
|
data/html/js/searcher.js
CHANGED
@@ -1,229 +1,228 @@
|
|
1
|
-
Searcher = function(data) {
|
2
|
-
this.data = data;
|
3
|
-
this.handlers = [];
|
4
|
-
}
|
5
|
-
|
6
|
-
Searcher.prototype = new function() {
|
7
|
-
// search is performed in chunks of 1000 for non-blocking user input
|
8
|
-
var CHUNK_SIZE = 1000;
|
9
|
-
// do not try to find more than 100 results
|
10
|
-
var MAX_RESULTS = 100;
|
11
|
-
var huid = 1;
|
12
|
-
var suid = 1;
|
13
|
-
var runs = 0;
|
14
|
-
|
15
|
-
this.find = function(query) {
|
16
|
-
var queries = splitQuery(query);
|
17
|
-
var regexps = buildRegexps(queries);
|
18
|
-
var highlighters = buildHilighters(queries);
|
19
|
-
var state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++};
|
20
|
-
var _this = this;
|
21
|
-
|
22
|
-
this.currentSuid = state.n;
|
23
|
-
|
24
|
-
if (!query) return;
|
25
|
-
|
26
|
-
var run = function() {
|
27
|
-
// stop current search thread if new search started
|
28
|
-
if (state.n != _this.currentSuid) return;
|
29
|
-
|
30
|
-
var results =
|
31
|
-
performSearch(_this.data, regexps, queries, highlighters, state);
|
32
|
-
var hasMore = (state.limit > 0 && state.pass < 4);
|
33
|
-
|
34
|
-
triggerResults.call(_this, results, !hasMore);
|
35
|
-
if (hasMore) {
|
36
|
-
setTimeout(run, 2);
|
37
|
-
}
|
38
|
-
runs++;
|
39
|
-
};
|
40
|
-
runs = 0;
|
41
|
-
|
42
|
-
// start search thread
|
43
|
-
run();
|
44
|
-
}
|
45
|
-
|
46
|
-
/* ----- Events ------ */
|
47
|
-
this.ready = function(fn) {
|
48
|
-
fn.huid = huid;
|
49
|
-
this.handlers.push(fn);
|
50
|
-
}
|
51
|
-
|
52
|
-
/* ----- Utilities ------ */
|
53
|
-
function splitQuery(query) {
|
54
|
-
return
|
55
|
-
return string.match(/\S/);
|
56
|
-
});
|
57
|
-
}
|
58
|
-
|
59
|
-
function buildRegexps(queries) {
|
60
|
-
return
|
61
|
-
return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i');
|
62
|
-
});
|
63
|
-
}
|
64
|
-
|
65
|
-
function buildHilighters(queries) {
|
66
|
-
return
|
67
|
-
return
|
68
|
-
return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2);
|
69
|
-
}).join('');
|
70
|
-
});
|
71
|
-
}
|
72
|
-
|
73
|
-
// function longMatchRegexp(index, longIndex, regexps) {
|
74
|
-
// for (var i = regexps.length - 1; i >= 0; i--){
|
75
|
-
// if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
|
76
|
-
// };
|
77
|
-
// return true;
|
78
|
-
// }
|
79
|
-
|
80
|
-
|
81
|
-
/* ----- Mathchers ------ */
|
82
|
-
|
83
|
-
/*
|
84
|
-
* This record matches if the index starts with queries[0] and the record
|
85
|
-
* matches all of the regexps
|
86
|
-
*/
|
87
|
-
function matchPassBeginning(index, longIndex, queries, regexps) {
|
88
|
-
if (index.indexOf(queries[0]) != 0) return false;
|
89
|
-
for (var i=1, l = regexps.length; i < l; i++) {
|
90
|
-
if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
|
91
|
-
return false;
|
92
|
-
}
|
93
|
-
return true;
|
94
|
-
}
|
95
|
-
|
96
|
-
/*
|
97
|
-
* This record matches if the longIndex starts with queries[0] and the
|
98
|
-
* longIndex matches all of the regexps
|
99
|
-
*/
|
100
|
-
function matchPassLongIndex(index, longIndex, queries, regexps) {
|
101
|
-
if (longIndex.indexOf(queries[0]) != 0) return false;
|
102
|
-
for (var i=1, l = regexps.length; i < l; i++) {
|
103
|
-
if (!longIndex.match(regexps[i]))
|
104
|
-
return false;
|
105
|
-
}
|
106
|
-
return true;
|
107
|
-
}
|
108
|
-
|
109
|
-
/*
|
110
|
-
* This record matches if the index contains queries[0] and the record
|
111
|
-
* matches all of the regexps
|
112
|
-
*/
|
113
|
-
function matchPassContains(index, longIndex, queries, regexps) {
|
114
|
-
if (index.indexOf(queries[0]) == -1) return false;
|
115
|
-
for (var i=1, l = regexps.length; i < l; i++) {
|
116
|
-
if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
|
117
|
-
return false;
|
118
|
-
}
|
119
|
-
return true;
|
120
|
-
}
|
121
|
-
|
122
|
-
/*
|
123
|
-
* This record matches if regexps[0] matches the index and the record
|
124
|
-
* matches all of the regexps
|
125
|
-
*/
|
126
|
-
function matchPassRegexp(index, longIndex, queries, regexps) {
|
127
|
-
if (!index.match(regexps[0])) return false;
|
128
|
-
for (var i=1, l = regexps.length; i < l; i++) {
|
129
|
-
if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
|
130
|
-
return false;
|
131
|
-
}
|
132
|
-
return true;
|
133
|
-
}
|
134
|
-
|
135
|
-
|
136
|
-
/* ----- Highlighters ------ */
|
137
|
-
function highlightRegexp(info, queries, regexps, highlighters) {
|
138
|
-
var result = createResult(info);
|
139
|
-
for (var i=0, l = regexps.length; i < l; i++) {
|
140
|
-
result.title = result.title.replace(regexps[i], highlighters[i]);
|
141
|
-
result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
|
142
|
-
}
|
143
|
-
return result;
|
144
|
-
}
|
145
|
-
|
146
|
-
function hltSubstring(string, pos, length) {
|
147
|
-
return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length);
|
148
|
-
}
|
149
|
-
|
150
|
-
function highlightQuery(info, queries, regexps, highlighters) {
|
151
|
-
var result = createResult(info);
|
152
|
-
var pos = 0;
|
153
|
-
var lcTitle = result.title.toLowerCase();
|
154
|
-
|
155
|
-
pos = lcTitle.indexOf(queries[0]);
|
156
|
-
if (pos != -1) {
|
157
|
-
result.title = hltSubstring(result.title, pos, queries[0].length);
|
158
|
-
}
|
159
|
-
|
160
|
-
result.namespace = result.namespace.replace(regexps[0], highlighters[0]);
|
161
|
-
for (var i=1, l = regexps.length; i < l; i++) {
|
162
|
-
result.title = result.title.replace(regexps[i], highlighters[i]);
|
163
|
-
result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
|
164
|
-
}
|
165
|
-
return result;
|
166
|
-
}
|
167
|
-
|
168
|
-
function createResult(info) {
|
169
|
-
var result = {};
|
170
|
-
result.title = info[0];
|
171
|
-
result.namespace = info[1];
|
172
|
-
result.path = info[2];
|
173
|
-
result.params = info[3];
|
174
|
-
result.snippet = info[4];
|
175
|
-
result.badge = info[6];
|
176
|
-
return result;
|
177
|
-
}
|
178
|
-
|
179
|
-
/* ----- Searching ------ */
|
180
|
-
function performSearch(data, regexps, queries, highlighters, state) {
|
181
|
-
var searchIndex = data.searchIndex;
|
182
|
-
var longSearchIndex = data.longSearchIndex;
|
183
|
-
var info = data.info;
|
184
|
-
var result = [];
|
185
|
-
var i = state.from;
|
186
|
-
var l = searchIndex.length;
|
187
|
-
var togo = CHUNK_SIZE;
|
188
|
-
var matchFunc, hltFunc;
|
189
|
-
|
190
|
-
while (state.pass < 4 && state.limit > 0 && togo > 0) {
|
191
|
-
if (state.pass == 0) {
|
192
|
-
matchFunc = matchPassBeginning;
|
193
|
-
hltFunc = highlightQuery;
|
194
|
-
} else if (state.pass == 1) {
|
195
|
-
matchFunc = matchPassLongIndex;
|
196
|
-
hltFunc = highlightQuery;
|
197
|
-
} else if (state.pass == 2) {
|
198
|
-
matchFunc = matchPassContains;
|
199
|
-
hltFunc = highlightQuery;
|
200
|
-
} else if (state.pass == 3) {
|
201
|
-
matchFunc = matchPassRegexp;
|
202
|
-
hltFunc = highlightRegexp;
|
203
|
-
}
|
204
|
-
|
205
|
-
for (; togo > 0 && i < l && state.limit > 0; i++, togo--) {
|
206
|
-
if (info[i].n == state.n) continue;
|
207
|
-
if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) {
|
208
|
-
info[i].n = state.n;
|
209
|
-
result.push(hltFunc(info[i], queries, regexps, highlighters));
|
210
|
-
state.limit--;
|
211
|
-
}
|
212
|
-
}
|
213
|
-
if (searchIndex.length <= i) {
|
214
|
-
state.pass++;
|
215
|
-
i = state.from = 0;
|
216
|
-
} else {
|
217
|
-
state.from = i;
|
218
|
-
}
|
219
|
-
}
|
220
|
-
return result;
|
221
|
-
}
|
222
|
-
|
223
|
-
function triggerResults(results, isLast) {
|
224
|
-
|
225
|
-
fn.call(this, results, isLast)
|
226
|
-
})
|
227
|
-
}
|
228
|
-
}
|
229
|
-
|
1
|
+
Searcher = function(data) {
|
2
|
+
this.data = data;
|
3
|
+
this.handlers = [];
|
4
|
+
}
|
5
|
+
|
6
|
+
Searcher.prototype = new function() {
|
7
|
+
// search is performed in chunks of 1000 for non-blocking user input
|
8
|
+
var CHUNK_SIZE = 1000;
|
9
|
+
// do not try to find more than 100 results
|
10
|
+
var MAX_RESULTS = 100;
|
11
|
+
var huid = 1;
|
12
|
+
var suid = 1;
|
13
|
+
var runs = 0;
|
14
|
+
|
15
|
+
this.find = function(query) {
|
16
|
+
var queries = splitQuery(query);
|
17
|
+
var regexps = buildRegexps(queries);
|
18
|
+
var highlighters = buildHilighters(queries);
|
19
|
+
var state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++};
|
20
|
+
var _this = this;
|
21
|
+
|
22
|
+
this.currentSuid = state.n;
|
23
|
+
|
24
|
+
if (!query) return;
|
25
|
+
|
26
|
+
var run = function() {
|
27
|
+
// stop current search thread if new search started
|
28
|
+
if (state.n != _this.currentSuid) return;
|
29
|
+
|
30
|
+
var results =
|
31
|
+
performSearch(_this.data, regexps, queries, highlighters, state);
|
32
|
+
var hasMore = (state.limit > 0 && state.pass < 4);
|
33
|
+
|
34
|
+
triggerResults.call(_this, results, !hasMore);
|
35
|
+
if (hasMore) {
|
36
|
+
setTimeout(run, 2);
|
37
|
+
}
|
38
|
+
runs++;
|
39
|
+
};
|
40
|
+
runs = 0;
|
41
|
+
|
42
|
+
// start search thread
|
43
|
+
run();
|
44
|
+
}
|
45
|
+
|
46
|
+
/* ----- Events ------ */
|
47
|
+
this.ready = function(fn) {
|
48
|
+
fn.huid = huid;
|
49
|
+
this.handlers.push(fn);
|
50
|
+
}
|
51
|
+
|
52
|
+
/* ----- Utilities ------ */
|
53
|
+
function splitQuery(query) {
|
54
|
+
return query.split(/(\s+|::?|\(\)?)/).filter(function(string) {
|
55
|
+
return string.match(/\S/);
|
56
|
+
});
|
57
|
+
}
|
58
|
+
|
59
|
+
function buildRegexps(queries) {
|
60
|
+
return queries.map(function(query) {
|
61
|
+
return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i');
|
62
|
+
});
|
63
|
+
}
|
64
|
+
|
65
|
+
function buildHilighters(queries) {
|
66
|
+
return queries.map(function(query) {
|
67
|
+
return query.split('').map(function(l, i) {
|
68
|
+
return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2);
|
69
|
+
}).join('');
|
70
|
+
});
|
71
|
+
}
|
72
|
+
|
73
|
+
// function longMatchRegexp(index, longIndex, regexps) {
|
74
|
+
// for (var i = regexps.length - 1; i >= 0; i--){
|
75
|
+
// if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
|
76
|
+
// };
|
77
|
+
// return true;
|
78
|
+
// }
|
79
|
+
|
80
|
+
|
81
|
+
/* ----- Mathchers ------ */
|
82
|
+
|
83
|
+
/*
|
84
|
+
* This record matches if the index starts with queries[0] and the record
|
85
|
+
* matches all of the regexps
|
86
|
+
*/
|
87
|
+
function matchPassBeginning(index, longIndex, queries, regexps) {
|
88
|
+
if (index.indexOf(queries[0]) != 0) return false;
|
89
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
90
|
+
if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
|
91
|
+
return false;
|
92
|
+
}
|
93
|
+
return true;
|
94
|
+
}
|
95
|
+
|
96
|
+
/*
|
97
|
+
* This record matches if the longIndex starts with queries[0] and the
|
98
|
+
* longIndex matches all of the regexps
|
99
|
+
*/
|
100
|
+
function matchPassLongIndex(index, longIndex, queries, regexps) {
|
101
|
+
if (longIndex.indexOf(queries[0]) != 0) return false;
|
102
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
103
|
+
if (!longIndex.match(regexps[i]))
|
104
|
+
return false;
|
105
|
+
}
|
106
|
+
return true;
|
107
|
+
}
|
108
|
+
|
109
|
+
/*
|
110
|
+
* This record matches if the index contains queries[0] and the record
|
111
|
+
* matches all of the regexps
|
112
|
+
*/
|
113
|
+
function matchPassContains(index, longIndex, queries, regexps) {
|
114
|
+
if (index.indexOf(queries[0]) == -1) return false;
|
115
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
116
|
+
if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
|
117
|
+
return false;
|
118
|
+
}
|
119
|
+
return true;
|
120
|
+
}
|
121
|
+
|
122
|
+
/*
|
123
|
+
* This record matches if regexps[0] matches the index and the record
|
124
|
+
* matches all of the regexps
|
125
|
+
*/
|
126
|
+
function matchPassRegexp(index, longIndex, queries, regexps) {
|
127
|
+
if (!index.match(regexps[0])) return false;
|
128
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
129
|
+
if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
|
130
|
+
return false;
|
131
|
+
}
|
132
|
+
return true;
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
/* ----- Highlighters ------ */
|
137
|
+
function highlightRegexp(info, queries, regexps, highlighters) {
|
138
|
+
var result = createResult(info);
|
139
|
+
for (var i=0, l = regexps.length; i < l; i++) {
|
140
|
+
result.title = result.title.replace(regexps[i], highlighters[i]);
|
141
|
+
result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
|
142
|
+
}
|
143
|
+
return result;
|
144
|
+
}
|
145
|
+
|
146
|
+
function hltSubstring(string, pos, length) {
|
147
|
+
return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length);
|
148
|
+
}
|
149
|
+
|
150
|
+
function highlightQuery(info, queries, regexps, highlighters) {
|
151
|
+
var result = createResult(info);
|
152
|
+
var pos = 0;
|
153
|
+
var lcTitle = result.title.toLowerCase();
|
154
|
+
|
155
|
+
pos = lcTitle.indexOf(queries[0]);
|
156
|
+
if (pos != -1) {
|
157
|
+
result.title = hltSubstring(result.title, pos, queries[0].length);
|
158
|
+
}
|
159
|
+
|
160
|
+
result.namespace = result.namespace.replace(regexps[0], highlighters[0]);
|
161
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
162
|
+
result.title = result.title.replace(regexps[i], highlighters[i]);
|
163
|
+
result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
|
164
|
+
}
|
165
|
+
return result;
|
166
|
+
}
|
167
|
+
|
168
|
+
function createResult(info) {
|
169
|
+
var result = {};
|
170
|
+
result.title = info[0];
|
171
|
+
result.namespace = info[1];
|
172
|
+
result.path = info[2];
|
173
|
+
result.params = info[3];
|
174
|
+
result.snippet = info[4];
|
175
|
+
result.badge = info[6];
|
176
|
+
return result;
|
177
|
+
}
|
178
|
+
|
179
|
+
/* ----- Searching ------ */
|
180
|
+
function performSearch(data, regexps, queries, highlighters, state) {
|
181
|
+
var searchIndex = data.searchIndex;
|
182
|
+
var longSearchIndex = data.longSearchIndex;
|
183
|
+
var info = data.info;
|
184
|
+
var result = [];
|
185
|
+
var i = state.from;
|
186
|
+
var l = searchIndex.length;
|
187
|
+
var togo = CHUNK_SIZE;
|
188
|
+
var matchFunc, hltFunc;
|
189
|
+
|
190
|
+
while (state.pass < 4 && state.limit > 0 && togo > 0) {
|
191
|
+
if (state.pass == 0) {
|
192
|
+
matchFunc = matchPassBeginning;
|
193
|
+
hltFunc = highlightQuery;
|
194
|
+
} else if (state.pass == 1) {
|
195
|
+
matchFunc = matchPassLongIndex;
|
196
|
+
hltFunc = highlightQuery;
|
197
|
+
} else if (state.pass == 2) {
|
198
|
+
matchFunc = matchPassContains;
|
199
|
+
hltFunc = highlightQuery;
|
200
|
+
} else if (state.pass == 3) {
|
201
|
+
matchFunc = matchPassRegexp;
|
202
|
+
hltFunc = highlightRegexp;
|
203
|
+
}
|
204
|
+
|
205
|
+
for (; togo > 0 && i < l && state.limit > 0; i++, togo--) {
|
206
|
+
if (info[i].n == state.n) continue;
|
207
|
+
if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) {
|
208
|
+
info[i].n = state.n;
|
209
|
+
result.push(hltFunc(info[i], queries, regexps, highlighters));
|
210
|
+
state.limit--;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
if (searchIndex.length <= i) {
|
214
|
+
state.pass++;
|
215
|
+
i = state.from = 0;
|
216
|
+
} else {
|
217
|
+
state.from = i;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
return result;
|
221
|
+
}
|
222
|
+
|
223
|
+
function triggerResults(results, isLast) {
|
224
|
+
this.handlers.forEach(function(fn) {
|
225
|
+
fn.call(this, results, isLast)
|
226
|
+
});
|
227
|
+
}
|
228
|
+
}
|