0

I opened http://dev.yathit.com/demo/ydn-db-text/animals/animals.html demo online, it worked. But when I try to use this demo in an offline mode, something goes wrong.

These error messages appear right after I type something into input:

Chrome (with --allow-file-access-from-files flag enabled):

Uncaught TypeError: Object [object Object] has no method 'search'  -->  animals.js:111
  Animals.handleSearch

Firefox:

TypeError: this.db.search is not a function
  var rq = this.db.search('name', this.ele_input_.value);
  animals.js (line 111)

By the way, I have "2359 animals loaded, indexing... done." message, it means that database is loaded, but what's the problem with var rq = this.db.search('name', this.ele_input_.value)?

UPDATE
I checked https://github.com/yathit/ydn-db-fulltext/blob/master/examples/animals/animals.html source, and now I see the problem: two local js files (ydn-db.js and animals.js) are not enough, this app has a lot of dependencies:

<script src="../../../closure-library/closure/goog/base.js"></script>
<script src="../../../closure-library/closure/goog/deps.js"></script>
<script src="../../../ydn-base/src/deps.js"></script>
<script src="../../../ydn-db/src/deps.js"></script>
<script src="../../../natural/js/deps.js"></script>
<script src="../../../fullproof/js/deps.js"></script>
<script type="text/javascript"
        src="../../../fullproof/js/tokenizer/categ_letters_numbers.js"></script>
<script type="text/javascript"
        src="../../../fullproof/js/tokenizer/normalizer_lowercase.js"></script>
<script type="text/javascript"
        src="../../../fullproof/js/tokenizer/normalizer_lowercase_nomark.js"></script>
<script type="text/javascript" src="../../src/deps.js"></script>
<script type="text/javascript">
    goog.require('ydn.debug');
    goog.require('ydn.db.crud.Storage');
    goog.require('ydn.db.crud.Storage.text');
</script>
<script src="../../../ydn-db/config/crud.js"></script>
<script type="text/javascript" src="../../../ydn-db/src/ydn/db/tr/inject.js"></script>
<script type="text/javascript" src="../../../ydn-db/src/ydn/db/crud/inject.js"></script>  

but those files are not included in the downloadable zip package.

lyrically wicked
  • 1,185
  • 12
  • 26

1 Answers1

1

It looks like you are using different ydn-db js file. Most of the ydn-db distribution files do not have full text search module.

The web page is client side html. It should work. IndexedDB must served by a valid origin, so spin up server for testing. --allow-file-access-from-files is irrelevant I believe.

Did you use the js file in the demo?

Kyaw Tun
  • 12,447
  • 10
  • 56
  • 83
  • you can check the update. By the way, `allow-file-access-from-files` is not irrelevant. If you don't set this flag, you get `XMLHttpRequest cannot load file:///path/to/data.csv. Cross origin requests are only supported for HTTP` error, because database is loaded by AJAX! But can you provide the full list of urls to required js files? (because they are not included in the downloadable github zip package) – lyrically wicked Feb 01 '14 at 07:58
  • 1
    I am sorry for misunderstanding. This web page will not run with `file` protocol. – Kyaw Tun Feb 02 '14 at 00:12
  • but can you explain why? If this app has no server-side dependency (only client-side code), then what's thr problem with `file://` protocol??? – lyrically wicked Feb 07 '14 at 06:37
  • @lyricallywicked - That's just the way browsers work. The file protocol is just limited. You need a webserver, even if it's local, just so you're using the http protocol. This isn't a problem with ydb... it's just how the browsers are built. – jamesmortensen Mar 18 '14 at 18:19