var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; }; if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } } { let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opener = _____WB$wombat$assign$function_____("opener"); function hideSocialBeerRating(beerId){ $('.social_rating_'+beerId).fadeOut(); } function showSocialBeerRating(beerId){ $('.social_rating_'+beerId).fadeIn(); } function getCurrentUserIsReal(){ return $('#theCurrentUserIsReal').val(); } $(document).ready(function() { $('.facebook_share_rating').click(function(){ var thisLink = $(this); if(getCurrentUserIsReal() == 'true'){ var beerId = thisLink.attr('id').split('_')[1]; var thisRating = $("input[name=pint_"+beerId+"]:checked").val(); thisLink.attr('id',''); //disable double click probably need something more robust showBeerRatingBusy(beerId); if(beerId > 0){ $.ajax({ type: "GET", cache: false, url: "/ajax/facebookHelper.cfc?method=postRating&returnFormat=JSON", data:{beerID:beerId, rating:(thisRating == undefined)?-1:thisRating}, success: function(msg){ showBeerRating(beerId); $("#facebookPoints_"+beerId).fadeOut(); var link = $("#tasteNotesLink_"+beerId).attr('href'); if(msg==0) showThankYou('Oops!','You just recently posted this to Facebook. You cannot post again so soon.'); else showThankYou('Thanks for Sharing!','To make your posts more valuable to your friends, Pintley sends posts to Facebook periodically. If you post multiple messages in a row, you may notice a delay between posts.'); }, error: function(msg) { showBeerRating(beerId); alert('Hmmm, something went wrong. Try reloading the page and trying again.'); } }); } } else { window.location = "/login?redirect="+window.location.href; } return false; }) function repeatTastePost(beerId, tasteNoteId){ $('.facebook_share_popup').attr('data',beerId); $('.facebook_share_popup').attr('tasteNoteId',tasteNoteId); $('#facebookPopUp').dialog('open'); } function tastePost(beerId, tasteNoteId){ $.ajax({ type: "GET", cache: false, url: "/ajax/facebookHelper.cfc?method=postTasteNotes&returnFormat=JSON", data:{beerID:beerId, tasteNoteId:tasteNoteId}, success: function(msg){ showBeerRating(beerId); $("#facebookPoints_"+beerId).fadeOut(); var link = $("#tasteNotesLink_"+beerId).attr('href'); $(".facebook_share_tastenotes").fadeOut(); $("#facebookPoints_"+beerId).fadeOut(); if(msg==0) showThankYou('Oops!','You just recently posted this to Facebook. You cannot post again so soon.'); else showThankYou('Thanks for Sharing!','To make your posts more valuable to your friends, Pintley sends posts to Facebook periodically. If you post multiple messages in a row, you may notice a delay between posts.'); }, error: function(msg){ $(".facebook_share_tastenotes").fadeOut(); alert('Fail Whale.'); } }); } $('.facebook_share_tastenotes').click(function(){ if(getCurrentUserIsReal() == 'false'){ window.location = "/login?redirect="+window.location.href; } else { var ids = $(this).attr('id').split('_'); var beerId = ids[1]; var tasteNoteId = ids[2]; $.ajax({ type: "GET", cache: false, url: "/ajax/facebookHelper.cfc?method=isRepeatTastenotePost&returnFormat=JSON", data:{beerId:beerId}, success: function(isRepeat){ if(isRepeat==0) tastePost(beerId, tasteNoteId); else repeatTastePost(beerId, tasteNoteId); }, error: function(msg){ $(".facebook_share_tastenotes").fadeOut(); alert('Fail Whale.'); } }); } return false; }) $('.facebook_share_join').click(function(){ if(getCurrentUserIsReal() == 'false'){ window.location = "/login?redirect="+window.location.href; } else { var message = $("#facebookMessage").val(); $.ajax({ type: "GET", cache: false, url: "/ajax/facebookHelper.cfc?method=postMessage&returnFormat=JSON&message="+message, success: function(msg){ $('.facebook_share_join').fadeOut(); $('.facebook_autopost').fadeIn(); if(msg==0) showThankYou('Oops!','You just recently posted this to Facebook. You cannot post again so soon.'); else showThankYou('Thanks for Sharing!',"We've posted that to Facebook."); }, error: function(msg){ alert('Fail Whale.'); } }); } return false; }) $('#facebookPopUp').dialog({ autoOpen: false, width: 400, modal: true, title : 'Share on Facebook.' }); $('.facebook_share_popup').click(function(){ var thisLink = $(this); var beerId = $(this).attr('data'); var tasteNoteId = $(this).attr('tasteNoteId'); var text = $("#facebookPopupText").val(); text = text.replace(/^\s+|\s+$/g,""); if(text.length > 0){ $.ajax({ type: "GET", cache: false, url: "/ajax/facebookHelper.cfc?method=postTasteNotes&returnFormat=JSON", data:{tasteNoteId:tasteNoteId, beerID:beerId, message:text}, success: function(msg){ $('.facebook_share_tastenotes').fadeOut(); $("#facebookPoints_"+beerId).fadeOut(); if(msg==0) showThankYou('Oops!','You just recently posted this to Facebook. You cannot post again so soon.'); else showThankYou('Thanks for Sharing!','To make your posts more valuable to your friends, Pintley sends posts to Facebook periodically. If you post multiple messages in a row, you may notice a delay between posts.'); }, error: function(msg) { showBeerRating(beerId); alert('Hmmm, something went wrong. Try reloading the page and trying again.'); } }); $('#facebookPopUp').dialog('close'); } else { alert('You cannot share an empty message.'); } }) $('#tweetPopUp').dialog({ autoOpen: false, width: 400, modal: true, title : 'Tweet about it.' }); //this is for the join and invite messages from /invite $('.twitter_share').click(function(){ if(getCurrentUserIsReal() == 'true'){ var beerId = $(this).attr('id').split('_')[1]; if(beerId != undefined && beerId.length > 0) $('.twitter_share_popup').attr('data',beerId); else $('.twitter_share_popup').attr('data',0); //join or invite $('.twitter_share_popup').attr('type',$('#tweetType').val()); $('#tweetText').val($('#tweetTextValue').val()) $('#tweetPopUp').dialog('open'); } else { window.location = "/login?redirect="+window.location.href; } return false; }); //this is for the ratings share from beerActions $('.twitter_share_rating').click(function(){ if(getCurrentUserIsReal() == 'true'){ var beerId = $(this).attr('id').split('_')[1]; $('.twitter_share_popup').attr('data',beerId); $('.twitter_share_popup').attr('type','rating'); //get the appropriate starting tweet text getRatingsTweet( beerId, function(msg){ $('#tweetText').val(msg) $('#tweetPopUp').dialog('open'); }, function(msg,err){ $('#tweetPopUp').dialog('open'); } ) } else { window.location = "/login?redirect="+window.location.href; } return false; }); //this is the handler for actually clicking the button in the twitter share pop up $('.twitter_share_popup').click(function(){ var thisLink = $(this); var beerId = $(this).attr('data'); var type = $(this).attr('type'); var thisRating = $("input[name=pint_"+beerId+"]:checked").val(); var tweetText = $("#tweetText").val(); tweetText = tweetText.replace(/^\s+|\s+$/g,""); showBeerRating(beerId); var re = /\b(http:\/\/hops.to\/[a-zA-Z0-9]{6,})/ var m = re.exec(tweetText); if( m == null){ alert("You must leave the Pintley link in your tweet."); getRatingsTweet( beerId, function(txt) { $("#tweetText").val(tweetText + ' ' + txt) }, function(msg){} ); return false; } re = /(.+)\b(http:\/\/hops.to\/[a-zA-Z0-9]{6,})\b(.*)/ m = re.exec(tweetText); if( m == null){ alert("You must enter a tweet."); return false; }else{ var txt = m[1] + m[3]; var clean = txt.replace(/@[a-zA-Z0-9]+\b/,""); if(clean.length < 6){ alert("You must enter a tweet."); return false; } } //if it got here it's all good to post $.ajax({ type: "GET", cache: false, url: "/ajax/twitterHelper.cfc?method=tweet&returnFormat=JSON", data:{beerID:beerId, tweet:tweetText, type:type}, success: function(msg){ showBeerRating(beerId); var link = $("#tasteNotesLink_"+beerId).attr('href'); $("#twitterPoints_"+beerId).fadeOut(); if(msg==0) showThankYou('Oops!','You just recently tweeted this to Twitter. You cannot tweet again so soon.'); else if(link != undefined) showThankYou('Thanks for Sharing!','To make your posts more valuable to your followers, Pintley sends posts to Twitter periodically. If you post multiple messages in a row, you may notice a delay between posts.'); else{ $('.twitter_share').fadeOut(); $('.twitter_autopost').fadeIn(); showThankYou('Thanks for Sharing!','To make your posts more valuable to your followers, Pintley sends posts to Twitter periodically. If you post multiple messages in a row, you may notice a delay between posts.'); } }, error: function(msg) { showBeerRating(beerId); alert('Hmmm, something went wrong. Try reloading the page and trying again.'); } }); $('#tweetPopUp').dialog('close'); }) function showThankYou(title,msg){ if(msg != undefined) $('#thankYouPopUpContent').html(msg); $('#thankYouPopUp').dialog({ autoOpen: false, width: 400, modal: true, title : title }); $('#thankYouPopUp').dialog('open'); } function getRatingsTweet(beerId,successHandler,faultHandler){ $.ajax({ type: "GET", cache: false, url: "/ajax/twitterHelper.cfc?method=getRatingTweet&returnFormat=plain", data:{beerID:beerId}, success: successHandler, error: faultHandler }); } }) }