408 lines
11 KiB
JavaScript
408 lines
11 KiB
JavaScript
//配置课程信息
|
||
function course_setting(id)
|
||
{
|
||
//alert(id);
|
||
$('#tb_'+id).removeClass().addClass("hwork_hovertab");
|
||
$('#tbc_0'+id).removeClass().addClass("dis");
|
||
$('#tb_'+(3-id)).removeClass().addClass("hwork_normaltab");
|
||
$('#tbc_0'+(3-id)).removeClass().addClass("undis");
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////////
|
||
//添加分班
|
||
function add_group(url,course_id) {
|
||
var group_name = $('#group_name').val();
|
||
$.get(
|
||
url,
|
||
{ valid: "name",
|
||
value: group_name,
|
||
course_id: course_id },
|
||
function (data) {
|
||
if (data.valid) {
|
||
$("#add_group_name").submit();
|
||
}
|
||
else
|
||
{
|
||
alert(data.message);
|
||
}
|
||
}
|
||
);
|
||
}
|
||
//修改分班:修改分班时得考虑什么都不改但是点击确定的情况
|
||
function edit_group(id,url,course_id,group_id)
|
||
{
|
||
var group_name = $('#'+id).val();
|
||
$.get(
|
||
url,
|
||
{
|
||
valid: "name",
|
||
value: group_name,
|
||
course_id: course_id,
|
||
group_id: group_id
|
||
},
|
||
function (data) {
|
||
if (data.valid) {
|
||
$("#update_group_"+group_id).submit();
|
||
}
|
||
else
|
||
{
|
||
alert(data.message);
|
||
}
|
||
}
|
||
);
|
||
}
|
||
///////////////////////////////////////////////////////////////
|
||
///////////////////////////////////////////////////////////////新建课程相关
|
||
//验证课程名称
|
||
function regex_course_name()
|
||
{
|
||
var name = $.trim($("#course_name").val());
|
||
if(name.length == 0)
|
||
{
|
||
$("#course_name_notice").show();
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
$("#course_name_notice").hide();
|
||
return true;
|
||
}
|
||
}
|
||
//验证课程学时
|
||
function regex_course_class_period()
|
||
{
|
||
var class_period = $.trim($("#class_period").val());
|
||
var regex = /^\d*$/;
|
||
if(class_period.length == 0)
|
||
{
|
||
$("#course_class_period_notice").html("学时总数不能为空");
|
||
$("#course_class_period_notice").show();
|
||
return false;
|
||
}
|
||
else if (regex.test(class_period)) {
|
||
$("#course_class_period_notice").html("");
|
||
$("#course_class_period_notice").hide();
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
$("#course_class_period_notice").html("学时总数必须为数字");
|
||
$("#course_class_period_notice").show();
|
||
return false;
|
||
}
|
||
}
|
||
//提交新建课程
|
||
function submit_new_course()
|
||
{
|
||
if(regex_course_name()&®ex_course_class_period())
|
||
{
|
||
$("#new_course").submit();
|
||
}
|
||
}
|
||
|
||
function submit_edit_course(id)
|
||
{
|
||
if(regex_course_name()&®ex_course_class_period())
|
||
{
|
||
$("#edit_course_"+id).submit();
|
||
}
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////////
|
||
//////////////////////////////////////////////////////////////课程讨论区
|
||
function regexSubject()
|
||
{
|
||
var content = $.trim($("#message_subject").val());
|
||
if(content.length ==0)
|
||
{
|
||
$("#subject_span").text("主题不能为空");
|
||
$("#subject_span").css('color','#ff0000');
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
$("#subject_span").text("填写正确");
|
||
$("#subject_span").css('color','#008000');
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
function regexContent()
|
||
{
|
||
var content = message_content_editor.html();
|
||
if(content.length ==0)
|
||
{
|
||
$("#message_content_span").text("描述不能为空");
|
||
$("#message_content_span").css('color','#ff0000');
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
$("#message_content_span").text("填写正确");
|
||
$("#message_content_span").css('color','#008000');
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
function submitCoursesBoard()
|
||
{
|
||
message_content_editor.sync();
|
||
if(regexSubject()&®exContent()){$("#message-form").submit();}
|
||
}
|
||
///////////////////////////////////////////////////////////////
|
||
/////////////////////////////////////////////////////////////// 课程通知
|
||
function regexTitle()
|
||
{
|
||
var name = $("#news_title").val();
|
||
if(name.length ==0)
|
||
{
|
||
$("#title_notice_span").text("标题不能为空");
|
||
$("#title_notice_span").css('color','#ff0000');
|
||
$("#title_notice_span").focus();
|
||
return false;
|
||
}
|
||
else if(name.length <= 60)
|
||
{
|
||
$("#title_notice_span").text("填写正确");
|
||
$("#title_notice_span").css('color','#008000');
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
$("#title_notice_span").text("标题超过60个字符");
|
||
$("#title_notice_span").css('color','#ff0000');
|
||
$("#title_notice_span").focus();
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function regexDescription()
|
||
{
|
||
var name = news_description_editor.html();
|
||
if(name.length ==0)
|
||
{
|
||
$("#description_notice_span").text("描述不能为空");
|
||
$("#description_notice_span").css('color','#ff0000');
|
||
$("#description_notice_span").focus();
|
||
return false;
|
||
}
|
||
else if(name.length >=6000){
|
||
$("#description_notice_span").text("描述最多3000个汉字(或6000个英文字符)");
|
||
$("#description_notice_span").css('color','#ff0000');
|
||
$("#description_notice_span").focus();
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
$("#description_notice_span").text("填写正确");
|
||
$("#description_notice_span").css('color','#008000');
|
||
return true;
|
||
}
|
||
}
|
||
|
||
function submitNews(is_new)
|
||
{
|
||
alert(is_new)
|
||
if(regexTitle() && regexDescription())
|
||
{
|
||
news_description_editor.sync();
|
||
$("#news-form").submit();
|
||
}
|
||
}
|
||
|
||
function submitFocus(obj)
|
||
{
|
||
$(obj).focus();
|
||
}
|
||
|
||
/////////////////////////////////////////////////课程讨论区
|
||
function course_board_submit_message_replay()
|
||
{
|
||
if(MessageReplayVevify())
|
||
{
|
||
message_content_editor.sync();//提交内容之前要sync,不然服务器端取不到值
|
||
$("#message_form").submit();
|
||
}
|
||
}
|
||
function MessageReplayVevify() {
|
||
var content = message_content_editor.html();//$.trim($("#message_content").val());
|
||
if (content.length == 0) {
|
||
$("#message_content_span").text("<%= l(:label_reply_empty) %>");
|
||
$("#message_content_span").css('color', '#ff0000');
|
||
return false;
|
||
}
|
||
else {
|
||
$("#message_content_span").text("<%= l(:label_field_correct) %>");
|
||
$("#message_content_span").css('color', '#008000');
|
||
return true;
|
||
}
|
||
}
|
||
//////////////////////////////////////////////////
|
||
|
||
///////////////////////////////////////////////////////////////
|
||
///////////////////////////////////////////////////////////////
|
||
//验证搜索时输入名字
|
||
function regexName(content)
|
||
{
|
||
var name = $.trim($("#name").val());
|
||
if(name.length == 0)
|
||
{
|
||
$("#project_name_span").text(content);
|
||
$("#project_name_span").css('color','#ff0000');
|
||
$("#project_name_span").focus();
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
$("#project_name_span").text("");
|
||
return true;
|
||
}
|
||
}
|
||
//提交搜索
|
||
function submitSerch(content)
|
||
{
|
||
if(regexName(content)){$("#course_search_form").submit();}
|
||
}
|
||
//课程描述显示更多信息
|
||
function show_more_msg()
|
||
{
|
||
$("#course_description").toggleClass("course_description_none");
|
||
}
|
||
//作业描述显示更多信息
|
||
function news_show_more_des(id)
|
||
{
|
||
$('#news_description_' + id).toggleClass("news_description_none");
|
||
}
|
||
function bid_show_more_des(id)
|
||
{
|
||
$("#bid_description_" + id).toggleClass("news_description_none");
|
||
}
|
||
|
||
//课程作业结束时间倒计时
|
||
function show_bid_dead_line(year,month,day,divname)
|
||
{
|
||
var now = new Date();
|
||
var endDate = new Date(year, month-1, day);
|
||
var leftTime=endDate.getTime()-now.getTime();
|
||
var leftsecond = parseInt(leftTime/1000);
|
||
var day1=Math.floor(leftsecond/(60*60*24));
|
||
var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
|
||
var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
|
||
var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
|
||
$("#"+divname).html("<form name='formnow' class='fr'>"
|
||
+ "<input class='c_orange' type='text' style='border:0;' size='1' value='"+day1+"' > 天"
|
||
+ "<input class='c_orange' type='text' style='border:0;' size='1' value='"+hour+"' > 小时"
|
||
+ "<input class='c_orange' type='text' style='border:0;' size='1' value='"+minute+"' > 分"
|
||
+ "<input class='c_orange' type='text' style='border:0;' size='1' value='"+second+"' > 秒"
|
||
+ "</form>"
|
||
+ "<p class='fr'>作业提交还剩:</p>");
|
||
}
|
||
//验证新建作业的名字
|
||
function regex_bid_name()
|
||
{
|
||
var name = $.trim($("#bid_name").val());
|
||
|
||
if(name=="")
|
||
{
|
||
$("#bid_name_span").text("名称不能为空");
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
$("#bid_name_span").text("");
|
||
return true;
|
||
}
|
||
}
|
||
|
||
//验证匿评数量
|
||
function regex_evaluation_num()
|
||
{
|
||
var evaluation_num = $.trim($("#bid_evaluation_num").val());
|
||
var regex = /^\d+$/;
|
||
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked")
|
||
{
|
||
if(evaluation_num=="")
|
||
{
|
||
$("#bid_evaluation_num_span").text("匿评分配数量不能为空");
|
||
return false;
|
||
}
|
||
else if(regex.test(evaluation_num))
|
||
{
|
||
if(evaluation_num > 0)
|
||
{
|
||
$("#bid_evaluation_num_span").text("");
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
$("#bid_evaluation_num_span").text("匿评分配数量必须为大于0");
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
$("#bid_evaluation_num_span").text("匿评分配数量只能为数字");
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
|
||
//点击是否开启匿评单选框效果
|
||
$(function(){
|
||
$("#bid_open_anonymous_evaluation").click(function(){
|
||
if($("#bid_open_anonymous_evaluation").attr("checked") == "checked")
|
||
{
|
||
$("#bid_evaluation_num_li").slideDown();
|
||
}
|
||
else
|
||
{
|
||
$("#bid_evaluation_num_li").slideUp();
|
||
}
|
||
});
|
||
});
|
||
|
||
//老师提交新建作业
|
||
function submit_new_bid(id)
|
||
{
|
||
if(regex_bid_name()&®ex_evaluation_num())
|
||
{
|
||
bid_description_editor.sync();
|
||
$("#"+id).submit();
|
||
}
|
||
}
|
||
|
||
function show_window (id1,id2,top,left) {
|
||
$('#'+ id1).css('top',top);
|
||
$('#'+ id1).css('left',left);
|
||
$('#'+ id1).css('display','block');
|
||
$('#' + id2).css('display','block');
|
||
}
|
||
|
||
function close_window(id1,id2){
|
||
$('#' + id1).css('display','none');
|
||
$('#' + id2).css('display','none');
|
||
}
|
||
|
||
//隐藏提示狂
|
||
function hidden_atert_form(cur_page,cur_type)
|
||
{
|
||
hideModal($("#popbox"));
|
||
}
|
||
|
||
//当课程描述长度小于112px时,不显示更多按钮
|
||
$(function(){
|
||
if($("#course_description_content").height()>112)
|
||
{
|
||
$("#lg-foot").show();
|
||
}
|
||
});
|
||
|
||
// 日历选择日期后关闭
|
||
function regexDeadLine()
|
||
{
|
||
('#ui-datepicker-div').hide;
|
||
} |