|
79 | 79 | _pubsub_observers = {},
|
80 | 80 |
|
81 | 81 | /* skip published items older than current timestamp */
|
82 |
| - _pubsub_last = +new Date(), |
| 82 | + _pubsub_last = +new Date(), |
83 | 83 |
|
84 | 84 | /* Next check for TTL */
|
85 | 85 | _ttl_timeout,
|
|
256 | 256 | function _createPolyfillStorage(type, forceCreate){
|
257 | 257 | var _skipSave = false,
|
258 | 258 | _length = 0,
|
259 |
| - i, |
| 259 | + i, |
260 | 260 | storage,
|
261 | 261 | storage_source = {};
|
262 | 262 |
|
|
272 | 272 | return;
|
273 | 273 | }
|
274 | 274 |
|
275 |
| - // only IE6/7 from this point on |
| 275 | + // only IE6/7 from this point on |
276 | 276 | if(_backend != "userDataBehavior"){
|
277 | 277 | return;
|
278 | 278 | }
|
|
300 | 300 | storage[i] = storage_source[i];
|
301 | 301 | }
|
302 | 302 | }
|
303 |
| - |
| 303 | + |
304 | 304 | // Polyfill API
|
305 | 305 |
|
306 | 306 | /**
|
|
310 | 310 |
|
311 | 311 | /**
|
312 | 312 | * Returns the key of the nth stored value
|
313 |
| - * |
| 313 | + * |
314 | 314 | * @param {Number} n Index position
|
315 | 315 | * @return {String} Key name of the nth stored value
|
316 | 316 | */
|
|
345 | 345 | * Sets or updates value for a give key
|
346 | 346 | *
|
347 | 347 | * @param {String} key Key name to be updated
|
348 |
| - * @param {String} value String value to be stored |
| 348 | + * @param {String} value String value to be stored |
349 | 349 | */
|
350 | 350 | storage.setItem = function(key, value){
|
351 | 351 | if(typeof value == "undefined"){
|
|
365 | 365 | }
|
366 | 366 |
|
367 | 367 | storage[key] = undefined;
|
368 |
| - |
| 368 | + |
369 | 369 | _skipSave = true;
|
370 | 370 | if(key in storage){
|
371 | 371 | storage.removeAttribute(key);
|
|
783 | 783 | if(!_storage.__jstorage_meta.PubSub){
|
784 | 784 | _storage.__jstorage_meta.PubSub = [];
|
785 | 785 | }
|
786 |
| - |
| 786 | + |
787 | 787 | _storage.__jstorage_meta.PubSub.unshift([+new Date, channel, payload]);
|
788 | 788 |
|
789 | 789 | _save();
|
|
795 | 795 | * JS Implementation of MurmurHash2
|
796 | 796 | *
|
797 | 797 | * SOURCE: https://github.com/garycourt/murmurhash-js (MIT licensed)
|
798 |
| - * |
| 798 | + * |
799 | 799 | * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
|
800 | 800 | * @see http://github.com/garycourt/murmurhash-js
|
801 | 801 | * @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
|
802 | 802 | * @see http://sites.google.com/site/murmurhash/
|
803 |
| - * |
| 803 | + * |
804 | 804 | * @param {string} str ASCII only
|
805 | 805 | * @param {number} seed Positive integer only
|
806 | 806 | * @return {number} 32-bit positive integer hash
|
807 | 807 | */
|
808 | 808 |
|
809 |
| - function murmurhash2_32_gc(str, seed) { |
810 |
| - var |
811 |
| - l = str.length, |
812 |
| - h = seed ^ l, |
813 |
| - i = 0, |
814 |
| - k; |
815 |
| - |
816 |
| - while (l >= 4) { |
817 |
| - k = |
818 |
| - ((str.charCodeAt(i) & 0xff)) | |
819 |
| - ((str.charCodeAt(++i) & 0xff) << 8) | |
820 |
| - ((str.charCodeAt(++i) & 0xff) << 16) | |
821 |
| - ((str.charCodeAt(++i) & 0xff) << 24); |
822 |
| - |
823 |
| - k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16)); |
824 |
| - k ^= k >>> 24; |
825 |
| - k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16)); |
826 |
| - |
827 |
| - h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k; |
828 |
| - |
829 |
| - l -= 4; |
830 |
| - ++i; |
831 |
| - } |
832 |
| - |
833 |
| - switch (l) { |
834 |
| - case 3: h ^= (str.charCodeAt(i + 2) & 0xff) << 16; |
835 |
| - case 2: h ^= (str.charCodeAt(i + 1) & 0xff) << 8; |
836 |
| - case 1: h ^= (str.charCodeAt(i) & 0xff); |
837 |
| - h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)); |
838 |
| - } |
839 |
| - |
840 |
| - h ^= h >>> 13; |
841 |
| - h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)); |
842 |
| - h ^= h >>> 15; |
843 |
| - |
844 |
| - return h >>> 0; |
845 |
| - } |
| 809 | + function murmurhash2_32_gc(str, seed) { |
| 810 | + var |
| 811 | + l = str.length, |
| 812 | + h = (seed || 0x9747b28c) ^ l, |
| 813 | + i = 0, |
| 814 | + k, |
| 815 | + a = 0xff, |
| 816 | + b = 0xffff, |
| 817 | + c = 0x5bd1e995; |
| 818 | + |
| 819 | + while (l >= 4) { |
| 820 | + k = |
| 821 | + ((str.charCodeAt(i) & a)) | |
| 822 | + ((str.charCodeAt(++i) & a) << 8) | |
| 823 | + ((str.charCodeAt(++i) & a) << 16) | |
| 824 | + ((str.charCodeAt(++i) & a) << 24); |
| 825 | + |
| 826 | + k = (((k & b) * c) + ((((k >>> 16) * c) & b) << 16)); |
| 827 | + k ^= k >>> 24; |
| 828 | + k = (((k & b) * c) + ((((k >>> 16) * c) & b) << 16)); |
| 829 | + |
| 830 | + h = (((h & b) * c) + ((((h >>> 16) * c) & b) << 16)) ^ k; |
| 831 | + |
| 832 | + l -= 4; |
| 833 | + ++i; |
| 834 | + } |
| 835 | + |
| 836 | + switch (l) { |
| 837 | + case 3: h ^= (str.charCodeAt(i + 2) & a) << 16; |
| 838 | + case 2: h ^= (str.charCodeAt(i + 1) & a) << 8; |
| 839 | + case 1: h ^= (str.charCodeAt(i) & a); |
| 840 | + h = (((h & b) * c) + ((((h >>> 16) * c) & b) << 16)); |
| 841 | + } |
| 842 | + |
| 843 | + h ^= h >>> 13; |
| 844 | + h = (((h & b) * c) + ((((h >>> 16) * c) & b) << 16)); |
| 845 | + h ^= h >>> 15; |
| 846 | + |
| 847 | + return h >>> 0; |
| 848 | + } |
846 | 849 |
|
847 | 850 | ////////////////////////// PUBLIC INTERFACE /////////////////////////
|
848 | 851 |
|
|
883 | 886 |
|
884 | 887 | _storage[key] = value;
|
885 | 888 |
|
886 |
| - _storage.__jstorage_meta.CRC32[key] = "2."+murmurhash2_32_gc(JSON.stringify(value), 0x9747b28c); |
| 889 | + _storage.__jstorage_meta.CRC32[key] = "2."+murmurhash2_32_gc(JSON.stringify(value)); |
887 | 890 |
|
888 | 891 | this.setTTL(key, options.TTL || 0); // also handles saving and _publishChange
|
889 | 892 |
|
|
0 commit comments