Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix custom time frame bug #46

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 25 additions & 26 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
{
"manifest_version": 2,
"name": "Screentime",
"description": "To keep track and manage your time on sites that reduce productivity. You can set the number of minutes you want and time frames",
"short_name": "screentime",
"version": "5.0.4",
"browser_action": {
"default_popup": "index.html",
"default_icon" : "images/icon_128.png"
},
"icons": {
"16": "images/icon_16.png",
"48": "images/icon_48.png",
"128": "images/icon_128.png"
},
"background": {
"scripts": [
"js/background/main.js"
]
},
"permissions": [
"storage",
"notifications",
"tabs"
],
"content_security_policy": "script-src 'self'; object-src 'self'"
"manifest_version": 3,
"name": "Screentime",
"description": "To keep track and manage your time on sites that reduce productivity. You can set the number of minutes you want and time frames",
"short_name": "screentime",
"version": "5.0.5",
"icons": {
"16": "images/icon_16.png",
"48": "images/icon_48.png",
"128": "images/icon_128.png"
},
"background": {
"service_worker": "js/background/main.js"
},
"permissions": [
"storage",
"notifications",
"tabs"
],
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
},
"action": {
"default_popup": "index.html",
"default_icon": "images/icon_128.png"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "screentime",
"version": "5.0.2",
"version": "5.0.5",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/js/dev_storage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const data = {
timer: {
'2021-10-03': {
'2023-09-27': {
instagram: 2000,
youtube: 2240,
twitter: 2000,
Expand Down
5 changes: 2 additions & 3 deletions src/assets/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default {
notify(message, action) {
const notificationObject = {
type: 'basic',
iconUrl: 'images/icon_128.png',
iconUrl: chrome.runtime.getURL('images/icon_128.png'),
title: 'SCREENTIME',
message
};
Expand All @@ -146,8 +146,7 @@ export default {
notificationObject.requireInteraction = true;
}
// eslint-disable-next-line
chrome.notifications.create(notificationObject, () => {
});
chrome.notifications.create(notificationObject);
},

saveConfiguration(key, data) {
Expand Down
76 changes: 48 additions & 28 deletions src/components/Advanced/TimeBlocks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,41 @@
<div
v-for="(eachTimeBlock, index) in timeBlocks[chosenDay]"
:key="index"
class="time-row box between"
>
<div class="input-field">
<label>Time from</label>
<div class="box between">
<number-input v-model="eachTimeBlock.from.hour" :max="23" class="number-input" />
<number-input
v-model="eachTimeBlock.from.minute"
:max="59"
class="number-input"
/>
<div class="time-row box between">
<div class="input-field">
<label>Time from</label>
<div class="box between">
<number-input v-model="eachTimeBlock.from.hour" :max="23" class="number-input" />
<number-input
v-model="eachTimeBlock.from.minute"
:max="59"
class="number-input"
/>
</div>
</div>
</div>
<div class="input-field">
<label>Time to</label>
<div class="box between">
<number-input v-model="eachTimeBlock.to.hour" :max="23" class="number-input" />
<number-input
v-model="eachTimeBlock.to.minute"
:max="59"
class="number-input"
/>
<div class="input-field">
<label>Time to</label>
<div class="box between">
<number-input v-model="eachTimeBlock.to.hour" :max="23" class="number-input" />
<number-input
v-model="eachTimeBlock.to.minute"
:max="59"
class="number-input"
/>
</div>
</div>
<button class="btn delete-block" @click="deleteBlock(chosenDay, index)">
<close-icon />
</button>
</div>
<button class="btn delete-block" @click="deleteBlock(chosenDay, index)">
<close-icon />
</button>
<span
v-if="!isTimeFrameValid({
from: `${eachTimeBlock.from.hour}:${eachTimeBlock.from.minute}`,
to: `${eachTimeBlock.to.hour}:${eachTimeBlock.to.minute}`
})"
class="text-error time-frame-error"
>*Invalid time frame</span>
</div>
<div class="add-time-block">
<button class="btn" @click="addTimeBlock(chosenDay)">
Expand Down Expand Up @@ -155,12 +163,20 @@ export default {
deleteBlock(day, index) {
this.timeBlocks[day].splice(index, 1);
},
formatTime(timeString) {
let [hour, minute] = timeString.split(':');
hour = hour.length === 1 ? `0${hour}` : hour;
minute = minute.length === 1 ? `0${minute}` : minute;
return `${hour}:${minute}`;
},
isTimeFrameValid(timeframe) {
return timeframe.to
&& timeframe.from
&& timeframe.from >= '00:00'
&& timeframe.to <= '23:59'
&& timeframe.to > timeframe.from;
const to = this.formatTime(timeframe.to);
const from = this.formatTime(timeframe.from);
return to
&& from
&& from >= '00:00'
&& to <= '23:59'
&& to > from;
},
saveTimeBlocks() {
const preparedTimeBlocks = {};
Expand Down Expand Up @@ -278,4 +294,8 @@ body.dark-mode .time-slots {
body.dark-mode input[type="time"]::-webkit-calendar-picker-indicator {
filter: invert(100%);
}

.time-frame-error {
font-size: 12px;
}
</style>
Loading