//for touch event
document.addEventListener('touchmove', function (event) {
    event.preventDefault();
}, false);

//audio play automatically
function audioAutoPlay(id){
    var audio = document.getElementById(id);
    audio.play();
    //for ios    
    var play = function(){  
        var audio = document.getElementById(id);
        audio.play();  
        document.removeEventListener("touchstart",play, false);  
    };    
    document.addEventListener("WeixinJSBridgeReady", function () {  
        play();  
    }, false);  
    document.addEventListener('YixinJSBridgeReady', function() {  
        play();  
    }, false);  
    document.addEventListener("touchstart",play, false);  
}  

document.addEventListener('DOMContentLoaded', function () {
   audioAutoPlay('Jaudio');
});

//生成随机整数函数
function rnd(start, end){
    return Math.floor(Math.random() * (end - start) + start);
}
//文字进入特效数组
var inClassArray = ['enter-up-bounce','dance','pulse-slow', 'journal', 'jamp'];
var temLength = inClassArray.length;


//logic for page switch
var curpage=1;
var totalpage,nextpage,lastpage,nexttotalpage;

function switchPage() {
    //获取总页数,以及总页数的+1后的序号，供后面for循环使用
    totalpage = $(".page").length;
    nexttotalpage = totalpage+1;
    //如果是最后一页，显示第一页，并移除所有page上的所有css效果类，否则显示下一页，并移除上一页的切换动画效果
    if(curpage == totalpage){
        for(var i=1; i<nexttotalpage;i++){
            $(".page"+i).removeClass("hide");
            $(".page"+i).removeClass("show");
            $(".page"+i).removeClass("flip-bottom");
        }
        $(".page1").addClass("show");
        $(".page1").addClass("flip-bottom");
        curpage =1;
    }else{
        nextpage = curpage+1;
        lastpage = curpage-1;
        $(".page"+curpage).removeClass("flip-bottom");
        $(".page"+curpage).addClass("flip-top");
        $(".page"+curpage).removeClass("show");
        $(".page"+curpage).addClass("hide");
        $(".page"+nextpage).removeClass("hide");
        $(".page"+nextpage).addClass("show");
        $(".page"+nextpage).addClass("flip-bottom");
        //为文字添加随机特效
        var randomNum = rnd(0,temLength);
        setTimeout(function(){
            $(".textbox"+nextpage).css('display','block');
            $(".textbox"+nextpage).addClass(inClassArray[curpage-1]);
        },500);
        $(".page"+lastpage).removeClass("flip-top");
        curpage = nextpage;
    }
}

$(document).swipeUp(function(){
    switchPage();
});
@@ -1598,32 +1598,278 @@
 %22flip-bottom%22);%0A
+        //%E4%B8%BA%E6%96%87%E5%AD%97%E6%B7%BB%E5%8A%A0%E9%9A%8F%E6%9C%BA%E7%89%B9%E6%95%88%0A        clearTextAnimation();%0A        var randomNum = rnd(0,temLength);%0A        setTimeout(function()%7B%0A            $(%22.textbox%22+1).css('display','block');%0A            $(%22.textbox%22+1).addClass(inClassArray%5B0%5D);%0A        %7D,500);%0A
         curpage 
@@ -1872,16 +1872,16 @@
 age =1;%0A
-
     %7Dels
@@ -2300,32 +2300,62 @@
     //%E4%B8%BA%E6%96%87%E5%AD%97%E6%B7%BB%E5%8A%A0%E9%9A%8F%E6%9C%BA%E7%89%B9%E6%95%88%0A
+        clearTextAnimation();%0A
         var rand
@@ -2637,16 +2637,16 @@
 xtpage;%0A
-
     %7D%0A%7D%0A
@@ -2646,16 +2646,195 @@
    %7D%0A%7D%0A%0A
+function clearTextAnimation() %7B%0A    $('.page%3Ediv').each(function (i) %7B%0A        $(this).css(%7B 'visibility': 'hidden' %7D);%0A        $(this).attr('class', 'textbox'+(i+1));%0A    %7D);%0A%7D%0A%0A
 $(docume

fix text animation for swipe multi times.