$(document).ready(function(){ //弹出层的宽高 $('.model-shadow').width($(window).width()); $('.model-shadow').height($(window).height()); //弹出层纠错显示 $('.error-correction').each(function(){ $(this).bind('click',function(){ $('.model-test').show(); }); }); //弹出层隐藏 $('.close-error-correction').each(function(){ $(this).bind('click',function(){ $(this).closest('.model-close').hide(); }); }); $('.change-question').bind('click',function(){ $('.model-change-test').show(); }); //替换试题弹窗关闭 $('.replace-question').bind('click',function(){ $(this).closest('.model-close').hide(); }); //编辑试卷侧边栏 $('.editing-test dt').each(function(){ if($(this).find('font').html() != $(this).find('span').html()){ $(this).addClass('bg-red').removeClass('bg-gray'); }else{ $(this).addClass('bg-gray').removeClass('bg-red'); } }); $("body").delegate('.editing-test dt','click',function(){ $(this).closest('dl').find('dd').toggle(); }); //全选 第一层 $('.set-useclass h2 input').bind('click',function(){ $('.set-useclass input').attr('checked',$(this).attr('checked')); if($('.set-useclass dt input').attr('checked')){ $('.set-useclass dt input').closest('dt').next('dd').find('input').attr('checked',$(this).attr('checked')); }else{ $('.set-useclass dt input').closest('dt').next('dd').find('input').attr('checked',$(this).attr('checked')); } }) //全选 第二层 $('.set-useclass dt input').bind('click',function(){ var _this = $('.set-useclass dt'); $(this).closest('dt').next('dd').find('input').attr('checked',$(this).attr('checked')); sumTwo(); }); ////全选 第三层 $('.set-useclass dd').each(function(){ var _this = $(this); $(this).find('input').bind('click',function(){ var res = 0; for(var i = 0;i<_this.find('input').length;i++){ if(_this.find('input')[i].checked == true){ res++; } } if(res == _this.find('input').length){ $(this).closest('dl').find('dt input').attr('checked',true); }else{ $(this).closest('dl').find('dt input').attr('checked',false); $('.set-useclass h2 input').attr('checked',false); } sumTwo(); }); }); function sumTwo(){ var res=0; for (var i = 0; i < $('.set-useclass dt input').length; i++) { if($('.set-useclass dt input').eq(i).attr('checked')){ res++; } }; if(res == $('.set-useclass dt input').length){ $('.set-useclass h2 input').attr('checked',true); }else{ $('.set-useclass h2 input').attr('checked',false); } } //设置周周练试卷难度 $('.choose-test ol li').click(function(){ if($(this).index() != 0){ $(this).addClass('bg-hot').siblings('li').removeClass('bg-hot'); } }); //拖拽悬浮窗口 $('.topic-total').bind('mousedown',function(ev){ var _this = $(this); var oEv = ev || event; var disX = oEv.clientX - $(this).offset().left; var disY = oEv.clientY+$('body').scrollTop() - $(this).offset().top; $(document).bind('mousemove',function(ev){ var oEv = ev || event; var l = oEv.clientX-disX; var t = oEv.clientY-disY; if(l<0) l=0; if(t<0) t=0; if(t>$(window).height()- _this.height()) t=$(window).height()- _this.height(); if(l>$(window).width()- _this.width()) l=l > $(window).width()- _this.width(); _this.css({'left':l+'px'}); _this.css({'top':t+'px'}); }); $(document).mouseup(function(){ $(document).unbind('mousemove'); $(document).unbind('mouseup'); }); return false; }); $('body').delegate('.choose-question .ellipsis','mouseover',function(){ if($(this).siblings('.ellipsis-html').length != 0) return; $(this).parent('ul').append('

'+$(this).html()+'

'); }); $('body').delegate('.choose-question .ellipsis','mouseout',function(){ $(this).parent('ul').children('.ellipsis-html').remove(); }); //系统关闭窗口 /* window.onbeforeunload = function() { setTimeout(onunloadcancel, 10); return ""; } window.onunloadcancel = function() { // alert("不离开"); return false; } */ }); function numToLetter(number) { 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']; var result = ''; if (number >= 1 && number <= 26) { result = latters[number - 1]; } return result; } function numToUpper(number) { number = number.toString(); number = number.substr(0, 2); var arr = ["零","一","二","三","四","五","六","七","八","九"]; if (number.length == 1) { result = arr[number]; } else { if (number == 10) { result ="十"; } else { if (number < 20) { result = "十"; } else { result = arr[number.substr(0, 1)] +"十"; } if (number.substr(1, 1) != "0") { result += arr[number.substr(1, 1)]; } } } return result; }