Path: blob/main/projects/particle-clicker/js/ui.js
1834 views
"use strict";var UI=function(){$((function(){FastClick.attach(document.body);var e=function(){var e=$(window).height(),t=111;$(window).width()<992&&(t=112),$(".scrollable").height(e-t+"px");var i=["research","hr","upgrades"];if($(window).width()<992)for(var n=0;n<i.length;n++)$("#"+i[n]+"Content").parent().attr("id")==i[n]+"Large"&&$("#"+i[n]+"Content").detach().appendTo("#"+i[n]);else for(n=0;n<i.length;n++)$("#"+i[n]+"Content").parent().attr("id")!=i[n]+"Large"&&$("#"+i[n]+"Content").detach().appendTo("#"+i[n]+"Large");if($(window).width()<600){var o=Math.max($(window).width()-($(window).height()-90+10),300);$("#column-lab").width($(window).width()-o),$("#column-tabs").width(o)}else $("#column-lab").removeAttr("style"),$("#column-tabs").removeAttr("style");if($(window).width()>=1200)500!=detector.width&&($("#detector").width(500).height(500),detector.init(500));else if($(window).width()<768&&$(window).height()-90<300){o=$(window).width()-Math.max($(window).width()-($(window).height()-90+10),300)-10;detector.width!=o&&($("#detector").width(o).height(o),detector.init(o))}else $(window).width()<992?300!=detector.width&&($("#detector").width(300).height(300),detector.init(300)):400!=detector.width&&($("#detector").width(400).height(400),detector.init(400))};$(window).resize(e),e()}));var e=function(e,t){$(e).append(t),t.animate({bottom:"+=30px",opacity:0},{duration:500,complete:function(){$(this).remove()}})};if(void 0===$.cookie("cookielaw")){var t='<div id="cookielaw" class="alert alert-info" role="alert">';t+='<button type="button" class="btn btn-primary">OK</button>',t+='<i class="fa fa-info-circle alert-glyph"></i> <span class="alert-text">Particle Clicker uses local storage to store your current progress.</span>',t+="</div>",(t=$(t)).find("button").click((function(){$.cookie("cookielaw","informed",{expires:365}),$("#cookielaw").slideUp(300,(function(){$("#cookielaw").remove()}))})),$("#messages-container").append(t)}if(void 0===$.cookie("cern60")){t='<div id="cern60" class="alert alert-info" role="alert">';t+='<button type="button" class="btn btn-primary">Close</button>',t+='<i class="fa fa-area-chart alert-glyph"></i> <span class="alert-text"><a class="alert-link" href="http://home.web.cern.ch/about/updates/2014/12/take-part-cern-60-public-computing-challenge" target="_blank">Join the CERN 60 computing challenge!</a></span>',t+="</div>",(t=$(t)).find("button").click((function(){$.cookie("cern60","closed",{expires:365}),$("#cern60").slideUp(300,(function(){$("#cern60").remove()}))})),$("#messages-container").append(t)}return{showAchievement:function(e){var t='<div class="alert alert-success alert-dismissible" role="alert">';t+='<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>',t+='<span class="fa '+e.icon+' alert-glyph"></span> <span class="alert-text">'+e.description+"</span>",t+="</div>",t=$(t),$("#achievements-container").prepend(t);var i;window.setTimeout((i=t,function(){i.slideUp(300,(function(){i.remove()}))}),2e3)},showModal:function(e,t,i){var n=$("#infoBox");n.find("#infoBoxLabel").html(e),n.find(".modal-body").html(t),n.modal({show:!0})},showLevels:function(e){$("#infoBox").find("[data-min-level]").each((function(){e>=$(this).data("min-level")?$(this).show():$(this).hide()}))},showUpdateValue:function(t,i){if(0!=i){var n,o=Helpers.formatNumberPostfix(i);n=i>0?$("<div></div>").attr("class","update-plus").html("+"+o):$("<div></div>").attr("class","update-minus").html(o),e(t,n)}}}}();!function(){var e="hidden";function t(t){var i="visible",n="hidden",o={focus:i,focusin:i,pageshow:i,blur:n,focusout:n,pagehide:n};(t=t||window.event).type in o?detector.visible="visible"==o[t.type]:detector.visible=!this[e]}e in document?document.addEventListener("visibilitychange",t):(e="mozHidden")in document?document.addEventListener("mozvisibilitychange",t):(e="webkitHidden")in document?document.addEventListener("webkitvisibilitychange",t):(e="msHidden")in document?document.addEventListener("msvisibilitychange",t):"onfocusin"in document?document.onfocusin=document.onfocusout=t:window.onpageshow=window.onpagehide=window.onfocus=window.onblur=t}();123