Commit 374305df authored by d11e9's avatar d11e9

fix rename and new file bug

parent dc1b100c
...@@ -113,10 +113,10 @@ THE SOFTWARE. ...@@ -113,10 +113,10 @@ THE SOFTWARE.
var $filesEl = $('#files'); var $filesEl = $('#files');
$filesEl.on('click','.newFile', function() { $filesEl.on('click','.newFile', function() {
var files = getFiles() while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount])
while (typeof files[SOL_CACHE_UNTITLED + untitledCount] !== 'undefined') untitledCount++; untitledCount++;
SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount; SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount;
window.localStorage[fileKey(SOL_CACHE_FILE)] = ''; window.localStorage[SOL_CACHE_FILE] = '';
updateFiles(); updateFiles();
}) })
...@@ -142,9 +142,9 @@ THE SOFTWARE. ...@@ -142,9 +142,9 @@ THE SOFTWARE.
$fileNameInputEl.off('keyup'); $fileNameInputEl.off('keyup');
if (newName !== originalName && confirm("Are you sure you want to rename: " + originalName + " to " + newName + '?')) { 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[fileKey( newName )] = content;
window.localStorage.removeItem( fileKey(originalName) ); window.localStorage.removeItem( fileKey( originalName) );
SOL_CACHE_FILE = fileKey( newName ); SOL_CACHE_FILE = fileKey( newName );
} }
......
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