Commit d74cb8e5 authored by Alex Beregszaszi's avatar Alex Beregszaszi

Consistently use the set/getCacheFile abstraction

parent 0857b30a
...@@ -29,7 +29,7 @@ function Editor (doNotLoadStorage, storage) { ...@@ -29,7 +29,7 @@ function Editor (doNotLoadStorage, storage) {
while (storage.exists('Untitled' + untitledCount)) { while (storage.exists('Untitled' + untitledCount)) {
untitledCount = (untitledCount - 0) + 1 untitledCount = (untitledCount - 0) + 1
} }
SOL_CACHE_FILE = 'Untitled' + untitledCount this.setCacheFile('Untitled' + untitledCount)
this.setCacheFileContent('') this.setCacheFileContent('')
} }
...@@ -37,9 +37,10 @@ function Editor (doNotLoadStorage, storage) { ...@@ -37,9 +37,10 @@ function Editor (doNotLoadStorage, storage) {
var fileReader = new FileReader() var fileReader = new FileReader()
var name = file.name var name = file.name
var self = this
fileReader.onload = function (e) { fileReader.onload = function (e) {
storage.set(name, e.target.result) self.setCacheFile(name)
SOL_CACHE_FILE = name self.setCacheFileContent(e.target.result)
callback() callback()
} }
fileReader.readAsText(file) fileReader.readAsText(file)
...@@ -67,7 +68,7 @@ function Editor (doNotLoadStorage, storage) { ...@@ -67,7 +68,7 @@ function Editor (doNotLoadStorage, storage) {
} }
this.resetSession = function () { this.resetSession = function () {
editor.setSession(sessions[SOL_CACHE_FILE]) editor.setSession(sessions[this.getCacheFile()])
editor.focus() editor.focus()
} }
...@@ -185,13 +186,13 @@ function Editor (doNotLoadStorage, storage) { ...@@ -185,13 +186,13 @@ function Editor (doNotLoadStorage, storage) {
storage.set(examples.ballot.name, examples.ballot.content) storage.set(examples.ballot.name, examples.ballot.content)
} }
SOL_CACHE_FILE = files[0] this.setCacheFile(files[0])
for (var x in files) { for (var x in files) {
sessions[files[x]] = newEditorSession(files[x]) sessions[files[x]] = newEditorSession(files[x])
} }
editor.setSession(sessions[SOL_CACHE_FILE]) editor.setSession(sessions[this.getCacheFile()])
editor.resize(true) editor.resize(true)
} }
} }
......
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