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;ic&&(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;t0&¬ifications.prepareToShow(),notifications.toShow.length>0&¬ifications.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()&¬ifications.queue.push({name:e,priority:notifications.data[e].priority})},checkGroup:function(e){if(notifications.alreadyShowing===e)return!1;if(notifications.data[e].hasOwnProperty("isBlocked")&¬ifications.data[e].isBlocked())return!1;for(var t=0;tt.priority?1:e.priority0){i=0;do{notifications.waiting.unshift(notifications.queue[i]),notifications.waiting[0].timestamp=(new Date).getTime(),i++}while(notifications.queue[i]&¬ifications.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=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[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&¬ifications.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)&¬ifications.data[notifications.alreadyShowing].hasOwnProperty("onShow")&¬ifications.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)&¬ifications.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)&¬ifications.data[notifications.alreadyShowing].hasOwnProperty("onHide")&¬ifications.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=0;t--){for(var n=0;n