var link = [];

var initEvent = function() {
    var l = link.length;
    var a = 0;

    var COUNT_START = 1 * 5 * 10; // tenths * seconds * hours
    var count = COUNT_START;
    var playing = false;

    playpause = document.getElementById('playpause');
    reset = document.getElementById('reset');
    playpause.onclick = playbtn;
    reset.onclick = reseting;

    function playbtn() {
        if (playing) {
            playing = false;
            playpause.innerHTML = "▶";
        } else if (!playing) {
            playing = true;
            console.log("Play!");
            playpause.innerHTML = "‖";
        }
    }
    function reseting() {
        playing = false;
        playpause.innerHTML = "▶";
        console.log("Reset Timer!");
        count = COUNT_START;
        clearTimeout(tt);
        countdown();
    }

    function countdown() {
        avs = a < l - 1 && a >=0 ? true : false;
        displayTime();
        if (count == 0) {
            playing = false;
            // console.log(avs);
            if (avs) {
                var j = confirm('時間到，下一組！');
                reseting();
            } else {
                alert('這是最後一組了！謝謝觀賞');
            }
            console.log('第' + (a + 1) + "組");
            if (j) {
                $('iframe').attr('src', link[++a]);
                setTimeout(playbtn, 2000);
            }
        } else if (playing) {
            // clearTimeout(tt);
            tt = setTimeout(countdown, 100);
            count--
        } else {
            // clearTimeout(tt);
            tt = setTimeout(countdown, 100);
        }
    }


    function displayTime() {
        var tenths = count;
        var sec = Math.floor(tenths / 10); // 300
        var hours = Math.floor(sec / 3600); //  1 / 12
        var mins = Math.floor(sec / 60); // 5
        sec = sec - mins * (60);
        // console.log('0');
        if (hours < 1) {
            document.getElementById('time_left').innerHTML = LeadingZero(mins) + ':' + LeadingZero(sec);
        } else {
            document.getElementById('time_left').innerHTML = hours + ':' + LeadingZero(mins) + ':' + LeadingZero(sec);
        }
    }

    function LeadingZero(Time) {
        return (Time < 10) ? "0" + Time : +Time;
    }

    // 頁面跳轉

    $('#next').on('click', function() {
        console.log(avs);
        if (avs) {
            $('iframe').attr('src', link[++a]);
            console.log('第' + (a + 1) + "組");
        } else {
            return false ;
        }
    });

    $('#pre').on('click', function() {
        if (a> 0){
            $('iframe').attr('src', link[--a]);
            console.log('第' + (a + 1) + "組");
        } else {
            return false ;
        }
    });

    $('#jump').on('click', function() {
        var jump = prompt("輸入要跳轉的組別");
        a = +jump;
        if(a < l){
            $('iframe').attr('src', link[a]);
            console.log('第' + (a + 1) + "組");
        }else{
            alert("沒這麼多組別，跳至最後一組");
            a = l-1 ;
            $('iframe').attr('src', link[a]);
        }
    });

    countdown();
}

var initData = function() {
    var options = {
        api: 'https://script.google.com/macros/s/AKfycbzTfdt_q9aNqvWp7LW9JKy6sZeL9fK-KjDcsuaFdmoLlzYsu0-R/exec',
        // api: 'https://script.google.com/a/macros/csie.ntu.edu.tw/s/AKfycbx2VJc30mJ_EeQ2zN_8W0EYBoHf5yhyeuflgzx_bl6H/dev',
        sheet: 'team_list'
    };

    // 查詢資料
    queryData(options, function(response) {

        if (response.result) {
            for(var i = 0; i < response.data.length; i++) {
                // link.push(response.data[i].project_url);
                link.push(response.data[i].slide_url);
            }

            $('#data-frame').attr('src', response.data[0].slide_url);

            // 找出 team id 為 1 的資料
            var team = $.grep(response.data, function(item) {
                return item.team_id == 1;
            });
            $('#output').text(JSON.stringify(team, null, 4));

            initEvent();
        } else {
            $('#output').text(JSON.stringify(response, null, 4));
        }
    });
}

@@ -3099,32 +3099,40 @@
 Data = function(
+callback
 ) %7B%0A    var opti
@@ -3412,16 +3412,40 @@
     %7D;%0A%0A
+    // console.log(1);%0A%0A
     // %E6%9F%A5
@@ -3540,55 +3540,32 @@
     
-for(var i = 0; i %3C response.data.length; i++) %7B
+callback(response.data);
 %0A   
@@ -3573,68 +3573,110 @@
     
-  
+%7D%0A
     
-  // link.push(response.data%5Bi%5D.project_url);%0A        
+%7D);%0A%7D%0A%0AinitData(function(data) %7B%0A    var link = %5B%5D;%0A%0A    for(var i = 0; i %3C data.length; i++) %7B%0A
     
@@ -3689,25 +3689,16 @@
 nk.push(
-response.
 data%5Bi%5D.
@@ -3717,27 +3717,11 @@
     
-        %7D%0A%0A        
+%7D%0A%0A
     
@@ -3749,25 +3749,16 @@
 ('src', 
-response.
 data%5B0%5D.
@@ -3778,345 +3778,21 @@
     
-        // %E6%89%BE%E5%87%BA team id %E7%82%BA 1 %E7%9A%84%E8%B3%87%E6%96%99%0A            var team = $.grep(response.data, function(item) %7B%0A                return item.team_id == 1;%0A            %7D);%0A            $('#output').text(JSON.stringify(team, null, 4));%0A%0A            initEvent();%0A        %7D else %7B%0A            $('#output').text(JSON.stringify(response, null, 4));%0A        %7D%0A    %7D);%0A%7D
+initEvent();%0A%7D);
 %0A

更新 presentation.js