JavaScript code now tracking editor dirty state and not calling save_note() when editor is clean.
This commit is contained in:
parent
7bf2cc35b4
commit
192d043e29
4
NEWS
4
NEWS
|
@ -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
|
1.2.2: March 4, 2008
|
||||||
* Introduced database object caching to improve performance.
|
* Introduced database object caching to improve performance.
|
||||||
* Wrote a database reaper script to delete unused notes, notebooks, etc.
|
* Wrote a database reaper script to delete unused notes, notebooks, etc.
|
||||||
|
|
|
@ -688,6 +688,17 @@ Editor.prototype.summarize = function () {
|
||||||
return summary;
|
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
|
// convenience function for parsing a link that has an href URL containing a query string
|
||||||
function parse_query( link ) {
|
function parse_query( link ) {
|
||||||
if ( !link || !link.href )
|
if ( !link || !link.href )
|
||||||
|
|
|
@ -1198,7 +1198,7 @@ Wiki.prototype.save_editor = function ( editor, fire_and_forget, callback ) {
|
||||||
editor = this.focused_editor;
|
editor = this.focused_editor;
|
||||||
|
|
||||||
var self = this;
|
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", {
|
this.invoker.invoke( "/notebooks/save_note", "POST", {
|
||||||
"notebook_id": this.notebook_id,
|
"notebook_id": this.notebook_id,
|
||||||
"note_id": editor.id,
|
"note_id": editor.id,
|
||||||
|
@ -1208,6 +1208,7 @@ Wiki.prototype.save_editor = function ( editor, fire_and_forget, callback ) {
|
||||||
}, function ( result ) {
|
}, function ( result ) {
|
||||||
self.update_editor_revisions( result, editor );
|
self.update_editor_revisions( result, editor );
|
||||||
self.display_storage_usage( result.storage_bytes );
|
self.display_storage_usage( result.storage_bytes );
|
||||||
|
editor.mark_clean();
|
||||||
if ( callback )
|
if ( callback )
|
||||||
callback();
|
callback();
|
||||||
}, null, fire_and_forget );
|
}, null, fire_and_forget );
|
||||||
|
|
Reference in New Issue