witten
/
luminotes
Archived
1
0
Fork 0

JavaScript code now tracking editor dirty state and not calling save_note() when editor is clean.

This commit is contained in:
Dan Helfman 2008-03-05 02:56:58 +00:00
parent 7bf2cc35b4
commit 192d043e29
3 changed files with 17 additions and 1 deletions

4
NEWS
View File

@ -1,3 +1,7 @@
1.2.3: March 4, 2008
* Client-side JavaScript code now only calls save_note() on the server when
necessary.
1.2.2: March 4, 2008
* Introduced database object caching to improve performance.
* Wrote a database reaper script to delete unused notes, notebooks, etc.

View File

@ -688,6 +688,17 @@ Editor.prototype.summarize = function () {
return summary;
}
Editor.prototype.dirty = function () {
if ( this.document.body.innerHTML == this.initial_text )
return false;
return true;
}
Editor.prototype.mark_clean = function () {
this.initial_text = this.document.body.innerHTML;
}
// convenience function for parsing a link that has an href URL containing a query string
function parse_query( link ) {
if ( !link || !link.href )

View File

@ -1198,7 +1198,7 @@ Wiki.prototype.save_editor = function ( editor, fire_and_forget, callback ) {
editor = this.focused_editor;
var self = this;
if ( editor && editor.read_write && !( editor.id == this.blank_editor_id && editor.empty() ) && !editor.closed ) {
if ( editor && editor.read_write && !( editor.id == this.blank_editor_id && editor.empty() ) && !editor.closed && editor.dirty() ) {
this.invoker.invoke( "/notebooks/save_note", "POST", {
"notebook_id": this.notebook_id,
"note_id": editor.id,
@ -1208,6 +1208,7 @@ Wiki.prototype.save_editor = function ( editor, fire_and_forget, callback ) {
}, function ( result ) {
self.update_editor_revisions( result, editor );
self.display_storage_usage( result.storage_bytes );
editor.mark_clean();
if ( callback )
callback();
}, null, fire_and_forget );