174 lines
79 KiB
JavaScript
174 lines
79 KiB
JavaScript
|
(function(){function a(a){a=String(a);return a.charAt(0).toUpperCase()+a.slice(1)}function d(a,c){var d=-1,f=a?a.length:0;if("number"==typeof f&&-1<f&&f<=m)for(;++d<f;)c(a[d],d,a);else b(a,c)}function f(c){c=String(c).replace(/^ +| +$/g,"");return/^(?:webOS|i(?:OS|P))/.test(c)?c:a(c)}function b(a,c){for(var b in a)u.call(a,b)&&c(a[b],b,a)}function g(c){return null==c?a(c):B.call(c).slice(8,-1)}function h(a,c){var b=null!=a?typeof a[c]:"number";return!/^(?:boolean|number|string|undefined)$/.test(b)&&
|
||
|
("object"==b?!!a[c]:!0)}function k(a){return String(a).replace(/([ -])(?!$)/g,"$1?")}function n(a,c){var b=null;d(a,function(d,f){b=c(b,d,f,a)});return b}function c(a){function d(e){return n(e,function(e,c){var b=c.pattern||k(c);!e&&(e=RegExp("\\b"+b+" *\\d+[.\\w_]*","i").exec(a)||RegExp("\\b"+b+" *\\w+-[\\w]*","i").exec(a)||RegExp("\\b"+b+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(a))&&((e=String(c.label&&!RegExp(b,"i").test(c.label)?c.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=
|
||
|
" "+e[1]),c=c.label||c,e=f(e[0].replace(RegExp(b,"i"),c).replace(RegExp("; *(?:"+c+"[_-])?","i")," ").replace(RegExp("("+c+")[-_.]?(\\w)","i"),"$1 $2")));return e})}function p(e){return n(e,function(e,c){return e||(RegExp(c+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(a)||0)[1]||null})}var q=t,r=a&&"object"==typeof a&&"String"!=g(a);r&&(q=a,a=null);var x=q.navigator||{},m=x.userAgent||"";a||(a=m);var u=r?!!x.likeChrome:/\bChrome\b/.test(a)&&!/internal|\n/i.test(B.toString()),
|
||
|
H=r?"Object":"ScriptBridgingProxyObject",D=r?"Object":"Environment",K=r&&q.java?"JavaPackage":g(q.java),M=r?"Object":"RuntimeObject";D=(K=/\bJava/.test(K)&&q.java)&&g(q.environment)==D;var R=K?"a":"\u03b1",N=K?"b":"\u03b2",S=q.document||{},I=q.operamini||q.opera,O=y.test(O=r&&I?I["[[Class]]"]:g(I))?O:I=null,e,U=a;r=[];var V=null,P=a==m;m=P&&I&&"function"==typeof I.version&&I.version();var z=function(e){return n(e,function(e,c){return e||RegExp("\\b"+(c.pattern||k(c))+"\\b","i").exec(a)&&(c.label||
|
||
|
c)})}([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]),v=function(e){return n(e,function(e,c){return e||RegExp("\\b"+(c.pattern||k(c))+"\\b","i").exec(a)&&(c.label||c)})}(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"Edge"},"Midori","Nook Browser",
|
||
|
"PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Waterfox","WebPositive","Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chrome",{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},
|
||
|
{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),A=d([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad",
|
||
|
"iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),L=function(e){return n(e,function(e,c,b){return e||(c[A]||c[/^[a-z]+(?: +[a-z]+\b)*/i.exec(A)]||RegExp("\\b"+k(b)+"(?:\\b|\\w*\\d)","i").exec(a))&&b})}({Apple:{iPad:1,iPhone:1,iPod:1},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},
|
||
|
"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1}}),w=function(e){return n(e,function(e,c){var b=c.pattern||k(c);if(!e&&(e=RegExp("\\b"+b+"(?:/[\\d.]+|[ \\w.]*)","i").exec(a))){var d=e,n=c.label||c,O={"10.0":"10","6.4":"10 Technical Preview",
|
||
|
"6.3":"8.1","6.2":"8","6.1":"Server 2008 R2 / 7","6.0":"Server 2008 / Vista","5.2":"Server 2003 / XP 64-bit","5.1":"XP","5.01":"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};b&&n&&/^Win/i.test(d)&&!/^Windows Phone /i.test(d)&&(O=O[/[\d.]+$/.exec(d)])&&(d="Windows "+O);d=String(d);b&&n&&(d=d.replace(RegExp(b,"i"),n));e=d=f(d.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/,
|
||
|
" $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}return e})}(["Windows Phone","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian","Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac",
|
||
|
"Windows 98;","Windows "]);z&&(z=[z]);L&&!A&&(A=d([L]));if(e=/\bGoogle TV\b/.exec(A))A=e[0];/\bSimulator\b/i.test(a)&&(A=(A?A+" ":"")+"Simulator");"Opera Mini"==v&&/\bOPiOS\b/.test(a)&&r.push("running in Turbo/Uncompressed mode");"IE"==v&&/\blike iPhone OS\b/.test(a)?(e=c(a.replace(/like iPhone OS/,"")),L=e.manufacturer,A=e.product):/^iP/.test(A)?(v||(v="Safari"),w="iOS"+((e=/ OS ([\d_]+)/i.exec(a))?" "+e[1].replace(/_/g,"."):"")):"Konqueror"!=v||/buntu/i.test(w)?L&&"Google"!=L&&(/Chrome/.test(v)&&
|
||
|
!/\bMobile Safari\b/i.test(a)||/\bVita\b/.test(A))||/\bAndroid\b/.test(w)&&/^Chrome/.test(v)&&/\bVersion\//i.test(a)?(v="Android Browser",w=/\bAndroid\b/.test(w)?w:"Android"):"Silk"==v?(/\bMobi/i.test(a)||(w="Android",r.unshift("desktop mode")),/Accelerated *= *true/i.test(a)&&r.unshift("accelerated")):"PaleMoon"==v&&(e=/\bFirefox\/([\d.]+)\b/.exec(a))?r.push("identifying as Firefox "+e[1]):"Firefox"==v&&(e=/\b(Mobile|Tablet|TV)\b/i.exec(a))?(w||(w="Firefox OS"),A||(A=e[1])):!v||(e=!/\bMinefield\b/i.test(a)&&
|
||
|
/\b(?:Firefox|Safari)\b/.exec(v))?(v&&!A&&/[\/,]|^[^(]+?\)/.test(a.slice(a.indexOf(e+"/")+8))&&(v=null),(e=A||L||w)&&(A||L||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(w))&&(v=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(w)?w:e)+" Browser")):"Electron"==v&&(e=(/\bChrome\/([\d.]+)\b/.exec(a)||0)[1])&&r.push("Chromium "+e):w="Kubuntu";m||(m=p(["(?:Cloud9|CriOS|CrMo|Edge|FxiOS|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$))","Version",k(v),"(?:Firefox|Minefield|NetFront)"]));
|
||
|
if(e="iCab"==z&&3<parseFloat(m)&&"WebKit"||/\bOpera\b/.test(v)&&(/\bOPR\b/.test(a)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(a)&&!/^(?:Trident|EdgeHTML)$/.test(z)&&"WebKit"||!z&&/\bMSIE\b/i.test(a)&&("Mac OS"==w?"Tasman":"Trident")||"WebKit"==z&&/\bPlayStation\b(?! Vita\b)/i.test(v)&&"NetFront")z=[e];"IE"==v&&(e=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(a)||0)[1])?(v+=" Mobile",w="Windows Phone "+(/\+$/.test(e)?e:e+".x"),r.unshift("desktop mode")):/\bWPDesktop\b/i.test(a)?(v="IE Mobile",w="Windows Phone 8.x",
|
||
|
r.unshift("desktop mode"),m||(m=(/\brv:([\d.]+)/.exec(a)||0)[1])):"IE"!=v&&"Trident"==z&&(e=/\brv:([\d.]+)/.exec(a))&&(v&&r.push("identifying as "+v+(m?" "+m:"")),v="IE",m=e[1]);if(P){if(h(q,"global"))if(K&&(e=K.lang.System,U=e.getProperty("os.arch"),w=w||e.getProperty("os.name")+" "+e.getProperty("os.version")),D){try{m=q.require("ringo/engine").version.join("."),v="RingoJS"}catch(X){(e=q.system)&&e.global.system==q.system&&(v="Narwhal",w||(w=e[0].os||null))}v||(v="Rhino")}else"object"==typeof q.process&&
|
||
|
!q.process.browser&&(e=q.process)&&("object"==typeof e.versions&&("string"==typeof e.versions.electron?(r.push("Node "+e.versions.node),v="Electron",m=e.versions.electron):"string"==typeof e.versions.nw&&(r.push("Chromium "+m,"Node "+e.versions.node),v="NW.js",m=e.versions.nw)),v||(v="Node.js",U=e.arch,w=e.platform,m=(m=/[\d.]+/.exec(e.version))?m[0]:null));else g(e=q.runtime)==H?(v="Adobe AIR",w=e.flash.system.Capabilities.os):g(e=q.phantom)==M?(v="PhantomJS",m=(e=e.version||null)&&e.major+"."+e.minor+
|
||
|
"."+e.patch):"number"==typeof S.documentMode&&(e=/\bTrident\/(\d+)/i.exec(a))?(m=[m,S.documentMode],(e=+e[1]+4)!=m[1]&&(r.push("IE "+m[1]+" mode"),z&&(z[1]=""),m[1]=e),m="IE"==v?String(m[1].toFixed(1)):m[0]):"number"==typeof S.documentMode&&/^(?:Chrome|Firefox)\b/.test(v)&&(r.push("masking as "+v+" "+m),v="IE",m="11.0",z=["Trident"],w="Windows");w=w&&f(w)}m&&(e=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(m)||/(?:alpha|beta)(?: ?\d)?/i.exec(a+";"+(P&&x.appMinorVersion))||/\bMinefield\b/i.test(a)&&
|
||
|
"a")&&(V=/b/i.test(e)?"beta":"alpha",m=m.replace(RegExp(e+"\\+?$"),"")+("beta"==V?N:R)+(/\d+\+?/.exec(e)||""));if("Fennec"==v||"Firefox"==v&&/\b(?:Android|Firefox OS)\b/.test(w))v="Firefox Mobile";else if("Maxthon"==v&&m)m=m.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(A))"Xbox 360"==A&&(w=null),"Xbox 360"==A&&/\bIEMobile\b/.test(a)&&r.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(v)&&(!v||A||/Browser|Mobi/.test(v))||"Windows CE"!=w&&!/Mobi/i.test(a))if("IE"==v&&P)try{null===q.external&&
|
||
|
r.unshift("platform preview")}catch(X){r.unshift("embedded")}else(/\bBlackBerry\b/.test(A)||/\bBB10\b/.test(a))&&(e=(RegExp(A.replace(/ +/g," *")+"/([.\\d]+)","i").exec(a)||0)[1]||m)?(e=[e,/BB10/.test(a)],w=(e[1]?(A=null,L="BlackBerry"):"Device Software")+" "+e[0],m=null):this!=b&&"Wii"!=A&&(P&&I||/Opera/.test(v)&&/\b(?:MSIE|Firefox)\b/i.test(a)||"Firefox"==v&&/\bOS X (?:\d+\.){2,}/.test(w)||"IE"==v&&(w&&!/^Win/.test(w)&&5.5<m||/\bWindows XP\b/.test(w)&&8<m||8==m&&!/\bTrident\b/.test(a)))&&!y.test(e=
|
||
|
c.call(b,a.replace(y,"")+";"))&&e.name&&(e="ing as "+e.name+((e=e.version)?" "+e:""),y.test(v)?(/\bIE\b/.test(e)&&"Mac OS"==w&&(w=null),e="identify"+e):(e="mask"+e,v=O?f(O.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(e)&&(w=null),P||(m=null)),z=["Presto"],r.push(e));else v+=" Mobile";if(e=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(a)||0)[1]){e=[parseFloat(e.replace(/\.(\d)$/,".0$1")),e];if("Safari"==v&&"+"==e[1].slice(-1))v="WebKit Nightly",V="alpha",m=e[1].slice(0,-1);else if(m==e[1]||m==(e[2]=
|
||
|
(/\bSafari\/([\d.]+\+?)/i.exec(a)||0)[1]))m=null;e[1]=(/\bChrome\/([\d.]+)/i.exec(a)||0)[1];537.36==e[0]&&537.36==e[2]&&28<=parseFloat(e[1])&&"WebKit"==z&&(z=["Blink"]);P&&(u||e[1])?(z&&(z[1]="like Chrome"),e=e[1]||(e=e[0],530>e?1:532>e?2:532.05>e?3:533>e?4:534.03>e?5:534.07>e?6:534.1>e?7:534.13>e?8:534.16>e?9:534.24>e?10:534.3>e?11:535.01>e?12:535.02>e?"13+":535.07>e?15:535.11>e?16:535.19>e?17:536.05>e?18:536.1>e?19:537.01>e?20:537.11>e?"21+":537.13>e?23:537.18>e?24:537.24>e?25:537.36>e?26:"Blink"!=
|
||
|
z?"27":"28")):(z&&(z[1]="like Safari"),e=(e=e[0],400>e?1:500>e?2:526>e?3:533>e?4:534>e?"4+":535>e?5:537>e?6:538>e?7:601>e?8:"8"));z&&(z[1]+=" "+(e+="number"==typeof e?".x":/[.+]/.test(e)?"":"+"));"Safari"==v&&(!m||45<parseInt(m))&&(m=e)}"Opera"==v&&(e=/\bzbov|zvav$/.exec(w))?(v+=" ",r.unshift("desktop mode"),"zvav"==e?(v+="Mini",m=null):v+="Mobile",w=w.replace(RegExp(" *"+e+"$"),"")):"Safari"==v&&/\bChrome\b/.exec(z&&z[1])&&(r.unshift("desktop mode"),v="Chrome Mobile",m=null,/\bOS X\b/.test(w)?(L=
|
||
|
"Apple",w="iOS 4.3+"):w=null);m&&0==m.indexOf(e=/[\d.]+$/.exec(w))&&-1<a.indexOf("/"+e+"-")&&(w=String(w.replace(e,"")).replace(/^ +| +$/g,""));z&&!/\b(?:Avant|Nook)\b/.test(v)&&(/Browser|Lunascape|Maxthon/.test(v)||"Safari"!=v&&/^iOS/.test(w)&&/\bSafari\b/.test(z[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|Web)/.test(v)&&z[1])&&(e=z[z.length-1])&&r.push(e);r.length&&(r=["("+r.join("; ")+")"]);L&&A&&0>A.indexOf(L)&&r.push("on "+L);A&&r.push((/^on /.test(r[r.length-
|
||
|
1])?"":"on ")+A);if(w){var W=(e=/ ([\d.+]+)$/.exec(w))&&"/"==w.charAt(w.length-e[0].length-1);w={architecture:32,family:e&&!W?w.replace(e[0],""):w,version:e?e[1]:null,toString:function(){var a=this.version;return this.family+(a&&!W?" "+a:"")+(64==this.architecture?" 64-bit":"")}}}(e=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(U))&&!/\bi686\b/i.test(U)?(w&&(w.architecture=64,w.family=w.family.replace(RegExp(" *"+e),"")),v&&(/\bWOW64\b/i.test(a)||P&&/\w(?:86|32)$/.test(x.cpuClass||x.platform)&&!/\bWin64; x64\b/i.test(a))&&
|
||
|
r.unshift("32-bit")):w&&/^OS X/.test(w.family)&&"Chrome"==v&&39<=parseFloat(m)&&(w.architecture=64);a||(a=null);q={};q.description=a;q.layout=z&&z[0];q.manufacturer=L;q.name=v;q.prerelease=V;q.product=A;q.ua=a;q.version=v&&m;q.os=w||{architecture:null,family:null,version:null,toString:function(){return"null"}};q.parse=c;q.toString=function(){return this.description||""};q.version&&r.unshift(m);q.name&&r.unshift(v);w&&v&&(w!=String(w).split(" ")[0]||w!=v.split(" ")[0]&&!A)&&r.push(A?"("+w+")":"on "+
|
||
|
w);r.length&&(q.description=r.join(" "));return q}var p={"function":!0,object:!0},t=p[typeof window]&&window||this,r=p[typeof exports]&&exports;p=p[typeof module]&&module&&!module.nodeType&&module;var x=r&&p&&"object"==typeof global&&global;!x||x.global!==x&&x.window!==x&&x.self!==x||(t=x);var m=Math.pow(2,53)-1,y=/\bOpera/;x=Object.prototype;var u=x.hasOwnProperty,B=x.toString,D=c();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.platform=D,define(function(){return D})):r&&
|
||
|
p?b(D,function(a,c){r[c]=a}):t.platform=D}).call(this);
|
||
|
function buildIOSMeta(){for(var a=[{name:"viewport",content:"width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"},{name:"apple-mobile-web-app-capable",content:"yes"},{name:"apple-mobile-web-app-status-bar-style",content:"black"}],d=0;d<a.length;d++){var f=document.createElement("meta");f.name=a[d].name;f.content=a[d].content;var b=window.document.head.querySelector('meta[name="'+f.name+'"]');b&&b.parentNode.removeChild(b);window.document.head.appendChild(f)}}
|
||
|
function hideIOSFullscreenPanel(){jQuery(".xxx-ios-fullscreen-message").css("display","none");jQuery(".xxx-ios-fullscreen-scroll").css("display","none");jQuery(".xxx-game-iframe-full").removeClass("xxx-game-iframe-iphone-se")}function buildIOSFullscreenPanel(){jQuery("body").append('<div class="xxx-ios-fullscreen-message"><div class="xxx-ios-fullscreen-swipe"></div></div><div class="xxx-ios-fullscreen-scroll"></div>')}
|
||
|
function showIOSFullscreenPanel(){jQuery(".xxx-ios-fullscreen-message").css("display","block");jQuery(".xxx-ios-fullscreen-scroll").css("display","block")}
|
||
|
function __iosResize(){window.scrollTo(0,0);console.log(window.devicePixelRatio);console.log(window.innerWidth);console.log(window.innerHeight);if("iPhone"===platform.product)switch(window.devicePixelRatio){case 2:switch(window.innerWidth){case 568:320!==window.innerHeight&&jQuery(".xxx-game-iframe-full").addClass("xxx-game-iframe-iphone-se");break;case 667:375===window.innerHeight?hideIOSFullscreenPanel():showIOSFullscreenPanel();break;case 808:414===window.innerHeight?hideIOSFullscreenPanel():showIOSFullscreenPanel();
|
||
|
break;default:hideIOSFullscreenPanel()}break;case 3:switch(window.innerWidth){case 736:414===window.innerHeight?hideIOSFullscreenPanel():showIOSFullscreenPanel();break;case 724:375===window.innerHeight?hideIOSFullscreenPanel():showIOSFullscreenPanel();break;case 808:414===window.innerHeight?hideIOSFullscreenPanel():showIOSFullscreenPanel();break;default:hideIOSFullscreenPanel()}break;default:hideIOSFullscreenPanel()}}function iosResize(){__iosResize();setTimeout(function(){__iosResize()},500)}
|
||
|
function iosInIframe(){try{return window.self!==window.top}catch(a){return!0}}$(document).ready(function(){platform&&"iPhone"===platform.product&&"safari"!==platform.name.toLowerCase()&&(buildIOSFullscreenPanel(),buildIOSMeta())});jQuery(window).resize(function(){platform&&"iPhone"===platform.product&&"safari"!==platform.name.toLowerCase()&&iosResize()});
|
||
|
(function(){var a="undefined"!==typeof window&&"undefined"!==typeof window.document?window.document:{},d="undefined"!==typeof module&&module.exports,f="undefined"!==typeof Element&&"ALLOW_KEYBOARD_INPUT"in Element,b=function(){for(var b,d=["requestFullscreen exitFullscreen fullscreenElement fullscreenEnabled fullscreenchange fullscreenerror".split(" "),"webkitRequestFullscreen webkitExitFullscreen webkitFullscreenElement webkitFullscreenEnabled webkitfullscreenchange webkitfullscreenerror".split(" "),
|
||
|
"webkitRequestFullScreen webkitCancelFullScreen webkitCurrentFullScreenElement webkitCancelFullScreen webkitfullscreenchange webkitfullscreenerror".split(" "),"mozRequestFullScreen mozCancelFullScreen mozFullScreenElement mozFullScreenEnabled mozfullscreenchange mozfullscreenerror".split(" "),"msRequestFullscreen msExitFullscreen msFullscreenElement msFullscreenEnabled MSFullscreenChange MSFullscreenError".split(" ")],c=0,f=d.length,g={};c<f;c++)if((b=d[c])&&b[1]in a){for(c=0;c<b.length;c++)g[d[0][c]]=
|
||
|
b[c];return g}return!1}(),g={change:b.fullscreenchange,error:b.fullscreenerror},h={request:function(d){var n=b.requestFullscreen;d=d||a.documentElement;if(/5\.1[.\d]* Safari/.test(navigator.userAgent))d[n]();else d[n](f&&Element.ALLOW_KEYBOARD_INPUT)},exit:function(){a[b.exitFullscreen]()},toggle:function(a){this.isFullscreen?this.exit():this.request(a)},onchange:function(a){this.on("change",a)},onerror:function(a){this.on("error",a)},on:function(b,d){var c=g[b];c&&a.addEventListener(c,d,!1)},off:function(b,
|
||
|
d){var c=g[b];c&&a.removeEventListener(c,d,!1)},raw:b};b?(Object.defineProperties(h,{isFullscreen:{get:function(){return!!a[b.fullscreenElement]}},element:{enumerable:!0,get:function(){return a[b.fullscreenElement]}},enabled:{enumerable:!0,get:function(){return!!a[b.fullscreenEnabled]}}}),d?module.exports=h:window.screenfull=h):d?module.exports=!1:window.screenfull=!1})();var s_iScaleFactor=1,s_bIsIphone=!1,s_iOffsetX,s_iOffsetY;
|
||
|
(function(a){(jQuery.browser=jQuery.browser||{}).mobile=/android|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(ad|hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|tablet|treo|up\.(browser|link)|vodafone|wap|webos|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,
|
||
|
4))})(navigator.userAgent||navigator.vendor||window.opera);$(window).resize(function(){sizeHandler()});function trace(a){console.log(a)}function isChrome(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}function isIOS(){var a="iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";");for(-1!==navigator.userAgent.toLowerCase().indexOf("iphone")&&(s_bIsIphone=!0);a.length;)if(navigator.platform===a.pop())return!0;return s_bIsIphone=!1}
|
||
|
function getSize(a){var d=a.toLowerCase(),f=window.document,b=f.documentElement;if(void 0===window["inner"+a])a=b["client"+a];else if(window["inner"+a]!=b["client"+a]){var g=f.createElement("body");g.id="vpw-test-b";g.style.cssText="overflow:scroll";var h=f.createElement("div");h.id="vpw-test-d";h.style.cssText="position:absolute;top:-1000px";h.innerHTML="<style>@media("+d+":"+b["client"+a]+"px){body#vpw-test-b div#vpw-test-d{"+d+":7px!important}}</style>";g.appendChild(h);b.insertBefore(g,f.head);
|
||
|
a=7==h["offset"+a]?b["client"+a]:window["inner"+a];b.removeChild(g)}else a=window["inner"+a];return a}window.addEventListener("orientationchange",onOrientationChange);function onOrientationChange(){window.matchMedia("(orientation: portrait)").matches&&sizeHandler();window.matchMedia("(orientation: landscape)").matches&&sizeHandler()}function getIOSWindowHeight(){return document.documentElement.clientWidth/window.innerWidth*window.innerHeight}
|
||
|
function getHeightOfIOSToolbars(){var a=(0===window.orientation?screen.height:screen.width)-getIOSWindowHeight();return 1<a?a:0}
|
||
|
function sizeHandler(){window.scrollTo(0,1);if($("#canvas")){var a="safari"===platform.name.toLowerCase()?getIOSWindowHeight():getSize("Height");var d=getSize("Width");_checkOrientation(d,a);var f=Math.min(a/CANVAS_HEIGHT,d/CANVAS_WIDTH),b=CANVAS_WIDTH*f;f*=CANVAS_HEIGHT;if(f<a){var g=a-f;f+=g;b+=CANVAS_WIDTH/CANVAS_HEIGHT*g}else b<d&&(g=d-b,b+=g,f+=CANVAS_HEIGHT/CANVAS_WIDTH*g);g=a/2-f/2;var h=d/2-b/2,k=CANVAS_WIDTH/b;if(h*k<-EDGEBOARD_X||g*k<-EDGEBOARD_Y)f=Math.min(a/(CANVAS_HEIGHT-2*EDGEBOARD_Y),
|
||
|
d/(CANVAS_WIDTH-2*EDGEBOARD_X)),b=CANVAS_WIDTH*f,f*=CANVAS_HEIGHT,g=(a-f)/2,h=(d-b)/2,k=CANVAS_WIDTH/b;s_iOffsetX=-1*h*k;s_iOffsetY=-1*g*k;0<=g&&(s_iOffsetY=0);0<=h&&(s_iOffsetX=0);null!==s_oInterface&&s_oInterface.refreshButtonPos(s_iOffsetX,s_iOffsetY);null!==s_oMenu&&s_oMenu.refreshButtonPos(s_iOffsetX,s_iOffsetY);null!==s_oLevelMenu&&s_oLevelMenu.refreshButtonPos(s_iOffsetX,s_iOffsetY);s_bIsIphone?(canvas=document.getElementById("canvas"),s_oStage.canvas.width=2*b,s_oStage.canvas.height=2*f,canvas.style.width=
|
||
|
b+"px",canvas.style.height=f+"px",s_iScaleFactor=2*Math.min(b/CANVAS_WIDTH,f/CANVAS_HEIGHT),s_oStage.scaleX=s_oStage.scaleY=s_iScaleFactor):s_bMobile||isChrome()?($("#canvas").css("width",b+"px"),$("#canvas").css("height",f+"px")):(s_oStage.canvas.width=b,s_oStage.canvas.height=f,s_iScaleFactor=Math.min(b/CANVAS_WIDTH,f/CANVAS_HEIGHT),s_oStage.scaleX=s_oStage.scaleY=s_iScaleFactor);0>g||(g=(a-f)/2);$("#canvas").css("top",g+"px");$("#canvas").css("left",h+"px");fullscreenHandler()}}
|
||
|
function _checkOrientation(a,d){s_bMobile&&ENABLE_CHECK_ORIENTATION&&(a>d?"landscape"===$(".orientation-msg-container").attr("data-orientation")?($(".orientation-msg-container").css("display","none"),s_oMain.startUpdate()):($(".orientation-msg-container").css("display","block"),s_oMain.stopUpdate()):"portrait"===$(".orientation-msg-container").attr("data-orientation")?($(".orientation-msg-container").css("display","none"),s_oMain.startUpdate()):($(".orientation-msg-container").css("display","block"),
|
||
|
s_oMain.stopUpdate()))}function createBitmap(a,d,f){var b=new createjs.Bitmap(a),g=new createjs.Shape;d&&f?g.graphics.beginFill("#fff").drawRect(0,0,d,f):g.graphics.beginFill("#ff0").drawRect(0,0,a.width,a.height);b.hitArea=g;return b}function createSprite(a,d,f,b,g,h){a=null!==d?new createjs.Sprite(a,d):new createjs.Sprite(a);d=new createjs.Shape;d.graphics.beginFill("#000000").drawRect(-f,-b,g,h);a.hitArea=d;return a}
|
||
|
function randomFloatBetween(a,d,f){"undefined"===typeof f&&(f=2);return parseFloat(Math.min(a+Math.random()*(d-a),d).toFixed(f))}function shuffle(a){for(var d=a.length,f,b;0!==d;)b=Math.floor(Math.random()*d),--d,f=a[d],a[d]=a[b],a[b]=f;return a}function formatTime(a){a/=1E3;var d=Math.floor(a/60);a=parseFloat(a-60*d).toFixed(1);var f="";f=10>d?f+("0"+d+":"):f+(d+":");return 10>a?f+("0"+a):f+a}
|
||
|
function NoClickDelay(a){this.element=a;window.Touch&&this.element.addEventListener("touchstart",this,!1)}function shuffle(a){for(var d=a.length,f,b;0<d;)b=Math.floor(Math.random()*d),d--,f=a[d],a[d]=a[b],a[b]=f;return a}
|
||
|
NoClickDelay.prototype={handleEvent:function(a){switch(a.type){case "touchstart":this.onTouchStart(a);break;case "touchmove":this.onTouchMove(a);break;case "touchend":this.onTouchEnd(a)}},onTouchStart:function(a){a.preventDefault();this.moved=!1;this.element.addEventListener("touchmove",this,!1);this.element.addEventListener("touchend",this,!1)},onTouchMove:function(a){this.moved=!0},onTouchEnd:function(a){this.element.removeEventListener("touchmove",this,!1);this.element.removeEventListener("touchend",
|
||
|
this,!1);if(!this.moved){a=document.elementFromPoint(a.changedTouches[0].clientX,a.changedTouches[0].clientY);3==a.nodeType&&(a=a.parentNode);var d=document.createEvent("MouseEvents");d.initEvent("click",!0,!0);a.dispatchEvent(d)}}};
|
||
|
(function(){function a(a){var b={focus:"visible",focusin:"visible",pageshow:"visible",blur:"hidden",focusout:"hidden",pagehide:"hidden"};a=a||window.event;a.type in b?document.body.className=b[a.type]:(document.body.className=this[d]?"hidden":"visible","hidden"===document.body.className?s_oMain.stopUpdate():s_oMain.startUpdate())}var d="hidden";d in document?document.addEventListener("visibilitychange",a):(d="mozHidden")in document?document.addEventListener("mozvisibilitychange",a):(d="webkitHidden")in
|
||
|
document?document.addEventListener("webkitvisibilitychange",a):(d="msHidden")in document?document.addEventListener("msvisibilitychange",a):"onfocusin"in document?document.onfocusin=document.onfocusout=a:window.onpageshow=window.onpagehide=window.onfocus=window.onblur=a})();function ctlArcadeResume(){null!==s_oMain&&s_oMain.startUpdate()}function ctlArcadePause(){null!==s_oMain&&s_oMain.stopUpdate()}
|
||
|
function getParamValue(a){for(var d=window.location.search.substring(1).split("&"),f=0;f<d.length;f++){var b=d[f].split("=");if(b[0]==a)return b[1]}}function playSound(a,d,f){return!1===DISABLE_SOUND_MOBILE||!1===s_bMobile?(s_aSounds[a].play(),s_aSounds[a].volume(d),s_aSounds[a].loop(f),s_aSounds[a]):null}function stopSound(a){!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||s_aSounds[a].stop()}function setVolume(a,d){!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||s_aSounds[a].volume(d)}
|
||
|
function setMute(a,d){!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||s_aSounds[a].mute(d)}function saveItem(a,d){s_bStorageAvailable&&localStorage.setItem(a,d)}function getItem(a){return s_bStorageAvailable?localStorage.getItem(a):null}function fullscreenHandler(){ENABLE_FULLSCREEN&&!1!==screenfull.enabled&&(s_bFullscreen=screenfull.isFullscreen,null!==s_oInterface&&s_oInterface.resetFullscreenBut(),null!==s_oMenu&&s_oMenu.resetFullscreenBut(),null!==s_oLevelMenu&&s_oLevelMenu.resetFullscreenBut())}
|
||
|
if(screenfull.enabled)screenfull.on("change",function(){s_bFullscreen=screenfull.isFullscreen;null!==s_oInterface&&s_oInterface.resetFullscreenBut();null!==s_oMenu&&s_oMenu.resetFullscreenBut();null!==s_oLevelMenu&&s_oLevelMenu.resetFullscreenBut()});
|
||
|
function CSpriteLibrary(){var a={},d,f,b,g,h,k;this.init=function(a,c,p){d={};b=f=0;g=a;h=c;k=p};this.addSprite=function(b,c){if(!a.hasOwnProperty(b)){var g=new Image;a[b]=d[b]={szPath:c,oSprite:g,bLoaded:!1};f++}};this.getSprite=function(b){return a.hasOwnProperty(b)?a[b].oSprite:null};this._onSpritesLoaded=function(){f=0;h.call(k)};this._onSpriteLoaded=function(){g.call(k);++b===f&&this._onSpritesLoaded()};this.loadSprites=function(){for(var a in d)d[a].oSprite.oSpriteLibrary=this,d[a].oSprite.szKey=
|
||
|
a,d[a].oSprite.onload=function(){this.oSpriteLibrary.setLoaded(this.szKey);this.oSpriteLibrary._onSpriteLoaded(this.szKey)},d[a].oSprite.onerror=function(a){var c=a.currentTarget;setTimeout(function(){d[c.szKey].oSprite.src=d[c.szKey].szPath},500)},d[a].oSprite.src=d[a].szPath};this.setLoaded=function(b){a[b].bLoaded=!0};this.isLoaded=function(b){return a[b].bLoaded};this.getNumSprites=function(){return f}}
|
||
|
var CANVAS_WIDTH=960,CANVAS_HEIGHT=540,EDGEBOARD_X=128,EDGEBOARD_Y=42,FPS_TIME=1E3/24,DISABLE_SOUND_MOBILE=!1,FONT_GAME="Chewy",STATE_LOADING=0,STATE_MENU=1,STATE_HELP=1,STATE_GAME=3,ON_MOUSE_DOWN=0,ON_MOUSE_UP=1,ON_MOUSE_OVER=2,ON_MOUSE_OUT=3,ON_DRAG_START=4,ON_DRAG_END=5,ON_MSG_BOX_LEFT_BUT=6,ON_MSG_BOX_CENTER_BUT=7,ON_MSG_BOX_RIGHT_BUT=8,STATE_GAME_ROLL_IN=0,STATE_GAME_BALL_MOVE=1,STATE_GAME_ROLL_OUT=2,STATE_GAME_SHOOTING=3,STATE_GAME_ATTRACT_BALLS=4,STEP_LENGTH=1.8,BALL_COLORS=5,BALL_ROLLING_IN,
|
||
|
BALL_SHOOTED_SPEED=24,NUM_LEVELS,COMBO_VALUE,EXTRA_SCORE,BALL_DIAMETER,BALL_RADIUS,BALL_DIAMETER_SQUARE,NUM_ROWS_PAGE_LEVEL=3,NUM_COLS_PAGE_LEVEL=5,SOUNDTRACK_VOLUME_IN_GAME=1,ENABLE_FULLSCREEN,ENABLE_CHECK_ORIENTATION,TEXT_GAMEOVER="GAME OVER",TEXT_CONGRATS="CONGRATULATIONS",TEXT_PLAY="PLAY",TEXT_SCORE="SCORE",TEXT_LEVEL="LEVEL",TEXT_FINAL_SCORE="FINAL SCORE",TEXT_SELECT_LEVEL="SELECT A LEVEL",TEXT_DELETE_SAVINGS="ALL YOUR PROGRESS WILL BE CANCELLED! ARE YOU SURE?",TEXT_NO="NO",TEXT_YES="YES",TEXT_ERR_LS=
|
||
|
"YOUR WEB BROWSER DOES NOT SUPPORT STORING SETTING LOCALLY. IN SAFARI, THE MOST COMMON CAUSE OF THIS IS USING 'PRIVATE BROWSING MODE'. SOME INFO MAY NOT SAVE OR SOME FEATURE MAY NOT WORK PROPERLY.",TEXT_CREDITS_DEVELOPED="HOSTED BY",TEXT_PRELOADER_CONTINUE="START",TEXT_SHARE_IMAGE="200x200.jpg",TEXT_SHARE_TITLE="Congratulations!",TEXT_SHARE_MSG1="You collected <strong>",TEXT_SHARE_MSG2=" points</strong>!<br><br>Share your score with your friends!",TEXT_SHARE_SHARE1="My score is ",TEXT_SHARE_SHARE2=
|
||
|
" points! Can you do better";
|
||
|
function CPreloader(){var a,d,f,b,g,h,k,n,c,p;this._init=function(){s_oSpriteLibrary.init(this._onImagesLoaded,this._onAllImagesLoaded,this);s_oSpriteLibrary.addSprite("progress_bar","./sprites/progress_bar.png");s_oSpriteLibrary.addSprite("200x200","./sprites/200x200.jpg");s_oSpriteLibrary.addSprite("but_start","./sprites/but_start.png");s_oSpriteLibrary.loadSprites();p=new createjs.Container;s_oStage.addChild(p)};this.unload=function(){p.removeAllChildren();c.unload()};this._onImagesLoaded=function(){};
|
||
|
this._onAllImagesLoaded=function(){this.attachSprites();s_oMain.preloaderReady()};this.attachSprites=function(){var t=new createjs.Shape;t.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);p.addChild(t);t=s_oSpriteLibrary.getSprite("200x200");k=createBitmap(t);k.regX=.5*t.width;k.regY=.5*t.height;k.x=CANVAS_WIDTH/2;k.y=CANVAS_HEIGHT/2-150;p.addChild(k);n=new createjs.Shape;n.graphics.beginFill("rgba(0,0,0,0.01)").drawRoundRect(k.x-100,k.y-100,200,200,10);p.addChild(n);k.mask=n;
|
||
|
t=s_oSpriteLibrary.getSprite("progress_bar");b=createBitmap(t);b.x=CANVAS_WIDTH/2-t.width/2;b.y=CANVAS_HEIGHT/2+50;p.addChild(b);a=t.width;d=t.height;g=new createjs.Shape;g.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(b.x,b.y,1,d);p.addChild(g);b.mask=g;f=new createjs.Text("","30px "+FONT_GAME,"#fff");f.x=CANVAS_WIDTH/2;f.y=CANVAS_HEIGHT/2+100;f.textBaseline="alphabetic";f.textAlign="center";p.addChild(f);t=s_oSpriteLibrary.getSprite("but_start");c=new CTextButton(CANVAS_WIDTH/2,CANVAS_HEIGHT/
|
||
|
2,t,TEXT_PRELOADER_CONTINUE,"Arial","#000","bold 40",p);c.addEventListener(ON_MOUSE_UP,this._onButStartRelease,this);c.setVisible(!1);h=new createjs.Shape;h.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);p.addChild(h);createjs.Tween.get(h).to({alpha:0},500).call(function(){createjs.Tween.removeTweens(h);p.removeChild(h)})};this._onButStartRelease=function(){s_oMain._onRemovePreloader()};this.refreshLoader=function(c){f.text=c+"%";100===c&&(s_oMain._onRemovePreloader(),f.visible=
|
||
|
!1,b.visible=!1);g.graphics.clear();c=Math.floor(c*a/100);g.graphics.beginFill("rgba(0,0,0,0.01)").drawRect(b.x,b.y,c,d)};this._init()}
|
||
|
function CMain(a){var d,f=0,b=0,g=STATE_LOADING,h,k;this.initContainer=function(){var a=document.getElementById("canvas");s_oStage=new createjs.Stage(a);createjs.Touch.enable(s_oStage);s_bMobile=jQuery.browser.mobile;!1===s_bMobile&&s_oStage.enableMouseOver(20);s_iPrevTime=(new Date).getTime();createjs.Ticker.setFPS(35);createjs.Ticker.on("tick",this._update);navigator.userAgent.match(/Windows Phone/i)&&(DISABLE_SOUND_MOBILE=!0);s_oSpriteLibrary=new CSpriteLibrary;h=new CPreloader};this.setLocalStorageLevel=
|
||
|
function(a){s_iLastLevel<a&&(s_iLastLevel=a,saveItem("sorcerer_level",s_iLastLevel))};this.setLocalStorageScore=function(a,b,d){saveItem("score_level_"+d,a)};this.clearLocalStorage=function(){s_iLastLevel=1;s_bStorageAvailable&&localStorage.clear()};this.getScoreTillLevel=function(a){if(!s_bStorageAvailable)return 0;for(var c=0,b=0;b<a-1;b++)c+=parseInt(getItem("score_level_"+(b+1)));return c};this.preloaderReady=function(){this._loadImages();!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||this._initSounds();
|
||
|
d=!0};this.soundLoaded=function(){f++;h.refreshLoader(Math.floor(f/b*100))};this._initSounds=function(){Howler.mute(!s_bAudioActive);s_aSoundsInfo=[];s_aSoundsInfo.push({path:"./sounds/",filename:"win",loop:!1,volume:1,ingamename:"win"});s_aSoundsInfo.push({path:"./sounds/",filename:"press_but",loop:!1,volume:1,ingamename:"press_but"});s_aSoundsInfo.push({path:"./sounds/",filename:"game_over",loop:!1,volume:1,ingamename:"game_over"});s_aSoundsInfo.push({path:"./sounds/",filename:"combo",loop:!1,volume:1,
|
||
|
ingamename:"combo"});s_aSoundsInfo.push({path:"./sounds/",filename:"shot",loop:!1,volume:1,ingamename:"shot"});s_aSoundsInfo.push({path:"./sounds/",filename:"soundtrack",loop:!0,volume:1,ingamename:"soundtrack"});b+=s_aSoundsInfo.length;s_aSounds=[];for(var a=0;a<s_aSoundsInfo.length;a++)this.tryToLoadSound(s_aSoundsInfo[a],!1)};this.tryToLoadSound=function(a,b){setTimeout(function(){s_aSounds[a.ingamename]=new Howl({src:[a.path+a.filename+".mp3"],autoplay:!1,preload:!0,loop:a.loop,volume:a.volume,
|
||
|
onload:s_oMain.soundLoaded,onloaderror:function(a,c){for(var b=0;b<s_aSoundsInfo.length;b++)if(a===s_aSounds[s_aSoundsInfo[b].ingamename]._sounds[0]._id){s_oMain.tryToLoadSound(s_aSoundsInfo[b],!0);break}},onplayerror:function(a){for(var c=0;c<s_aSoundsInfo.length;c++)if(a===s_aSounds[s_aSoundsInfo[c].ingamename]._sounds[0]._id){s_aSounds[s_aSoundsInfo[c].ingamename].once("unlock",function(){s_aSounds[s_aSoundsInfo[c].ingamename].play();"soundtrack"===s_aSoundsInfo[c].ingamename&&null!==s_oGame&&
|
||
|
setVolume("soundtrack",SOUNDTRACK_VOLUME_IN_GAME)});break}}})},b?200:0)};this._loadImages=function(){s_oSpriteLibrary.init(this._onImagesLoaded,this._onAllImagesLoaded,this);s_oSpriteLibrary.addSprite("but_bg","./sprites/but_play_bg.png");s_oSpriteLibrary.addSprite("but_play","./sprites/but_play.png");s_oSpriteLibrary.addSprite("but_continue","./sprites/but_continue.png");s_oSpriteLibrary.addSprite("but_generic_small","./sprites/but_generic_small.png");s_oSpriteLibrary.addSprite("but_exit","./sprites/but_exit.png");
|
||
|
s_oSpriteLibrary.addSprite("bg_menu","./sprites/bg_menu.jpg");s_oSpriteLibrary.addSprite("audio_icon","./sprites/audio_icon.png");s_oSpriteLibrary.addSprite("hero","./sprites/hero.png");s_oSpriteLibrary.addSprite("hit_area","./sprites/hit_area.png");s_oSpriteLibrary.addSprite("explosion","./sprites/explosion.png");s_oSpriteLibrary.addSprite("msg_box","./sprites/msg_box.png");s_oSpriteLibrary.addSprite("extra_score","./sprites/extra_score.png");s_oSpriteLibrary.addSprite("end_path","./sprites/end_path.png");
|
||
|
s_oSpriteLibrary.addSprite("but_level","./sprites/but_level.png");s_oSpriteLibrary.addSprite("bg_menu_level","./sprites/bg_menu_level.jpg");s_oSpriteLibrary.addSprite("arrow_left","./sprites/arrow_left.png");s_oSpriteLibrary.addSprite("arrow_right","./sprites/arrow_right.png");s_oSpriteLibrary.addSprite("logo_ctl","./sprites/logo_ctl.png");s_oSpriteLibrary.addSprite("but_credits","./sprites/but_credits.png");s_oSpriteLibrary.addSprite("but_exit_small","./sprites/but_exit_small.png");s_oSpriteLibrary.addSprite("but_fullscreen",
|
||
|
"./sprites/but_fullscreen.png");for(var a=0;a<BALL_COLORS;a++)s_oSpriteLibrary.addSprite("ball_"+a,"./sprites/ball_"+a+".png");s_oSpriteLibrary.addSprite("bg_game_1","./sprites/bg_game_1.jpg");s_oSpriteLibrary.addSprite("bg_game_2","./sprites/bg_game_2.jpg");s_oSpriteLibrary.addSprite("bg_game_3","./sprites/bg_game_3.jpg");s_oSpriteLibrary.addSprite("bg_game_4","./sprites/bg_game_4.jpg");b+=s_oSpriteLibrary.getNumSprites();s_oSpriteLibrary.loadSprites()};this._onImagesLoaded=function(){f++;h.refreshLoader(Math.floor(f/
|
||
|
b*100))};this._onAllImagesLoaded=function(){};this._onRemovePreloader=function(){h.unload();jQuery.getJSON("levels.json",this.onLoadedJSON)};this.onLoadedJSON=function(a){try{saveItem("ls_available","ok")}catch(p){s_bStorageAvailable=!1}s_oLevelSettings=new CLevelSettings(a);s_oSoundTrack=playSound("soundtrack",1,!0);s_oMain.gotoMenu()};this.stopUpdate=function(){d=!1;createjs.Ticker.paused=!0;$("#block_game").css("display","block");!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||Howler.mute(!0)};this.startUpdate=
|
||
|
function(){s_iPrevTime=(new Date).getTime();d=!0;createjs.Ticker.paused=!1;$("#block_game").css("display","none");(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)&&s_bAudioActive&&Howler.mute(!1)};this.gotoMenu=function(){new CMenu;g=STATE_MENU};this.gotoLevelMenu=function(){new CLevelMenu};this.gotoGame=function(a,b){k=new CGame(n,a,b);g=STATE_GAME};this.gotoHelp=function(){new CHelp;g=STATE_HELP};this.levelSelected=function(a){a>=s_iLastLevel&&(s_iLastLevel=a);var c=this.getScoreTillLevel(a);this.gotoGame(a,
|
||
|
c)};this._update=function(a){if(!1!==d){var c=(new Date).getTime();s_iTimeElaps=c-s_iPrevTime;s_iCntTime+=s_iTimeElaps;s_iCntFps++;s_iPrevTime=c;1E3<=s_iCntTime&&(s_iCurFps=s_iCntFps,s_iCntTime-=1E3,s_iCntFps=0);g===STATE_GAME&&k.update();void 0!==s_oStage&&s_oStage.update(a)}};s_oMain=this;var n=a;ENABLE_FULLSCREEN=a.fullscreen;ENABLE_CHECK_ORIENTATION=a.check_orientation;this.initContainer()}
|
||
|
var s_bMobile,s_bAudioActive=!1,s_iCntTime=0,s_iTimeElaps=0,s_iPrevTime=0,s_iCntFps=0,s_iCurFps=0,s_oSoundTrack=null,s_oDrawLayer,s_oStage,s_oMain=null,s_oSpriteLibrary,s_oLevelSettings,s_iLastLevel=1,s_bFullscreen=!1,s_bStorageAvailable=!0,s_aSounds,s_aSoundsInfo;
|
||
|
function CTextButton(a,d,f,b,g,h,k,n){var c,p,t,r,x,m,y,u,B,D;this._init=function(a,b,d,f,g,m,h){c=!1;p=1;t=[];r=[];D=createBitmap(d);u=new createjs.Container;u.x=a;u.y=b;u.regX=d.width/2;u.regY=d.height/2;s_bMobile||(u.cursor="pointer");u.addChild(D,B);n.addChild(u);B=new CTLText(u,10,12,d.width-20,d.height-20,h,"center",m,g,1.1,0,0,f,!0,!0,!1,!1);this._initListener()};this.unload=function(){u.off("mousedown",x);u.off("pressup",m);n.removeChild(u)};this.setVisible=function(a){u.visible=a};this.setAlign=
|
||
|
function(a){B.textAlign=a};this.setTextX=function(a){B.x=a};this.setScale=function(a){p=u.scaleX=u.scaleY=a};this.enable=function(){c=!1};this.disable=function(){c=!0};this._initListener=function(){x=u.on("mousedown",this.buttonDown);m=u.on("pressup",this.buttonRelease)};this.addEventListener=function(a,c,b){t[a]=c;r[a]=b};this.addEventListenerWithParams=function(a,c,b,d){t[a]=c;r[a]=b;y=d};this.buttonRelease=function(){c||(playSound("press_but",1,!1),u.scaleX=p,u.scaleY=p,t[ON_MOUSE_UP]&&t[ON_MOUSE_UP].call(r[ON_MOUSE_UP],
|
||
|
y))};this.buttonDown=function(){c||(u.scaleX=.9*p,u.scaleY=.9*p,t[ON_MOUSE_DOWN]&&t[ON_MOUSE_DOWN].call(r[ON_MOUSE_DOWN]))};this.setPosition=function(a,c){u.x=a;u.y=c};this.tweenPosition=function(a,c,b,d,f,g,m){createjs.Tween.get(u).wait(d).to({x:a,y:c},b,f).call(function(){void 0!==g&&g.call(m)})};this.changeText=function(a){B.refreshText(a)};this.setX=function(a){u.x=a};this.setY=function(a){u.y=a};this.getButtonImage=function(){return u};this.getX=function(){return u.x};this.getY=function(){return u.y};
|
||
|
this.getSprite=function(){return u};this.getScale=function(){return u.scaleX};this._init(a,d,f,b,g,h,k)}
|
||
|
function CGfxButton(a,d,f){var b,g,h=[],k,n,c;this._init=function(a,d,f){b=[];g=[];c=createBitmap(f);c.x=a;c.y=d;c.regX=f.width/2;c.regY=f.height/2;c.cursor="pointer";s_oStage.addChild(c);this._initListener()};this.unload=function(){c.off("mousedown",k);c.off("pressup",n);s_oStage.removeChild(c)};this.setVisible=function(a){c.visible=a};this._initListener=function(){k=c.on("mousedown",this.buttonDown);n=c.on("pressup",this.buttonRelease)};this.addEventListener=function(a,c,d){b[a]=c;g[a]=d};this.addEventListenerWithParams=
|
||
|
function(a,c,d,f){b[a]=c;g[a]=d;h=f};this.buttonRelease=function(){playSound("press_but",1,!1);c.scaleX=1;c.scaleY=1;b[ON_MOUSE_UP]&&b[ON_MOUSE_UP].call(g[ON_MOUSE_UP],h)};this.buttonDown=function(){c.scaleX=.9;c.scaleY=.9;b[ON_MOUSE_DOWN]&&b[ON_MOUSE_DOWN].call(g[ON_MOUSE_DOWN],h)};this.setPosition=function(a,b){c.x=a;c.y=b};this.setX=function(a){c.x=a};this.setY=function(a){c.y=a};this.getButtonImage=function(){return c};this.getX=function(){return c.x};this.getY=function(){return c.y};this._init(a,
|
||
|
d,f);return this}
|
||
|
function CToggle(a,d,f,b){var g,h,k,n,c,p;this._init=function(a,c,b,d){h=[];k=[];var f=new createjs.SpriteSheet({images:[b],frames:{width:b.width/2,height:b.height,regX:b.width/2/2,regY:b.height/2},animations:{state_true:[0],state_false:[1]}});g=d;p=createSprite(f,"state_"+g,b.width/2/2,b.height/2,b.width/2,b.height);p.x=a;p.y=c;p.stop();p.cursor="pointer";s_oStage.addChild(p);this._initListener()};this.unload=function(){p.off("mousedown",n);p.off("pressup",c);s_oStage.removeChild(p)};this._initListener=
|
||
|
function(){n=p.on("mousedown",this.buttonDown);c=p.on("pressup",this.buttonRelease)};this.addEventListener=function(a,c,b){h[a]=c;k[a]=b};this.setActive=function(a){g=a;p.gotoAndStop("state_"+g)};this.buttonRelease=function(){p.scaleX=1;p.scaleY=1;playSound("press_but",1,!1);g=!g;p.gotoAndStop("state_"+g);h[ON_MOUSE_UP]&&h[ON_MOUSE_UP].call(k[ON_MOUSE_UP],g)};this.buttonDown=function(){p.scaleX=.9;p.scaleY=.9;h[ON_MOUSE_DOWN]&&h[ON_MOUSE_DOWN].call(k[ON_MOUSE_DOWN])};this.setPosition=function(a,c){p.x=
|
||
|
a;p.y=c};this._init(a,d,f,b)}
|
||
|
function CMenu(){var a,d,f,b,g,h,k,n,c=null,p,t,r,x,m=null,y=null;this._init=function(){k=createBitmap(s_oSpriteLibrary.getSprite("bg_menu"));s_oStage.addChild(k);if(s_bStorageAvailable){var u=getItem("sorcerer_level");null!==u&&void 0!==u?s_iLastLevel=parseInt(getItem("sorcerer_level")):saveItem("sorcerer_level",1)}else new CAlertSavingBox(TEXT_ERR_LS,s_oStage);1===s_iLastLevel?(n=new CGfxButton(CANVAS_WIDTH/2,CANVAS_HEIGHT-120,s_oSpriteLibrary.getSprite("but_play"),!0),n.addEventListener(ON_MOUSE_UP,
|
||
|
this._onButPlayRelease,this)):(n=new CGfxButton(CANVAS_WIDTH/2-150,CANVAS_HEIGHT-120,s_oSpriteLibrary.getSprite("but_play"),!0),n.addEventListener(ON_MOUSE_UP,this._onButPlayRelease,this),c=new CGfxButton(CANVAS_WIDTH/2+150,CANVAS_HEIGHT-120,s_oSpriteLibrary.getSprite("but_continue"),!0),c.addEventListener(ON_MOUSE_UP,this._onButContinueRelease,this));if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)u=s_oSpriteLibrary.getSprite("audio_icon"),g=CANVAS_WIDTH-u.height/2,h=u.height/2,p=new CToggle(g,h,u,
|
||
|
s_bAudioActive),p.addEventListener(ON_MOUSE_UP,this._onAudioToggle,this);u=s_oSpriteLibrary.getSprite("but_credits");f=u.height/2+10;b=u.height/2+10;t=new CGfxButton(f,b,u,s_oStage);t.addEventListener(ON_MOUSE_UP,this._onButCreditsRelease,this);u=window.document;var B=u.documentElement;m=B.requestFullscreen||B.mozRequestFullScreen||B.webkitRequestFullScreen||B.msRequestFullscreen;y=u.exitFullscreen||u.mozCancelFullScreen||u.webkitExitFullscreen||u.msExitFullscreen;!1===ENABLE_FULLSCREEN&&(m=!1);m&&
|
||
|
screenfull.enabled&&(u=s_oSpriteLibrary.getSprite("but_fullscreen"),a=f+u.width/2+10,d=b-2,x=new CToggle(a,d,u,s_bFullscreen,s_oStage),x.addEventListener(ON_MOUSE_UP,this._onFullscreenRelease,this));r=new createjs.Shape;r.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);s_oStage.addChild(r);createjs.Tween.get(r).to({alpha:0},400).call(function(){r.visible=!1});this.refreshButtonPos(s_iOffsetX,s_iOffsetY)};this.unload=function(){n.unload();n=null;t.unload();null!==c&&c.unload();
|
||
|
if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)p.unload(),p=null;m&&screenfull.enabled&&x.unload();s_oStage.removeChild(k);k=null;s_oStage.removeChild(r);s_oMenu=r=null};this.refreshButtonPos=function(c,k){!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||p.setPosition(g-c,k+h);m&&screenfull.enabled&&x.setPosition(a+c,d+k);t.setPosition(f+c,b+k)};this._exitFromMenu=function(){this.unload();s_oMain.gotoLevelMenu();$(s_oMain).trigger("start_session")};this._onButPlayRelease=function(){if(1<s_iLastLevel){var a=
|
||
|
new CMsgBox(TEXT_DELETE_SAVINGS,TEXT_NO,"",TEXT_YES);a.addEventListener(ON_MSG_BOX_LEFT_BUT,function(){a.hide()},this);a.addEventListener(ON_MSG_BOX_RIGHT_BUT,function(){a.hide();s_oMain.clearLocalStorage();s_oMenu._exitFromMenu()},this)}else s_oMenu._exitFromMenu()};this._onButContinueRelease=function(){s_oMenu._exitFromMenu()};this._onButCreditsRelease=function(){new CCreditsPanel};this._onAudioToggle=function(){Howler.mute(s_bAudioActive);s_bAudioActive=!s_bAudioActive};this.resetFullscreenBut=
|
||
|
function(){m&&screenfull.enabled&&x.setActive(s_bFullscreen)};this._onFullscreenRelease=function(){s_bFullscreen?y.call(window.document):m.call(window.document.documentElement);sizeHandler()};s_oMenu=this;this._init()}var s_oMenu=null;
|
||
|
function CGame(a,d,f){var b=!1,g,h,k,n,c,p,t,r,x=-1,m,y,u,B,D,H,E,l,q,F,C,J=null,T=null,Q=null,G,K,M,R,N,S,I;this._init=function(a,e){E=a;n=e;s_oBezier=new CBezier;I=new createjs.Container;K=createBitmap(s_oSpriteLibrary.getSprite(s_oLevelSettings.getBgForLevel(E)));I.addChild(K);s_oStage.addChild(I);K.cache(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);G=new CHero;N=new createjs.Container;R=new createjs.Container;S=new createjs.Container;s_oStage.addChild(N);s_oStage.addChild(R);s_oStage.addChild(S);M=new CInterface(n);
|
||
|
this.reset();if(!1===s_bMobile){var c=this;s_oStage.addEventListener("stagemousemove",function(a){c._onMouseMove(a.stageX,a.stageY)})}b=!0};this.unload=function(){b=!1;clearInterval(u);M.unload();G.unload();s_oStage.removeAllChildren()};this.reset=function(){g=!0;k=h=!1;r=s_oLevelSettings.getBallSpeedForLevel(E);t=s_oLevelSettings.getBallNumberForLevel(E);D=s_oLevelSettings.getBallColorsForLevel(E);BALL_ROLLING_IN=Math.floor(.33*t);m=0;p=y=1;c=H=0;G.reset(s_oLevelSettings.getHeroPosForLevel(E),D);
|
||
|
null!==T&&(N.removeChild(T),N.removeChild(Q));this._initCurve();this._initBall();M.refreshLevel(E);$(s_oMain).trigger("start_level",E)};this._normalize=function(a){var e=this._length(a);return 0<e?{x:a.x/e,y:a.y/e}:a};this._length=function(a){return Math.sqrt(a.x*a.x+a.y*a.y)};this._dotProductV2=function(a,e){return a.x*e.x+a.y*e.y};this._angleBetweenVectors=function(a,e){var c=Math.acos(this._dotProductV2(a,e)/(this._length(a)*this._length(e)));return!0===isNaN(c)?0:c};this._rot90CW=function(a){return{x:a.y,
|
||
|
y:-a.x}};this._rot90CCW=function(a){return{x:-a.y,y:a.x}};this._rotateVector2D=function(a,e){return{x:e.x*Math.cos(a)+e.y*Math.sin(a),y:e.x*-Math.sin(a)+e.y*Math.cos(a)}};this._initCurve=function(){var a;var e=s_oLevelSettings.getCurveForLevel(E);var c=new createjs.Graphics;q=[];for(a=0;a<e.length-2;++a){var b=0===a?new createjs.Point(e[0][0],e[0][1]):new createjs.Point((e[a][0]+e[a+1][0])/2,(e[a][1]+e[a+1][1])/2),d=new createjs.Point(e[a+1][0],e[a+1][1]),f=a<=e.length-4?new createjs.Point((e[a+1][0]+
|
||
|
e[a+2][0])/2,(e[a+1][1]+e[a+2][1])/2):new createjs.Point(e[a+2][0],e[a+2][1]);b=s_oBezier.init(b,d,f,STEP_LENGTH);for(d=1;d<=b;++d)f=s_oBezier.getAnchorPoint(d),q.push(f)}c.setStrokeStyle(4);c.beginStroke("#00a29b");c.beginFill("#221910");b={x:q[1][0]-q[0][0],y:q[1][1]-q[0][1]};b=this._normalize(b);b=this._rot90CW(b);b.x*=15;b.y*=15;b.x+=q[0][0];b.y+=q[0][1];e=b.x;a=b.y;c.moveTo(b.x,b.y);for(d=1;d<q.length-1;d++)b={x:q[d+1][0]-q[d][0],y:q[d+1][1]-q[d][1]},b=this._normalize(b),b=this._rot90CW(b),b.x*=
|
||
|
15,b.y*=15,b.x+=q[d][0],b.y+=q[d][1],c.lineTo(b.x,b.y);c.lineTo(b.x,b.y);b={x:q[q.length-1][0]-q[q.length-2][0],y:q[q.length-1][1]-q[q.length-2][1]};b=this._normalize(b);b=this._rot90CCW(b);b.x*=15;b.y*=15;b.x+=q[q.length-1][0];b.y+=q[q.length-1][1];c.lineTo(b.x,b.y);for(d=q.length-2;1<d;d--)b={x:q[d][0]-q[d-1][0],y:q[d][1]-q[d-1][1]},b=this._normalize(b),b=this._rot90CCW(b),b.x*=15,b.y*=15,b.x+=q[d][0],b.y+=q[d][1],c.lineTo(b.x,b.y);c.lineTo(e,a);c.endFill();T=new createjs.Shape(c);N.addChild(T);
|
||
|
c=q.length;e=s_oSpriteLibrary.getSprite("end_path");Q=createBitmap(e);Q.x=q[c-9][0];Q.y=q[c-9][1];Q.regX=e.width/2;Q.regY=e.height/2;N.addChild(Q);N.cache(0,0,CANVAS_WIDTH,CANVAS_HEIGHT)};this._initBall=function(){l=[];var a=this.getRandomBall();l.unshift(a);a.setPos(16,q);x=STATE_GAME_ROLL_IN};this.getRandomBall=function(){t--;return new CBall(Math.floor(Math.random()*D),R)};this._pushNextBall=function(a,b){var c=[];c.push(l[a]);for(var e=a;e<l.length-1;++e)if(16>=l[e+1].getFotogram()-l[e].getFotogram())16>
|
||
|
l[e+1].getFotogram()-l[e].getFotogram()&&l[e+1].setPos(l[e].getFotogram()+16,q),c.push(l[e+1]);else break;for(e=0;e<c.length;++e)c[e].increasePos(b,q);if(l[l.length-1].getFotogram()>=q.length-17){g=!1;if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)s_aSounds.soundtrack.pause(),playSound("game_over",1,!1).on("end",this._onSoundGameOverComplete);s_oStage.removeEventListener("stagemousemove");k=h=!1;p=1;l[l.length-1].unload();l.splice(l.length-1,1);x=STATE_GAME_ROLL_OUT}};this.onIntroduceBall=function(){if(0!==
|
||
|
l.length&&(s_oGame._pushNextBall(0,1),32===l[0].getFotogram()&&0!==t)){var a=s_oGame.getRandomBall();l.unshift(a);a.setPos(16,q)}};this.shoot=function(){playSound("shot",1,!1);var a=(G.getRotation()+90)*Math.PI/180,b=G.getCurrentBall();b.changePos(G.getX()+60*Math.cos(a),G.getY()+60*Math.sin(a));R.addChild(b.getSprite());b.setContainer(R);F.push([b,a]);x=STATE_GAME_SHOOTING};this._checkCollision=function(a){a=a[0];for(var b=0;b<l.length;++b)if((l[b].getX()-a.getX())*(l[b].getX()-a.getX())+(l[b].getY()-
|
||
|
a.getY())*(l[b].getY()-a.getY())<=BALL_DIAMETER_SQUARE)return b;return-1};this._insertBall=function(a,b,c){if("next"===c){var e=l[b].getFotogram()+16;l[b+1]&&32>l[b+1].getFotogram()-l[b].getFotogram()&&(C.push([a,l[b+1]]),h=!0)}else l[b-1]&&32>l[b].getFotogram()-l[b-1].getFotogram()?(e=l[b-1].getFotogram()+16,C.push([a,l[b]]),h=!0):e=l[b].getFotogram()-16;b=q[e][0];c=q[e][1];var d=this;createjs.Tween.get(a.getSprite()).to({x:b,y:c},200).call(function(){d.motionFinished(a,e)})};this.motionFinished=
|
||
|
function(a,b){for(var c,e=0;e<l.length;++e){if(l[e].getFotogram()>b){c=e;break}e===l.length-1&&(c=e+1)}C.splice(C.indexOf(a),1);a.setPos(b,q);l.splice(c,0,a);l[c-1]&&l[c-1].getIndex()===l[c].getIndex()&&17<l[c].getFotogram()-l[c-1].getFotogram()&&this._addToBallAttracted(l[c]);l[c+1]&&l[c+1].getIndex()===l[c].getIndex()&&17<l[c+1].getFotogram()-l[c].getFotogram()&&this._addToBallAttracted(l[c+1]);this._clearCheck(c,!0)};this._addToBallAttracted=function(a){null===J&&(J=[]);J.push(a);setTimeout(function(){k=
|
||
|
!0},400)};this._clearCheck=function(a,b){var c=[];c.push(l[a]);for(var e=l[a].getIndex(),d=a+1;l[d];)if(l[d].getIndex()===e)if(17>=l[d].getFotogram()-l[d-1].getFotogram())c.push(l[d]),++d;else if(b)break;else c.push(l[d]),++d;else break;for(d=a-1;l[d];)if(l[d].getIndex()===e)if(17>=l[d+1].getFotogram()-l[d].getFotogram())c.push(l[d]),--d;else if(b)break;else c.push(l[d]),--d;else break;++d;2<c.length&&b&&this._clearBall(d,c);return c.length};this._attract=function(){if(0!==J.length)for(var a=0;a<
|
||
|
J.length;++a){var b=l.indexOf(J[a]);if(-1!==b&&l[b-1])if(J[a].getIndex()===l[b-1].getIndex()){var c=19<J[a].getFotogram()-l[b-1].getFotogram()?3:J[a].getFotogram()-l[b-1].getFotogram()-16;this._pushNextBall(b,-c);16>=J[a].getFotogram()-l[b-1].getFotogram()&&(p++,J.splice(a,1),this._clearCheck(b-1,!0),0===J.length&&(k=!1,p=1))}else J.splice(a,1),m>y&&(y=m),m=0}else k=!1,p=1};this._checkPushCollision=function(){if(0!==C.length)for(var a=0;a<C.length;++a){var b=(C[a][0].getX()-C[a][1].getX())*(C[a][0].getX()-
|
||
|
C[a][1].getX())+(C[a][0].getY()-C[a][1].getY())*(C[a][0].getY()-C[a][1].getY());b=b<BALL_DIAMETER_SQUARE?!0:!1;for(var c=0;b;)++c,b=(C[a][0].getX()-q[C[a][1].getFotogram()+c][0])*(C[a][0].getX()-q[C[a][1].getFotogram()+c][0])+(C[a][0].getY()-q[C[a][1].getFotogram()+c][1])*(C[a][0].getY()-q[C[a][1].getFotogram()+c][1]),b=b<BALL_DIAMETER_SQUARE?!0:!1;b=l.indexOf(C[a][1]);-1!==b&&this._pushNextBall(b,c)}else h=!1};this._clearBall=function(a,b){++m;playSound("combo",1,!1);for(var e=0,d=0;d<b.length;++d)b[d].explode(),
|
||
|
e+=COMBO_VALUE;e*=p;n+=e;c+=e;M.refreshScore(n);l.length===b.length&&(g=!1,B=l[l.length-1].getFotogram(),setTimeout(this._gamePass,600),!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)&&(s_aSounds.soundtrack.pause(),playSound("win",1,!1).on("end",this._onSoundGameOverComplete));l.splice(a,b.length);0===t&&this._checkColor(b[0].getIndex());l[a-1]&&l[a]&&l[a-1].getIndex()===l[a].getIndex()?(3>this._clearCheck(a,!1)&&(m>y&&(y=m),m=0),this._addToBallAttracted(l[a])):(m>y&&(y=m),m=0)};this._gamePass=function(){u=
|
||
|
setInterval(s_oGame._extraScore,r)};this._extraScore=function(){B+16<q.length-17?(B+=16,new CExtraScore(q[B][0],q[B][1],S),n+=EXTRA_SCORE,c+=EXTRA_SCORE,M.refreshScore(n)):($(s_oMain).trigger("end_level",E),clearInterval(u),s_oStage.removeEventListener("stagemousemove"),g=!1,s_oMain.setLocalStorageScore(c,n,E),E++,E>s_oLevelSettings.getNumLevels()?(E--,M.win(n)):(s_oMain.setLocalStorageLevel(E),M.nextLevel(E,n)))};this._checkColor=function(a){for(var b=0;b<l.length;++b)if(l[b].getIndex()===a)return;
|
||
|
for(b=0;b<F.length;++b)if(F[b].getIndex()===a)return;G.colorCleared(a)};this.nextLevel=function(){I.removeChild(K);K=createBitmap(s_oSpriteLibrary.getSprite(s_oLevelSettings.getBgForLevel(E)));I.addChild(K);this.reset();b=!0};this.onShot=function(a,b){if(g&&G.canShoot()){if(s_bMobile){var c=a-G.getX()*s_iScaleFactor,d=b-G.getY()*s_iScaleFactor;G.rotate(180*Math.atan2(d,c)/Math.PI-90)}this.shoot()}};this._onMouseMove=function(a,b){var c=a-G.getX()*s_iScaleFactor,d=b-G.getY()*s_iScaleFactor;G.rotate(180*
|
||
|
Math.atan2(d,c)/Math.PI-90)};this.onExit=function(){this.unload();s_oMain.gotoMenu();$(s_oMain).trigger("end_session");$(s_oMain).trigger("share_event",n)};this._onSoundGameOverComplete=function(){playSound("soundtrack",1,!0)};this._updateMove=function(){H+=s_iTimeElaps;H>r&&(H=0,this.onIntroduceBall())};this._updateRollOut=function(){for(var a=l.length-1;0<=a;--a)l[a].getFotogram()>q.length-17?(l[a].unload(),l.splice(a,1),0===l.length&&(x=-1,M.gameOver(n))):l[a].increasePos(8,q)};this._updateRollIn=
|
||
|
function(){if(l.length<BALL_ROLLING_IN){for(var a=0;a<l.length;++a)l[a].increasePos(4,q);32===l[0].getFotogram()&&(a=this.getRandomBall(),l.unshift(a),a.setPos(16,q))}else x=-1,F=[],C=[],G.start(),x=STATE_GAME_BALL_MOVE};this._updateShooting=function(){if(0!==F.length)for(var a=0;a<F.length;++a)if(0<F[a][0].getX()&&F[a][0].getX()<CANVAS_WIDTH&&0<F[a][0].getY()&&F[a][0].getY()<CANVAS_HEIGHT){var b=this._checkCollision(F[a]);if(-1===b)F[a][0].increasePosWithNumbers(Math.cos(F[a][1])*BALL_SHOOTED_SPEED,
|
||
|
Math.sin(F[a][1])*BALL_SHOOTED_SPEED);else{var c=F[a][0],d=F[a][1],f=Math.sqrt((l[b].getX()-c.getX())*(l[b].getX()-c.getX())+(l[b].getY()-c.getY())*(l[b].getY()-c.getY()));F[a][0].decreasePos((BALL_DIAMETER-f)*Math.cos(d),(BALL_DIAMETER-f)*Math.sin(d));d=q[l[b].getFotogram()-BALL_RADIUS][0];f=q[l[b].getFotogram()-BALL_RADIUS][1];d=Math.sqrt((c.getX()-d)*(c.getX()-d)+(c.getY()-f)*(c.getY()-f));f=q[l[b].getFotogram()+BALL_RADIUS][0];var g=q[l[b].getFotogram()+BALL_RADIUS][1];c=Math.sqrt((c.getX()-f)*
|
||
|
(c.getX()-f)+(c.getY()-g)*(c.getY()-g));this._insertBall(F[a][0],b,d>c?"next":"previous");F.splice(a,1)}}else F[a][0].unload(),F.splice(a,1);else x=-1};this.update=function(){if(!1!==b)switch(!0===k&&this._attract(),!0===h&&this._checkPushCollision(),x){case STATE_GAME_ROLL_IN:this._updateRollIn();break;case STATE_GAME_ROLL_OUT:this._updateRollOut();break;case STATE_GAME_SHOOTING:this._updateShooting();this._updateMove();break;default:this._updateMove()}};s_oGame=this;COMBO_VALUE=a.combo_value;EXTRA_SCORE=
|
||
|
a.extra_score;this._init(d,f)}var s_oGame,s_oBezier;
|
||
|
function CInterface(a){var d,f,b,g,h,k,n,c,p,t,r,x,m,y,u,B,D,H,E=null,l=null;this._init=function(a){c=n=10;x=new createjs.Text(TEXT_SCORE+" "+a,"38px "+FONT_GAME,"#fff");x.x=n;x.y=c;x.textAlign="left";s_oStage.addChild(x);h=10;k=50;r=new createjs.Text(TEXT_LEVEL+" "+s_iLastLevel,"30px "+FONT_GAME,"#fff");r.x=h;r.y=k;r.textAlign="left";s_oStage.addChild(r);var q=this;y=createBitmap(s_oSpriteLibrary.getSprite("hit_area"));s_oStage.addChild(y);y.on("pressup",function(a){q._onTapScreen(a.stageX,a.stageY)});
|
||
|
a=s_oSpriteLibrary.getSprite("but_exit");d=CANVAS_WIDTH-a.width/2;f=a.height/2+4;m=new CGfxButton(d,f,a,!0);m.addEventListener(ON_MOUSE_UP,this._onExit,this);!1===DISABLE_SOUND_MOBILE||!1===s_bMobile?(p=d-a.width,t=a.height/2+4,a=s_oSpriteLibrary.getSprite("audio_icon"),u=new CToggle(p,t,a,s_bAudioActive),u.addEventListener(ON_MOUSE_UP,this._onAudioToggle,this),b=p-a.width/2,g=t):(b=m.getX()-a.width,g=a.height/2+4);a=window.document;var C=a.documentElement;E=C.requestFullscreen||C.mozRequestFullScreen||
|
||
|
C.webkitRequestFullScreen||C.msRequestFullscreen;l=a.exitFullscreen||a.mozCancelFullScreen||a.webkitExitFullscreen||a.msExitFullscreen;!1===ENABLE_FULLSCREEN&&(E=!1);E&&screenfull.enabled&&(a=s_oSpriteLibrary.getSprite("but_fullscreen"),H=new CToggle(b,g,a,s_bFullscreen,s_oStage),H.addEventListener(ON_MOUSE_UP,this._onFullscreenRelease,this));D=new CNextLevel;B=new CEndPanel(s_oSpriteLibrary.getSprite("msg_box"));this.refreshButtonPos(s_iOffsetX,s_iOffsetY)};this.unload=function(){m.unload();m=null;
|
||
|
!1===DISABLE_SOUND_MOBILE&&(u.unload(),u=null);E&&screenfull.enabled&&H.unload();s_oStage.removeAllChildren();s_oInterface=null};this.refreshButtonPos=function(a,l){x.x=n+a;x.y=c+l;r.x=h+a;r.y=k+l;m.setPosition(d-a,f+l);!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||u.setPosition(p-a,l+t);E&&screenfull.enabled&&H.setPosition(b-a,g+l)};this._onTapScreen=function(a,b){s_oGame.onShot(a,b)};this.gameOver=function(a){B.show(a,!1)};this.win=function(a){B.show(a,!0)};this.nextLevel=function(a,b){D.show(a,b)};
|
||
|
this.refreshScore=function(a){x.text=TEXT_SCORE+" "+a};this.refreshLevel=function(a){r.text=TEXT_LEVEL+" "+a};this._onExit=function(){s_oGame.onExit()};this._onAudioToggle=function(){Howler.mute(s_bAudioActive);s_bAudioActive=!s_bAudioActive};this.resetFullscreenBut=function(){E&&screenfull.enabled&&H.setActive(s_bFullscreen)};this._onFullscreenRelease=function(){s_bFullscreen?l.call(window.document):E.call(window.document.documentElement);sizeHandler()};s_oInterface=this;this._init(a);return this}
|
||
|
var s_oInterface=null;
|
||
|
function CEndPanel(a){var d,f,b,g,h,k;this._init=function(a){k=new createjs.Container;k.alpha=0;k.visible=!1;s_oStage.addChild(k);d=createBitmap(a);k.addChild(d);h=new CTLText(k,CANVAS_WIDTH/2-80,CANVAS_HEIGHT/2-68,210,30,50,"center","#000",FONT_GAME,1.1,0,0,TEXT_CONGRATS,!0,!0,!0,!1);g=new CTLText(k,CANVAS_WIDTH/2-80,CANVAS_HEIGHT/2-68,210,30,50,"center","#fff",FONT_GAME,1.1,0,0,TEXT_CONGRATS,!0,!0,!0,!1);f=new CTLText(k,CANVAS_WIDTH/2-80,CANVAS_HEIGHT/2-15,200,70,50,"center","#000",FONT_GAME,1.1,
|
||
|
0,0,TEXT_FINAL_SCORE+"\n99999",!0,!0,!0,!1);b=new CTLText(k,CANVAS_WIDTH/2-80,CANVAS_HEIGHT/2-15,200,70,50,"center","#fff",FONT_GAME,1.1,0,0,TEXT_FINAL_SCORE+"\n99999",!0,!0,!0,!1)};this.unload=function(){k.off("mousedown",this._onExit);s_oStage.removeChild(k)};this._initListener=function(){k.on("mousedown",this._onExit);$(s_oMain).trigger("show_interlevel_ad")};this.show=function(a,c){c?(h.refreshText(TEXT_CONGRATS),g.refreshText(TEXT_CONGRATS)):(h.refreshText(TEXT_GAMEOVER),g.refreshText(TEXT_GAMEOVER));
|
||
|
f.refreshText(TEXT_FINAL_SCORE+"\n "+a);b.refreshText(TEXT_FINAL_SCORE+"\n "+a);k.visible=!0;var d=this;createjs.Tween.get(k).to({alpha:1},500).call(function(){d._initListener()});$(s_oMain).trigger("save_score",a)};this._onExit=function(){k.off("mousedown");s_oGame.onExit()};this._init(a);return this}
|
||
|
function CTweenController(){this.tweenValue=function(a,d,f){return a+f*(d-a)};this.easeLinear=function(a,d,f,b){return f*a/b+d};this.easeInCubic=function(a,d,f,b){b=(a/=b)*a*a;return d+f*b};this.easeBackInQuart=function(a,d,f,b){b=(a/=b)*a;return d+f*(2*b*b+2*b*a+-3*b)};this.easeInBack=function(a,d,f,b){return f*(a/=b)*a*(2.70158*a-1.70158)+d};this.easeOutCubic=function(a,d,f,b){return f*((a=a/b-1)*a*a+1)+d}}
|
||
|
function CLevelSettings(a){var d,f,b,g,h,k,n;this._init=function(a){d=a;NUM_LEVELS=Object.keys(d).length;trace("NUM_LEVELS: "+NUM_LEVELS);this._initBallSpeed();this._initBallNumber();this._initBallColors();this._initHeroPos();this._initCurveLevel();this._initBgLevel()};this._initBallSpeed=function(){f=[];for(var a=0;a<NUM_LEVELS;a++)f[a]=d[a].ball_speed};this._initBallNumber=function(){b=[];for(var a=0;a<NUM_LEVELS;a++)b[a]=d[a].ball_number};this._initBallColors=function(){g=[];for(var a=0;a<NUM_LEVELS;a++)g[a]=
|
||
|
d[a].num_colors};this._initHeroPos=function(){h=[];for(var a=0;a<NUM_LEVELS;a++)h[a]=new createjs.Point(d[a].hero_pos.x,d[a].hero_pos.y)};this._initCurveLevel=function(){k=[];for(var a=0;a<NUM_LEVELS;a++){k[a]=[];for(var b=d[a].curve_point,f=0;f<b.length;f++)k[a].push([b[f].x,b[f].y])}};this._initBgLevel=function(){n=[];for(var a=0;a<NUM_LEVELS;a++)n[a]=d[a].bg_image};this.getBallSpeedForLevel=function(a){return f[a-1]};this.getBallNumberForLevel=function(a){return b[a-1]};this.getBallColorsForLevel=
|
||
|
function(a){return g[a-1]};this.getHeroPosForLevel=function(a){return h[a-1]};this.getCurveForLevel=function(a){return k[a-1]};this.getNumLevels=function(){return k.length};this.getBgForLevel=function(a){return n[a-1]};this._init(a)}
|
||
|
function CHero(){var a=!1,d,f,b,g,h,k,n,c,p,t;this._init=function(){var a=s_oSpriteLibrary.getSprite("hero");t=new createjs.Container;t.regX=a.width/2;t.regY=a.height/2;s_oStage.addChild(t);n=createBitmap(a);n.x=0;n.y=0;t.addChild(n);c=new createjs.Shape;c.graphics.beginFill("rgba(255,0,0,0.01)").drawCircle(40,110,16);t.addChild(c);p=new createjs.Shape;p.graphics.beginFill("rgba(255,0,0,0.01)").drawCircle(120,60,6);t.addChild(p);d=a.width;f=a.height};this.reset=function(a,c){b=c;void 0!==h&&null!==
|
||
|
h&&h.unload();void 0!==k&&null!==k&&k.unload();t.x=a.x;t.y=a.y;g=[];for(var d=0;d<b;d++)g[d]=!0};this.unload=function(){};this.rotate=function(a){t.rotation=a};this.start=function(){h=this._getRandomBall();h.changePos(d/2-25,f/2+20);h.getSprite().mask=c;k=this._getRandomBall();k.changePos(120,f/2-12);k.getSprite().mask=p;var a=this;createjs.Tween.get(h.getSprite()).to({y:h.getY()+25},300).call(function(){a._onBallReady()});createjs.Tween.get(k.getSprite()).to({y:k.getY()+16},300)};this._getRandomBall=
|
||
|
function(){if(!0===this._checkIfAllColorsNotAvailable())return null;do{var a=Math.floor(Math.random()*b),c=!1;if(!0===g[a]){var d=new CBall(a,t);break}}while(!1===c);return d};this._checkIfAllColorsNotAvailable=function(){for(var a=!0,b=0;b<g.length;b++)!0===g[b]&&(a=!1);return a};this._nextShoot=function(){null!==h&&h.unload();h=k;h.changePos(d/2-25,f/2+20);h.getSprite().mask=c;k=this._getRandomBall();k.changePos(120,f/2-12);k.getSprite().mask=p;var a=this;createjs.Tween.get(h.getSprite()).to({y:h.getY()+
|
||
|
25},300).call(function(){a._onBallReady()});createjs.Tween.get(k.getSprite()).to({y:k.getY()+16},300)};this.colorCleared=function(a){g[a]=!1;h.getIndex()===a&&(h.unload(),h=this._getRandomBall(),null!==h&&(h.changePos(d/2-25,f/2+45),h.getSprite().mask=c));k.getIndex()===a&&(k.unload(),k=this._getRandomBall(),null!==k&&(k.changePos(120,f/2+4),k.getSprite().mask=p))};this._onBallReady=function(){a=!0};this.getCurrentBall=function(){a=!1;var b=h;this._nextShoot();return b};this.getX=function(){return t.x};
|
||
|
this.getY=function(){return t.y};this.getRotation=function(){return t.rotation};this.canShoot=function(){return a};this._init()}
|
||
|
function CBezier(){var a,d,f,b,g,h,k,n,c,p,t,r;this.init=function(x,m,y,u){a=x;d=m;f=y;g=a.x-2*d.x+f.x;h=a.y-2*d.y+f.y;k=2*d.x-2*a.x;n=2*d.y-2*a.y;c=4*(g*g+h*h);p=4*(g*k+h*n);t=k*k+n*n;r=this._length(1);b=Math.floor(r/u);r%u>u/2&&b++;return b};this._speed=function(a){return Math.sqrt(c*a*a+p*a+t)};this._length=function(a){var b=Math.sqrt(t+a*(p+c*a));return(2*Math.sqrt(c)*(2*c*a*b+p*(b-Math.sqrt(t)))+(p*p-4*c*t)*(Math.log(p+2*Math.sqrt(c)*Math.sqrt(t))-Math.log(p+2*c*a+2*Math.sqrt(c)*b)))/(8*Math.pow(c,
|
||
|
1.5))};this.invertL=function(a,b){var c=a;do{var d=c-(this._length(c)-b)/this._speed(c);if(1E-6>Math.abs(c-d))break;c=d}while(1);return d};this.getAnchorPoint=function(c){if(0<=c&&c<=b){var g=c/b;g=this.invertL(g,g*r);c=(1-g)*(1-g)*a.x+2*(1-g)*g*d.x+g*g*f.x;var h=(1-g)*(1-g)*a.y+2*(1-g)*g*d.y+g*g*f.y,k=new createjs.Point((1-g)*a.x+g*d.x,(1-g)*a.y+g*d.y);g=new createjs.Point((1-g)*d.x+g*f.x,(1-g)*d.y+g*f.y);return[c,h,180*Math.atan2(g.y-k.y,g.x-k.x)/Math.PI]}return[]}}
|
||
|
function CBall(a,d){var f,b,g,h,k;this._init=function(a,c){f=a;b=0;k=c;var d=s_oSpriteLibrary.getSprite("ball_"+f);BALL_DIAMETER=d.width;BALL_DIAMETER_SQUARE=BALL_DIAMETER*BALL_DIAMETER;BALL_RADIUS=BALL_DIAMETER/2;d=new createjs.SpriteSheet({images:[d],frames:{width:BALL_DIAMETER,height:BALL_DIAMETER,regX:BALL_RADIUS,regY:BALL_RADIUS},animations:{move:[0,49]}});g=createSprite(d,null,BALL_RADIUS,BALL_RADIUS,BALL_DIAMETER,BALL_DIAMETER);g.stop();k.addChild(g)};this.unload=function(){k.removeChild(h);
|
||
|
k.removeChild(g)};this.nextFrame=function(){g.gotoAndStop(50===g.currentFrame+1?0:g.currentFrame+1)};this.prevFrame=function(){g.gotoAndStop(0>g.currentFrame-1?49:g.currentFrame-1)};this.setPos=function(a,c){a>b?this.nextFrame():a<b&&this.prevFrame();b=a;g.x=c[b][0];g.y=c[b][1];g.rotation=c[b][2]-90};this.changePos=function(a,b){g.x=a;g.y=b};this.increasePosWithNumbers=function(a,b){g.x+=a;g.y+=b};this.decreasePos=function(a,b){g.x-=a;g.y-=b};this.increasePos=function(a,c){this.setPos(b+a,c)};this.setContainer=
|
||
|
function(a){g.mask=null;k=a};this.explode=function(){var a={images:[s_oSpriteLibrary.getSprite("explosion")],frames:{width:30,height:30,regX:15,regY:15},animations:{show:[0,19],hide:[20]}},b=this;a=new createjs.SpriteSheet(a,"show");h=new createjs.Sprite(a);k.addChild(h);h.x=g.x;h.y=g.y;h.gotoAndPlay("show");createjs.Tween.get(g).to({alpha:0},1E3,createjs.Ease.cubicOut).call(function(){g.visible=!1});createjs.Tween.get(h).to({alpha:0},1200,createjs.Ease.cubicOut).call(function(){b.onExplosionEnd()})};
|
||
|
this.onExplosionEnd=function(){k.removeChild(h);k.removeChild(g)};this.rollInStage=function(){};this.getFotogram=function(){return b};this.getSprite=function(){return g};this.getIndex=function(){return f};this.getX=function(){return g.x};this.getY=function(){return g.y};this._init(a,d)}
|
||
|
function CNextLevel(){var a,d,f,b,g,h;this._init=function(){h=new createjs.Container;h.alpha=0;h.visible=!1;s_oStage.addChild(h);a=createBitmap(s_oSpriteLibrary.getSprite("msg_box"));h.addChild(a);f=new CTLText(h,CANVAS_WIDTH/2-80,CANVAS_HEIGHT/2-68,210,30,50,"center","#000",FONT_GAME,1.1,0,0,TEXT_CONGRATS,!0,!0,!0,!1);d=new CTLText(h,CANVAS_WIDTH/2-80,CANVAS_HEIGHT/2-68,210,30,50,"center","#fff",FONT_GAME,1.1,0,0,TEXT_CONGRATS,!0,!0,!0,!1);g=new CTLText(h,CANVAS_WIDTH/2-80,CANVAS_HEIGHT/2-15,200,
|
||
|
70,50,"center","#000",FONT_GAME,1.1,0,0,TEXT_FINAL_SCORE+"\n99999",!0,!0,!0,!1);b=new CTLText(h,CANVAS_WIDTH/2-80,CANVAS_HEIGHT/2-15,200,70,50,"center","#fff",FONT_GAME,1.1,0,0,TEXT_FINAL_SCORE+"\n99999",!0,!0,!0,!1)};this.show=function(a,n){f.refreshText(TEXT_LEVEL+" "+a);d.refreshText(TEXT_LEVEL+" "+a);g.refreshText(TEXT_SCORE+" "+n);b.refreshText(TEXT_SCORE+" "+n);h.visible=!0;var c=this;createjs.Tween.get(h).to({alpha:1},500).call(function(){c._initListener()});$(s_oMain).trigger("save_score",
|
||
|
n)};this._initListener=function(){h.on("mousedown",this._onExit);$(s_oMain).trigger("show_interlevel_ad")};this._onExit=function(){h.off("mousedown");h.alpha=0;h.visible=!1;s_oGame.nextLevel()};this._init()}function CExtraScore(a,d,f){var b;this._init=function(a,d,f){var g=s_oSpriteLibrary.getSprite("extra_score");b=createBitmap(g);b.x=a;b.y=d;b.regX=g.width/2;b.regY=g.height/2;b.alpha=0;f.addChild(b);createjs.Tween.get(b).to({alpha:1},1E3).call(function(){f.removeChild(b)})};this._init(a,d,f)}
|
||
|
function CLevelMenu(){var a,d,f,b,g,h,k,n,c,p,t,r,x,m=null,y=null,u,B,D=null,H=null;this._init=function(){k=0;u=new createjs.Container;s_oStage.addChild(u);var c=createBitmap(s_oSpriteLibrary.getSprite("bg_menu_level"));u.addChild(c);new CTLText(s_oStage,230,90,500,60,100,"center","#fff",FONT_GAME,1.1,0,0,TEXT_SELECT_LEVEL,!0,!0,!0,!1);c=s_oSpriteLibrary.getSprite("but_exit");g=CANVAS_WIDTH-c.width/2;h=c.height/2+4;r=new CGfxButton(g,h,c,!0);r.addEventListener(ON_MOUSE_UP,this._onExit,this);n=c.height;
|
||
|
if(!1===DISABLE_SOUND_MOBILE||!1===s_bMobile)f=r.getX()-c.width,b=c.height/2+4,x=new CToggle(f,b,s_oSpriteLibrary.getSprite("audio_icon"),s_bAudioActive),x.addEventListener(ON_MOUSE_UP,this._onAudioToggle,this);c=window.document;var l=c.documentElement;D=l.requestFullscreen||l.mozRequestFullScreen||l.webkitRequestFullScreen||l.msRequestFullscreen;H=c.exitFullscreen||c.mozCancelFullScreen||c.webkitExitFullscreen||c.msExitFullscreen;!1===ENABLE_FULLSCREEN&&(D=!1);D&&screenfull.enabled&&(c=s_oSpriteLibrary.getSprite("but_fullscreen"),
|
||
|
a=c.width/4+10,d=c.height/2+4,B=new CToggle(a,d,c,s_bFullscreen,s_oStage),B.addEventListener(ON_MOUSE_UP,this._onFullscreenRelease,this));this._checkBoundLimits();p=[];c=Math.floor((CANVAS_WIDTH-2*EDGEBOARD_X)/NUM_COLS_PAGE_LEVEL)/2;for(var q=l=0;q<NUM_COLS_PAGE_LEVEL;q++)p.push(l),l+=2*c;t=[];this._createNewLevelPage(0,NUM_LEVELS);if(1<t.length){for(c=1;c<t.length;c++)t[c].visible=!1;m=new CGfxButton(CANVAS_WIDTH/2+280,CANVAS_HEIGHT-80,s_oSpriteLibrary.getSprite("arrow_right"),!0);m.addEventListener(ON_MOUSE_UP,
|
||
|
this._onRight,this);y=new CGfxButton(CANVAS_WIDTH/2-280,CANVAS_HEIGHT-80,s_oSpriteLibrary.getSprite("arrow_left"),!0);y.addEventListener(ON_MOUSE_UP,this._onLeft,this)}this.refreshButtonPos(s_iOffsetX,s_iOffsetY)};this.unload=function(){for(var a=0;a<c.length;a++)c[a].unload();!1!==DISABLE_SOUND_MOBILE&&!1!==s_bMobile||x.unload();D&&screenfull.enabled&&B.unload();r.unload();null!==y&&(y.unload(),m.unload());s_oLevelMenu=null};this.refreshButtonPos=function(c,k){r.setPosition(g-c,h+k);!1!==DISABLE_SOUND_MOBILE&&
|
||
|
!1!==s_bMobile||x.setPosition(f-c,k+b);D&&screenfull.enabled&&B.setPosition(a+c,d+k)};this._checkBoundLimits=function(){for(var a=s_oSpriteLibrary.getSprite("but_level"),b=0,c=CANVAS_HEIGHT-2*EDGEBOARD_Y-2*n,d=0;b<c;)b+=a.height+20,d++;NUM_ROWS_PAGE_LEVEL>d&&(NUM_ROWS_PAGE_LEVEL=d);c=b=0;d=CANVAS_WIDTH-2*EDGEBOARD_X;for(a=s_oSpriteLibrary.getSprite("but_level");c<d;)c+=a.width/2+5,b++;NUM_COLS_PAGE_LEVEL>b&&(NUM_COLS_PAGE_LEVEL=b)};this._createNewLevelPage=function(a,b){var d=new createjs.Container;
|
||
|
u.addChild(d);t.push(d);c=[];for(var f=0,g=0,h=1,k=!1,l=s_oSpriteLibrary.getSprite("but_level"),m=a;m<b;m++){var n=new CLevelBut(p[f]+l.width/4,g+l.height/2,m+1,l,m+1>s_iLastLevel?!1:!0,d);n.addEventListenerWithParams(ON_MOUSE_UP,this._onButLevelRelease,this,m);c.push(n);f++;if(f===p.length&&(f=0,g+=l.height+20,h++,h>NUM_ROWS_PAGE_LEVEL)){k=!0;break}}d.x=CANVAS_WIDTH/2;d.y=CANVAS_HEIGHT/2;d.regX=d.getBounds().width/2;d.regY=d.getBounds().height/2;k&&this._createNewLevelPage(m+1,b)};this._onRight=
|
||
|
function(){t[k].visible=!1;k++;k>=t.length&&(k=0);t[k].visible=!0};this._onLeft=function(){t[k].visible=!1;k--;0>k&&(k=t.length-1);t[k].visible=!0};this._onButLevelRelease=function(a){s_oMain.levelSelected(a+1)};this._onAudioToggle=function(){Howler.mute(s_bAudioActive);s_bAudioActive=!s_bAudioActive};this.resetFullscreenBut=function(){D&&screenfull.enabled&&B.setActive(s_bFullscreen)};this._onFullscreenRelease=function(){s_bFullscreen?H.call(window.document):D.call(window.document.documentElement);
|
||
|
sizeHandler()};this._onExit=function(){s_oMain.gotoMenu()};s_oLevelMenu=this;this._init()}var s_oLevelMenu=null;
|
||
|
function CLevelBut(a,d,f,b,g,h){var k,n,c,p=[],t=[],r,x,m,y;this._init=function(a,b,d,f,g){n=[];c=[];y=new createjs.Container;u.addChild(y);var h=new createjs.SpriteSheet({images:[f],frames:{width:f.width/2,height:f.height,regX:f.width/2/2,regY:f.height/2},animations:{state_true:[0],state_false:[1]}});k=g;m=createSprite(h,"state_"+k,f.width/2/2,f.height/2,f.width/2,f.height);m.mouseEnabled=g;m.x=a;m.y=b;m.stop();s_bMobile||(y.cursor="pointer");y.addChild(m);p.push(m);r=new createjs.Text(d,"60px "+
|
||
|
FONT_GAME,"#004e6f");r.x=a;r.y=b+20;r.textAlign="center";r.textBaseline="alphabetic";r.lineWidth=200;r.outline=6;y.addChild(r);x=new createjs.Text(d,"60px "+FONT_GAME,"#fff");x.x=a;x.y=b+20;x.textAlign="center";x.textBaseline="alphabetic";x.lineWidth=200;y.addChild(x);g||(x.color="#b4b4b4",r.color="#606161");this._initListener()};this.unload=function(){y.off("mousedown",this.buttonDown);y.off("pressup",this.buttonRelease);y.removeChild(m)};this._initListener=function(){y.on("mousedown",this.buttonDown);
|
||
|
y.on("pressup",this.buttonRelease)};this.viewBut=function(a){y.addChild(a)};this.addEventListener=function(a,b,d){n[a]=b;c[a]=d};this.addEventListenerWithParams=function(a,b,d,f){n[a]=b;c[a]=d;t=f};this.ifClickable=function(){return!0===y.mouseEnabled?1:0};this.setActive=function(a,b){k=b;p[a].gotoAndStop("state_"+k);p[a].mouseEnabled=!0;k?(x.color="#69b8d5",r.color="#004e6f"):(x.color="#b4b4b4",r.color="#606161")};this.buttonRelease=function(){k&&(playSound("press_but",1,!1),n[ON_MOUSE_UP]&&n[ON_MOUSE_UP].call(c[ON_MOUSE_UP],
|
||
|
t))};this.buttonDown=function(){n[ON_MOUSE_DOWN]&&n[ON_MOUSE_DOWN].call(c[ON_MOUSE_DOWN],t)};this.setPosition=function(a,b){y.x=a;y.y=b};this.setVisible=function(a){y.visible=a};var u=h;this._init(a,d,f,b,g,h)}
|
||
|
function CMsgBox(a,d,f,b){var g,h,k,n,c,p,t;this._init=function(a,b,d,f){g=[];h=[];t=new createjs.Container;s_oStage.addChild(t);var m=createBitmap(s_oSpriteLibrary.getSprite("msg_box"));t.addChild(m);k=new CTLText(t,CANVAS_WIDTH/2-80,CANVAS_HEIGHT/2-80,210,130,50,"center","#fff",FONT_GAME,1.1,0,0,"",!0,!0,!0,!1);n=new CTextButton(CANVAS_WIDTH/2-100,CANVAS_HEIGHT-150,s_oSpriteLibrary.getSprite("but_generic_small"),"LEFT",FONT_GAME,"#ffffff",50,t);n.addEventListener(ON_MOUSE_UP,this._onButLeftDownRelease,
|
||
|
this);c=new CTextButton(CANVAS_WIDTH/2,CANVAS_HEIGHT-150,s_oSpriteLibrary.getSprite("but_generic_small"),"CENTER",FONT_GAME,"#ffffff",50,t);c.addEventListener(ON_MOUSE_UP,this._onButCenterDownRelease,this);p=new CTextButton(CANVAS_WIDTH/2+90,CANVAS_HEIGHT-150,s_oSpriteLibrary.getSprite("but_generic_small"),"LEFT",FONT_GAME,"#ffffff",50,t);p.addEventListener(ON_MOUSE_UP,this._onButRightDownRelease,this);this.show(a,b,d,f)};this.show=function(a,b,d,f){k.refreshText(a);""!==b?(n.changeText(b),n.setVisible(!0)):
|
||
|
n.setVisible(!1);""!==d?(c.changeText(d),c.setVisible(!0)):c.setVisible(!1);""!==f?(p.changeText(f),p.setVisible(!0)):p.setVisible(!1)};this.hide=function(){this.unload();s_oStage.removeChild(t)};this.unload=function(){n.unload();c.unload();p.unload()};this.addEventListener=function(a,b,c){g[a]=b;h[a]=c};this._onButLeftDownRelease=function(){g[ON_MSG_BOX_LEFT_BUT]&&(g[ON_MSG_BOX_LEFT_BUT].call(h[ON_MSG_BOX_LEFT_BUT]),t.visible=!1)};this._onButCenterDownRelease=function(){g[ON_MSG_BOX_CENTER_BUT]&&
|
||
|
(g[ON_MSG_BOX_CENTER_BUT].call(h[ON_MSG_BOX_CENTER_BUT]),t.visible=!1)};this._onButRightDownRelease=function(){g[ON_MSG_BOX_RIGHT_BUT]&&(g[ON_MSG_BOX_RIGHT_BUT].call(h[ON_MSG_BOX_RIGHT_BUT]),t.visible=!1)};this._init(a,d,f,b)}
|
||
|
function CCreditsPanel(){var a,d,f,b,g,h,k,n;this._init=function(){n=new createjs.Container;n.alpha=0;s_oStage.addChild(n);var c=new createjs.Shape;c.graphics.beginFill("rgba(0,0,0,0.7)").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);n.addChild(c);d=createBitmap(s_oSpriteLibrary.getSprite("msg_box"));n.addChild(d);h=new createjs.Shape;h.graphics.beginFill("#0f0f0f").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);h.alpha=.01;a=h.on("click",this._onLogoButRelease);n.addChild(h);c=s_oSpriteLibrary.getSprite("but_exit_small");
|
||
|
b=new CGfxButton(620,180,c,n);b.addEventListener(ON_MOUSE_UP,this.unload,this);g=new CTLText(n,400,214,200,30,50,"center","#000",FONT_GAME,1.1,0,0,TEXT_CREDITS_DEVELOPED,!0,!0,!0,!1);g.setOutline(2);new CTLText(n,400,214,200,30,50,"center","#fff",FONT_GAME,1.1,0,0,TEXT_CREDITS_DEVELOPED,!0,!0,!0,!1);c=s_oSpriteLibrary.getSprite("logo_ctl");f=createBitmap(c);f.regX=c.width/2;f.regY=c.height/2;f.x=CANVAS_WIDTH/2+20;f.y=265;n.addChild(f);k=new CTLText(n,400,286,200,30,50,"center","#000",FONT_GAME,1.1,
|
||
|
0,0,"WebOas.is",!0,!0,!0,!1);k.setOutline(2);new CTLText(n,400,286,200,30,50,"center","#fff",FONT_GAME,1.1,0,0,"WebOas.is",!0,!0,!0,!1);createjs.Tween.get(n).to({alpha:1},600,createjs.Ease.cubicOut);this.refreshButtonPos(s_iOffsetX,s_iOffsetY)};this.refreshButtonPos=function(a,b){};this.unload=function(){h.off("click",a);b.unload();b=null;s_oStage.removeChild(n)};this._onLogoButRelease=function(){window.open("https://weboas.is","_blank")};this._init()}
|
||
|
function CAlertSavingBox(a,d){var f,b;this._init=function(a){b=new createjs.Container;h.addChild(b);var d=new createjs.Shape;d.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);d.alpha=.5;d.on("click",function(){});b.addChild(d);d=s_oSpriteLibrary.getSprite("msg_box");var c=createBitmap(d);c.x=.5*CANVAS_WIDTH;c.y=.5*CANVAS_HEIGHT;c.regX=.5*d.width;c.regY=.5*d.height;b.addChild(c);new CTLText(b,400,190,200,130,50,"center","#fff",FONT_GAME,1.1,0,0,a,!0,!0,!0,!1);f=new CGfxButton(CANVAS_WIDTH/
|
||
|
2,430,s_oSpriteLibrary.getSprite("but_exit"),b);f.addEventListener(ON_MOUSE_UP,this._onButOk,this)};this._onButOk=function(){g.unload()};this.unload=function(){f.unload();h.removeChild(b)};var g=this;var h=d;this._init(a)}
|
||
|
CTLText.prototype={constructor:CTLText,__autofit:function(){if(this._bFitText){for(var a=this._iFontSize;(this._oText.getBounds().height>this._iHeight-2*this._iPaddingV||this._oText.getBounds().width>this._iWidth-2*this._iPaddingH)&&!(a--,this._oText.font=a+"px "+this._szFont,this._oText.lineHeight=Math.round(a*this._fLineHeightFactor),this.__updateY(),this.__verticalAlign(),8>a););this._iFontSize=a}},__verticalAlign:function(){if(this._bVerticalAlign){var a=this._oText.getBounds().height;this._oText.y-=
|
||
|
(a-this._iHeight)/2+this._iPaddingV}},__updateY:function(){this._oText.y=this._y+this._iPaddingV;switch(this._oText.textBaseline){case "middle":this._oText.y+=this._oText.lineHeight/2+(this._iFontSize*this._fLineHeightFactor-this._iFontSize)}},__createText:function(a){this._bDebug&&(this._oDebugShape=new createjs.Shape,this._oDebugShape.graphics.beginFill("rgba(255,0,0,0.5)").drawRect(this._x,this._y,this._iWidth,this._iHeight),this._oContainer.addChild(this._oDebugShape));this._oText=new createjs.Text(a,
|
||
|
this._iFontSize+"px "+this._szFont,this._szColor);this._oText.textBaseline="middle";this._oText.lineHeight=Math.round(this._iFontSize*this._fLineHeightFactor);this._oText.textAlign=this._szAlign;this._oText.lineWidth=this._bMultiline?this._iWidth-2*this._iPaddingH:null;switch(this._szAlign){case "center":this._oText.x=this._x+this._iWidth/2;break;case "left":this._oText.x=this._x+this._iPaddingH;break;case "right":this._oText.x=this._x+this._iWidth-this._iPaddingH}this._oContainer.addChild(this._oText);
|
||
|
this.refreshText(a)},setVerticalAlign:function(a){this._bVerticalAlign=a},setOutline:function(a){null!==this._oText&&(this._oText.outline=a)},setShadow:function(a,d,f,b){null!==this._oText&&(this._oText.shadow=new createjs.Shadow(a,d,f,b))},setColor:function(a){this._oText.color=a},setAlpha:function(a){this._oText.alpha=a},removeTweens:function(){createjs.Tween.removeTweens(this._oText)},getText:function(){return this._oText},getY:function(){return this._y},getFontSize:function(){return this._iFontSize},
|
||
|
refreshText:function(a){""===a&&(a=" ");null===this._oText&&this.__createText(a);this._oText.text=a;this._oText.font=this._iFontSize+"px "+this._szFont;this._oText.lineHeight=Math.round(this._iFontSize*this._fLineHeightFactor);this.__autofit();this.__updateY();this.__verticalAlign()}};
|
||
|
function CTLText(a,d,f,b,g,h,k,n,c,p,t,r,x,m,y,u,B){this._oContainer=a;this._x=d;this._y=f;this._iWidth=b;this._iHeight=g;this._bMultiline=u;this._iFontSize=h;this._szAlign=k;this._szColor=n;this._szFont=c;this._iPaddingH=t;this._iPaddingV=r;this._bVerticalAlign=y;this._bFitText=m;this._bDebug=B;this._oDebugShape=null;this._fLineHeightFactor=p;this._oText=null;x&&this.__createText(x)};
|