Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
a42040de
Commit
a42040de
authored
Jan 10, 2018
by
Rob Stupay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update storage.js so no error when the window is not defined
parent
14a09cc7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
15 deletions
+29
-15
storage.js
remix-lib/src/storage.js
+29
-15
No files found.
remix-lib/src/storage.js
View file @
a42040de
...
@@ -2,16 +2,22 @@
...
@@ -2,16 +2,22 @@
function
Storage
(
prefix
)
{
function
Storage
(
prefix
)
{
this
.
exists
=
function
(
name
)
{
this
.
exists
=
function
(
name
)
{
return
this
.
get
(
name
)
!==
null
if
(
typeof
window
!==
'undefined'
)
{
return
this
.
get
(
name
)
!==
null
}
}
}
this
.
get
=
function
(
name
)
{
this
.
get
=
function
(
name
)
{
return
window
.
localStorage
.
getItem
(
prefix
+
name
)
if
(
typeof
window
!==
'undefined'
)
{
return
window
.
localStorage
.
getItem
(
prefix
+
name
)
}
}
}
this
.
set
=
function
(
name
,
content
)
{
this
.
set
=
function
(
name
,
content
)
{
try
{
try
{
window
.
localStorage
.
setItem
(
prefix
+
name
,
content
)
if
(
typeof
window
!==
'undefined'
)
{
window
.
localStorage
.
setItem
(
prefix
+
name
,
content
)
}
}
catch
(
exception
)
{
}
catch
(
exception
)
{
return
false
return
false
}
}
...
@@ -19,8 +25,10 @@ function Storage (prefix) {
...
@@ -19,8 +25,10 @@ function Storage (prefix) {
}
}
this
.
remove
=
function
(
name
)
{
this
.
remove
=
function
(
name
)
{
window
.
localStorage
.
removeItem
(
prefix
+
name
)
if
(
typeof
window
!==
'undefined'
)
{
return
true
window
.
localStorage
.
removeItem
(
prefix
+
name
)
return
true
}
}
}
this
.
rename
=
function
(
originalName
,
newName
)
{
this
.
rename
=
function
(
originalName
,
newName
)
{
...
@@ -34,7 +42,9 @@ function Storage (prefix) {
...
@@ -34,7 +42,9 @@ function Storage (prefix) {
function
safeKeys
()
{
function
safeKeys
()
{
// NOTE: this is a workaround for some browsers
// NOTE: this is a workaround for some browsers
return
Object
.
keys
(
window
.
localStorage
).
filter
(
function
(
item
)
{
return
item
!==
null
&&
item
!==
undefined
})
if
(
typeof
window
!==
'undefined'
)
{
return
Object
.
keys
(
window
.
localStorage
).
filter
(
function
(
item
)
{
return
item
!==
null
&&
item
!==
undefined
})
}
}
}
this
.
keys
=
function
()
{
this
.
keys
=
function
()
{
...
@@ -46,16 +56,20 @@ function Storage (prefix) {
...
@@ -46,16 +56,20 @@ function Storage (prefix) {
}
}
// on startup, upgrade the old storage layout
// on startup, upgrade the old storage layout
safeKeys
().
forEach
(
function
(
name
)
{
if
(
typeof
window
!==
'undefined'
)
{
if
(
name
.
indexOf
(
'sol-cache-file-'
,
0
)
===
0
)
{
safeKeys
().
forEach
(
function
(
name
)
{
var
content
=
window
.
localStorage
.
getItem
(
name
)
if
(
name
.
indexOf
(
'sol-cache-file-'
,
0
)
===
0
)
{
window
.
localStorage
.
setItem
(
name
.
replace
(
/^sol-cache-file-/
,
'sol:'
),
content
)
var
content
=
window
.
localStorage
.
getItem
(
name
)
window
.
localStorage
.
removeItem
(
name
)
window
.
localStorage
.
setItem
(
name
.
replace
(
/^sol-cache-file-/
,
'sol:'
),
content
)
}
window
.
localStorage
.
removeItem
(
name
)
})
}
})
}
// remove obsolete key
// remove obsolete key
window
.
localStorage
.
removeItem
(
'editor-size-cache'
)
if
(
typeof
window
!==
'undefined'
)
{
window
.
localStorage
.
removeItem
(
'editor-size-cache'
)
}
}
}
module
.
exports
=
Storage
module
.
exports
=
Storage
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment