/*
 * MelonJS Game Engine
 * Copyright (C) 2011 - 2013 melonJS
 * http://www.melonjs.org
 *
 */

(function(window) {
    
    /** 
     * A singleton object to access the device localStorage area
     * @example
     * // Initialize "score" and "lives" with default values
     * me.save.add({ score : 0, lives : 3 });
     *
     * // Save score
     * me.save.score = 31337;
     *
     * // Load lives
     * console.log(me.save.lives);
     *
     * // Also supports complex objects thanks to JSON backend
     * me.save.complexObject = { a : "b", c : [ 1, 2, 3, "d" ], e : { f : [{}] } };
     * // DO NOT set any child properties of me.save.complexObject directly!
     * // Changes made that way will not save. Always set the entire object value at once.
     *
     * // Print all
     * console.log(JSON.stringify(me.save));
     *
     * // Delete "score" from localStorage
     * me.save.delete('score');
     * @namespace me.save
     * @memberOf me
     */

    me.save = (function () {
        // Variable to hold the object data
        var data = {};

        // a fucntion to check if the given key is a reserved word
        function isReserved (key) {
            return (key === "add" || key === "delete");
        }

        // Public API
        var api = {

            /**
             * @ignore
             */
            _init: function() {
                // Load previous data if local Storage is supported
                if (me.device.localStorage === true) {
                    var keys = JSON.parse(localStorage.getItem("me.save")) || [];
                    keys.forEach(function (key) {
                        data[key] = JSON.parse(localStorage.getItem("me.save." + key));
                    });
                }
            },

            /**
             * Add new keys to localStorage and set them to the given default values if they do not exist
             * @name add
             * @memberOf me.save
             * @function
             * @param {Object} props key and corresponding values
             * @example
             * // Initialize "score" and "lives" with default values
             * me.save.add({ score : 0, lives : 3 });
             */
            add : function (props) {
                Object.keys(props).forEach(function (key) {
                    if (isReserved(key)) return;

                    (function (prop) {
                        Object.defineProperty(api, prop, {
                            configurable : true,
                            enumerable : true,
                            get : function () {
                                return data[prop];
                            },
                            set : function (value) {
                                data[prop] = value;
                                if (me.device.localStorage === true) {
                                    localStorage.setItem("me.save." + prop, JSON.stringify(value));
                                }
                            }
                        });
                    })(key);

                    // Set default value for key
                    if (!(key in data)) {
                        api[key] = props[key];
                    }
                });

                // Save keys
                if (me.device.localStorage === true) {
                    localStorage.setItem("me.save", JSON.stringify(Object.keys(data)));
                }
            },

            /**
             * Remove a key from localStorage
             * @name delete
             * @memberOf me.save
             * @function
             * @param {String} key key to be removed
             * @example
             * // Remove the "score" key from localStorage
             * me.save.delete("score");
             */
            delete : function (key) {
                if (!isReserved(key)) {
                    if (typeof data[key] !== 'undefined') {
                        delete data[key];
                        if (me.device.localStorage === true) {
                            localStorage.removeItem("me.save." + key);
                            localStorage.setItem("me.save", JSON.stringify(Object.keys(data)));
                        }
                    }
                }
            }
        };

        return api;

    })();
})(window);

@@ -848,13 +848,13 @@
  // 
-Delet
+Remov
 e %22s
@@ -892,21 +892,21 @@
 me.save.
-delet
+remov
 e('score
@@ -1080,10 +1080,10 @@
 a fu
-c
 n
+c
 tion
@@ -1210,21 +1210,21 @@
 ey === %22
-delet
+remov
 e%22);%0A   
@@ -3535,21 +3535,21 @@
 * @name 
-delet
+remov
 e%0A      
@@ -3759,21 +3759,21 @@
 me.save.
-delet
+remov
 e(%22score
@@ -3804,21 +3804,21 @@
         
-delet
+remov
 e : func

Rename me.save.delete -> me.save.remove