Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #18479
| Message-ID | <1605051.1mSJY5JTrl@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2013-02-13 15:06 +0100 |
| Subject | Re: Implement offline site search? |
| Newsgroups | comp.lang.javascript |
| References | <haWdnRUFFpDr0IbMnZ2dnUVZ5uidnZ2d@giganews.com> |
Robert Crandal wrote: > Our website is stored on a local hard-drive on a computer > that has no Internet access. It's basically an offline website > that only our company can use. > > Is it possible to add a search feature to this website using > Javascript? I want to let users type a search string, and > then somehow search all the HTML documents on the > hard drive for string matches, then display a new HTML > page with the search results. Can Javascript do this? How? There is no Javascript. But with an ECMAScript implementation such as JavaScript you can, in a sufficiently recent Web browser, use an implementation of the XMLHttpRequest API. That API, with sufficient permissions granted, allows you to GET listings of (local) files (the format will vary between UAs) and to GET the file contents via URIs. Having the files' content, you can build from that an index as an Object instance (preferably with empty prototype chain, or a collision-avoiding Map implementation such as JSX:map.js) that ultimately maps words (property names) to a list of files that contain them (references to Array instances of file names, as property values). [As an optimization, a previous object could also map prefixes to words.] You can store that index in serialized form in Local Storage and from that point forward only use the unserialized form of the index to perform the search until the index needs to be updated. As an alternative, you can use other software to build a script resource with the index as an Object instance that you use for searches after you loaded that resource from an HTML document. An example of that can be found in SELFHTML's offline search; the code quality thereis is awful, but debugging that code could still help. Probably there are other, better implementations as this is not likely to be an uncommon problem. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Implement offline site search? "Robert Crandal" <rcranz143101@gmail.com> - 2013-02-13 01:23 -0700
Re: Implement offline site search? Tim Slattery <Slattery_T@bls.gov> - 2013-02-13 09:04 -0500
Re: Implement offline site search? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-13 15:23 +0100
Re: Implement offline site search? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-02-13 15:33 +0100
Re: Implement offline site search? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-13 15:06 +0100
Re: Implement offline site search? "Robert Crandal" <rcranz143101@gmail.com> - 2013-02-17 02:24 -0700
Re: Implement offline site search? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-17 13:18 +0100
Re: Implement offline site search? John G Harris <niam@jghnorth.org.uk.invalid> - 2013-02-17 16:14 +0000
Re: Implement offline site search? "Robert Crandal" <rcranz143101@gmail.com> - 2013-02-17 11:54 -0700
Re: Implement offline site search? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-17 20:52 +0100
Re: Implement offline site search? "Robert Crandal" <rcranz143101@gmail.com> - 2013-02-17 15:10 -0700
Re: Implement offline site search? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-17 23:16 +0100
Re: Implement offline site search? Andrew Poulos <ap_prog@hotmail.com> - 2013-02-18 09:54 +1100
Re: Implement offline site search? John G Harris <niam@jghnorth.org.uk.invalid> - 2013-02-18 10:17 +0000
Re: Implement offline site search? "Robert Crandal" <rcranz143101@gmail.com> - 2013-02-18 11:43 -0700
Re: Implement offline site search? Andrew Poulos <ap_prog@hotmail.com> - 2013-02-19 06:27 +1100
Re: Implement offline site search? Andrew Poulos <ap_prog@hotmail.com> - 2013-02-19 06:33 +1100
Re: Implement offline site search? Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-02-18 12:23 +0000
Re: Implement offline site search? Martin Leese <please@see.Web.for.e-mail.INVALID> - 2013-02-13 10:23 -0700
Re: Implement offline site search? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-02-14 10:56 +0100
Re: Implement offline site search? John G Harris <niam@jghnorth.org.uk.invalid> - 2013-02-14 10:20 +0000
Re: Implement offline site search? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-02-14 11:26 +0100
Re: Implement offline site search? Wally W. <ww84wa@aim.com> - 2013-02-14 08:07 -0500
Re: Implement offline site search? Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-02-14 22:47 +0000
Re: Implement offline site search? Scott Sauyet <scott.sauyet@gmail.com> - 2013-02-14 18:49 -0800
csiph-web