From c16d0fb99f812d6d54c0a434e4f706139df22898 Mon Sep 17 00:00:00 2001 From: d11e9 Date: Fri, 9 Oct 2015 10:32:58 +0100 Subject: [PATCH] tidy filesEl hack --- index.html | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index b565c318bf..dcb8901253 100644 --- a/index.html +++ b/index.html @@ -93,8 +93,6 @@ THE SOFTWARE. $(document).ready(function() { - var $filesEl = $('#files'); - // ------------------ gist load ---------------- var location_hash_params = window.location.hash.substr(1).split("="); @@ -202,7 +200,7 @@ THE SOFTWARE. // ----------------- file selector------------- - + var $filesEl = $('#files'); $filesEl.on('click','.newFile', function() { while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount]) untitledCount = (untitledCount - 0) + 1; @@ -273,8 +271,11 @@ THE SOFTWARE. function updateFiles() { - $filesEl.find('.file').remove(); + var $filesEl = $('#files'); var files = getFiles(); + + $filesEl.find('.file').remove(); + for (var f in files) { $filesEl.append(fileTabTemplate(files[f])); } @@ -284,10 +285,8 @@ THE SOFTWARE. active.addClass('active'); editor.setValue( window.localStorage[SOL_CACHE_FILE] || '', -1); editor.focus(); - $('#input').toggle( true ); - } else { - $('#input').toggle( false ); - } + } + $('#input').toggle( !!SOL_CACHE_FILE ); } function fileTabTemplate(key) {