From 632b41da236e3b6c5e7e8065f45265c4814c79f6 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Fri, 25 Sep 2015 12:13:08 +0200 Subject: [PATCH] editor has an option whether it should remember the last used tab and show it, or whether it should display the first tab. currently, it shows the first tab. (as users whished for this behaviour) --- app/assets/javascripts/editor.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js index 25767031..9d866998 100644 --- a/app/assets/javascripts/editor.js +++ b/app/assets/javascripts/editor.js @@ -11,6 +11,7 @@ $(function() { var FILENAME_URL_PLACEHOLDER = '{filename}'; var SUCCESSFULL_PERCENTAGE = 90; var THEME = 'ace/theme/textmate'; + var REMEMBER_TAB = false; var AUTOSAVE_INTERVAL = 15 * 1000; var editors = []; @@ -946,11 +947,16 @@ $(function() { }; var showRequestedTab = function() { - var regexp = /tab=(\d+)/; - if (regexp.test(window.location.search)) { - var index = regexp.exec(window.location.search)[1] - 1; + if(REMEMBER_TAB){ + var regexp = /tab=(\d+)/; + if (regexp.test(window.location.search)) { + var index = regexp.exec(window.location.search)[1] - 1; + } else { + var index = localStorage.tab; + } } else { - var index = localStorage.tab; + // else start with first tab. + var index = 0; } showTab(index); };