portal html css js resource

common.js 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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('添加')").siblings("input").keypress(function(){
  319. var e = event || window.event;
  320. if(e.keyCode == 13) {
  321. var oValue = $(this).val().trim();
  322. var oJudge = $(this).parent().siblings().find("ul.ulspace li");
  323. var addContent = $(this).attr("data-pro");
  324. var addNum = $(this).attr("data-num");
  325. var addfontSizeNum = $(this).attr("data-fontSizeN");
  326. if(!oValue) {
  327. $.MsgBox.Alert('提示', '请先填写内容');
  328. return;
  329. }
  330. if(oValue.length > addfontSizeNum) {
  331. $.MsgBox.Alert('提示', addContent);
  332. return;
  333. }
  334. for(var i = 0; i < oJudge.length; i++) {
  335. if(oValue == oJudge[i].innerText) {
  336. $.MsgBox.Alert('提示', '添加内容不能重复');
  337. return;
  338. }
  339. }
  340. $(this).parent().siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  341. $(this).siblings(".addButton").hide();
  342. $(this).val("");
  343. if(oJudge.length == addNum - 1) {
  344. $(this).val("").parents(".col-w-12").hide();
  345. }
  346. $(this).siblings(".keydrop").find("ul").html("");
  347. }
  348. })
  349. $("button:contains('添加')").click(function() {
  350. var oValue = $(this).siblings("input").val().trim();
  351. var oJudge = $(this).parent().siblings().find("ul.ulspace li");
  352. var addContent=$(this).siblings("input").attr("data-pro");
  353. var addNum=$(this).siblings("input").attr("data-num");
  354. var addfontSizeNum=$(this).siblings("input").attr("data-fontSizeN");
  355. if(!oValue) {
  356. $.MsgBox.Alert('提示', '请先填写内容');
  357. return;
  358. }
  359. if(oValue.length > addfontSizeNum) {
  360. $.MsgBox.Alert('提示', addContent);
  361. return;
  362. }
  363. for(var i = 0; i < oJudge.length; i++) {
  364. if(oValue == oJudge[i].innerText) {
  365. $.MsgBox.Alert('提示', '添加内容不能重复');
  366. return;
  367. }
  368. }
  369. $(this).parent().siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  370. $(this).hide();
  371. $(this).siblings("input").val("");
  372. if(oJudge.length == addNum-1) {
  373. $(this).val("").parents(".col-w-12").hide();
  374. }
  375. $(this).siblings(".keydrop").find("ul").html("");
  376. })
  377. }
  378. //带有限制字数的多行文本框
  379. function limitObj(obj,maxNum){
  380. $(obj).bind({
  381. paste: function(e) {
  382. if($(this).val().length==""){
  383. $(this).parent().siblings("button").attr("disabled", true);
  384. }else{
  385. $(this).parent().siblings("button").attr("disabled", false);
  386. }
  387. var pastedText;
  388. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  389. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  390. else  {            
  391. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  392. }
  393. $(this).val(pastedText);
  394. setTimeout(function() {
  395. $(this).siblings().find("em").text($(obj).val().length);
  396. }, 1);
  397. e.preventDefault();
  398. },
  399. cut: function(e) {
  400. if($(this).val().length==""){
  401. $(this).parent().siblings("button").attr("disabled", true);
  402. }else{
  403. $(this).parent().siblings("button").attr("disabled", false);
  404. }
  405. setTimeout(function() {
  406. $(obj).siblings().find("em").text($(obj).val().length);
  407. }, 1);
  408. },
  409. keyup: function(e) {
  410. if($(this).val().length==""){
  411. $(this).parent().siblings("button").attr("disabled", true);
  412. }else{
  413. $(this).parent().siblings("button").attr("disabled", false);
  414. }
  415. if($(this).val().length > maxNum) {
  416. $(obj).val($(obj).val().substring(0, maxNum));
  417. e.preventDefault();
  418. }
  419. setTimeout(function() {
  420. $(obj).siblings().find("em").text($(obj).val().length);
  421. }, 1);
  422. }
  423. });
  424. }
  425. //时间显示规则
  426. function commenTime(startTime) {
  427. //console.log(startTime)
  428. var nowTimg = new Date();
  429. var startdate = new Date();
  430. startdate.setFullYear(parseInt(startTime.substring(0, 4)));
  431. startdate.setMonth(parseInt(startTime.substring(4, 6)) - 1);
  432. startdate.setDate(parseInt(startTime.substring(6, 8)));
  433. startdate.setHours(parseInt(startTime.substring(8, 10)));
  434. startdate.setMinutes(parseInt(startTime.substring(10, 12)));
  435. startdate.setSeconds(parseInt(startTime.substring(12, 14)));
  436. var date3 = nowTimg.getTime() - startdate.getTime(); //时间差的毫秒数
  437. var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  438. var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
  439. if(date3 < 60000) {
  440. return "刚刚";
  441. } else if(date3 >= 60000 && date3 < 3600000) {
  442. return minutes + "分钟前";
  443. } else if(date3 >= 3600000 && date3 < 86400000) {
  444. return hours + "小时前";
  445. } else if(date3 >= 86400000) {
  446. if(nowTimg.getFullYear() == startTime.substring(0, 4)) {
  447. 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);
  448. } else {
  449. 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);
  450. }
  451. }
  452. }
  453. function TimeTr(dealtime) {
  454. var myDate = new Date();
  455. var s = dealtime;
  456. var y = s.substr(0, 4);
  457. var m = s.substr(4, 2);
  458. var d = s.substr(6, 2);
  459. var h = s.substr(8, 2);
  460. var minute = s.substr(10, 2);
  461. var formatTime;
  462. if(s.length <= 6) {
  463. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月";
  464. } else if(s.length > 6 && s.length <= 8) {
  465. formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 ";
  466. if(y != myDate.getFullYear()) {
  467. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 ";
  468. }
  469. } else {
  470. formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  471. if(y != myDate.getFullYear()) {
  472. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  473. }
  474. }
  475. return formatTime;
  476. }
  477. //栏目
  478. var columnType = {
  479. "1":{
  480. fullName:"个人原创",
  481. shortName:"原创"
  482. },
  483. "2":{
  484. fullName:"企业原创",
  485. shortName:"原创"
  486. },
  487. "3":{
  488. fullName:"科研",
  489. shortName:"科研"
  490. },
  491. "4":{
  492. fullName:"智库",
  493. shortName:"智库"
  494. },
  495. "5":{
  496. fullName:"检测",
  497. shortName:"检测"
  498. },
  499. "6":{
  500. fullName:"会议",
  501. shortName:"会议"
  502. },
  503. "7":{
  504. fullName:"企业",
  505. shortName:"企业"
  506. },
  507. "8":{
  508. fullName:"招聘",
  509. shortName:"招聘"
  510. },
  511. "9":{
  512. fullName:"新闻",
  513. shortName:"新闻"
  514. }
  515. }
  516. function fillColum(allnum){//填充栏目选项
  517. var zCount=allnum+3;
  518. for(var i=3;i<zCount;i++){
  519. var colum=$('<option value="'+i+'">'+columnType[i].fullName+'</option>')
  520. $(".form-column").append(colum);
  521. }
  522. }
  523. var currentdate;
  524. function getNowFormatDate() {
  525. var date = new Date();
  526. var seperator1 = "-";
  527. var seperator2 = ":";
  528. var month = date.getMonth() + 1;
  529. var strDate = date.getDate();
  530. var getHours = date.getHours();
  531. var getMinutes = date.getMinutes();
  532. if (month >= 1 && month <= 9) {
  533. month = "0" + month;
  534. }
  535. if (strDate >= 0 && strDate <= 9) {
  536. strDate = "0" + strDate;
  537. }
  538. if (getMinutes >= 0 && getMinutes <= 9) {
  539. getMinutes = "0" + getMinutes;
  540. }
  541. if (getHours >= 0 && getHours <= 9) {
  542. getHours = "0" + getHours;
  543. }
  544. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
  545. + " " + getHours + seperator2 + getMinutes
  546. return currentdate;
  547. }
  548. function resMgr(oid) {
  549. $.ajax({
  550. url: "/ajax/org/" +oid,
  551. type: "GET",
  552. timeout: 10000,
  553. dataType: "json",
  554. async:"true",
  555. success: function(data, textState) {
  556. if(data.success) {
  557. if(data.data.resMgr) {
  558. $('a:contains("资源")').parent().show();
  559. }
  560. }
  561. },
  562. error: function(XMLHttpRequest, textStats, errorThrown) {
  563. $.MsgBox.Alert('提示', '服务器请求失败')
  564. }
  565. })
  566. }