fix rename and new file bug

pull/1/head
d11e9 10 years ago
parent dc1b100c9d
commit 374305dfa1
  1. 10
      index.html

@ -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.
$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 );
} }

Loading…
Cancel
Save