Skip to content

Commit ab109d6

Browse files
committed
Counting time between 2 hours
1 parent 3819c85 commit ab109d6

File tree

3 files changed

+42
-19
lines changed

3 files changed

+42
-19
lines changed

src/assets/css/main.css

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,14 @@ body {
1919
padding: 0;
2020
margin: 0;
2121
}
22-
.no-data {
23-
text-align: center;
24-
font-size: 16px;
25-
font-weight: 600;
26-
margin-top: 30%;
27-
}
2822
.tabs {
2923
}
3024
.tabs input[name='tab-control'] {
3125
display: none;
3226
}
3327
.tabs .content section h2,
3428
.tabs ul li label {
29+
3530
font-size: 15px;
3631
color: #428bff;
3732
}

src/components/TimeIntervalChart.vue

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,44 @@ const hours: number[] = [];
5151
5252
isLoaded.value = false;
5353
54-
function convertTimIntervalToObject(timeInterval: string, domain: string): DomainsInterval | null {
54+
function convertTimIntervalToObject(
55+
timeInterval: string,
56+
domain: string,
57+
): DomainsInterval[] | null {
5558
const array = timeInterval.split('-');
5659
const time1 = array[0].split(':');
5760
const time2 = array[1].split(':');
58-
//добавить подсчет, если в разных часах интервал
5961
if (time1[0] == time2[0]) {
60-
return {
61-
hour: Number(time1[0]),
62+
return [
63+
{
64+
hour: Number(time1[0]),
65+
summary:
66+
convertStringTimeIntervalToSeconds(array[1]) -
67+
convertStringTimeIntervalToSeconds(array[0]),
68+
domain: domain,
69+
},
70+
];
71+
} else {
72+
const arr = [];
73+
const firstPart1 = array[0];
74+
const firstPart2 = `${time1[0]}:59:59`;
75+
arr.push({
76+
hour: Number(firstPart1[0]),
6277
summary:
63-
convertStringTimeIntervalToSeconds(array[1]) - convertStringTimeIntervalToSeconds(array[0]),
78+
convertStringTimeIntervalToSeconds(firstPart2) -
79+
convertStringTimeIntervalToSeconds(firstPart1),
6480
domain: domain,
65-
};
81+
});
82+
const secondPart1 = `${time2[0]}:00:00`;
83+
const secondPart2 = `${time2[0]}:${time2[1]}:${time2[2]}`;
84+
arr.push({
85+
hour: Number(secondPart1[0]),
86+
summary:
87+
convertStringTimeIntervalToSeconds(secondPart2) -
88+
convertStringTimeIntervalToSeconds(secondPart1),
89+
domain: domain,
90+
});
91+
return arr;
6692
}
6793
return null;
6894
}
@@ -77,12 +103,14 @@ function fillData(timeIntervalList: TimeInterval[]) {
77103
intervals.forEach(array => {
78104
const i = array.intervals;
79105
i.forEach(time => {
80-
const obj = convertTimIntervalToObject(time, domain);
81-
if (obj != null) {
82-
const existDomain = intervalsObj.find(x => x.domain == domain && x.hour == obj.hour);
83-
if (existDomain != undefined) {
84-
existDomain.summary += obj.summary;
85-
} else intervalsObj.push(obj);
106+
const objs = convertTimIntervalToObject(time, domain);
107+
if (objs != null && objs.length > 0) {
108+
objs.forEach(obj => {
109+
const existDomain = intervalsObj.find(x => x.domain == domain && x.hour == obj.hour);
110+
if (existDomain != undefined) {
111+
existDomain.summary += obj.summary;
112+
} else intervalsObj.push(obj);
113+
});
86114
}
87115
});
88116
});

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "__MSG_extName__",
44
"short_name": "Web Tracker",
5-
"version": "2.0.0",
5+
"version": "2.0.2",
66
"description": "__MSG_extDescription__",
77
"options_page": "src/dashboard.html",
88
"default_locale": "en",

0 commit comments

Comments
 (0)