Index: js/autosave.js
===================================================================
--- js/autosave.js	(revision 23353)
+++ js/autosave.js	(working copy)
@@ -5,9 +5,13 @@
 	autosaveLast = ( $('#post #title').val() || '' ) + ( $('#post #content').val() || '' );
 	autosavePeriodical = $.schedule({time: autosaveL10n.autosaveInterval * 1000, func: function() { autosave(); }, repeat: true, protect: true});
 
+    autosavePeriodical_client = $.schedule({time: 10000, func: function() { autosave_local_storage.set_data(); }, repeat: true, protect: true});
+    autosave_local_storage.remove_stale_data();
 	//Disable autosave after the form has been submitted
 	$("#post").submit(function() {
 		$.cancel(autosavePeriodical);
+        $.cancel(autosavePeriodical_client);
+        autosave_local_storage.delete_data();
 		autosaveLockRelease = false;
 	});
 
@@ -162,6 +166,9 @@
 		// if no errors: add slug UI
 		if ( !res.errors ) {
 			postID = parseInt( res.responses[0].id, 10 );
+
+            autosave_local_storage.stale_data();
+
 			if ( !isNaN(postID) && postID > 0 ) {
 				autosave_update_slug(postID);
 			}
@@ -341,6 +348,9 @@
 	}
 
 	autosaveOldMessage = jQuery('#autosave').html();
+
+    autosave_local_storage.set_data();
+
 	jQuery.ajax({
 		data: post_data,
 		beforeSend: doAutoSave ? autosave_loading : null,
@@ -349,3 +359,211 @@
 		success: successCallback
 	});
 }
+
+autosave_local_storage = {
+
+    lastsaveddata:'',
+    modified_data : {},
+
+    prepare_data: function() {
+
+        var post_data = {
+            action: "autosave",
+            post_ID:  jQuery("#post_ID").val() || 0,
+            post_type: jQuery('#post_type').val() || ""
+        };
+
+        if ( fullscreen && fullscreen.settings.visible ) {
+            post_data["post_title"] = jQuery('#wp-fullscreen-title').val() || '';
+            post_data["content"] = jQuery("#wp_mce_fullscreen").val() || '';
+        } else {
+            post_data["post_title"] = jQuery("#title").val() || '';
+            post_data["content"] = jQuery("#content").val() || '';
+        }
+
+        if ( jQuery('#post_name').val() )
+            post_data["post_name"] = jQuery('#post_name').val();
+
+        var cats = ([]);
+
+        jQuery("[name='post_category[]']:checked").each( function(i) {
+            cats.push(this.value);
+        } );
+        post_data["catslist"] = cats.join(",");
+
+        if ( jQuery("#comment_status").prop("checked") )
+            post_data["comment_status"] = 'open';
+        if ( jQuery("#ping_status").prop("checked") )
+            post_data["ping_status"] = 'open';
+        if ( jQuery("#excerpt").size() )
+            post_data["excerpt"] = jQuery("#excerpt").val();
+        if ( jQuery("#post_author").size() )
+            post_data["post_author"] = jQuery("#post_author").val();
+        if ( jQuery("#parent_id").val() )
+            post_data["parent_id"] = jQuery("#parent_id").val();
+        post_data["user_ID"] = jQuery("#user-id").val();
+        if ( jQuery('#auto_draft').val() == '1' )
+            post_data["auto_draft"] = '1';
+
+        post_data["save_time"] = new Date().getTime();
+
+        post_data['storage_status'] = 'fresh';
+
+        return post_data;
+
+    },
+
+    get_post_id: function() {
+        var post_id = jQuery("#post_ID").val() || 0;
+
+        if( 0 < post_id ) {
+            return post_id;
+        }
+    },
+
+    get_storage: function() {
+
+        if ( window.localStorage ) {
+            var store = localStorage.getItem( 'wp_autosave' );
+
+            if( store ) {
+                return JSON.parse( store );
+            } else {
+                return {};
+            }
+        }
+    },
+
+    handle_post_data: function( data ) {
+
+        var storage_arr = this.get_storage();
+
+        if ( storage_arr ) {
+
+            var post_id = this.get_post_id();
+
+            if( post_id ) {
+                var post_key = autosaveL10n.blog_id+'_'+post_id;
+
+                if( data ) {
+
+                    if( 'del' === data){
+
+                        if( typeof storage_arr[post_key] !== 'undefined' ) {
+                            delete storage_arr[post_key];
+                        }
+
+                    } else{
+                        storage_arr[post_key] = data;
+                    }
+
+                    storage_arr = JSON.stringify( storage_arr );
+
+                    localStorage.setItem( 'wp_autosave', storage_arr );
+                } else if( typeof storage_arr[post_key] !== 'undefined' ) {
+
+                     return storage_arr[post_key];
+                }
+            }
+
+        }
+    },
+
+    get_data: function() {
+
+        return this.handle_post_data();
+
+    },
+
+    set_data: function() {
+
+        var post_data = this.prepare_data();
+
+        var storage_data = this.handle_post_data();
+
+        //if the content and title did not change from last server save,dont keep data in local storage
+        if ( ( post_data["post_title"].length == 0 && post_data["content"].length == 0 )
+            || post_data["post_title"] + post_data["content"] == autosaveLast
+            || post_data["post_title"] + post_data["content"] == this.lastsaveddata
+            ) {
+            if( storage_data && 5 < storage_data.length  ) {
+                storage_data.pop();
+                this.handle_post_data( storage_data )
+            }
+
+        } else {
+
+            if( storage_data  ) {
+
+                if( 5 < storage_data.unshift( post_data ) ) {
+                    storage_data.pop();
+                }
+
+            } else {
+                var storage_data = new Array( post_data );
+            }
+
+            this.lastsaveddata = post_data["post_title"] + post_data["content"];
+
+            this.handle_post_data( storage_data );
+
+        }
+    },
+
+    delete_data: function() {
+
+        this.handle_post_data( 'del' );
+
+    },
+
+    stale_data: function() {
+        var storage_data = this.handle_post_data();
+
+        if( storage_data  ) {
+            for( var i=0; i < storage_data.length; i++ ) {
+                storage_data[i]['storage_status'] = 'stale';
+            }
+            this.handle_post_data( storage_data );
+        }
+    },
+
+    remove_stale_data: function() {
+
+        var stored_data = this.get_storage();
+
+        var new_stored_data = {};
+
+        if( stored_data ) {
+
+            jQuery.each( stored_data, function( key, value ) {
+
+                var current_time = new Date().getTime();
+
+                var new_val_arr = new Array();
+
+                for( var i=0; i < value.length; i++ ) {
+
+                    var post_store = value[i];
+
+                    var time_diff = current_time - post_store['save_time']
+
+                    //check for 12 hr difference && stale data
+                    if( 'stale' != post_store['storage_status'] && 43200000 > time_diff  ) {
+                        new_val_arr.unshift( post_store );
+                    }
+
+                }
+
+                if( new_val_arr && 0 < new_val_arr.length ) {
+                    autosave_local_storage.modified_data[key] = new_val_arr;
+                }
+            });
+
+            storage_arr = JSON.stringify( autosave_local_storage.modified_data );
+            autosave_local_storage.modified_data = '';
+
+            localStorage.setItem( 'wp_autosave', storage_arr );
+
+        }
+    }
+}
Index: script-loader.php
===================================================================
--- script-loader.php	(revision 23353)
+++ script-loader.php	(working copy)
@@ -577,7 +577,8 @@
 	wp_localize_script( 'autosave', 'autosaveL10n', array(
 		'autosaveInterval' => AUTOSAVE_INTERVAL,
 		'savingText' => __('Saving Draft&#8230;'),
-		'saveAlert' => __('The changes you made will be lost if you navigate away from this page.')
+		'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
+		'blog_id' => get_current_blog_id()
 	) );
 
 }
