From b070292b4584e438b5c238c739f5c9c063608999 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 30 Mar 2017 10:05:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BB=BB=E5=8A=A1=E9=80=9A?= =?UTF-8?q?=E5=85=B3=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 2 +- app/views/games/_exec_results.html.erb | 8 +++- app/views/games/_pass_game_show.html.erb | 13 ++++--- app/views/layouts/base_myshixun.html.erb | 48 ++++++++++++------------ 4 files changed, 40 insertions(+), 31 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index ad3bd71b6..47383d628 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -126,7 +126,7 @@ class GamesController < ApplicationController else outputs = outputs.map{|result| [result.code, result.id]} end - had_done = 1 if (@myshixun.games.count == game_challenge.position && @game.status ==2) + (@myshixun.games.count == game_challenge.position && @game.status ==2) ? had_done = 1 : had_done = 0 latest_output = @game.latest_output.try(:out_put) render :json => {status: @game.status, output: latest_output, results: outputs, had_done: had_done} end diff --git a/app/views/games/_exec_results.html.erb b/app/views/games/_exec_results.html.erb index 786820655..a788c10ef 100644 --- a/app/views/games/_exec_results.html.erb +++ b/app/views/games/_exec_results.html.erb @@ -111,6 +111,7 @@ data:'test', success:function(data){ //如果查到了,就退出 + // i变量用来统计setInterval执行了多少次,便于统计访问时间 i = i + 1; if(data.status == 2 || data.status == 0){ clearInterval(intId); @@ -119,11 +120,16 @@ var html = bt('t:exec_results',{status: data.status, output: data.output, results: data.results, had_done: data.had_done}); $("#code_results").html(html); if(data.status == 2){ - var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun}) %>"; + if( data.had_done == 0 ) { + var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun, :had_done => 1}) %>"; + }else{ + var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun, :had_done => 1}) %>"; + } // 传递具体屏幕的宽高,实现不同浏览器与不同分辨率都能撑满屏幕 pop_box_new2(htmlvalue, window.innerWidth, window.innerHeight); } } + // 访问30次,即60s后后台还未改变状态即执行 if(i == 30){ $.ajax({ url: '<%= change_status_myshixun_game_path(@game, :myshixun_id => @myshixun) %>', diff --git a/app/views/games/_pass_game_show.html.erb b/app/views/games/_pass_game_show.html.erb index 45ba36b08..b21b5f46e 100644 --- a/app/views/games/_pass_game_show.html.erb +++ b/app/views/games/_pass_game_show.html.erb @@ -1,12 +1,15 @@ <%= stylesheet_link_tag 'css/bigdata-common', 'css/bigdata-popup' %>
-
+
">
-

恭喜您通过本关

- <%= link_to "下 一 步", {:controller => 'games', :action => "next_step", :id => game, :myshixun_id => myshixun}, :class => "task-su-btn", :remote => true %> + <% if had_done == 0 %> +

恭喜您通过本关

+ <%= link_to "下 一 步", {:controller => 'games', :action => "next_step", :id => game, :myshixun_id => myshixun}, :class => "task-su-btn", :remote => true %> + <% else %> + 查看光辉历史 + <% end %>
-
- +
\ No newline at end of file diff --git a/app/views/layouts/base_myshixun.html.erb b/app/views/layouts/base_myshixun.html.erb index 428753b9c..436097dce 100644 --- a/app/views/layouts/base_myshixun.html.erb +++ b/app/views/layouts/base_myshixun.html.erb @@ -20,33 +20,33 @@
-
+
- - -
+ + +
- <%= render :partial => "myshixuns/myshixun_top" %> - <%= yield %> -
+ <%= render :partial => "myshixuns/myshixun_top" %> + <%= yield %> +