Mercurial > hg > dml-open-vis
annotate src/DML/MainVisBundle/Resources/assets/jasmine/helpers.js @ 1:f38015048f48 tip
Added GPL
author | Daniel Wolff |
---|---|
date | Sat, 13 Feb 2016 20:43:38 +0100 |
parents | 493bcb69166c |
children |
rev | line source |
---|---|
Daniel@0 | 1 (function(){ |
Daniel@0 | 2 |
Daniel@0 | 3 var localStorageDumps = {}; |
Daniel@0 | 4 jasmine.helpers = { |
Daniel@0 | 5 |
Daniel@0 | 6 dumpStorage: function(dumpName) { |
Daniel@0 | 7 var realDumpName = _.isString(dumpName) ? dumpName : ""; |
Daniel@0 | 8 localStorageDumps[realDumpName] = {}; |
Daniel@0 | 9 var dump = localStorageDumps[realDumpName]; |
Daniel@0 | 10 for (var i = 0, len = localStorage.length; i < len; ++i) { |
Daniel@0 | 11 dump[localStorage.key(i)] = localStorage.getItem(localStorage.key(i)); |
Daniel@0 | 12 } |
Daniel@0 | 13 }, |
Daniel@0 | 14 |
Daniel@0 | 15 clearStorage: function() { |
Daniel@0 | 16 localStorage.clear(); |
Daniel@0 | 17 }, |
Daniel@0 | 18 |
Daniel@0 | 19 restoreStorageFromDump: function(dumpName) { |
Daniel@0 | 20 var realDumpName = _.isString(dumpName) ? dumpName : ""; |
Daniel@0 | 21 var localStorageDump = localStorageDumps[realDumpName]; |
Daniel@0 | 22 localStorage.clear(); |
Daniel@0 | 23 if (_.isObject(localStorageDump)) { |
Daniel@0 | 24 for(var key in localStorageDump) { |
Daniel@0 | 25 if (localStorageDump.hasOwnProperty(key)) { |
Daniel@0 | 26 localStorage.setItem(key,localStorageDump[key]); |
Daniel@0 | 27 } |
Daniel@0 | 28 } |
Daniel@0 | 29 } |
Daniel@0 | 30 } |
Daniel@0 | 31 }; |
Daniel@0 | 32 })(); |