\n
\n
\n
\n
> 回報成功,系統將於一週內完成確認
\n
\n \n \n \n ',(()=>{let e=this.me.querySelector("#name");this.ascp=new Awesomplete(e),e.addEventListener("compositionstart",(e=>this.input_key=!1)),e.addEventListener("compositionend",(e=>this.input_key=!0)),e.addEventListener("input",this.debounce(this.inputHandler,[e])),e.addEventListener("click",(()=>{this.ascp.evaluate()})),e.addEventListener("awesomplete-select",(async t=>{clearTimeout(this.timer),this.showLoading("none");let n=t.text.value.split("-"),r=n[0],i=cpn.Tool.server_map_r[n[1]];e.blur(),this.dispatchEvent(new CustomEvent(cpn.Events.SELECT,{detail:{name:r,server:i}}))})),this.me.querySelector("#report").addEventListener("click",(async()=>{this.me.querySelector("#ldi").style.display="block";let e,t=this.capitalize(this.me.querySelector("#name").value.split("-")[0]);try{e=await fetch("/report",{method:"POST",body:t})}catch(e){return void(e instanceof TypeError?this.dispatchEvent(new CustomEvent(Events.REPORT_ERR,{detail:{err:new cpn.NetError("連線異常,請檢查網路是否中斷")}})):"AbortError"==e.name?this.dispatchEvent(new CustomEvent(Events.REPORT_ERR,{detail:{err:new cpn.NetError("連線逾時,請檢查網路品質")}})):this.dispatchEvent(new CustomEvent(Events.REPORT_ERR,{detail:{err:e}})))}if(e.status>=500)throw new cpn.ServerError("伺服器繁忙,請稍候再嘗試");(await e.json()).err?this.dispatchEvent(new CustomEvent(Events.REPORT_ERR,{detail:{err:new cpn.ServerError("伺服器繁忙,請稍候再嘗試")}})):(this.me.querySelector("#ldi").style.display="none",this.goto(this.me.querySelector("#hint"),"#ok","block"))}))}))}setLight(e){let t,n=Math.ceil(e/1e3/60/60/24);t=n>=30?"drop-shadow(0 0 10px cyan)":n>=7&&n<30?"drop-shadow(0 0 3px cyan)":n>=1&&n<7?"drop-shadow(0 0 3px red)":"drop-shadow(0 0 10px red)",this.me.querySelector("#logo").style.filter=t,this.me.querySelector("#title").style.filter=t,this.me.querySelector("#input_img").style.filter=t,this.me.querySelector("#title").style.color="white"}showLoading(e){this.me.querySelector("#ldi").style.display=e}setName(e){this.me.querySelector("#name").value=e}capitalize(e){return e&&e[0].toLocaleUpperCase()+e.slice(1).toLocaleLowerCase()}async inputHandler(e){let t,n,r;if(this.goto(this.me.querySelector("#hint"),"#none","block"),e.value.indexOf("-")>-1){let r=e.value.split("-");if(t=this.capitalize(r[0]),n=cpn.Tool.server_map_r[r[1]],!n)return void(this.me.querySelector("#ldi").style.display="none")}else t=this.capitalize(e.value),n="all";try{r=MainService.getNames_c(t,n)}catch(e){if(!(e instanceof cpn.CacheError))return void this.dispatchEvent(new CustomEvent(Events.NAME_LIST_ERR,{detail:{err:e}}));try{r=await this.getNameList(t,n)}catch(e){if(!(e instanceof FormatError))return void this.dispatchEvent(new CustomEvent(Events.NAME_LIST_ERR,{detail:{err:e}}));if("不完整的輸入"==e.message)return void(this.me.querySelector("#ldi").style.display="none");if("無效的格式"==e.message)return void this.dispatchEvent(new CustomEvent(Events.NAME_LIST_ERR,{detail:{err:e}}))}MainService.setNames_c(t,n,r)}this.ascp.list=r,this.ascp.evaluate(),r&&0==r.length&&this.goto(this.me.querySelector("#hint"),"#no_data","block"),this.me.querySelector("#ldi").style.display="none"}async getNameList(e,t){let n,r=/[~!@#$%^&*()_+=\`\[\]{}';:".,<>/\\?\|0-9\s]/;if(e.length<2)throw new FormatError("不完整的輸入");if(r.test(e)||r.test(t))throw new FormatError("無效的格式");try{n=await MainService.getNames(e,t)}catch(e){throw e}let i=[];for(let e in n){let t=n[e].name,r=cpn.Tool.server_map[n[e].server];i.push(`${t}-${r}`)}return i}debounce(e,t,n=1e3){return()=>{setTimeout((()=>{if(navigator.userAgent.indexOf("Android")>-1&&(this.input_key=!0),this.input_key){this.me.querySelector("#ldi").style.display="block";let r=this;clearTimeout(this.timer),this.timer=setTimeout((()=>{e.apply(r,t)}),n)}}),0)}}connectedCallback(){}}async function dclHandler(){let e=new URL(location.href).searchParams.get("msg");e&&alert(e),document.querySelector("c-search_array").style.visibility="hidden",document.querySelector("c-footer").style.visibility="hidden",await hashTagHandler(),document.querySelector("c-search_array").style.visibility="visible",document.querySelector("c-footer").style.visibility="visible"}async function hashTagHandler(){let e=location.hash;if("#_=_"==e)return;if(""==e)return void viewHome();document.querySelector("c-search_array").showLoading("block");let t=e.substr(1).split("/"),n=decodeURIComponent(t[1]),r=t[0];try{await getDataAndViewContent(n,r)}catch(e){if(e instanceof cpn.NetError||e instanceof cpn.ServerError)return void alert(e.message);throw e}document.querySelector("c-search_array").showLoading("none")}async function getDataAndViewContent(e,t){let n;checkU();try{n=MainService.getDatas_c(e,t)}catch(r){if(!(r instanceof cpn.CacheError))throw r;try{let r=cpn.UserService.getU(),i=null!=r?r.tk:"";n=await MainService.getDatas(e,t,i)}catch(e){throw e}if(!(n.length>0))return void viewHome();MainService.setDatas_c(e,t,n)}viewContent(e,t,n)}function viewContent(e,t,n){let r=e+"-"+cpn.Tool.server_map[t];document.title=r+" | WOW魔獸分身查詢",document.querySelector("c-search_array").style.marginTop="1rem",document.querySelector("c-search_array").setName(r),document.querySelector("c-form_list").renderFormContent(n,e,t),document.querySelector("c-form_list").style.display="block"}function viewHome(){location.hash="",document.title="WOW魔獸分身查詢",document.querySelector("c-search_array").style.marginTop="25vh",document.querySelector("c-search_array").setName(""),document.querySelector("c-form_list").style.display="none"}function setStickyTitleTop(){document.querySelector("c-form_list").style.setProperty("--sticky-titleTop",document.querySelector("c-header").offsetHeight-1+"px")}function alertMsg(e){let t=e.detail.err;if(!(t instanceof cpn.NetError||t instanceof cpn.ServerError||t instanceof FormatError))throw t;alert(t.message)}async function main(){cpn.StyleService.InitTheme([document.querySelector("#style").sheet]),cpn.CacheService.checkExpire(),customElements.define("c-header",cpn.Header),customElements.define("c-footer",cpn.Footer),customElements.define("c-heart",Heart),customElements.define("c-search_array",SearchArray),customElements.define("c-msg",Msg),customElements.define("c-form_list",cpn.FormList),window.addEventListener("hashchange",hashTagHandler),window.addEventListener("DOMContentLoaded",dclHandler),setStickyTitleTop(),checkU()}function checkU(){let e=cpn.UserService.getU(),t=0,n="block",r=!0;null!=e&&(t=e.et-Date.now(),n="none",r=!1),document.querySelector("c-heart").setV(t),document.querySelector("c-search_array").setLight(t),document.querySelector("c-msg").setV(t),document.querySelector("c-form_list").setCure(n)}document.querySelector("c-search_array").addEventListener(cpn.Events.SELECT,(async e=>{let t=e.detail.name,n=e.detail.server;location.hash=n+"/"+t})),window.addEventListener("resize",setStickyTitleTop),document.querySelector("c-form_list").addEventListener(cpn.Events.SCORE_ERR,alertMsg),document.querySelector("c-search_array").addEventListener(Events.NAME_LIST_ERR,alertMsg),document.querySelector("c-search_array").addEventListener(Events.REPORT_ERR,alertMsg),main()