From 374305dfa1b02c9700810c311e754102b184485d Mon Sep 17 00:00:00 2001 From: d11e9 Date: Sun, 4 Oct 2015 21:13:30 +0000 Subject: [PATCH] fix rename and new file bug --- index.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index af6145acd5..5862da7770 100644 --- a/index.html +++ b/index.html @@ -113,10 +113,10 @@ THE SOFTWARE. var $filesEl = $('#files'); $filesEl.on('click','.newFile', function() { - var files = getFiles() - while (typeof files[SOL_CACHE_UNTITLED + untitledCount] !== 'undefined') untitledCount++; + while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount]) + untitledCount++; SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount; - window.localStorage[fileKey(SOL_CACHE_FILE)] = ''; + window.localStorage[SOL_CACHE_FILE] = ''; updateFiles(); }) @@ -142,9 +142,9 @@ THE SOFTWARE. $fileNameInputEl.off('keyup'); if (newName !== originalName && confirm("Are you sure you want to rename: " + originalName + " to " + newName + '?')) { - var content = window.localStorage.removeItem( fileKey(originalName) ); + var content = window.localStorage.getItem( fileKey(originalName) ); window.localStorage[fileKey( newName )] = content; - window.localStorage.removeItem( fileKey(originalName) ); + window.localStorage.removeItem( fileKey( originalName) ); SOL_CACHE_FILE = fileKey( newName ); }