diff --git a/css/main.css b/css/main.css index 1660bc9e..89228096 100644 --- a/css/main.css +++ b/css/main.css @@ -4,8 +4,6 @@ body { } #file-title { - float:right; - padding: 10px; } #file-title-input { diff --git a/index.html b/index.html index cceedb32..8bb4001a 100644 --- a/index.html +++ b/index.html @@ -41,7 +41,10 @@
diff --git a/js/main.js b/js/main.js index d1397c4c..c7b51f78 100644 --- a/js/main.js +++ b/js/main.js @@ -23,12 +23,12 @@ var fileManager = (function($) { $("#file-title-input").blur(function() { var title = $.trim($(this).val()); if(title) { - fileIndex = localStorage["file.current"]; + var fileIndex = localStorage["file.current"]; localStorage[fileIndex + ".title"] = title; } $(this).hide(); $("#file-title").show(); - fileManager.selectFile(); + fileManager.updateFileTitleUI(); }); }; @@ -40,7 +40,7 @@ var fileManager = (function($) { } this.updateFileTitleList(); // If no file create one - if(this.fileTitleList.length == 0) { + if(this.fileTitleList.length === 0) { this.createFile(); this.updateFileTitleList(); } @@ -58,9 +58,8 @@ var fileManager = (function($) { // Update the editor and the file title var fileIndex = localStorage["file.current"]; $("#wmd-input").val(localStorage[fileIndex + ".content"]); - var title = localStorage[fileIndex + ".title"]; - $("#file-title").text(title); - $("#file-title-input").val(title); + editor.refreshPreview(); + this.updateFileTitleUI(); }; fileManager.createFile = function(title) { @@ -83,23 +82,39 @@ var fileManager = (function($) { var title = localStorage[fileIndex + ".title"]; if(title) { this.fileTitleList[i] = title; + } + } + }; + + fileManager.updateFileTitleUI = function() { + // Update the editor and the file title + var fileIndex = localStorage["file.current"]; + var title = localStorage[fileIndex + ".title"]; + $("#file-title").text(title); + $("#file-title-input").val(title); + $("#file-selector").empty(); + for(var i=0; i