Skip to content

Commit fa935c6

Browse files
committed
Cleaned up files
1 parent 3c1a233 commit fa935c6

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

src/bubble.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ export default class Bubble {
1111
};
1212
}
1313

14+
// End returns the Bubble's end date object
15+
End() {
16+
return this.date.end;
17+
}
18+
1419
// Label returns the Bubble's label text
1520
Label() {
1621
return this.label;
@@ -20,9 +25,4 @@ export default class Bubble {
2025
Start() {
2126
return this.date.start;
2227
}
23-
24-
// End returns the Bubble's end date object
25-
End() {
26-
return this.date.end;
27-
}
2828
}

src/list.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,6 @@ export default class List {
1717
this.storage.sort(this.sorter)
1818
}
1919

20-
// Next increase the position pointer and return the current element
21-
Next() {
22-
this.position++;
23-
24-
if (this.position > this.storage.length) {
25-
return null;
26-
}
27-
28-
return this.storage[this.position-1];
29-
}
30-
3120
// Add can receive one or multiple parameters which are added to the List
3221
Add() {
3322
for (var i = 0, m = arguments.length; i < m; i++) {
@@ -37,28 +26,39 @@ export default class List {
3726
this.sort();
3827
}
3928

40-
// Walk is an alias for forEach
41-
Walk(func) {
42-
return this.storage.forEach(func);
43-
}
44-
4529
// First returns the first item of the List
4630
First() {
4731
return this.storage[0]
4832
}
4933

34+
// Get returns all items in the List
35+
Get() {
36+
return this.storage;
37+
}
38+
5039
// Last returns the last item of the List
5140
Last() {
5241
return this.storage[this.Size()-1]
5342
}
5443

55-
// Get returns all items in the List
56-
Get() {
57-
return this.storage;
44+
// Next increase the position pointer and return the current element
45+
Next() {
46+
this.position++;
47+
48+
if (this.position > this.storage.length) {
49+
return null;
50+
}
51+
52+
return this.storage[this.position-1];
5853
}
5954

6055
// Size returns the length of the List
6156
Size() {
6257
return this.storage.length;
6358
}
59+
60+
// Walk is an alias for forEach
61+
Walk(func) {
62+
return this.storage.forEach(func);
63+
}
6464
}

src/main.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,29 @@ export default class Timesheet {
77
this.list = p.parse(html)
88
}
99

10-
Start() {
11-
var start = null;
10+
// End returns the last end date of all bubbles
11+
End() {
12+
var end = null;
1213

1314
this.list.Walk((item) => {
14-
if (start === null || item.Start() < start) {
15-
start = item.Start();
15+
if (end === null || item.End() > end) {
16+
end = item.End();
1617
}
1718
});
1819

19-
return start;
20+
return end;
2021
}
2122

22-
End() {
23-
var end = null;
23+
// Start returns the earliest start date of all bubbles
24+
Start() {
25+
var start = null;
2426

2527
this.list.Walk((item) => {
26-
if (end === null || item.End() > end) {
27-
end = item.End();
28+
if (start === null || item.Start() < start) {
29+
start = item.Start();
2830
}
2931
});
3032

31-
return end;
33+
return start;
3234
}
3335
}

0 commit comments

Comments
 (0)