scheduler implementation part/3; do not allow start = end; allow start < end
This commit is contained in:
parent
c2f993db27
commit
52ae781960
|
@ -713,7 +713,10 @@
|
||||||
"scheduleButtonActive": {
|
"scheduleButtonActive": {
|
||||||
"message": "Scheduled"
|
"message": "Scheduled"
|
||||||
},
|
},
|
||||||
"scheduleMSG": {
|
"scheduleOneEntry": {
|
||||||
"message": "Either clear both start and end values to disable the schedule or set both to enable it"
|
"message": "Either clear both start and end values to disable the schedule or set both to enable it"
|
||||||
|
},
|
||||||
|
"scheduleEqualEntries": {
|
||||||
|
"message": "Start and end times cannot be equal"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ schedule.execute = (name, request) => {
|
||||||
chrome.alarms.create(name, {when});
|
chrome.alarms.create(name, {when});
|
||||||
getStylesSafe({id: request.id}).then(([style]) => {
|
getStylesSafe({id: request.id}).then(([style]) => {
|
||||||
if (style) {
|
if (style) {
|
||||||
const enabled = start <= 0 && end > 0;
|
const enabled = (start <= 0 && end > 0) || (start > end && start * end > 0) ;
|
||||||
console.log(`style with id = ${style.id}; enabled = `, enabled);
|
console.log(`style with id = ${style.id}; enabled = `, enabled);
|
||||||
|
|
||||||
saveStyleSafe({
|
saveStyleSafe({
|
||||||
|
|
|
@ -36,10 +36,14 @@ document.addEventListener('click', e => {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 1: // when only start or end value is set; display an alert
|
case 1: // when only start or end value is set; display an alert
|
||||||
window.alert(t('scheduleMSG'));
|
window.alert(t('scheduleOneEntry'));
|
||||||
[start, end].filter(o => !o.value).forEach(o => o.focus());
|
[start, end].filter(o => !o.value).forEach(o => o.focus());
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
if (start.value === end.value) {
|
||||||
|
window.alert(t('scheduleEqualEntries'));
|
||||||
|
return start.focus();
|
||||||
|
}
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
method: 'schedule',
|
method: 'schedule',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user