var page_index_artical = 0, page_index_video = 0, page_index_img = 0, contentTypeAticle = 'Article', contentTypeVideo = 'Video', contentTypeImg = 'Image', href = window.siteURL + "comment/list/index.shtml?contentID=", cur_sortType, cur_attributes, pageSize = 12, isMore = true, isLock = false; (function($){ $("div.publish-date").each(function() { $(this).html(timestampFormat($(this).attr('data-publishdate').replaceAll("-", "/"))); }) //==== start 璧勬簮璺緞鏌ユ壘 ==== var getCurrentScript = function (base) { if (document.currentScript) { return document.currentScript.src; //FF,Chrome }; var stack; try { a.b.c(); //寮哄埗鎶ラ敊,浠ヤ究鎹曡幏e.stack } catch (e) { //safari鐨勯敊璇璞″彧鏈塴ine,sourceId,sourceURL stack = e.stack; if (!stack && window.opera) { //opera 9娌℃湁e.stack,浣嗘湁e.Backtrace,浣嗕笉鑳界洿鎺ュ彇寰?闇€瑕佸e瀵硅薄杞瓧绗︿覆杩涜鎶藉彇 stack = (String(e).match(/of linked script \S+/g) || []).join(" "); } } if (stack) { stack = stack.split(/[@ ]/g).pop(); //鍙栧緱鏈€鍚庝竴琛?鏈€鍚庝竴涓┖鏍兼垨@涔嬪悗鐨勯儴鍒 stack = stack[0] === "(" ? stack.slice(1, -1) : stack.replace(/\s/, ""); //鍘绘帀鎹㈣绗 return stack.replace(/(:\d+)?:\d+$/i, ""); //鍘绘帀琛屽彿涓庢垨璁稿瓨鍦ㄧ殑鍑洪敊瀛楃璧峰浣嶇疆 } var nodes = (base ? document : head).getElementsByTagName("script"); //鍙湪head鏍囩涓鎵 for (var i = nodes.length, node; node = nodes[--i]; ) { if (node.readyState === "interactive") { return node.src; } } var node=nodes[nodes.length - 1]; return node.hasAttribute ? node.src : node.getAttribute("src", 4); } var jspath = getCurrentScript(true); var scripts = document.getElementsByTagName('script'), script = document.currentScript || scripts[scripts.length - 1]; JSLIBPATH = jspath.substr(0, jspath.lastIndexOf('/') + 1); //==== end 璧勬簮璺緞鏌ユ壘 ==== $(function(){ var previewSiteLink = window.frontAppContext + 'ui/preview/site/'+window.siteID; $('#siteLink').attr('href', window.isPreview? previewSiteLink:window.siteURL);//闈㈠寘灞戣矾寰 if(window.isPreview){ $('#home>a').attr('href', previewSiteLink);//澶撮儴 } var menuBtnImg = $('.head .menu-btn img'); //绐楀彛鍙樺姩鏃讹紝閲嶇疆瀵艰埅鏄剧ず鐘舵€ $(window).resize(function(){ if($(document.body).width() < 992){ $('.head .menu').hide(); $('.head .menu').css({top: $('.head').height()}); menuBtnImg.attr("src",JSLIBPATH+ "../images/menu.png"); menuBtnImg.removeClass('active'); }else { $('.head .menu').show(); $('.head .menu').css({top: ''}); } }) //==== end 瀵艰埅鑿滃崟 ==== //==== start 鐐瑰嚮鎼滅储 ==== $('.head .search a').on('click', function(e){ e.stopPropagation(); // 缃┖杈撳叆妗嗗唴瀹 $('.head .search input').val(''); $(this).attr('href','JavaScript:;'); searchInp(); if(window.innerWidth >= 992){ //鍘绘帀澶氫綑鏍峰紡 $('.head .others .input').css({top: ''}); $('.head .others .input').removeClass('min'); // 鍒囨崲鎼滅储妗嗘樉绀虹姸鎬 if ($('.head .others input').css('display') == 'none') { $('.head .search input').show(); $('.head input').animate({width: 250,'padding-left': 5,'padding-right': 5,'border-width': 1,opacity: 1}, 300); }else { $('.head .search input').hide(); $('.head input').animate({width: 0,'padding-left': 0,'padding-right': 0, 'border-width': 0,opacity: 0}, 300); } } }); searchInp(); function searchInp() { if(window.innerWidth >= 992){ $('.others .input').css({right: $('.others ul').width() - 10}); }else { $('.others .input').css({right: -61}); } } $('.head .search input').on('click', function(e){ e.stopPropagation(); }); // 绐楀彛鍙樺姩鏃讹紝閲嶇疆杈撳叆妗嗘樉绀虹姸鎬 //==== end 鐐瑰嚮鎼滅储 ==== //==== start 鐐瑰嚮闅愯棌瀵艰埅鍜屾悳绱㈡ ==== //==== end 鐐瑰嚮闅愯棌瀵艰埅鍜屾悳绱㈡ ==== //==== start 鏂伴椈鍒楄〃 鍗$墖涓庡垪琛ㄥ睍绀哄垏鎹 ==== var el_list = $('.switch a.switch-list'); var el_panel = $('.switch a.switch-panel'); // 鍗$墖寮 var switch_panel = function(){ el_panel.addClass('active'); el_panel.find('img').attr("src",JSLIBPATH+ "../images/icon_11_a.png"); el_list.find('img').attr("src",JSLIBPATH+ "../images/icon_12.png"); el_list.removeClass('active'); $('.news-recommend .news-item').addClass('col-sm-6 col-md-6'); $('.news-recommend .news-item .box').removeClass('col-sm-4 col-md-4'); $('.news-recommend .news-item .right').removeClass('col-xs-12 col-sm-8 col-md-8'); $('.news-recommend .news-item').css({'padding-left': 15, 'padding-right': 15, 'border-bottom': 'none'}); $('.news-recommend .news-item .box').css({ float: 'none'}) $('.news-recommend .news-item .right h2').css({'margin-top': 10, 'margin-bottom':10}) } // 鍒楄〃寮 var switch_list = function (){ el_list.addClass('active'); el_list.find('img').attr("src",JSLIBPATH+ "../images/icon_12_a.png"); el_panel.find('img').attr("src",JSLIBPATH+ "../images/icon_11.png"); el_panel.removeClass('active'); $('.news-recommend .news-item').removeClass('col-sm-6 col-md-6'); $('.news-recommend .news-item .box').addClass('col-sm-4 col-md-4'); $('.news-recommend .news-item .right').addClass('col-xs-12 col-sm-8 col-md-8'); $('.news-recommend .news-item').css({'padding-left': 0, 'padding-right': 0, 'border-bottom': '1px dashed #ddd'}); if($(document).width() > 768){ $('.news-recommend .news-item .box').css({ float: 'left'}) $('.news-recommend .news-item .right h2').css({'margin-top': 0, 'margin-bottom':0}) } } // 鐐瑰嚮鍒囨崲 el_panel.on('click', switch_panel); el_list.on('click', switch_list); // 绐楀彛鍙樺姩鏃讹紝閲嶇疆杈撳崱鐗囧垪琛ㄥ睍绀虹姸鎬 $(window).resize(function(){ if(el_list.hasClass('active')){ if($(document).width() > 768){ $('.news-recommend .news-item .box').css({ float: 'left'}) }else { $('.news-recommend .news-item .box').css({ float: 'none'}) } } }); //==== end 鏂伴椈鍒楄〃 鍗$墖涓庡垪琛ㄥ睍绀哄垏鎹 ==== //==== start 鍥炲埌椤堕儴 ==== $('.go_top').click(function() { $('html,body').animate({scrollTop:0}, 500); return false; }); var height=$(window).height(); var scrollHandler = function(evt){ var top = Math.max(document.documentElement.scrollTop, document.body.scrollTop) if (top>height){ $(".go_top").fadeIn(500); }else{ $(".go_top").fadeOut(500); } } $(document.body).on('scroll', scrollHandler); $(window).on('scroll', scrollHandler); //==== end 鍥炲埌椤堕儴 ==== //==== start 鍘绘帀娴姩 ==== $('.news-list .news-item:nth-child(odd)').css({clear: 'left'}); $('.detail-page .img-list-box:nth-child(odd)').css({clear: 'left', 'padding-left': 0}); $('.detail-page .img-list-box:nth-child(even)').css({'padding-right': 0}); //==== end 鍘绘帀娴姩 ==== //==== start 鍒楄〃椤靛姞杞芥洿澶?璇勮鏁 ==== //鍒楄〃灏忎簬10鏉¢殣钘忓姞杞芥洿澶氭寜閽 if($('.articles-item-box ul li').length < 10){ $('.articles-item-box .more').hide(); } if($('.videos-item-box .news-item').length < 10){ $('.videos-item-box .more').hide(); } if($('.images-item-box .news-item').length < 10){ $('.images-item-box .more').hide(); } //鑾峰彇璇勮鏁癷d var ids = []; $('span.total-commend').each(function(){ var id = $(this).attr('id'); if ($.isNumeric(id)) { ids.push(id); } }) if(ids.length > 0) { commentTotal(ids); } $("#mylist").bind('onRecommendLoaded',function(e,ids){ $("#mylist").removeClass('hide'); commentTotal(ids); //娌℃湁鍥剧墖澶勭悊 $('#mylist .news-item').each(function(){ if($(this).find('.box img').attr('src') == 'null' || $(this).find('.box img').attr('src') == ''){ $(this).find('.box').hide(); $(this).find('.right').removeClass('col-xs-12 col-sm-8 col-md-8'); } }); if(ids == ''){ $('.news-recommend .more-btn').text('娌℃湁鏇村鍐呭浜?); $('.news-recommend .more-btn').off('click'); } if($(".switch-panel.active").length){ $(".switch-panel.active").click() } }) //棣栭〉鎺ㄨ崘 $('.news-recommend .more-btn').on('click',function(e){ window._zcms_recommend.getNext(); }) cur_sortType = 'OrderFlag'; cur_attributes = ''; if($('.list-page').length){ cur_attributes = ''; } //loadMore(page_index_artical); //鐐瑰嚮鍔犺浇鏇村鎸夐挳锛屽姞杞?0鏉℃暟鎹 $('.more-btn').on('click',function(e){ // 鏂囩珷鍒楄〃 if($('.articles-item-box').css('display') == 'block'){ if (!isMore) { return; } if (isLock) { return; } page_index_artical ++; cur_sortType = 'OrderFlag'; cur_attributes = ''; if($('.list-page').length){ cur_attributes = ''; } loadMore(page_index_artical); } // 瑙嗛鍒楄〃 if($('.videos-item-box').css('display') == 'block'){ if (!isMore) { return; } if (isLock) { return; } page_index_video ++; cur_sortType = 'OrderFlag'; cur_attributes = ''; loadMore(page_index_video); } // 鍥剧墖鍒楄〃 if($('.images-item-box').css('display') == 'block'){ if (!isMore) { return; } if (isLock) { return; } page_index_img ++; cur_sortType = 'OrderFlag'; cur_attributes = ''; loadMore(page_index_img); } }) //==== end 鍒楄〃椤靛姞杞芥洿澶?璇勮鏁 ==== //==== start 璇︾粏椤垫崲涓€鎵 ==== window.refresh_index = 0; $('.refresh').on('click',function(){ window.refresh_index ++; cur_attributes = 'Recommend'; contentType = 'Article'; var conids = []; $('.recomment-news .con-box').each(function(){ var re_id = $(this).attr('id'); conids.push(re_id); }) refresh(contentType, cur_attributes, conids.join(','),2); }) //==== end 璇︾粏椤垫崲涓€鎵 ==== }) })(window.jQuery); $(window).scroll( function () { var isLoad = document.documentElement.scrollTop + document.documentElement.clientHeight > document.documentElement.scrollHeight - 10; if (isLoad && isMore) { console.log("鍔犺浇鏇村"); if (isLock) { return; } page_index_artical++; loadMore(page_index_artical); } } ); // 鍔犺浇鏇村 function loadMore(index){ if (undefined == articleUrl) { return; } isLock=true; $.ajax({ url : articleUrl, type : "get", async: true, success : function(result) { var json = result.list; var current_arr = []; for(var k in json){ if(!isNaN(k)){ if ($('#li_'+ json[k].contentId).html() != undefined) { continue; } current_arr.push(json[k].ID); var html_artical = '
  • ' + ''+ json[k].title +''+ '

    '+ json[k].title +'

    '+ '
    '+ '鍙戝竷鏃堕棿锛欬span class="info-l">'+ json[k].time +''+ '
    '+ '
  • '; if($('.articles-item-box').css('display') == 'block'){ $(".articles-item-box .imglist2").append(html_artical); if($(".switch-panel.active").length){ $(".switch-panel.active").click() } } } } // 娌℃湁鏁版嵁鍙姞杞 if($('.articles-item-box').css('display') == 'block'){ if(!result.isMore){ $('.articles-item-box a.more-btn').text('娌℃湁鏇村鍐呭浜?); isMore = result.isMore; } else { articleUrl = result.appNextPageUrl + '?t=' + new Date().getTime(); $('.articles-item-box .more').show(); } } isLock=false; } }); } function chartWith(source,len,suffix){ var result = source; if(source && source.length>len){ result = source.substr(0,len); result += suffix; } return result; } function timestampFormat( date ) { var timestamp = new Date(date).getTime() / 1000; function zeroize( num ) { return (String(num).length == 1 ? '0' : '') + num; } var curTimestamp = parseInt(new Date().getTime() / 1000); //褰撳墠鏃堕棿鎴 var timestampDiff = curTimestamp - timestamp; // 鍙傛暟鏃堕棿鎴充笌褰撳墠鏃堕棿鎴崇浉宸鏁 var curDate = new Date( curTimestamp * 1000 ); // 褰撳墠鏃堕棿鏃ユ湡瀵硅薄 var tmDate = new Date( timestamp * 1000 ); // 鍙傛暟鏃堕棿鎴宠浆鎹㈡垚鐨勬棩鏈熷璞 var Y = tmDate.getFullYear(), m = tmDate.getMonth() + 1, d = tmDate.getDate(); var H = tmDate.getHours(), i = tmDate.getMinutes(), s = tmDate.getSeconds(); if ( timestampDiff < 60 ) { // 涓€鍒嗛挓浠ュ唴 return "鍒氬垰"; } else if( timestampDiff < 3600 ) { // 涓€灏忔椂鍓嶄箣鍐 return Math.floor( timestampDiff / 60 ) + "鍒嗛挓鍓?; } else if ( curDate.getFullYear() == Y && curDate.getMonth()+1 == m && curDate.getDate() == d ) { return '浠婂ぉ' + zeroize(H) + ':' + zeroize(i); } else { var newDate = new Date( (curTimestamp - 86400) * 1000 ); // 鍙傛暟涓殑鏃堕棿鎴冲姞涓€澶╄浆鎹㈡垚鐨勬棩鏈熷璞 if ( newDate.getFullYear() == Y && newDate.getMonth()+1 == m && newDate.getDate() == d ) { return '鏄ㄥぉ' + zeroize(H) + ':' + zeroize(i); //} else if ( curDate.getFullYear() == Y ) { // return zeroize(m) + '鏈? + zeroize(d) + '鏃 ' + zeroize(H) + ':' + zeroize(i); } else { return Y + '-' + zeroize(m) + '-' + zeroize(d) + ' ' + zeroize(H) + ':' + zeroize(i); } } } $("img").each(function(){let $a=$(this).attr("src");let b;if(($a.split(":").length>2)&&($a.split("//")[1][0]=='1')){b="//db.workercn.cn/media"+$a.substr(21+$a.indexOf(":"));$(this).attr({"src":b})}});