1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 12:50:36 +01:00

Mark default value in drop downs settings

For #696
This commit is contained in:
kkapsner 2024-04-08 00:15:55 +02:00
parent d159769997
commit acce01bfeb
4 changed files with 39 additions and 1 deletions

View File

@ -109,6 +109,11 @@
"description": "" "description": ""
}, },
"labelForDefaultOption": {
"message": " (default)",
"description": ""
},
"group_general": { "group_general": {
"message": "General", "message": "General",
"description": "" "description": ""

View File

@ -51,10 +51,12 @@
const option = document.createElement("option"); const option = document.createElement("option");
if (typeof value === typeof setting.defaultValue){ if (typeof value === typeof setting.defaultValue){
option.value = value; option.value = value;
option.text = extension.getTranslation(setting.name + "_options." + value) || value;
if (setting.defaultValue === value){ if (setting.defaultValue === value){
option.selected = true; option.selected = true;
option.selectedText = option.text;
option.notSelectedText = option.text + extension.getTranslation("labelForDefaultOption");
} }
option.text = extension.getTranslation(setting.name + "_options." + value) || value;
} }
else { else {
option.disabled = true; option.disabled = true;
@ -62,12 +64,26 @@
} }
select.appendChild(option); select.appendChild(option);
}); });
select.update = function(){
Array.from(select.options).forEach(function(option){
if (option.notSelectedText){
option.text = option.notSelectedText;
}
});
const selectedOption = select.options[select.selectedIndex];
if (selectedOption.selectedText){
selectedOption.text = selectedOption.selectedText;
}
};
return select; return select;
} }
const inputTypes = { const inputTypes = {
all: { all: {
updateCallback: function(input, value, defaultValue){ updateCallback: function(input, value, defaultValue){
if (input.update){
input.update();
}
input.classList[value === defaultValue? "remove": "add"]("changed"); input.classList[value === defaultValue? "remove": "add"]("changed");
} }
}, },

View File

@ -5,6 +5,7 @@ Version 1.10.1:
new features: new features:
- added tag search - added tag search
- added :changed tag - added :changed tag
- mark default value in drop downs settings
fixes: fixes:
- lag and functionality loss on google sites - lag and functionality loss on google sites

View File

@ -317,6 +317,22 @@
{ {
"version": "1.10.20240330", "version": "1.10.20240330",
"update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-1.10.20240330.xpi" "update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-1.10.20240330.xpi"
},
{
"version": "1.10.1.20240405",
"update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-1.10.1.20240405.xpi"
},
{
"version": "1.10.20240407",
"update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-1.10.20240407.xpi"
},
{
"version": "1.10.20240407.1",
"update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-1.10.20240407.1.xpi"
},
{
"version": "1.10.20240408",
"update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-1.10.20240408.xpi"
} }
] ]
} }