From 3848ab142ae5e834d9910a1eb7af729299501111 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 9 Jan 2020 11:53:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shixun_work/shixun_work.html.erb | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/app/templates/shixun_work/shixun_work.html.erb b/app/templates/shixun_work/shixun_work.html.erb index 76a269f3f..04ba5e038 100644 --- a/app/templates/shixun_work/shixun_work.html.erb +++ b/app/templates/shixun_work/shixun_work.html.erb @@ -240,25 +240,27 @@ window.onload = function() { console.debug("window.onload"); - <% @games.map(&:id).each do |game_id| %> + <% if @games %> + <% @games.map(&:id).each do |game_id| %> var ele = document.getElementById("content_show_<%= game_id %>"); if (ele) { - var ide = CodeMirror.fromTextArea(ele, { - lineNumbers: true, - theme: "default", - // extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键 - indentUnit: 4, //代码缩进为一个tab的距离 - matchBrackets: true, - autoRefresh: true, - smartIndent: true,//智能换行 - styleActiveLine: true, - lineWrapping: true, - lint: true, - readOnly: "nocursor" - }); + var ide = CodeMirror.fromTextArea(ele, { + lineNumbers: true, + theme: "default", + // extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键 + indentUnit: 4, //代码缩进为一个tab的距离 + matchBrackets: true, + autoRefresh: true, + smartIndent: true,//智能换行 + styleActiveLine: true, + lineWrapping: true, + lint: true, + readOnly: "nocursor" + }); - ide.setSize("auto", ide.lineCount() * 18); + ide.setSize("auto", ide.lineCount() * 18); } + <% end %> <% end %> From 1159fa72ab1fa15174d338e97f4daf4863e2571b Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 9 Jan 2020 11:56:12 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/shixun_work/shixun_work.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/shixun_work/shixun_work.html.erb b/app/templates/shixun_work/shixun_work.html.erb index 04ba5e038..fa2ad8101 100644 --- a/app/templates/shixun_work/shixun_work.html.erb +++ b/app/templates/shixun_work/shixun_work.html.erb @@ -240,7 +240,7 @@ window.onload = function() { console.debug("window.onload"); - <% if @games %> + <% if @games.present? %> <% @games.map(&:id).each do |game_id| %> var ele = document.getElementById("content_show_<%= game_id %>"); if (ele) {