1
0
forked from sent/waves
waves/public/assets/g/littlealchemy/js/alchemy.secondLoad.580.js
2025-04-09 17:11:14 -05:00

1 line
23 KiB
JavaScript

function ElementInfoBox(e,t,n,i){this.id=e,this.init(t,n),this.initEvents(i)}var sharing={url:"http://littlealchemy.com/share/",initiated:!1,types:{element:{data:function(e){return sharing.hashData({type:"element",elementId:e,elementName:bases.names[e]})}},progress:{data:function(){return sharing.hashData({type:"progress",progress:game.progress.length+game.prime.length})}},screenshot:{data:function(e){return sharing.hashData({type:"screenshot",screenshot:e})}}},initElement:function(e){var t=e.find(".shareButton");t[0].href=sharing.getUrl("element",t[0].getAttribute("data-elementid"))},initProgress:function(){var e=document.getElementById("progressShareButton");e.href=sharing.getUrl("progress"),$(document).on("newChildCreated",(function(){e.href=sharing.getUrl("progress")}))},init:function(){return!sharing.initiated&&(sharing.initiated=!0,$("#getScreenshot").on("click",sharing.getScreenshot),$("#screenshotIcon").on("click",(function(){$("#screenshotLinks").hide(),$("#screenshotWaitText").show(),html2canvas(document.body,{onrendered:function(e){sharing.uploadScreenshot(e.toDataURL().replace("data:image/png;base64,",""))}})})),game.progress&&sharing.initProgress(),void $(document).on("progressInitiated resetProgress",sharing.initProgress))},getScreenshot:function(){$("#panel").hide(),$("#screenshotLinks").hide(),$("#screenshotWaitText").show(),html2canvas(document.body,{onrendered:function(e){$("#panel").show();var t=e.toDataURL();sharing.uploadScreenshot(t.replace("data:image/png;base64,",""))}})},uploadScreenshot:function(e){$.ajax({method:"POST",url:"php/uploadScreenshot.php",data:{image:e}}).done((function(e){var t=JSON.parse(e);sharing.showScreenshotUrls(t.data.link)})).fail((function(e,t,n){console.log(t,n)}))},showScreenshotUrls:function(e){$("#screenshotWaitText").hide(),$("#screenshotLinks").show(),$("#screenshotUrl").attr("href",e);var t=document.getElementById("screenshotSharingButton");t.href=sharing.getUrl("screenshot",e),t.style.display="block",iscrollMenu.refresh()},getUrl:function(e,t){return sharing.url+e[0]+"/s/"+sharing.types[e].data(t)},hashData:function(e){return window.btoa(encodeURIComponent(JSON.stringify(e)))}};sharing.init();var elementInfo={constants:{WIDTH:235,DISTANCE_TO_ELEMENT:10,TIME_TO_FADE_OUT:5e3,FADE_OUT_TIME:1500},init:function(){$(document).on("showElementInfo",(function(e,t,n){var i,a="libraryBox"===n.$el.attr("data-elementType"),o=n.$el.offset(),s=(n.$el.outerWidth(),n.$el.outerHeight()),r=$("#workspace").outerWidth(),c=$("#workspace").outerHeight(),d={},l=$(".elementInfoBox[data-elementId="+n.id+"]");for(i=0;i<l.length;i++)if($(l[i]).data("parent")===n.$el){var f=$(l[i]);return f.stop().css("opacity","1"),setTimeout((function(){f.fadeOut(elementInfo.constants.FADE_OUT_TIME,(function(){f.off().remove()}))}),elementInfo.constants.TIME_TO_FADE_OUT),!1}var h=new ElementInfoBox(n.id,t,n.$el,a);d.top=o.top-h.height-elementInfo.constants.DISTANCE_TO_ELEMENT,d.left=o.left-h.width-elementInfo.constants.DISTANCE_TO_ELEMENT,d.left<0&&(d.left=0),d.top<0&&(d.top=o.top+s+elementInfo.constants.DISTANCE_TO_ELEMENT),d.top+h.height>c&&(o.top>c-o.top-s?d.top=0:d.top=c-h.height),"libraryBox"===n.$el.attr("data-elementType")&&(d.left=o.left),d.left+h.width>r&&(d.left=r-h.width),h.$el.css({width:h.width-h.paddingLR+"px","z-index":"1000",top:d.top+"px",left:d.left+"px"}),iscrollLibrary&&(iscrollLibrary.initiated=!1)})),$(document).on("libraryBoxDraggingStart",(function(e){$(".elementInfoBox").off().remove()})),$(document).on("workspaceBoxDraggingStart",(function(e){$(".elementInfoBox").off().remove()}))},getElementInfoData:function(e){var t,n=0,i=[],a=!1;if(bases.base[e].hasOwnProperty("parents"))for(n=bases.base[e].parents.length,t=0;t<bases.base[e].parents.length;t++)game.checkIfNotAlreadyDone(bases.base[e].parents[t])||(n--,i.push({names:[bases.names[bases.base[e].parents[t][0]],bases.names[bases.base[e].parents[t][1]]],id:[bases.base[e].parents[t][0],bases.base[e].parents[t][1]]}));return 0==i.length&&(i=localization.get("elementInfo-itIsAsItIs")),GoogleAPI.logged&&(a=!0),{id:e,name:bases.names[e],parents:i,combinationsLeft:n,loggedIn:a}}};ElementInfoBox.prototype.init=function(e,t){var n=this,i=document.createElement("div");i.setAttribute("class","elementInfoBox"),i.setAttribute("data-elementId",this.id),this.$el=$(document.getElementById("workspace").appendChild(i)),this.$el.data("parent",t),this.$el.html(templateEngine(templates.list.elementInfo,elementInfo.getElementInfoData(this.id))),this.height=this.$el.outerHeight(),this.width=elementInfo.constants.WIDTH,this.paddingLR=parseInt(this.$el.css("padding-left"))+parseInt(this.$el.css("padding-right")),"mousedown"!==e.type?$(e.target).on("touchend pointerup MSPointerUp",(function(){n.timer=setTimeout((function(){n.fadeOut()}),elementInfo.constants.TIME_TO_FADE_OUT)})):this.timer=setTimeout((function(){n.fadeOut()}),elementInfo.constants.TIME_TO_FADE_OUT),sharing.initElement(this.$el)},ElementInfoBox.prototype.initEvents=function(e){var t=this;e&&$(document).one("libraryScrollStart",(function(){window.clearTimeout(t.timer),null!==t.$el&&t.$el.hide().off().remove()}));var n=function(e){"mousedown"===e.type&&1!==e.which||"elementInfoBox"!==e.target.className&&"elementInfoBox"!==e.target.parentNode.className&&(window.clearTimeout(t.timer),null!==t.$el&&t.$el.hide().off().remove(),$(document).off(gestures.startEvents.join(" "),n))};$(document).on(gestures.startEvents.join(" "),n);var i=gestures.startEvents.join(" ").replace("mousedown","");this.$el.find(".close").on("click "+i,(function(){window.clearTimeout(t.timer),t.$el.hide().off().remove()})),this.$el.on("mouseenter",(function(){window.clearTimeout(t.timer),t.$el.stop().css("opacity","1")})),this.$el.on("mouseleave",(function(){t.timer=setTimeout((function(){t.fadeOut()}),elementInfo.constants.TIME_TO_FADE_OUT)})),this.$el.on(i,(function(e){window.clearTimeout(t.timer),t.$el.stop().css("opacity","1.0"),t.$el.on(gestures.events[e.type][1],(function(e){t.timer=setTimeout((function(){t.$el.fadeOut(elementInfo.constants.FADE_OUT_TIME,(function(){t.$el.off().remove(),t.$el=null}))}),elementInfo.constants.TIME_TO_FADE_OUT)}))}))},ElementInfoBox.prototype.fadeOut=function(){var e=this;null!==e.$el&&e.$el.fadeOut(elementInfo.constants.FADE_OUT_TIME,(function(){null!==e.$el&&e.$el.off().remove(),e.$el=null}))},elementInfo.init();var broadcast={DISPLAY_TIME:20,currentIndex:0,timer:{timer:null,start:0,remaining:0},init:function(){broadcast.$el=$("#broadcast"),broadcast.$controls=broadcast.$el.find(".controls"),broadcast.$content=broadcast.$el.find(".content"),broadcast.loadResources(),broadcast.initEvents(),broadcast.$controls.hide(),broadcast.onresize()},initEvents:function(){broadcast.$el.on("mouseenter",(function(){broadcast.timer.remaining-=(new Date).getTime()-broadcast.timer.start,clearTimeout(broadcast.timer.timer)})),broadcast.$el.on("mouseleave",(function(){broadcast.timer.timer=setTimeout(broadcast.showNext,broadcast.timer.remaining),broadcast.timer.start=(new Date).getTime()})),$(document).on("languageChanged",broadcast.loadResources),$(window).on("resize",broadcast.onresize)},show:function(){broadcast.$content.empty().append(broadcast.data[broadcast.currentIndex]),broadcast.timer.timer=setTimeout(broadcast.showNext,1e3*broadcast.DISPLAY_TIME),broadcast.timer.start=(new Date).getTime(),broadcast.timer.remaining=1e3*broadcast.DISPLAY_TIME},showNext:function(){broadcast.currentIndex+=1,broadcast.currentIndex==broadcast.data.length&&(broadcast.currentIndex=0),broadcast.show()},showPrev:function(){broadcast.currentIndex-=1,-1==broadcast.currentIndex&&(broadcast.currentIndex=broadcast.data.length-1),broadcast.show()},loadResources:function(){$.getJSON(localization.getURL("broadcast.580.json"),(function(e){broadcast.data=e.data,null!==broadcast.timer.timer&&window.clearTimeout(broadcast.timer.timer),broadcast.show()}))},onresize:function(){broadcast.$el.css("max-width",$("#toggleFullscreen").offset().right-broadcast.$el.offset().right-10)}};broadcast.init();var notifications={shown:[],DISPLAY_TIME:10,PRIORITY_ALWAYS_SHOW:5,init:function(){notifications.queue=[],notifications.waiting=[],notifications.toShow=[],notifications.alreadyShowing="",notifications.waitingTimer=null,notifications.$box=$("#notificationBox"),notifications.$boxContent=notifications.$box.find(".content"),notifications.loadTemplates(),notifications.loadData(),$(document).one("progressInitiated",notifications.loadData),$(document).on("statsDataUpdated",(function(){notifications.checkConditions(),notifications.queue.length>0&&notifications.prepareToShow(),notifications.toShow.length>0&&notifications.showOnBoard()})),notifications.initEvents()},loadData:function(){"undefined"!=typeof notificationsData&&void 0===notifications.data&&(notifications.data=notificationsData)},initEvents:function(){$(document).on("languageChanged",(function(){notifications.loadTemplates()})),$(document).on("achievementEarned",(function(e,t){var n=localization.get("achievements-"+t);notifications.showSpecified(templates.list.achievement,{title:n.title,description:n.earned})})),notifications.$box.find(".close").on("click",(function(){notifications.hideOnBoard()}))},checkConditions:function(){for(var e in notifications.queue=[],notifications.data)notifications.data[e].hasOwnProperty("isGroup")?notifications.checkGroup(e):notifications.data[e].check()&&notifications.queue.push({name:e,priority:notifications.data[e].priority})},checkGroup:function(e){if(notifications.alreadyShowing===e)return!1;if(notifications.data[e].hasOwnProperty("isBlocked")&&notifications.data[e].isBlocked())return!1;for(var t=0;t<notifications.waiting.length;t++)if(notifications.waiting[t].group===e)return!1;for(var n in notifications.data[e].list)if(notifications.data[e].check(notifications.data[e].list[n])&&(notifications.queue.push({group:e,name:n,priority:notifications.data[e].priority}),notifications.data[e].hasOwnProperty("isBlocked")&&(notifications.data[e].blocker=n),notifications.data[e].hasOwnProperty("selfBlocking")))break},prepareToShow:function(){if(notifications.queue.sort((function(e,t){return e.priority>t.priority?1:e.priority<t.priority?-1:0})),notifications.prepareQueue(),notifications.queue.length>0){i=0;do{notifications.waiting.unshift(notifications.queue[i]),notifications.waiting[0].timestamp=(new Date).getTime(),i++}while(notifications.queue[i]&&notifications.queue[i].priority>notifications.PRIORITY_ALWAYS_SHOW)}notifications.checkWaiting()},prepareQueue:function(){var e,t,n,i;for(notifications.queue=notifications.queue.filter((function(e,t){return notifications.queue.indexOf(e)==t})),t=0;t<notifications.queue.length;)if(notifications.queue[t].hasOwnProperty("group"))t++;else{for(e=notifications.queue[t].name,i=[],n=t+1;n<notifications.queue.length;n++)e!==notifications.queue[n].name&&-1==notifications.data[e].blocker.indexOf(notifications.queue[n].name)||i.push(n);for(n=0;n<notifications.toShow.length;n++)if(e===notifications.toShow[n].name||-1!=notifications.data[e].blocker.indexOf(notifications.toShow[n].name)){i.push(t);break}for(notifications.alreadyShowing!==e&&-1==notifications.data[e].blocker.indexOf(notifications.alreadyShowing)||i.push(t),-1===(i=i.filter((function(e,t){return i.indexOf(e)==t}))).indexOf(t)&&t++,n=i.length-1;n>=0;n--)notifications.queue.splice(i[n],1)}},checkWaiting:function(){for(var e,t=function(e){return!isNaN(parseFloat(e))&&isFinite(e)},n=[],i=(new Date).getTime(),a=0;a<notifications.waiting.length;a++)if(e=notifications.waiting[a].hasOwnProperty("group")?notifications.waiting[a].group:notifications.waiting[a].name,notifications.data[e].hasOwnProperty("delay"))if(t(notifications.data[e].delay))i>=notifications.waiting[a].timestamp+1e3*notifications.data[e].delay&&(notifications.toShow.push(notifications.waiting[a]),n.push(a));else{var o=notifications.data[e].delay(notifications.waiting[a]);o&&!t(o)?(notifications.toShow.push(notifications.waiting[a]),n.push(a)):t(o)&&(notifications.waiting[a].timestamp=i)}else notifications.toShow.push(notifications.waiting[a]),n.push(a);for(var s=n.length-1;s>=0;s--)notifications.waiting.splice(n[s],1);0===notifications.waiting.length?(window.clearInterval(notifications.waitingTimer),notifications.waitingTimer=null):notifications.setCheckingWaiting(),notifications.toShow.length>0&&notifications.showOnBoard()},setCheckingWaiting:function(){null===notifications.waitingTimer&&(notifications.waitingTimer=window.setInterval(notifications.checkWaiting,1e3))},showOnBoard:function(){""!==notifications.alreadyShowing||settings.data.turnOffNotifications||(notifications.showNext(),notifications.$box.removeClass("hide").addClass("show"),notifications.data.hasOwnProperty(notifications.alreadyShowing)&&notifications.data[notifications.alreadyShowing].hasOwnProperty("onShow")&&notifications.data[notifications.alreadyShowing].onShow())},showNext:function(){if(notifications.toShow.length>0){notifications.$boxContent.empty();var e,t,n,i=notifications.toShow.shift();notifications.alreadyShowing=i.hasOwnProperty("group")?i.group:i.name,i.hasOwnProperty("group")?(e=notifications.templates[notifications.data[i.group].template],t=notifications.data[i.group].passData(notifications.data[i.group].list[i.name]),n=notifications.data[i.group].hasOwnProperty("duration")?notifications.data[i.group].duration:notifications.DISPLAY_TIME):(e=notifications.data[i.name].hasOwnProperty("template")?notifications.templates[notifications.data[i.name].template]:notifications.templates[i.name],notifications.data[i.name].hasOwnProperty("passData")&&(t=notifications.data[i.name].passData()),n=notifications.data[i.name].hasOwnProperty("duration")?notifications.data[i.name].duration:notifications.DISPLAY_TIME),notifications.$boxContent.append(templateEngine(e,t)),notifications.boxTimer=setTimeout(notifications.showNextCallback,1e3*n),i.hasOwnProperty("group")?notifications.data[i.group].hasOwnProperty("once")&&-1===notifications.shown.indexOf(i.group+"."+i.name)&&notifications.shown.push(i.group+"."+i.name):notifications.data[i.name].hasOwnProperty("once")&&-1===notifications.shown.indexOf(i.name)&&(notifications.shown.push(i.name),delete notifications.data[i.name]),storage.updateNotifications()}},showNextCallback:function(){var e=!!window.getStyleProperty("transition"),t=function(){notifications.toShow.length>0?(notifications.showNext(),notifications.$box.removeClass("hide").addClass("show")):notifications.hideOnBoard(),notifications.$box.off("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",t)};notifications.$box.removeClass("show").addClass("hide"),notifications.data.hasOwnProperty(notifications.alreadyShowing)&&notifications.data[notifications.alreadyShowing].hasOwnProperty("onHide")&&notifications.data[notifications.alreadyShowing].onHide(),e?notifications.$box.on("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",t):t()},showSpecified:function(e,t,n){var i=n||notifications.DISPLAY_TIME;notifications.$boxContent.empty().append(templateEngine(e,t)),notifications.$box.removeClass("hide").addClass("show"),notifications.boxTimer=setTimeout(notifications.hideOnBoard,1e3*i)},hideOnBoard:function(){notifications.$box.is(":visible")&&(notifications.$box.removeClass("show").addClass("hide"),notifications.$boxContent.empty(),notifications.toShow=[],notifications.alreadyShowing="",clearTimeout(notifications.boxTimer))},loadTemplates:function(){notifications.templates={};var e=localization.getURL("notifications.html");$.get(loading.getURL(e),(function(t,n,i){loading.analyzeModificationDate(e,i.getResponseHeader("Last-Modified"));var a=$(t);for(var o in notifications.data)notifications.templates.hasOwnProperty(o)||(notifications.data[o].hasOwnProperty("template")?notifications.templates[notifications.data[o].template]=a.filter("#"+notifications.data[o].template).html():notifications.templates[o]=a.filter("#"+o).html())})).then((function(){$(document).trigger("notificationsLoaded")}))},removeAlreadyShown:function(){notifications.shown=storage.getNotifications();for(var e=0;e<notifications.shown.length;e++)-1!==notifications.shown[e].indexOf(".")?delete notifications.data[notifications.shown[e].split(".")[0]].list[notifications.shown[e].split(".")[1]]:delete notifications.data[notifications.shown[e]]}};notifications.init();var leaderboard={boardIDs:{progress:"CgkIz_OApZAJEAIQAQ",connections:"CgkIz_OApZAJEAIQBg"},scores:{},init:function(){$(document).on("newChildCreated",(function(){GoogleAPI.logged&&leaderboard.submitScore("progress",game.progress.length+game.prime.length)})),$(document).on("updateHistory",(function(){GoogleAPI.logged&&leaderboard.submitScore("connections",game.history.parents.length)})),$(document).on("leaderboardsTabShown",(function(){document.getElementById("leaderboard").style.display="none",document.getElementById("leaderboardWaitText").style.display="block",leaderboard.getScores("progress",(function(){$("#leaderboard").html(templateEngine(templates.list.leaderboards,leaderboard.scores.progress)),document.getElementById("leaderboard").style.display="block",document.getElementById("leaderboardWaitText").style.display="none",window.setTimeout((function(){menu.refreshIScroll()}),100)}),"SOCIAL")}))},submitScore:function(e,t){if(void 0===gapi.client.games)return!1;gapi.client.games.scores.submit({leaderboardId:leaderboard.boardIDs[e],score:t}).execute((function(e){}))},submitMultipleScores:function(e){var t={kind:"games#playerScoreSubmissionList",scores:[]};for(var n in e)leaderboard.boardIDs.hasOwnProperty(n)&&t.scores.push({kind:"games#scoreSubmission",leaderboardId:leaderboard.boardIDs[n],score:e[n]});gapi.client.games.scores.submitMultiple(t).execute((function(e){}))},getScores:function(e,t,n){var i=n||"PUBLIC";GoogleAPI.logged&&leaderboard.boardIDs.hasOwnProperty(e)&&gapi.client.games.scores.list({collection:i,leaderboardId:leaderboard.boardIDs[e],timeSpan:"ALL_TIME"}).execute((function(n){n.hasOwnProperty("error")?401===n.code&&$(document).trigger("unauthorized"):(leaderboard.parseResponse(e,n),t&&t())}))},showScores:function(e,t){var n=t||"PUBLIC";leaderboard.getScores(e,(function(){$("#leaderboard").html(templateEngine(templates.list.leaderboards,{players:leaderboard.scores[e].list}))}),n)},parseResponse:function(e,t){if(leaderboard.scores[e]={},t.hasOwnProperty("playerScore")?leaderboard.scores[e].player={id:t.playerScore.player.playerId,name:t.playerScore.player.displayName,avatar:t.playerScore.player.avatarImageUrl,score:t.playerScore.scoreValue,rank:t.playerScore.scoreRank,timeStamp:t.playerScore.writeTimestampMillis}:leaderboard.scores[e].player={id:-1},t.hasOwnProperty("items")){leaderboard.scores[e].list=[];for(var n=0,i=t.items.length;n<i;n++)leaderboard.scores[e].list.push({id:t.items[n].player.playerId,name:t.items[n].player.displayName,avatar:t.items[n].player.hasOwnProperty("avatarImageUrl")?t.items[n].player.avatarImageUrl:"img/achievement-earned-placeholder.png",score:t.items[n].scoreValue,rank:t.items[n].scoreRank,timeStamp:t.items[n].writeTimestampMillis})}}};leaderboard.init();var achievements={earnedList:[],playerList:{},init:function(){achievements.earnedList=storage.getAchievements(),achievements.loadData(),achievements.checked=!1,bases&&bases.loaded&&void 0!==achievements.data?(achievements.initialCheck(),achievements.initConditionsEvents()):$(document).one("progressInitiated",(function(){achievements.loadData(),achievements.initialCheck(),achievements.initConditionsEvents()})),$(document).on("achievementsTabShown",(function(){$("#achievementsList").html(templateEngine(templates.list.achievements,{achievements:achievements.getDataToShow()}))})),$(document).on("GAPIclientLoaded loggedIn",(function(){GoogleAPI.logged&&!achievements.checked&&gapi.client.games&&(achievements.getPlayerList(),achievements.initConditionsEvents())})),$(document).on("loggedOut",(function(){achievements.checked=!1})),$(document).on("historySynchronized",(function(){void 0!==achievements.data&&achievements.initialCheck()}))},checkEarnedIntegrity:function(){for(var e=!1,t=achievements.earnedList.length-1;t>=0;t--){for(var n=0;n<achievements.data.length;n++)if(achievements.earnedList[t]===achievements.data[n].id){e=!0;break}e||achievements.earnedList.splice(t,1)}},loadData:function(){"undefined"!=typeof achievementsData&&void 0===achievements.data&&(achievements.data=achievementsData,achievements.checkEarnedIntegrity())},initialCheck:function(){for(var e=0,t=achievements.data.length;e<t;e++)-1===achievements.earnedList.indexOf(achievements.data[e].id)&&achievements.data[e].hasOwnProperty("initCheck")&&achievements.data[e].initCheck()&&achievements.earnedList.push(achievements.data[e].id);$(document).trigger("updateAchievements")},initConditionsEvents:function(){for(var e=0,t=achievements.data.length;e<t;e++)!function(e){-1==achievements.earnedList.indexOf(achievements.data[e].id)&&$(document).on(achievements.data[e].events,(function t(n,i){-1==achievements.earnedList.indexOf(achievements.data[e].id)&&(achievements.data[e].hasOwnProperty("check")&&!achievements.data[e].check(i)||(achievements.earn(achievements.data[e].id,{trigger:!0}),$(document).off(achievements.data[e].events,t)))}))}(e)},earn:function(e,t){achievements.earnedList.push(e),achievements.unlock(achievements.getById(e).gapiId),$(document).trigger("updateAchievements"),$(document).trigger("achievementEarned",[e])},getByGapiId:function(e){for(var t=0;t<achievements.data.length;t++)if(e===achievements.data[t].gapiId)return achievements.data[t]},getById:function(e){for(var t=0;t<achievements.data.length;t++)if(e===achievements.data[t].id)return achievements.data[t]},getDataToShow:function(){for(var e,t,n={},i=[],a=0,o=achievements.data.length;a<o;a++)n=localization.get("achievements-"+achievements.data[a].id),e=(t=-1!==achievements.earnedList.indexOf(achievements.data[a].id))?achievements.data[a].imageEarned:achievements.data[a].imageNotEarned,i.push({title:n.title,description:n.description,earned:t,image:e});return i},synchronize:function(){for(var e in achievements.playerList)"UNLOCKED"===achievements.playerList[e].achievementState&&-1==achievements.earnedList.indexOf(achievements.getByGapiId(e).id)&&achievements.earnedList.push(achievements.getByGapiId(e).id);$(document).trigger("updateAchievements");for(var t,n=0;n<achievements.earnedList.length;n++)(t=achievements.getById(achievements.earnedList[n]))&&t.hasOwnProperty("gapiId")&&((e=t.gapiId)&&"UNLOCKED"!==achievements.playerList[e].achievementState&&achievements.unlock(e))},unlock:function(e){GoogleAPI.logged&&gapi.client.games&&(e.hasOwnProperty("incremental")?achievements.incrementRequest(e):achievements.unlockRequest(e))},unlockRequest:function(e){gapi.client.games.achievements.unlock({achievementId:e}).execute((function(e){}))},incrementRequest:function(e){gapi.client.games.achievements.increment({achievementId:e,stepsToIncrement:1}).execute((function(t){achievements.playerList[e].currentSteps=t.currentSteps,t.newlyUnlocked&&(achievements.playerList[e].achievementState="UNLOCKED")}))},getPlayerList:function(){gapi.client.games.achievements.list({playerId:"me"}).execute((function(e){if("games#playerAchievementListResponse"===e.kind&&e.hasOwnProperty("items")){for(var t=0,n=e.items.length;t<n;t++)delete e.items[t].kind,delete e.items[t].formattedCurrentStepsString,achievements.playerList[e.items[t].id]=e.items[t];achievements.synchronize(),achievements.checked=!0}}))},reset:function(){achievements.earnedList=[],$(document).trigger("updateAchievements")}};achievements.init();