Refactor code

This commit is contained in:
the1812 2019-03-04 20:33:03 +08:00
parent 2df673af9b
commit b892275356
6 changed files with 12 additions and 12 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(()=>{return(t,e)=>{const{toolTips:s}=e.import("settings-tooltip");class i{constructor(){this.input=document.querySelector(".gui-settings-search");const t=[...document.querySelectorAll(".gui-settings-content>ul>li")];const e=t=>e=>e.classList.contains("category")===t;this.categories=t.filter(e(true));this.items=t.filter(e(false));this.input.addEventListener("input",()=>this.keywordChange())}keywordChange(){const t=this.input.value.trim();if(!t){this.categories.concat(this.items).forEach(t=>t.classList.add("folded"));return}this.items.forEach(e=>{const i=$(e).find("input").attr("key");const n=Resource.displayNames[i]+s[i].replace(/<span>|<\/span>/g,"");if(n.includes(t)){e.classList.remove("folded")}else{e.classList.add("folded")}});this.foldCategories()}foldCategories(){for(const e of this.categories){function t(){let t=e.nextElementSibling;while(t!==null&&!t.classList.contains("category")){if(!t.classList.contains("folded")){return"remove"}t=t.nextElementSibling}return"add"}e.classList[t()]("folded")}}}return{export:{SettingsSearch:i}}}})();
(()=>{return(t,e)=>{const{toolTips:s}=e.import("settings-tooltip");class i{constructor(){this.input=document.querySelector(".gui-settings-search");const t=[...document.querySelectorAll(".gui-settings-content>ul>li")];const e=t=>e=>e.classList.contains("category")===t;this.categories=t.filter(e(true));this.items=t.filter(e(false));this.input.addEventListener("input",()=>this.keywordChange())}keywordChange(){const t=this.input.value.trim();if(!t){this.categories.concat(this.items).forEach(t=>t.classList.add("folded"));return}this.items.forEach(e=>{const i=e.querySelector("input").getAttribute("key");const n=Resource.displayNames[i]+s[i].replace(/<span>|<\/span>/g,"");if(n.includes(t)){e.classList.remove("folded")}else{e.classList.add("folded")}});this.foldCategories()}foldCategories(){for(const e of this.categories){function t(){let t=e.nextElementSibling;while(t!==null&&!t.classList.contains("category")){if(!t.classList.contains("folded")){return"remove"}t=t.nextElementSibling}return"add"}e.classList[t()]("folded")}}}return{export:{SettingsSearch:i}}}})();

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,7 @@ export class SettingsSearch
}
this.items.forEach(item =>
{
const key = $(item).find("input").attr("key");
const key = item.querySelector("input").getAttribute("key");
const texts = Resource.displayNames[key] + toolTips[key].replace(/<span>|<\/span>/g, "");
if (texts.includes(value))
{

View File

@ -71,7 +71,7 @@ export const toolTips = {
};
function extractKey(listItem)
{
const input = $(listItem).find("input");
const input = listItem.querySelector("input");
if (input.length > 0)
{
return input.attr("key");