Skip to content

Commit

Permalink
Merge pull request #58 from rmg/remove-global-storage
Browse files Browse the repository at this point in the history
Remove global storage
  • Loading branch information
marcuswestin committed Dec 19, 2012
2 parents 9be0a4f + 51a4070 commit 0f1582e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 32 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -26,7 +26,7 @@ store.js depends on JSON for serialization.


How does it work? How does it work?
------------------ ------------------
store.js uses localStorage when available, and falls back on globalStorage for earlier versions of Firefox and the userData behavior in IE6 and IE7. No flash to slow down your page load. No cookies to fatten your network requests. store.js uses localStorage when available, and falls back on the userData behavior in IE6 and IE7. No flash to slow down your page load. No cookies to fatten your network requests.


Screencast Screencast
----------- -----------
Expand Down Expand Up @@ -160,3 +160,4 @@ Contributors
- [@whitehat101](https://github.com/whitehat101) Jeremy Ebler - [@whitehat101](https://github.com/whitehat101) Jeremy Ebler
- [@lepture](https://github.com/lepture) Hsiaoming Yang - [@lepture](https://github.com/lepture) Hsiaoming Yang
- [@lovejs](https://github.com/lovejs) Ruslan G - [@lovejs](https://github.com/lovejs) Ruslan G
- [@rmg](https://github.com/rmg) Ryan Graham
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -14,7 +14,8 @@
"Marcus Tucker <info@marcustucker.com> (https://github.com/MarcusJT)", "Marcus Tucker <info@marcustucker.com> (https://github.com/MarcusJT)",
"Leonid Bugaev <leonsbox@gmail.com> (https://github.com/buger)", "Leonid Bugaev <leonsbox@gmail.com> (https://github.com/buger)",
"Per Eckerdal <per.eckerdal@gmail.com> (https://github.com/pereckerdal)", "Per Eckerdal <per.eckerdal@gmail.com> (https://github.com/pereckerdal)",
"Fredrik Blomqvist (https://github.com/blq)" "Fredrik Blomqvist (https://github.com/blq)",
"Ryan Graham (https://github.com/rmg)"
], ],
"repository": { "repository": {
"type": "git", "type": "git",
Expand Down
2 changes: 1 addition & 1 deletion store+json2.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 0 additions & 25 deletions store.js
Expand Up @@ -24,7 +24,6 @@
win = window, win = window,
doc = win.document, doc = win.document,
localStorageName = 'localStorage', localStorageName = 'localStorage',
globalStorageName = 'globalStorage',
namespace = '__storejs__', namespace = '__storejs__',
storage storage


Expand Down Expand Up @@ -62,11 +61,6 @@
catch(err) { return false } catch(err) { return false }
} }


function isGlobalStorageNameSupported() {
try { return (globalStorageName in win && win[globalStorageName] && win[globalStorageName][win.location.hostname]) }
catch(err) { return false }
}

if (isLocalStorageNameSupported()) { if (isLocalStorageNameSupported()) {
storage = win[localStorageName] storage = win[localStorageName]
store.set = function(key, val) { store.set = function(key, val) {
Expand All @@ -85,25 +79,6 @@
} }
return ret return ret
} }
} else if (isGlobalStorageNameSupported()) {
storage = win[globalStorageName][win.location.hostname]
store.set = function(key, val) {
if (val === undefined) { return store.remove(key) }
storage[key] = store.serialize(val)
return val
}
store.get = function(key) { return store.deserialize(storage[key] && storage[key].value) }
store.remove = function(key) { delete storage[key] }
store.clear = function() { for (var key in storage ) { delete storage[key] } }
store.getAll = function() {
var ret = {}
for (var i=0; i<storage.length; ++i) {
var key = storage.key(i)
ret[key] = store.get(key)
}
return ret
}

} else if (doc.documentElement.addBehavior) { } else if (doc.documentElement.addBehavior) {
var storageOwner, var storageOwner,
storageContainer storageContainer
Expand Down
2 changes: 1 addition & 1 deletion store.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions test.html
Expand Up @@ -85,7 +85,7 @@
assert(!store.get('circularReference'), "attempting to store object with circular reference which should have faile affected store state") assert(!store.get('circularReference'), "attempting to store object with circular reference which should have faile affected store state")


// If plain local storage was used before store.js, we should attempt to JSON.parse them into javascript values. // If plain local storage was used before store.js, we should attempt to JSON.parse them into javascript values.
// Store values using vanilla local/globalStorage, then read them out using store.js // Store values using vanilla localStorage, then read them out using store.js
var promoteValues = { var promoteValues = {
'int' : 42, 'int' : 42,
'bool' : true, 'bool' : true,
Expand All @@ -96,8 +96,6 @@
for (key in promoteValues) { for (key in promoteValues) {
if (window.localStorage) { if (window.localStorage) {
window.localStorage[key] = promoteValues[key] window.localStorage[key] = promoteValues[key]
} else if (window.globalStorage) {
window.globalStorage[location.hostname][key] = promoteValues[key]
} }
} }
for(key in promoteValues) { for(key in promoteValues) {
Expand Down

0 comments on commit 0f1582e

Please sign in to comment.