2023-05-08 07:46:35 -06:00
|
|
|
// various hints and extra info for the settings tab
|
2023-05-17 06:46:58 -06:00
|
|
|
|
2023-05-18 00:59:10 -06:00
|
|
|
var settingsHintsSetup = false;
|
2023-05-17 06:46:58 -06:00
|
|
|
|
2023-05-14 01:02:51 -06:00
|
|
|
onOptionsChanged(function() {
|
|
|
|
if (settingsHintsSetup) return;
|
|
|
|
settingsHintsSetup = true;
|
2023-05-17 06:46:58 -06:00
|
|
|
|
2023-05-14 01:02:51 -06:00
|
|
|
gradioApp().querySelectorAll('#settings [id^=setting_]').forEach(function(div) {
|
|
|
|
var name = div.id.substr(8);
|
|
|
|
var commentBefore = opts._comments_before[name];
|
|
|
|
var commentAfter = opts._comments_after[name];
|
2023-05-17 06:46:58 -06:00
|
|
|
|
2023-05-14 01:02:51 -06:00
|
|
|
if (!commentBefore && !commentAfter) return;
|
2023-05-17 06:46:58 -06:00
|
|
|
|
2023-05-14 01:02:51 -06:00
|
|
|
var span = null;
|
|
|
|
if (div.classList.contains('gradio-checkbox')) span = div.querySelector('label span');
|
2023-05-14 02:04:21 -06:00
|
|
|
else if (div.classList.contains('gradio-checkboxgroup')) span = div.querySelector('span').firstChild;
|
|
|
|
else if (div.classList.contains('gradio-radio')) span = div.querySelector('span').firstChild;
|
2023-05-14 01:02:51 -06:00
|
|
|
else span = div.querySelector('label span').firstChild;
|
2023-05-17 06:46:58 -06:00
|
|
|
|
2023-05-14 01:02:51 -06:00
|
|
|
if (!span) return;
|
2023-05-17 06:46:58 -06:00
|
|
|
|
2023-05-14 01:02:51 -06:00
|
|
|
if (commentBefore) {
|
|
|
|
var comment = document.createElement('DIV');
|
|
|
|
comment.className = 'settings-comment';
|
|
|
|
comment.innerHTML = commentBefore;
|
|
|
|
span.parentElement.insertBefore(document.createTextNode('\xa0'), span);
|
|
|
|
span.parentElement.insertBefore(comment, span);
|
|
|
|
span.parentElement.insertBefore(document.createTextNode('\xa0'), span);
|
|
|
|
}
|
|
|
|
if (commentAfter) {
|
2023-05-18 00:59:10 -06:00
|
|
|
comment = document.createElement('DIV');
|
2023-05-14 01:02:51 -06:00
|
|
|
comment.className = 'settings-comment';
|
|
|
|
comment.innerHTML = commentAfter;
|
|
|
|
span.parentElement.insertBefore(comment, span.nextSibling);
|
|
|
|
span.parentElement.insertBefore(document.createTextNode('\xa0'), span.nextSibling);
|
|
|
|
}
|
|
|
|
});
|
2023-05-08 07:46:35 -06:00
|
|
|
});
|
2023-05-17 06:46:58 -06:00
|
|
|
|
2023-05-14 01:02:51 -06:00
|
|
|
function settingsHintsShowQuicksettings() {
|
|
|
|
requestGet("./internal/quicksettings-hint", {}, function(data) {
|
|
|
|
var table = document.createElement('table');
|
2023-05-20 15:41:41 -06:00
|
|
|
table.className = 'popup-table';
|
2023-05-17 06:46:58 -06:00
|
|
|
|
2023-05-14 01:02:51 -06:00
|
|
|
data.forEach(function(obj) {
|
|
|
|
var tr = document.createElement('tr');
|
|
|
|
var td = document.createElement('td');
|
|
|
|
td.textContent = obj.name;
|
|
|
|
tr.appendChild(td);
|
2023-05-17 06:46:58 -06:00
|
|
|
|
2023-05-18 00:59:10 -06:00
|
|
|
td = document.createElement('td');
|
2023-05-14 01:02:51 -06:00
|
|
|
td.textContent = obj.label;
|
|
|
|
tr.appendChild(td);
|
2023-05-17 06:46:58 -06:00
|
|
|
|
2023-05-14 01:02:51 -06:00
|
|
|
table.appendChild(tr);
|
|
|
|
});
|
2023-05-17 06:46:58 -06:00
|
|
|
|
2023-05-14 01:02:51 -06:00
|
|
|
popup(table);
|
|
|
|
});
|
|
|
|
}
|