pull/1/head
chriseth 9 years ago
parent 7985e9864d
commit 81eb45fb3a
  1. 30
      index.html

@ -122,14 +122,14 @@ THE SOFTWARE.
$filesEl.on('click','.newFile', function() {
count++;
var name = 'Unititled' + count;
solFiles.push( name )
solFiles.push(name);
SOL_CACHE_FILE = name;
window.localStorage.setItem(SOL_CACHE_FILES_KEY, JSON.stringify(solFiles));
window.localStorage.setItem(SOL_CACHE_FILE, '');
updateFiles();
})
$filesEl.on( 'click','.file:not(.active)', showFileHandler )
$filesEl.on('click', '.file:not(.active)', showFileHandler);
$filesEl.on('click', '.file.active', function(ev) {
var $fileTabEl = $(this);
@ -155,11 +155,11 @@ THE SOFTWARE.
solFiles.splice(solFiles.indexOf(originalName), 1, newName);
window.localStorage.setItem(newName, window.localStorage.getItem(originalName));
window.localStorage.setItem(SOL_CACHE_FILES_KEY, JSON.stringify(solFiles));
window.localStorage.removeItem( originalName )
window.localStorage.removeItem(originalName);
SOL_CACHE_FILE = newName;
}
updateFiles()
updateFiles();
return false;
}
@ -168,46 +168,46 @@ THE SOFTWARE.
$filesEl.on('click', '.file .remove', function(ev) {
ev.preventDefault();
var name = $(this).parent().find('.name').text()
var name = $(this).parent().find('.name').text();
if (confirm("Are you sure you want to remove: " + name + " from local storage?")) {
var index = solFiles.indexOf(name);
solFiles.splice(index, 1);
window.localStorage.setItem(SOL_CACHE_FILES_KEY, JSON.stringify(solFiles));
SOL_CACHE_FILE = solFiles[ Math.max(0, index - 1)]
window.localStorage.removeItem( name )
updateFiles()
SOL_CACHE_FILE = solFiles[ Math.max(0, index - 1)];
window.localStorage.removeItem(name);
updateFiles();
}
return false;
});
function showFileHandler(ev) {
ev.preventDefault()
ev.preventDefault();
SOL_CACHE_FILE = $(this).find('.name').text();
updateFiles()
(updateFiles();
return false;
}
function fileTabFromName(name) {
return $('#files .file').filter(function(){ return $(this).find('.name').text() == name; })
return $('#files .file').filter(function(){ return $(this).find('.name').text() == name; });
}
function updateFiles() {
$filesEl.find('.file').remove()
$filesEl.find('.file').remove();
for (var f in solFiles) {
if (solFiles[f]) $filesEl.append(fileTabTemplate(solFiles[f]));
}
var active = fileTabFromName(SOL_CACHE_FILE);
active.addClass('active')
active.addClass('active');
editor.setValue(window.localStorage.getItem(SOL_CACHE_FILE) || '', -1);
$('#input').toggle( typeof SOL_CACHE_FILE === 'string' )
$('#input').toggle(typeof SOL_CACHE_FILE === 'string');
}
function fileTabTemplate(name) {
return $('<span class="file"><span class="name">'+name+'</span><span class="remove">x</span></span>');
}
SOL_CACHE_FILE = solFiles[0]
SOL_CACHE_FILE = solFiles[0];
updateFiles();
// ----------------- version selector-------------

Loading…
Cancel
Save