/**
* Created by TT on 2017/5/25.
*/
$(function() {
// loginStatus();//判断个人是否登录
//1获取数据
var nameD;
var orgD;
var authSD
var userid = GetQueryString("professorId");
$(".replace-photo").attr("href","photo-set.html?id="+userid);
if(userid) {
//填充学术领域
var subjectShow = function(data) {
if(data != undefined && data.length != 0) {
var subs = new Array();
if(data.indexOf(',')) {
subs = data.split(',');
} else {
subs[0] = data;
}
if(subs.length > 0) {
for(var i = 0; i < subs.length; i++) {
$("#subjectList").append("
" + subs[i] + "
");
$("#subjectShow").append("" + subs[i] + "
");
};
}
}
}
//填充应用行业
var industryShow = function(data) {
if(data != undefined && data.length != 0) {
var subs = new Array();
if(data.indexOf(',')) {
subs = data.split(',');
} else {
subs[0] = data;
}
if(subs.length > 0) {
for(var i = 0; i < subs.length; i++) {
$("#industryList").append("" + subs[i] + "
");
$("#industryShow").append("" + subs[i] + "");
};
}
}
}
//填充教育背景
var eduBgShow = function(data) {
eduFil("#eduUl");
if(data.length > 0) {
for(var i = 0; i < data.length; i++) {
if(!data[i].year) {
data[i].year = "";
}
if(!data[i].college) {
data[i].college = "";
}
if(!data[i].major) {
data[i].major = "";
}
if(!data[i].degree) {
data[i].degree = "";
}
var string = ''
string += ' '
if(data[i].college && data[i].major && data[i].degree) {
string += data[i].school + '-' + data[i].college + '-' + data[i].major + '-' + data[i].degree
} else if(!data[i].college && data[i].major && data[i].degree) {
string += data[i].school + '-' + data[i].major + '-' + data[i].degree
} else if(data[i].college && !data[i].major && data[i].degree) {
string += data[i].school + '-' + data[i].college + '-' + data[i].degree
} else if(data[i].college && data[i].major && !data[i].degree) {
string += data[i].school + '-' + data[i].college + '-' + data[i].major
} else if(!data[i].college && !data[i].major && data[i].degree) {
string += data[i].school + '-' + data[i].degree
} else if(!data[i].college && data[i].major && !data[i].degree) {
string += data[i].school + '-' + data[i].major
} else if(data[i].college && !data[i].major && !data[i].degree) {
string += data[i].school + '-' + data[i].college
}
//+data[i].school+'-'+data[i].college+'-'+data[i].major+'-'+data[i].degree+
string += '' + data[i].year + '
'
string += ''
string += '
'
string += '
'
string += ''
$("#eduUl").append(string);
}
}
}
//填充社会兼职
var timeJobShow = function(data) {
jobFil("#timeJobShow");
if(data.length > 0) {
for(var i = 0; i < data.length; i++) {
var sDate = "";
var eDate = "";
if(data[i].department) {
var dep = "-" + data[i].department;
var depart = data[i].department;
} else {
var dep = "";
var depart = ""
}
if(data[i].startMonth) {
sDate = data[i].startMonth.substr(0, 4) + "-" + data[i].startMonth.substr(4, 6);
if(data[i].stopMonth) {
eDate = data[i].stopMonth.substr(0, 4) + "-" + data[i].stopMonth.substr(4, 6);
} else {
eDate = "至今"
}
}
var string = ''
string += ' ' + data[i].company + '-' + data[i].title + '' + dep + '';
string += sDate;
if(eDate) string += ("-" + eDate);
string += '
';
string += ''
string += '
'
string += '
'
string += ''
$("#timeJobShow").append(string);
}
}
}
//填充项目经历
var projectShow = function(data) {
projectFil("#projectShow")
if(data.length > 0) {
for(var i = 0; i < data.length; i++) {
if(!data[i].descp) {
data[i].descp = "";
}
if(!data[i].startMonth) {
data[i].startMonth = '';
data[i].stopMonth = '';
} else {
data[i].startMonth = data[i].startMonth.substr(0, 4) + "-" + data[i].startMonth.substr(4, 6) + "-"
if(!data[i].stopMonth) {
data[i].stopMonth = '至今';
} else {
data[i].stopMonth = data[i].stopMonth.substr(0, 4) + "-" + data[i].stopMonth.substr(4, 6)
}
}
var string = ''
string += '' + data[i].name + '' + data[i].startMonth + '' + data[i].stopMonth + '
';
string += '
' + data[i].descp + '
';
//string+=' '+data[i].name+'-'+data[i].descp+'-'+data[i].startMonth+'-'+data[i].stopMonth+'
'
string += ''
string += '
'
string += '
'
string += ''
$("#projectShow").append(string);
}
}
}
//填充著作论文文章
var paperShow = function(data) {
papFil("#paperShow");
if(data.length > 0) {
for(var i = 0; i < data.length; i++) {
if(!data[i].year) {
data[i].year = "";
}
if(!data[i].descp) {
data[i].descp = "";
}
if(!data[i].url) {
data[i].url = "";
}
var string = ''
string += '' + data[i].name + '' + data[i].year + '
';
string += '
' + data[i].descp + '
';
//string+=' '+data[i].year+'-'+data[i].name+'-'+data[i].descp+'
'
string += ''
$("#paperShow").append(string);
}
}
}
//填充专利
var patentShow = function(data) {
patFil("#patentShow");
if(data.length > 0) {
for(var i = 0; i < data.length; i++) {
if(!data[i].year) {
data[i].year = "";
}
if(!data[i].descp) {
data[i].descp = "";
}
if(!data[i].url) {
data[i].url = "";
}
var string = ''
//string+=' '+data[i].year+'-'+data[i].name+'-'+data[i].descp+'
'
string += '' + data[i].name + '' + data[i].year + '
';
string += '
' + data[i].descp + '
';
string += ''
string += '
'
string += '
'
string += ''
$("#patentShow").append(string);
}
}
}
//填充荣誉
var honorShow = function(data) {
hounerFil("#honorShow");
if(data.length > 0) {
for(var i = 0; i < data.length; i++) {
if(!data[i].year) {
data[i].year = "";
}
if(!data[i].descp) {
data[i].descp = "";
}
var string = ''
//string+=' '+data[i].year+'-'+data[i].name+'-'+data[i].descp+'
'
string += '' + data[i].name + '' + data[i].year + '
';
string += '
' + data[i].descp + '
';
string += ''
string += '
'
string += '
'
string += ''
$("#honorShow").append(string);
}
}
}
//填充研究方向
var researchAreaShow = function($datas, $datarecords) {
if($datas != undefined && $datas.length != 0) {
$("#researchAreaList").empty();
for(var i = 0; i < $datas.length; ++i) {
var $data = $datas[i];
var $photos = [];
//获取头像
if($datarecords.length > 0) {
$photos = getRecords($datarecords, $data.caption);
}
var showDiv = "" + $data.count + "" + $data.caption + "
";
if($photos.length > 10) {
showDiv += "
";
}
if($photos.length > 0) {
for(var j = 0; j < $photos.length; ++j) {
showDiv += "
";
}
}
showDiv += "
";
$("#researchAreaShow").append(showDiv);
$("#researchAreaList").append("" + $data.count + "" + $data.caption + " ");
$(".like-h").load(function() {})
.error(function() {
$(this).attr("src", "/images/default-photo.jpg");
});
}
}
}
//填充研究方向
var getRecords = function($researchAreaLogs, caption) {
var ret = [];
for(var i = 0; i < $researchAreaLogs.length; i++) {
if(caption == $researchAreaLogs[i].caption) {
ret.push($researchAreaLogs[i].opreteProfessorId);
}
}
return ret;
}
//获取数据,填充页面
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
console.log($data);
var $info = $data.data;
$info.authType = 1;
if($info) {
//展示专家的信息
$("#nameS").text($info.name);
nameD = $info.name;
authSD = $info.authStatus;
//console.log($info.authStatus)
orgD = $info.orgName;
if($info.authType == 1) {
$(".yesshow,.xslyshow,.yyhyshow").show();
} else {
if($info.authentication == 1) {
$(".xslyshow").show();
}
if($info.authentication == 2) {
$("#orgUpdata").text("所在企业");
$(".yyhyshow").show();
}
if($info.authentication == 3) {
$("#orgUpdata").text("所在高校");
$("#departmentUpdata").text("所属院系");
$("#titleNone").hide();
$("#office").hide();
$("#titleS").hide();
}
}
//alert($info.authentication)
//alert($info.authType)
if($info.authStatus==3) {
$("#authSta").text("已认证");
} else {
$("#authSta").text("未认证");
}
if($info.office) {
if($info.title) {
$("#office").text($info.office + ",");
} else {
$("#office").text($info.office);
}
}
if($info.title) {
$("#titleS").text($info.title);
}
if($info.department) {
if($info.orgName) {
$("#industryS").text($info.department + ",");
} else {
$("#industryS").text($info.department);
}
}
if($info.orgName) {
$("#orgNameS").text($info.orgName);
}
if($info.address) {
$("#address").text($info.address);
}
if($info.email) {
$("#mail").text("联系邮箱(非公开):" + $info.email);
$("#moileMail").val($info.email);
}
if($info.phone) {
$("#phone").text("联系电话(非公开):" + $info.phone);
$("#mobilePhone").val($info.phone);
}
$("#headImage").attr("src", "/images/head/" + userid + "_l.jpg");
$("#headImage").load(function() {})
.error(function() {
$("#headImage").attr("src", "/images/default-photo.jpg");
});
$("#orgImage").attr("src", "/images/org/" + $info.orgId + ".jpg");
$("#orgImage").load(function() {})
.error(function() {
$("#orgImage").attr("src", "/images/default-icon.jpg");
});
$("#descpS").text($info.descp);
//显示专家信息到保存数据
$("#name").val($info.name);
$("#title").val($info.title);
$("#orgId").val($info.orgId);
$("#orgName").val($info.orgName);
$("#department").val($info.department);
$("#officeRevise").val($info.office);
//省
//$("#Province input[name=cho_Province]").val($info.province);
//console.log($info.province);
if(!$info.province) {
$info.province = ""
}
if(!$info.address) {
$info.address = ""
}
$("#Province .mr_show").text($info.province);
//市
//$("#City input[name=cho_City]").val($info.address);
//console.log($info.address)
$("#City .mr_show").text($info.address);
//$("#addressRevise").val($info.address);
if($info.descp) {
$("#descp").val($info.descp);
} else {
$("#descpS").css("min-height", "0px");
}
//console.log($info.authentication);
if($info.subject) {
subjectShow($info.subject);
}
//研究方向
if($info.researchAreas.length) {
researchAreaShow($info.researchAreas, $info.editResearchAreaLogs);
}
//展示专家的行业
if($info.industry) {
industryShow($info.industry);
}
//教育背景
if($info.edus) {
eduBgShow($info.edus);
}
//社会兼职
if($info.jobs) {
timeJobShow($info.jobs);
}
//项目经历
if($info.projects) {
projectShow($info.projects)
}
//著作 论文 文章
if($info.papers) {
paperShow($info.papers);
}
//专利
if($info.patents) {
patentShow($info.patents);
}
//荣誉及奖项
if($info.honors) {
honorShow($info.honors);
}
yearAdd();
month();
$(".stopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
$(".StopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
//下滑滚动不覆盖底部
var d;
var t;
/*向下滚动时,header背景变半透明*/
var top5 = $(".content-left").height();
var top4 = $("#container").height();
var top3 = $(window).height();
$(document).scroll(function() {
var top1 = $(document).scrollTop();
var top2 = $("#container").height() - top3 + (top3 - 80 - top5) - 10; //变成绝对定位
if(top1 >= 300) {
$(".content-left").css({
"position": "fixed",
"top": "80px"
});
if(top1 >= top2) {
$('.information-content').css("position", "static");
$(".content-left").css("position", "absolute");
$(".content-left").css("top", top4 - top5 - 10 + "px");
} else {
$('.information-content').css("position", "relative");
$(".content-left").css({
"position": "fixed",
"top": "80px"
});
}
} else {
$(".content-left").css({
"position": "static"
});
}
})
//下滑滚动不覆盖底部 结束
}
}
});
} else {
location.href = "login.html";
return;
}
//搜索框
$("#hsearch").on("click", function() {
var searchContent = $("#hsearchContent").val();
location.href = "search.html?searchContent=" + searchContent;
});
function trim(str) { //删除左右两端的空格
return str.replace(/(^\s*)|(\s*$)/g, "");
}
//头像旁保存
$("#saveProfessor").on("click", function() {
var length1 = trim($("#name").val());
//console.log(length1)
var length2 = trim($("#orgName").val());
var loginName=$("#mobilePhone").val();
if(trim(loginName)){
var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
if(!hunPhone.test(loginName.trim())) {
$.MsgBox.Alert("消息提醒", "联系电话格式不对,请输入正确的格式");
return;
}
}
var mail=$("#moileMail").val();
if(trim(mail)){
var gunf = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
if(!gunf.test(mail.trim())) {
$.MsgBox.Alert("消息提醒", "请输入正确的邮箱格式");
return;
}
}
if(!length1 && length2) {
$.MsgBox.Alert("消息提醒", "姓名不能为空");
return;
} else if(length1 && !length2) {
$.MsgBox.Alert("消息提醒", "所在机构不能为空");
return;
} else if(!length1 && !length2) {
$.MsgBox.Alert("消息提醒", "姓名和所在机构不能为空");
return;
}
if(nameD != length1 && orgD != length2) {
if(authSD) {
$.MsgBox.Confirm("消息", "修改姓名&&和所在机构会导致身份验证失效?", personUpdata);
return;
} else {
personUpdata();
}
} else if(nameD == length1 && orgD != length2) {
if(authSD) {
$.MsgBox.Confirm("消息", "修改所在机构会导致身份验证失效?", personUpdata);
return;
} else {
personUpdata();
}
} else if(nameD != length1 && orgD == length2) {
if(authSD) {
$.MsgBox.Confirm("消息", "修改姓名会导致身份验证失效?", personUpdata);
return;
} else {
personUpdata();
}
} else {
personUpdata();
}
});
//更新认证状态函数
var upStatus = function() {
$.ajax({
url: "/ajax/professor/authStatus",
dataType: 'json', //数据格式类型
type: 'post', //http请求类型
data: {
authStatus: 0,
id: userid
},
timeout: 10000, //超时设置
success: function(data) {
if(data.success) {} else {
}
}
})
}
function personUpdata() {
if(nameD == $("#name").val() && orgD == $("#orgName").val()) {
} else {
if(authSD) {
upStatus();
}
}
var $data = {};
$data.name = $("#name").val();
$data.orgId = $("#orgId").val();
$data.orgName = $("#orgName").val();
$data.title = $("#title").val();
$data.department = $("#department").val();
$data.phone=$("#mobilePhone").val();
$data.email=$("#moileMail").val();
if($("#Province input[name=cho_Province]").val() != "请选择省份") {
$data.province = $("#Province input[name=cho_Province]").val(); //省
}
if($("#City input[name=cho_City]").val() != "请选择城市") {
$data.address = $("#City input[name=cho_City]").val(); //市
}
$data.office = $("#officeRevise").val();
if(userid) {
$data.id = userid;
}
console.log(userid);
$.ajax({
"url": "../ajax/professor",
"type": userid ? "PUT" : "POST",
"success": function(rdata) {
if(rdata.success) {
if(userid) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
var $info = $data.data;
if($info) {
//展示专家的信息
$(".modifybox").css("display", "none");
$(".infor-browse").css("display", "block");
if($info.authType) {
$("#authSta").text("已认证");
} else {
$("#authSta").text("未认证");
}
nameD = $info.name;
authSD = $info.authStatus;
orgD = $info.orgName;
$("#nameS").text("");
$("#office").text("");
$("#titleS").text("");
$("#industryS").text("");
$("#orgNameS").text("");
$("#address").text("");
$("#nameS").text($info.name);
if($info.phone){
$("#phone").text("联系电话(非公开):" +$info.phone);
$("#mobilePhone").val($info.phone);
}else{
$("#phone").text("");
$("#mobilePhone").val("");
}
if($info.email){
$("#mail").text("联系邮箱(非公开):" +$info.email);
$("#moileMail").val($info.email);
}else{
$("#mail").text("");
$("#moileMail").val("");
}
if($info.office) {
if($info.title) {
$("#office").text($info.office + ",");
} else {
$("#office").text($info.office);
}
}
if($info.title) {
$("#titleS").text($info.title);
}
if($info.department) {
if($info.orgName) {
$("#industryS").text($info.department + ",");
} else {
$("#industryS").text($info.department);
}
}
if($info.orgName) {
$("#orgNameS").text($info.orgName);
}
if($info.address) {
$("#address").text($info.address);
}
//显示专家信息到保存数据
$("#name").val($info.name);
$("#title").val($info.title);
$("#orgId").val($info.orgId);
$("#orgName").val($info.orgName);
$("#department").val($info.department);
$("#officeRevise").val($info.office);
//$("#addressRevise").val($info.address);
//省
//console.log($info.province);
$("#Province .mr_show").text("");
$("#Province input[name=cho_Province]").val($info.province);
$("#Province .mr_show").text($info.province);
//市
//console.log($info.address);
$("#City .mr_show").text("");
$("#City input[name=cho_City]").val($info.address);
$("#City .mr_show").text($info.address);
}
}
})
} else {
location.href = "information.html?id=" + rdata.data;
}
} else {
alert(rdata.msg);
}
},
"data": userid ? JSON.stringify($data) : $data,
"contentType": userid ? "application/json" : "application/x-www-form-urlencoded",
dataType: "json"
});
}
//上传图像的hover
$(".head-left").hover(function() {
$(".replace-photo").animate({
"bottom": "0px"
});
}, function() {
$(".replace-photo").animate({
"bottom": "-50px"
});
})
//拿到点击的顺序,然后求出局文档的距离
$(".subsidebar").mouseenter(function() {
var dd = $(this)[0].className;
if(dd != "subsidebar subcolor") {
$(this).css("background", "#efefef");
}
}).mouseleave(function() {
$(this).css("background", "")
});
//专家信息点击换背景颜色
$(".subsidebar").click(function() {
$(".subsidebar").removeClass("subcolor");
$(".subsidebar").eq($(".subsidebar").index(this)).addClass("subcolor");
});
$(".subsidebar").click(function() {
var index = $(".subsidebar").index(this) + 1;
//console.log(index)
var offset = $(".introduction").eq(index).offset();
$("body,html").animate({
scrollTop: offset.top - 80 + "px" //��body��scrollTop����pos��top����ʵ���˹���
}, 1000);
}).mousedown(function() {
$(this).css("background", "");
});
//获取点击那个编辑,及
$("#container .edit").click(function() {
var edit = $(".edit").index(this);
$(".right-title span").eq(edit - 1).css("color", "#3e3e3e");
$(".infor-browse").eq(edit).hide();
$(".modifybox").eq(edit).show();
//点击取消的操作
$(".close").click(function() {
$(".modifybox").eq(edit).hide();
$(".infor-browse").eq(edit).show();
});
}); //个人简介保存
$("#saveDescp").on("click", function() {
$.ajax({
"url": "../ajax/professor/descp",
"type": "POST",
"data": {
"id": userid,
"descp": $("#descp").val()
},
"contentType": "application/x-www-form-urlencoded",
"success": function($data) {
//debugger;;
if($data.success) {
$(".infor-browse").css("display", "block");
$(".indu").css("display", "none");
$("#descpS").text($("#descp").val());
} else {
$.MsgBox.Alert("message", $data.msg);
}
}
})
})
//学术领域添加
$("#subjectAdd").click(function() {
var val = $("#subject").val();
if(!val) {
$.MsgBox.Alert("消息提醒", "内容不能为空");
return;
}
var inV = $("#subjectList .acad");
for(var i = 0; i < inV.length; i++) {
if(inV[i].innerText == val) {
$.MsgBox.Alert("消息提醒", "不能添加重复内容");
return;
}
}
$("#subjectList").append("" + val + "
")
$("#subject").val("")
})
//学术领域删除
$("#subjectList").on("click", ".remove", function() {
$(this).parent().remove();
})
//学术领域保存
$("#subjectSave").on("click", function() {
var subjects = $("#subjectList .acad");
var subjectAll = "";
if(subjects.size() > 0) {
for(var i = 0; i < subjects.size(); i++) {
subjectAll += subjects[i].innerText;
subjectAll += ',';
};
subjectAll = subjectAll.substring(0, subjectAll.length - 1);
}
$.ajax({
"url": "/ajax/professor/subject",
"type": "POST",
"data": {
"id": userid,
"subject": subjectAll
},
"contentType": "application/x-www-form-urlencoded",
"success": function($data) {
if($data.success) {
$("#subject").val("");
$("#subjectShow").empty();
$("#subjectList").empty();
$(".indu").css("display", "none");
$(".infor-browse").css("display", "block");
subjectShow(subjectAll);
} else {
$.MsgBox.Alert("message", $data.msg);
}
}
});
})
//应用行业添加
$("#industryAdd").click(function() {
var val = $("#industry").val();
if(!val) {
$.MsgBox.Alert("消息提醒", "内容不能为空");
return;
}
var inV = $("#industryList .acad");
for(var i = 0; i < inV.length; i++) {
if(inV[i].innerText == val) {
$.MsgBox.Alert("消息提醒", "不能添加重复内容");
return;
}
}
$("#industryList").append("" + val + "
")
$("#industry").val("")
})
//应用行业删除
$("#industryList").on("click", ".remove", function() {
$(this).parent().remove();
})
//应用行业保存
$("#industrySave").on("click", function() {
var industrys = $("#industryList .acad");
var industryAll = "";
if(industrys.size() > 0) {
for(var i = 0; i < industrys.size(); i++) {
industryAll += industrys[i].innerText;
industryAll += ',';
};
industryAll = industryAll.substring(0, industryAll.length - 1);
}
$.ajax({
"url": "/ajax/professor/industry",
"type": "POST",
"data": {
"id": userid,
"industry": industryAll
},
"contentType": "application/x-www-form-urlencoded",
"success": function($data) {
if($data.success) {
$("#industry").val("");
$("#industryShow").empty();
$("#industryList").empty();
$(".indu").css("display", "none");
$(".infor-browse").css("display", "block");
industryShow(industryAll);
} else {
$.MsgBox.Alert("message", $data.msg);
}
}
});
})
//研究方向添加
$("#researchAreaAdd").click(function() {
var researchArea = $("#researchArea").val();
if(!researchArea) {
$.MsgBox.Alert("消息提醒", "内容不能为空");
return;
}
var inV = $("#researchAreaList .ra");
for(var i = 0; i < inV.length; i++) {
if(inV[i].innerText == researchArea) {
$.MsgBox.Alert("消息提醒", "不能添加重复内容");
return;
}
}
$("#researchAreaList").append("0" + researchArea + " ")
$("#researchArea").val("");
});
//研究方向删除
$("#researchAreaList").on("click", ".remove", function() {
$(this).parent().remove();
})
//研究方向保存
$("#researchAreaSave").on("click", function() {
//debugger;
var $data = [];
var researchAreas = $("#researchAreaList .list .ra");
if(researchAreas.length > 0) {
for(var i = 0; i < researchAreas.length; i++) {
var $rd = {};
$rd.professorId = userid;
$rd.caption = researchAreas[i].innerText;
$data[i] = $rd;
}
}
var $has = $data.length > 0;
$.ajax({
"url": $has ? "../ajax/researchArea" : "../ajax/researchArea/" + userid,
"type": $has ? "PUT" : "DELETE",
"data": $has ? JSON.stringify($data) : null,
"contentType": $has ? "application/json" : "application/x-www-form-urlencoded",
"success": function($data) {
if($data.success) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
$("#researchAreaShow").empty("");
$("#researchAreaShow").show();
$(".indu").hide();
researchAreaShow($data.data.researchAreas, $data.data.editResearchAreaLogs);
}
});
} else {
$.MsgBox.Alert("message", $data.msg);
}
}
});
})
/*Ӧ����ҵ�������*/
$("#other").click(function() {
$(".addbox").toggle();
});
//教育背景最下面的例子
$("#eduBgList").on("mouseover mouseout", ".eg", function(even) {
if(event.type == "mouseover") {
$(this).find("span").show();
} else if(event.type == "mouseout") {
$(this).find("span").hide();
}
})
function trim(str) { //删除左右两端的空格
return str.replace(/(^\s*)|(\s*$)/g, "");
}
$("#eduUl").on("blur", ".school", function() {
var valueE = $(this).val();
var length = trim(valueE);
if(!length) {
$.MsgBox.Alert("消息", "学校不能为空");
}
})
//教育背景填充函数
var eduFil = function(select) {
var string = ''
string += ''
string += '
'
string += '
'
string += ''
$("" + select + "").prepend(string);
}
//教育背景添加
$("#addEdu").on("click", function() {
$("#eduUl").find(".listnone1").toggle(100);
});
$("#eduUl").on("click", ".close1", function() {
$("#eduUl").find(".listnone1").toggle(100);
});
$("#eduUl").on("click", "em", function() {
$(this).parent().hide();
$(this).parent().siblings().show();
//$(this).parent().parent().children(".")
});
$("#eduUl").on("click", ".mr_btn", function() {
$(this).siblings(".xl_list").children("ul").show();
});
$("#eduUl").on("click", ".ul_edubg li", function() {
$(this).parents(".xl_list").siblings(".mr_btn").val($(this).text());
$(this).parent().hide();
});
$("#eduUl").on("click", ".close", function() {
$(this).parents(".modifybox").hide();
$(this).parents(".modifybox").siblings().show();
});
$("#eduUl").on("click", ".deletebtn", function() {
var deuId = $(this).parents(".txtExpForm").find(".eduId").val();
delEdu(deuId);
});
//教育背景,对已经添加的背景删除
var delEdu = function(data) {
$.ajax({
"url": "/ajax/edu/" + data,
"type": "DELETE",
"success": function($data) {
if($data.success) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
$("#eduUl").empty("");
eduBgShow($data.data.edus);
}
});
} else {
alert($data.msg);
}
}
});
}
//教育背景保存
$("#eduUl").on("click", ".infor-save", function() {
var length = trim($(this).parents(".txtExpForm").find(".school").val());
if(!length) {
$.MsgBox.Alert("消息", "学校不能为空");
return;
}
var $data = {};
var $id = $(this).parents(".txtExpForm").find(".eduId").val();
if($id) {
$data.id = $id;
}
$data.professorId = userid;
$data.year = $(this).parents(".txtExpForm").find(".year").val();
$data.school = $(this).parents(".txtExpForm").find(".school").val();
$data.college = $(this).parents(".txtExpForm").find(".college").val();
$data.major = $(this).parents(".txtExpForm").find(".major").val();
$data.degree = $(this).parents(".txtExpForm").find(".mr_btn").val();
$.ajax({
"url": "/ajax/edu",
"type": $id ? "PUT" : "POST",
"data": $id ? JSON.stringify($data) : $data,
"contentType": $id ? "application/json" : "application/x-www-form-urlencoded",
"success": function($data) {
if($data.success) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
$("#eduUl").empty("");
eduBgShow($data.data.edus);
yearAdd();
$(".stopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
$(".StopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
}
});
} else {
$.MsgBox.Alert("message", $data.msg);
}
}
});
})
//社会兼职
$("#timeJobShow").on("blur", ".jobCompany", function() {
var valueE = $(this).val();
var length = trim(valueE);
if(!length) {
$.MsgBox.Alert("消息", "机构名称不能为空");
}
})
$("#timeJobShow").on("blur", ".jobTitle", function() {
var valueE = $(this).val();
var length = trim(valueE);
if(!length) {
$.MsgBox.Alert("消息", "职位不能为空");
}
})
var jobFil = function(select) {
var string = ''
string += ''
string += '
'
string += '
'
string += ''
$("" + select + "").prepend(string);
}
//专利添加
$("#timeJobAdd").on("click", function() {
$("#timeJobShow").find(".listnone1").toggle(100);
});
$("#timeJobShow").on("click", ".close1", function() {
$("#timeJobShow").find(".listnone1").toggle(100);
});
$("#timeJobShow").on("click", "em", function() {
$(this).parent().hide();
$(this).parent().siblings().show();
//$(this).parent().parent().children(".")
});
$("#timeJobShow").on("click", ".close", function() {
$(this).parents(".modifybox").hide();
$(this).parents(".modifybox").siblings().show();
});
$("#timeJobShow").on("click", ".deletebtn", function() {
var deuId = $(this).parents(".txtExpForm").find(".jobId").val();
delTimeJob(deuId);
});
//社会兼职,对添加的兼职删除
var delTimeJob = function(data) {
$.ajax({
"url": "/ajax/job/" + data,
"type": "DELETE",
"success": function($data) {
if($data.success) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
$("#timeJobShow").empty("");
timeJobShow($data.data.jobs);
}
});
} else {
alert($data.msg);
}
}
});
}
//社会兼职保存
$("#timeJobShow").on("click", ".infor-save", function() {
var length1 = trim($(this).parents(".txtExpForm").find(".jobCompany").val());
var length2 = trim($(this).parents(".txtExpForm").find(".jobTitle").val());
var length3 = trim($(this).parents(".txtExpForm").find(".startMonth").val());
var length4 = trim($(this).parents(".txtExpForm").find(".stopMonth").val());
if(!length3 && length4) {
$.MsgBox.Alert("消息", "没有选开始时间");
return;
} else if(length3 && !length4) {
$.MsgBox.Alert("消息", "没有选结束时间");
return;
}
if(!length1 && length2) {
$.MsgBox.Alert("消息", "机构名称不能为空");
return;
} else if(length1 && !length2) {
$.MsgBox.Alert("消息", "职位不能为空");
return;
} else if(!length1 && !length2) {
$.MsgBox.Alert("消息", "职位&&机构名称不能为空");
return;
}
var $data = {};
var $id = $(this).parents(".txtExpForm").find(".jobId").val();
if($id) {
$data.id = $id;
}
$data.professorId = userid;
$data.company = $(this).parents(".txtExpForm").find(".jobCompany").val();
$data.department = $(this).parents(".txtExpForm").find(".jobdepartment").val();
var s = $(this).parents(".txtExpForm").find(".startMonth").val();
var st = $(this).parents(".txtExpForm").find(".stopMonth").val();
if(s) {
$data.startMonth = s.substr(0, 4) + s.substr(5, 6);
}
if(st) {
if(st == "至今") {} else {
$data.stopMonth = st.substr(0, 4) + st.substr(5, 6);
}
}
$data.title = $(this).parents(".txtExpForm").find(".jobTitle").val();
$.ajax({
"url": "/ajax/job",
"type": $id ? "PUT" : "POST",
"data": $id ? JSON.stringify($data) : $data,
"contentType": $id ? "application/json" : "application/x-www-form-urlencoded",
beforeSend: function() {
//console.log(this.data)
},
"success": function($data) {
if($data.success) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
$("#timeJobShow").empty("");
timeJobShow($data.data.jobs);
yearAdd();
month();
$(".stopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
$(".StopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
}
});
} else {
$.MsgBox.Alert("message", $data.msg);
}
}
});
})
//项目经历
$("#projectShow").on("blur", ".projectName", function() {
var valueE = $(this).val();
var length = trim(valueE);
if(!length) {
$.MsgBox.Alert("消息", "项目名称不能为空");
}
});
var projectFil = function(select) {
var string = ''
string += ''
string += '
'
string += '
'
string += ''
$("" + select + "").prepend(string);
}
$("#projectAdd").on("click", function() {
$("#projectShow").find(".listnone1").toggle(100);
});
$("#projectShow").on("click", ".close1", function() {
$("#projectShow").find(".listnone1").toggle(100);
});
$("#projectShow").on("click", "em", function() {
$(this).parent().parent().hide();
$(this).parent().parent().siblings().show();
//$(this).parent().parent().children(".")
});
$("#projectShow").on("click", ".close", function() {
$(this).parents(".modifybox").hide();
$(this).parents(".modifybox").siblings().show();
});
$("#projectShow").on("click", ".deletebtn", function() {
var deuId = $(this).parents(".txtExpForm").find(".projectId").val();
delProject(deuId);
});
//项目经历,对添加的项目删除
var delProject = function(data) {
$.ajax({
"url": "/ajax/project/" + data,
"type": "DELETE",
"success": function($data) {
if($data.success) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
$("#projectShow").empty("");
projectShow($data.data.projects);
}
});
} else {
alert($data.msg);
}
}
});
}
//项目经历保存
$("#projectShow").on("click", ".infor-save", function() {
var length = trim($(this).parents(".txtExpForm").find(".projectName").val());
var length1 = trim($(this).parents(".txtExpForm").find(".StartMonth").val());
var length2 = trim($(this).parents(".txtExpForm").find(".StopMonth").val());
if(!length) {
$.MsgBox.Alert("消息", "项目名称不能为空");
return;
}
if(length1 && !length2) {
$.MsgBox.Alert("消息", "没有选结束时间");
return;
}
if(!length1 && length2) {
$.MsgBox.Alert("消息", "没有选开始时间");
return;
}
var $data = {};
var $id = $(this).parents(".txtExpForm").find(".projectId").val();
//console.log($id);
if($id) {
$data.id = $id;
}
$data.professorId = userid;
var s = $(this).parents(".txtExpForm").find(".StartMonth").val();
var st = $(this).parents(".txtExpForm").find(".StopMonth").val();
if(s) {
$data.startMonth = s.substr(0, 4) + s.substr(5, 6);
}
if(st) {
if(st == "至今") {} else {
$data.stopMonth = st.substr(0, 4) + st.substr(5, 6);
}
}
$data.name = $(this).parents(".txtExpForm").find(".projectName").val()
$data.descp = $(this).parents(".txtExpForm").find(".projectDescp").val()
$.ajax({
"url": "../ajax/project",
"type": $id ? "PUT" : "POST",
"data": $id ? JSON.stringify($data) : $data,
"contentType": $id ? "application/json" : "application/x-www-form-urlencoded",
"success": function($data) {
if($data.success) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
$("#projectShow").empty("");
projectShow($data.data.projects);
yearAdd();
month();
$(".stopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
$(".StopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
}
});
} else {
$.MsgBox.Alert("message", $data.msg);
}
}
});
})
//著作论文 文章
var papFil = function(select) {
var string = ''
string += ''
$("" + select + "").prepend(string);
}
$("#paperShow").on("blur", ".paperName", function() {
var valueE = $(this).val();
var length = trim(valueE);
if(!length) {
$.MsgBox.Alert("消息", "标题不能为空");
}
})
$("#papAdd").on("click", function() {
$("#paperShow").find(".listnone1").toggle(100);
});
$("#paperShow").on("click", ".close1", function() {
$("#paperShow").find(".listnone1").toggle(100);
});
$("#paperShow").on("click", "em", function() {
$(this).parent().parent().hide();
$(this).parent().parent().siblings().show();
//$(this).parent().parent().children(".")
});
$("#paperShow").on("click", ".close", function() {
$(this).parents(".modifybox").hide();
$(this).parents(".modifybox").siblings().show();
});
$("#paperShow").on("click", ".deletebtn", function() {
var deuId = $(this).parents(".txtExpForm").find(".paperId").val();
delPaper(deuId);
});
//著作论文 文章 ,对添加的论文删除
var delPaper = function(data) {
$.ajax({
"url": "../ajax/paper/" + data,
"type": "DELETE",
"success": function($data) {
if($data.success) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
$("#paperShow").empty("");
paperShow($data.data.papers);
}
});
} else {
alert($data.msg);
}
}
});
}
//著作 论文 文章 保存
$("#paperShow").on("click", ".infor-save", function() {
var length = trim($(this).parents(".txtExpForm").find(".paperName").val());
if(!length) {
$.MsgBox.Alert("消息", "标题不能为空");
return;
}
var $data = {};
var $id = $(this).parents(".txtExpForm").find(".paperId").val();
if($id) {
$data.id = $id;
}
$data.professorId = userid;
$data.year = $(this).parents(".txtExpForm").find(".paperYear").val();
$data.name = $(this).parents(".txtExpForm").find(".paperName").val();
$data.descp = $(this).parents(".txtExpForm").find(".paperDescp").val();
$data.url = $(this).parents(".txtExpForm").find(".paperUrl").val();
$.ajax({
"url": "../ajax/paper",
"type": $id ? "PUT" : "POST",
"data": $id ? JSON.stringify($data) : $data,
"contentType": $id ? "application/json" : "application/x-www-form-urlencoded",
"success": function($data) {
if($data.success) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
$("#paperShow").empty("");
paperShow($data.data.papers);
yearAdd();
$(".stopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
$(".StopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
}
});
} else {
$.MsgBox.Alert("message", $data.msg);
}
}
});
});
//专利
$("#patentShow").on("blur", ".patentName", function() {
var valueE = $(this).val();
var length = trim(valueE);
if(!length) {
$.MsgBox.Alert("消息", "标题不能为空");
}
})
var patFil = function(select) {
var string = ''
string += ''
string += '
'
string += '
'
string += ''
$("" + select + "").prepend(string);
}
//专利添加
$("#patenAdd").on("click", function() {
$("#patentShow").find(".listnone1").toggle(100);
});
$("#patentShow").on("click", ".close1", function() {
$("#patentShow").find(".listnone1").toggle(100);
});
$("#patentShow").on("click", "em", function() {
$(this).parent().parent().hide();
$(this).parent().parent().siblings().show();
//$(this).parent().parent().children(".")
});
$("#patentShow").on("click", ".close", function() {
$(this).parents(".modifybox").hide();
$(this).parents(".modifybox").siblings().show();
});
$("#patentShow").on("click", ".deletebtn", function() {
var deuId = $(this).parents(".txtExpForm").find(".patentId").val();
delPatent(deuId);
})
//专利 ,对添加的专利删除
var delPatent = function(data) {
$.ajax({
"url": "/ajax/patent/" + data,
"type": "DELETE",
"success": function($data) {
if($data.success) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
$("#patentShow").empty();
patentShow($data.data.patents);
}
});
} else {
alert($data.msg);
}
}
});
}
//专利保存
$("#patentShow").on("click", ".infor-save", function() {
var length = trim($(this).parents(".txtExpForm").find(".patentName").val());
if(!length) {
$.MsgBox.Alert("消息", "标题不能为空");
return;
}
var $data = {};
var $id = $(this).parents(".txtExpForm").find(".patentId").val();
if($id) {
$data.id = $id;
}
$data.professorId = userid;
$data.year = $(this).parents(".txtExpForm").find(".patentYear").val();
$data.name = $(this).parents(".txtExpForm").find(".patentName").val();
$data.descp = $(this).parents(".txtExpForm").find(".patentDescp").val();
$data.url = $(this).parents(".txtExpForm").find(".patentUrl").val();
$.ajax({
"url": "../ajax/patent",
"type": $id ? "PUT" : "POST",
"data": $id ? JSON.stringify($data) : $data,
"contentType": $id ? "application/json" : "application/x-www-form-urlencoded",
"success": function($data) {
if($data.success) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
$("#patentShow").empty("");
patentShow($data.data.patents);
yearAdd();
$(".stopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
$(".StopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
}
});
} else {
$.MsgBox.Alert("message", $data.msg);
}
}
});
})
//荣誉及奖项
$("#honorShow").on("blur", ".honorName", function() {
var valueE = $(this).val();
var length = trim(valueE);
if(!length) {
$.MsgBox.Alert("消息", "标题不能为空");
}
})
var hounerFil = function(select) {
var string = ''
string += ''
string += '
'
string += '
'
string += ''
$("" + select + "").prepend(string);
}
//专利添加
$("#honorAdd").on("click", function() {
$("#honorShow").find(".listnone1").toggle(100);
});
$("#honorShow").on("click", ".close1", function() {
$("#honorShow").find(".listnone1").toggle(100);
});
$("#honorShow").on("click", "em", function() {
$(this).parent().parent().hide();
$(this).parent().parent().siblings().show();
//$(this).parent().parent().children(".")
});
$("#honorShow").on("click", ".close", function() {
$(this).parents(".modifybox").hide();
$(this).parents(".modifybox").siblings().show();
});
$("#honorShow").on("click", ".deletebtn", function() {
var deuId = $(this).parents(".txtExpForm").find(".honorId").val();
delHonor(deuId);
});
//荣誉及奖项 ,对添加的专利删除
var delHonor = function(data) {
$.ajax({
"url": "/ajax/honor/" + data,
"type": "DELETE",
"success": function($data) {
if($data.success) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
$("#honorShow").empty("");
honorShow($data.data.honors);
}
});
} else {
alert($data.msg);
}
}
});
}
//function getProfessorData(){
// $.get("/ajax/professor/info/" + userid, function($data) {
// if ($data.success) {
//
// }
// });
//}
//getProfessorData()
//荣誉及奖项保存
$("#honorShow").on("click", ".infor-save", function() {
var length = trim($(this).parents(".txtExpForm").find(".honorName").val());
if(!length) {
$.MsgBox.Alert("消息", "标题不能为空");
return;
}
var $data = {};
var $id = $(this).parents(".txtExpForm").find(".honorId").val();
if($id) {
$data.id = $id;
}
$data.professorId = userid;
$data.year = $(this).parents(".txtExpForm").find(".honorYear").val();
$data.name = $(this).parents(".txtExpForm").find(".honorName").val();
$data.descp = $(this).parents(".txtExpForm").find(".patentDescp").val();
//console.log($data.descp);
$.ajax({
"url": "../ajax/honor",
"type": $id ? "PUT" : "POST",
"data": $id ? JSON.stringify($data) : $data,
"contentType": $id ? "application/json" : "application/x-www-form-urlencoded",
"success": function($data) {
if($data.success) {
$.get("/ajax/professor/info/" + userid, function($data) {
if($data.success) {
$("#honorShow").empty("");
honorShow($data.data.honors);
yearAdd();
$(".stopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
$(".StopMonth").siblings(".mr_calendar_ym ").find(".mr_year").prepend("至今");
}
});
} else {
$.MsgBox.Alert("message", $data.msg);
}
}
});
})
//科研资源
$.ajax({
"url": "/ajax/resource/qapro",
"type": "get",
"data": {
"professorId": userid
},
"async": true,
"success": function(data) {
//console.log(data);
if(data.data.length == 0) {
$("#infor-browse").css("display", "none");
}
var add = "";
if(data.success) {
//console.log(data);
for(var i = 0; i < data.data.length; i++) {
add = ''
add += '
'
add += '
资源名称:' + data.data[i].resourceName + '
'
if(data.data[i].supportedServices == undefined) {
data.data[i].supportedServices = "";
}
add += '
应用用途:' + data.data[i].supportedServices + '
'
add += '
'
$add = $(add);
$("#keyanRe").append($add);
/*$(".resouImage").load(function(){})
.error(function(){
$(this).attr("src","/images/default-resource.jpg");
});*/
if(data.data[i].images.length) {
$add.find(".resourceImg").attr("src", "/images/resource/" + data.data[i].resourceId + ".jpg");
} else {
$add.find(".resourceImg").attr("src", "/images/default-resource.jpg");
}
//add="";
}
//资源轮播
var $content = $("#keyanRe");
var childcount = $content.find(".sharesrc").length;
Carousel(3, 3, 3, childcount, $content, $(".resoubtn2.resounext"), $(".resoubtn2.resouprev"));
} else {
$.MsgBox.Alert("消息", "系统异常!");
}
},
"error": function() {
$.MsgBox.Alert('message', 'failddd')
}
});
$("#enterwork").on("click", function() {
location.href = "newsciresource.html";
})
//到至今选中复选框的操作
/*$(".present").click(function(){
var date = $(".present").index(this);
$(".datebox").eq(date).find(".ago").remove();
$(".datebox").eq(date).css("width","326px");
})*/
$(".present").change(function() {
if($(".present").is(":checked")) {
$(this).parent().parent().find('.ago').hide();
$(this).parent().parent().find('.inputno').hide();
} else {
$(this).parent().parent().find('.ago').show();
$(this).parent().parent().find('.inputno').show();
}
})
/*科研文章*/
$.ajax({
url: "/ajax/article/qaPro",
dataType: 'json', //数据格式类型
type: 'GET', //http请求类型
data: {
"professorId": userid
},
timeout: 10000, //超时设置
success: function(data) {
if(data.success) {
if(!ifuser.authType2) {
$("#reA").hide();
return;
} else {
$("#reA").show();
if(data.data.length == 0) {
$("#reachArticle").height(0)
return;
}
for(var i = 0; i < data.data.length; i++) {
var add = ''
add += ''
add += '
' + data.data[i].articleTitle + '
'
add += '
'
add += '';
$add = $(add);
$("#reachArticle").append($add);
$add.find('.tagsBox span').text(data.data[i].industry); //data.data[i].subject
if(data.data[i].articleImg) {
$add.find(".art_img").attr("style", "background: url(/data/article/" + data.data[i].articleImg + ") 0 0 no-repeat;background-size:cover;");
}
}
//资源轮播
var $content2 = $("#keyanAr");
var childcount2 = $content2.find(".otherRes.shareshow li").length;
Carousel(3, 3, 3, childcount2, $content2, $(".articalbtn.resounext"), $(".articalbtn.resouprev"));
}
}
},
error: function() {
return;
}
});
$("#enter1work").on("click", function() {
location.href = "articalList.html";
})
/*ģ��Selectѡ���*/
$(".input_select").click(function() {
var ul = $(this).next();
if(ul.css("display") == "none") {
ul.slideDown("fast");
} else {
ul.slideUp("fast");
}
});
$(".divselect ul li a").click(function() {
var txt = $(this).text();
$(".divselect .input_select").val(txt);
var value = $(this).attr("rel");
$(".divselect ul").hide();
});
$("#aclick").on("click", function() {
exit();
});
})
function exit() {
$.cookie('userid', null);
$.cookie('userAuth', null);
location.href = "login.html"
}
//获取数据填充页面
/*����*/