var script = function (lineInfo) { var $body = $('html,body'); var winH = $(window).height(); var winW = $(window).width(); var $win = $(window); var scrollBottom = $(window).scrollTop() + $(window).height(); var conH = $('.wrapper').height(); // var headerH = $('.myheader').height(); /* 回頁頂 -----------------------------------------------------------------*/ $('.backtop').click(function () { var $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body'); $body.animate({ scrollTop: 0 }, 600); }) const $input = $('input[name="cActivity1_SN"]'); const $marqueeSpan = $('.marquee span'); $input.on('focus', function() { $marqueeSpan.hide(); }); $input.on('blur', function() { $marqueeSpan.show(); }); /* lightbox ------------------------------------------------------------*/ var $lb = $('.lb'), $lbbox = $('.lbbox'); var lb_data, lbname; var lbOpen = function (lb_data) { var lbAni = new TimelineMax(); lbAni.to($('.lb[data-lb="' + lb_data + '"]'), .3, { css: { zIndex: 9999 } }, '-=.3') .to($('.lb[data-lb="' + lb_data + '"]'), .3, { opacity: 1, ease: Linear.easeNone }); $body.css({ 'overflow': 'hidden' // 'position': 'fixed' }) } var lbClose = function (lb_data) { var lbCloseAni = new TimelineMax(); lbCloseAni.to($('.lb'), .2, { opacity: 0, ease: Linear.easeNone }) .to($('.lb'), .2, { css: { zIndex: -1 } }); $body.css({ 'overflow': '' // 'position': '' }) } $('.libtn').click(function () { var lbname = $(this).data('lb'); lbOpen(lbname); return false; }); $('.lb .btn_x').click(lbClose); $('.lb .btnClose').click(lbClose); $('.lb .btnLINE').click(function () { liff.login({ redirectUri: location.href }); }); if (lineInfo == null && document.getElementById('aBtn')) { lbOpen('checksn'); } if (liff.isLoggedIn() && document.getElementById('endL')) { liff.logout(); } /* resize ------------------------------------------------------------*/ var _resize = function () { winW = $win.width(); winH = $win.height(); docH = $(document).height(); _scroll = $(window).scrollTop(); scrollBottom = $(window).scrollTop() + $(window).height(); // headerH = $('.myheader').height(); } // $win.scroll(scrollPage); _resize(); $win.resize(function () { // _resize(); }); var windowHeight = $(window).height(); // Resize Event $(window).resize(function () { // Check window width has actually changed and it's not just iOS triggering a resize event on scroll if ($(window).width() != windowHeight) { // Update the window width for next time windowHeight = $(window).width(); // Do stuff here _resize(); // if (pagescroll || windowHeight > 768) scrollthispage(); } }); }; $('#lBtn').click(function () { var lineInfo = { sub: "Uf95d96f57288ff3311c040b7a21" }; fillInfo(lineInfo); return false; }); function fillInfo(lineInfo) { //console.log(lineInfo); if (lineInfo.sub) { $('input[name=cLine_Uid]').val(lineInfo.sub); //$('input[name=cLine_Uid]').val("U74902ea8defecd01397f83510f1f1add"); $.post("/api/ajax_mgm.ashx", { "mode": "Y", "luId": $('input[name=cLine_Uid]').val(), "po": $('input[name=po]').val() }, function (rsp) { if (rsp.status == 1) { $('input[name=cUser_Name]').val(rsp.objectz.data.lineName); $('input[name=cUser_EMail]').val(rsp.objectz.data.userEmail); $('input[name=cUser_Phone]').val(rsp.objectz.data.userPhone); } else { if (rsp.status == -2) { alert('找不到您的會員資料,請重新輸入'); } } }, "json"); } //if(lineInfo.name){ // $('input[name=cUser_Name]').val(lineInfo.name); //} //if(lineInfo.email){ // $('input[name=cUser_EMail]').val(lineInfo.email); //} //$('input[name=cUser_Phone]').val(lineInfo.phone); } function loadScript(url, callback) { var script = document.createElement("script") script.type = "text/javascript"; if (script.readyState) { // only required for IE <9 script.onreadystatechange = function () { if (script.readyState === "loaded" || script.readyState === "complete") { script.onreadystatechange = null; callback(); } }; } else { //Others script.onload = function () { callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); } $(function () { //$('.myheader').load('include/header.html'); //$('.myfooter').load('include/footer.html'); var liff_Id = $('.liff').text(); console.log(liff_Id); var lineInfo = null; loadScript("https://static.line-scdn.net/liff/edge/versions/2.22.3/sdk.js", function () { liff.init({ liffId: liff_Id }).then(function () { // check line login if (liff.isLoggedIn()) { lineInfo = liff.getDecodedIDToken(); fillInfo(lineInfo); $('.lb .btn_x').trigger('click'); } }).catch(function (error) { console.log(error); }); }); var imagesLoaded = loading(); imagesLoaded.loadfunc(); imagesLoaded.callback = function () { script(lineInfo); }; // script(); });