portal html css js resource

common.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. $(document).ready(function() {
  2. $(".unlogin").removeClass("displayNone");
  3. var footerHeight = $("footer").outerHeight(true);
  4. $('#container').css("padding-bottom", footerHeight + "px");
  5. //窗口大小变更事件
  6. $(window).resize(function() {
  7. footerHeight = $("footer").outerHeight(true);
  8. $('#container').css("padding-bottom", footerHeight + "px");
  9. //console.log(footerHeight)
  10. });
  11. $(document).scroll(function() {
  12. var top = $(document).scrollTop();
  13. if(top == 0) {
  14. $(".navheader").removeClass("navhdown");
  15. } else {
  16. $(".navheader").addClass("navhdown");
  17. }
  18. })
  19. //退出登录转态
  20. $("#exitLogin").on("click", function() {
  21. exit();
  22. })
  23. //判断登录转态
  24. var orgId = $.cookie("orgId");
  25. if(orgId && orgId != "null" && orgId != null) {
  26. $(".unlogin").addClass("displayNone");
  27. $(".onlogin").removeClass("displayNone");
  28. $.ajax("/ajax/image/hasOrgLogo", {
  29. data: {
  30. "id": orgId
  31. },
  32. type: "GET",
  33. dataType: 'json',
  34. async: false,
  35. success: function($data) {
  36. if($data.success) {
  37. if($data.data) {
  38. $("#imglogo").attr("src", "/images/org/" + orgId + ".jpg");
  39. }
  40. }
  41. },
  42. error: function() {
  43. $.MsgBox.Alert('提示', '服务器请求失败')
  44. },
  45. });
  46. $("#imglogo").on("click",function(){
  47. location.href="../cmpInforShow.html?orgId="+orgId;
  48. })
  49. } else {
  50. $(".unlogin").removeClass("displayNone");
  51. $(".onlogin").addClass("displayNone");
  52. }
  53. });
  54. //Model模态框打开关闭
  55. function modelOpen() {
  56. $(".blackcover").fadeIn();
  57. $(".modelContain").slideDown();
  58. $("body").addClass("modelOpen");
  59. }
  60. function modelClose() {
  61. $(".modelContain").slideUp();
  62. $(".blackcover").fadeOut();
  63. $("body").removeClass("modelOpen");
  64. }
  65. function exit() {
  66. $.cookie('orgId', null, {
  67. path: "/"
  68. });
  69. $.cookie('orgAuth', null, {
  70. path: "/"
  71. });
  72. $.cookie('orgEmail', null, {
  73. path: "/"
  74. });
  75. $.cookie('orgName', null, {
  76. path: "/"
  77. });
  78. $.cookie('orgType', null, {
  79. path: "/"
  80. });
  81. location.href = "cmp-settled-log.html"
  82. }
  83. //截取url传值
  84. function GetQueryString(name) {
  85. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  86. var r = window.location.search.substr(1).match(reg); //��ȡurl��"?"�����ַ�����ƥ��
  87. var context = "";
  88. if(r != null)
  89. context = r[2];
  90. reg = null;
  91. r = null;
  92. return context == null || context == "" || context == "undefined" ? "" : decodeURI(context);
  93. }
  94. //转换格式
  95. function changeTime(dealtime) {
  96. var s = dealtime;
  97. //console.log(s);
  98. if(dealtime.length == 8) {
  99. var y = s.substr(0, 4);
  100. var m = s.substr(4, 2);
  101. var d = s.substr(6, 2);
  102. var formatTime = y + "-" + m + "-" + d;
  103. return formatTime;
  104. } else {
  105. var y = s.substr(0, 4);
  106. var m = s.substr(4, 2);
  107. var d = s.substr(6, 2);
  108. var h = s.substr(8, 2);
  109. var minute = s.substr(10, 2);
  110. var formatTime = y + "-" + m + "-" + d + " " + h + ":" + minute;
  111. return formatTime;
  112. }
  113. }
  114. //过滤特殊字符
  115. function replaceStr(s) {
  116. var pattern = new RegExp("-");
  117. var rs = "";
  118. for(var i = 0; i < s.length; i++) {
  119. rs = rs + s.substr(i, 1).replace(pattern, '');
  120. }
  121. return rs;
  122. }
  123. //根据用户输入的Email跳转到相应的电子邮箱首页
  124. var hash = {
  125. 'qq.com': 'http://mail.qq.com',
  126. 'gmail.com': 'http://mail.google.com',
  127. 'sina.com': 'http://mail.sina.com.cn',
  128. '163.com': 'http://mail.163.com',
  129. '126.com': 'http://mail.126.com',
  130. 'yeah.net': 'http://www.yeah.net/',
  131. 'sohu.com': 'http://mail.sohu.com/',
  132. 'tom.com': 'http://mail.tom.com/',
  133. 'sogou.com': 'http://mail.sogou.com/',
  134. '139.com': 'http://mail.10086.cn/',
  135. 'hotmail.com': 'http://www.hotmail.com',
  136. 'live.com': 'http://login.live.com/',
  137. 'live.cn': 'http://login.live.cn/',
  138. 'live.com.cn': 'http://login.live.com.cn',
  139. '189.com': 'http://webmail16.189.cn/webmail/',
  140. 'yahoo.com.cn': 'http://mail.cn.yahoo.com/',
  141. 'yahoo.cn': 'http://mail.cn.yahoo.com/',
  142. 'eyou.com': 'http://www.eyou.com/',
  143. '21cn.com': 'http://mail.21cn.com/',
  144. '188.com': 'http://www.188.com/',
  145. 'ustb.edu.cn': 'http://mail.ustb.edu.cn/',
  146. 'foxmail.coom': 'http://www.foxmail.com'
  147. };
  148. /*标志*/
  149. function autho() {
  150. if(arguments[0] == 1) {
  151. return {
  152. "sty": "authicon-pro",
  153. "title": "科袖认证专家"
  154. }
  155. } else {
  156. if(arguments[1] == 1) {
  157. return {
  158. "sty": "authicon-staff-ok",
  159. "title": "企业认证员工"
  160. }
  161. } else {
  162. if(arguments[2] == 3) {
  163. return {
  164. "sty": "authicon-real",
  165. "title": "实名认证用户"
  166. }
  167. } else {
  168. return {
  169. "sty": "e",
  170. "title": " "
  171. }
  172. }
  173. }
  174. }
  175. }
  176. /*选择省份*/
  177. $(document).on("click", "#Province li a", function() {
  178. var aVal = $(this).text();
  179. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  180. $(this).parent().parent().parent().find('input[name=cho_Province]').val(aVal);
  181. if($("#oprovince").text() == "请选择企业总部所在省或直辖市") {
  182. $("#oprovince").removeClass("mr_select");
  183. $("#ocity").removeClass("mr_select");
  184. } else {
  185. $("#oprovince").addClass("mr_select");
  186. $("#ocity").removeClass("mr_select");
  187. }
  188. });
  189. /*选择城市填充js */
  190. $(document).on("click", "#City li a", function() {
  191. var aVal = $(this).text();
  192. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  193. $(this).parent().parent().parent().find('input[name=cho_City]').val(aVal);
  194. if($("#ocity").text() == "请选择企业总部所在城市") {
  195. $("#ocity").removeClass("mr_select");
  196. } else {
  197. $("#ocity").addClass("mr_select");
  198. }
  199. });
  200. //下拉关键信息检索
  201. function hotKey(sel) {
  202. $(sel).bind({
  203. paste: function(e) {
  204. var pastedText;
  205. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  206.             
  207. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  208. else  {            
  209. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  210.           
  211. }
  212. $(this).val(pastedText);
  213. var $this = $(this);
  214. setTimeout(function() {
  215. if($this.val().trim()) {
  216. $this.siblings("button").show();
  217. } else {
  218. $this.siblings("button").hide();
  219. }
  220. }, 1);
  221. e.preventDefault();
  222. },
  223. cut: function(e) {
  224. var $this = $(this);
  225. setTimeout(function() {
  226. if($this.val().trim()) {
  227. $this.siblings("button").show();
  228. } else {
  229. $this.siblings("button").hide();
  230. }
  231. }, 1);
  232. },
  233. blur: function() {
  234. var $this = $(this);
  235. setTimeout(function() {
  236. $this.siblings(".keydrop").hide();
  237. }, 500)
  238. },
  239. focus: function() {
  240. $(this).siblings(".keydrop").show();
  241. },
  242. keyup: function(e) {
  243. var ti=$(this).val();
  244. var $t=this;
  245. $t.comr=ti;
  246. var $this=$(this);
  247. if($(this).val().trim()) {
  248. $(this).siblings("button").show();
  249. var lNum = $.trim($(this).val()).length;
  250. if(0 < lNum) {
  251. setTimeout(function(){
  252. if( ti===$t.comr && ti!== $t.comrEnd) {
  253. var tt=ti;
  254. $t.comrEnd=tt;
  255. $("#addKeyword").show();
  256. $.ajax({
  257. "url": "/ajax/dataDict/qaHotKey",
  258. "type": "GET",
  259. "success": function(data) {
  260. console.log(data);
  261. if(data.success) {
  262. if($t.comrEnd==tt) {
  263. if(data.data.length == 0) {
  264. $this.siblings(".keydrop").addClass("displayNone");
  265. $this.siblings(".keydrop").find("ul").html("");
  266. } else {
  267. $this.siblings(".keydrop").removeClass("displayNone");
  268. var oSr = "";
  269. for(var i = 0; i < Math.min(data.data.length,5); i++) {
  270. oSr += '<li>' + data.data[i].caption + '<div class="closeThis"></div></li>';
  271. }
  272. $this.siblings(".keydrop").find("ul").html(oSr);
  273. }
  274. }
  275. } else {
  276. $this.siblings(".keydrop").addClass("displayNone");
  277. $this.siblings(".keydrop").find("ul").html("");
  278. }
  279. },
  280. "data": {
  281. "key": $this.val()
  282. },
  283. dataType: "json",
  284. 'error': function() {
  285. $.MsgBox.Alert('提示', '服务器连接超时!');
  286. }
  287. });
  288. }
  289. },500);
  290. }
  291. } else {
  292. $(this).siblings("button").hide();
  293. $(this).siblings(".keydrop").addClass("displayNone");
  294. $(this).siblings(".keydrop").find("ul").html("");
  295. }
  296. }
  297. })
  298. $(".keydrop").on("click", "li", function() {
  299. var oValue = $(this).text();
  300. var oJudge = $(this).parents(".col-w-12").siblings().find("ul.ulspace li");
  301. var addNum=$(this).parents(".keydrop").siblings("input").attr("data-num");
  302. for(var i = 0; i < oJudge.length; i++) {
  303. if(oValue == oJudge[i].innerText) {
  304. $.MsgBox.Alert('提示', '添加内容不能重复');
  305. return;
  306. }
  307. }
  308. $(this).parents(".col-w-12").siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  309. $(this).parents(".keydrop").siblings("input").val("");
  310. $(this).parents(".keydrop").siblings("button").hide();
  311. if(oJudge.length == addNum-1) {
  312. $(this).parents(".keydrop").siblings("input").val("");
  313. $(this).parents(".col-w-12").hide();
  314. }
  315. $(this).parent("ul").html("")
  316. })
  317. /*添加*/
  318. $("button:contains('添加')").click(function() {
  319. var oValue = $(this).siblings("input").val().trim();
  320. var oJudge = $(this).parent().siblings().find("ul.ulspace li");
  321. var addContent=$(this).siblings("input").attr("data-pro");
  322. var addNum=$(this).siblings("input").attr("data-num");
  323. var addfontSizeNum=$(this).siblings("input").attr("data-fontSizeN");
  324. if(!oValue) {
  325. $.MsgBox.Alert('提示', '请先填写内容');
  326. return;
  327. }
  328. if(oValue.length > addfontSizeNum) {
  329. $.MsgBox.Alert('提示', addContent);
  330. return;
  331. }
  332. for(var i = 0; i < oJudge.length; i++) {
  333. if(oValue == oJudge[i].innerText) {
  334. $.MsgBox.Alert('提示', '添加内容不能重复');
  335. return;
  336. }
  337. }
  338. $(this).parent().siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  339. $(this).hide();
  340. $(this).siblings("input").val("");
  341. if(oJudge.length == addNum-1) {
  342. $(this).val("").parents(".col-w-12").hide();
  343. }
  344. $(this).siblings(".keydrop").find("ul").html("");
  345. })
  346. }
  347. //带有限制字数的多行文本框
  348. function limitObj(obj,maxNum){
  349. $(obj).bind({
  350. paste: function(e) {
  351. if($(this).val().length==""){
  352. $(this).parent().siblings("button").attr("disabled", true);
  353. }else{
  354. $(this).parent().siblings("button").attr("disabled", false);
  355. }
  356. var pastedText;
  357. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  358. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  359. else  {            
  360. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  361. }
  362. $(this).val(pastedText);
  363. setTimeout(function() {
  364. $(this).siblings().find("em").text($(obj).val().length);
  365. }, 1);
  366. e.preventDefault();
  367. },
  368. cut: function(e) {
  369. if($(this).val().length==""){
  370. $(this).parent().siblings("button").attr("disabled", true);
  371. }else{
  372. $(this).parent().siblings("button").attr("disabled", false);
  373. }
  374. setTimeout(function() {
  375. $(obj).siblings().find("em").text($(obj).val().length);
  376. }, 1);
  377. },
  378. keyup: function(e) {
  379. if($(this).val().length==""){
  380. $(this).parent().siblings("button").attr("disabled", true);
  381. }else{
  382. $(this).parent().siblings("button").attr("disabled", false);
  383. }
  384. if($(this).val().length > maxNum) {
  385. $(obj).val($(obj).val().substring(0, maxNum));
  386. e.preventDefault();
  387. }
  388. setTimeout(function() {
  389. $(obj).siblings().find("em").text($(obj).val().length);
  390. }, 1);
  391. }
  392. });
  393. }
  394. //时间显示规则
  395. function commenTime(startTime) {
  396. //console.log(startTime)
  397. var nowTimg = new Date();
  398. var startdate = new Date();
  399. startdate.setFullYear(parseInt(startTime.substring(0, 4)));
  400. startdate.setMonth(parseInt(startTime.substring(4, 6)) - 1);
  401. startdate.setDate(parseInt(startTime.substring(6, 8)));
  402. startdate.setHours(parseInt(startTime.substring(8, 10)));
  403. startdate.setMinutes(parseInt(startTime.substring(10, 12)));
  404. startdate.setSeconds(parseInt(startTime.substring(12, 14)));
  405. var date3 = nowTimg.getTime() - startdate.getTime(); //时间差的毫秒数
  406. var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  407. var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
  408. if(date3 < 60000) {
  409. return "刚刚";
  410. } else if(date3 >= 60000 && date3 < 3600000) {
  411. return minutes + "分钟前";
  412. } else if(date3 >= 3600000 && date3 < 86400000) {
  413. return hours + "小时前";
  414. } else if(date3 >= 86400000) {
  415. if(nowTimg.getFullYear() == startTime.substring(0, 4)) {
  416. 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);
  417. } else {
  418. 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);
  419. }
  420. }
  421. }
  422. function TimeTr(dealtime) {
  423. var myDate = new Date();
  424. var s = dealtime;
  425. var y = s.substr(0, 4);
  426. var m = s.substr(4, 2);
  427. var d = s.substr(6, 2);
  428. var h = s.substr(8, 2);
  429. var minute = s.substr(10, 2);
  430. var formatTime;
  431. if(s.length <= 6) {
  432. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月";
  433. } else if(s.length > 6 && s.length <= 8) {
  434. formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 ";
  435. if(y != myDate.getFullYear()) {
  436. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 ";
  437. }
  438. } else {
  439. formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  440. if(y != myDate.getFullYear()) {
  441. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  442. }
  443. }
  444. return formatTime;
  445. }
  446. //栏目
  447. var columnType = {
  448. "1":{
  449. fullName:"个人原创",
  450. shortName:"原创"
  451. },
  452. "2":{
  453. fullName:"企业原创",
  454. shortName:"原创"
  455. },
  456. "3":{
  457. fullName:"前沿动态",
  458. shortName:"前沿"
  459. },
  460. "4":{
  461. fullName:"学术经验",
  462. shortName:"经验"
  463. },
  464. "5":{
  465. fullName:"分析检测",
  466. shortName:"检测"
  467. },
  468. "6":{
  469. fullName:"会议培训",
  470. shortName:"会议"
  471. },
  472. "7":{
  473. fullName:"科袖访谈",
  474. shortName:"访谈"
  475. },
  476. "8":{
  477. fullName:"招聘招生",
  478. shortName:"招聘"
  479. },
  480. "9":{
  481. fullName:"重大新闻",
  482. shortName:"新闻"
  483. }
  484. }
  485. function fillColum(allnum){//填充栏目选项
  486. var zCount=allnum+3;
  487. for(var i=3;i<zCount;i++){
  488. var colum=$('<option value="'+i+'">'+columnType[i].fullName+'</option>')
  489. $(".form-column").append(colum);
  490. }
  491. }
  492. var currentdate;
  493. function getNowFormatDate() {
  494. var date = new Date();
  495. var seperator1 = "-";
  496. var seperator2 = ":";
  497. var month = date.getMonth() + 1;
  498. var strDate = date.getDate();
  499. var getHours = date.getHours();
  500. var getMinutes = date.getMinutes();
  501. if (month >= 1 && month <= 9) {
  502. month = "0" + month;
  503. }
  504. if (strDate >= 0 && strDate <= 9) {
  505. strDate = "0" + strDate;
  506. }
  507. if (getMinutes >= 0 && getMinutes <= 9) {
  508. getMinutes = "0" + getMinutes;
  509. }
  510. if (getHours >= 0 && getHours <= 9) {
  511. getHours = "0" + getHours;
  512. }
  513. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
  514. + " " + getHours + seperator2 + getMinutes
  515. return currentdate;
  516. }