Skip to content

Commit d0cbcf3

Browse files
committed
webui/js: support config requirement
Signed-off-by: KOWX712 <[email protected]>
1 parent 4b27511 commit d0cbcf3

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

webui/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,43 @@ function appendInputGroup() {
161161
container.appendChild(div);
162162
}
163163
}
164+
165+
for (const key in configMetadata) {
166+
const metadata = configMetadata[key];
167+
if (metadata.require) {
168+
const dependentGroup = document.querySelector(`.input-group[data-key="${key}"]`);
169+
if (!dependentGroup) continue;
170+
const dependentInput = dependentGroup.querySelector('md-outlined-select, md-outlined-text-field');
171+
if (!dependentInput) continue;
172+
173+
const checkAndSetDisabled = () => {
174+
const satisfied = metadata.require.every(req =>
175+
Object.entries(req).every(([reqKey, reqValue]) => config[reqKey] === reqValue)
176+
);
177+
178+
if (satisfied) {
179+
dependentInput.removeAttribute('disabled');
180+
} else {
181+
dependentInput.setAttribute('disabled', '');
182+
}
183+
};
184+
185+
metadata.require.forEach(req => {
186+
Object.keys(req).forEach(reqKey => {
187+
const requirementGroup = document.querySelector(`.input-group[data-key="${reqKey}"]`);
188+
if (requirementGroup) {
189+
const requirementInput = requirementGroup.querySelector('md-outlined-select, md-outlined-text-field');
190+
if (requirementInput) {
191+
const eventType = requirementInput.tagName.toLowerCase() === 'md-outlined-select' ? 'change' : 'input';
192+
requirementInput.addEventListener(eventType, checkAndSetDisabled);
193+
}
194+
}
195+
});
196+
});
197+
checkAndSetDisabled();
198+
}
199+
}
200+
164201
setupKeyboard();
165202
appendExtras();
166203
}

webui/public/config_mountify.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
},
5151
"FAKE_APEX_NAME": {
5252
"type": "ext4",
53+
"require": [{"spoof_sparse": 1}],
5354
"option": ["allow-other", "com.android.mntservice"],
5455
"description": "Customize spoofed apex mount name.\nWhile futile, this tries to make it look legit."
5556
},
@@ -65,6 +66,7 @@
6566
},
6667
"lkm_filename": {
6768
"type": "ext4",
69+
"require": [{"enable_lkm_nuke": 1}],
6870
"option": [
6971
"nuke-android12-5.10.ko",
7072
"nuke-android13-5.10.ko",

0 commit comments

Comments
 (0)