diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index e00cb2f28..8e1edbfe6 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -183,22 +183,6 @@ nAjaxLoading.hide(); nInfoAjaxLoading.hide(); // test_sets 公开测,hide_test_sets 隐藏测试集 - - /* var html = bt('t:exec_results_1',{ - "test_sets": eval('[' + data.test_sets + ']'), - had_test_count: data.had_test_count, - test_sets_count: data.test_sets_count, - had_passed_testsests_error_count: data.had_passed_testsests_error_count, - test_sets_hidden_count: data.test_sets_hidden_count, - test_sets_public_count: data.test_sets_public_count, - had_passed_testsests_hidden_count: data.had_passed_testsests_hidden_count, - had_passed_testsests_public_count: data.had_passed_testsests_public_count, - final_score: data.final_score, - latest_output: data.latest_output, - language: data.language - }); - $("#game_test_set_results").html(html); - $(".blacktab_con").eq(1).trigger("click"); // 回到测试结果页面*/ code_evaluation( eval('[' + data.test_sets + ']'), data.had_test_count, diff --git a/app/views/games/_file_edit_form.html.erb b/app/views/games/_file_edit_form.html.erb index 992be58fc..36f240f9a 100644 --- a/app/views/games/_file_edit_form.html.erb +++ b/app/views/games/_file_edit_form.html.erb @@ -4,52 +4,38 @@
-
  • - -
  • +
  • + +
  • \ No newline at end of file diff --git a/app/views/games/_game_show.html.erb b/app/views/games/_game_show.html.erb index 54ec33729..ab0c8c441 100644 --- a/app/views/games/_game_show.html.erb +++ b/app/views/games/_game_show.html.erb @@ -68,10 +68,10 @@ <%= render :partial => "games/shixun_comment_block" %>
  • 发送
  • - " onclick="game_praise()" id="game_praise_tread" class="pt5 color-grey mr20"> + " onclick="game_praise('<%= @game_challenge.id %>', '<%= @game_challenge.class %>')" id="game_praise_tread" class="pt5 color-grey mr20"> " alt="赞" ><%= @praise_count %> - " onclick="game_tread()" id="game_tread" class="color-grey" style="padding-top:7px;"> + " onclick="game_tread('<%= @game_challenge.id %>')" id="game_tread" class="color-grey" style="padding-top:7px;"> " ><%= @tread_count %>
  • @@ -129,56 +129,4 @@ // 点赞/取消点赞功能 var praiseStatus = <%= @praise.nil? ? false : true %>; // 是否点赞 var treadStatus = <%= @tread.nil? ? false : true %>; // 是否踩 - var h = true; - function game_praise(){ - if(treadStatus){ - return; - } - $.ajax({ - url: '<%= praise_tread_praise_plus_path({:obj_id => @game_challenge.id, :obj_type => @game_challenge.class}) %>', - data: {horizontal: h, game_praise: true}, - success:function(data){ - h = !h; - var praise_count = $("#game_praise_count"); - if(data.praise){ - praiseStatus = true; //已赞 - praise_count.html(data.praise_tread_count); - $("#game_praise_tread").children("i").addClass("color-light-green"); - $("#game_praise_tread").attr("title", "取消点赞") - }else{ - praiseStatus = false; //取消赞 - praise_count.html(data.praise_tread_count); - $("#game_praise_tread").children("i").removeClass("color-light-green"); - $("#game_praise_tread").attr("title", "点赞") - } - } - }); - } - // 踩/取消踩功能 - var d = true; - function game_tread(){ - if(praiseStatus){ - return; - } - $.ajax({ - url: '<%= praise_tread_praise_plus_path({:obj_id => @game_challenge.id, :obj_type => "ChallengeTread"}) %>', - data: {horizontal: d, game_praise: true}, - success:function(data){ - d = !d; - var tread_count = $("#game_tread_count"); - if(data.praise){ - treadStatus = true; // 取消踩 - tread_count.html(data.praise_tread_count); - $("#game_tread").children("i").addClass("color-orange"); - $("#game_tread").attr("title", "取消踩") - }else{ - treadStatus = false; // 已踩 - tread_count.html(data.praise_tread_count); - $("#game_tread").children("i").removeClass("color-orange"); - $("#game_tread").attr("title", "踩"); - } - } - }); - } - \ No newline at end of file diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb index 55a9bd559..cc68d75b0 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -19,53 +19,4 @@ notice_sure_box("实训更新啦,系统已自动为您重置"); <% end %> }); - var control = 0; // 版本库控制 0表示点击放大 1表示点击缩小 - var control_1 = 0; // 测评控制 0表示点击放大 1表示点击缩小 - var nGameRes = $("#games_repository_contents"); // 版本库区域 - var nGameEva = $("#games_valuation_contents"); // 评测区域 - var nRIcon = $("#extend_and_zoom").children("i"); // 版本库放大缩小按钮 - var nCode = $("#file_entry_content").find(".CodeMirror-scroll"); // 版本库代码区域 - var nVIcon = $("#valuation_extend_and_zoom").children("i"); // 评测放大缩小 - var nMove = $(".h-center"); - -/* --------------------------------版本库的放大与缩小---------------------------------------------*/ - function repository_extend_and_zoom(){ - if(control == 0){ - nGameRes.addClass("-flex-basic100"); - nGameEva.addClass("-flex-basic0"); - nRIcon.addClass("fa-compress"); - nRIcon.removeClass("fa-arrows-alt"); - nMove.hide(); - control = 1; - }else if(control == 1){ - nGameRes.removeClass("-flex-basic100"); - nGameEva.removeClass("-flex-basic0"); - nRIcon.removeClass("fa-compress"); - nRIcon.addClass("fa-arrows-alt"); - nMove.show(); - control = 0; - } - editor_CodeMirror.setSize("auto", "auto"); - var h = nGameRes.height() - $("#top_repository").height() - 50; - nCode.css("min-height", h); - } - -/* --------------------------------测评的扩大与缩小---------------------------------------------*/ - function valuation_extend_and_zoom(){ - if(control_1 == 0){ - nGameRes.addClass("-flex-basic0"); - nGameEva.addClass("-flex-basic100"); - nVIcon.removeClass("fa-expand"); - nVIcon.addClass("fa-compress"); - nMove.hide(); - control_1 = 1; - }else if(control_1 == 1){ - nGameRes.removeClass("-flex-basic0"); - nGameEva.removeClass("-flex-basic100"); - nVIcon.addClass("fa-expand"); - nVIcon.removeClass("fa-compress"); - nMove.show(); - control_1 = 0; - } - } \ No newline at end of file diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 202e3378f..f3f0d3c20 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -217,6 +217,137 @@ function toggle_test_case(t_case, id){ } // end +// codemirror渲染textarea +function CodeMirror_fromTextArea(id){ + var Code = CodeMirror.fromTextArea(document.getElementById(id), { + /* mode: {name: "text/x-c++src", + // version: 2, + singleLineStringErrors: false},*/ // 目前补全js是引入的javascript-hint,因此目前不能指定语言 + lineNumbers: true, + theme: "railscasts", + // extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键 + indentUnit: 4, //代码缩进为一个tab的距离 + matchBrackets: true, + autoRefresh: true, + smartIndent: true,//智能换行 + extraKeys: {"Ctrl-Q": "autocomplete"}, + autofocus: true, + styleActiveLine: true, + lint: true, + gutters: ["CodeMirror-linenumbers", "breakpoints"] + }); + return Code; +} +// end + +var control = 0; // 版本库控制 0表示点击放大 1表示点击缩小 +var control_1 = 0; // 测评控制 0表示点击放大 1表示点击缩小 +// 版本库的放大与缩小 +function repository_extend_and_zoom(){ + var nGameRes = $("#games_repository_contents"); // 版本库区域 + var nGameEva = $("#games_valuation_contents"); // 评测区域 + var nRIcon = $("#extend_and_zoom").children("i"); // 版本库放大缩小按钮 + var nCode = $("#file_entry_content").find(".CodeMirror-scroll"); // 版本库代码区域 + var nMove = $(".h-center"); + if(control == 0){ + nGameRes.addClass("-flex-basic100"); + nGameEva.addClass("-flex-basic0"); + nRIcon.addClass("fa-compress"); + nRIcon.removeClass("fa-arrows-alt"); + nMove.hide(); + control = 1; + }else if(control == 1){ + nGameRes.removeClass("-flex-basic100"); + nGameEva.removeClass("-flex-basic0"); + nRIcon.removeClass("fa-compress"); + nRIcon.addClass("fa-arrows-alt"); + nMove.show(); + control = 0; + } + editor_CodeMirror.setSize("auto", "auto"); + var h = nGameRes.height() - $("#top_repository").height() - 50; + nCode.css("min-height", h); +} +// end + +// 测评的扩大与缩小 +function valuation_extend_and_zoom(){ + var nGameRes = $("#games_repository_contents"); // 版本库区域 + var nGameEva = $("#games_valuation_contents"); // 评测区域 + var nVIcon = $("#valuation_extend_and_zoom").children("i"); // 评测放大缩小 + var nMove = $(".h-center"); + if(control_1 == 0){ + nGameRes.addClass("-flex-basic0"); + nGameEva.addClass("-flex-basic100"); + nVIcon.removeClass("fa-expand"); + nVIcon.addClass("fa-compress"); + nMove.hide(); + control_1 = 1; + }else if(control_1 == 1){ + nGameRes.removeClass("-flex-basic0"); + nGameEva.removeClass("-flex-basic100"); + nVIcon.addClass("fa-expand"); + nVIcon.removeClass("fa-compress"); + nMove.show(); + control_1 = 0; + } +} +// end + +// 点赞与取消点赞 +var h = true; +function game_praise(obj_id, obj_type){ + if(treadStatus){ + return; + } + $.ajax({ + url: "/praise_tread/praise_plus?obj_id=" + obj_id + "&obj_type=" + obj_type, + data: {horizontal: h, game_praise: true}, + success:function(data){ + h = !h; + var praise_count = $("#game_praise_count"); + if(data.praise){ + praiseStatus = true; //已赞 + praise_count.html(data.praise_tread_count); + $("#game_praise_tread").children("i").addClass("color-light-green"); + $("#game_praise_tread").attr("title", "取消点赞") + }else{ + praiseStatus = false; //取消赞 + praise_count.html(data.praise_tread_count); + $("#game_praise_tread").children("i").removeClass("color-light-green"); + $("#game_praise_tread").attr("title", "点赞") + } + } + }); +} +// 踩/取消踩功能 +var d = true; +function game_tread(obj_id){ + if(praiseStatus){ + return; + } + $.ajax({ + url: "/praise_tread/praise_plus?obj_id=" + obj_id + "&obj_type=ChallengeTread", + data: {horizontal: d, game_praise: true}, + success:function(data){ + d = !d; + var tread_count = $("#game_tread_count"); + if(data.praise){ + treadStatus = true; // 取消踩 + tread_count.html(data.praise_tread_count); + $("#game_tread").children("i").addClass("color-orange"); + $("#game_tread").attr("title", "取消踩") + }else{ + treadStatus = false; // 已踩 + tread_count.html(data.praise_tread_count); + $("#game_tread").children("i").removeClass("color-orange"); + $("#game_tread").attr("title", "踩"); + } + } + }); +} +// end + // test_sets:测试集;had_test_count:输出集的个数;test_sets_count:测试集的个数;had_passed_testsests_error_count:测试集报错数;test_sets_hidden_count:隐藏测试集的个数 // test_sets_public_count:公开测试集的个人;had_passed_testsests_hidden_count:通过的隐藏集个数;had_passed_testsests_public_count:通过的公开测试集个数 // final_score:最终得分;latest_output:最新的输出;language:实训的语言 @@ -403,7 +534,5 @@ function code_evaluation(test_sets, $("#game_test_set_results").html($html); } -console.log($("#evaluating_info")); -console.log($(".-task-ces-box")); // end