Commit 7a9b1695 authored by chriseth's avatar chriseth Committed by GitHub

Merge pull request #77 from redsquirrel/encapsulate-cache-file-prefix

Encapsulating 'Cache File Prefix'
parents b1e4e018 861deadf
......@@ -6,7 +6,7 @@ var ace = require('brace');
require('../mode-solidity.js');
function Editor (loadingFromGist) {
var SOL_CACHE_UNTITLED = utils.getCacheFilePrefix() + 'Untitled';
var SOL_CACHE_UNTITLED = utils.fileKey('Untitled');
var SOL_CACHE_FILE = null;
var editor = ace.edit('input');
......@@ -70,7 +70,7 @@ function Editor (loadingFromGist) {
function getFiles () {
var files = [];
for (var f in window.localStorage) {
if (f.indexOf(utils.getCacheFilePrefix(), 0) === 0) {
if (utils.isCachedFile(f)) {
files.push(f);
if (!sessions[f]) sessions[f] = newEditorSession(f);
}
......
......@@ -35,7 +35,7 @@ function StorageHandler (updateFiles) {
for (var y in window.localStorage) {
console.log('checking', y);
obj[y] = window.localStorage.getItem(y);
if (y.indexOf(utils.getCacheFilePrefix()) !== 0) {
if (!utils.isCachedFile(y)) {
continue;
}
count++;
......
......@@ -4,6 +4,10 @@ function getCacheFilePrefix () {
return SOL_CACHE_FILE_PREFIX;
}
function isCachedFile (name) {
return name.indexOf(getCacheFilePrefix(), 0) === 0;
}
function fileKey (name) {
return getCacheFilePrefix() + name;
}
......@@ -17,7 +21,7 @@ function errortype (message) {
}
module.exports = {
getCacheFilePrefix: getCacheFilePrefix,
isCachedFile: isCachedFile,
fileKey: fileKey,
fileNameFromKey: fileNameFromKey,
errortype: errortype
......
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