Commit 60fc07ee authored by Alex Beregszaszi's avatar Alex Beregszaszi

Add boolean to set/remove/rename in storage

parent c4e4d366
...@@ -10,7 +10,12 @@ function Storage () { ...@@ -10,7 +10,12 @@ function Storage () {
} }
this.set = function (name, content) { this.set = function (name, content) {
try {
window.localStorage.setItem('sol:' + name, content) window.localStorage.setItem('sol:' + name, content)
} catch (exception) {
return false
}
return true
} }
function safeKeys () { function safeKeys () {
...@@ -28,12 +33,16 @@ function Storage () { ...@@ -28,12 +33,16 @@ function Storage () {
this.remove = function (name) { this.remove = function (name) {
window.localStorage.removeItem('sol:' + name) window.localStorage.removeItem('sol:' + name)
return true
} }
this.rename = function (originalName, newName) { this.rename = function (originalName, newName) {
var content = this.get(originalName) var content = this.get(originalName)
this.set(newName, content) if (!this.set(newName, content)) {
return false
}
this.remove(originalName) this.remove(originalName)
return true
} }
this.loadFile = function (filename, content) { this.loadFile = function (filename, content) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment