转Y身
普通女子,胸无大志,只愿昨日可忆,未来可期,有山水可游,有奇事可闻,有朋友可交,有家人可依,文字之乐不改,童稚之心不灭,已是完满一生。
function judgeAndroidDevice(){
        var flag = true; // true
        var browser = {
            versions : function (){
                var u = navigator.userAgent, app = navigator.appVersion;
                return { 
                    ios : !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), 
                    android : u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, 
                    iPhone : u.indexOf('iPhone') > -1,
                    iPad : u.indexOf('iPad') > -1, 
                };
            }(),
        }
        if (browser.versions.iPhone || browser.versions.iPad || browser.versions.ios) {
            flag = false;
        }
        if (browser.versions.android) {
            flag = true;
        }

        return flag;
    }
    
    
    计算时间差函数:
    
     function renderTimeDiff(beginDate, endDate) { 
                             var date1 = new Date(beginDate.replace(/-/g,"/"));  //开始时间
                             var date2 = new Date(endDate.replace(/-/g,"/"));    //结束时间
                             var date3 = date2.getTime() - date1.getTime();  //时间差的毫秒数
                              
                             //计算出小时数
                             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));
                             return hours + "小时" + minutes + "分钟";
                         }
格式化参数:
formatDate : function (date){
                var mydate = new Date(date.replace(/-/g,"/")), week = [ "周日", "周一", "周二", "周三", "周四", "周五", "周六" ], mon = mydate.getMonth() + 1;
                return {
                    day : mon + "月" + mydate.getDate() + "日",
                    weekday : week[mydate.getDay()]
                };
            }
iScrollClick: function(){    
                    if (/iPhone|iPad|iPod|Macintosh/i.test(navigator.userAgent)) {return false;    }
                    if (/Chrome/i.test(navigator.userAgent)) { return (/Android/i.test(navigator.userAgent));}
                    if (/Silk/i.test(navigator.userAgent)) {return false;}
                    if (/Android/i.test(navigator.userAgent)) {       
                        var s=navigator.userAgent.substr(navigator.userAgent.indexOf('Android')+8,3);
                        return parseFloat(s[0]+s[3]) < 44 ? false : true;    
                    }
             }
             
             FastClick.attach(document.body);

 

posted on 2016-08-24 17:48  转Y身  阅读(237)  评论(0编辑  收藏  举报