-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.min.js
1 lines (1 loc) · 15.1 KB
/
main.min.js
1
$(document).ready(function(){function e(){$(".statsColumn.column-1").animate({left:0},700),$(".statsColumn.column-3").animate({right:0},700);var e=$.map(G,function(e){return e}),t=1500;M&&(n(e,t,".value"),M=!1)}function t(){$(".profile .picture>*").eq(0).animate({left:0},500),$(".profile .picture>*").eq(1).animate({left:0},600),$(".profile .picture>*").eq(2).animate({left:0},700);var e=_.player_stats,t=[e.total_correct,e.total_incorrect,e.games_played,e.best_score],a=1500;B&&(setTimeout(function(){$(".infoLabel").empty().addClass("infoValue").removeClass("infoLabel"),$(".customPadding").removeClass("customPadding"),n(t,a,".infoValue")},3e3),B=!1)}function n(e,t,n){$(n).each(function(n){$(this).prop("Counter",0).animate({Counter:e[n]},{duration:t,easing:"swing",step:function(e){$(this).text(Math.ceil(e))}})})}function a(e,t,n){var a="";a='<table class="gameTable" style="display:none;">\n',a+=" <thead>\n",a+=" <tr>\n",a+=" <th>\nUser</th>\n",a+=" <th>\nTweet</th>\n",a+=" </tr>\n",a+=" </thead>\n",a+=" <tbody>\n",$.each(e[t],function(e,t){tweetHTML=twemoji.parse(t.tweetInfo.tweetHTML),a+=" <tr>\n",a+=" <td>\n",a+=' <div class="userCard">\n',a+=' <div class="userImg">\n',a=a+' <a href="https://twitter.com/'+t.userInfo.handle.substring(1)+'" target="_blank"><img src="'+t.userInfo.profilePicURL+'"></a>\n',a+=" </div>\n",a+=' <div class="userInfo">\n',a=a+' <div class="userName">'+t.userInfo.name+"</div>\n",a=a+' <div class="userHandle">'+t.userInfo.handle+"</div>\n",a+=" </div>\n",a=a+' <a class="followButton" href="'+t.userInfo.followURL+'" target="_blank">\n',a+=' <span class="fa fa-twitter"></span>\n',a+=' <p class="text">Follow</p>\n',a+=" </a>\n",a+=" </div>\n",a+=" </td>\n",a+=" <td>\n",a+=' <div class="tweetCard">\n',a+=tweetHTML,a+=" </div>\n",a+=" </td>\n",a+=" </tr>\n"}),a+=" </tbody>\n",a+="</table>\n",$(n).append(a)}function o(e,t){if(A=e.find(".userInfo").find(".userHandle")[0].innerHTML.replace("@",""),E=t.parent("td").siblings("td").find(".userCard").find(".userInfo").find(".userHandle")[0].innerHTML.replace("@",""),F[A].tweetInfo.tweetID==R[E].tweetInfo.tweetID){var n=$(".timer").TimeCircles().getTime(),a=$.Event("correct-selection");a.time=n,$("table").trigger("correct-selection"),Q.toggleClass("correctSelection"),z.toggleClass("correctSelection"),U+=A,V+=E}else $("table").trigger("incorrect-selection"),Q.toggleClass("incorrectSelection"),z.toggleClass("incorrectSelection"),Q.toggleClass("shake shake-horzontal"),z.toggleClass("shake shake-horzontal");Q.toggleClass("selectedCard"),z.toggleClass("selectedCard"),Q=void 0,z=void 0,D=!1,J=!1}function s(e,t,n){var a=$.extend(!0,{},t),o=$.extend(!0,{},n);setTimeout(function(){a.toggleClass("correctSelectionAnimation"),o.toggleClass("correctSelectionAnimation")},e)}function i(e,t,n){var a=$.extend(!0,{},t),o=$.extend(!0,{},n);setTimeout(function(){a.toggleClass("incorrectSelection"),o.toggleClass("incorrectSelection"),a.toggleClass("shake shake-horzontal"),o.toggleClass("shake shake-horzontal")},e)}function r(e,t){console.log("consecutive bonus: "+50*t.num);var n=50+Math.floor(Math.pow(1.05,e)*Y)+50*t.num,a=W;return W+=n,a=W-a,W}function l(){var e="";$.ajax({url:Z,type:"POST",data:te,dataType:"json",async:!1,beforeSend:function(e,t){(t.data!=$.param(ne)||W>18e3||q)&&e.abort()},success:function(e){},error:function(e,t,n){console.log("Error Occured")}}),e+='<div class="endInfo">',e+=' <div class="finalScore">',e=e+" <p>Your Score:<span>"+W+"</span></p>",e+=" </div>",e+=' <div class="attempts">',e+=' <div class="correct">',e=e+" <p>Correct Attempts: "+Y+"</p>",e+=" </div>",e+=' <div class="incorrect">',e=e+" <p>Incorrect Attempts: "+K+"</p>",e+=" </div>",e+=" </div>",e+=' <div class="survey">',e+=' <a href="https://tweetysurvey.typeform.com/to/m1GIH1" target="_blank"><p>Please take our survey to make this game better</p></a>',e+=" </div>",e+=' <div class="buttons">',e+=' <button class="leaderboardButton">Leaderboard</button>',e+=' <button class="answersButton">Answers</button>',e+=' <button class="playAgain">Play Again</button>',e+=" </div>",e+=' <div class="leaderboard">',e+=" </div>",e+=' <div class="answerTable">',e+=" </div>",e+="</div>",$("body").append(e),c(5)}function c(e){var t;$.ajax({url:"http://tweety.midnightjabber.com/php/scoreQueries.php?query=get_top_players",type:"GET",async:!1,success:function(e){t=JSON.parse(e)}});var n="";n='<table class="leaderboardTable">\n',n+=" <thead>\n",n+=" <tr>\n",n+=" <th>\nRank</th>\n",n+=" <th>\nPlayer</th>\n",n+=" <th>\nName</th>\n",n+=" <th>\nScore</th>\n",n+=" </tr>\n",n+=" </thead>\n",n+=" <tbody>\n",$.each(t,function(e,t){var a=t.playerID==_.player_id&&t.playerName==_.fullname;n+=" <tr",a&&(n+=' class="highlightPlayerRow"'),n+=">\n",n+=" <td>\n",a&&(n+=' <span class="fa fa-trophy"></span>\n'),n=n+' <p class="rank">'+e+"</p>\n",n+=" </td>\n",n+=" <td>\n",n=n+' <img class="playerImage hasLink" src="http://'+t.profilePic+'" data-link="http://'+t.link+'">\n',n+=" </td>\n",n+=" <td>\n",n=n+' <p class="playerName hasLink" data-link="http://'+t.link+'">'+t.playerName+"</p>\n",n+=" </td>\n",n+=" <td>\n",n=n+' <p class="leaderboardScore">'+t.score+"</p>\n",n+=" </td>\n",n+=" </tr>\n"}),n+=" </tbody>\n",n+="</table>\n",$(".leaderboard").append(n)}function d(e){var t=$(".timer").TimeCircles().getTime();if(t=Math.floor(t-e),0>=t){var n=$.Event("endGame");n._all=!1,n.timeLeft=0,$("body").trigger(n)}else $(".timer").data("timer",t).TimeCircles().restart()}function p(e){$(".timer").data("timer",e).TimeCircles({total_duration:e,count_past_zero:!1,use_background:!1,animation:"ticks",time:{Days:{show:!1},Hours:{show:!1},Minutes:{show:!1},Seconds:{text:"Seconds",color:"#00B200",show:!0}}}).start().addListener(function(e,t,n){var a;if(0==n){var o=$.Event("endGame");o._all=!1,o.timeLeft=n,$("body").trigger(o)}else 30>=n?a="#E60000":75>=n&&(a="#FFFF5C");$(".timer").TimeCircles({time:{Seconds:{color:a}}})})}function u(){var e="anonymous";S&&(e=_.fullname),te.name=e,ne=te}function f(){te.timeRemaining=X,ne=te}function g(){te.score=W,ne=te}function m(){te.correct=Y,ne=te}function v(){te.incorrect=K,ne=te}function h(){if(S){var e=_.player_id;te.player_id=e,ne=te}}function b(){if(S){var e=_.social_media;te.social_media=e,ne=te}}function w(){if(S){var e=_.gender;te.gender=e,ne=te}}function y(){if(S){var e=_.link;e=e.replace(/(https?:\/\/)/i,""),console.log(e),te.profile_link=e,ne=te}}function C(){if(S){var e=_.location;console.log(e),te.location=e,ne=te}}function T(){var e=oe[Math.floor(5*Math.random())];S&&(e=_.profile_pic,e=e.replace(/(https?:\/\/)/i,"")),te.profile_pic=e,ne=te}function k(){var e="";$.ajax({url:"http://jsonip.com?callback=",type:"GET",async:!1,success:function(t){e=t.ip,te.ipAddress=e,ne=te}})}var _;$.ajax({url:"php/social-media.php?query=get_homepage_response",type:"GET",async:!1,success:function(e){_=JSON.parse(e)}});var S=_.loggedIn,I=_.fb_login_url,L=_.twitter_login_url;if(S){var x="";x+='<div class="picture">\n',x=x+' <img src="'+_.profile_pic+'" alt="">\n',x=x+' <p><span class="name">'+_.fullname+'</span>\n<span class="fa fa-sign-out signOut" data-url="'+_.logout_url+'"></span></p>\n',x=x+' <p><span class="rank">#'+_.player_stats.rank+"</span><p>\n",x+="</div>\n",x+='<div class="infoCard">\n',x+=' <table class="quadrants">\n',x+=" <tbody>\n",x+=" <tr>\n",x+=" <td>\n",x+=' <p class="quadrant customPadding firstQuadrant total_correct">\n',x+=' <span class="infoLabel">Total Correct</span>\n',x+=" </p>\n",x+=" </td>\n",x+=" <td>\n",x+=' <p class="quadrant customPadding secondQuadrant total_incorrect">\n',x+=' <span class="infoLabel">Total Incorrect</span>\n',x+=" </p>\n",x+=" </td>\n",x+=" </tr>\n",x+=" <tr>\n",x+=" <td>\n",x+=' <p class="quadrant customPadding thirdQuadrant numGames">\n',x+=' <span class="infoLabel"># Games</span>\n',x+=" </p>\n",x+=" </td>\n",x+=" <td>\n",x+=' <p class="quadrant customPadding fourthQuadrant bestScore">\n',x+=' <span class="infoLabel">Best Score</span>\n',x+=" </p>\n",x+=" </td>\n",x+=" </tr>\n",x+=" </tbody>\n",x+=" </table>\n",x+=' <div class="lastGameCard">\n',x+=" <u><h3>Last Game</h3></u>\n",x+=' <table class="lastGame">\n',x+=" <thead>\n",x+=" <tr>\n",x+=" <th>Score</th>\n",x+=" <th>Correct</th>\n",x+=" <th>Incorrect</th>\n",x+=" </tr>\n",x+=" </thead>\n",x+=" <tbody>\n",x+=" <tr>\n",x=x+' <td class="lastScore">'+_.player_stats.last_game.score+"</td>\n",x=x+' <td class="lastCorrect">'+_.player_stats.last_game.num_correct+"</td>\n",x=x+' <td class="lastIncorrect">'+_.player_stats.last_game.num_incorrect+"</td>\n",x+=" </tr>\n",x+=" </tbody>\n",x+=" </table>\n",x+=" </div>\n",x+="</div>\n",$(".loginProfile").addClass("profile"),$(".profile").removeClass("loginProfile"),$(".profile").append(x)}else{var H='<span class="initialButton loginButton fa fa fa-user"></span>';$(".initialButtons").prepend(H);var O="";O+='<div class="loginOptions">\n',O=O+' <span class="option facebook fa fa-facebook" data-url="'+I+'"></span>\n',O=O+' <span class="option twitter fa fa-twitter" data-url="'+L+'"></span>\n',O+="</div>\n",console.log(O),$(".loginProfile").append(O.toString())}$(".loginOptions .option").on("click",function(e){window.location=$(this).data("url")}),$(".signOut").on("click",function(e){window.location=$(this).data("url")}),$(".initialButton.loginButton").on("click",function(e){$.fn.fullpage.moveTo($("#pageScroll .section").index($(".profileSection"))+1)}),$(".initialButtons").delay(500).fadeIn(2e3),$(".downArrow").delay(1500).fadeIn(1e3),$("#pageScroll").fullpage({navigation:!0,scrollingSpeed:600,touchSensitivity:1,onLeave:function(n,a,o){$(this);1==n&&"down"==o&&e();var s=$(".section").index($(".profileSection"))+1;a!=s||"down"!=o&&"up"!=o||!S||t()}}),$(".flipCard").flip();var P,G=_.homepage_stats,M=!0,B=!0,j=0,N=0,q=!1;$.ajax({url:"php/gameObject.php",type:"GET",async:!1,success:function(e){P=JSON.parse(e)}}),$(".startButton").on("click",function(e){$(document).trigger("startGame"),a(P,"incorrect",".addTableHere"),$(".gameTable").fadeIn("fast"),j=$.now()}),$(document).on("startGame",function(e){$("#pageScroll").remove(),$.fn.fullpage.destroy("all"),$("table").fadeIn("slow"),p(121)});var A,E,Q,z,F=P.correct,R=P.incorrect,D=!1,J=!1,U="",V="",Y=0,K=0,W=0,X=0,Z="http://tweety.midnightjabber.com/php/scoreQueries.php?query=record_score",ee={flag:!1,num:-1,timeStamp:0};$(".linkOne").on("click",function(e){$(this).siblings(".imgOne").slideToggle("fast"),$(this).siblings(".imgTwo").hide()}),$(".linkTwo").on("click",function(){$(this).siblings(".imgTwo").slideToggle("fast"),$(this).siblings(".imgOne").hide()}),$(".addTableHere, body").on("click",".linkOne",function(e){$(this).siblings(".imgOne").slideToggle("fast"),$(this).siblings(".imgTwo").hide()}),$(".addTableHere, body").on("click",".linkTwo",function(){$(this).siblings(".imgTwo").slideToggle("fast"),$(this).siblings(".imgOne").hide()}),$("body").on("click",function(e){var t=e.target.localName;("body"==t||"td"==t)&&(void 0!=Q&&(Q.removeClass("selectedCard incorrectSelection"),Q=void 0,D=!1),void 0!=z&&(z.removeClass("selectedCard incorrectSelection"),z=void 0,J=!1))}),$(".addTableHere").on("click",".userCard",function(e){var t=e.target.className,n=e.target.localName,a=$(this),s=a.find(".userInfo").find(".userHandle")[0].innerHTML.replace("@","");U.indexOf(s)>=0||n.indexOf("img")>=0||t.indexOf("followButton")>=0||(void 0==Q?(Q=$(this),Q.toggleClass("selectedCard"),D=!0):a[0]===Q[0]?(Q.toggleClass("selectedCard"),Q=void 0,D=!1):(Q.toggleClass("selectedCard"),Q=$(this),Q.toggleClass("selectedCard"),D=!0),J&&o(Q,z))}),$(".addTableHere").on("click",".tweetCard",function(e){var t=(e.target.className,$(this)),n=t.parent("td").siblings("td").find(".userCard").find(".userInfo").find(".userHandle")[0].innerHTML.replace("@","");V.indexOf(n)>=0||(void 0==z?(z=$(this),z.toggleClass("selectedCard"),J=!0):t[0]===z[0]?(z.toggleClass("selectedCard"),z=void 0,J=!1):(z.toggleClass("selectedCard"),z=$(this),z.toggleClass("selectedCard"),J=!0),D&&o(Q,z))}),$(".addTableHere, .answerTable").on("click",".imgLink",function(e){e.stopPropagation()}),$(".addTableHere, .answerTable").on("click","td a",function(e){e.stopPropagation()}),$("body").on("incorrect-selection","table",function(e){d(10),$(".incorrectSound").trigger("play"),K+=1,i(500,Q,z),ee.flag=!1,ee.num=-1,ee.timeStamp=0}),$("body").on("correct-selection","table",function(e){if(Y+=1,ee.flag=!0,ee.num=ee.num+1,ee.timeStamp=$(".timer").TimeCircles().getTime(),$(".correctSound").trigger("play"),s(0,Q,z),10===Y){var t=$.Event("endGame");t._all=!0,t.timeLeft=$(".timer").TimeCircles().getTime(),$("body").trigger(t)}var n=$(".timer").TimeCircles().getTime();$(".score").text(r(n,ee))}),$("body").on("endGame",function(e){N=$.now(),N-j>13e4&&(q=!0),X=Math.floor(e.timeLeft),W+=Math.floor(20*e.timeLeft),$("table").remove(),$(".timer").TimeCircles().destroy(),$(".timer").remove(),$(".score").remove(),u(),f(),g(),m(),v(),h(),b(),w(),y(),C(),k(),T(),l()});var te={},ne={};$("body").on("click",".leaderboardTable .hasLink",function(e){console.log($(this)),window.open($(this).data("link"),"_blank")});var ae=0;$("body").on("click",".answersButton",function(e){0===ae&&(a(P,"correct",".answerTable"),ae=1,$(".answerTable table").css("box-shadow","0 0 20px -5px rgba(0,0,0,0.2)")),$(".leaderboardTable").hide(),$(".answerTable table").fadeIn("slow"),$(".answerTable table thead th").empty()}),$("body").on("click",".leaderboardButton",function(e){$(".answerTable table").hide(),$(".leaderboardTable").fadeIn("slow")}),$("body").on("click",".playAgain",function(e){location.reload()}),$("body").on("click",".logoImg",function(e){location.reload()});var oe=["www.lovemarks.com/wp-content/uploads/profile-avatars/default-avatar-bad-werewolf.png","www.lovemarks.com/wp-content/uploads/profile-avatars/default-avatar-knives-ninja.png","www.lovemarks.com/wp-content/uploads/profile-avatars/default-avatar-foxy-fox.png","www.lovemarks.com/wp-content/uploads/profile-avatars/default-avatar-ponsy-deer.png","www.lovemarks.com/wp-content/uploads/profile-avatars/default-avatar-nerd-pug.png"]});