mirror of
https://github.com/webxoss/webxoss-client.git
synced 2024-11-20 05:49:55 +01:00
1 line
No EOL
6.5 KiB
JavaScript
1 line
No EOL
6.5 KiB
JavaScript
"use strict";window.ImageManager=function(){function e(e){var t=new Image;return t.src=e,t}function t(t){this.dir=t||"./",this.black=e(this.dir+"images/WIXOSS_BLACK.jpg"),this.white=e(this.dir+"images/WIXOSS_WHITE.jpg"),this.noimage=e(this.dir+"images/noimage.jpg"),this.imageCache={},this.stateImageMap={frozen:e(this.dir+"background/frozen.png"),charm:e(this.dir+"background/charm.png"),lancer:e(this.dir+"background/lancer.png"),doubleCrash:e(this.dir+"background/doubleCrash.png"),locked:e(this.dir+"background/locked.png"),assassin:e(this.dir+"background/assassin.png")}}return t.prototype.getUrlByPid=function(e){var t=window.ImageFileCache.getUrlByPid(e);return t?t:(t=this.dir+"images/"+("0000"+e).slice(-4)+".jpg",window.ImageFileCache.fetchAndCache(e,t),t)},t.prototype.getImageByPid=function(t){if(!t)return this.noimage;if(t in this.imageCache)return this.imageCache[t];var i=this.getUrlByPid(t),a=e(i);return this.imageCache[t]=a,a},t.prototype.getBackImage=function(e){return e?this.white:this.black},t.prototype.getStateImage=function(e){return this.stateImageMap[e]},t}(),window.CardDetail=function(){function e(e){return document.getElementById(e)}function t(e){for(var t=document.createElement(e),i=1;i<arguments.length;i++)t.classList.add(arguments[i]);return t}function i(e,i){this.prop=e,this.keyHidden=i,this.value="",this.eKey=t("td","key",e),this.eKey.textContent=Localize.propToKey(e),this.eValue=t("td","value",e)}function a(t){this.imageManager=t,this.eDetail=e("detail"),this.eImage=e("detail-card-image"),this.eWxid=e("detail-card-wxid"),this.eName=e("detail-card-name"),this.eLimiting=e("detail-card-limiting"),this.eTable=e("detail-table"),this.eTableBody=e("detail-table-body"),this.kvCardType=new i("cardType"),this.kvColor=new i("color"),this.kvLevel=new i("level"),this.kvClasses=new i("classes"),this.kvLimit=new i("limit"),this.kvPower=new i("power"),this.kvLimting=new i("limting"),this.kvGuard=new i("guard"),this.kvCost=new i("cost"),this.kvTimmings=new i("timmings"),this.kvEffects=new i("effects",!0),this.kvBurst=new i("burst",!0),this._pid=0}return a.prototype.show=function(e){if(e&&this._pid!==e){this._pid=e,this.eTable.setAttribute("lang",Localize.getLanguage()),this.eTableBody.innerHTML="";var i=CardInfo[e];this.eWxid.textContent=i.wxid,this.eName.innerHTML="";var a=t("a");a.target="_blank",a.href="http://www.takaratomy.co.jp/products/wixoss/card/card_list.php?card=card_detail&card_no="+i.wxid,a.textContent=Localize.cardName(i),this.eName.appendChild(a),this.eLimiting.textContent=Localize.limiting(i),this.eImage.src=this.imageManager.getUrlByPid(e),this.kvColor.value=i.color.split("/").map(Localize.color).join("/"),this.kvCardType.value=Localize.cardType(i),this.kvEffects.value=Localize.effectTexts(i),inArr(i.cardType,["LRIG","SIGNI","RESONA"])&&(this.kvClasses.value=Localize.classes(i),this.kvLevel.value=i.level),inArr(i.cardType,["LRIG","SPELL","ARTS"])&&(this.kvCost.value=Localize.cost(i)),inArr(i.cardType,["SIGNI","SPELL"])&&(this.kvBurst.value=Localize.burstEffectTexts(i)),"LRIG"===i.cardType?(i.limit>=1024?this.kvLimit.value="∞":this.kvLimit.value=i.limit,this.addKeyValue([this.kvCardType,this.kvColor],[this.kvLevel,this.kvClasses],[this.kvLimit,this.kvCost],[this.kvEffects])):"SIGNI"===i.cardType?(this.kvPower.value=i.power,this.kvGuard.value=Localize.guard(i),this.addKeyValue([this.kvCardType,this.kvColor],[this.kvLevel,this.kvClasses],[this.kvPower,this.kvGuard],[this.kvEffects],[this.kvBurst])):"RESONA"===i.cardType?(this.kvPower.value=i.power,this.kvGuard.value=Localize.guard(i),this.addKeyValue([this.kvCardType,this.kvColor],[this.kvLevel,this.kvClasses],[this.kvPower,this.kvGuard],[this.kvEffects])):"SPELL"===i.cardType?this.addKeyValue([this.kvCardType,this.kvColor],[this.kvCost],[this.kvEffects],[this.kvBurst]):"ARTS"===i.cardType&&(this.kvTimmings.value=Localize.timmings(i),this.addKeyValue([this.kvCardType,this.kvColor],[this.kvCost],[this.kvTimmings],[this.kvEffects]))}},a.prototype.addKeyValue=function(){for(var e=0;e<arguments.length;e++){var i=arguments[e],a=t("tr");if(i.forEach(function(e){e.eValue.textContent=e.value,e.eValue.removeAttribute("colspan"),e.keyHidden||a.appendChild(e.eKey),a.appendChild(e.eValue)},this),1===i.length){var n=i[0],s=n.keyHidden?4:3;n.eValue.setAttribute("colspan",s)}this.eTableBody.appendChild(a)}},a}(),window.ImageFileCache=function(){function e(e){function t(t,a){i&&i.close(),e(!!t,!!a)}var i=null;if(!window.indexedDB)return t();if(!window.IDBKeyRange)return t();if(!window.IDBOpenDBRequest)return t();var a=indexedDB.open("test indexedDB support",1);return"onupgradeneeded"in a?(a.onupgradeneeded=function(e){i=this.result,i.createObjectStore("one"),i.createObjectStore("two",{keyPath:"key"})},a.onerror=function(e){t()},void(a.onsuccess=function(e){i=this.result,i.onerror=function(e){t()};var a;try{a=i.transaction(["one","two"],"readwrite")}catch(e){return t()}var n=a.objectStore("two").put({key:1});n.onsuccess=function(e){var s=new XMLHttpRequest;if(s.responseType="blob",!window.Blob||!window.URL||"blob"!==s.responseType)return i.close(),t(!0,!1);var r=new Blob(["text"],{type:"text/plain"});try{n=a.objectStore("one").put(r,"blob"),a.onabort=function(e){e.stopPropagation(),t(!0,!1)},a.onerror=function(e){e.stopPropagation(),t(!0,!1)},a.oncomplete=function(e){return t(!0,!0)}}catch(e){return t(!0,!1)}}})):t()}function t(e,t,i,a){var n=new XMLHttpRequest;n.responseType=t,n.onload=function(e){200!==n.status?a(n,e):i(n,e)},n.onerror=function(e){a(n,e)},n.open("GET",e,!0),n.send()}function i(e,t){if(s.supportBlob&&!(e in a)){var i=window.URL.createObjectURL(t);a[e]=i;var n=indexedDB.open("card images",1);n.onupgradeneeded=function(e){this.result.createObjectStore("images")},n.onsuccess=function(i){var a=this.result;a.transaction(["images"],"readwrite").objectStore("images").add(t,e)}}}var a={},n={},s={supportIndexedDB:!1,supportBlob:!1},r=!1;return e(function(e,t){if(s.supportIndexedDB=e,s.supportBlob=t,t){var i=indexedDB.open("card images",1);i.onupgradeneeded=function(e){this.result.createObjectStore("images")},i.onsuccess=function(e){var t=this.result,i=!1;t.transaction(["images"]).objectStore("images").openCursor().onsuccess=function(e){var t=this.result;if(t){var n=t.key,s=t.value,o=window.URL.createObjectURL(s);if(!i){i=!0;var c=new Image;c.onload=function(){r=!0,console.log("supportObjectURL")},c.src=o}a[n]=o,t.continue()}}}}}),s.getUrlByPid=function(e){return r?a[e]||"":""},s.fetchAndCache=function(e,a){s.supportBlob&&(n[e]||(n[e]=!0,t(a,"blob",function(t,a){var n=t.response;i(e,n)},function(t,i){console.log('Failed to load "'+a+'"'),n[e]=!1})))},s}(); |