witten
/
luminotes
Archived
1
0
Fork 0

Improved the detection of whether an existing note has been altered.

There is still at least one case (IE only) where this detection fails and a
note unaltered by the user gets resaved to the server. This is because IE
alters relative links within design mode documents.
This commit is contained in:
Dan Helfman 2008-05-17 23:17:37 -07:00
parent 501ec7b37b
commit 1722d02317
2 changed files with 18 additions and 4 deletions

4
NEWS
View File

@ -1,3 +1,7 @@
1.3.31: May ??, 2008
* Improved the detection of whether an existing note has been altered and
thus needs to be saved to the server.
1.3.30: May 16, 2008
* Updated download page with mention of new Mercurial source repository.
* Added Mercurial link on faq page.

View File

@ -134,6 +134,10 @@ Editor.prototype.finish_init = function () {
this.insert_html( this.initial_text );
// since the browser may subtly tweak the html when it's inserted, save off the browser's version
// of the html here. this yields more accurate comparisons within the dirty() method
this.initial_text = this.document.body.innerHTML;
var self = this; // necessary so that the member functions of this editor object are used
if ( this.edit_enabled ) {
connect( this.document, "onkeydown", function ( event ) { self.key_pressed( event ); } );
@ -708,11 +712,17 @@ Editor.prototype.summarize = function () {
return summary;
}
// return the given html in a normal form. this makes html string comparisons more accurate
normalize_html = function ( html ) {
// remove any "pulldown" attributes
html = html.replace( /\s+pulldown="[^"]"/g, "" );
return html;
}
Editor.prototype.dirty = function () {
// the replace() calls here cause the comparison to ignore difference between, for instance,
// "<br>" and "<br />"
var original_html = this.initial_text.replace( /\s*\/>/g, ">" );
var current_html = this.document.body.innerHTML.replace( /\s*\/>/g, ">" );
var original_html = normalize_html( this.initial_text )
var current_html = normalize_html( this.document.body.innerHTML )
if ( current_html == original_html )
return false;