diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 6f2f62143..b9faa41e9 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -17,10 +17,21 @@ class GamesController < ApplicationController end # mushixun的版本库必须创建时就创建 + # 首次进入版本库自动打开文件 + # path:"" && path: @game.path def show + game_path = (@game.path.blank? ? @game.path : @game.path.strip) @rev = @rev.nil? ? "master" : @rev @git_url = git_repository_url(@myshixun, "Myshixun") - @entries = @repository.entries(@path, @rev) + @type = params[:type] + # 默认打开文件 + if @path == "" && !game_path.nil? && !@repository.cat(game_path, @rev).blank? && @type != "root" + @path = game_path + @file_open = true + @content = @repository.cat(@path, @rev) + else + @entries = @repository.entries(@path, @rev) + end @latest_output = @game.latest_output.try(:out_put) outputs = @game.outputs @had_done = 1 if (@myshixun.games.count == @game.stage && @game.status ==2) @@ -33,6 +44,8 @@ class GamesController < ApplicationController format.html format.js end + rescue Exception => e + flash[:error] = e.message end # 代码预览 @@ -47,9 +60,9 @@ class GamesController < ApplicationController def file_edit entry_and_raw(false) @content = @repository.cat(@path, @rev).rstrip - respond_to do |format| - format.js - end + # respond_to do |format| + # format.js + # end end def file_update diff --git a/app/views/games/_exec_results.html.erb b/app/views/games/_exec_results.html.erb index 733caeb04..1a9005426 100644 --- a/app/views/games/_exec_results.html.erb +++ b/app/views/games/_exec_results.html.erb @@ -95,34 +95,33 @@ var html = bt('t:exec_results',{status: <%= @game.status %>, output:"<%= @latest_output %>", results: <%= @results %>, had_done: "<%= @had_done %>"}); $("#code_results").html(html); }); - function training_task_submmit(){ + $("#ajax-indicator").show(); $("#game_commit").html("评测中.."); $.ajax({ url: '<%= game_build_myshixun_game_path(@game, :myshixun_id => @myshixun) %>', success: function (){ - - //循环等1分钟 + //移除载入 + var temp = $("#ajax-indicator"); + $("#ajax-indicator").remove(); var intId = setInterval(function(){ $.ajax({ url: '<%= game_status_myshixun_game_path(@game, :myshixun_id => @myshixun) %>', data:'test', success:function(data){ //如果查到了,就退出 - console.log(html); if(data.status == 2 || data.status == 0){ - alert("进来了"); clearInterval(intId); + $("#ajax-position").html(temp); + $("#ajax-indicator").hide(); var html = bt('t:exec_results',{status: data.status, output: data.output, results: data.results, had_done: data.had_done}); - console.log(html); $("#code_results").html(html); } } }); }, 2000); } - }) - + }); } function extend_window(){ var web_h = window.innerHeight; diff --git a/app/views/games/_myshixun_breadcrumbs.html.erb b/app/views/games/_myshixun_breadcrumbs.html.erb index 5e9e01b87..a41bb3947 100644 --- a/app/views/games/_myshixun_breadcrumbs.html.erb +++ b/app/views/games/_myshixun_breadcrumbs.html.erb @@ -2,7 +2,7 @@ <% if @path.blank? %> <%= @repository.identifier %> <% else %> - <%= link_to "#{@repository.identifier.present? ? h(@repository.identifier) : 'root'}", myshixun_game_path(@game, :myshixun_id => @myshixun) %> + <%= link_to "#{@repository.identifier.present? ? h(@repository.identifier) : 'root'}", myshixun_game_path(@game, :myshixun_id => @myshixun, :type => "root"), :remote => true %> <% dirs = path.split('/') if 'file' == kind diff --git a/app/views/games/_myshixun_extend_repository.html.erb b/app/views/games/_myshixun_extend_repository.html.erb index 84a876b94..bc936059a 100644 --- a/app/views/games/_myshixun_extend_repository.html.erb +++ b/app/views/games/_myshixun_extend_repository.html.erb @@ -1,7 +1,7 @@