> Yes, I understand that process. > My point was that a more "correct" (which I know is not always a good thing) > way to do would be to > * read the file > * shove it into the innerHTML of a (not in document) dom node X > * use getElementByID to find the storearea div > * set the innerHTML of that div > * pull the innerHTML out of X > * write that string to the file
TiddlyWiki directly encodes and generates the HTML for the storeArea DIV needed to save the current tiddlers. Thus, when TW reads in the saved file content, the purpose of the string manipulation is not to locate the existing storeArea in the saved content... rather, it is to extract the *unparsed* contents of the rest of the file that surrounds the storeArea definition, so that the newly-generated storeArea HTML can be inserted into that content and then re-written to the file. However, the 'round-trip' process you outlined: (1) read file (2) set innerHTML (3) read innerHTML (4) write file, will *not* produce correct results. The reason is that the innerHTML you set is automaticaly *parsed* by the browser, and the innerHTML that is subsequently returned from the DOM node will be *re-generated* according that particular browser's internal 'pretty printing' logic, with all the JS code reformatted and all comments stripped out. The round-trip through innerHTML can also mangle other parts of the source code as well -- I think it fails to regenerate the CDATA blocks (but I'm not 100% certain of that) -- and there are other subtle cross- browser differences in the innerHTML output that make it impractical and unreliable to use in the way you suggest. In contrast, using string manipulation to merge the newly generated storeArea with the existing plain-text file content is 100% consistent across all browsers, specifically because it does *not* rely upon the browser's handling of innerHTML. -e Eric Shulman TiddlyTools / ELS Design Studios --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/TiddlyWikiDev?hl=en -~----------~----~----~----~------~----~------~--~---
