diff --git a/app/templates/shixun_work/shixun_work.html.erb b/app/templates/shixun_work/shixun_work.html.erb index 76a269f3f..fa2ad8101 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.present? %> + <% @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 %>