socialforge/public/javascripts/organization.js

157 lines
4.3 KiB
JavaScript

/**
* Created by ouyangxuhua on 2015/12/30.
*/
function submit_topic()
{
// if(regexTopicSubject() && regexTopicDescription())
// {
message_content_editor.sync();
$("#message-form").submit();
// }
}
function regexTopicSubject() {
var name = $("#message_subject").val();
if(name.length ==0)
{
$("#subjectmsg").text("标题不能为空");
$("#subjectmsg").css('color','#ff0000');
$("#message_subject").focus();
return false;
}
else if(name.length <= 255)
{
$("#subjectmsg").text("填写正确");
$("#subjectmsg").css('color','#008000');
return true;
}
else
{
$("#subjectmsg").text("标题超过255个字符");
$("#subjectmsg").css('color','#ff0000');
$("#message_subject").focus();
return false;
}
}
function reset_topic(){
}
(function(){
//提交匿评参数设置
function submit_set_evaluation_attr(end_time){
if(!regex_evaluation_start(end_time)){
$("#evaluation_start_time").focus();
}
else if(!regex_evaluation_end()){
$("#evaluation_end_time").focus();
}
else if(!regex_evaluation_num()){
$("#evaluation_num").focus();
}
else{
$('#muban_popup_box form').submit();
hideModal();
}
}
//验证匿评开启时间:大于截止时间,或者为空
function regex_evaluation_start(end_time){
var evaluation_start = $.trim($("#evaluation_start_time").val());
if(evaluation_start == ""){
$("#homework_evaluation_start_time").text("开启匿评日期不能为空");
return false;
}
var end_time = new Date(end_time);
var evaluation_start_time = new Date(evaluation_start);
if(evaluation_start_time > end_time){
$("#homework_evaluation_start_time").text("");
return true;
}else{
$("#homework_evaluation_start_time").text("开启匿评日期必须大于截止日期");
return false;
}
}
//验证匿评结束时间:大于匿评开启时间,或者为空。当匿评开启时间为空时,匿评结束时间必须为空
function regex_evaluation_end(){
var evaluation_start = $.trim($("#evaluation_start_time").val());
var evaluation_end = $.trim($("#evaluation_end_time").val());
if(evaluation_end == ""){
$("#homework_evaluation_end_time").text("关闭匿评日期不能为空");
return true;
}
var evaluation_start_time = new Date(evaluation_start);
var evaluation_end_time = new Date(evaluation_end);
if(evaluation_end_time >= evaluation_start_time){
$("#homework_evaluation_end_time").text("");
return true;
}else{
$("#homework_evaluation_end_time").text("关闭匿评日期不能小于开启匿评日期");
return false;
}
}
//验证匿评数量
function regex_evaluation_num(){
var evaluation_num = $.trim($("#evaluation_num").val());
var regex = /^\d+$/;
if(evaluation_num==""){
$("#evaluation_num_notice").text("匿评人数不能为空");
return false;
}
else if(regex.test(evaluation_num)){
if(evaluation_num > 0){
$("#evaluation_num_notice").html("");
return true;
}
else{
$("#evaluation_num_notice").text("匿评人数必须为大于0");
return false;
}
}
else{
$("#evaluation_num_notice").text("匿评人数只能为数字");
return false;
}
}
window.submit_set_evaluation_attr=submit_set_evaluation_attr;
})();
//处理迟交、缺评扣分
function check_late_penalty(id)
{
var obj = $("#" + id);
var regex = /^\d+$/;
if(regex.test(obj.val()))
{
if(obj.val() > 50)
{
obj.val("50");
}
}
else
{
obj.val("0");
}
}
//匿评弹框确定按钮
function clickOK(path)
{
clickCanel();
$.ajax({
type: "GET",
url: path,
data: 'text',
success: function (data) {
}
});
}
//匿评弹框取消按钮
function clickCanel(){hideModal("#popbox02");}