From ad610cb0b23551e3430b6b98ad9613a48d7bd0fc Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 18 Sep 2015 11:29:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=9B=86=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E6=A1=86=E7=9A=84=E8=87=AA=E9=80=82=E5=BA=94?= =?UTF-8?q?=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../users/_user_programing_attr.html.erb | 13 ++- public/javascripts/homework.js | 9 +- public/javascripts/new_user.js | 91 ++++++++++++++++++- 3 files changed, 108 insertions(+), 5 deletions(-) diff --git a/app/views/users/_user_programing_attr.html.erb b/app/views/users/_user_programing_attr.html.erb index 0ebe997e2..0bfbd379f 100644 --- a/app/views/users/_user_programing_attr.html.erb +++ b/app/views/users/_user_programing_attr.html.erb @@ -11,7 +11,7 @@ <% homework.homework_tests.each_with_index do |test, index| %>
- + <% if index != 0 %> @@ -22,7 +22,7 @@ <% else %>
- +
@@ -34,4 +34,11 @@
- \ No newline at end of file + + + \ No newline at end of file diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index ca07093fe..0499ac5fb 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -168,7 +168,14 @@ $(function(){ $("#BluePopupBox").on('click', 'a.icon_add', function(){ var html = bt('t:test-answer-list', null); $(this).parent('.mt10').after(html); - + var inputs = document.getElementsByName("program[input][]"); + var outputs = document.getElementsByName("program[output][]"); + if (inputs.length == outputs.length) { + for (var i=0; i minHeight) { + if (maxHeight && elem.scrollHeight > maxHeight) { + height = maxHeight - padding; + style.overflowY = 'auto'; + style2.overflowY = 'auto'; + } else { + height = elem.scrollHeight - padding; + style.overflowY = 'hidden'; + style2.overflowY = 'hidden'; + }; + style.height = height + extra + 'px'; + style2.height = height + extra + 'px'; + scrollTop += parseInt(style.height) - elem.currHeight; + document.body.scrollTop = scrollTop; + document.documentElement.scrollTop = scrollTop; + elem.currHeight = parseInt(style.height); + }; + if (elem2.scrollHeight > minHeight) { + if (maxHeight && elem2.scrollHeight > maxHeight) { + height = maxHeight - padding; + style.overflowY = 'auto'; + style2.overflowY = 'auto'; + } else { + height = elem2.scrollHeight - padding; + style.overflowY = 'hidden'; + style2.overflowY = 'hidden'; + }; + style.height = height + extra + 'px'; + style2.height = height + extra + 'px'; + scrollTop += parseInt(style2.height) - elem2.currHeight; + document.body.scrollTop = scrollTop; + document.documentElement.scrollTop = scrollTop; + elem2.currHeight = parseInt(style2.height); + }; + }; + + addEvent(elem, 'propertychange', change); + addEvent(elem, 'input', change); + addEvent(elem, 'focus', change); + addEvent(elem2, 'propertychange', change); + addEvent(elem2, 'input', change); + addEvent(elem2, 'focus', change); + change(); +}; \ No newline at end of file