|
$(document).ready(function() {
$(".unlogin").removeClass("displayNone");
var footerHeight = $("footer").outerHeight(true);
$('#container').css("padding-bottom", footerHeight + "px");
//窗口大小变更事件
$(window).resize(function() {
footerHeight = $("footer").outerHeight(true);
$('#container').css("padding-bottom", footerHeight + "px");
//console.log(footerHeight)
});
$(document).scroll(function() {
var top = $(document).scrollTop();
if(top == 0) {
$(".navheader").removeClass("navhdown");
} else {
$(".navheader").addClass("navhdown");
}
})
//退出登录转态
$("#exitLogin").on("click", function() {
exit();
})
//判断登录转态
var orgId = $.cookie("orgId");
if(orgId && orgId != "null" && orgId != null) {
$(".unlogin").addClass("displayNone");
$(".onlogin").removeClass("displayNone");
$.ajax("/ajax/image/hasOrgLogo", {
data: {
"id": orgId
},
type: "GET",
dataType: 'json',
async: false,
success: function($data) {
if($data.success) {
if($data.data) {
$("#imglogo").attr("src", "/images/org/" + orgId + ".jpg");
}
}
},
error: function() {
$.MsgBox.Alert('提示', '服务器请求失败')
},
});
$("#imglogo").on("click",function(){
location.href="../cmpInforShow.html?orgId="+orgId;
})
} else {
$(".unlogin").removeClass("displayNone");
$(".onlogin").addClass("displayNone");
}
});
//Model模态框打开关闭
function modelOpen() {
$(".blackcover").fadeIn();
$(".modelContain").slideDown();
$("body").addClass("modelOpen");
}
function modelClose() {
$(".modelContain").slideUp();
$(".blackcover").fadeOut();
$("body").removeClass("modelOpen");
}
function exit() {
$.cookie('orgId', null, {
path: "/"
});
$.cookie('orgAuth', null, {
path: "/"
});
$.cookie('orgEmail', null, {
path: "/"
});
$.cookie('orgName', null, {
path: "/"
});
$.cookie('orgType', null, {
path: "/"
});
location.href = "cmp-settled-log.html"
}
//截取url传值
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg); //��ȡurl��"?"�����ַ�����ƥ��
var context = "";
if(r != null)
context = r[2];
reg = null;
r = null;
return context == null || context == "" || context == "undefined" ? "" : decodeURI(context);
}
//转换格式
function changeTime(dealtime) {
var s = dealtime;
//console.log(s);
if(dealtime.length == 8) {
var y = s.substr(0, 4);
var m = s.substr(4, 2);
var d = s.substr(6, 2);
var formatTime = y + "-" + m + "-" + d;
return formatTime;
} else {
var y = s.substr(0, 4);
var m = s.substr(4, 2);
var d = s.substr(6, 2);
var h = s.substr(8, 2);
var minute = s.substr(10, 2);
var formatTime = y + "-" + m + "-" + d + " " + h + ":" + minute;
return formatTime;
}
}
//过滤特殊字符
function replaceStr(s) {
var pattern = new RegExp("-");
var rs = "";
for(var i = 0; i < s.length; i++) {
rs = rs + s.substr(i, 1).replace(pattern, '');
}
return rs;
}
//根据用户输入的Email跳转到相应的电子邮箱首页
var hash = {
'qq.com': 'http://mail.qq.com',
'gmail.com': 'http://mail.google.com',
'sina.com': 'http://mail.sina.com.cn',
'163.com': 'http://mail.163.com',
'126.com': 'http://mail.126.com',
'yeah.net': 'http://www.yeah.net/',
'sohu.com': 'http://mail.sohu.com/',
'tom.com': 'http://mail.tom.com/',
'sogou.com': 'http://mail.sogou.com/',
'139.com': 'http://mail.10086.cn/',
'hotmail.com': 'http://www.hotmail.com',
'live.com': 'http://login.live.com/',
'live.cn': 'http://login.live.cn/',
'live.com.cn': 'http://login.live.com.cn',
'189.com': 'http://webmail16.189.cn/webmail/',
'yahoo.com.cn': 'http://mail.cn.yahoo.com/',
'yahoo.cn': 'http://mail.cn.yahoo.com/',
'eyou.com': 'http://www.eyou.com/',
'21cn.com': 'http://mail.21cn.com/',
'188.com': 'http://www.188.com/',
'ustb.edu.cn': 'http://mail.ustb.edu.cn/',
'foxmail.coom': 'http://www.foxmail.com'
};
/*标志*/
function autho() {
if(arguments[0] == 1) {
return {
"sty": "authicon-pro",
"title": "科袖认证专家"
}
} else {
if(arguments[1] == 1) {
return {
"sty": "authicon-staff-ok",
"title": "企业认证员工"
}
} else {
if(arguments[2] == 3) {
return {
"sty": "authicon-real",
"title": "实名认证用户"
}
} else {
return {
"sty": "e",
"title": " "
}
}
}
}
}
/*选择省份*/
$(document).on("click", "#Province li a", function() {
var aVal = $(this).text();
$(this).parent().parent().parent().find('.mr_show').text(aVal);
$(this).parent().parent().parent().find('input[name=cho_Province]').val(aVal);
if($("#oprovince").text() == "请选择企业总部所在省或直辖市") {
$("#oprovince").removeClass("mr_select");
$("#ocity").removeClass("mr_select");
} else {
$("#oprovince").addClass("mr_select");
$("#ocity").removeClass("mr_select");
}
});
/*选择城市填充js */
$(document).on("click", "#City li a", function() {
var aVal = $(this).text();
$(this).parent().parent().parent().find('.mr_show').text(aVal);
$(this).parent().parent().parent().find('input[name=cho_City]').val(aVal);
if($("#ocity").text() == "请选择企业总部所在城市") {
$("#ocity").removeClass("mr_select");
} else {
$("#ocity").addClass("mr_select");
}
});
//下拉关键信息检索
function hotKey(sel) {
$(sel).bind({
paste: function(e) {
var pastedText;
if (window.clipboardData && window.clipboardData.getData) { // IE
pastedText = $(this).val() + window.clipboardData.getData('Text');
}
else {
pastedText = $(this).val() + e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
}
$(this).val(pastedText);
var $this = $(this);
setTimeout(function() {
if($this.val().trim()) {
$this.siblings("button").show();
} else {
$this.siblings("button").hide();
}
}, 1);
e.preventDefault();
},
cut: function(e) {
var $this = $(this);
setTimeout(function() {
if($this.val().trim()) {
$this.siblings("button").show();
} else {
$this.siblings("button").hide();
}
}, 1);
},
blur: function() {
var $this = $(this);
setTimeout(function() {
$this.siblings(".keydrop").hide();
}, 500)
},
focus: function() {
$(this).siblings(".keydrop").show();
},
keyup: function(e) {
var ti=$(this).val();
var $t=this;
$t.comr=ti;
var $this=$(this);
if($(this).val().trim()) {
$(this).siblings("button").show();
var lNum = $.trim($(this).val()).length;
if(0 < lNum) {
setTimeout(function(){
if( ti===$t.comr && ti!== $t.comrEnd) {
var tt=ti;
$t.comrEnd=tt;
$("#addKeyword").show();
$.ajax({
"url": "/ajax/dataDict/qaHotKey",
"type": "GET",
"success": function(data) {
console.log(data);
if(data.success) {
if($t.comrEnd==tt) {
if(data.data.length == 0) {
$this.siblings(".keydrop").addClass("displayNone");
$this.siblings(".keydrop").find("ul").html("");
} else {
$this.siblings(".keydrop").removeClass("displayNone");
var oSr = "";
for(var i = 0; i < Math.min(data.data.length,5); i++) {
oSr += '<li>' + data.data[i].caption + '<div class="closeThis"></div></li>';
}
$this.siblings(".keydrop").find("ul").html(oSr);
}
}
} else {
$this.siblings(".keydrop").addClass("displayNone");
$this.siblings(".keydrop").find("ul").html("");
}
},
"data": {
"key": $this.val()
},
dataType: "json",
'error': function() {
$.MsgBox.Alert('提示', '服务器连接超时!');
}
});
}
},500);
}
} else {
$(this).siblings("button").hide();
$(this).siblings(".keydrop").addClass("displayNone");
$(this).siblings(".keydrop").find("ul").html("");
}
}
})
$(".keydrop").on("click", "li", function() {
var oValue = $(this).text();
var oJudge = $(this).parents(".col-w-12").siblings().find("ul.ulspace li");
var addNum=$(this).parents(".keydrop").siblings("input").attr("data-num");
for(var i = 0; i < oJudge.length; i++) {
if(oValue == oJudge[i].innerText) {
$.MsgBox.Alert('提示', '添加内容不能重复');
return;
}
}
$(this).parents(".col-w-12").siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
$(this).parents(".keydrop").siblings("input").val("");
$(this).parents(".keydrop").siblings("button").hide();
if(oJudge.length == addNum-1) {
$(this).parents(".keydrop").siblings("input").val("");
$(this).parents(".col-w-12").hide();
}
$(this).parent("ul").html("")
})
/*添加*/
$("button:contains('添加')").click(function() {
var oValue = $(this).siblings("input").val().trim();
var oJudge = $(this).parent().siblings().find("ul.ulspace li");
var addContent=$(this).siblings("input").attr("data-pro");
var addNum=$(this).siblings("input").attr("data-num");
var addfontSizeNum=$(this).siblings("input").attr("data-fontSizeN");
if(!oValue) {
$.MsgBox.Alert('提示', '请先填写内容');
return;
}
if(oValue.length > addfontSizeNum) {
$.MsgBox.Alert('提示', addContent);
return;
}
for(var i = 0; i < oJudge.length; i++) {
if(oValue == oJudge[i].innerText) {
$.MsgBox.Alert('提示', '添加内容不能重复');
return;
}
}
$(this).parent().siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
$(this).hide();
$(this).siblings("input").val("");
if(oJudge.length == addNum-1) {
$(this).val("").parents(".col-w-12").hide();
}
$(this).siblings(".keydrop").find("ul").html("");
})
}
//带有限制字数的多行文本框
function limitObj(obj,maxNum){
$(obj).bind({
paste: function(e) {
if($(this).val().length==""){
$(this).parent().siblings("button").attr("disabled", true);
}else{
$(this).parent().siblings("button").attr("disabled", false);
}
var pastedText;
if (window.clipboardData && window.clipboardData.getData) { // IE
pastedText = $(this).val() + window.clipboardData.getData('Text');
}
else {
pastedText = $(this).val() + e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
}
$(this).val(pastedText);
setTimeout(function() {
$(this).siblings().find("em").text($(obj).val().length);
}, 1);
e.preventDefault();
},
cut: function(e) {
if($(this).val().length==""){
$(this).parent().siblings("button").attr("disabled", true);
}else{
$(this).parent().siblings("button").attr("disabled", false);
}
setTimeout(function() {
$(obj).siblings().find("em").text($(obj).val().length);
}, 1);
},
keyup: function(e) {
if($(this).val().length==""){
$(this).parent().siblings("button").attr("disabled", true);
}else{
$(this).parent().siblings("button").attr("disabled", false);
}
if($(this).val().length > maxNum) {
$(obj).val($(obj).val().substring(0, maxNum));
e.preventDefault();
}
setTimeout(function() {
$(obj).siblings().find("em").text($(obj).val().length);
}, 1);
}
});
}
//时间显示规则
function commenTime(startTime) {
//console.log(startTime)
var nowTimg = new Date();
var startdate = new Date();
startdate.setFullYear(parseInt(startTime.substring(0, 4)));
startdate.setMonth(parseInt(startTime.substring(4, 6)) - 1);
startdate.setDate(parseInt(startTime.substring(6, 8)));
startdate.setHours(parseInt(startTime.substring(8, 10)));
startdate.setMinutes(parseInt(startTime.substring(10, 12)));
startdate.setSeconds(parseInt(startTime.substring(12, 14)));
var date3 = nowTimg.getTime() - startdate.getTime(); //时间差的毫秒数
var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
if(date3 < 60000) {
return "刚刚";
} else if(date3 >= 60000 && date3 < 3600000) {
return minutes + "分钟前";
} else if(date3 >= 3600000 && date3 < 86400000) {
return hours + "小时前";
} else if(date3 >= 86400000) {
if(nowTimg.getFullYear() == startTime.substring(0, 4)) {
return startTime.substring(4, 6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6, 8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8, 10) + ":" + startTime.substring(10, 12);
} else {
return startTime.substring(0, 4) + "年" + startTime.substring(4, 6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6, 8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8, 10) + ":" + startTime.substring(10, 12);
}
}
}
function TimeTr(dealtime) {
var myDate = new Date();
var s = dealtime;
var y = s.substr(0, 4);
var m = s.substr(4, 2);
var d = s.substr(6, 2);
var h = s.substr(8, 2);
var minute = s.substr(10, 2);
var formatTime;
if(s.length <= 6) {
formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月";
} else if(s.length > 6 && s.length <= 8) {
formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 ";
if(y != myDate.getFullYear()) {
formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 ";
}
} else {
formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
if(y != myDate.getFullYear()) {
formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
}
}
return formatTime;
}
//栏目
var columnType = {
"1":{
fullName:"个人原创",
shortName:"原创"
},
"2":{
fullName:"企业原创",
shortName:"原创"
},
"3":{
fullName:"前沿动态",
shortName:"前沿"
},
"4":{
fullName:"学术经验",
shortName:"经验"
},
"5":{
fullName:"分析检测",
shortName:"检测"
},
"6":{
fullName:"会议培训",
shortName:"会议"
},
"7":{
fullName:"科袖访谈",
shortName:"访谈"
},
"8":{
fullName:"招聘招生",
shortName:"招聘"
},
"9":{
fullName:"重大新闻",
shortName:"新闻"
}
}
function fillColum(allnum){//填充栏目选项
var zCount=allnum+3;
for(var i=3;i<zCount;i++){
var colum=$('<option value="'+i+'">'+columnType[i].fullName+'</option>')
$(".form-column").append(colum);
}
}
var currentdate;
function getNowFormatDate() {
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var strDate = date.getDate();
var getHours = date.getHours();
var getMinutes = date.getMinutes();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
if (getMinutes >= 0 && getMinutes <= 9) {
getMinutes = "0" + getMinutes;
}
if (getHours >= 0 && getHours <= 9) {
getHours = "0" + getHours;
}
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
+ " " + getHours + seperator2 + getMinutes
return currentdate;
}
function resMgr(oid) {
$.ajax({
url: "/ajax/org/" +oid,
type: "GET",
timeout: 10000,
dataType: "json",
async:"true",
success: function(data, textState) {
if(data.success) {
if(data.data.resMgr) {
$('a:contains("资源")').parent().show();
}
}
},
error: function(XMLHttpRequest, textStats, errorThrown) {
$.MsgBox.Alert('提示', '服务器请求失败')
}
})
}
|