diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 8a89754f..02ded4d0 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -713,7 +713,10 @@ "scheduleButtonActive": { "message": "Scheduled" }, - "scheduleMSG": { + "scheduleOneEntry": { "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" } } diff --git a/schedule/core.js b/schedule/core.js index 63bf2b56..ba0897ef 100644 --- a/schedule/core.js +++ b/schedule/core.js @@ -76,7 +76,7 @@ schedule.execute = (name, request) => { chrome.alarms.create(name, {when}); getStylesSafe({id: request.id}).then(([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); saveStyleSafe({ diff --git a/schedule/ui.js b/schedule/ui.js index e4ddff08..27c4eebb 100644 --- a/schedule/ui.js +++ b/schedule/ui.js @@ -36,10 +36,14 @@ document.addEventListener('click', e => { }); break; 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()); return; default: + if (start.value === end.value) { + window.alert(t('scheduleEqualEntries')); + return start.focus(); + } chrome.runtime.sendMessage({ method: 'schedule', enabled: true,