zujuan.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. $(document).ready(function(){
  2. //弹出层的宽高
  3. $('.model-shadow').width($(window).width());
  4. $('.model-shadow').height($(window).height());
  5. //弹出层纠错显示
  6. $('.error-correction').each(function(){
  7. $(this).bind('click',function(){
  8. $('.model-test').show();
  9. });
  10. });
  11. //弹出层隐藏
  12. $('.close-error-correction').each(function(){
  13. $(this).bind('click',function(){
  14. $(this).closest('.model-close').hide();
  15. });
  16. });
  17. $('.change-question').bind('click',function(){
  18. $('.model-change-test').show();
  19. });
  20. //替换试题弹窗关闭
  21. $('.replace-question').bind('click',function(){
  22. $(this).closest('.model-close').hide();
  23. });
  24. //编辑试卷侧边栏
  25. $('.editing-test dt').each(function(){
  26. if($(this).find('font').html() != $(this).find('span').html()){
  27. $(this).addClass('bg-red').removeClass('bg-gray');
  28. }else{
  29. $(this).addClass('bg-gray').removeClass('bg-red');
  30. }
  31. });
  32. $("body").delegate('.editing-test dt','click',function(){
  33. $(this).closest('dl').find('dd').toggle();
  34. });
  35. //全选 第一层
  36. $('.set-useclass h2 input').bind('click',function(){
  37. $('.set-useclass input').attr('checked',$(this).attr('checked'));
  38. if($('.set-useclass dt input').attr('checked')){
  39. $('.set-useclass dt input').closest('dt').next('dd').find('input').attr('checked',$(this).attr('checked'));
  40. }else{
  41. $('.set-useclass dt input').closest('dt').next('dd').find('input').attr('checked',$(this).attr('checked'));
  42. }
  43. })
  44. //全选 第二层
  45. $('.set-useclass dt input').bind('click',function(){
  46. var _this = $('.set-useclass dt');
  47. $(this).closest('dt').next('dd').find('input').attr('checked',$(this).attr('checked'));
  48. sumTwo();
  49. });
  50. ////全选 第三层
  51. $('.set-useclass dd').each(function(){
  52. var _this = $(this);
  53. $(this).find('input').bind('click',function(){
  54. var res = 0;
  55. for(var i = 0;i<_this.find('input').length;i++){
  56. if(_this.find('input')[i].checked == true){
  57. res++;
  58. }
  59. }
  60. if(res == _this.find('input').length){
  61. $(this).closest('dl').find('dt input').attr('checked',true);
  62. }else{
  63. $(this).closest('dl').find('dt input').attr('checked',false);
  64. $('.set-useclass h2 input').attr('checked',false);
  65. }
  66. sumTwo();
  67. });
  68. });
  69. function sumTwo(){
  70. var res=0;
  71. for (var i = 0; i < $('.set-useclass dt input').length; i++) {
  72. if($('.set-useclass dt input').eq(i).attr('checked')){
  73. res++;
  74. }
  75. };
  76. if(res == $('.set-useclass dt input').length){
  77. $('.set-useclass h2 input').attr('checked',true);
  78. }else{
  79. $('.set-useclass h2 input').attr('checked',false);
  80. }
  81. }
  82. //设置周周练试卷难度
  83. $('.choose-test ol li').click(function(){
  84. if($(this).index() != 0){
  85. $(this).addClass('bg-hot').siblings('li').removeClass('bg-hot');
  86. }
  87. });
  88. //拖拽悬浮窗口
  89. $('.topic-total').bind('mousedown',function(ev){
  90. var _this = $(this);
  91. var oEv = ev || event;
  92. var disX = oEv.clientX - $(this).offset().left;
  93. var disY = oEv.clientY+$('body').scrollTop() - $(this).offset().top;
  94. $(document).bind('mousemove',function(ev){
  95. var oEv = ev || event;
  96. var l = oEv.clientX-disX;
  97. var t = oEv.clientY-disY;
  98. if(l<0) l=0;
  99. if(t<0) t=0;
  100. if(t>$(window).height()- _this.height()) t=$(window).height()- _this.height();
  101. if(l>$(window).width()- _this.width()) l=l > $(window).width()- _this.width();
  102. _this.css({'left':l+'px'});
  103. _this.css({'top':t+'px'});
  104. });
  105. $(document).mouseup(function(){
  106. $(document).unbind('mousemove');
  107. $(document).unbind('mouseup');
  108. });
  109. return false;
  110. });
  111. $('body').delegate('.choose-question .ellipsis','mouseover',function(){
  112. if($(this).siblings('.ellipsis-html').length != 0) return;
  113. $(this).parent('ul').append('<p class="ellipsis-html">'+$(this).html()+'</p>');
  114. });
  115. $('body').delegate('.choose-question .ellipsis','mouseout',function(){
  116. $(this).parent('ul').children('.ellipsis-html').remove();
  117. });
  118. //系统关闭窗口
  119. /*
  120. window.onbeforeunload = function()
  121. {
  122. setTimeout(onunloadcancel, 10);
  123. return "";
  124. }
  125. window.onunloadcancel = function()
  126. {
  127. // alert("不离开");
  128. return false;
  129. }
  130. */
  131. });
  132. function numToLetter(number) {
  133. var latters = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
  134. var result = '';
  135. if (number >= 1 && number <= 26)
  136. {
  137. result = latters[number - 1];
  138. }
  139. return result;
  140. }
  141. function numToUpper(number)
  142. {
  143. number = number.toString();
  144. number = number.substr(0, 2);
  145. var arr = ["零","一","二","三","四","五","六","七","八","九"];
  146. if (number.length == 1)
  147. {
  148. result = arr[number];
  149. }
  150. else
  151. {
  152. if (number == 10)
  153. {
  154. result ="十";
  155. }
  156. else
  157. {
  158. if (number < 20)
  159. {
  160. result = "十";
  161. }
  162. else
  163. {
  164. result = arr[number.substr(0, 1)] +"十";
  165. }
  166. if (number.substr(1, 1) != "0")
  167. {
  168. result += arr[number.substr(1, 1)];
  169. }
  170. }
  171. }
  172. return result;
  173. }