warning spam threshold too low added. see #231

This commit is contained in:
mic 2025-02-14 22:20:36 +01:00
parent 720f810533
commit f823d5c4b2
4 changed files with 35 additions and 1 deletions

View file

@ -1098,5 +1098,13 @@
"prefs_OptionText_spamfilter_threshold_Info": {
"message": "If the value returned by the AI is above this threshold, the email will be moved to the spam folder.",
"description": ""
},
"spam_threshold_too_low": {
"message": "The spam threshold is too low! You will likely mark too much mails as spam!",
"description": ""
},
"spam_threshold_zero": {
"message": "The spam threshold is zero! You will mark all mails as spam!",
"description": ""
}
}

View file

@ -91,6 +91,14 @@ table#miczPrefs tr:last-child td {
color: red;
}
#spam_threshold_too_low{
display: none;
color:red;
font-weight: bold;
font-size: 1.1em;
margin-left: 10px;
}
@media (prefers-color-scheme: dark) {
body {

View file

@ -17,7 +17,7 @@
<td><span>__MSG_prefs_OptionText_spamfilter_threshold__</span></td>
<td>
<label>
<input type="number" id="spamfilter_threshold" name="spamfilter_threshold" class="option-input" />
<input type="number" id="spamfilter_threshold" name="spamfilter_threshold" min="0" max="100" class="option-input" /><span id="spam_threshold_too_low">__MSG_spam_trhreshold_too_low__</span>
<br>__MSG_prefs_OptionText_spamfilter_threshold_Info__
</label>
</td>

View file

@ -34,6 +34,9 @@ document.addEventListener('DOMContentLoaded', async () => {
element.addEventListener("change", saveOptions);
});
document.getElementById("spamfilter_threshold").addEventListener("input", check_spamfilter_threshold);
check_spamfilter_threshold({target: document.getElementById("spamfilter_threshold")});
let spamfilter_textarea = document.getElementById('spamfilter_prompt_text');
let spamfilter_save_btn = document.getElementById('btn_save_prompt');
let spamfilter_reset_btn = document.getElementById('btn_reset_prompt');
@ -77,6 +80,21 @@ document.addEventListener('DOMContentLoaded', async () => {
});
function check_spamfilter_threshold(event) {
let spam_threshold_too_low = document.getElementById("spam_threshold_too_low");
if(event.target.value < 50){
spam_threshold_too_low.style.display = "inline";
if(event.target.value == 0){
spam_threshold_too_low.textContent = browser.i18n.getMessage('spam_threshold_zero');
spam_threshold_too_low.style.fontSize = "1.5em";
}else{
spam_threshold_too_low.textContent = browser.i18n.getMessage('spam_threshold_too_low');
spam_threshold_too_low.style.fontSize = "1.1em";
}
}else{
spam_threshold_too_low.style.display = "none";
}
}
// Methods to manage options, derived from: /options/mzta-options.js