diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js index 25cba6e3..5fad1358 100644 --- a/app/assets/javascripts/editor.js +++ b/app/assets/javascripts/editor.js @@ -481,14 +481,8 @@ $(function() { }); }; - var showFrame = function(frame) { - active_frame = frame; - $('.frame').hide(); - frame.show(); - }; - - var showMainFile = function() { - var frame = $('.frame[data-role="main_file"]'); + var showFirstFile = function() { + var frame = $('.frame[data-role="main_file"]').isPresent() ? $('.frame[data-role="main_file"]') : $('.frame').first(); var file_id = frame.find('.editor').data('file-id'); active_file = { filename: frame.data('filename'), @@ -499,6 +493,12 @@ $(function() { toggleButtonStates(); }; + var showFrame = function(frame) { + active_frame = frame; + $('.frame').hide(); + frame.show(); + }; + var showOutput = function(event) { event.preventDefault(); showTab(2); @@ -613,7 +613,7 @@ $(function() { initializeFileTree(); initializeTooltips(); renderScore(); - showMainFile(); + showFirstFile(); showRequestedTab(); }