PageSourceSearch

http://kiss.com.tw/data/roger-script.js

js kiss.com.tw collected 2026-10-02 19:09:41 UTC 4,607 bytes, 144 lines download raw bytes

1//youtube 影片控制function說明
2//source code : http://demo.tutorialzine.com/2015/08/how-to-control-youtubes-video-player-with-javascript/
3
4var player;
5// 影片寬度
6//var player_width = 800;
7var player_width = 560;
8// 影片高度
9//var player_height = 500;
10var player_height = 315;
11// 影片音量,0為靜音
12var player_volume = 40;
13// 指定U2播放清單
14var u2_playlist = "PL41EFB8517C6F8E24";
15//廣告視窗跳出,閒置秒數(微秒)
16var ad_show_time = 180 * 1000;
17//紀錄目前影片播放的狀態
18var video_status = "stop";
19
20function onYouTubeIframeAPIReady() {
21  // console.log(Cookies.getJSON('KissU2DayPlayOnce'));
22  //使用者第一次連線進來,檢查cookie有沒有之前的紀錄
23  if (Cookies.getJSON('KissU2DayPlayOnce') !== "isplay") {
24    //顯示上方影片區塊
25    $('#top_video').css('display', 'block');
26    //紀錄使用者已經播放過影片
27    // 這裡的 expires 參數的單位是天,上面這樣的設定就是一個可以使用 7 天的 cookie。
28    // 若沒有指定 expires,則預設會建立 session cookie(session 結束就刪除的 cookie)。
29    // Cookies.set('name', 'value', { expires: 7 });
30    Cookies.set('KissU2DayPlayOnce', 'isplay', { expires: 1 });
31
32    player = new YT.Player('top_U2', {
33      width: player_width,
34      height: player_height,
35      // 預設播放清單中的影片,若不設定就是依照清單中設定,排序的第一個
36      // videoId: 'fs0XN4K6l78',
37      playerVars: {
38        list: u2_playlist,
39        // color: 'white',
40        //autoplay自動播放
41        autoplay: 0,
42        //showinfo影片上方資訊
43        showinfo: 1,
44        //controls顯示影片控制項目
45        controls: 1,
46      },
47      events: {
48        onReady:        initialize,
49        onStateChange:  onPlayerStateChange,
50      }
51    });
52  } else {
53    hide_u2play_block();
54  }
55}
56//影片初始值設定
57function initialize(){
58    player.setVolume(player_volume);
59}
60//影片播放狀態偵測
61function onPlayerStateChange(event) {
62  //console.log(event);
63  // 影片狀態是停止狀態時,不繼續播放影片,隱藏影片區塊
64  if (event.data == 0) {
65    video_status = "stop";
66    player.stopVideo();
67    hide_u2play_block();
68  //影片暫停的狀態
69  } else if (event.data == 2) {
70    video_status = "pause";
71  //影片播放的狀態
72  } else if (event.data == 1) {
73    video_status = "play";
74    $('#idle_ad').css('display', 'none');
75  }
76}
77//隱藏最上方影片區塊
78function hide_u2play_block() {
79  $('#top_video').css('display', 'none');
80  $('#stop').click();
81}
82
83//======================手動U2影片控制區塊=============================
84// 播放影片
85$('#play').on('click', function () {
86    player.playVideo();
87});
88// 暫停影片
89$('#pause').on('click', function () {
90    player.pauseVideo();
91    hide_u2play_block();
92});
93// 停止影片
94$('#stop').on('click', function () {
95    player.stopVideo();
96});
97//======================手動U2影片控制區塊=============================
98
99function getUrlParameter(sParam) {
100    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
101        sURLVariables = sPageURL.split('&'),
102        sParameterName,
103        i;
104
105    for (i = 0; i < sURLVariables.length; i++) {
106        sParameterName = sURLVariables[i].split('=');
107
108        if (sParameterName[0] === sParam) {
109            return sParameterName[1] === undefined ? true : sParameterName[1];
110        }
111    }
112};
113
114//======================首頁閒置廣告=============================
115
116var ad_url = 'https://www.kiss.com.tw/templates/idle/ad-300x250-idle.htm'; //h
117var ad_url1 = 'https://www.kiss.com.tw/templates/idle/ad-300x250-1idle.htm';
118var ad_url2 = 'https://www.kiss.com.tw/templates/idle/ad-650x60-idle.htm';
119
120(function ($) {
121    $(document).on("idle.idleTimer", function () {
122      //影片播放的時候不會有閒置廣告跳出
123      if (video_status != "play") {
124        $('#idle_ad').css('display', 'block');
125
126  	    $('.ad_blcok1').attr('src', ad_url);
127        $('.ad_blcok2').attr('src', ad_url1);
128        $('.ad_blcok3').attr('src', ad_url2);
129      }
130    });
131
132    //使用者開始動作時的動作
133    $(document).on("active.idleTimer", function () {
134      // $('#ad').css('display', 'none');
135    });
136
137    $.idleTimer(ad_show_time);
138
139})(jQuery);
140
141$('#ad_close').on('click', function () {
142    $('#idle_ad').css('display', 'none');
143});
144//======================首頁閒置廣告=============================

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.