This commit is contained in:
the1812 2019-01-01 15:32:16 +08:00
parent e8f4c8ac84
commit 833ab8fe9c
6 changed files with 20 additions and 9 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(e,t)=>{const n=t.attributes.textValidate.export.Validator;const i=t.attributes.settingsSearch.export;const s=t.attributes.themeColors.export;const o=new s;const a=t.data.guiSettingsDom.text;function c(e){let t=e.nextElementSibling;const n=[];while(t!==null&&!t.classList.contains("category")){n.push(t);t=t.nextElementSibling}return n}function r(e,t){$(`input[type='checkbox'][key='${e}']`).prop("checked",t);$(`input[type='text'][key='${e}']`).val(t)}function l(){for(const[t,n]of Object.entries(e)){r(t,n)}}function p(){$(".gui-settings-mask").on("click",()=>{$(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask").removeClass("opened")});$("input[type='text'][key]").each((t,n)=>{$(n).attr("placeholder",e[$(n).attr("key")])});$(".gui-settings-content ul li.category").on("click",e=>{e.currentTarget.classList.toggle("folded");c(e.currentTarget).forEach(e=>e.classList.toggle("folded"))});$(".gui-settings-dropdown>input").on("click",e=>{$(e.currentTarget).parent().toggleClass("opened")});onSettingsChange((t,n,i)=>{if(e[t]!==i){e[t]=i;$(`input[type='checkbox'][key='${t}']`).prop("checked",i).change();$(`input[type='text'][key='${t}']`).val(i).change()}})}function u(){const t=e=>{};$("input[type='checkbox'][key]").each((n,i)=>{$(i).on("change",()=>{const n=i.getAttribute("key");const s=i.checked;e[n]=s;t(n);saveSettings(e)})});$("input[type='text'][key]").each((i,s)=>{$(s).on("change",()=>{const i=s.getAttribute("key");const o=n.getValidator(i).validate(s.value);e[i]=o;s.value=o;t(i);saveSettings(e)})})}function d(){const e={};$(`input[dependencies]`).each((t,n)=>{const i=$(n).attr("dependencies");if(i){e[$(n).attr("key")]=i}});const t=t=>{const n=t.prop("checked");for(const i in e){const s=e[i].split(" ");if(s.indexOf(t.attr("key"))!==-1){let e=true;if(n&&s.every(e=>$(`input[key='${e}']`).prop("checked"))){e=false}const t=$(`li:has(input[key='${i}'])`);const o=e?"addClass":"removeClass";t[o]("disabled");$(`input[key='${i}'][type='text']`).parent()[o]("disabled")}}};$(`input[type='checkbox'][key]`).on("change",e=>t($(e.target))).each((e,n)=>t($(n)))}function g(){if(typeof offlineData!=="undefined"){$("li:has(input[key=useCache])").addClass("disabled");$("input[key=useCache]").prop("disabled",true)}}function y(){$(".gui-settings-content ul li.category").each((e,t)=>{$(t).click()})}function k(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){$("input[key=blurVideoControl]").prop("disabled",true);e.blurVideoControl=false;saveSettings(e)}if(window.devicePixelRatio===1){$("input[key=harunaScale]").prop("disabled",true);e.harunaScale=false;saveSettings(e)}}t.applyStyle("guiSettingsStyle");$("body").append(a);p();g();l();d();o.setupDom();u();y();k();new i;new SpinQuery(()=>$("body"),e=>e.length>0&&!(unsafeWindow.parent.window===unsafeWindow),e=>$(".gui-settings-icon-panel").css("display","none")).start()}})(); (()=>{return(e,t)=>{const n=t.attributes.textValidate.export.Validator;const i=t.attributes.settingsSearch.export;const s=t.attributes.themeColors.export;const o=new s;const a=t.data.guiSettingsDom.text;function c(e){let t=e.nextElementSibling;const n=[];while(t!==null&&!t.classList.contains("category")){n.push(t);t=t.nextElementSibling}return n}function r(e,t){$(`input[type='checkbox'][key='${e}']`).prop("checked",t);$(`input[type='text'][key='${e}']`).val(t)}function u(){for(const[t,n]of Object.entries(e)){r(t,n)}}function l(){$(".gui-settings-mask").on("click",()=>{$(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask").removeClass("opened")});$("input[type='text'][key]").each((t,n)=>{$(n).attr("placeholder",e[$(n).attr("key")])});$(".gui-settings-content ul li.category").on("click",e=>{const t=document.querySelector(".gui-settings-search");if(t.value!==""){t.value="";raiseEvent(t,"input")}e.currentTarget.classList.toggle("folded");c(e.currentTarget).forEach(e=>e.classList.toggle("folded"))});$(".gui-settings-dropdown>input").on("click",e=>{$(e.currentTarget).parent().toggleClass("opened")});onSettingsChange((t,n,i)=>{if(e[t]!==i){e[t]=i;$(`input[type='checkbox'][key='${t}']`).prop("checked",i).change();$(`input[type='text'][key='${t}']`).val(i).change()}})}function p(){const t=e=>{};$("input[type='checkbox'][key]").each((n,i)=>{$(i).on("change",()=>{const n=i.getAttribute("key");const s=i.checked;e[n]=s;t(n);saveSettings(e)})});$("input[type='text'][key]").each((i,s)=>{$(s).on("change",()=>{const i=s.getAttribute("key");const o=n.getValidator(i).validate(s.value);e[i]=o;s.value=o;t(i);saveSettings(e)})})}function d(){const e={};$(`input[dependencies]`).each((t,n)=>{const i=$(n).attr("dependencies");if(i){e[$(n).attr("key")]=i}});const t=t=>{const n=t.prop("checked");for(const i in e){const s=e[i].split(" ");if(s.indexOf(t.attr("key"))!==-1){let e=true;if(n&&s.every(e=>$(`input[key='${e}']`).prop("checked"))){e=false}const t=$(`li:has(input[key='${i}'])`);const o=e?"addClass":"removeClass";t[o]("disabled");$(`input[key='${i}'][type='text']`).parent()[o]("disabled")}}};$(`input[type='checkbox'][key]`).on("change",e=>t($(e.target))).each((e,n)=>t($(n)))}function g(){if(typeof offlineData!=="undefined"){$("li:has(input[key=useCache])").addClass("disabled");$("input[key=useCache]").prop("disabled",true)}}function y(){$(".gui-settings-content ul li.category").each((e,t)=>{$(t).click()})}function k(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){$("input[key=blurVideoControl]").prop("disabled",true);e.blurVideoControl=false;saveSettings(e)}if(window.devicePixelRatio===1){$("input[key=harunaScale]").prop("disabled",true);e.harunaScale=false;saveSettings(e)}}t.applyStyle("guiSettingsStyle");$("body").append(a);l();g();u();d();o.setupDom();p();y();k();new i;new SpinQuery(()=>$("body"),e=>e.length>0&&!(unsafeWindow.parent.window===unsafeWindow),e=>$(".gui-settings-icon-panel").css("display","none")).start()}})();

View File

@ -1 +1 @@
(()=>{return(t,e)=>{const s=e.attributes.settingsTooltip.export;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();this.items.forEach(e=>{const i=$(e).find("input").attr("key");const n=e.innerText+s[i].replace(/<span>|<\/span>/g,"");if(!t||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:i}}})(); (()=>{return(t,e)=>{const s=e.attributes.settingsTooltip.export;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=e.innerText+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:i}}})();

View File

@ -45,6 +45,12 @@
}); });
$(".gui-settings-content ul li.category").on("click", e => $(".gui-settings-content ul li.category").on("click", e =>
{ {
const searchBox = document.querySelector(".gui-settings-search");
if (searchBox.value !== "")
{
searchBox.value = "";
raiseEvent(searchBox, "input");
}
e.currentTarget.classList.toggle("folded"); e.currentTarget.classList.toggle("folded");
getCategoriyItems(e.currentTarget).forEach(it => it.classList.toggle("folded")); getCategoriyItems(e.currentTarget).forEach(it => it.classList.toggle("folded"));
}); });

View File

@ -17,11 +17,16 @@
keywordChange() keywordChange()
{ {
const value = this.input.value.trim(); const value = this.input.value.trim();
if (!value)
{
this.categories.concat(this.items).forEach(it => it.classList.add("folded"));
return;
}
this.items.forEach(item => this.items.forEach(item =>
{ {
const key = $(item).find("input").attr("key"); const key = $(item).find("input").attr("key");
const texts = item.innerText + toolTips[key].replace(/<span>|<\/span>/g, ""); const texts = item.innerText + toolTips[key].replace(/<span>|<\/span>/g, "");
if (!value || texts.includes(value)) if (texts.includes(value))
{ {
item.classList.remove("folded"); item.classList.remove("folded");
} }