Created
April 17, 2013 06:21
-
-
Save fud/5402164 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function clone(obj) { | |
| var target = {}; | |
| for (var i in obj) { | |
| if (obj.hasOwnProperty(i)) { | |
| target[i] = obj[i]; | |
| } | |
| } | |
| return target; | |
| } | |
| (function($, undefined) { | |
| var b64store = clone(store); | |
| b64store.serialize = function(value) { | |
| console.log('executing our serialize'); | |
| value = JSON.stringify(value); | |
| return rnn.modules.b64.encode(value); | |
| } | |
| b64store.deserialize = function(value) { | |
| console.log('executing our deserialize'); | |
| if (typeof value != 'string') { return undefined } | |
| try { | |
| console.log('Before decode ' + value); | |
| value = rnn.modules.b64.decode(value); | |
| console.log('After decode ' + value); | |
| return JSON.parse(value); | |
| } | |
| catch(e) { | |
| console.log('Erroring out ' + value); | |
| return value || undefined | |
| } | |
| } | |
| rnn.modules.register("b64store", { | |
| store: b64store, | |
| }); | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment