|
@@ -0,0 +1,417 @@
|
|
|
+var priceshow = false;
|
|
|
+var timeshow = false;
|
|
|
+function priceTime(){
|
|
|
+ $(".pricefat").mouseover(function(){
|
|
|
+ if(!$(".pricefat").hasClass("active")){
|
|
|
+ $("#minprice").css({"border-color":"#2cb7ca"});
|
|
|
+ $("#maxprice").css({"border-color":"#2cb7ca"});
|
|
|
+ $(".pricebut").show();
|
|
|
+ $(".pricefat").addClass("customtime-active");
|
|
|
+ }
|
|
|
+ }).mouseout(function(){
|
|
|
+ if(!$(".pricefat").hasClass("active")){
|
|
|
+ if(!priceshow){
|
|
|
+ $("#minprice").css({"border-color":""});
|
|
|
+ $("#maxprice").css({"border-color":""});
|
|
|
+ $(".pricebut").hide();
|
|
|
+ $(".pricefat").removeClass("customtime-active");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ $("#minprice,#maxprice").blur(function(){
|
|
|
+ if(!priceshow&&!$(".pricefat").hasClass("active")){
|
|
|
+ $("#minprice").css({"border-color":""});
|
|
|
+ $("#maxprice").css({"border-color":""});
|
|
|
+ $(".pricebut").hide();
|
|
|
+ $(".pricefat").removeClass("customtime-active");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ $("#minprice").click(function(){
|
|
|
+ priceshow=true;
|
|
|
+ $(".pricebut").show();
|
|
|
+ $(".pricefat").addClass("customtime-active");
|
|
|
+ })
|
|
|
+ $("#maxprice").click(function(){
|
|
|
+ priceshow=true;
|
|
|
+ $(".pricebut").show();
|
|
|
+ $(".pricefat").addClass("customtime-active");
|
|
|
+ })
|
|
|
+ //
|
|
|
+ $(".timerInput").mouseover(function(){
|
|
|
+ if(!$(".timerInput").hasClass("active")){
|
|
|
+ $("#starttime").css({"border-color":"#2cb7ca"});
|
|
|
+ $("#endtime").css({"border-color":"#2cb7ca"});
|
|
|
+ $("#timebut").show();
|
|
|
+ $(".timerInput").addClass("customtime-active");
|
|
|
+ }
|
|
|
+ }).mouseout(function(){
|
|
|
+ if(!$(".timerInput").hasClass("active")){
|
|
|
+ if(!timeshow){
|
|
|
+ $("#starttime").css({"border-color":""});
|
|
|
+ $("#endtime").css({"border-color":""});
|
|
|
+ $("#timebut").hide();
|
|
|
+ $(".timerInput").removeClass("customtime-active");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ //
|
|
|
+ $("#starttime").click(function(){
|
|
|
+ timeshow = true;
|
|
|
+ $("#timebut").show();
|
|
|
+ $(".timerInput").addClass("customtime-active");
|
|
|
+ })
|
|
|
+ $("#endtime").click(function(){
|
|
|
+ timeshow = true;
|
|
|
+ $("#timebut").show();
|
|
|
+ $(".timerInput").addClass("customtime-active");
|
|
|
+ })
|
|
|
+}
|
|
|
+//
|
|
|
+var EasyAlert = {
|
|
|
+ timeout: null,
|
|
|
+ waitTime: 1000,
|
|
|
+ show: function(text,css,waitTime){
|
|
|
+ if(this.timeout != null){
|
|
|
+ clearTimeout(this.timeout);
|
|
|
+ this.hide();
|
|
|
+ this.timeout = null;
|
|
|
+ }
|
|
|
+ var thisClass = this;
|
|
|
+ this.timeout = setTimeout(function(){
|
|
|
+ thisClass.hide();
|
|
|
+ thisClass.timeout = null;
|
|
|
+ },waitTime?waitTime:this.waitTime);
|
|
|
+ $("body").append('<div class="easyalert" id="easyAlert">'+text+'</div>');
|
|
|
+ if(typeof(css) != "undefined"&&css!=""){
|
|
|
+ $("#easyAlert").css(css);
|
|
|
+ }
|
|
|
+ $("#easyAlert").css({"left":"50%","margin-top":-($("#easyAlert").outerHeight()/2),"margin-left":-($("#easyAlert").outerWidth()/2)}).show();
|
|
|
+ },
|
|
|
+ hide: function(){
|
|
|
+ $("#easyAlert").remove();
|
|
|
+ }
|
|
|
+}
|
|
|
+var EasyPopup = function(id){
|
|
|
+ this.id = id;
|
|
|
+ var thisClass = this;
|
|
|
+ document.getElementById(id).ontap = function(e){
|
|
|
+ if(e.target.id == id){
|
|
|
+ thisClass.hide();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.show = function(){
|
|
|
+ $("#"+this.id).fadeIn();
|
|
|
+ var mainObj = $("#"+id+">div:first");
|
|
|
+ mainObj.css({"margin-top":-(mainObj.outerHeight()/2 + 35)});
|
|
|
+ },
|
|
|
+ this.hide = function(){
|
|
|
+ $("#"+this.id).fadeOut();
|
|
|
+ }
|
|
|
+}
|
|
|
+//计算时差
|
|
|
+function timeDiff(date){
|
|
|
+ var date1 = date;//开始时间
|
|
|
+ var date2 = new Date();//结束时间
|
|
|
+ var date3 = date2.getTime()-date1.getTime();//时间差的毫秒数
|
|
|
+ //计算出相差天数
|
|
|
+ var days = Math.floor(date3/(24*3600*1000));
|
|
|
+ //计算出小时数
|
|
|
+ var leave1 = date3%(24*3600*1000);//计算天数后剩余的毫秒数
|
|
|
+ var hours = Math.floor(leave1/(3600*1000));
|
|
|
+ //计算相差分钟数
|
|
|
+ var leave2 = leave1%(3600*1000);//计算小时数后剩余的毫秒数
|
|
|
+ var minutes = Math.floor(leave2/(60*1000));
|
|
|
+ //计算相差秒数
|
|
|
+ var td = "30秒前";
|
|
|
+ if(days > 0){
|
|
|
+ if (days > 10) {
|
|
|
+ var date1year = date1.getFullYear();
|
|
|
+ var date2year = date2.getFullYear();
|
|
|
+ var date1month = date1.getMonth()+1;
|
|
|
+ var date1day = date1.getDate();
|
|
|
+ if(date1month < 10){
|
|
|
+ date1month ="0"+date1month;
|
|
|
+ }
|
|
|
+ if(date1day < 10){
|
|
|
+ date1day ="0"+date1day;
|
|
|
+ }
|
|
|
+ if (date1year<date2year){
|
|
|
+ td = date1.getFullYear()+"-"+date1month+"-"+date1day;
|
|
|
+ }else{
|
|
|
+ td = date1month+"-"+date1day;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ td = days+"天前"
|
|
|
+ }
|
|
|
+ }else if(hours > 0){
|
|
|
+ td = hours+"小时前";
|
|
|
+ }else if(minutes > 0){
|
|
|
+ td = minutes+"分钟前";
|
|
|
+ }
|
|
|
+ return td;
|
|
|
+}
|
|
|
+function redirect(zbadd,link,sid,sds){
|
|
|
+ if(link != null && typeof(link) != "undefined"){
|
|
|
+ link = link.replace(/\n/g,"");
|
|
|
+ if(!/^http/.test(link)){
|
|
|
+ link="http://"+link
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(sds){
|
|
|
+ window.location.href=zbadd+"/article/content/"+sid+".html?keywords="+encodeURIComponent(sds);
|
|
|
+ }else{
|
|
|
+ window.location.href=zbadd+"/article/content/"+sid+".html";
|
|
|
+ }
|
|
|
+}
|
|
|
+function newredirect(zbadd,link,sid,sds,index){
|
|
|
+ if(link != null && typeof(link) != "undefined"){
|
|
|
+ link = link.replace(/\n/g,"");
|
|
|
+ if(!/^http/.test(link)){
|
|
|
+ link="http://"+link
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var pt = ""
|
|
|
+ if (index==1){
|
|
|
+ pt="projectMatch=项目匹配"
|
|
|
+ }
|
|
|
+ if(sds){
|
|
|
+ pt = "&"+pt
|
|
|
+ window.location.href=zbadd+"/article/content/"+sid+".html?keywords="+encodeURIComponent(sds)+pt;
|
|
|
+ }else{
|
|
|
+ window.location.href=zbadd+"/article/content/"+sid+".html"+pt;
|
|
|
+ }
|
|
|
+}
|
|
|
+function pcredirect(link,sid){
|
|
|
+ window.open("/pcdetail/"+sid+".html");
|
|
|
+}
|
|
|
+function keyWordHighlight(value,oldChars,newChar){
|
|
|
+ if(typeof(oldChars) == "undefined" || oldChars == null || typeof(newChar) == "undefined" || newChar == null || newChar == ""){
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ var array = [];
|
|
|
+ if(oldChars instanceof Array){
|
|
|
+ array = oldChars.concat();
|
|
|
+ }else{
|
|
|
+ array.push(oldChars);
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ var map = {};
|
|
|
+ for(var i=0;i<array.length;i++){
|
|
|
+ var oldChar = array[i];
|
|
|
+ if(oldChar.replace(/\s+/g,"") == "" || map[oldChar]){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ map[oldChar] = true;
|
|
|
+ oldChar = oldChar.replace(/\$/g,"\\$");
|
|
|
+ oldChar = oldChar.replace(/\(/g,"\\(");
|
|
|
+ oldChar = oldChar.replace(/\)/g,"\\)");
|
|
|
+ oldChar = oldChar.replace(/\*/g,"\\*");
|
|
|
+ oldChar = oldChar.replace(/\+/g,"\\+");
|
|
|
+ oldChar = oldChar.replace(/\./g,"\\.");
|
|
|
+ oldChar = oldChar.replace(/\[/g,"\\[");
|
|
|
+ oldChar = oldChar.replace(/\]/g,"\\]");
|
|
|
+ oldChar = oldChar.replace(/\?/g,"\\?");
|
|
|
+ oldChar = oldChar.replace(/\\/g,"\\");
|
|
|
+ oldChar = oldChar.replace(/\//g,"\\/");
|
|
|
+ oldChar = oldChar.replace(/\^/g,"\\^");
|
|
|
+ oldChar = oldChar.replace(/\{/g,"\\{");
|
|
|
+ oldChar = oldChar.replace(/\}/g,"\\}");
|
|
|
+ oldChar = oldChar.replace(/\|/g,"\\|");
|
|
|
+ value = value.replace(new RegExp("("+oldChar+")",'gmi'),newChar);
|
|
|
+ }
|
|
|
+ }catch(e){}
|
|
|
+ return value;
|
|
|
+}
|
|
|
+function getWxVersion(){
|
|
|
+ var wechatInfo = navigator.userAgent.match(/MicroMessenger\/([\d\.]+)/i);
|
|
|
+ if(!wechatInfo) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return wechatInfo[1];
|
|
|
+}
|
|
|
+/**
|
|
|
+ * 设置光标在短连接输入框中的位置
|
|
|
+ * @param inpObj 输入框
|
|
|
+ * @param pos
|
|
|
+ */
|
|
|
+function setCursorPos(inpObj, pos){
|
|
|
+ if(navigator.userAgent.indexOf("MSIE") > -1){
|
|
|
+ var range = document.selection.createRange();
|
|
|
+ var textRange = inpObj.createTextRange();
|
|
|
+ textRange.moveStart('character',pos);
|
|
|
+ textRange.collapse();
|
|
|
+ textRange.select();
|
|
|
+ }else{
|
|
|
+ inpObj.setSelectionRange(pos,pos);
|
|
|
+ }
|
|
|
+}
|
|
|
+/**
|
|
|
+ * 获取光标在短连接输入框中的位置
|
|
|
+ * @param inpObj 输入框
|
|
|
+ */
|
|
|
+function getCursorPos(inpObj){
|
|
|
+ if(navigator.userAgent.indexOf("MSIE") > -1) { // IE
|
|
|
+ var range = document.selection.createRange();
|
|
|
+ range.text = '';
|
|
|
+ range.setEndPoint('StartToStart',inpObj.createTextRange());
|
|
|
+ return range.text.length;
|
|
|
+ } else {
|
|
|
+ return inpObj.selectionStart;
|
|
|
+ }
|
|
|
+}
|
|
|
+//获取url中参数
|
|
|
+function getUrlParam(name){
|
|
|
+ var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
|
|
|
+ var r = window.location.search.substr(1).match(reg);
|
|
|
+ if(r != null)
|
|
|
+ return unescape(r[2]);
|
|
|
+ return null;
|
|
|
+}
|
|
|
+
|
|
|
+/******* 获取url参数(正则)********/
|
|
|
+function getParam(name) {
|
|
|
+ var search = document.location.search;
|
|
|
+ // alert(search);
|
|
|
+ var pattern = new RegExp("[?&]" + name + "\=([^&]+)", "g");
|
|
|
+ var matcher = pattern.exec(search);
|
|
|
+ var items = null;
|
|
|
+ if (null != matcher) {
|
|
|
+ try {
|
|
|
+ items = decodeURIComponent(decodeURIComponent(matcher[1]));
|
|
|
+ } catch (e) {
|
|
|
+ try {
|
|
|
+ items = decodeURIComponent(matcher[1]);
|
|
|
+ } catch (e) {
|
|
|
+ items = matcher[1];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return items;
|
|
|
+};
|
|
|
+//获取滚动条宽度
|
|
|
+function getScrollWidth() {
|
|
|
+ var noScroll, scroll, oDiv = document.createElement("DIV");
|
|
|
+ oDiv.style.cssText = "position:absolute; top:-1000px; width:100px; height:100px; overflow:hidden;";
|
|
|
+ noScroll = document.body.appendChild(oDiv).clientWidth;
|
|
|
+ oDiv.style.overflowY = "scroll";
|
|
|
+ scroll = oDiv.clientWidth;
|
|
|
+ document.body.removeChild(oDiv);
|
|
|
+ return noScroll-scroll;
|
|
|
+}
|
|
|
+//表头固定
|
|
|
+var TableHeadFixed = function(className,isminus,flag,pageName){
|
|
|
+ if(typeof(className) == "undefined"){
|
|
|
+ className = "tabContainer-2";
|
|
|
+ }
|
|
|
+ if(typeof(isminus) == "undefined"){
|
|
|
+ isminus = true;
|
|
|
+ }
|
|
|
+ if(typeof(flag) == "undefined"){
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ var cHeight = document.body.clientHeight;
|
|
|
+ if(cHeight <= 0){
|
|
|
+ cHeight = 500;
|
|
|
+ }
|
|
|
+ var thisFlag = false;
|
|
|
+ var prevSelectType = null;
|
|
|
+ $(window).scroll(function(event){
|
|
|
+ if(!$("#right-table").hasClass("active") && flag){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //超级搜索页面增加处理逻辑
|
|
|
+ if(pageName == "supsearch"){
|
|
|
+ if(prevSelectType != selectType){
|
|
|
+ thisFlag = false;
|
|
|
+ }
|
|
|
+ prevSelectType = selectType;
|
|
|
+ if(selectType == "all"){
|
|
|
+ className = "tabContainer"
|
|
|
+ }else{
|
|
|
+ className = "tabContainer-2";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var tableHeight = $("."+className).outerHeight();
|
|
|
+ if(tableHeight <= cHeight){
|
|
|
+ $("."+className+" .lucene-table").removeClass("tabfixed tababsolute");
|
|
|
+ $("."+className+" .lucene-table>table:first").css("top",0);
|
|
|
+ thisFlag = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var offsetTop = $("."+className).offset().top;
|
|
|
+ var scrollTop = $(this).scrollTop();
|
|
|
+ var oTop = offsetTop;
|
|
|
+ var ooTop = offsetTop;
|
|
|
+ if(isminus){
|
|
|
+ oTop+=20;
|
|
|
+ ooTop-=20;
|
|
|
+ }
|
|
|
+ if(scrollTop >= oTop){
|
|
|
+ if(ooTop + tableHeight - scrollTop -20 <= cHeight){
|
|
|
+ if(!thisFlag){
|
|
|
+ $("."+className+" .lucene-table").addClass("tababsolute");
|
|
|
+ $("."+className+" .lucene-table>table:first").css("top",scrollTop);
|
|
|
+ }
|
|
|
+ thisFlag = true;
|
|
|
+ }else{
|
|
|
+ if(thisFlag){
|
|
|
+ $("."+className+" .lucene-table").removeClass("tababsolute");
|
|
|
+ $("."+className+" .lucene-table>table:first").css("top",0);
|
|
|
+ }
|
|
|
+ thisFlag = false;
|
|
|
+ }
|
|
|
+ $("."+className+" .lucene-table").addClass("tabfixed");
|
|
|
+ }else{
|
|
|
+ $("."+className+" .lucene-table").removeClass("tabfixed tababsolute");
|
|
|
+ $("."+className+" .lucene-table>table:first").css("top",0);
|
|
|
+ thisFlag = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+//页面跳转输入框光标位置
|
|
|
+function moveEnd(obj) {
|
|
|
+ obj.focus();
|
|
|
+ var len = obj.value.length;
|
|
|
+ if (document.selection) {
|
|
|
+ var sel = obj.createTextRange();
|
|
|
+ sel.moveStart('character', len);
|
|
|
+ sel.collapse();
|
|
|
+ sel.select();
|
|
|
+ } else if (typeof obj.selectionStart == 'number'
|
|
|
+ && typeof obj.selectionEnd == 'number') {
|
|
|
+ obj.selectionStart = obj.selectionEnd = len;
|
|
|
+ }
|
|
|
+}
|
|
|
+function mySysIsIos(){
|
|
|
+ return !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
|
|
|
+}
|
|
|
+$(function(){
|
|
|
+ //自定义tap
|
|
|
+ if("ontouchend" in document){
|
|
|
+ $(document).on("touchstart", function(e) {
|
|
|
+ var $target = $(e.target);
|
|
|
+ $target.data("isMoved", 0);
|
|
|
+ $target.data("startTime", Date.now());
|
|
|
+ });
|
|
|
+ $(document).on("touchmove", function(e) {
|
|
|
+ var $target = $(e.target);
|
|
|
+ $target.data("isMoved", 1);
|
|
|
+ });
|
|
|
+ $(document).on("touchend", function(e) {
|
|
|
+ var $target = $(e.target);
|
|
|
+ var startTime = $target.data("startTime");
|
|
|
+ if(Date.now()-startTime>200){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if($target.data("isMoved") == 1){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $target.trigger("tap");
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ $(document).on("click", function(e) {
|
|
|
+ var $target = $(e.target);
|
|
|
+ $target.trigger("tap");
|
|
|
+ });
|
|
|
+ }
|
|
|
+});
|