Esempio n. 1
0
 exports.savePersistent = function(_key,id,value){
     var key = keys[_key];
     if(!key){return null};
     h5_base.isSuppLocalStorage() ?
         local_cache.pushValue(key, id, value, maxCount)
         :cookie.setCookie(key + "_" + id, value);
 }
Esempio n. 2
0
 function updateCookie(){
     var jData={};
     //{"cart":[100,2,3],"package":"on","earphone":"on"}
     var aCart=[];
     oCart.find(".jsDelete").each(function(){
         aCart.push($(this).attr("data-id"));
     });
     jData.cart=aCart;
     if(oPackageChk.prop("checked")){
         jData.package="on";
     }else{
         jData.package="off";
     }
     if(oEarphoneChk.prop("checked")){
         jData.earphone="on";
     }else{
         jData.earphone="off";
     }
     var sData=JSON2.stringify(jData);
     oInput.val(sData);
     cookies.setCookie(cookieName,sData);
     //$.cookie(cookieName,sData,{expires:7,path:'/',domain:sDomain});
 }
Esempio n. 3
0
			plus.geolocation.getCurrentPosition( function (p) {	
				var city = p.address.city;
				obj.html(city);
				cookie.setCookie('geo_ad',city,10);	
			}, function (e) {
Esempio n. 4
0
 define(function(require,exports,module){
    
    var cookie   = require("cookie");
    try{
        cookie.clearCookie("restime_start");
        cookie.setCookie("restime_start", Math.round(new Date().getTime()/1000));
    } catch(e) {
    }

    var aBtn     = document.querySelectorAll(".jsPlayer"),
        sBtn     = document.querySelectorAll(".switch"),
        bigImg   = document.querySelectorAll(".bigImg"),
        title    = document.querySelectorAll(".title"),
        smallImg = document.querySelectorAll(".smallImg"),  
        count    = 0, //自动播放计时器
        ua       = window.navigator.userAgent, //浏览器类型判断标识
        i, slidint;
    for(i=0; i<aBtn.length; i++){
        (function(index){
            var oBtn   = aBtn[index],
                tBtn   = sBtn[index],
                src    = oBtn.getAttribute("data-audioSrc"),
                oAudio = document.createElement("audio");
            oAudio.setAttribute("class", "word");
            if (oBtn.getAttribute("id")=="realword") {
                oAudio.setAttribute("id", "realaudio");
            }

            //直接获取后台给的时长---针对ios的bug
            //duration=str2Second(oTimer.innerHTML);
            //duration=100;
            oAudio.src = src;
            document.body.appendChild(oAudio);
            oBtn.onclick = function(){
                clearTimeout(slidint);
                if(oAudio.paused){
                    WXbug(oAudio);
                    pauseOther(oAudio);
                    oAudio.play();
                }else{
                    WXbug(oAudio);
                    oAudio.pause();
                }
            };
            tBtn.onclick = function(){
                clearTimeout(slidint);
                if(oAudio.paused){
                    WXbug(oAudio);
                    pauseOther(oAudio);
                    oAudio.play();
                }else{
                    WXbug(oAudio);
                    oAudio.pause();
                }
            };
            //暂停
            oAudio.addEventListener('pause',function() {
                tBtn.className = tBtn.className.replace("off","on");
            }, false);

             //播放
            oAudio.addEventListener('play',function() {
               tBtn.className = tBtn.className.replace("on","off");
            }, false);
            //播放结束
        })(i);
    }

    //自动播放定时器
    function playall(audioIndex) {
        slidint = setInterval(function() {
            if ( count == 0 && !audioIndex[count].ended) {
                audioIndex[count].play();
            }
            if (audioIndex[count].ended) {
                count++;
                audioIndex[count].play();
            }
            if (count == audioIndex.length-1) {
                count == 0;
                clearTimeout(slidint);
            }
        }, 1000);
    }
    playall(document.querySelectorAll(".word"));//定时播放启动

    /**
    * 该方法用于绑定点击事件,比一般的click事件反应速度快2倍。
    * @param {对象字面量} obj 要绑定的dom对象
    * @param {对象字面量} fun 事件触发的函数
    */

    function tap(obj,fun) {
        var start_x = 0, start_y = 0;
        obj.addEventListener('touchstart',function(e){
            start_x = e.touches[0].clientX;
            start_y = e.touches[0].clientY;
            document.addEventListener('touchend', touEnd, false);
        });
        function touEnd(e){
            var endX = e.changedTouches[0].clientX;
            var endY = e.changedTouches[0].clientY;
            if(Math.abs(endX - start_x) < 5 && Math.abs(endY - start_y) < 5) fun.call(obj,e);
            document.removeEventListener('touchend', touEnd, false);
        }
    }
    //ios微信中home键切换页面bug
    function WXbug(oAudio){
        if(isIOSClient() && isWeiXin()){
            oAudio.pause();
            oAudio.play();
        }
    }
    function pauseOther(oAudio){
        var aAudio = document.querySelectorAll("audio");
        for(var j=0; j<aAudio.length; j++){
            if(aAudio[j]!=oAudio) aAudio[j].pause();
        }
    }
    //是否是IOS端
    function isIOSClient(){
        if(!!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) return true;
        return false;
    }
    //是否是微信浏览器
    function isWeiXin(){
        if(ua.indexOf("MicroMessenger")!=-1) return true;
        return false;
    }
    //字符串转化为秒数
    function str2Second(str){
        var arr = str.match(/\d+/g);
        if(arr.length>1) return arr[0]*60+arr[1]*1;
        return arr[0]*1;
    }

    //二张图片,三张图片显示样式
    if (bigImg.length == 2) {
        for (i = 0; i < title.length; i++) {
            title[i].style.display = "none";
        }
        for (i = 0; i < bigImg.length; i++) {
            bigImg[i].className = "bigImg pwlist";

        }
    }
    if (smallImg.length == 3) {
        for (i = 0; i < smallImg.length; i++) {
            smallImg[i].className = "smallImg pwlist";
        }
    }
});