portal html css js resource

common.js 13KB

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