exercise.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  5. if(ret.code==1){
  6. Backend.api.addtabs( ret.url,'正在练习');
  7. }
  8. });
  9. },
  10. examing: function () {
  11. $(document).ready(function() {
  12. var countdownTime = Config.timer; // 倒计时时间,单位为秒
  13. var display = $('#timer');
  14. var timer = setInterval(function() {
  15. var minutes = parseInt(countdownTime / 60, 10);
  16. var seconds = parseInt(countdownTime % 60, 10);
  17. minutes = minutes < 10 ? "0" + minutes : minutes;
  18. seconds = seconds < 10 ? "0" + seconds : seconds;
  19. display.text(minutes + "分" + seconds+'秒');
  20. if (--countdownTime < 0) {
  21. clearInterval(timer);
  22. display.text("时间到!");
  23. }
  24. }, 1000);
  25. });
  26. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  27. if(ret.code==1){
  28. Backend.api.addtabs( ret.url,'得分分析');
  29. }
  30. });
  31. },
  32. analysis: function () {
  33. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  34. if(ret.code==1){
  35. Backend.api.addtabs( ret.url);
  36. }
  37. });
  38. },
  39. edit: function () {
  40. Controller.api.bindevent();
  41. },
  42. api: {
  43. bindevent: function () {
  44. Form.api.bindevent($("form[role=form]"));
  45. }
  46. }
  47. };
  48. return Controller;
  49. });