Originally Posted by rnd me
if this is something that's going to be saved, it better to use <textarea>.value so people can cut and paste and to prevent the browser from wrongly fixing certain unicode chars.
The major problem with textarea is that g-translate doesn't see it.
I think it assumes that as 'user input' it has no right translating it.
With all the thinking and research that's been going on..... it has led me to believe that the simplest form is going to be best:
var text = document.body.innerText;
This standardises everything, and enables simple comparative testing for state of change (which will be needed as the text changes from English to French.
It works..... I've tested it.
- I can write into the textarea of page 1
localStorage it as page_1_text
- Refreshing page 2 causes page_1_text to be written as innerHTML <pre>(will try innerText tomorrow).
- Google auto reads the page & sends back its translated text as innerHTML.
- I can click the text, and the translation is localStorage(d) as page_2_text.
- Refreshing page 3 causes page_2_text to be written as innerHTML<pre>.
It seems perfect!
We've come a long way around the houses.... but I guess: that is what it's all about.
I know what you're saying (about the universality) but I think that this might be a good place to move on to other interesting aspects (with another thread..... so if improvements can be made on this current issue then fine).
There is the question of 'checking the state of page 2..... when it's changed to (say) French, it will need to be stored, and page 3 reloaded.
So this is gonna require an 'onEnter' event to complete a paragraph.
The whole text then passed via localStorage & refresh to page 2.
An indeterminate number of milliseconds later, the text will change to French, and will require passing to page 3.
LocalStorage can handle the passing of data from page to page.
What's gonna be interesting is the sequence of events that occur when the author hits the 'Enter' key (to complete a paragraph).
Clearly page 2 has to refresh AND (I think) start a compare loop, checking the page 2 innerHTML with the page_1_text variable.
When it changes..... stop comparing, and pass it to page 3.
Ok... so I've just started a new thread on the old thread.
Sorry... it's nearly 3:00am.
I think I'll chuck the towel in for tonight.