var animationEnd = 'webkitAnimationEnd mozAnimationEnd animationend', ua = navigator.userAgent.toLowerCase(), iphone = ua.indexOf('iphone') != -1, android = ua.indexOf('android') != -1, ipad = ua.indexOf('ipad') != -1, pc = (!iphone && !android && !ipad), wechat = ua.indexOf('micromessenger') !== -1, safari = (!wechat && ua.indexOf('safari') != -1 && (iphone || ipad)), MAXFONT = 10, DPR = window.devicePixelRatio, meta_scale = 1 / DPR; //$('#id_scale').after(''); if(pc){ $('html').addClass('ua-pc'); }else{ if(iphone){ $('html').addClass('ua-iphone'); }else if(ipad){ $('html').addClass('ua-ipad'); }else if(android){ $('html').addClass('ua-android'); } if(safari){ $('html').addClass('ua-safari'); }else if(wechat){ $('html').addClass('ua-wechat'); } $('html').addClass('ua-mobile'); } $(function(){ $(window).trigger('resize'); }); $(window).resize(function(){ var MYFONT = $('body').width() * 0.0052083333333333; if(MYFONT > MAXFONT) MYFONT = MAXFONT; //$('html').css({ fontSize: MYFONT }); }); function addAnimate(ele){ ele.find('[data-animate]').each(function(index, el) { var _this = $(this), cls = _this.attr('data-animate'), delay = _this.attr('data-delay') || 0; setTimeout(function(){ _this.addClass(cls + ' animated'); }, delay); }); } /*$(window).scroll(function(event) { var t = $(this).scrollTop(); $('.animatebox').each(function(index, el) { var _this = $(this), offset = _this.attr('data-offset') || 520, y = _this.offset().top - offset; if(t > y){ addAnimate(_this); } }); });*/ function audioAutoPlay(id){ var audio = document.getElementById(id), play = function(){ audio.play(); document.removeEventListener("touchstart",play, false); }; audio.play(); document.addEventListener("WeixinJSBridgeReady", function () { play(); }, false); document.addEventListener('YixinJSBridgeReady', function() { play(); }, false); document.addEventListener("touchstart",play, false); } function writeCookie(name,value,expires,path,domain){ var str=name+"="+escape(value); if(expires!=""){ var date=new Date(); date.setTime(date.getTime()+expires*24*3600*1000); str+=";expires="+date.toGMTString(); } if(path!=""){ str+=";path="+path; } if(domain!=""){ str+=";domain="+domain; } document.cookie=str; } function getCookie(name){ var strcookie = document.cookie; var arrcookie = strcookie.split("; "); for ( var i = 0; i < arrcookie.length; i++) { var arr = arrcookie[i].split("="); if (arr[0] == name){ return arr[1]; } } return ""; } function getByteLen(val) { var len = 0; for (var i = 0; i < val.length; i++) { var a = val.charAt(i); if (a.match(/[^\x00-\xff]/ig) != null) { len += 2; }else{ len += 1; } } return len; } function randomSort(a, b) { return Math.random()>.5 ? -1 : 1; } /* var arr = [1, 2, 3, 4, 5]; arr.sort(randomSort); */ function getParam() { var url = location.search; //获取url中"?"符后的字串 var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for(var i = 0; i < strs.length; i ++) { theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); } } return theRequest; }