(function($){ var $window = $(window); var windowHeight = $window.height(); $window.resize(function(){ windowHeight = $window.height(); }); $.fn.parallax = function(xpos, speedFactor, outerHeight){ var $this = $(this); var getHeight; var firstTop; var paddingTop = 0; $this.each(function(){ firstTop = $this.offset().top; }); if(outerHeight){ getHeight = function(jqo){ return jqo.outerHeight(true); }; }else{ getHeight = function(jqo){ return jqo.height(); }; } if(arguments.length < 1 || xpos === null) xpos = "50%"; if(arguments.length < 2 || speedFactor === null) speedFactor = 0.1; if (arguments.length < 3 || outerHeight === null) outerHeight = true; function update(){ var pos = $window.scrollTop(); $this.each(function(){ var $element = $(this); var top = $element.offset().top; var height = getHeight($element); if(top + height < pos || top > pos + windowHeight){ return; } $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px"); }); } $window.bind('scroll', update).resize(update); update(); }; })(jQuery); (function (factory){ if (typeof define === 'function' && define.amd){ define(['jquery'], factory); }else{ factory(jQuery); }}(function($){ var pluses = /\+/g; function encode(s){ return config.raw ? s : encodeURIComponent(s); } function decode(s){ return config.raw ? s:decodeURIComponent(s); } function stringifyCookieValue(value){ return encode(config.json ? JSON.stringify(value) : String(value)); } function parseCookieValue(s){ if (s.indexOf('"') === 0){ s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); } try{ s = decodeURIComponent(s.replace(pluses, ' ')); }catch(e){ return; } try{ return config.json ? JSON.parse(s):s; }catch(e){} } function read(s, converter){ var value = config.raw ? s:parseCookieValue(s); return $.isFunction(converter) ? converter(value):value; } var config = $.cookie = function (key, value, options){ if (value !== undefined && !$.isFunction(value)){ options = $.extend({}, config.defaults, options); if(typeof options.expires === 'number'){ var days = options.expires, t = options.expires = new Date(); t.setDate(t.getDate() + days); } return (document.cookie = [ encode(key), '=', stringifyCookieValue(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : '' ].join('')); } var result = key ? undefined:{}; var cookies = document.cookie ? document.cookie.split('; '):[]; for (var i = 0, l = cookies.length; i < l; i++){ var parts = cookies[i].split('='); var name = decode(parts.shift()); var cookie = parts.join('='); if (key && key === name){ result = read(cookie, value); break; } if (!key && (cookie = read(cookie))!==undefined){ result[name] = cookie; } } return result; }; config.defaults = {}; $.removeCookie = function (key, options){ if($.cookie(key) !== undefined){ $.cookie(key, '', $.extend({}, options, { expires: -1 })); return true; } return false; }; })); var at_time = new Date(); window.fbAsyncInit = function(){ FB.init({appId:'829212790553809', status: true, cookie: true, oauth: true, xfbml: true, frictionlessRequests: true}); $(window).trigger('fbAsyncInit'); }; (function(d, debug){ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/zh_TW/all" + (debug ? "/debug" : "") + ".js"; ref.parentNode.insertBefore(js, ref); }(document, /*debug*/ false)); function fb_login(){ FB.login(function(response){ if(response.authResponse){ at_time.setTime(at_time.getTime() + (1 * 60 * 60 * 1000)); $.cookie('fb_uid', response.authResponse.userID, { expires:at_time }); $.cookie('fb_accesstoken', response.authResponse.accessToken, { expires:at_time }); FB.api('/me?fields=id,email,name,gender,birthday', function(response1){ $.post('sql.php', {action:'facebook_registration', 'fb_uid':$.cookie('fb_uid'), 'fb_accesstoken':$.cookie('fb_accesstoken'), 'name':response1.name, 'email':response1.email, 'sex':response1.gender, 'birthday':response1.birthday}, function(data){ location='VRChannels?pn=&pt='; }); }); }else{ console.info(2); } },{scope: 'user_likes,user_photos,publish_actions,email,user_birthday'}); } function share($url){ FB.getLoginStatus(function(response){ if(response.status==='connected'){ var pic, url, title, body; pic = 'http://www.live319.el8.tw/'+$('#img img:first').attr('src'); title = $('meta#fb_title').attr('content'); body = $('meta#fb_desc').attr('content'); FB.ui({method:'feed', name:'', link:'http://www.live319.el8.tw/'+$url, picture:pic, caption:title, description:body }, function(response1){ if(response1.post_id){ $.post('sql.php', {action:'share_product', fb_uid:$.cookie('fb_uid'), nid:$('#pid').val(), 'sid':response1.post_id}, function(data){ if(data.trim()=='OK'){ $.post('sql.php', {action:'check_share', nid:$('#pid').val()}, function(data){ if(data.trim()=='OK'){ $('#no_share').hide(); $('#on_share').show(10); alert('分享成功!'); }else{ $('#on_share').hide(); $('#no_share').show(); alert('分享失敗!'); } }); } }); } }); }else{ fb_login(); } }); } var $pano = null; function loadPlayer(id){ embedpano({swf:"/pano/pano.swf", xml:'/pano'+id+'.xml', target:"pano", html5:"auto", mobilescale:1.0, passQueryParameters:true}); } function qs(name){ var AllVars = window.location.search.substring(1); var Vars = AllVars.split("&"); for(i = 0; i < Vars.length; i++){ var Var = Vars[i].split("="); if (Var[0] == name) return Var[1]; } return ''; } function reset_ck(obj){ $('#'+obj).attr('src','kcaptcha/?ckn='+obj+'&rnd='+Math.random()); } var $index_ad01; function ini(){ $.ajaxSetup({ cache: false }); $('.img_hover').hover(function(){$(this).attr('src',$(this).attr('src').replace('out','over'));}, function(){$(this).attr('src',$(this).attr('src').replace('over','out'));}); $('.date').css({'width':'100px'}).datepicker(); $('.birthday').css({'width':'100px'}).datepicker({changeYear: true, yearRange:"-100:-16",defaultDate:(new Date(new Date().getFullYear()-30+"/01/01")-new Date())/(1000 * 60 * 60 * 24)}); $('form').each(function(){ $(this).attr('data-ajax','false'); if($(this).attr('method')=='post' && $(this).attr('class')!='nosql') $(this).attr('action','sql').attr('target','sql'); }); $('iframe, form').each(function(){ $(this).attr('data-ajax','false'); }); reset_ck('cknCode'); $('.twzipcode').twzipcode(); $('.twzipcode select').attr('data-inline','true'); $('.cycle-slideshow').cycle(); $index_ad01.rondell({radius:{x:400}, center:{left:500, top:175}, scaling:1, itemProperties:{size:{width:700, height:350}}, preset: "carousel"}); } var $i, $id; $(function(){ $('body').prepend(''); $index_ad01 = $('#index_ad01'); }); $(document).on("pageinit", function(){ }); $(document).on('pagebeforeshow', function(event, data){ }); $(document).on("pagecontainerload",function(event,data){ }); $(document).on("pagecontainerloadfailed",function(event,data){ alert("Sorry, the page has been failed to load!!!"); }); $(document).on('pageshow',function(){ $i = $.mobile.activePage.find("#i").text(); $id = $.mobile.activePage.find("#id").text(); $pano = $.mobile.activePage.find("#pano"); $index_ad01 = $.mobile.activePage.find("#index_ad01"); ini(); $('.twzipcode select').selectmenu(); var wow = new WOW(); wow.init(); if($pano.size()>0 && parseInt($id)>0){ loadPlayer($i+'_'+$id); } // if($.mobile.activePage.find("#fbShareBox").size()>0) FB.XFBML.parse(); });