jeddi
05-09-2009, 06:22 AM
This is my plan:
Overview:
I want to use a server based thesaurus to enable a client to make changes to their document in their browser.
So the thesaurus file needs to be served to the client and then the client does the searching locally using the pcs ram.
File would be about 3 Mb. ( A guess)
So a client has some text content in an html textarea of a form.
He/she highlights a word (with cursor or double-click) and then clicks on
a "thesaurus button".
Eg word = "gust"
That thesaurus button will take the word wind and put it in square brackets
and then after it it list words that it gets from the server provided thesaurus.
EG [gust, breeze, wind, surge]
Now, I can do this bit but what I don't know about is how to get javascript to read a text file from the server that delivers the html page.
The file format could be a flat text file with a line fro each entry:
gust: breeze, wind, surge
I guess that it would need these entries as well:
breeze: wind, surge, gust
wind: surge, surge, gust
surge: surge, gust, wind
This would make the file much longer though :(
Is there a way for js to search a file to do this kind of thing ?
I am familiar with php and could store everything in a mysql table
but I don't know how I would serve that up to the javascript.
Also it is the javascript that will have to do the search and retrieve
not the server.
The thesaurus needs to come from the server because the client may add
a new word and this needs to be available next time - so I need to update the thesaurus file on the server when the form is processed.
This maybe pretty basic but I haven't done any file access work with js so I am hoping someone here can help :)
Overview:
I want to use a server based thesaurus to enable a client to make changes to their document in their browser.
So the thesaurus file needs to be served to the client and then the client does the searching locally using the pcs ram.
File would be about 3 Mb. ( A guess)
So a client has some text content in an html textarea of a form.
He/she highlights a word (with cursor or double-click) and then clicks on
a "thesaurus button".
Eg word = "gust"
That thesaurus button will take the word wind and put it in square brackets
and then after it it list words that it gets from the server provided thesaurus.
EG [gust, breeze, wind, surge]
Now, I can do this bit but what I don't know about is how to get javascript to read a text file from the server that delivers the html page.
The file format could be a flat text file with a line fro each entry:
gust: breeze, wind, surge
I guess that it would need these entries as well:
breeze: wind, surge, gust
wind: surge, surge, gust
surge: surge, gust, wind
This would make the file much longer though :(
Is there a way for js to search a file to do this kind of thing ?
I am familiar with php and could store everything in a mysql table
but I don't know how I would serve that up to the javascript.
Also it is the javascript that will have to do the search and retrieve
not the server.
The thesaurus needs to come from the server because the client may add
a new word and this needs to be available next time - so I need to update the thesaurus file on the server when the form is processed.
This maybe pretty basic but I haven't done any file access work with js so I am hoping someone here can help :)