You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trustieforge/public/javascripts/course.js

210 lines
5.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

///////////////////////////////////////////////////////////////
function check_groupname(course_id) {
var $group_name = $('#group_name');
$.get(
'<%=valid_ajax_course_path%>',
{ valid: "name",
value: document.getElementById('group_name').value,
course_id: course_id },
function (data) {
if (!data.valid) {
alert(data.message);
}
});
}
function validate_groupname(value1) {
if(value1.length > 20) {
alert('<%= l(:label_limit_groupname) %>');
}
}
function checkclass(value) {
for(var i = 0; i < document.getElementsByName("check_group_name").length; i++) {
if(document.getElementsByName("check_group_name")[i].id == value) {
document.getElementById(value).className = "selected";
}
else {
document.getElementsByName("check_group_name")[i].className = "classbox";
}
}
}
function validate_groupname_null(value1) {
value1 = value1.trim();
if(value1.length == 0 ) {
alert('<%= l(:label_limit_groupname_null) %>');
}
}
function validate_update(name) {
value1 = document.getElementById(name).value;
validate_groupname(value1);
}
function validate_add_group() {
check_groupname();
}
///////////////////////////////////////////////////////////////
//验证搜索时输入名字
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").slideDown();
}
else
{
$("#bid_evaluation_num").slideUp();
}
});
});
//老师提交新建作业
function submit_new_bid(id)
{
if(regex_bid_name()&&regex_evaluation_num())
{
$("#"+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();
}
});
//将右侧的最小高度设置成左侧高度,美化界面
$(document).ready(function () {
$("#RSide").css("min-height",$("#LSide").height()-30);
});