game.min.js 102 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190
  1. if (cc.sys._supportWebAudio) {
  2. var _ctx = cc.webAudioContext = new(window.AudioContext || window.webkitAudioContext || window.mozAudioContext);
  3. cc.WebAudio = cc.Class.extend({
  4. _events: null,
  5. _buffer: null,
  6. _sourceNode: null,
  7. _volumeNode: null,
  8. src: null,
  9. preload: null,
  10. autoplay: null,
  11. controls: null,
  12. mediagroup: null,
  13. currentTime: 0,
  14. startTime: 0,
  15. duration: 0,
  16. _loop: null,
  17. _volume: 1,
  18. _pauseTime: 0,
  19. _paused: !1,
  20. _stopped: !0,
  21. _loadState: -1,
  22. ctor: function(b) {
  23. this._events = {};
  24. this.src = b;
  25. this._volumeNode = _ctx.createGain ? _ctx.createGain() : _ctx.createGainNode();
  26. this._onSuccess1 = this._onSuccess.bind(this);
  27. this._onError1 = this._onError.bind(this)
  28. },
  29. _play: function(e) {
  30. var d = this._sourceNode = _ctx.createBufferSource(),
  31. f = this._volumeNode;
  32. e = e || 0;
  33. d.buffer = this._buffer;
  34. f.gain.value = this._volume;
  35. d.connect(f);
  36. f.connect(_ctx.destination);
  37. d.loop = this._loop;
  38. this._stopped = this._paused = !1;
  39. d.start ? d.start(0, e) : d.noteGrainOn ? (f = d.buffer.duration, this.loop ? d.noteGrainOn(0, e, f) : d.noteGrainOn(0, e, f - e)) : d.noteOn(0);
  40. this._pauseTime = 0
  41. },
  42. _stop: function() {
  43. var b = this._sourceNode;
  44. this._stopped || (b.stop ? b.stop(0) : b.noteOff(0), this._stopped = !0)
  45. },
  46. play: function() {
  47. if ( - 1 == this._loadState) {
  48. this._loadState = 0
  49. } else {
  50. if (1 == this._loadState) {
  51. var b = this._sourceNode;
  52. if (this._stopped || !(b && 2 == b.playbackState)) {
  53. this.startTime = _ctx.currentTime,
  54. this._play(0)
  55. }
  56. }
  57. }
  58. },
  59. pause: function() {
  60. this._pauseTime = _ctx.currentTime;
  61. this._paused = !0;
  62. this._stop()
  63. },
  64. resume: function() {
  65. this._paused && this._play(this._buffer ? (this._pauseTime - this.startTime) % this._buffer.duration: 0)
  66. },
  67. stop: function() {
  68. this._pauseTime = 0;
  69. this._paused = !1;
  70. this._stop()
  71. },
  72. load: function() {
  73. var d = this;
  74. if (1 != d._loadState) {
  75. d._loadState = -1;
  76. d.played = !1;
  77. d.ended = !0;
  78. var c = new XMLHttpRequest;
  79. c.open("GET", d.src, !0);
  80. c.responseType = "arraybuffer";
  81. c.onload = function() {
  82. _ctx.decodeAudioData(c.response, d._onSuccess1, d._onError1)
  83. };
  84. c.send()
  85. }
  86. },
  87. addEventListener: function(d, c) {
  88. this._events[d] = c.bind(this)
  89. },
  90. removeEventListener: function(b) {
  91. delete this._events[b]
  92. },
  93. canplay: function() {
  94. return cc.sys._supportWebAudio
  95. },
  96. _onSuccess: function(d) {
  97. this._buffer = d;
  98. d = this._events.success;
  99. var c = this._events.canplaythrough;
  100. d && d();
  101. c && c(); (0 == this._loadState || "autoplay" == this.autoplay || !0 == this.autoplay) && this._play();
  102. this._loadState = 1
  103. },
  104. _onError: function() {
  105. var b = this._events.error;
  106. b && b();
  107. this._loadState = -2
  108. },
  109. cloneNode: function() {
  110. var b = new cc.WebAudio(this.src);
  111. b.volume = this.volume;
  112. b._loadState = this._loadState;
  113. b._buffer = this._buffer; (0 == b._loadState || -1 == b._loadState) && b.load();
  114. return b
  115. }
  116. });
  117. var _p = cc.WebAudio.prototype;
  118. cc.defineGetterSetter(_p, "loop",
  119. function() {
  120. return this._loop
  121. },
  122. function(b) {
  123. this._loop = b;
  124. this._sourceNode && (this._sourceNode.loop = b)
  125. });
  126. cc.defineGetterSetter(_p, "volume",
  127. function() {
  128. return this._volume
  129. },
  130. function(b) {
  131. this._volume = b;
  132. this._volumeNode.gain.value = b
  133. });
  134. cc.defineGetterSetter(_p, "paused",
  135. function() {
  136. return this._paused
  137. });
  138. cc.defineGetterSetter(_p, "ended",
  139. function() {
  140. var b = this._sourceNode;
  141. return ! this._paused && (this._stopped || !b || 3 == b.playbackState)
  142. });
  143. cc.defineGetterSetter(_p, "played",
  144. function() {
  145. var b = this._sourceNode;
  146. return b && 2 == b.playbackState
  147. })
  148. }
  149. cc.AudioEngine = cc.Class.extend({
  150. _soundSupported: !1,
  151. _currMusic: null,
  152. _currMusicPath: null,
  153. _musicPlayState: 0,
  154. _audioID: 0,
  155. _effects: {},
  156. _audioPool: {},
  157. _effectsVolume: 1,
  158. _maxAudioInstance: 5,
  159. _effectPauseCb: null,
  160. _playings: [],
  161. ctor: function() {
  162. this._soundSupported = 0 < cc._audioLoader._supportedAudioTypes.length;
  163. this._effectPauseCb && (this._effectPauseCb = this._effectPauseCb.bind(this))
  164. },
  165. willPlayMusic: function() {
  166. return ! 1
  167. },
  168. getEffectsVolume: function() {
  169. return this._effectsVolume
  170. },
  171. playMusic: function(e, d) {
  172. if (this._soundSupported) {
  173. var f = this._currMusic;
  174. f && this._stopAudio(f);
  175. e != this._currMusicPath && (this._currMusic = f = this._getAudioByUrl(e), this._currMusicPath = e);
  176. f && (f.loop = d || !1, this._playMusic(f))
  177. }
  178. },
  179. _getAudioByUrl: function(e) {
  180. var d = cc.loader,
  181. f = d.getRes(e);
  182. f || (d.load(e), f = d.getRes(e));
  183. return f
  184. },
  185. _playMusic: function(b) {
  186. b.ended || (b.stop ? b.stop() : (b.pause(), b.currentTime = 0));
  187. this._musicPlayState = 2;
  188. b.play()
  189. },
  190. stopMusic: function(d) {
  191. if (0 < this._musicPlayState) {
  192. var c = this._currMusic;
  193. c && this._stopAudio(c) && (d && cc.loader.release(this._currMusicPath), this._currMusicPath = this._currMusic = null, this._musicPlayState = 0)
  194. }
  195. },
  196. _stopAudio: function(b) {
  197. return b && !b.ended ? (b.stop ? b.stop() : b.duration && Infinity != b.duration ? b.currentTime = b.duration: b.pause(), !0) : !1
  198. },
  199. pauseMusic: function() {
  200. 2 == this._musicPlayState && (this._currMusic.pause(), this._musicPlayState = 1)
  201. },
  202. resumeMusic: function() {
  203. 1 == this._musicPlayState && (this._resumeAudio(this._currMusic), this._musicPlayState = 2)
  204. },
  205. _resumeAudio: function(b) {
  206. b && !b.ended && (b.resume ? b.resume() : b.play())
  207. },
  208. rewindMusic: function() {
  209. this._currMusic && this._playMusic(this._currMusic)
  210. },
  211. getMusicVolume: function() {
  212. return 0 == this._musicPlayState ? 0 : this._currMusic.volume
  213. },
  214. setMusicVolume: function(b) {
  215. 0 < this._musicPlayState && (this._currMusic.volume = Math.min(Math.max(b, 0), 1))
  216. },
  217. isMusicPlaying: function() {
  218. return 2 == this._musicPlayState && this._currMusic && !this._currMusic.ended
  219. },
  220. _getEffectList: function(d) {
  221. var c = this._audioPool[d];
  222. c || (c = this._audioPool[d] = []);
  223. return c
  224. },
  225. _getEffect: function(g) {
  226. var e;
  227. if (!this._soundSupported) {
  228. return null
  229. }
  230. for (var l = this._getEffectList(g), j = 0, i = l.length; j < i; j++) {
  231. var h = l[j];
  232. if (h.ended) {
  233. e = h;
  234. e.currentTime = 0;
  235. window.chrome && e.load();
  236. break
  237. }
  238. }
  239. if (!e) {
  240. if (l.length >= this._maxAudioInstance) {
  241. return cc.log("Error: " + g + " greater than " + this._maxAudioInstance),
  242. null
  243. }
  244. e = this._getAudioByUrl(g);
  245. if (!e) {
  246. return null
  247. }
  248. e = e.cloneNode(!0);
  249. this._effectPauseCb && cc._addEventListener(e, "pause", this._effectPauseCb);
  250. e.volume = this._effectsVolume;
  251. l.push(e)
  252. }
  253. return e
  254. },
  255. playEffect: function(f, e) {
  256. var h = this._getEffect(f);
  257. if (!h) {
  258. return null
  259. }
  260. h.loop = e || !1;
  261. h.play();
  262. var g = this._audioID++;
  263. this._effects[g] = h;
  264. return g
  265. },
  266. setEffectsVolume: function(e) {
  267. e = this._effectsVolume = Math.min(Math.max(e, 0), 1);
  268. var d = this._effects,
  269. f;
  270. for (f in d) {
  271. d[f].volume = e
  272. }
  273. },
  274. pauseEffect: function(b) { (b = this._effects[b]) && !b.ended && b.pause()
  275. },
  276. pauseAllEffects: function() {
  277. var e = this._effects,
  278. d;
  279. for (d in e) {
  280. var f = e[d];
  281. f.ended || f.pause()
  282. }
  283. },
  284. resumeEffect: function(b) {
  285. this._resumeAudio(this._effects[b])
  286. },
  287. resumeAllEffects: function() {
  288. var d = this._effects,
  289. c;
  290. for (c in d) {
  291. this._resumeAudio(d[c])
  292. }
  293. },
  294. stopEffect: function(b) {
  295. this._stopAudio(this._effects[b]);
  296. delete this._effects[b]
  297. },
  298. stopAllEffects: function() {
  299. var d = this._effects,
  300. c;
  301. for (c in d) {
  302. this._stopAudio(d[c]),
  303. delete d[c]
  304. }
  305. },
  306. unloadEffect: function(g) {
  307. var e = cc.loader,
  308. j = this._effects,
  309. i = this._getEffectList(g);
  310. e.release(g);
  311. if (0 != i.length) {
  312. e = i[0].src;
  313. delete this._audioPool[g];
  314. for (var h in j) {
  315. j[h].src == e && (this._stopAudio(j[h]), delete j[h])
  316. }
  317. }
  318. },
  319. end: function() {
  320. this.stopMusic();
  321. this.stopAllEffects()
  322. },
  323. _pausePlaying: function() {
  324. var e = this._effects,
  325. d, f;
  326. for (f in e) {
  327. if ((d = e[f]) && !d.ended && !d.paused) {
  328. this._playings.push(d),
  329. d.pause()
  330. }
  331. }
  332. this.isMusicPlaying() && (this._playings.push(this._currMusic), this._currMusic.pause())
  333. },
  334. _resumePlaying: function() {
  335. for (var e = this._playings,
  336. d = 0,
  337. f = e.length; d < f; d++) {
  338. this._resumeAudio(e[d])
  339. }
  340. e.length = 0
  341. }
  342. }); ! cc.sys._supportWebAudio && 0 > cc.sys._supportMultipleAudio && (cc.AudioEngineForSingle = cc.AudioEngine.extend({
  343. _waitingEffIds: [],
  344. _pausedEffIds: [],
  345. _currEffect: null,
  346. _maxAudioInstance: 2,
  347. _effectCache4Single: {},
  348. _needToResumeMusic: !1,
  349. _expendTime4Music: 0,
  350. _isHiddenMode: !1,
  351. _playMusic: function(b) {
  352. this._stopAllEffects();
  353. this._super(b)
  354. },
  355. resumeMusic: function() {
  356. 1 == this._musicPlayState && (this._stopAllEffects(), this._needToResumeMusic = !1, this._expendTime4Music = 0, this._super())
  357. },
  358. playEffect: function(g, e) {
  359. var j = this._currEffect,
  360. i = e ? this._getEffect(g) : this._getSingleEffect(g);
  361. if (!i) {
  362. return null
  363. }
  364. i.loop = e || !1;
  365. var h = this._audioID++;
  366. this._effects[h] = i;
  367. this.isMusicPlaying() && (this.pauseMusic(), this._needToResumeMusic = !0);
  368. j ? (j != i && this._waitingEffIds.push(this._currEffectId), this._waitingEffIds.push(h), j.pause()) : (this._currEffect = i, this._currEffectId = h, i.play());
  369. return h
  370. },
  371. pauseEffect: function(b) {
  372. cc.log("pauseEffect not supported in single audio mode!")
  373. },
  374. pauseAllEffects: function() {
  375. var g = this._waitingEffIds,
  376. e = this._pausedEffIds,
  377. j = this._currEffect;
  378. if (j) {
  379. for (var i = 0,
  380. h = g.length; i < h; i++) {
  381. e.push(g[i])
  382. }
  383. g.length = 0;
  384. e.push(this._currEffectId);
  385. j.pause()
  386. }
  387. },
  388. resumeEffect: function(b) {
  389. cc.log("resumeEffect not supported in single audio mode!")
  390. },
  391. resumeAllEffects: function() {
  392. var f = this._waitingEffIds,
  393. e = this._pausedEffIds;
  394. this.isMusicPlaying() && (this.pauseMusic(), this._needToResumeMusic = !0);
  395. for (var h = 0,
  396. g = e.length; h < g; h++) {
  397. f.push(e[h])
  398. }
  399. e.length = 0;
  400. if (!this._currEffect && 0 <= f.length && (f = f.pop(), e = this._effects[f])) {
  401. this._currEffectId = f,
  402. this._currEffect = e,
  403. this._resumeAudio(e)
  404. }
  405. },
  406. stopEffect: function(f) {
  407. var e = this._currEffect,
  408. h = this._waitingEffIds,
  409. g = this._pausedEffIds;
  410. e && this._currEffectId == f ? this._stopAudio(e) : (e = h.indexOf(f), 0 <= e ? h.splice(e, 1) : (e = g.indexOf(f), 0 <= e && g.splice(e, 1)))
  411. },
  412. stopAllEffects: function() {
  413. this._stopAllEffects(); ! this._currEffect && this._needToResumeMusic && (this._resumeAudio(this._currMusic), this._musicPlayState = 2, this._needToResumeMusic = !1, this._expendTime4Music = 0)
  414. },
  415. unloadEffect: function(h) {
  416. var e = cc.loader,
  417. n = this._effects,
  418. m = this._effectCache4Single,
  419. l = this._getEffectList(h),
  420. i = this._currEffect;
  421. e.release(h);
  422. if (0 != l.length || m[h]) {
  423. e = 0 < l.length ? l[0].src: m[h].src;
  424. delete this._audioPool[h];
  425. delete m[h];
  426. for (var j in n) {
  427. n[j].src == e && delete n[j]
  428. }
  429. i && i.src == e && this._stopAudio(i)
  430. }
  431. },
  432. _getSingleEffect: function(g) {
  433. var e = this._effectCache4Single[g],
  434. l = this._waitingEffIds,
  435. j = this._pausedEffIds,
  436. i = this._effects;
  437. if (e) {
  438. e.currentTime = 0
  439. } else {
  440. e = this._getAudioByUrl(g);
  441. if (!e) {
  442. return null
  443. }
  444. e = e.cloneNode(!0);
  445. this._effectPauseCb && cc._addEventListener(e, "pause", this._effectPauseCb);
  446. e.volume = this._effectsVolume;
  447. this._effectCache4Single[g] = e
  448. }
  449. g = 0;
  450. for (var h = l.length; g < h;) {
  451. i[l[g]] == e ? l.splice(g, 1) : g++
  452. }
  453. g = 0;
  454. for (h = j.length; g < h;) {
  455. i[j[g]] == e ? j.splice(g, 1) : g++
  456. }
  457. e._isToPlay = !0;
  458. return e
  459. },
  460. _stopAllEffects: function() {
  461. var h = this._currEffect,
  462. e = this._audioPool,
  463. n = this._effectCache4Single,
  464. m = this._waitingEffIds,
  465. l = this._pausedEffIds;
  466. if (h || !(0 == m.length && 0 == l.length)) {
  467. for (var i in n) {
  468. var j = n[i];
  469. j.duration && Infinity != j.duration && (j.currentTime = j.duration)
  470. }
  471. m.length = 0;
  472. l.length = 0;
  473. for (i in e) {
  474. n = e[i];
  475. m = 0;
  476. for (l = n.length; m < l; m++) {
  477. j = n[m],
  478. j.loop = !1,
  479. j.duration && Infinity != j.duration && (j.currentTime = j.duration)
  480. }
  481. }
  482. h && this._stopAudio(h)
  483. }
  484. },
  485. _effectPauseCb: function() {
  486. if (!this._isHiddenMode) {
  487. var d = this._getWaitingEffToPlay();
  488. if (d) {
  489. d._isToPlay ? (delete d._isToPlay, d.play()) : this._resumeAudio(d)
  490. } else {
  491. if (this._needToResumeMusic) {
  492. d = this._currMusic;
  493. if (d.duration && Infinity != d.duration) {
  494. var c = d.currentTime + this._expendTime4Music,
  495. c = c - d.duration * (c / d.duration | 0);
  496. d.currentTime = c
  497. }
  498. this._expendTime4Music = 0;
  499. this._resumeAudio(d);
  500. this._musicPlayState = 2;
  501. this._needToResumeMusic = !1
  502. }
  503. }
  504. }
  505. },
  506. _getWaitingEffToPlay: function() {
  507. var g = this._waitingEffIds,
  508. e = this._effects,
  509. j = this._currEffect,
  510. i = j ? j.currentTime - (j.startTime || 0) : 0;
  511. for (this._expendTime4Music += i; 0 != g.length;) {
  512. var h = g.pop();
  513. if (j = e[h]) {
  514. if (j._isToPlay || j.loop || j.duration && j.currentTime + i < j.duration) {
  515. return this._currEffectId = h,
  516. this._currEffect = j,
  517. !j._isToPlay && (j.duration && Infinity != j.duration) && (g = j.currentTime + i, g -= j.duration * (g / j.duration | 0), j.currentTime = g),
  518. j._isToPlay = !1,
  519. j
  520. }
  521. j.duration && Infinity != j.duration && (j.currentTime = j.duration)
  522. }
  523. }
  524. return this._currEffect = this._currEffectId = null
  525. },
  526. _pausePlaying: function() {
  527. var b = this._currEffect;
  528. this._isHiddenMode = !0;
  529. if (b = 2 == this._musicPlayState ? this._currMusic: b) {
  530. this._playings.push(b),
  531. b.pause()
  532. }
  533. },
  534. _resumePlaying: function() {
  535. var b = this._playings;
  536. this._isHiddenMode = !1;
  537. 0 < b.length && (this._resumeAudio(b[0]), b.length = 0)
  538. }
  539. }));
  540. cc._audioLoader = {
  541. _supportedAudioTypes: null,
  542. getBasePath: function() {
  543. return cc.loader.audioPath
  544. },
  545. _load: function(q, o, n, m, l, i, j) {
  546. var h = this,
  547. e = cc.loader,
  548. s = cc.path,
  549. x = this._supportedAudioTypes,
  550. t = "";
  551. if (0 == x.length) {
  552. return j("can not support audio!")
  553. }
  554. if ( - 1 == m) {
  555. t = (s.extname(q) || "").toLowerCase(),
  556. h.audioTypeSupported(t) || (t = x[0], m = 0)
  557. } else {
  558. if (m < x.length) {
  559. t = x[m]
  560. } else {
  561. return j("can not found the resource of audio! Last match url is : " + q)
  562. }
  563. }
  564. if (0 <= l.indexOf(t)) {
  565. return h._load(q, o, n, m + 1, l, i, j)
  566. }
  567. q = s.changeExtname(q, t);
  568. l.push(t);
  569. i = h._loadAudio(q, i,
  570. function(a) {
  571. if (a) {
  572. return h._load(q, o, n, m + 1, l, i, j)
  573. }
  574. j(null, i)
  575. },
  576. m == x.length - 1);
  577. e.cache[o] = i
  578. },
  579. audioTypeSupported: function(b) {
  580. return ! b ? !1 : 0 <= this._supportedAudioTypes.indexOf(b.toLowerCase())
  581. },
  582. _loadAudio: function(g, e, j, i) {
  583. var h = "file://" == location.origin ? Audio: cc.WebAudio || Audio;
  584. 2 == arguments.length ? (j = e, e = new h) : 3 < arguments.length && !e && (e = new h);
  585. e.src = g;
  586. e.preload = "auto";
  587. h = navigator.userAgent;
  588. /Mobile/.test(h) && (/iPhone OS/.test(h) || /iPad/.test(h) || /Firefox/.test(h)) || /MSIE/.test(h) ? (e.load(), j(null, e)) : (cc._addEventListener(e, "canplaythrough",
  589. function() {
  590. j(null, e);
  591. this.removeEventListener("canplaythrough", arguments.callee, !1);
  592. this.removeEventListener("error", arguments.callee, !1)
  593. },
  594. !1), cc._addEventListener(e, "error",
  595. function() {
  596. j("load " + g + " failed");
  597. i && (this.removeEventListener("canplaythrough", arguments.callee, !1), this.removeEventListener("error", arguments.callee, !1))
  598. },
  599. !1), e.load());
  600. return e
  601. },
  602. load: function(f, e, h, g) {
  603. this._load(f, e, h, -1, [], null, g)
  604. }
  605. };
  606. cc._audioLoader._supportedAudioTypes = function() {
  607. var e = cc.newElement("audio"),
  608. d = [];
  609. if (e.canPlayType) {
  610. var f = function(a) {
  611. a = e.canPlayType(a);
  612. return "no" != a && "" != a
  613. };
  614. f('audio/ogg; codecs\x3d"vorbis"') && d.push(".ogg");
  615. f("audio/mpeg") && d.push(".mp3");
  616. f('audio/wav; codecs\x3d"1"') && d.push(".wav");
  617. f("audio/mp4") && d.push(".mp4"); (f("audio/x-m4a") || f("audio/aac")) && d.push(".m4a")
  618. }
  619. return d
  620. } ();
  621. cc.loader.register(["mp3", "ogg", "wav", "mp4", "m4a"], cc._audioLoader);
  622. cc.audioEngine = cc.AudioEngineForSingle ? new cc.AudioEngineForSingle: new cc.AudioEngine;
  623. cc.eventManager.addCustomListener(cc.game.EVENT_HIDE,
  624. function() {
  625. cc.audioEngine._pausePlaying()
  626. });
  627. cc.eventManager.addCustomListener(cc.game.EVENT_SHOW,
  628. function() {
  629. cc.audioEngine._resumePlaying()
  630. });
  631. var bs = bs || {};
  632. bs.System = {
  633. messageBox: function() {},
  634. measureStringWidth: function() {
  635. return this
  636. },
  637. openUrl: function() {},
  638. countStringCanDisplayInWidth: function() {
  639. return this
  640. },
  641. setRateAppDelegate: function() {},
  642. getDeviceIdfa: function() {
  643. return this
  644. },
  645. UTFStringBytes: function() {
  646. return this
  647. },
  648. getDeviceID: function() {
  649. return this
  650. },
  651. rateApp: function() {},
  652. copyToClipboard: function() {},
  653. getTimeOfDay: function() {
  654. return this
  655. },
  656. getSystemUpTime: function() {
  657. return this
  658. },
  659. isRetina: function() {
  660. return this
  661. },
  662. urlEncode: function() {
  663. return this
  664. },
  665. generateOrderID: function() {
  666. return this
  667. },
  668. getPackageName: function() {
  669. return this
  670. },
  671. calcStringLength: function() {
  672. return this
  673. },
  674. md5: function() {
  675. return this
  676. },
  677. getCurrentVersion: function() {
  678. return this
  679. },
  680. logMemoryUsage: function() {},
  681. compareVersion: function() {
  682. return this
  683. },
  684. isUsingWifi: function() {
  685. return this
  686. },
  687. showRateAppAlert: function() {},
  688. getDeviceMac: function() {
  689. return this
  690. }
  691. };
  692. bs.Notification = {
  693. destroy: function() {},
  694. init: function() {
  695. return this
  696. },
  697. cancelAllNotification: function() {},
  698. scheduleNotification: function() {},
  699. shared: function() {
  700. return this
  701. },
  702. BSNotification: function() {}
  703. };
  704. bs.Umeng = {
  705. feedback: function() {},
  706. getConfigParam: function() {
  707. return this
  708. },
  709. checkUpdate: function() {},
  710. failLevel: function() {},
  711. logEvent: function() {},
  712. getChannel: function() {
  713. return this
  714. },
  715. setIsUpdated: function() {},
  716. init: function() {
  717. return this
  718. },
  719. setVersionKey: function() {},
  720. startWithAppKey: function() {},
  721. getIsUpdated: function() {
  722. return this
  723. },
  724. logPurchase: function() {},
  725. destroy: function() {},
  726. getAppKey: function() {
  727. return this
  728. },
  729. startLevel: function() {},
  730. finishLevel: function() {},
  731. logRecharge: function() {},
  732. isInReview: function() {
  733. return this
  734. },
  735. shared: function() {
  736. return this
  737. },
  738. BSUmeng: function() {}
  739. };
  740. bs.TencentMTA = {
  741. setPlayerLevel: function() {},
  742. trackRecharge: function() {},
  743. trackLevelUp: function() {},
  744. trackEvent: function() {},
  745. trackRaid: function() {},
  746. startWithAppKey: function() {},
  747. trackLogout: function() {},
  748. setDebugEnable: function() {},
  749. isInReview: function() {
  750. return this
  751. },
  752. trackRegister: function() {},
  753. getConfigParam: function() {
  754. return this
  755. },
  756. setPlayerId: function() {},
  757. init: function() {
  758. return this
  759. },
  760. destroy: function() {},
  761. trackConsumeItem: function() {},
  762. trackPurchaseItem: function() {},
  763. getChannel: function() {
  764. return this
  765. },
  766. setExchangeRate: function() {},
  767. trackLogin: function() {},
  768. trackTask: function() {},
  769. getAppKey: function() {
  770. return this
  771. },
  772. trackPurchaseOther: function() {},
  773. shared: function() {
  774. return this
  775. },
  776. BSTencentMTA: function() {}
  777. };
  778. bs.Share = {
  779. registerApp: function() {},
  780. shareVideo: function() {},
  781. shareImage: function() {},
  782. shareURL: function() {},
  783. init: function() {
  784. return this
  785. },
  786. onShareSuccess: function() {},
  787. destroy: function() {},
  788. shared: function() {
  789. return this
  790. },
  791. BSShare: function() {}
  792. };
  793. bs.ShareQQ = {
  794. destroy: function() {},
  795. init: function() {
  796. return this
  797. },
  798. registerApp: function() {},
  799. shared: function() {
  800. return this
  801. },
  802. BSShareQQ: function() {}
  803. };
  804. bs.AsyncRemoteSprite = {
  805. textureLoaded: function() {},
  806. create: function() {
  807. return this
  808. },
  809. BSAsyncRemoteSprite: function() {}
  810. };
  811. bs.Social = {
  812. invite: function() {},
  813. getType: function() {
  814. return this
  815. },
  816. initWithAppId: function() {},
  817. isLogin: function() {
  818. return this
  819. },
  820. login: function() {},
  821. queryUserInfo: function() {},
  822. BSSocial: function() {}
  823. };
  824. bs.SocialQQ = {
  825. getType: function() {
  826. return this
  827. },
  828. shared: function() {
  829. return this
  830. }
  831. };
  832. bs.SocialWechat = {
  833. setCode: function() {},
  834. getType: function() {
  835. return this
  836. },
  837. getCode: function() {
  838. return this
  839. },
  840. shared: function() {
  841. return this
  842. }
  843. };
  844. bs.SocialWeibo = {
  845. getType: function() {
  846. return this
  847. },
  848. shared: function() {
  849. return this
  850. }
  851. };
  852. bs.Config = {
  853. decrypt: function() {
  854. return this
  855. },
  856. init: function() {
  857. return this
  858. },
  859. setKey: function() {},
  860. loadConf: function() {
  861. return this
  862. },
  863. destroy: function() {},
  864. shared: function() {
  865. return this
  866. },
  867. BSConfig: function() {}
  868. };
  869. bs.PlatformImpl = {
  870. feedback: function() {},
  871. setPlatformDelegate: function() {},
  872. getPlatformName: function() {
  873. return this
  874. },
  875. setLoginStateToTrue: function() {},
  876. restorePurchase: function() {},
  877. getProductID: function() {
  878. return this
  879. },
  880. quitGame: function() {},
  881. getUserBalance: function() {
  882. return this
  883. },
  884. setIsInited: function() {},
  885. setAppIdAndKey: function() {},
  886. accountManagement: function() {},
  887. init: function() {
  888. return this
  889. },
  890. getUserNickName: function() {
  891. return this
  892. },
  893. setPlatformType: function() {},
  894. setProductID: function() {},
  895. getPlatformDelegate: function() {
  896. return this
  897. },
  898. getisVersionChecked: function() {
  899. return this
  900. },
  901. setRechargeAddr: function() {},
  902. getisFirstLogin: function() {
  903. return this
  904. },
  905. social: function() {},
  906. setisVersionChecked: function() {},
  907. getRechargeAddr: function() {
  908. return this
  909. },
  910. setOrderID: function() {},
  911. updateVersion: function() {},
  912. enterAppBBS: function() {},
  913. getIsInited: function() {
  914. return this
  915. },
  916. buyGoodConfirm: function() {},
  917. onEnterForeground: function() {},
  918. setisFirstLogin: function() {},
  919. setPlatformName: function() {},
  920. buyGood: function() {},
  921. setIsDebugMode: function() {},
  922. getLoginState: function() {
  923. return this
  924. },
  925. isLogined: function() {
  926. return this
  927. },
  928. getUserID: function() {
  929. return this
  930. },
  931. getPlatformType: function() {
  932. return this
  933. },
  934. getOrderID: function() {
  935. return this
  936. },
  937. login: function() {},
  938. BSPlatformImpl: function() {}
  939. };
  940. bs.Platform = {
  941. setPlatformImpl: function() {},
  942. shared: function() {
  943. return this
  944. }
  945. };
  946. bs.Sound = {
  947. stopAllEffects: function() {},
  948. switchMusicMute: function() {},
  949. setEffectVolume: function() {},
  950. setMusicVolume: function() {},
  951. setIsMusicMute: function() {},
  952. stopEffect: function() {},
  953. getEffectVolume: function() {
  954. return this
  955. },
  956. pushMusic: function() {
  957. return this
  958. },
  959. getMusicVolume: function() {
  960. return this
  961. },
  962. stopMusic: function() {},
  963. dump: function() {},
  964. getIsMute: function() {
  965. return this
  966. },
  967. setIsEffectMute: function() {},
  968. playMusic: function() {},
  969. setIsMute: function() {},
  970. popMusic: function() {},
  971. destroy: function() {},
  972. getIsMusicMute: function() {
  973. return this
  974. },
  975. configure: function() {},
  976. playEffect: function() {
  977. return this
  978. },
  979. active: function() {},
  980. switchEffectMute: function() {},
  981. init: function() {
  982. return this
  983. },
  984. getIsEffectMute: function() {
  985. return this
  986. },
  987. shared: function() {
  988. return this
  989. },
  990. BSSound: function() {}
  991. };
  992. bs.Ad = {
  993. destroy: function() {},
  994. init: function() {
  995. return this
  996. },
  997. showAd: function() {},
  998. setID: function() {},
  999. shared: function() {
  1000. return this
  1001. },
  1002. BSAd: function() {}
  1003. };
  1004. bs.OfferWall = {
  1005. setID: function() {},
  1006. showWall: function() {},
  1007. consumeAllPoints: function() {}
  1008. };
  1009. bs.OfferWallAdwo = {
  1010. consumeAllPoints: function() {},
  1011. init: function() {
  1012. return this
  1013. },
  1014. showWall: function() {},
  1015. destroy: function() {},
  1016. setID: function() {},
  1017. shared: function() {
  1018. return this
  1019. },
  1020. BSOfferWallAdwo: function() {}
  1021. };
  1022. bs.OfferWallDM = {
  1023. consumeAllPoints: function() {},
  1024. init: function() {
  1025. return this
  1026. },
  1027. showWall: function() {},
  1028. destroy: function() {},
  1029. setID: function() {},
  1030. shared: function() {
  1031. return this
  1032. },
  1033. BSOfferWallDM: function() {}
  1034. };
  1035. bs.OfferWallYjf = {
  1036. consumeAllPoints: function() {},
  1037. init: function() {
  1038. return this
  1039. },
  1040. showWall: function() {},
  1041. destroy: function() {},
  1042. setID: function() {},
  1043. shared: function() {
  1044. return this
  1045. },
  1046. BSOfferWallYjf: function() {}
  1047. };
  1048. bs.OfferWallDianRu = {
  1049. consumeAllPoints: function() {},
  1050. init: function() {
  1051. return this
  1052. },
  1053. showWall: function() {},
  1054. destroy: function() {},
  1055. setID: function() {},
  1056. shared: function() {
  1057. return this
  1058. },
  1059. BSOfferWallDianRu: function() {}
  1060. };
  1061. bs.Coupon = {
  1062. setServer: function() {},
  1063. useCoupon: function() {},
  1064. setProduct: function() {},
  1065. init: function() {
  1066. return this
  1067. },
  1068. destroy: function() {},
  1069. shared: function() {
  1070. return this
  1071. },
  1072. BSCoupon: function() {}
  1073. };
  1074. bs.Pay = {
  1075. getPlayerId: function() {
  1076. return this
  1077. },
  1078. setPayCode: function() {},
  1079. getIsSandbox: function() {
  1080. return this
  1081. },
  1082. setIsSandbox: function() {},
  1083. recordOrder: function() {},
  1084. getPayMethod: function() {
  1085. return this
  1086. },
  1087. setServerId: function() {},
  1088. getPayCode: function() {
  1089. return this
  1090. },
  1091. setPrice: function() {},
  1092. setPlayerId: function() {},
  1093. init: function() {
  1094. return this
  1095. },
  1096. getProductId: function() {
  1097. return this
  1098. },
  1099. destroy: function() {},
  1100. getPrice: function() {
  1101. return this
  1102. },
  1103. setPayData: function() {},
  1104. onRecordOrder: function() {},
  1105. getServerId: function() {
  1106. return this
  1107. },
  1108. setPayMethod: function() {},
  1109. restoreProduct: function() {},
  1110. getOrderId: function() {
  1111. return this
  1112. },
  1113. setProductId: function() {},
  1114. getPayData: function() {
  1115. return this
  1116. },
  1117. setOrderId: function() {},
  1118. setPaySecret: function() {},
  1119. buyProduct: function() {},
  1120. shared: function() {
  1121. return this
  1122. },
  1123. BSPay: function() {}
  1124. };
  1125. bs.Resource = {
  1126. unuseResource: function() {},
  1127. setThreadCount: function() {},
  1128. getThreadCount: function() {
  1129. return this
  1130. },
  1131. checkUpdate: function() {},
  1132. setMaxThreadCount: function() {},
  1133. getStatus: function() {
  1134. return this
  1135. },
  1136. setRemoteHost: function() {},
  1137. setStatus: function() {},
  1138. getRemoteHost: function() {
  1139. return this
  1140. },
  1141. init: function() {
  1142. return this
  1143. },
  1144. startUpdate: function() {},
  1145. getMaxThreadCount: function() {
  1146. return this
  1147. },
  1148. destroy: function() {},
  1149. getUpdateDurationMS: function() {
  1150. return this
  1151. },
  1152. getCacheFilePath: function() {
  1153. return this
  1154. },
  1155. useResource: function() {},
  1156. shared: function() {
  1157. return this
  1158. },
  1159. BSResource: function() {}
  1160. };
  1161. bs.Promotion = {
  1162. setServer: function() {},
  1163. sendInfo: function() {},
  1164. init: function() {
  1165. return this
  1166. },
  1167. destroy: function() {},
  1168. shared: function() {
  1169. return this
  1170. },
  1171. BSPromotion: function() {}
  1172. };
  1173. bs.KTPlay = {
  1174. handleOpenURL: function() {},
  1175. setAppKeyAndSecret: function() {},
  1176. show: function() {},
  1177. isEnabled: function() {
  1178. return this
  1179. },
  1180. dismiss: function() {},
  1181. isShowing: function() {
  1182. return this
  1183. },
  1184. init: function() {
  1185. return this
  1186. },
  1187. destroy: function() {},
  1188. shared: function() {
  1189. return this
  1190. },
  1191. BSKTPlay: function() {}
  1192. };
  1193. bs.AsyncRemoteSprite = cc.Sprite.extend({
  1194. _preferredSize: null,
  1195. initWithUrlAndSize: function(d, c) {
  1196. this.initWithFile(d);
  1197. this._preferredSize = c
  1198. },
  1199. onEnter: function() {
  1200. this._super();
  1201. this._preferredSize && (0 !== this.getContentSize().width ? bs.scaleToSize(this, this._preferredSize) : this.schedule(function() {
  1202. 0 !== this.getContentSize().width && (bs.scaleToSize(this, this._preferredSize), this.unscheduleAllCallbacks())
  1203. }.bind(this), 0.01))
  1204. }
  1205. });
  1206. bs.AsyncRemoteSprite.create = function(e, d, f) {
  1207. f = new bs.AsyncRemoteSprite;
  1208. f.initWithUrlAndSize(e, d);
  1209. return f
  1210. };
  1211. bs.System.getDeviceID = function() {
  1212. var b = cc.sys.localStorage.getItem("device_id");
  1213. if (b) {
  1214. return b
  1215. }
  1216. b = bs.guid();
  1217. cc.sys.localStorage.setItem("device_id", b);
  1218. return b
  1219. };
  1220. bs.System.getSystemUpTime = function() {
  1221. return Math.ceil((new Date).getTime() / 1000)
  1222. };
  1223. bs.System.currentTimeMillis = function() {
  1224. return (new Date).getTime()
  1225. };
  1226. bs.System.getServerTime = function(b) {
  1227. bs.Http.get("http://week.pictoword.hortorgame.com/week/serverTime",
  1228. function(a, f) {
  1229. if (a) {
  1230. b(a, null)
  1231. } else {
  1232. var e = parseInt(f);
  1233. isNaN(e) || 0 > e ? (cc.log("[BSHTTP] server time request error:" + JSON.stringify(f)), b("", null)) : b(null, e)
  1234. }
  1235. })
  1236. };
  1237. bs.platform = "html5";
  1238. bs.platformpay = "appstore";
  1239. bs._ResourceClass = cc.Class.extend({
  1240. _resUsed: null,
  1241. init: function() {
  1242. this._resUsed = {}
  1243. },
  1244. useResource: function(b) {
  1245. this._resUsed[b] || (this._resUsed[b] = 0, cc.spriteFrameCache.addSpriteFrames(b));
  1246. this._resUsed[b]++
  1247. },
  1248. unuseResource: function(b) {
  1249. this._resUsed[b]--;
  1250. 0 == this._resUsed[b] && cc.spriteFrameCache.removeSpriteFramesFromFile(b)
  1251. }
  1252. });
  1253. bs.Resource = {
  1254. _instance: null,
  1255. shared: function() {
  1256. this._instance || (this._instance = new bs._ResourceClass, this._instance.init());
  1257. return this._instance
  1258. }
  1259. }; (function() {
  1260. var ar = this,
  1261. aq = ar._,
  1262. ap = {},
  1263. ao = Array.prototype,
  1264. am = Object.prototype,
  1265. aj = ao.push,
  1266. al = ao.slice,
  1267. ag = ao.concat,
  1268. ac = am.toString,
  1269. S = am.hasOwnProperty,
  1270. W = ao.forEach,
  1271. U = ao.map,
  1272. ai = ao.reduce,
  1273. ak = ao.reduceRight,
  1274. ah = ao.filter,
  1275. aa = ao.every,
  1276. T = ao.some,
  1277. o = ao.indexOf,
  1278. R = ao.lastIndexOf,
  1279. am = Array.isArray,
  1280. Q = Object.keys,
  1281. af = Function.prototype.bind,
  1282. an = function(b) {
  1283. if (b instanceof an) {
  1284. return b
  1285. }
  1286. if (! (this instanceof an)) {
  1287. return new an(b)
  1288. }
  1289. this._wrapped = b
  1290. };
  1291. "undefined" !== typeof exports ? ("undefined" !== typeof module && module.exports && (exports = module.exports = an), exports._ = an) : ar._ = an;
  1292. an.VERSION = "1.6.0";
  1293. var Y = an.each = an.forEach = function(g, e, p) {
  1294. if (null == g) {
  1295. return g
  1296. }
  1297. if (W && g.forEach === W) {
  1298. g.forEach(e, p)
  1299. } else {
  1300. if (g.length === +g.length) {
  1301. for (var k = 0,
  1302. c = g.length; k < c; k++) {
  1303. if (e.call(p, g[k], k, g) === ap) {
  1304. return
  1305. }
  1306. }
  1307. } else {
  1308. for (var l = an.keys(g), k = 0, c = l.length; k < c; k++) {
  1309. if (e.call(p, g[l[k]], l[k], g) === ap) {
  1310. return
  1311. }
  1312. }
  1313. }
  1314. }
  1315. return g
  1316. };
  1317. an.map = an.collect = function(f, d, h) {
  1318. var g = [];
  1319. if (null == f) {
  1320. return g
  1321. }
  1322. if (U && f.map === U) {
  1323. return f.map(d, h)
  1324. }
  1325. Y(f,
  1326. function(b, e, c) {
  1327. g.push(d.call(h, b, e, c))
  1328. });
  1329. return g
  1330. };
  1331. an.reduce = an.foldl = an.inject = function(f, e, l, k) {
  1332. var g = 2 < arguments.length;
  1333. null == f && (f = []);
  1334. if (ai && f.reduce === ai) {
  1335. return k && (e = an.bind(e, k)),
  1336. g ? f.reduce(e, l) : f.reduce(e)
  1337. }
  1338. Y(f,
  1339. function(b, d, c) {
  1340. g ? l = e.call(k, l, b, d, c) : (l = b, g = !0)
  1341. });
  1342. if (!g) {
  1343. throw new TypeError("Reduce of empty array with no initial value")
  1344. }
  1345. return l
  1346. };
  1347. an.reduceRight = an.foldr = function(h, g, q, p) {
  1348. var e = 2 < arguments.length;
  1349. null == h && (h = []);
  1350. if (ak && h.reduceRight === ak) {
  1351. return p && (g = an.bind(g, p)),
  1352. e ? h.reduceRight(g, q) : h.reduceRight(g)
  1353. }
  1354. var l = h.length;
  1355. if (l !== +l) {
  1356. var k = an.keys(h),
  1357. l = k.length
  1358. }
  1359. Y(h,
  1360. function(c, b, a) {
  1361. b = k ? k[--l] : --l;
  1362. e ? q = g.call(p, q, h[b], b, a) : (q = h[b], e = !0)
  1363. });
  1364. if (!e) {
  1365. throw new TypeError("Reduce of empty array with no initial value")
  1366. }
  1367. return q
  1368. };
  1369. an.find = an.detect = function(f, e, h) {
  1370. var g;
  1371. ae(f,
  1372. function(b, d, c) {
  1373. if (e.call(h, b, d, c)) {
  1374. return g = b,
  1375. !0
  1376. }
  1377. });
  1378. return g
  1379. };
  1380. an.filter = an.select = function(f, e, h) {
  1381. var g = [];
  1382. if (null == f) {
  1383. return g
  1384. }
  1385. if (ah && f.filter === ah) {
  1386. return f.filter(e, h)
  1387. }
  1388. Y(f,
  1389. function(b, d, c) {
  1390. e.call(h, b, d, c) && g.push(b)
  1391. });
  1392. return g
  1393. };
  1394. an.reject = function(e, d, f) {
  1395. return an.filter(e,
  1396. function(b, g, c) {
  1397. return ! d.call(f, b, g, c)
  1398. },
  1399. f)
  1400. };
  1401. an.every = an.all = function(e, c, g) {
  1402. c || (c = an.identity);
  1403. var f = !0;
  1404. if (null == e) {
  1405. return f
  1406. }
  1407. if (aa && e.every === aa) {
  1408. return e.every(c, g)
  1409. }
  1410. Y(e,
  1411. function(b, h, d) {
  1412. if (! (f = f && c.call(g, b, h, d))) {
  1413. return ap
  1414. }
  1415. });
  1416. return !! f
  1417. };
  1418. var ae = an.some = an.any = function(e, c, g) {
  1419. c || (c = an.identity);
  1420. var f = !1;
  1421. if (null == e) {
  1422. return f
  1423. }
  1424. if (T && e.some === T) {
  1425. return e.some(c, g)
  1426. }
  1427. Y(e,
  1428. function(b, h, d) {
  1429. if (f || (f = c.call(g, b, h, d))) {
  1430. return ap
  1431. }
  1432. });
  1433. return !! f
  1434. };
  1435. an.contains = an.include = function(d, c) {
  1436. return null == d ? !1 : o && d.indexOf === o ? -1 != d.indexOf(c) : ae(d,
  1437. function(b) {
  1438. return b === c
  1439. })
  1440. };
  1441. an.invoke = function(f, e) {
  1442. var h = al.call(arguments, 2),
  1443. g = an.isFunction(e);
  1444. return an.map(f,
  1445. function(b) {
  1446. return (g ? e: b[e]).apply(b, h)
  1447. })
  1448. };
  1449. an.pluck = function(d, c) {
  1450. return an.map(d, an.property(c))
  1451. };
  1452. an.where = function(d, c) {
  1453. return an.filter(d, an.matches(c))
  1454. };
  1455. an.findWhere = function(d, c) {
  1456. return an.find(d, an.matches(c))
  1457. };
  1458. an.max = function(f, e, l) {
  1459. if (!e && an.isArray(f) && f[0] === +f[0] && 65535 > f.length) {
  1460. return Math.max.apply(Math, f)
  1461. }
  1462. var k = -Infinity,
  1463. g = -Infinity;
  1464. Y(f,
  1465. function(b, d, c) {
  1466. d = e ? e.call(l, b, d, c) : b;
  1467. d > g && (k = b, g = d)
  1468. });
  1469. return k
  1470. };
  1471. an.min = function(f, e, l) {
  1472. if (!e && an.isArray(f) && f[0] === +f[0] && 65535 > f.length) {
  1473. return Math.min.apply(Math, f)
  1474. }
  1475. var k = Infinity,
  1476. g = Infinity;
  1477. Y(f,
  1478. function(b, d, c) {
  1479. d = e ? e.call(l, b, d, c) : b;
  1480. d < g && (k = b, g = d)
  1481. });
  1482. return k
  1483. };
  1484. an.shuffle = function(f) {
  1485. var e, h = 0,
  1486. g = [];
  1487. Y(f,
  1488. function(b) {
  1489. e = an.random(h++);
  1490. g[h - 1] = g[e];
  1491. g[e] = b
  1492. });
  1493. return g
  1494. };
  1495. an.sample = function(e, d, f) {
  1496. return null == d || f ? (e.length !== +e.length && (e = an.values(e)), e[an.random(e.length - 1)]) : an.shuffle(e).slice(0, Math.max(0, d))
  1497. };
  1498. var ad = function(b) {
  1499. return null == b ? an.identity: an.isFunction(b) ? b: an.property(b)
  1500. };
  1501. an.sortBy = function(e, d, f) {
  1502. d = ad(d);
  1503. return an.pluck(an.map(e,
  1504. function(b, g, c) {
  1505. return {
  1506. value: b,
  1507. index: g,
  1508. criteria: d.call(f, b, g, c)
  1509. }
  1510. }).sort(function(h, g) {
  1511. var l = h.criteria,
  1512. k = g.criteria;
  1513. if (l !== k) {
  1514. if (l > k || void 0 === l) {
  1515. return 1
  1516. }
  1517. if (l < k || void 0 === k) {
  1518. return - 1
  1519. }
  1520. }
  1521. return h.index - g.index
  1522. }), "value")
  1523. };
  1524. var ab = function(b) {
  1525. return function(a, g, f) {
  1526. var e = {};
  1527. g = ad(g);
  1528. Y(a,
  1529. function(h, c) {
  1530. var d = g.call(f, h, c, a);
  1531. b(e, d, h)
  1532. });
  1533. return e
  1534. }
  1535. };
  1536. an.groupBy = ab(function(e, d, f) {
  1537. an.has(e, d) ? e[d].push(f) : e[d] = [f]
  1538. });
  1539. an.indexBy = ab(function(e, d, f) {
  1540. e[d] = f
  1541. });
  1542. an.countBy = ab(function(d, c) {
  1543. an.has(d, c) ? d[c]++:d[c] = 1
  1544. });
  1545. an.sortedIndex = function(k, g, r, q) {
  1546. r = ad(r);
  1547. g = r.call(q, g);
  1548. for (var l = 0,
  1549. p = k.length; l < p;) {
  1550. var f = l + p >>> 1;
  1551. r.call(q, k[f]) < g ? l = f + 1 : p = f
  1552. }
  1553. return l
  1554. };
  1555. an.toArray = function(b) {
  1556. return ! b ? [] : an.isArray(b) ? al.call(b) : b.length === +b.length ? an.map(b, an.identity) : an.values(b)
  1557. };
  1558. an.size = function(b) {
  1559. return null == b ? 0 : b.length === +b.length ? b.length: an.keys(b).length
  1560. };
  1561. an.first = an.head = an.take = function(e, d, f) {
  1562. return null == e ? void 0 : null == d || f ? e[0] : 0 > d ? [] : al.call(e, 0, d)
  1563. };
  1564. an.initial = function(e, d, f) {
  1565. return al.call(e, 0, e.length - (null == d || f ? 1 : d))
  1566. };
  1567. an.last = function(e, d, f) {
  1568. return null == e ? void 0 : null == d || f ? e[e.length - 1] : al.call(e, Math.max(e.length - d, 0))
  1569. };
  1570. an.rest = an.tail = an.drop = function(e, d, f) {
  1571. return al.call(e, null == d || f ? 1 : d)
  1572. };
  1573. an.compact = function(b) {
  1574. return an.filter(b, an.identity)
  1575. };
  1576. var P = function(e, d, f) {
  1577. if (d && an.every(e, an.isArray)) {
  1578. return ag.apply(f, e)
  1579. }
  1580. Y(e,
  1581. function(b) {
  1582. an.isArray(b) || an.isArguments(b) ? d ? aj.apply(f, b) : P(b, d, f) : f.push(b)
  1583. });
  1584. return f
  1585. };
  1586. an.flatten = function(d, c) {
  1587. return P(d, c, [])
  1588. };
  1589. an.without = function(b) {
  1590. return an.difference(b, al.call(arguments, 1))
  1591. };
  1592. an.partition = function(f, e) {
  1593. var h = [],
  1594. g = [];
  1595. Y(f,
  1596. function(b) { (e(b) ? h: g).push(b)
  1597. });
  1598. return [h, g]
  1599. };
  1600. an.uniq = an.unique = function(g, f, p, l) {
  1601. an.isFunction(f) && (l = p, p = f, f = !1);
  1602. p = p ? an.map(g, p, l) : g;
  1603. var k = [],
  1604. e = [];
  1605. Y(p,
  1606. function(b, a) {
  1607. if (f ? !a || e[e.length - 1] !== b: !an.contains(e, b)) {
  1608. e.push(b),
  1609. k.push(g[a])
  1610. }
  1611. });
  1612. return k
  1613. };
  1614. an.union = function() {
  1615. return an.uniq(an.flatten(arguments, !0))
  1616. };
  1617. an.intersection = function(d) {
  1618. var c = al.call(arguments, 1);
  1619. return an.filter(an.uniq(d),
  1620. function(b) {
  1621. return an.every(c,
  1622. function(a) {
  1623. return an.contains(a, b)
  1624. })
  1625. })
  1626. };
  1627. an.difference = function(d) {
  1628. var c = ag.apply(ao, al.call(arguments, 1));
  1629. return an.filter(d,
  1630. function(b) {
  1631. return ! an.contains(c, b)
  1632. })
  1633. };
  1634. an.zip = function() {
  1635. for (var e = an.max(an.pluck(arguments, "length").concat(0)), d = Array(e), f = 0; f < e; f++) {
  1636. d[f] = an.pluck(arguments, "" + f)
  1637. }
  1638. return d
  1639. };
  1640. an.object = function(f, e) {
  1641. if (null == f) {
  1642. return {}
  1643. }
  1644. for (var l = {},
  1645. k = 0,
  1646. g = f.length; k < g; k++) {
  1647. e ? l[f[k]] = e[k] : l[f[k][0]] = f[k][1]
  1648. }
  1649. return l
  1650. };
  1651. an.indexOf = function(f, e, l) {
  1652. if (null == f) {
  1653. return - 1
  1654. }
  1655. var k = 0,
  1656. g = f.length;
  1657. if (l) {
  1658. if ("number" == typeof l) {
  1659. k = 0 > l ? Math.max(0, g + l) : l
  1660. } else {
  1661. return k = an.sortedIndex(f, e),
  1662. f[k] === e ? k: -1
  1663. }
  1664. }
  1665. if (o && f.indexOf === o) {
  1666. return f.indexOf(e, l)
  1667. }
  1668. for (; k < g; k++) {
  1669. if (f[k] === e) {
  1670. return k
  1671. }
  1672. }
  1673. return - 1
  1674. };
  1675. an.lastIndexOf = function(f, e, h) {
  1676. if (null == f) {
  1677. return - 1
  1678. }
  1679. var g = null != h;
  1680. if (R && f.lastIndexOf === R) {
  1681. return g ? f.lastIndexOf(e, h) : f.lastIndexOf(e)
  1682. }
  1683. for (h = g ? h: f.length; h--;) {
  1684. if (f[h] === e) {
  1685. return h
  1686. }
  1687. }
  1688. return - 1
  1689. };
  1690. an.range = function(g, f, p) {
  1691. 1 >= arguments.length && (f = g || 0, g = 0);
  1692. p = arguments[2] || 1;
  1693. for (var m = Math.max(Math.ceil((f - g) / p), 0), k = 0, l = Array(m); k < m;) {
  1694. l[k++] = g,
  1695. g += p
  1696. }
  1697. return l
  1698. };
  1699. var Z = function() {};
  1700. an.bind = function(f, e) {
  1701. var h, g;
  1702. if (af && f.bind === af) {
  1703. return af.apply(f, al.call(arguments, 1))
  1704. }
  1705. if (!an.isFunction(f)) {
  1706. throw new TypeError
  1707. }
  1708. h = al.call(arguments, 2);
  1709. return g = function() {
  1710. if (! (this instanceof g)) {
  1711. return f.apply(e, h.concat(al.call(arguments)))
  1712. }
  1713. Z.prototype = f.prototype;
  1714. var a = new Z;
  1715. Z.prototype = null;
  1716. var b = f.apply(a, h.concat(al.call(arguments)));
  1717. return Object(b) === b ? b: a
  1718. }
  1719. };
  1720. an.partial = function(d) {
  1721. var c = al.call(arguments, 1);
  1722. return function() {
  1723. for (var f = 0,
  1724. e = c.slice(), b = 0, a = e.length; b < a; b++) {
  1725. e[b] === an && (e[b] = arguments[f++])
  1726. }
  1727. for (; f < arguments.length;) {
  1728. e.push(arguments[f++])
  1729. }
  1730. return d.apply(this, e)
  1731. }
  1732. };
  1733. an.bindAll = function(d) {
  1734. var c = al.call(arguments, 1);
  1735. if (0 === c.length) {
  1736. throw Error("bindAll must be passed function names")
  1737. }
  1738. Y(c,
  1739. function(a) {
  1740. d[a] = an.bind(d[a], d)
  1741. });
  1742. return d
  1743. };
  1744. an.memoize = function(e, d) {
  1745. var f = {};
  1746. d || (d = an.identity);
  1747. return function() {
  1748. var a = d.apply(this, arguments);
  1749. return an.has(f, a) ? f[a] : f[a] = e.apply(this, arguments)
  1750. }
  1751. };
  1752. an.delay = function(e, d) {
  1753. var f = al.call(arguments, 2);
  1754. return setTimeout(function() {
  1755. return e.apply(null, f)
  1756. },
  1757. d)
  1758. };
  1759. an.defer = function(b) {
  1760. return an.delay.apply(an, [b, 1].concat(al.call(arguments, 1)))
  1761. };
  1762. an.throttle = function(u, t, r) {
  1763. var q, l, e, p = null,
  1764. v = 0;
  1765. r || (r = {});
  1766. var g = function() {
  1767. v = !1 === r.leading ? 0 : an.now();
  1768. p = null;
  1769. e = u.apply(q, l);
  1770. q = l = null
  1771. };
  1772. return function() {
  1773. var b = an.now(); ! v && !1 === r.leading && (v = b);
  1774. var a = t - (b - v);
  1775. q = this;
  1776. l = arguments;
  1777. 0 >= a ? (clearTimeout(p), p = null, v = b, e = u.apply(q, l), q = l = null) : !p && !1 !== r.trailing && (p = setTimeout(g, a));
  1778. return e
  1779. }
  1780. };
  1781. an.debounce = function(u, t, r) {
  1782. var q, l, e, p, v, g = function() {
  1783. var a = an.now() - p;
  1784. a < t ? q = setTimeout(g, t - a) : (q = null, r || (v = u.apply(e, l), e = l = null))
  1785. };
  1786. return function() {
  1787. e = this;
  1788. l = arguments;
  1789. p = an.now();
  1790. var a = r && !q;
  1791. q || (q = setTimeout(g, t));
  1792. a && (v = u.apply(e, l), e = l = null);
  1793. return v
  1794. }
  1795. };
  1796. an.once = function(e) {
  1797. var d = !1,
  1798. f;
  1799. return function() {
  1800. if (d) {
  1801. return f
  1802. }
  1803. d = !0;
  1804. f = e.apply(this, arguments);
  1805. e = null;
  1806. return f
  1807. }
  1808. };
  1809. an.wrap = function(d, c) {
  1810. return an.partial(c, d)
  1811. };
  1812. an.compose = function() {
  1813. var b = arguments;
  1814. return function() {
  1815. for (var a = arguments,
  1816. d = b.length - 1; 0 <= d; d--) {
  1817. a = [b[d].apply(this, a)]
  1818. }
  1819. return a[0]
  1820. }
  1821. };
  1822. an.after = function(d, c) {
  1823. return function() {
  1824. if (1 > --d) {
  1825. return c.apply(this, arguments)
  1826. }
  1827. }
  1828. };
  1829. an.keys = function(e) {
  1830. if (!an.isObject(e)) {
  1831. return []
  1832. }
  1833. if (Q) {
  1834. return Q(e)
  1835. }
  1836. var d = [],
  1837. f;
  1838. for (f in e) {
  1839. an.has(e, f) && d.push(f)
  1840. }
  1841. return d
  1842. };
  1843. an.values = function(f) {
  1844. for (var e = an.keys(f), l = e.length, k = Array(l), g = 0; g < l; g++) {
  1845. k[g] = f[e[g]]
  1846. }
  1847. return k
  1848. };
  1849. an.pairs = function(f) {
  1850. for (var e = an.keys(f), l = e.length, k = Array(l), g = 0; g < l; g++) {
  1851. k[g] = [e[g], f[e[g]]]
  1852. }
  1853. return k
  1854. };
  1855. an.invert = function(f) {
  1856. for (var e = {},
  1857. l = an.keys(f), k = 0, g = l.length; k < g; k++) {
  1858. e[f[l[k]]] = l[k]
  1859. }
  1860. return e
  1861. };
  1862. an.functions = an.methods = function(e) {
  1863. var d = [],
  1864. f;
  1865. for (f in e) {
  1866. an.isFunction(e[f]) && d.push(f)
  1867. }
  1868. return d.sort()
  1869. };
  1870. an.extend = function(b) {
  1871. Y(al.call(arguments, 1),
  1872. function(a) {
  1873. if (a) {
  1874. for (var d in a) {
  1875. b[d] = a[d]
  1876. }
  1877. }
  1878. });
  1879. return b
  1880. };
  1881. an.pick = function(e) {
  1882. var d = {},
  1883. f = ag.apply(ao, al.call(arguments, 1));
  1884. Y(f,
  1885. function(a) {
  1886. a in e && (d[a] = e[a])
  1887. });
  1888. return d
  1889. };
  1890. an.omit = function(e) {
  1891. var d = {},
  1892. g = ag.apply(ao, al.call(arguments, 1)),
  1893. f;
  1894. for (f in e) {
  1895. an.contains(g, f) || (d[f] = e[f])
  1896. }
  1897. return d
  1898. };
  1899. an.defaults = function(b) {
  1900. Y(al.call(arguments, 1),
  1901. function(a) {
  1902. if (a) {
  1903. for (var d in a) {
  1904. void 0 === b[d] && (b[d] = a[d])
  1905. }
  1906. }
  1907. });
  1908. return b
  1909. };
  1910. an.clone = function(b) {
  1911. return ! an.isObject(b) ? b: an.isArray(b) ? b.slice() : an.extend({},
  1912. b)
  1913. };
  1914. an.tap = function(d, c) {
  1915. c(d);
  1916. return d
  1917. };
  1918. var X = function(k, g, t, r) {
  1919. if (k === g) {
  1920. return 0 !== k || 1 / k == 1 / g
  1921. }
  1922. if (null == k || null == g) {
  1923. return k === g
  1924. }
  1925. k instanceof an && (k = k._wrapped);
  1926. g instanceof an && (g = g._wrapped);
  1927. var p = ac.call(k);
  1928. if (p != ac.call(g)) {
  1929. return ! 1
  1930. }
  1931. switch (p) {
  1932. case "[object String]":
  1933. return k == String(g);
  1934. case "[object Number]":
  1935. return k != +k ? g != +g: 0 == k ? 1 / k == 1 / g: k == +g;
  1936. case "[object Date]":
  1937. case "[object Boolean]":
  1938. return + k == +g;
  1939. case "[object RegExp]":
  1940. return k.source == g.source && k.global == g.global && k.multiline == g.multiline && k.ignoreCase == g.ignoreCase
  1941. }
  1942. if ("object" != typeof k || "object" != typeof g) {
  1943. return ! 1
  1944. }
  1945. for (var e = t.length; e--;) {
  1946. if (t[e] == k) {
  1947. return r[e] == g
  1948. }
  1949. }
  1950. var e = k.constructor,
  1951. q = g.constructor;
  1952. if (e !== q && (!an.isFunction(e) || !(e instanceof e && an.isFunction(q) && q instanceof q)) && "constructor" in k && "constructor" in g) {
  1953. return ! 1
  1954. }
  1955. t.push(k);
  1956. r.push(g);
  1957. e = 0;
  1958. q = !0;
  1959. if ("[object Array]" == p) {
  1960. if (e = k.length, q = e == g.length) {
  1961. for (; e--&&(q = X(k[e], g[e], t, r));) {}
  1962. }
  1963. } else {
  1964. for (var l in k) {
  1965. if (an.has(k, l) && (e++, !(q = an.has(g, l) && X(k[l], g[l], t, r)))) {
  1966. break
  1967. }
  1968. }
  1969. if (q) {
  1970. for (l in g) {
  1971. if (an.has(g, l) && !e--) {
  1972. break
  1973. }
  1974. }
  1975. q = !e
  1976. }
  1977. }
  1978. t.pop();
  1979. r.pop();
  1980. return q
  1981. };
  1982. an.isEqual = function(d, c) {
  1983. return X(d, c, [], [])
  1984. };
  1985. an.isEmpty = function(d) {
  1986. if (null == d) {
  1987. return ! 0
  1988. }
  1989. if (an.isArray(d) || an.isString(d)) {
  1990. return 0 === d.length
  1991. }
  1992. for (var c in d) {
  1993. if (an.has(d, c)) {
  1994. return ! 1
  1995. }
  1996. }
  1997. return ! 0
  1998. };
  1999. an.isElement = function(b) {
  2000. return !! (b && 1 === b.nodeType)
  2001. };
  2002. an.isArray = am ||
  2003. function(b) {
  2004. return "[object Array]" == ac.call(b)
  2005. };
  2006. an.isObject = function(b) {
  2007. return b === Object(b)
  2008. };
  2009. Y("Arguments Function String Number Date RegExp".split(" "),
  2010. function(b) {
  2011. an["is" + b] = function(a) {
  2012. return ac.call(a) == "[object " + b + "]"
  2013. }
  2014. });
  2015. an.isArguments(arguments) || (an.isArguments = function(b) {
  2016. return ! (!b || !an.has(b, "callee"))
  2017. });
  2018. "function" !== typeof / . / &&(an.isFunction = function(b) {
  2019. return "function" === typeof b
  2020. });
  2021. an.isFinite = function(b) {
  2022. return isFinite(b) && !isNaN(parseFloat(b))
  2023. };
  2024. an.isNaN = function(b) {
  2025. return an.isNumber(b) && b != +b
  2026. };
  2027. an.isBoolean = function(b) {
  2028. return ! 0 === b || !1 === b || "[object Boolean]" == ac.call(b)
  2029. };
  2030. an.isNull = function(b) {
  2031. return null === b
  2032. };
  2033. an.isUndefined = function(b) {
  2034. return void 0 === b
  2035. };
  2036. an.has = function(d, c) {
  2037. return S.call(d, c)
  2038. };
  2039. an.noConflict = function() {
  2040. ar._ = aq;
  2041. return this
  2042. };
  2043. an.identity = function(b) {
  2044. return b
  2045. };
  2046. an.constant = function(b) {
  2047. return function() {
  2048. return b
  2049. }
  2050. };
  2051. an.property = function(b) {
  2052. return function(a) {
  2053. return a[b]
  2054. }
  2055. };
  2056. an.matches = function(b) {
  2057. return function(a) {
  2058. if (a === b) {
  2059. return ! 0
  2060. }
  2061. for (var d in b) {
  2062. if (b[d] !== a[d]) {
  2063. return ! 1
  2064. }
  2065. }
  2066. return ! 0
  2067. }
  2068. };
  2069. an.times = function(f, e, l) {
  2070. for (var k = Array(Math.max(0, f)), g = 0; g < f; g++) {
  2071. k[g] = e.call(l, g)
  2072. }
  2073. return k
  2074. };
  2075. an.random = function(d, c) {
  2076. null == c && (c = d, d = 0);
  2077. return d + Math.floor(Math.random() * (c - d + 1))
  2078. };
  2079. an.now = Date.now ||
  2080. function() {
  2081. return (new Date).getTime()
  2082. };
  2083. var O = {
  2084. escape: {
  2085. "\x26": "\x26amp;",
  2086. "\x3c": "\x26lt;",
  2087. "\x3e": "\x26gt;",
  2088. '"': "\x26quot;",
  2089. "'": "\x26#x27;"
  2090. }
  2091. };
  2092. O.unescape = an.invert(O.escape);
  2093. var N = {
  2094. escape: RegExp("[" + an.keys(O.escape).join("") + "]", "g"),
  2095. unescape: RegExp("(" + an.keys(O.unescape).join("|") + ")", "g")
  2096. };
  2097. an.each(["escape", "unescape"],
  2098. function(b) {
  2099. an[b] = function(a) {
  2100. return null == a ? "": ("" + a).replace(N[b],
  2101. function(c) {
  2102. return O[b][c]
  2103. })
  2104. }
  2105. });
  2106. an.result = function(e, d) {
  2107. if (null != e) {
  2108. var f = e[d];
  2109. return an.isFunction(f) ? f.call(e) : f
  2110. }
  2111. };
  2112. an.mixin = function(b) {
  2113. Y(an.functions(b),
  2114. function(a) {
  2115. var d = an[a] = b[a];
  2116. an.prototype[a] = function() {
  2117. var c = [this._wrapped];
  2118. aj.apply(c, arguments);
  2119. c = d.apply(an, c);
  2120. return this._chain ? an(c).chain() : c
  2121. }
  2122. })
  2123. };
  2124. var n = 0;
  2125. an.uniqueId = function(d) {
  2126. var c = ++n + "";
  2127. return d ? d + c: c
  2128. };
  2129. an.templateSettings = {
  2130. evaluate: /<%([\s\S]+?)%>/g,
  2131. interpolate: /<%=([\s\S]+?)%>/g,
  2132. escape: /<%-([\s\S]+?)%>/g
  2133. };
  2134. var V = /(.)^/,
  2135. j = {
  2136. "'": "'",
  2137. "\\": "\\",
  2138. "\r": "r",
  2139. "\n": "n",
  2140. "\t": "t",
  2141. "\u2028": "u2028",
  2142. "\u2029": "u2029"
  2143. },
  2144. i = /\\|'|\r|\n|\t|\u2028|\u2029/g;
  2145. an.template = function(k, g, t) {
  2146. var r;
  2147. t = an.defaults({},
  2148. t, an.templateSettings);
  2149. var p = RegExp([(t.escape || V).source, (t.interpolate || V).source, (t.evaluate || V).source].join("|") + "|$", "g"),
  2150. e = 0,
  2151. q = "__p+\x3d'";
  2152. k.replace(p,
  2153. function(a, u, s, f, m) {
  2154. q += k.slice(e, m).replace(i,
  2155. function(b) {
  2156. return "\\" + j[b]
  2157. });
  2158. u && (q += "'+\n((__t\x3d(" + u + "))\x3d\x3dnull?'':_.escape(__t))+\n'");
  2159. s && (q += "'+\n((__t\x3d(" + s + "))\x3d\x3dnull?'':__t)+\n'");
  2160. f && (q += "';\n" + f + "\n__p+\x3d'");
  2161. e = m + a.length;
  2162. return a
  2163. });
  2164. q += "';\n";
  2165. t.variable || (q = "with(obj||{}){\n" + q + "}\n");
  2166. q = "var __t,__p\x3d'',__j\x3dArray.prototype.join,print\x3dfunction(){__p+\x3d__j.call(arguments,'');};\n" + q + "return __p;\n";
  2167. try {
  2168. r = new Function(t.variable || "obj", "_", q)
  2169. } catch(l) {
  2170. throw l.source = q,
  2171. l
  2172. }
  2173. if (g) {
  2174. return r(g, an)
  2175. }
  2176. g = function(b) {
  2177. return r.call(this, b, an)
  2178. };
  2179. g.source = "function(" + (t.variable || "obj") + "){\n" + q + "}";
  2180. return g
  2181. };
  2182. an.chain = function(b) {
  2183. return an(b).chain()
  2184. };
  2185. an.mixin(an);
  2186. Y("pop push reverse shift sort splice unshift".split(" "),
  2187. function(d) {
  2188. var c = ao[d];
  2189. an.prototype[d] = function() {
  2190. var a = this._wrapped;
  2191. c.apply(a, arguments); ("shift" == d || "splice" == d) && 0 === a.length && delete a[0];
  2192. return this._chain ? an(a).chain() : a
  2193. }
  2194. });
  2195. Y(["concat", "join", "slice"],
  2196. function(d) {
  2197. var c = ao[d];
  2198. an.prototype[d] = function() {
  2199. var b = c.apply(this._wrapped, arguments);
  2200. return this._chain ? an(b).chain() : b
  2201. }
  2202. });
  2203. an.extend(an.prototype, {
  2204. chain: function() {
  2205. this._chain = !0;
  2206. return this
  2207. },
  2208. value: function() {
  2209. return this._wrapped
  2210. }
  2211. });
  2212. "function" === typeof define && define.amd && define("underscore", [],
  2213. function() {
  2214. return an
  2215. })
  2216. }).call(this); !
  2217. function(t, s) {
  2218. var q = s.prototype.trim,
  2219. o = s.prototype.trimRight,
  2220. n = s.prototype.trimLeft,
  2221. j = function(f, d) {
  2222. if (1 > d) {
  2223. return ""
  2224. }
  2225. for (var g = ""; 0 < d;) {
  2226. d & 1 && (g += f),
  2227. d >>= 1,
  2228. f += f
  2229. }
  2230. return g
  2231. },
  2232. m = [].slice,
  2233. h = function(b) {
  2234. return null == b ? "\\s": b.source ? b.source: "[" + i.escapeRegExp(b) + "]"
  2235. },
  2236. e = {
  2237. lt: "\x3c",
  2238. gt: "\x3e",
  2239. quot: '"',
  2240. apos: "'",
  2241. amp: "\x26"
  2242. },
  2243. x = {},
  2244. z;
  2245. for (z in e) {
  2246. x[e[z]] = z
  2247. }
  2248. var y = function() {
  2249. function b(a) {
  2250. return Object.prototype.toString.call(a).slice(8, -1).toLowerCase()
  2251. }
  2252. var d = function() {
  2253. d.cache.hasOwnProperty(arguments[0]) || (d.cache[arguments[0]] = d.parse(arguments[0]));
  2254. return d.format.call(null, d.cache[arguments[0]], arguments)
  2255. };
  2256. d.format = function(E, D) {
  2257. var v = 1,
  2258. B = E.length,
  2259. A = "",
  2260. u = [],
  2261. C,
  2262. w,
  2263. k,
  2264. a;
  2265. for (C = 0; C < B; C++) {
  2266. if (A = b(E[C]), "string" === A) {
  2267. u.push(E[C])
  2268. } else {
  2269. if ("array" === A) {
  2270. k = E[C];
  2271. if (k[2]) {
  2272. A = D[v];
  2273. for (w = 0; w < k[2].length; w++) {
  2274. if (!A.hasOwnProperty(k[2][w])) {
  2275. throw Error(y('[_.sprintf] property "%s" does not exist', k[2][w]))
  2276. }
  2277. A = A[k[2][w]]
  2278. }
  2279. } else {
  2280. A = k[1] ? D[k[1]] : D[v++]
  2281. }
  2282. if (/[^s]/.test(k[8]) && "number" != b(A)) {
  2283. throw Error(y("[_.sprintf] expecting number but found %s", b(A)))
  2284. }
  2285. switch (k[8]) {
  2286. case "b":
  2287. A = A.toString(2);
  2288. break;
  2289. case "c":
  2290. A = s.fromCharCode(A);
  2291. break;
  2292. case "d":
  2293. A = parseInt(A, 10);
  2294. break;
  2295. case "e":
  2296. A = k[7] ? A.toExponential(k[7]) : A.toExponential();
  2297. break;
  2298. case "f":
  2299. A = k[7] ? parseFloat(A).toFixed(k[7]) : parseFloat(A);
  2300. break;
  2301. case "o":
  2302. A = A.toString(8);
  2303. break;
  2304. case "s":
  2305. A = (A = s(A)) && k[7] ? A.substring(0, k[7]) : A;
  2306. break;
  2307. case "u":
  2308. A = Math.abs(A);
  2309. break;
  2310. case "x":
  2311. A = A.toString(16);
  2312. break;
  2313. case "X":
  2314. A = A.toString(16).toUpperCase()
  2315. }
  2316. A = /[def]/.test(k[8]) && k[3] && 0 <= A ? "+" + A: A;
  2317. w = k[4] ? "0" == k[4] ? "0": k[4].charAt(1) : " ";
  2318. a = k[6] - s(A).length;
  2319. w = k[6] ? j(w, a) : "";
  2320. u.push(k[5] ? A + w: w + A)
  2321. }
  2322. }
  2323. }
  2324. return u.join("")
  2325. };
  2326. d.cache = {};
  2327. d.parse = function(k) {
  2328. for (var g = [], u = [], r = 0; k;) {
  2329. if (null !== (g = /^[^\x25]+/.exec(k))) {
  2330. u.push(g[0])
  2331. } else {
  2332. if (null !== (g = /^\x25{2}/.exec(k))) {
  2333. u.push("%")
  2334. } else {
  2335. if (null !== (g = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(k))) {
  2336. if (g[2]) {
  2337. var r = r | 1,
  2338. l = [],
  2339. f = g[2],
  2340. p = [];
  2341. if (null !== (p = /^([a-z_][a-z_\d]*)/i.exec(f))) {
  2342. for (l.push(p[1]);
  2343. "" !== (f = f.substring(p[0].length));) {
  2344. if (null !== (p = /^\.([a-z_][a-z_\d]*)/i.exec(f))) {
  2345. l.push(p[1])
  2346. } else {
  2347. if (null !== (p = /^\[(\d+)\]/.exec(f))) {
  2348. l.push(p[1])
  2349. } else {
  2350. throw Error("[_.sprintf] huh?")
  2351. }
  2352. }
  2353. }
  2354. } else {
  2355. throw Error("[_.sprintf] huh?")
  2356. }
  2357. g[2] = l
  2358. } else {
  2359. r |= 2
  2360. }
  2361. if (3 === r) {
  2362. throw Error("[_.sprintf] mixing positional and named placeholders is not (yet) supported")
  2363. }
  2364. u.push(g)
  2365. } else {
  2366. throw Error("[_.sprintf] huh?")
  2367. }
  2368. }
  2369. }
  2370. k = k.substring(g[0].length)
  2371. }
  2372. return u
  2373. };
  2374. return d
  2375. } (),
  2376. i = {
  2377. VERSION: "2.3.0",
  2378. isBlank: function(b) {
  2379. null == b && (b = "");
  2380. return /^\s*$/.test(b)
  2381. },
  2382. stripTags: function(b) {
  2383. return null == b ? "": s(b).replace(/<\/?[^>]+>/g, "")
  2384. },
  2385. capitalize: function(b) {
  2386. b = null == b ? "": s(b);
  2387. return b.charAt(0).toUpperCase() + b.slice(1)
  2388. },
  2389. chop: function(b, d) {
  2390. if (null == b) {
  2391. return []
  2392. }
  2393. b = s(b);
  2394. d = ~~d;
  2395. return 0 < d ? b.match(RegExp(".{1," + d + "}", "g")) : [b]
  2396. },
  2397. clean: function(b) {
  2398. return i.strip(b).replace(/\s+/g, " ")
  2399. },
  2400. count: function(b, d) {
  2401. return null == b || null == d ? 0 : s(b).split(d).length - 1
  2402. },
  2403. chars: function(b) {
  2404. return null == b ? [] : s(b).split("")
  2405. },
  2406. swapCase: function(b) {
  2407. return null == b ? "": s(b).replace(/\S/g,
  2408. function(c) {
  2409. return c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase()
  2410. })
  2411. },
  2412. escapeHTML: function(b) {
  2413. return null == b ? "": s(b).replace(/[&<>"']/g,
  2414. function(c) {
  2415. return "\x26" + x[c] + ";"
  2416. })
  2417. },
  2418. unescapeHTML: function(b) {
  2419. return null == b ? "": s(b).replace(/\&([^;]+);/g,
  2420. function(f, k) {
  2421. var g;
  2422. return k in e ? e[k] : (g = k.match(/^#x([\da-fA-F]+)$/)) ? s.fromCharCode(parseInt(g[1], 16)) : (g = k.match(/^#(\d+)$/)) ? s.fromCharCode(~~g[1]) : f
  2423. })
  2424. },
  2425. escapeRegExp: function(b) {
  2426. return null == b ? "": s(b).replace(/([.*+?^=!:${}()|[\]\/\\])/g, "\\$1")
  2427. },
  2428. splice: function(g, f, l, k) {
  2429. g = i.chars(g);
  2430. g.splice(~~f, ~~l, k);
  2431. return g.join("")
  2432. },
  2433. insert: function(f, d, g) {
  2434. return i.splice(f, d, 0, g)
  2435. },
  2436. include: function(b, d) {
  2437. return "" === d ? !0 : null == b ? !1 : -1 !== s(b).indexOf(d)
  2438. },
  2439. join: function() {
  2440. var d = m.call(arguments),
  2441. c = d.shift();
  2442. null == c && (c = "");
  2443. return d.join(c)
  2444. },
  2445. lines: function(b) {
  2446. return null == b ? [] : s(b).split("\n")
  2447. },
  2448. reverse: function(b) {
  2449. return i.chars(b).reverse().join("")
  2450. },
  2451. startsWith: function(b, d) {
  2452. if ("" === d) {
  2453. return ! 0
  2454. }
  2455. if (null == b || null == d) {
  2456. return ! 1
  2457. }
  2458. b = s(b);
  2459. d = s(d);
  2460. return b.length >= d.length && b.slice(0, d.length) === d
  2461. },
  2462. endsWith: function(b, d) {
  2463. if ("" === d) {
  2464. return ! 0
  2465. }
  2466. if (null == b || null == d) {
  2467. return ! 1
  2468. }
  2469. b = s(b);
  2470. d = s(d);
  2471. return b.length >= d.length && b.slice(b.length - d.length) === d
  2472. },
  2473. succ: function(b) {
  2474. if (null == b) {
  2475. return ""
  2476. }
  2477. b = s(b);
  2478. return b.slice(0, -1) + s.fromCharCode(b.charCodeAt(b.length - 1) + 1)
  2479. },
  2480. titleize: function(b) {
  2481. return null == b ? "": s(b).replace(/(?:^|\s)\S/g,
  2482. function(c) {
  2483. return c.toUpperCase()
  2484. })
  2485. },
  2486. camelize: function(b) {
  2487. return i.trim(b).replace(/[-_\s]+(.)?/g,
  2488. function(d, c) {
  2489. return c.toUpperCase()
  2490. })
  2491. },
  2492. underscored: function(b) {
  2493. return i.trim(b).replace(/([a-z\d])([A-Z]+)/g, "$1_$2").replace(/[-\s]+/g, "_").toLowerCase()
  2494. },
  2495. dasherize: function(b) {
  2496. return i.trim(b).replace(/([A-Z])/g, "-$1").replace(/[-_\s]+/g, "-").toLowerCase()
  2497. },
  2498. classify: function(b) {
  2499. return i.titleize(s(b).replace(/_/g, " ")).replace(/\s/g, "")
  2500. },
  2501. humanize: function(b) {
  2502. return i.capitalize(i.underscored(b).replace(/_id$/, "").replace(/_/g, " "))
  2503. },
  2504. trim: function(b, c) {
  2505. if (null == b) {
  2506. return ""
  2507. }
  2508. if (!c && q) {
  2509. return q.call(b)
  2510. }
  2511. c = h(c);
  2512. return s(b).replace(RegExp("^" + c + "+|" + c + "+$", "g"), "")
  2513. },
  2514. ltrim: function(b, d) {
  2515. if (null == b) {
  2516. return ""
  2517. }
  2518. if (!d && n) {
  2519. return n.call(b)
  2520. }
  2521. d = h(d);
  2522. return s(b).replace(RegExp("^" + d + "+"), "")
  2523. },
  2524. rtrim: function(b, d) {
  2525. if (null == b) {
  2526. return ""
  2527. }
  2528. if (!d && o) {
  2529. return o.call(b)
  2530. }
  2531. d = h(d);
  2532. return s(b).replace(RegExp(d + "+$"), "")
  2533. },
  2534. truncate: function(b, g, f) {
  2535. if (null == b) {
  2536. return ""
  2537. }
  2538. b = s(b);
  2539. g = ~~g;
  2540. return b.length > g ? b.slice(0, g) + (f || "...") : b
  2541. },
  2542. prune: function(b, g, f) {
  2543. if (null == b) {
  2544. return ""
  2545. }
  2546. b = s(b);
  2547. g = ~~g;
  2548. f = null != f ? s(f) : "...";
  2549. if (b.length <= g) {
  2550. return b
  2551. }
  2552. g = b.slice(0, g + 1).replace(/.(?=\W*\w*$)/g,
  2553. function(c) {
  2554. return c.toUpperCase() !== c.toLowerCase() ? "A": " "
  2555. });
  2556. g = g.slice(g.length - 2).match(/\w\w/) ? g.replace(/\s*\S+$/, "") : i.rtrim(g.slice(0, g.length - 1));
  2557. return (g + f).length > b.length ? b: b.slice(0, g.length) + f
  2558. },
  2559. words: function(d, c) {
  2560. return i.isBlank(d) ? [] : i.trim(d, c).split(c || /\s+/)
  2561. },
  2562. pad: function(b, r, p, l) {
  2563. b = null == b ? "": s(b);
  2564. r = ~~r;
  2565. var k = 0;
  2566. p ? 1 < p.length && (p = p.charAt(0)) : p = " ";
  2567. switch (l) {
  2568. case "right":
  2569. return k = r - b.length,
  2570. b + j(p, k);
  2571. case "both":
  2572. return k = r - b.length,
  2573. j(p, Math.ceil(k / 2)) + b + j(p, Math.floor(k / 2));
  2574. default:
  2575. return k = r - b.length,
  2576. j(p, k) + b
  2577. }
  2578. },
  2579. lpad: function(f, d, g) {
  2580. return i.pad(f, d, g)
  2581. },
  2582. rpad: function(f, d, g) {
  2583. return i.pad(f, d, g, "right")
  2584. },
  2585. lrpad: function(f, d, g) {
  2586. return i.pad(f, d, g, "both")
  2587. },
  2588. sprintf: y,
  2589. vsprintf: function(d, c) {
  2590. c.unshift(d);
  2591. return y.apply(null, c)
  2592. },
  2593. toNumber: function(b, g) {
  2594. if (null == b || "" == b) {
  2595. return 0
  2596. }
  2597. b = s(b);
  2598. var f;
  2599. f = 1 * (1 * b || 0).toFixed(~~g) || 0;
  2600. return 0 === f && !b.match(/^0+$/) ? Number.NaN: f
  2601. },
  2602. numberFormat: function(g, f, l, k) {
  2603. if (isNaN(g) || null == g) {
  2604. return ""
  2605. }
  2606. g = g.toFixed(~~f);
  2607. k = k || ",";
  2608. g = g.split(".");
  2609. l = g[1] ? (l || ".") + g[1] : "";
  2610. return g[0].replace(/(\d)(?=(?:\d{3})+$)/g, "$1" + k) + l
  2611. },
  2612. strRight: function(b, g) {
  2613. if (null == b) {
  2614. return ""
  2615. }
  2616. b = s(b);
  2617. g = null != g ? s(g) : g;
  2618. var f = !g ? -1 : b.indexOf(g);
  2619. return~f ? b.slice(f + g.length, b.length) : b
  2620. },
  2621. strRightBack: function(b, g) {
  2622. if (null == b) {
  2623. return ""
  2624. }
  2625. b = s(b);
  2626. g = null != g ? s(g) : g;
  2627. var f = !g ? -1 : b.lastIndexOf(g);
  2628. return~f ? b.slice(f + g.length, b.length) : b
  2629. },
  2630. strLeft: function(b, g) {
  2631. if (null == b) {
  2632. return ""
  2633. }
  2634. b = s(b);
  2635. g = null != g ? s(g) : g;
  2636. var f = !g ? -1 : b.indexOf(g);
  2637. return~f ? b.slice(0, f) : b
  2638. },
  2639. strLeftBack: function(f, d) {
  2640. if (null == f) {
  2641. return ""
  2642. }
  2643. f += "";
  2644. var g = f.lastIndexOf(null != d ? "" + d: d);
  2645. return~g ? f.slice(0, g) : f
  2646. },
  2647. toSentence: function(l, k, v, u) {
  2648. k = k || ", ";
  2649. v = v || " and ";
  2650. var r = l.slice(),
  2651. p = r.pop();
  2652. 2 < l.length && u && (v = i.rtrim(k) + v);
  2653. return r.length ? r.join(k) + v + p: p
  2654. },
  2655. toSentenceSerial: function() {
  2656. var b = m.call(arguments);
  2657. b[3] = !0;
  2658. return i.toSentence.apply(i, b)
  2659. },
  2660. slugify: function(b) {
  2661. if (null == b) {
  2662. return ""
  2663. }
  2664. var d = RegExp(h("\u0105\u00e0\u00e1\u00e4\u00e2\u00e3\u00e5\u00e6\u0107\u0119\u00e8\u00e9\u00eb\u00ea\u00ec\u00ed\u00ef\u00ee\u0142\u0144\u00f2\u00f3\u00f6\u00f4\u00f5\u00f8\u00f9\u00fa\u00fc\u00fb\u00f1\u00e7\u017c\u017a"), "g");
  2665. b = s(b).toLowerCase().replace(d,
  2666. function(c) {
  2667. c = "\u0105\u00e0\u00e1\u00e4\u00e2\u00e3\u00e5\u00e6\u0107\u0119\u00e8\u00e9\u00eb\u00ea\u00ec\u00ed\u00ef\u00ee\u0142\u0144\u00f2\u00f3\u00f6\u00f4\u00f5\u00f8\u00f9\u00fa\u00fc\u00fb\u00f1\u00e7\u017c\u017a".indexOf(c);
  2668. return "aaaaaaaaceeeeeiiiilnoooooouuuunczz".charAt(c) || "-"
  2669. });
  2670. return i.dasherize(b.replace(/[^\w\s-]/g, ""))
  2671. },
  2672. surround: function(d, c) {
  2673. return [c, d, c].join("")
  2674. },
  2675. quote: function(b) {
  2676. return i.surround(b, '"')
  2677. },
  2678. exports: function() {
  2679. var d = {},
  2680. c;
  2681. for (c in this) {
  2682. this.hasOwnProperty(c) && !c.match(/^(?:include|contains|reverse)$/) && (d[c] = this[c])
  2683. }
  2684. return d
  2685. },
  2686. repeat: function(b, l, k) {
  2687. if (null == b) {
  2688. return ""
  2689. }
  2690. l = ~~l;
  2691. if (null == k) {
  2692. return j(s(b), l)
  2693. }
  2694. for (var g = []; 0 < l; g[--l] = b) {}
  2695. return g.join(k)
  2696. },
  2697. levenshtein: function(p, A) {
  2698. if (null == p && null == A) {
  2699. return 0
  2700. }
  2701. if (null == p) {
  2702. return s(A).length
  2703. }
  2704. if (null == A) {
  2705. return s(p).length
  2706. }
  2707. p = s(p);
  2708. A = s(A);
  2709. for (var w = [], v, u, r = 0; r <= A.length; r++) {
  2710. for (var b = 0; b <= p.length; b++) {
  2711. u = r && b ? p.charAt(b - 1) === A.charAt(r - 1) ? v: Math.min(w[b], w[b - 1], v) + 1 : r + b,
  2712. v = w[b],
  2713. w[b] = u
  2714. }
  2715. }
  2716. return w.pop()
  2717. }
  2718. };
  2719. i.strip = i.trim;
  2720. i.lstrip = i.ltrim;
  2721. i.rstrip = i.rtrim;
  2722. i.center = i.lrpad;
  2723. i.rjust = i.lpad;
  2724. i.ljust = i.rpad;
  2725. i.contains = i.include;
  2726. i.q = i.quote;
  2727. "undefined" !== typeof exports ? ("undefined" !== typeof module && module.exports && (module.exports = i), exports._s = i) : "function" === typeof define && define.amd ? define("underscore.string", [],
  2728. function() {
  2729. return i
  2730. }) : (t._ = t._ || {},
  2731. t._.string = t._.str = i)
  2732. } (this, String);
  2733. _.mixin(_.str.exports());
  2734. bs = bs || {};
  2735. bs.s_sharelayer_ccbi = "js_bscommon/res/shareLayer.ccbi";
  2736. bs.init = function() {
  2737. cc.Sequence.createWithArray = function(d) {
  2738. if (0 === d.length) {
  2739. return cc.Sequence.create()
  2740. }
  2741. if (1 === d.length) {
  2742. return cc.Sequence.create(d[0])
  2743. }
  2744. if (2 === d.length) {
  2745. return cc.Sequence.create(d[0], d[1])
  2746. }
  2747. var c = d.pop();
  2748. return cc.Sequence.create(cc.Sequence.createWithArray(d), c)
  2749. };
  2750. bs.isInBrowser() && (bs._originEGLViewConvertToLocationInView || (bs._originEGLViewConvertToLocationInView = cc.view.convertToLocationInView), cc.view.convertToLocationInView = function(e, d, f) {
  2751. e = bs._originEGLViewConvertToLocationInView.call(cc.view, e, d, f);
  2752. window && window.canvasScale && (d = window.canvasScale, e.x /= d, e.y /= d);
  2753. return e
  2754. });
  2755. cc.PhysicsSprite && (cc.PhysicsSprite.extend = cc.Class.extend);
  2756. cc.ClippingNode && (cc.ClippingNode.extend = cc.Class.extend);
  2757. cc.Scale9Sprite && (cc.Scale9Sprite.extend = cc.Class.extend);
  2758. cc.ParallaxNode && (cc.ParallaxNode.extend = cc.Class.extend)
  2759. };
  2760. bs.System = bs.System || {};
  2761. bs.System.currentTimeMillis = function() {
  2762. return (new Date).getTime()
  2763. };
  2764. bs.onPlatformBuyGoodSuccess = function() {};
  2765. bs.onPlatformBuyGoodFail = function() {};
  2766. bs.onPlatformRestoreFinish = function() {};
  2767. bs.onPlatformRestoreFail = function() {};
  2768. bs.Pay = bs.Pay || {};
  2769. bs.Pay.kPayMethodAppstore = 1;
  2770. bs.Pay.kPayMethodChinaMobile = 2;
  2771. bs.Pay.kPayMethodChinaUnicom = 3;
  2772. bs.Pay.kPayMethodChinaTelecom = 4;
  2773. bs.Pay.kPayMethodAlipay = 5;
  2774. bs.Pay.kPayMethodWechat = 6;
  2775. bs.Pay.kPayMethodQQ = 7;
  2776. "undefined" === typeof cc.GRAY && (cc.GRAY = {
  2777. r: 166,
  2778. g: 166,
  2779. b: 166
  2780. });
  2781. String.prototype.format = function(b) {
  2782. return this.replace(String.prototype.format.regex,
  2783. function(a) {
  2784. a = parseInt(a.substring(1, a.length - 1));
  2785. return 0 <= a ? b[a] : -1 === a ? "{": -2 === a ? "}": ""
  2786. })
  2787. };
  2788. String.prototype.format.regex = /{-?[0-9]+}/g;
  2789. bs.stringFromFormat = function(d, c) {
  2790. return d.format(c)
  2791. };
  2792. bs.fabs = function(b) {
  2793. return 0 > b ? -b: b
  2794. };
  2795. bs.stringFromSecondsClockStyle = function(e) {
  2796. var d = Math.floor(e / 3600),
  2797. f = Math.floor((e - 3600 * d) / 60);
  2798. return "{0}:{1}:{2}".format([d, f, e - 3600 * d - 60 * f])
  2799. };
  2800. bs.middleOfNode = function(b) {
  2801. return cc.p(b.getContentSize().width / 2, b.getContentSize().height / 2)
  2802. };
  2803. bs.middleOfWindow = function() {
  2804. var b = cc.director.getWinSize();
  2805. return cc.p(b.width / 2, b.height / 2)
  2806. };
  2807. bs.c4BFromccc3B = function(b) {
  2808. return cc.color(b.r, b.g, b.b, 255)
  2809. };
  2810. bs.jsonFromFile = function(a) {
  2811. return eval("(" + cc.FileUtils.getInstance().getStringFromFile(a) + ")")
  2812. };
  2813. bs.parseJSON = function(d) {
  2814. try {
  2815. return JSON.parse(d)
  2816. } catch(c) {
  2817. return cc.log("[JSON]:" + c.message),
  2818. cc.log("[JSON]:" + c.description),
  2819. null
  2820. }
  2821. };
  2822. bs.toJSONString = function(d) {
  2823. try {
  2824. return JSON.stringify(d)
  2825. } catch(c) {
  2826. return cc.log(c.message),
  2827. cc.log(c.description),
  2828. null
  2829. }
  2830. };
  2831. bs.SAFE_REMOVE = function(b) {
  2832. b && b.removeFromParent()
  2833. };
  2834. bs.RAND = function(d, c) {
  2835. return d + Math.floor(Math.random() * (c - d))
  2836. };
  2837. bs.surround = function(f, e, h, g) {
  2838. return _.filter([[f - 1, e - 1], [f, e - 1], [f + 1, e - 1], [f - 1, e], [f, e], [f + 1, e], [f - 1, e + 1], [f, e + 1], [f + 1, e + 1]],
  2839. function(b) {
  2840. return 0 <= b[0] && 0 <= b[1] && b[0] < h && b[1] < g
  2841. })
  2842. };
  2843. bs.isInBrowser = function() {
  2844. return ! cc.sys.isNative
  2845. };
  2846. bs.ALLOCATE_PRIORITY = function() {
  2847. return bs.TouchPriorityManager.getInstance().allocatePriority()
  2848. };
  2849. bs._s4 = function() {
  2850. return Math.floor(65536 * (1 + Math.random())).toString(16).substring(1)
  2851. };
  2852. bs.guid = function() {
  2853. return bs._s4() + bs._s4() + "-" + bs._s4() + "-" + bs._s4() + "-" + bs._s4() + "-" + bs._s4() + bs._s4() + bs._s4()
  2854. };
  2855. bs.setFlipX = function(d, c) {
  2856. d.setFlipX ? d.setFlipX(c) : d.setFlippedX(c)
  2857. };
  2858. bs.setFlipY = function(d, c) {
  2859. d.setFlipY ? d.setFlipY(c) : d.setFlippedY(c)
  2860. };
  2861. bs.getTop = function(b) {
  2862. return cc.rectGetMaxY(b.getBoundingBox())
  2863. };
  2864. bs.getTopOnScreen = function(b) {
  2865. return cc.rectGetMaxY(b.getBoundingBoxToWorld())
  2866. };
  2867. bs.getBottom = function(b) {
  2868. return cc.rectGetMinY(b.getBoundingBox())
  2869. };
  2870. bs.getBottomOnScreen = function(b) {
  2871. return cc.rectGetMinY(b.getBoundingBoxToWorld())
  2872. };
  2873. bs.getLeft = function(b) {
  2874. return cc.rectGetMinX(b.getBoundingBox())
  2875. };
  2876. bs.getRight = function(b) {
  2877. return cc.rectGetMaxX(b.getBoundingBox())
  2878. };
  2879. bs.getVisualWidth = function(b) {
  2880. return b.getContentSize().width * b.getScaleX()
  2881. };
  2882. bs.getVisualHeight = function(b) {
  2883. return b.getContentSize().height * b.getScaleY()
  2884. };
  2885. bs.getVisualSize = function(d) {
  2886. var c = d.getContentSize();
  2887. return cc.size(c.width * d.getScaleX(), c.height * d.getScaleY())
  2888. };
  2889. bs.centerNodeToParent = function(d, c) {
  2890. bs.positionNodeToParentPercent(d, c, 0.5, 0.5)
  2891. };
  2892. bs.positionNodeToParentPercent = function(g, e, l, j) {
  2893. e = (e || g.getParent()).getContentSize();
  2894. var i = bs.getVisualSize(g),
  2895. h = g.isIgnoreAnchorPointForPosition() ? cc.p(0, 0) : g.getAnchorPoint();
  2896. g.setPosition(cc.p(e.width * l + (h.x - 0.5) * i.width, e.height * j + (h.y - 0.5) * i.height))
  2897. };
  2898. bs.centerNodeXToParent = function(d, c) {
  2899. c = c || d.getParent();
  2900. d.setPositionX(c.getContentSize().width / 2 + (d.getAnchorPoint().x - 0.5) * d.getContentSize().width)
  2901. };
  2902. bs.centerNodeYToParent = function(d, c) {
  2903. c = c || d.getParent();
  2904. d.setPositionY(c.getContentSize().height / 2 + (d.getAnchorPoint().y - 0.5) * d.getContentSize().height)
  2905. };
  2906. bs.scaleToWidth = function(d, c) {
  2907. d.setScale(c / d.getContentSize().width)
  2908. };
  2909. bs.scaleToHeight = function(d, c) {
  2910. d.setScale(c / d.getContentSize().height)
  2911. };
  2912. bs.scaleToSize = function(f, e, h) {
  2913. var g = h ? e: e.width;
  2914. h = h ? h: e.height;
  2915. bs.scaleXToWidth(f, g);
  2916. bs.scaleYToHeight(f, h)
  2917. };
  2918. bs.scaleXToWidth = function(d, c) {
  2919. d.setScaleX(c / d.getContentSize().width)
  2920. };
  2921. bs.scaleYToHeight = function(d, c) {
  2922. d.setScaleY(c / d.getContentSize().height)
  2923. };
  2924. bs.TexParams = function(g, e, j, i) {
  2925. var h = {};
  2926. h.minFilter = g || 0;
  2927. h.magFilter = e || 0;
  2928. h.wrapS = j || 0;
  2929. h.wrapT = i || 0;
  2930. return h
  2931. };
  2932. bs.autoSprite = function(b) {
  2933. return cc.spriteFrameCache.getSpriteFrame(b) ? new cc.Sprite("#" + b) : cc.Sprite.create(b)
  2934. };
  2935. bs.isInWechat = function() {
  2936. return ! _.isUndefined(navigator) && !_.isUndefined(navigator.userAgent) ? -1 != navigator.userAgent.toLowerCase().indexOf("micromessenger") : !1
  2937. };
  2938. bs.headimgForQQ = function(d, c) {
  2939. return "/proxy?url\x3d" + encodeURIComponent(d.replace(/\/[0-9]+$/, "/" + c))
  2940. };
  2941. bs.setAllMenuEnabledWithNode = function(e, d) {
  2942. for (var f = 0; f < e.getChildrenCount(); ++f) {
  2943. this.setAllMenuEnabledWithNode(e.getChildren()[f], d)
  2944. }
  2945. e instanceof cc.Menu && e.setEnabled(d)
  2946. };
  2947. bs.versionCompare = function(g, e) {
  2948. if ("stringstring" != typeof g + typeof e) {
  2949. return ! 1
  2950. }
  2951. for (var l = g.split("."), j = e.split("."), i = 0, h = Math.max(l.length, j.length); i < h; i++) {
  2952. if (l[i] && !j[i] && 0 < parseInt(l[i]) || parseInt(l[i]) > parseInt(j[i])) {
  2953. return 1
  2954. }
  2955. if (j[i] && !l[i] && 0 < parseInt(j[i]) || parseInt(l[i]) < parseInt(j[i])) {
  2956. return - 1
  2957. }
  2958. }
  2959. return 0
  2960. };
  2961. bs.createSpriteWithAnimate = function(h, e, n, m, l, i) {
  2962. var j = new cc.Sprite("#" + h + e + ".png");
  2963. h = bs.createAnimate(h, e + 1, n, m); - 1 == l ? j.runAction(cc.RepeatForever.create(h)) : (0 < l && (h = cc.Repeat.create(h, l)), i && (h = cc.Sequence.create(h, cc.RemoveSelf.create())), j.runAction(h));
  2964. return j
  2965. };
  2966. bs.createAnimate = function(h, e, o, n, l) {
  2967. var i = h + "_" + e + "_" + o,
  2968. j = cc.animationCache.getAnimation(i);
  2969. if (!j) {
  2970. for (j = []; - 1 == o || e <= o; ++e) {
  2971. var m = bs.spriteFrameFromName(h + e + ".png");
  2972. if (!m) {
  2973. break
  2974. }
  2975. j.push(m)
  2976. }
  2977. j = new cc.Animation(j, n);
  2978. cc.animationCache.addAnimation(j, i)
  2979. }
  2980. h = cc.Animate.create(j);
  2981. l && ( - 1 == l ? h.repeatForever() : h.repeat(l));
  2982. return h
  2983. };
  2984. bs.spriteFrameFromName = function(b) {
  2985. _.endsWith(b, ".png") || (b += ".png");
  2986. return cc.spriteFrameCache.getSpriteFrame(b)
  2987. };
  2988. bs.setSpriteDisplayFrameName = function(e, d, f) {
  2989. d = bs.spriteFrameFromName(d);
  2990. e.setSpriteFrame(d);
  2991. f && e.setContentSize(d.getOriginalSize())
  2992. };
  2993. bs.logf = function() {
  2994. var b = _.sprintf.apply(_, arguments);
  2995. cc.sys.isNative ? cc.log(b) : cc.IS_SHOW_DEBUG_ON_PAGE ? cc._logToWebPage(b) : console.log(b)
  2996. };
  2997. bs.isTouchInside = function(f, e, h) {
  2998. f = e.convertTouchToNodeSpace(f);
  2999. var g = e.getContentSize().width * e.getScaleX();
  3000. e = e.getContentSize().height * e.getScaleY();
  3001. h = h || cc.rect(0, 0, g, e);
  3002. return cc.rectContainsPoint(h, f)
  3003. };
  3004. bs.createClippingNode = function(e) {
  3005. var d = cc.DrawNode.create(),
  3006. f = cc.color(1, 1, 1, 1);
  3007. e = [cc.p(e.x, e.y), cc.p(e.x + e.width, e.y), cc.p(e.x + e.width, e.y + e.height), cc.p(e.x, e.y + e.height)];
  3008. d.drawPoly(e, f, 1, f);
  3009. return cc.ClippingNode.create(d)
  3010. };
  3011. bs.clone = function(e) {
  3012. var d = e instanceof Array ? [] : {},
  3013. f;
  3014. for (f in e) {
  3015. e.hasOwnProperty(f) && !_.isFunction(e[f]) && (d[f] = _.isObject(e[f]) ? bs.clone(e[f]) : e[f])
  3016. }
  3017. return d
  3018. };
  3019. bs.convertPositionToTargetNodeSpace = function(g, e, j) {
  3020. var i = g.getAnchorPoint(),
  3021. h = g.getContentSize();
  3022. j = j || cc.p(h.width * i.x, h.height * i.y);
  3023. g = g.convertToWorldSpace(j);
  3024. return e.convertToNodeSpace(g)
  3025. };
  3026. bs.jsonFromConfFile = function(d) {
  3027. if (this.isInBrowser()) {
  3028. var c = cc.loader.getRes("conf/" + d + ".json");
  3029. if (c) {
  3030. return c
  3031. }
  3032. d = cc.loader._loadTxtSync("res/conf/" + d + ".json")
  3033. } else {
  3034. d = bs.Config.shared().loadConf("conf/" + d + ".bjs")
  3035. }
  3036. return bs.parseJSON(d)
  3037. };
  3038. bs.isNodeVisible = function(b) {
  3039. for (; b && b.isVisible();) {
  3040. b = b.getParent()
  3041. }
  3042. return ! b
  3043. };
  3044. bs.layerWithChildrenHorizontal = function(h, e, n, m) {
  3045. var l = cc.Layer.create(),
  3046. i = 0;
  3047. null == n && (n = cc.VERTICAL_TEXT_ALIGNMENT_CENTER);
  3048. m || (m = 0, _.each(h,
  3049. function(b) {
  3050. b = bs.getVisualSize(b).height;
  3051. m < b && (m = b)
  3052. }));
  3053. var j = [1, 0.5, 0];
  3054. _.each(h,
  3055. function(c) {
  3056. if (c) {
  3057. var f = bs.getVisualSize(c),
  3058. b = c.getAnchorPoint();
  3059. c.isIgnoreAnchorPointForPosition() && (b = cc.p(0, 0));
  3060. var d = cc.p(i, j[n] * (m - f.height));
  3061. c.setPosition(cc.pAdd(d, cc.pCompMult(b, cc.pFromSize(f))));
  3062. i += f.width + e;
  3063. l.addChild(c)
  3064. }
  3065. });
  3066. l.setContentSize(i - e, m);
  3067. l.setAnchorPoint(0, 0);
  3068. return l
  3069. };
  3070. bs.layerWithChildrenVertical = function(h, e, n, m) {
  3071. var l = cc.Layer.create(),
  3072. i = 0;
  3073. if (_.isUndefined(n) || _.isNull(n)) {
  3074. n = cc.TEXT_ALIGNMENT_CENTER
  3075. }
  3076. m || (m = 0, _.each(h,
  3077. function(b) {
  3078. b && (b = b.getContentSize().width, m < b && (m = b))
  3079. }));
  3080. var j = [0, 0.5, 1];
  3081. h.reverse();
  3082. _.each(h,
  3083. function(c) {
  3084. if (c) {
  3085. var f = bs.getVisualSize(c),
  3086. b = c.getAnchorPoint();
  3087. c.isIgnoreAnchorPointForPosition() && (b = cc.p(0, 0));
  3088. var d = cc.p(j[n] * (m - f.width), i);
  3089. c.setPosition(cc.pAdd(d, cc.pCompMult(b, cc.pFromSize(f))));
  3090. i += f.height + e;
  3091. l.addChild(c)
  3092. }
  3093. });
  3094. l.setContentSize(m, i - e);
  3095. l.setAnchorPoint(0, 0);
  3096. return l
  3097. };
  3098. bs.formatTime = function(f) {
  3099. var e = Math.floor(f / 3600);
  3100. f = Math.floor(f % 3600);
  3101. var h = Math.floor(f / 60);
  3102. f %= 60;
  3103. var g = "",
  3104. g = 10 <= e ? e: "0" + e,
  3105. g = 10 <= h ? g + ":" + h: g + ":0" + h;
  3106. return 10 <= f ? g + ":" + f: g + ":0" + f
  3107. };
  3108. bs.roundingTime = function(f) {
  3109. var e = Math.floor(f / 86400),
  3110. h = Math.floor(f / 3600),
  3111. g = Math.floor(f / 60);
  3112. return 0 != e ? e + "\u5929": 0 != h ? h + "\u5c0f\u65f6": 0 != g ? g + "\u5206\u949f": f + "\u79d2"
  3113. };
  3114. bs.registerTouchEventOneByOne = function(e, d, f) {
  3115. d = {
  3116. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  3117. swallowTouches: null == d ? !0 : d,
  3118. onTouchBegan: e.onTouchBegan.bind(e)
  3119. };
  3120. e.onTouchMoved && (d.onTouchMoved = e.onTouchMoved.bind(e));
  3121. e.onTouchEnded && (d.onTouchEnded = e.onTouchEnded.bind(e));
  3122. e.onTouchCanceled && (d.onTouchCanceled = e.onTouchCanceled.bind(e));
  3123. d = cc.EventListener.create(d);
  3124. cc.eventManager.addListener(d, f || e);
  3125. return d
  3126. };
  3127. bs.kSocialTypeNone = 0;
  3128. bs.kSocialTypeQQ = 1;
  3129. bs.kSocialTypeWechat = 2;
  3130. bs.kSocialTypeLaiwang = 3;
  3131. bs.kBSSocialTypeWeibo = 4;
  3132. bs.Sound = {
  3133. _isMute: !1,
  3134. _isMusicMute: !1,
  3135. _isEffectMute: !1,
  3136. _musicVolume: 1,
  3137. _effectVolume: 1,
  3138. _stack: [],
  3139. getEffectVolume: function() {
  3140. return this._effectVolume
  3141. },
  3142. setEffectVolume: function(b) {
  3143. this._effectVolume = b;
  3144. cc.audioEngine.setEffectsVolume(b)
  3145. },
  3146. getMusicVolume: function() {
  3147. return this._musicVolume
  3148. },
  3149. setMusicVolume: function(b) {
  3150. this._musicVolume = b;
  3151. cc.audioEngine.setMusicVolume(b)
  3152. },
  3153. getIsMute: function() {
  3154. return this._isMute
  3155. },
  3156. setIsMute: function(b) {
  3157. this._isMute = b;
  3158. this.setIsEffectMute(b);
  3159. this.setIsMusicMute(b)
  3160. },
  3161. getIsMusicMute: function() {
  3162. return this._isMusicMute
  3163. },
  3164. setIsMusicMute: function(b) {
  3165. this._isMusicMute = b;
  3166. cc.audioEngine.setMusicVolume(b ? 0 : this._musicVolume)
  3167. },
  3168. switchMusicMute: function() {
  3169. this.setIsMusicMute(!this.getIsEffectMute())
  3170. },
  3171. getIsEffectMute: function() {
  3172. return this._isEffectMute
  3173. },
  3174. setIsEffectMute: function(b) {
  3175. this._isEffectMute = b;
  3176. cc.audioEngine.setEffectsVolume(b ? 0 : this._effectVolume)
  3177. },
  3178. switchEffectMute: function() {
  3179. this.setIsEffectMute(!this.getIsEffectMute())
  3180. },
  3181. playEffect: function(d, c) {
  3182. return cc.audioEngine.playEffect(d, c)
  3183. },
  3184. stopEffect: function(b) {
  3185. cc.audioEngine.stopEffect(b)
  3186. },
  3187. stopAllEffects: function() {
  3188. cc.audioEngine.stopAllEffects()
  3189. },
  3190. playMusic: function(b) {
  3191. cc.audioEngine.playMusic(b)
  3192. },
  3193. stopMusic: function() {
  3194. cc.audioEngine.stopMusic()
  3195. },
  3196. pushMusic: function(e, d) {
  3197. var f = this._stack;
  3198. return 0 >= f.length || d <= _.last(f).priority ? (f.push({
  3199. file: e,
  3200. priority: d
  3201. }), this._playMusic(e), !0) : !1
  3202. },
  3203. popMusic: function() {
  3204. var b = this._stack;
  3205. 0 >= b.length || (cc.audioEngine.stopMusic(), b.pop(), 0 < b.length && this._playMusic(_.last(b).file))
  3206. },
  3207. dump: function() {
  3208. cc.log("bs.Sound.dump not implemented.")
  3209. },
  3210. destroy: function() {},
  3211. configure: function() {},
  3212. active: function() {},
  3213. init: function() {},
  3214. _playMusic: function(b) {
  3215. cc.audioEngine.stopMusic();
  3216. cc.audioEngine.playMusic(b, !0)
  3217. },
  3218. shared: function() {
  3219. return this
  3220. }
  3221. };
  3222. bs.kResourceStatusServerError = -3;
  3223. bs.kResourceStatusCacheDirError = -2;
  3224. bs.kResourceStatusUnknown = -1;
  3225. bs.kResourceStatusUpToDate = 0;
  3226. bs.kResourceStatusChecking = 1;
  3227. bs.kResourceStatusNeedUpdate = 2;
  3228. bs.kResourceStatusUpdating = 3;
  3229. bs.kResourceStatusFinish = 4;
  3230. bs.kMessageResourceStatusChanged = "message-resource-status-changed";
  3231. bs.kMessageResourceUpdateProgressChanged = "message-resource-update-progress-changed";
  3232. bs.onResourceCheckStatusChanged = function(d, c) {
  3233. bs.postMessage(bs.kMessageResourceStatusChanged, {
  3234. module: d,
  3235. status: c
  3236. });
  3237. bs.logf("[BSResource] onResourceCheckStatusChanged: %s, %d", d, c)
  3238. };
  3239. bs.onResourceUpdateStatusChanged = function(d, c) {
  3240. bs.postMessage(bs.kMessageResourceStatusChanged, {
  3241. module: d,
  3242. status: c
  3243. });
  3244. bs.logf("[BSResource] onResourceUpdateStatusChanged: %s, %d", d, c)
  3245. };
  3246. bs.onResourceUpdateProgressChanged = function(e, d, f) {
  3247. bs.postMessage(bs.kMessageResourceUpdateProgressChanged, {
  3248. module: e,
  3249. finished: d,
  3250. total: f
  3251. });
  3252. bs.logf("[BSResource] onResourceUpdateProgressChanged: %s, %d, %d", e, d, f)
  3253. };
  3254. bs.Http = bs.Http || {};
  3255. bs.Http.TIME_OUT = 10000;
  3256. bs.Http.proxy = function(d, c) {
  3257. bs.Http.get("/proxy?url\x3d" + encodeURIComponent(d), c)
  3258. };
  3259. bs.Http.get = function(e, d) {
  3260. var f = new XMLHttpRequest;
  3261. f.open("GET", e, !0);
  3262. f.onreadystatechange = function() {
  3263. 4 == f.readyState && _.isFunction(d) && (200 == f.status ? d(null, f.responseText) : (cc.log("[BSHttp] response status error :" + f.status), 0 >= f.status ? d(f.status, null) : d(f.status, f.responseText)))
  3264. };
  3265. f.timeout = bs.Http.TIME_OUT;
  3266. f.ontimeout = d;
  3267. f.send()
  3268. };
  3269. bs.Http.post = function(g, e, j, i) {
  3270. var h = new XMLHttpRequest;
  3271. h.open("POST", g, !0);
  3272. i && h.setRequestHeader("Content-Type", i);
  3273. h.onreadystatechange = function() {
  3274. 4 == h.readyState && _.isFunction(j) && (200 == h.status ? j(null, h.responseText) : (cc.log("[BSHttp] response status error :" + h.status), 0 >= h.status ? j(h.status, null) : j(h.status, h.responseText)))
  3275. };
  3276. h.timeout = bs.Http.TIME_OUT;
  3277. h.send(e)
  3278. };
  3279. bs.Http._signingFunc = null;
  3280. bs.Http.setSigningFunction = function(b) {
  3281. bs.Http._signingFunc = b
  3282. };
  3283. bs.Http.addSignature = function(e, d) {
  3284. if (_.isFunction(bs.Http._signingFunc)) {
  3285. var f = bs.Http._signingFunc(e, d);
  3286. _.isArray(d) ? d.push(f) : d._sig = f
  3287. }
  3288. };
  3289. bs.Http.jsonrpc = function(f, e, h, g) {
  3290. bs.Http.addSignature(e, h);
  3291. bs.Http.post(f, JSON.stringify({
  3292. jsonrpc: "2.0",
  3293. method: e,
  3294. params: h,
  3295. id: 0
  3296. }),
  3297. function(b, i) {
  3298. if (b) {
  3299. g(b, null)
  3300. } else {
  3301. var d = bs.parseJSON(i); ! d || d.error ? (cc.log("[BSHTTP] rpc:" + e + ", return error:" + JSON.stringify(d)), g(d, null)) : g(null, bs.parseJSON(i).result)
  3302. }
  3303. },
  3304. "application/json")
  3305. };
  3306. bs.TouchPriorityManager = cc.Class.extend({
  3307. _currentPriority: 1000000,
  3308. allocatePriority: function() {
  3309. this._currentPriority--;
  3310. this._currentPriority == this.kHighestPriority && (cc.log("[TouchPriorityManager] touch priority overflow"), this._currentPriority = this.kLowestPriority);
  3311. return this._currentPriority
  3312. }
  3313. });
  3314. bs.gTouchPriorityManagerInstance = null;
  3315. bs.TouchPriorityManager.getInstance = function() {
  3316. null == bs.gTouchPriorityManagerInstance && (bs.gTouchPriorityManagerInstance = new bs.TouchPriorityManager);
  3317. return bs.gTouchPriorityManagerInstance
  3318. };
  3319. bs.TouchPriorityManager.kLowestPriority = 1000000;
  3320. bs.TouchPriorityManager.kHighestPriority = 1024;
  3321. bs.TouchableSprite = cc.Layer.extend({
  3322. RGBAProtocol: !0,
  3323. _target: null,
  3324. _callback: null,
  3325. _isSwallowTouch: !1,
  3326. _isTouchMoved: !1,
  3327. _conditionalRect: null,
  3328. _internalImg: null,
  3329. _cancelTouchOnMove: !1,
  3330. _cancelTouchOnMoveOut: !0,
  3331. _enable: !0,
  3332. _originTouchPoint: null,
  3333. _foregroundImg: null,
  3334. _normalSpriteFrameName: null,
  3335. _selectedSpriteFrameName: null,
  3336. _disabledSpriteFrameName: null,
  3337. _fadeOutCallback: null,
  3338. ctor: function() {
  3339. this._super()
  3340. },
  3341. _isTouchInside: function(d) {
  3342. d = this.convertToNodeSpace(d.getLocation());
  3343. var c = this.rect();
  3344. c.x = 0;
  3345. c.y = 0;
  3346. return cc.rectEqualToRect(this._conditionalRect, cc.rect(0, 0, 0, 0)) ? cc.rectContainsPoint(c, d) : cc.rectContainsPoint(this._conditionalRect, d)
  3347. },
  3348. init: function(d, c) {
  3349. this._super();
  3350. this._target = c;
  3351. this._callback = d;
  3352. this._conditionalRect = cc.rect(0, 0, 0, 0);
  3353. this._eventListener = bs.registerTouchEventOneByOne(this);
  3354. this.ignoreAnchorPointForPosition(!1)
  3355. },
  3356. initWithSize: function(e, d, f) {
  3357. this.init(d, f);
  3358. this.setContentSize(e)
  3359. },
  3360. initWithSpriteName: function(e, d, f) {
  3361. this.init(d, f);
  3362. e = this._internalImg = new cc.Sprite(e);
  3363. e.setAnchorPoint(0, 0);
  3364. this.addChild(e);
  3365. this.setContentSize(e.getContentSize())
  3366. },
  3367. initWithSpriteFrameName: function(e, d, f) {
  3368. this.init(d, f);
  3369. e = this._internalImg = new cc.Sprite("#" + e);
  3370. e.setAnchorPoint(0, 0);
  3371. this.addChild(e);
  3372. this.setContentSize(e.getContentSize())
  3373. },
  3374. initWithTwoStateSpriteFrameName: function(f, e, h, g) {
  3375. this.init(h, g);
  3376. h = this._internalImg = new cc.Sprite("#" + f);
  3377. this.setNormalSpriteFrameName(f);
  3378. this.setSelectedSpriteFrameName(e);
  3379. h.setAnchorPoint(0, 0);
  3380. this.addChild(h);
  3381. this.setContentSize(h.getContentSize())
  3382. },
  3383. initWithThreeStateSpriteFrameName: function(g, e, j, i, h) {
  3384. this.init(i, h);
  3385. i = this._internalImg = new cc.Sprite("#" + g);
  3386. this.setNormalSpriteFrameName(g);
  3387. this.setSelectedSpriteFrameName(e);
  3388. this.setDisabledSpriteFrameName(j);
  3389. i.setAnchorPoint(0, 0);
  3390. this.addChild(i);
  3391. this.setContentSize(i.getContentSize())
  3392. },
  3393. initWithScale9SpriteFrameName: function(g, e, j, i, h) {
  3394. this.init(i, h);
  3395. g = this._internalImg = cc.Scale9Sprite.createWithSpriteFrameName(g, e);
  3396. g.setAnchorPoint(0, 0);
  3397. this.addChild(g);
  3398. this.setContentSize(j)
  3399. },
  3400. initWithSprite: function(e, d, f) {
  3401. this.init(d, f);
  3402. this._internalImg = e;
  3403. e.setAnchorPoint(0, 0);
  3404. this.addChild(e);
  3405. this.setContentSize(e.getContentSize())
  3406. },
  3407. setIsSwallowTouch: function(b) {
  3408. this._eventListener.setSwallowTouches(b)
  3409. },
  3410. rect: function() {
  3411. var e = this.getPosition(),
  3412. d = this.getContentSize(),
  3413. f = this.getAnchorPoint();
  3414. return cc.rect(e.x - d.width * f.x, e.y - d.height * f.y, d.width, d.height)
  3415. },
  3416. setForegroundImg: function(f, e, h) {
  3417. this._foregroundImg = {
  3418. node: f,
  3419. anchor: _.clone(e),
  3420. pos: _.clone(h)
  3421. };
  3422. var g = this.getContentSize();
  3423. e && (f.setAnchorPoint(e), f.setPosition(h.x + g.width * e.x, h.y + g.height * e.y));
  3424. this.addChild(f, 1)
  3425. },
  3426. setContentSize: function(b) {
  3427. cc.sizeEqualToSize(b, this.getContentSize()) || (this._super(b), this._internalImg && this._internalImg.setContentSize(b))
  3428. },
  3429. setFlipX: function(b) {
  3430. bs.setFlipX(this._internalImg, b)
  3431. },
  3432. setFlipY: function(b) {
  3433. bs.setFlipY(this._internalImg, b)
  3434. },
  3435. setSpriteFrame: function(f) {
  3436. if (this._internalImg instanceof cc.Scale9Sprite) {
  3437. var e = this._internalImg.getCapInsets(),
  3438. h = _.clone(this._internalImg.getContentSize()),
  3439. g = _.clone(this._internalImg.getAnchorPoint());
  3440. this._internalImg.initWithSpriteFrame(f, e);
  3441. this._internalImg.setAnchorPoint(g);
  3442. this._internalImg.setContentSize(h)
  3443. } else {
  3444. this._updateDisplayFrame(f)
  3445. }
  3446. },
  3447. setNormalSpriteFrameName: function(d) {
  3448. var c = !!this._normalSpriteFrameName;
  3449. this._normalSpriteFrameName = d;
  3450. c && (d = cc.spriteFrameCache.getSpriteFrame(d), this._updateDisplayFrame(d))
  3451. },
  3452. setSelectedSpriteFrameName: function(b) {
  3453. this._selectedSpriteFrameName = b
  3454. },
  3455. setDisabledSpriteFrameName: function(b) {
  3456. this._disabledSpriteFrameName = b
  3457. },
  3458. setCancelTouchOnMove: function(b) {
  3459. this._cancelTouchOnMove = b
  3460. },
  3461. setCancelTouchOnMoveOut: function(b) {
  3462. this._cancelTouchOnMoveOut = b
  3463. },
  3464. onTouchBegan: function(e, d) {
  3465. if (!bs.isNodeVisible(this)) {
  3466. return ! 1
  3467. }
  3468. this._originTouchPoint = _.clone(e.getLocation());
  3469. if (this._isTouchInside(e) && this._enable) {
  3470. if (this._selectedSpriteFrameName) {
  3471. var f = cc.spriteFrameCache.getSpriteFrame(this._selectedSpriteFrameName);
  3472. this._updateDisplayFrame(f)
  3473. }
  3474. return ! 0
  3475. }
  3476. return ! 1
  3477. },
  3478. onTouchMoved: function(d, c) {
  3479. 15 < cc.pDistance(d.getLocation(), this._originTouchPoint) && (this._isTouchMoved = !0)
  3480. },
  3481. onTouchEnded: function(f, e) {
  3482. if (this._normalSpriteFrameName && this._enable) {
  3483. var h = cc.spriteFrameCache.getSpriteFrame(this._normalSpriteFrameName);
  3484. this._updateDisplayFrame(h)
  3485. }
  3486. if (this._enable && (!this._cancelTouchOnMoveOut || this._isTouchInside(f))) {
  3487. if (h = this._isTouchMoved, this._isTouchMoved = !1, !h || !this._cancelTouchOnMove) {
  3488. var h = this._target,
  3489. g = this._callback;
  3490. if (g) {
  3491. if (h && "string" == typeof g) {
  3492. h[g](this)
  3493. } else {
  3494. h && "function" == typeof g ? g.call(h, this, f) : g(this)
  3495. }
  3496. }
  3497. }
  3498. }
  3499. },
  3500. isCascadeColorEnabled: function() {
  3501. return ! 1
  3502. },
  3503. isCascadeOpacityEnabled: function() {
  3504. return ! 1
  3505. },
  3506. getColor: function() {
  3507. return this._internalImg.getColor()
  3508. },
  3509. setColor: function(f) {
  3510. for (var e = this.getChildren(), h = 0; h < e.length; h++) {
  3511. var g = e[h];
  3512. g && g.setColor && g.setColor(f)
  3513. }
  3514. },
  3515. getOpacity: function() {
  3516. return this._internalImg.getOpacity()
  3517. },
  3518. setOpacity: function(f) {
  3519. for (var e = this.getChildren(), h = 0; h < e.length; h++) {
  3520. var g = e[h];
  3521. g && g.setOpacity && g.setOpacity(f)
  3522. }
  3523. },
  3524. setEnabled: function(b) {
  3525. b != this._enable && (this._enable = b, this._disabledSpriteFrameName && (b = cc.spriteFrameCache.getSpriteFrame(b ? this._normalSpriteFrameName: this._disabledSpriteFrameName), this._updateDisplayFrame(b)))
  3526. },
  3527. setTouchEnabled: function() {
  3528. cc.log("do not use bs.TouchableSprite.setTouchEnabled, use setEnabled instead")
  3529. },
  3530. _updateDisplayFrame: function(f) {
  3531. if (this._foregroundImg) {
  3532. var e = this._internalImg.displayFrame().getOriginalSize(),
  3533. h = f.getOriginalSize();
  3534. this._internalImg.setSpriteFrame(f);
  3535. if (!cc.sizeEqualToSize(e, h)) {
  3536. f = this._foregroundImg;
  3537. var e = f.pos,
  3538. g = f.anchor;
  3539. f.node.setPosition(e.x + h.width * g.x, e.y + h.height * g.y)
  3540. }
  3541. } else {
  3542. this._internalImg.setSpriteFrame(f)
  3543. }
  3544. },
  3545. fadeOut: function(d, c) {
  3546. this._fadeOutStep = 255 / d;
  3547. this._fadeOutCallback = c;
  3548. this.scheduleUpdate()
  3549. },
  3550. update: function(b) {
  3551. b = this.getOpacity() - this._fadeOutStep * b;
  3552. 0 >= b && (b = 0, this.unscheduleUpdate(), this._fadeOutCallback && (this._fadeOutCallback(), this._fadeOutCallback = null));
  3553. this.setOpacity(b)
  3554. }
  3555. });
  3556. bs.TouchableSprite.createWithSize = function(f, e, h) {
  3557. var g = new this;
  3558. g.initWithSize(f, e, h);
  3559. return g
  3560. };
  3561. bs.TouchableSprite.createWithSprite = function(e, d, f) {
  3562. e = new this;
  3563. e.initWithSprite(e, d, f);
  3564. return e
  3565. };
  3566. bs.TouchableSprite.createWithSpriteName = function(f, e, h) {
  3567. var g = new this;
  3568. g.initWithSpriteName(f, e, h);
  3569. return g
  3570. };
  3571. bs.TouchableSprite.createWithSpriteFrameName = function(f, e, h) {
  3572. var g = new this;
  3573. g.initWithSpriteFrameName(f, e, h);
  3574. return g
  3575. };
  3576. bs.TouchableSprite.createWithTwoStateSpriteFrameName = function(g, e, j, i) {
  3577. var h = new this;
  3578. h.initWithTwoStateSpriteFrameName(g, e, j, i);
  3579. return h
  3580. };
  3581. bs.TouchableSprite.createWithThreeStateSpriteFrameName = function(g, e, l, j, i) {
  3582. var h = new this;
  3583. h.initWithThreeStateSpriteFrameName(g, e, l, j, i);
  3584. return h
  3585. };
  3586. bs.TouchableSprite.createWithScale9SpriteFrameName = function(g, e, l, j, i) {
  3587. var h = new this;
  3588. h.initWithScale9SpriteFrameName(g, e, l, j, i);
  3589. return h
  3590. };
  3591. bs.TouchableSpriteWithSwitch = bs.TouchableSprite.extend({
  3592. _frameOn: null,
  3593. _frameOff: null,
  3594. _sp_on: null,
  3595. _sp_off: null,
  3596. _on: null,
  3597. _delta: null,
  3598. initWithFrameName: function(g, e, l, j, i, h) {
  3599. bs.TouchableSprite.prototype.initWithSize.call(this, g, h, i, e);
  3600. this._frameOn = cc.spriteFrameCache.getSpriteFrame(l);
  3601. this._frameOff = cc.spriteFrameCache.getSpriteFrame(j);
  3602. this._sp_on = cc.Sprite.createWithSpriteFrame(this._frameOn);
  3603. this._sp_on.setAnchorPoint(cc.p(0, 0));
  3604. this._sp_off = cc.Sprite.createWithSpriteFrame(this._frameOff);
  3605. this._sp_off.setAnchorPoint(cc.p(0, 0));
  3606. this._on = !1;
  3607. this.addChild(this._sp_on);
  3608. this.addChild(this._sp_off);
  3609. this._sp_off.setVisible(!0);
  3610. this._sp_on.setVisible(!1);
  3611. return ! 0
  3612. },
  3613. toggle: function() {
  3614. this.switchTo(!this._on)
  3615. },
  3616. switchOn: function() {
  3617. this.switchTo(!0)
  3618. },
  3619. switchOff: function() {
  3620. this.switchTo(!1)
  3621. },
  3622. switchTo: function(b) {
  3623. this._on = b;
  3624. this._sp_off.setVisible(!1);
  3625. this._sp_on.setVisible(!1);
  3626. b ? this._sp_on.setVisible(!0) : this._sp_off.setVisible(!0)
  3627. },
  3628. isOn: function() {
  3629. return this._on
  3630. },
  3631. setDeltaForStateChanging: function(b) {
  3632. this._delta = b
  3633. }
  3634. });
  3635. bs.TouchableSpriteWithSwitch.switchSpriteWithFrameName = function(h, e, n, m, l, i) {
  3636. var j = new bs.TouchableSpriteWithSwitch;
  3637. j.initWithFrameName(h, e, n, m, l, i);
  3638. return j
  3639. };
  3640. bs.kMessageAppEnterForeground = "bs-message-app-enter-foreground";
  3641. bs.kMessageAppEnterBackground = "bs-message-app-enter-background";
  3642. bs.kMessageSocialUserInfoUpdated = "bs-message-social-user-info-updated";
  3643. bs.kMessageRegisterRemoteNotification = "bs-message-register-remote-notification";
  3644. bs.kMessageSocialWechatCode = "bs-message-social-wechat-code";
  3645. bs.kMessagePayRestoreFinished = "bs-message-pay-restore-finish";
  3646. bs.kMessagePaySuccess = "bs-message-pay-success";
  3647. bs.kMessagePayFail = "bs-message-pay-fail";
  3648. bs.MessageManager = cc.Class.extend({
  3649. _handlers: {},
  3650. _delayedMessages: [],
  3651. registerHandler: function(e, d, f) {
  3652. null == this._handlers[e] && (this._handlers[e] = []);
  3653. this._handlers[e].push({
  3654. target: d,
  3655. callback: f
  3656. })
  3657. },
  3658. unregisterHandler: function(f, e, h) {
  3659. var g = this._handlers[f];
  3660. null != g && (this._handlers[f] = _.filter(g,
  3661. function(b) {
  3662. return b.target != e || b.callback != h
  3663. }))
  3664. },
  3665. unregisterAllHandlerForTarget: function(d) {
  3666. var c = this._handlers;
  3667. _.each(c,
  3668. function(b, a) {
  3669. _.isEmpty(b) || (c[a] = _.filter(b,
  3670. function(e) {
  3671. return e.target != d
  3672. }))
  3673. })
  3674. },
  3675. postDelayedMessage: function(d, c) {
  3676. this._delayedMessages.push([d, c])
  3677. },
  3678. flushMessage: function() {
  3679. _.each(this._delayedMessages,
  3680. function(b) {
  3681. this.postMessage(b[0], b[1])
  3682. }.bind(this))
  3683. },
  3684. postMessage: function(g, e) {
  3685. var j = this._handlers[g];
  3686. if (null != j) {
  3687. for (var i = 0; i < _.size(j); i++) {
  3688. var h = j[i];
  3689. h.callback.call(h.target, e, g)
  3690. }
  3691. }
  3692. }
  3693. });
  3694. bs.g_messageManager = null;
  3695. bs.MessageManager.getInstance = function() {
  3696. null == bs.g_messageManager && (bs.g_messageManager = new bs.MessageManager);
  3697. return bs.g_messageManager
  3698. };
  3699. bs.registerMessageHandler = function(e, d, f) {
  3700. bs.MessageManager.getInstance().registerHandler(e, d, f)
  3701. };
  3702. bs.unregisterMessageHandler = function(e, d, f) {
  3703. bs.MessageManager.getInstance().unregisterHandler(e, d, f)
  3704. };
  3705. bs.unregisterAllMessageHandlerForTarget = function(b) {
  3706. bs.MessageManager.getInstance().unregisterAllHandlerForTarget(b)
  3707. };
  3708. bs.postMessage = function(d, c) {
  3709. bs.MessageManager.getInstance().postMessage(d, c)
  3710. };
  3711. bs.postDelayedMessage = function(d, c) {
  3712. bs.MessageManager.getInstance().postDelayedMessage(d, c)
  3713. };
  3714. bs.BIND_MESSAGE = bs.registerMessageHandler;
  3715. bs.UNBIND_MESSAGE = bs.unregisterMessageHandler;
  3716. bs.POST_MESSAGE = bs.postMessage;
  3717. bs.POST_DELAYED_MESSAGE = bs.postDelayedMessage;
  3718. bs.Share = bs.Share || {};
  3719. bs.Share.kShareTargetWeixinSession = 0;
  3720. bs.Share.kShareTargetWeixinTimeline = 1;
  3721. bs.Share.kShareTargetQQ = 2;
  3722. bs.Share.kShareTargetQZone = 3;
  3723. bs.Share.kTargetWeixinSession = 0;
  3724. bs.Share.kTargetWeixinTimeline = 1;
  3725. bs.Share.kTargetQQ = 2;
  3726. bs.Share.kTargetQZone = 3;
  3727. bs.Layer = cc.Layer.extend({
  3728. _plistUsed: null,
  3729. init: function() {
  3730. this._super();
  3731. this._plistUsed = []
  3732. },
  3733. use: function(b) {
  3734. this._plistUsed.push(b);
  3735. bs.Resource.shared().useResource(b)
  3736. },
  3737. onExit: function() {
  3738. this._super();
  3739. bs.unregisterAllMessageHandlerForTarget(this);
  3740. _.each(this._plistUsed,
  3741. function(b) {
  3742. bs.Resource.shared().unuseResource(b)
  3743. })
  3744. },
  3745. setDebugDraw: function() {
  3746. var d = this.getContentSize(),
  3747. d = [cc.p(0, 0), cc.p(d.width, 0), cc.p(d.width, d.height), cc.p(0, d.height)],
  3748. c = cc.DrawNode.create();
  3749. this.addChild(c, -1);
  3750. c.drawPoly(d, new cc.Color4F(0, 0, 1, 0.5), 1, new cc.Color4F(1, 0, 1, 1))
  3751. }
  3752. });
  3753. bs.ToggleButton = bs.TouchableSprite.extend({
  3754. _img1: null,
  3755. _img2: null,
  3756. _status: 0,
  3757. initWithSprite: function(g, e, j, i, h) {
  3758. this._img1 = bs.autoSprite(g);
  3759. this._img2 = bs.autoSprite(e);
  3760. bs.TouchableSprite.prototype.initWithSize.call(this, this._img1.getContentSize(), j, i, h);
  3761. this._img1.setAnchorPoint(cc.p(0, 0));
  3762. this._img2.setAnchorPoint(cc.p(0, 0));
  3763. this.addChild(this._img1);
  3764. this.addChild(this._img2);
  3765. this._img1.setVisible(0 === this._status);
  3766. this._img2.setVisible(1 === this._status)
  3767. },
  3768. onTouchBegan: function(d, c) {
  3769. return this._super(d, c)
  3770. },
  3771. onTouchEnded: function(d, c) {
  3772. this._isTouchInside(d) && (this._status = (this._status + 1) % 2, this._img1.setVisible(0 === this._status), this._img2.setVisible(1 === this._status));
  3773. this._super(d, c)
  3774. }
  3775. });
  3776. bs.ToggleButton.create = function(g, e, l, j, i) {
  3777. var h = new bs.ToggleButton;
  3778. h.initWithSprite(g, e, l, j, i);
  3779. return h
  3780. };
  3781. var Util = {
  3782. scene: function(d) {
  3783. var c = cc.Scene.create();
  3784. d = d instanceof cc.Layer ? d: new d;
  3785. c.addChild(d);
  3786. return c
  3787. },
  3788. fullscreenNode: function(e, d) {
  3789. d && e.setContentSize(d);
  3790. var f = cc.winSize;
  3791. e.width / e.height > f.width / f.height ? (bs.scaleToHeight(e, f.height), e.x = (f.width - e.width * e.scale) / 2) : (bs.scaleToWidth(e, f.width), e.y = (f.height - e.height * e.scale) / 2)
  3792. },
  3793. randomReal: function(d, c) {
  3794. _.isArray(d) && (c = d[1], d = d[0]);
  3795. return Math.random() * (c - d) + d
  3796. },
  3797. randomInt: function(d, c) {
  3798. return Math.floor(Math.random() * (c - d + 1)) + d
  3799. },
  3800. randomRate: function(b) {
  3801. return Math.random() < b
  3802. },
  3803. randomItemByRate: function(q, o, n) {
  3804. var m = 0,
  3805. l = 0;
  3806. _.each(q,
  3807. function(b) {
  3808. if (void 0 != b[o] && (!_.isFunction(n) || n(b))) {
  3809. m += b[o]
  3810. }
  3811. });
  3812. var m = 10000 * m,
  3813. i = this.randomReal(0, m),
  3814. j;
  3815. for (j in q) {
  3816. var h = q[j];
  3817. if (!_.isFunction(n) || n(h)) {
  3818. var e = l + 10000 * h[o];
  3819. if (i > l && i <= e) {
  3820. return h
  3821. }
  3822. l = e
  3823. }
  3824. }
  3825. return null
  3826. },
  3827. trackEvent: function(f, e, h) {
  3828. if (window._hmt) {
  3829. var g = ["_trackEvent", wx.game, f];
  3830. e || (e = wx.game + "-" + f);
  3831. e && g.push(e);
  3832. h && g.push(h);
  3833. _hmt.push(g)
  3834. }
  3835. }
  3836. };
  3837. var wx = wx || {};
  3838. wx.game = "chess";
  3839. wx.chess = {
  3840. designHeight: 533,
  3841. font: "\u9ed1\u4f53",
  3842. moreGamesUrl: "http://game.ikongzhong.cn/",
  3843. resources: ["texture.png", "texture.plist", "step.mp3"],
  3844. gridSize: {
  3845. width: 64,
  3846. height: 64
  3847. },
  3848. touchRadius: 20,
  3849. row: 4,
  3850. col: 4,
  3851. shareType: "normal",
  3852. getTitle: function(b) {
  3853. b = b || wx.chess.lastScore || 0;
  3854. return 11 == b ? "BUG": 41 <= b ? "\u53bf\u5b98": 36 <= b && 41 > b ? "\u540f\u90e8\u4f8d\u90ce": 31 <= b && 35 > b ? "\u5927\u7406\u5bfa\u537f": 25 <= b && 31 > b ? "\u4e24\u5e7f\u603b\u7763": 21 <= b && 25 > b ? "\u90e1\u738b": "\u5927\u5b66\u58eb"
  3855. },
  3856. lastScore: 0
  3857. };
  3858. cc.game.onStart = function() {
  3859. cc.view.adjustViewPort(!0);
  3860. var d = cc.winSize,
  3861. c = d.width,
  3862. d = d.height;
  3863. cc.view.enableAutoFullScreen(!1);
  3864. cc.view.setDesignResolutionSize(320, 320 * (d / c), cc.ResolutionPolicy.FIXED_WIDTH);
  3865. cc.view.resizeWithBrowserSize(!0);
  3866. cc.LoaderScene.preload(wx.chess.resources,
  3867. function() {
  3868. wx.init();
  3869. cc.director.runScene(Util.scene(wx.chess.UILayer))
  3870. },
  3871. this)
  3872. };
  3873. cc.game.run();
  3874. wx.chess.Board = cc.Node.extend({
  3875. col: 0,
  3876. row: 0,
  3877. horse: null,
  3878. holes: {},
  3879. moving: !1,
  3880. passed: !1,
  3881. gameLayer: null,
  3882. ctor: function(f) {
  3883. this._super();
  3884. this.init();
  3885. bs.registerTouchEventOneByOne(this, !0);
  3886. this.gameLayer = f;
  3887. f = wx.chess.gridSize;
  3888. this.attr({
  3889. width: (wx.chess.col - 1) * f.width,
  3890. height: (wx.chess.row - 1) * f.height
  3891. });
  3892. var e = new cc.Sprite("#ma_board.png");
  3893. e.attr({
  3894. anchorX: 135 / e.width,
  3895. anchorY: 213 / e.height,
  3896. x: this.width / 2,
  3897. y: this.height / 2
  3898. });
  3899. this.addChild(e);
  3900. for (e = 0; e < wx.chess.col; ++e) {
  3901. this.addLine(this.height, {
  3902. x: e * f.width
  3903. })
  3904. }
  3905. for (var h = 0; h < wx.chess.row; ++h) {
  3906. this.addLine(this.width, {
  3907. rotation: 90,
  3908. y: h * f.height
  3909. })
  3910. }
  3911. for (e = 0; e < wx.chess.col; ++e) {
  3912. this.holes[e] = {};
  3913. for (h = 0; h < wx.chess.row; ++h) {
  3914. var g = new cc.Sprite("#ma_hole.png");
  3915. g.x = e * f.width;
  3916. g.y = h * f.height;
  3917. this.holes[e][h] = g;
  3918. this.addChild(g)
  3919. }
  3920. }
  3921. f = this.horse = new cc.Sprite("#ma_horse.png");
  3922. this.addChild(f);
  3923. this.reset()
  3924. },
  3925. addLine: function(e, d) {
  3926. var f = new cc.Sprite("#ma_line.png");
  3927. f.anchorY = 0;
  3928. bs.scaleYToHeight(f, e);
  3929. f.attr(d);
  3930. this.addChild(f)
  3931. },
  3932. onTouchBegan: function(h) {
  3933. if (!this.moving) {
  3934. var e = wx.chess,
  3935. o = e.gridSize.width,
  3936. n = e.gridSize.height,
  3937. l = e.touchRadius,
  3938. i = this.convertTouchToNodeSpace(h);
  3939. h = Math.abs(i.x) % o;
  3940. var j = Math.abs(i.y) % n,
  3941. m = Math.round(Math.abs(i.x) / o),
  3942. i = Math.round(Math.abs(i.y) / n),
  3943. n = 0 <= i && i < e.row && (j <= l || n - j <= l);
  3944. return 0 <= m && (m < e.col && (h <= l || o - h <= l)) && n ? (this.moveTo(m, i), !0) : !1
  3945. }
  3946. },
  3947. reset: function() {
  3948. var d = _.sample(_.range(0, wx.chess.col * wx.chess.row), Util.randomInt(2, 5)),
  3949. c = 0;
  3950. _.each(this.holes,
  3951. function(a) {
  3952. _.each(a,
  3953. function(b) {
  3954. b.isOn = -1 !== d.indexOf(c);
  3955. b.setSpriteFrame(bs.spriteFrameFromName(b.isOn ? "ma_hole1.png": "ma_hole.png"));
  3956. c++
  3957. })
  3958. });
  3959. this.col = Util.randomInt(0, wx.chess.col - 1);
  3960. this.row = Util.randomInt(0, wx.chess.row - 1);
  3961. this.horse.x = wx.chess.gridSize.width * this.col;
  3962. this.horse.y = wx.chess.gridSize.height * this.row;
  3963. this.passed = !1
  3964. },
  3965. moveTo: function(f, e) {
  3966. var h = Math.abs(this.col - f),
  3967. g = Math.abs(this.row - e);
  3968. if (1 == h && 2 == g || 2 == h && 1 == g) {
  3969. h = wx.chess.gridSize,
  3970. this.col = f,
  3971. this.row = e,
  3972. this.moving = !0,
  3973. this.gameLayer.incrScore(),
  3974. this.horse.runAction(cc.sequence(cc.jumpTo(0.3, cc.p(h.width * f, h.height * e), 50, 1), cc.callFunc(this.onMoveEnd.bind(this)))),
  3975. h = this.holes[f][e],
  3976. h.isOn = !h.isOn,
  3977. h.setSpriteFrame(bs.spriteFrameFromName(h.isOn ? "ma_hole1.png": "ma_hole.png"))
  3978. }
  3979. },
  3980. onMoveEnd: function() {
  3981. this.moving = !1;
  3982. cc.audioEngine.playEffect("step.mp3");
  3983. _.find(this.holes,
  3984. function(b) {
  3985. return _.find(b,
  3986. function(c) {
  3987. return ! c.isOn
  3988. })
  3989. }) || (this.passed = !0, bs.postMessage("game-over", this.gameLayer.score))
  3990. }
  3991. });
  3992. wx.chess.GameLayer = bs.Layer.extend({
  3993. score: 0,
  3994. board: null,
  3995. ctor: function() {
  3996. this._super();
  3997. this.init();
  3998. var d = this.board = new wx.chess.Board(this);
  3999. this.addChild(d);
  4000. bs.centerNodeToParent(d);
  4001. var c = this.scoreLbl = cc.LabelTTF.create("\u5df2\u8d70\u6b65\u6570 0", wx.chess.font, 22);
  4002. c.y = bs.getTop(d) + 32;
  4003. c.x = cc.winSize.width / 2;
  4004. this.addChild(c);
  4005. this.height = bs.getTop(c)
  4006. },
  4007. onEnter: function() {
  4008. this._super()
  4009. },
  4010. incrScore: function() {
  4011. this.score++;
  4012. this.scoreLbl.setString("\u5df2\u8d70\u6b65\u6570 " + this.score)
  4013. },
  4014. restart: function() {
  4015. this.board.reset();
  4016. this.score = 0;
  4017. this.scoreLbl.setString("\u5df2\u8d70\u6b65\u6570 0")
  4018. }
  4019. });
  4020. wx.init = function() {
  4021. bs.init();
  4022. cc.spriteFrameCache.addSpriteFrames("texture.plist")
  4023. };
  4024. wx.chess.Button = bs.TouchableSprite.extend({
  4025. ctor: function(f, e, h, g) {
  4026. this._super();
  4027. this.initWithSpriteFrameName(e + ".png", h, g);
  4028. this.setIsSwallowTouch(!0);
  4029. f && (f = cc.LabelTTF.create(f, "\u9ed1\u4f53", 22), this.addChild(f), bs.centerNodeToParent(f))
  4030. }
  4031. });
  4032. wx.chess.ShareTip = cc.LayerColor.extend({
  4033. tip: null,
  4034. ctor: function() {
  4035. this._super();
  4036. this.init(cc.color(0, 0, 0, 200));
  4037. this.setContentSize(cc.winSize);
  4038. bs.registerTouchEventOneByOne(this, !0);
  4039. var b = this.tip = new cc.Sprite("#ma_sharetip.png");
  4040. b.setAnchorPoint(1, 1);
  4041. b.setPosition(cc.winSize.width, cc.winSize.height);
  4042. this.addChild(b)
  4043. },
  4044. onTouchBegan: function() {
  4045. this.scheduleOnce(this.removeFromParent.bind(this), 0);
  4046. return ! 0
  4047. }
  4048. });
  4049. wx.chess.GameTip = wx.chess.ShareTip.extend({
  4050. ctor: function() {
  4051. this._super();
  4052. var e = cc.winSize,
  4053. d = cc.LabelTTF.create("\u8c61\u68cb\u89c4\u5219\uff1a\u201c\u99ac\u201d\u8d70\u201c\u65e5\u201d", "Arial-Bold", 20);
  4054. d.setHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER);
  4055. d.setDimensions(cc.size(0.8 * e.width, 0));
  4056. d.x = this.width / 2;
  4057. d.y = bs.getBottom(this.tip) - 40;
  4058. this.addChild(d);
  4059. e = new cc.Sprite("#ma_tip.png");
  4060. e.anchorY = 1;
  4061. e.x = d.x;
  4062. e.y = bs.getBottom(d) - 10;
  4063. this.addChild(e);
  4064. var f = cc.LabelTTF.create("\u5b9e\u5728\u662f\u597d\u96be\u554a~\u4f46\u662f\u4e0d\u80fd\u5f97\u7f6a\u7687\u4e0a\u5440~~\u5feb\u5feb\u53eb\u5c0f\u4f19\u4f34\u6765\u5e2e\u4f60\u89e3\u56f4\u5427\uff01", "Arial-Bold", 20);
  4065. f.setHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER);
  4066. f.setDimensions(d.getDimensions());
  4067. f.x = d.x;
  4068. f.y = bs.getBottom(e) - 50;
  4069. this.addChild(f)
  4070. },
  4071. onEnter: function() {
  4072. this._super();
  4073. wx.chess.shareType = "help"
  4074. },
  4075. onExit: function() {
  4076. this._super();
  4077. wx.chess.shareType = "normal"
  4078. }
  4079. });
  4080. wx.chess.UILayer = cc.LayerGradient.extend({
  4081. mainMenu: null,
  4082. gameLayer: null,
  4083. shareTip: null,
  4084. first: !0,
  4085. introLayer: null,
  4086. ctor: function() {
  4087. this._super();
  4088. var f = cc.winSize,
  4089. e = f.height / wx.chess.designHeight;
  4090. this.init(cc.color(149, 196, 60), cc.color(111, 151, 47), cc.p(1, 1));
  4091. var h = cc.LabelTTF.create("", "Arial", 12);
  4092. bs.positionNodeToParentPercent(h, this, 0.5, 1);
  4093. h.anchorY = 1;
  4094. this.addChild(h);
  4095. h = this.title = new cc.Sprite("#ma_title.png");
  4096. h.x = f.width / 2;
  4097. h.y = f.height - 90 * e + 30;
  4098. this.addChild(h);
  4099. e = cc.LabelTTF.create("\u63d0\u793a\uff1a\u2460\u99ac\u8d70\u201c\u65e5\u201d \u2461\u70b9\u4eae\u6240\u6709\u706f", wx.chess.font, 16);
  4100. e.x = f.width / 2;
  4101. e.y = bs.getBottom(h) - 15;
  4102. this.addChild(e);
  4103. e = this.gameLayer = new wx.chess.GameLayer;
  4104. this.addChild(e);
  4105. h = bs.getBottom(this.title) - bs.getTop(e);
  4106. 25 > h && (e.y = e.y + h - 25);
  4107. var e = new wx.chess.Button("", "ma_button_play", this.play, this),
  4108. h = new wx.chess.Button("", "ma_button_help", this.help, this),
  4109. g = new wx.chess.Button("", "ma_button_more", this.more, this);
  4110. e.x = 0.25 * f.width;
  4111. h.x = 0.5 * f.width;
  4112. g.x = 0.75 * f.width;
  4113. e.y = h.y = g.y = 60 + 30 * (f.height - 455) / 120;
  4114. this.addChild(e);
  4115. this.addChild(h);
  4116. this.addChild(g);
  4117. Util.trackEvent("play")
  4118. },
  4119. onEnter: function() {
  4120. this._super();
  4121. bs.registerMessageHandler("game-over", this, this.gameOver)
  4122. },
  4123. play: function() {
  4124. this.retryDlg && (this.retryDlg.removeFromParent(), delete this.retryDlg);
  4125. this.gameLayer.restart();
  4126. Util.trackEvent("replay");
  4127. },
  4128. help: function() {
  4129. Util.trackEvent("help");
  4130. this.addChild(new wx.chess.GameTip)
  4131. },
  4132. more: function() {
  4133. Util.trackEvent("more");
  4134. //window.location.href = wx.chess.moreGamesUrl
  4135. clickMore();
  4136. },
  4137. share: function() {
  4138. click_share_action()
  4139. },
  4140. gameOver: function(d) {
  4141. wx.chess.lastScore = d;
  4142. Util.trackEvent("end", "score", d);
  4143. /*var c = _.sprintf("\u606d\u559c\u60a8\u53ea\u7528%d\u6b65\u5c31\u89e3\u5f00\u4e86\u8ff7\u5c40\uff01\u7687\u4e0a\u9f99\u989c\u5927\u60a6\uff0c\u5c01\u60a8\u4e3a\u3010%s\u3011\uff0c\u5feb\u53bb\u70ab\u8000\u4e00\u4e0b\u5427\uff01", d, wx.chess.getTitle());
  4144. Util.trackEvent("end", "score", d);
  4145. c = new wx.chess.Dialog(c, "取消",
  4146. function() {
  4147. this.showRetryDlg(d)
  4148. }.bind(this), "分享",
  4149. function() {
  4150. //this.showRetryDlg(d);
  4151. //this.share()
  4152. }.bind(this));
  4153. this.addChild(c);
  4154. bs.centerNodeToParent(c)
  4155. */
  4156. this.showRetryDlg(d);
  4157. dp_submitScore(d);
  4158. },
  4159. showRetryDlg: function(b) {
  4160. b = this.retryDlg = new wx.chess.Dialog(_.sprintf("\u60a8\u7528\u4e86%d\u6b65\u89e3\u5f00\u4e86\u8ff7\u5c40", b), "再玩一次", this.play.bind(this), "更多游戏", this.more.bind(this));
  4161. this.addChild(b);
  4162. bs.centerNodeToParent(b)
  4163. }
  4164. });
  4165. wx.chess.Dialog = cc.Sprite.extend({
  4166. ctor: function(g, e, l, j, i) {
  4167. this._super();
  4168. this.initWithSpriteFrameName("ma_dialog_bg.png");
  4169. g = cc.LabelTTF.create(g, "\u9ed1\u4f53", 18);
  4170. g.setColor(cc.color(0, 0, 0));
  4171. g.setHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER);
  4172. g.setDimensions(cc.size(this.width - 40, 0));
  4173. bs.positionNodeToParentPercent(g, this, 0.5, 0.65);
  4174. this.addChild(g);
  4175. var h = this;
  4176. g = function(b) {
  4177. return function() {
  4178. h.removeFromParent();
  4179. b()
  4180. }
  4181. };
  4182. e = new wx.chess.Button(e, "ma_button_blue", g(l), this);
  4183. bs.positionNodeToParentPercent(e, this, 0.28, 0.27);
  4184. this.addChild(e);
  4185. j = new wx.chess.Button(j, "ma_button_red", g(i), this);
  4186. bs.positionNodeToParentPercent(j, this, 0.72, 0.27);
  4187. this.addChild(j)
  4188. }
  4189. });