Improve settings

This commit is contained in:
the1812 2019-05-19 18:25:52 +08:00
parent 191437c73d
commit b2c6f1cbac
8 changed files with 21 additions and 21 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

@ -193,19 +193,19 @@ namespace BilibiliEvolved.Build
@"<textbox\s*?indent=""?(.+?)""?\s*key=""?(.+?)""?\s*?dependencies=""?(.*?)""?>([^\0]*?)<\/textbox>", @"<textbox\s*?indent=""?(.+?)""?\s*key=""?(.+?)""?\s*?dependencies=""?(.*?)""?>([^\0]*?)<\/textbox>",
}; };
var replacements = new string[] { var replacements = new string[] {
@"<li class='indent-center category'> @"<li class='indent-center category folded'>
<i class='icon-$1' style='margin-right:8px'></i> <i class='icon-$1' style='margin-right:8px'></i>
<span class='settings-category'>$2</span> <span class='settings-category'>$2</span>
<i class='icon-arrow' style='margin-left:8px'></i> <i class='icon-arrow' style='margin-left:8px'></i>
</li>", </li>",
@"<li class='indent-$1'> @"<li class='indent-$1 folded'>
<label class='gui-settings-checkbox-container'> <label class='gui-settings-checkbox-container'>
<input key='$2' type='checkbox' dependencies='$3' checked/> <input key='$2' type='checkbox' dependencies='$3' checked/>
<div class='gui-settings-checkbox'></div> <div class='gui-settings-checkbox'></div>
<span>$4</span> <span>$4</span>
</label> </label>
</li>", </li>",
@"<li class='indent-$1'> @"<li class='indent-$1 folded'>
<label class='gui-settings-dropdown-container'> <label class='gui-settings-dropdown-container'>
<span class='gui-settings-dropdown-span'>$4</span> <span class='gui-settings-dropdown-span'>$4</span>
<div class='gui-settings-dropdown popup'> <div class='gui-settings-dropdown popup'>
@ -215,7 +215,7 @@ namespace BilibiliEvolved.Build
</div> </div>
</label> </label>
</li>", </li>",
@"<li class='indent-$1'> @"<li class='indent-$1 folded'>
<label class='gui-settings-textbox-container'> <label class='gui-settings-textbox-container'>
<span>$4</span> <span>$4</span>
<input key='$2' dependencies='$3' spellcheck='false' type='text' /> <input key='$2' dependencies='$3' spellcheck='false' type='text' />

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(()=>{return(e,t)=>{const{ThemeColors:n}=t.import("theme-colors");const{SettingsSearch:i}=t.import("settings-search");const{Validator:s}=t.import("text-validate");let o=[];let c=[];let r=[];function l(e){let t=e.nextElementSibling;const n=[];while(t!==null&&!t.classList.contains("category")){n.push(t);t=t.nextElementSibling}return n}function a(){r.forEach(t=>t.value=e[t.getAttribute("key")]);c.forEach(t=>t.checked=e[t.getAttribute("key")])}function u(){document.querySelector(".gui-settings-mask").addEventListener("click",()=>{document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask,.bilibili-evolved-about").forEach(e=>e.classList.remove("opened"))});r.forEach(t=>{t.setAttribute("placeholder",e[t.getAttribute("key")])});document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.addEventListener("click",e=>{const t=document.querySelector(".gui-settings-search");if(t.value!==""){t.value="";raiseEvent(t,"input")}e.currentTarget.classList.toggle("folded");l(e.currentTarget).forEach(e=>e.classList.toggle("folded"))})});document.querySelectorAll(".gui-settings-dropdown>input").forEach(e=>{e.addEventListener("click",e=>{e.currentTarget.parentElement.classList.toggle("opened")})})}function d(){const t=e=>{};c.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const s=n.checked;e[i]=s;t(i);saveSettings(e)})});r.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const o=s.getValidator(i).validate(n.value);e[i]=o;n.value=o;t(i);saveSettings(e)})})}function g(){const e=o.map(e=>[e.getAttribute("dependencies").split(" ").map(e=>o.find(t=>t.getAttribute("key")===e)),e]);const t=e=>e.nodeName.toUpperCase()==="LI"?e:t(e.parentElement);e.forEach(([e,n])=>{if(e[0]===undefined){return}const i=()=>{if(e.every(e=>e.checked)){t(n).classList.remove("disabled")}else{t(n).classList.add("disabled")}};e.forEach(e=>e.addEventListener("change",i));i()})}function f(){if(typeof offlineData!=="undefined"){document.querySelector(".gui-settings-checkbox-container>input[key=useCache]").parentElement.parentElement.classList.add("disabled");document.querySelector("input[key=useCache]").disabled=true}}function b(){document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.click()})}function m(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){o.find(e=>e.getAttribute("key")==="blurVideoControl").disabled=true;e.blurVideoControl=false;saveSettings(e)}if(window.devicePixelRatio===1){o.find(e=>e.getAttribute("key")==="harunaScale").disabled=true;o.find(e=>e.getAttribute("key")==="imageResolution").disabled=true;e.harunaScale=false;e.imageResolution=false;saveSettings(e)}}function p(){for(const[e,t]of Object.entries(Resource.displayNames)){const n=o.find(t=>t.getAttribute("key")===e);if(!n){continue}switch(n.type){case"checkbox":n.nextElementSibling.nextElementSibling.innerHTML=t;break;case"text":const e=n.parentElement;if(e.classList.contains("gui-settings-textbox-container")){n.previousElementSibling.innerHTML=t}else if(e.classList.contains("gui-settings-dropdown")){e.previousElementSibling.innerHTML=t}break;default:break}}}(async()=>{t.applyStyle("guiSettingsStyle");document.body.insertAdjacentHTML("afterbegin",`<link rel="stylesheet" href="//cdn.materialdesignicons.com/3.5.95/css/materialdesignicons.min.css">`);const e=document.body&&unsafeWindow.parent.window!==unsafeWindow;if(e){document.querySelector(".gui-settings-icon-panel").style.display="none"}const s=t.data.guiSettingsHtml.text;document.body.insertAdjacentHTML("beforeend",s);const l=document.querySelector(".widgets-container");const y=l.querySelector(".empty-tip");Observer.childList(l,()=>{if(l.childElementCount<=1){y.classList.add("show")}else{y.classList.remove("show")}});(new n).setupDom();const h=document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box");document.querySelector(".gui-settings-icon-panel").addEventListener("mouseover",()=>{h.forEach(e=>e.classList.add("loaded"));o=[...document.querySelectorAll("input[key]")];c=o.filter(e=>e.type==="checkbox");r=o.filter(e=>e.type==="text");u();f();a();g();d();b();m();p();new i},{once:true})})()}})(); (()=>{return(e,t)=>{const{ThemeColors:n}=t.import("theme-colors");const{SettingsSearch:i}=t.import("settings-search");const{Validator:s}=t.import("text-validate");let o=[];let c=[];let r=[];function a(e){let t=e.nextElementSibling;const n=[];while(t!==null&&!t.classList.contains("category")){n.push(t);t=t.nextElementSibling}return n}function l(){r.forEach(t=>t.value=e[t.getAttribute("key")]);c.forEach(t=>t.checked=e[t.getAttribute("key")])}function u(){document.querySelector(".gui-settings-mask").addEventListener("click",()=>{document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask,.bilibili-evolved-about").forEach(e=>e.classList.remove("opened"))});r.forEach(t=>{t.setAttribute("placeholder",e[t.getAttribute("key")])});document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.addEventListener("click",e=>{const t=document.querySelector(".gui-settings-search");if(t.value!==""){t.value="";raiseEvent(t,"input")}e.currentTarget.classList.toggle("folded");a(e.currentTarget).forEach(e=>e.classList.toggle("folded"))})});document.querySelectorAll(".gui-settings-dropdown>input").forEach(e=>{e.addEventListener("click",e=>{e.currentTarget.parentElement.classList.toggle("opened")})})}function d(){const t=e=>{};c.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const s=n.checked;e[i]=s;t(i);saveSettings(e)})});r.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const o=s.getValidator(i).validate(n.value);e[i]=o;n.value=o;t(i);saveSettings(e)})})}function g(){const e=o.map(e=>[e.getAttribute("dependencies").split(" ").map(e=>o.find(t=>t.getAttribute("key")===e)),e]);const t=e=>e.nodeName.toUpperCase()==="LI"?e:t(e.parentElement);e.forEach(([e,n])=>{if(e[0]===undefined){return}const i=()=>{if(e.every(e=>e.checked)){t(n).classList.remove("disabled")}else{t(n).classList.add("disabled")}};e.forEach(e=>e.addEventListener("change",i));i()})}function f(){if(typeof offlineData!=="undefined"){document.querySelector(".gui-settings-checkbox-container>input[key=useCache]").parentElement.parentElement.classList.add("disabled");document.querySelector("input[key=useCache]").disabled=true}}function b(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){o.find(e=>e.getAttribute("key")==="blurVideoControl").disabled=true;e.blurVideoControl=false;saveSettings(e)}if(window.devicePixelRatio===1){o.find(e=>e.getAttribute("key")==="harunaScale").disabled=true;o.find(e=>e.getAttribute("key")==="imageResolution").disabled=true;e.harunaScale=false;e.imageResolution=false;saveSettings(e)}}function m(){for(const[e,t]of Object.entries(Resource.displayNames)){const n=o.find(t=>t.getAttribute("key")===e);if(!n){continue}switch(n.type){case"checkbox":n.nextElementSibling.nextElementSibling.innerHTML=t;break;case"text":const e=n.parentElement;if(e.classList.contains("gui-settings-textbox-container")){n.previousElementSibling.innerHTML=t}else if(e.classList.contains("gui-settings-dropdown")){e.previousElementSibling.innerHTML=t}break;default:break}}}(async()=>{t.applyStyle("guiSettingsStyle");document.body.insertAdjacentHTML("afterbegin",`<link rel="stylesheet" href="//cdn.materialdesignicons.com/3.5.95/css/materialdesignicons.min.css">`);const e=document.body&&unsafeWindow.parent.window!==unsafeWindow;if(e){document.querySelector(".gui-settings-icon-panel").style.display="none"}const s=t.data.guiSettingsHtml.text;document.body.insertAdjacentHTML("beforeend",s);const a=document.querySelector(".widgets-container");const p=a.querySelector(".empty-tip");Observer.childList(a,()=>{if(a.childElementCount<=1){p.classList.add("show")}else{p.classList.remove("show")}});(new n).setupDom();const y=document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box");document.querySelector(".gui-settings-icon-panel").addEventListener("mouseover",()=>{y.forEach(e=>e.classList.add("loaded"));o=[...document.querySelectorAll("input[key]")];c=o.filter(e=>e.type==="checkbox");r=o.filter(e=>e.type==="text");u();f();l();g();d();b();m();new i},{once:true})})()}})();

View File

@ -43,7 +43,7 @@
<textbox indent="1" key="playerFocusOffset" dependencies="playerFocus"></textbox> <textbox indent="1" key="playerFocusOffset" dependencies="playerFocus"></textbox>
<checkbox indent="0" key="outerWatchlater" dependencies=""></checkbox> <checkbox indent="0" key="outerWatchlater" dependencies=""></checkbox>
<category icon="style">样式</category> <category icon="style">样式</category>
<li class="indent-0"> <li class="indent-0 folded">
<label class="gui-settings-textbox-container"> <label class="gui-settings-textbox-container">
<span>主题颜色</span> <span>主题颜色</span>
<div class="custom-color-preview"> <div class="custom-color-preview">

View File

@ -201,13 +201,13 @@ function checkOfflineData()
document.querySelector("input[key=useCache]").disabled = true; document.querySelector("input[key=useCache]").disabled = true;
} }
} }
function foldAllCategories() // function foldAllCategories()
{ // {
document.querySelectorAll(".gui-settings-content ul li.category").forEach(e => // document.querySelectorAll(".gui-settings-content ul li.category").forEach(e =>
{ // {
e.click(); // e.click();
}); // });
} // }
function checkCompatibility() function checkCompatibility()
{ {
if (!CSS.supports("backdrop-filter", "blur(24px)") if (!CSS.supports("backdrop-filter", "blur(24px)")
@ -313,7 +313,7 @@ function setDisplayNames()
syncGui(); syncGui();
listenDependencies(); listenDependencies();
listenSettingsChange(); listenSettingsChange();
foldAllCategories(); // foldAllCategories();
checkCompatibility(); checkCompatibility();
setDisplayNames(); setDisplayNames();
new SettingsSearch(); new SettingsSearch();