Commit 705d465a authored by Alex Beregszaszi's avatar Alex Beregszaszi

Reorder storage.js

parent 944a5863
'use strict' 'use strict'
function Storage () { function Storage () {
this.rename = function (originalName, newName) {
var content = this.get(originalName)
this.set(newName, content)
this.remove(originalName)
}
this.remove = function (name) {
window.localStorage.removeItem(name)
}
this.exists = function (key) { this.exists = function (key) {
return !!this.get(key) return !!this.get(key)
} }
this.set = function (key, content) {
window.localStorage.setItem(key, content)
}
this.get = function (key) { this.get = function (key) {
return window.localStorage.getItem(key) return window.localStorage.getItem(key)
} }
this.set = function (key, content) {
window.localStorage.setItem(key, content)
}
this.keys = function () { this.keys = function () {
// 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 }) return Object.keys(window.localStorage).filter(function (item) { return item !== null && item !== undefined })
} }
this.remove = function (name) {
window.localStorage.removeItem(name)
}
this.rename = function (originalName, newName) {
var content = this.get(originalName)
this.set(newName, content)
this.remove(originalName)
}
this.loadFile = function (filename, content) { this.loadFile = function (filename, content) {
if (this.exists(filename) && this.get(filename) !== content) { if (this.exists(filename) && this.get(filename) !== content) {
var count = '' var count = ''
......
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