Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
angular
twitter-archive
Commits
94c3e23b
Commit
94c3e23b
authored
Feb 10, 2019
by
Zéfling
🎨
Browse files
Fix calendar and add links
parent
49bb19eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/app/tweets/tweets-calendar.component.html
View file @
94c3e23b
...
...
@@ -44,8 +44,9 @@
<div
*ngIf=
"month || search.active"
class=
"tweets"
>
<section
*ngFor=
"let tweet of (!search.active ? month.tweets : search.tweets)"
class=
"tweet"
[class.retweet]=
""
>
[class.tweet]=
"true"
[class.retweet]=
"false"
[id]=
"tweet.id"
>
<div
class=
"tweet-infos"
>
<a
href=
"https://twitter.com/{{tweet.user_screen_name}}"
>
{{tweet.user_name}}
</a>
<time
class=
"tweet-date"
>
{{tweet.created_date | date:'yyyy-MM-dd HH:mm:ss'}}
</time>
...
...
@@ -105,7 +106,14 @@
[class.current]=
"day.current"
[class.with-tweets]=
"day.tweets"
[title]=
"day.title"
>
{{day.date}}
<ng-container
*ngIf=
"day.id; else noLink"
>
<a
[href]=
"'#'+day.id"
>
{{day.date}}
</a>
</ng-container>
<ng-template
#noLink
>
{{day.date}}
</ng-template>
</td>
</tr>
</table>
...
...
src/app/tweets/tweets-calendar.component.scss
View file @
94c3e23b
...
...
@@ -182,6 +182,8 @@
table
{
width
:
100%
;
text-align
:
center
;
position
:
sticky
;
top
:
0
;
}
th
{
...
...
src/app/tweets/tweets-calendar.component.ts
View file @
94c3e23b
...
...
@@ -97,7 +97,6 @@ export class TweetsCalendarComponent implements OnInit, OnDestroy {
const
date
=
new
Date
(
`
${
month
.
year
}
-
${
month
.
month
+
1
<
10
?
'
0
'
:
''
}${
month
.
month
+
1
}
-01`
);
date
.
setDate
(
date
.
getDate
()
-
this
.
mountCalandarGetDay
(
date
)
+
1
);
console
.
log
(
'
month.month
'
,
month
.
month
,
(
month
.
month
+
1
)
%
12
);
while
(
(
date
.
getMonth
()
!==
(
month
.
month
+
1
)
%
12
)
||
(
date
.
getMonth
()
===
(
month
.
month
+
1
)
%
12
&&
this
.
mountCalandarGetDay
(
date
)
-
1
)
...
...
@@ -112,13 +111,19 @@ export class TweetsCalendarComponent implements OnInit, OnDestroy {
}
let
tweets
=
0
;
let
id
;
const
current
=
date
.
getMonth
()
===
month
.
month
;
const
dateYear
=
date
[
'
_getDayOfYear
'
]();
if
(
current
)
{
const
list
=
this
.
month
.
tweets
.
filter
(
t
=>
t
.
created_date
[
'
_getDayOfYear
'
]()
===
dateYear
);
tweets
=
list
?
list
.
length
:
0
;
if
(
list
&&
list
.
length
)
{
list
.
sort
((
d1
,
d2
)
=>
d2
.
created_date
.
getTime
()
-
d1
.
created_date
.
getTime
());
id
=
list
[
0
].
id
;
tweets
=
list
.
length
;
}
}
this
.
calendar
[
week
].
push
({
id
:
id
,
current
:
current
,
date
:
`
${
date
.
getDate
()}
`
,
tweets
:
tweets
>
0
,
...
...
@@ -128,7 +133,6 @@ export class TweetsCalendarComponent implements OnInit, OnDestroy {
date
.
setDate
(
date
.
getDate
()
+
1
);
}
console
.
log
(
this
.
calendar
);
}
mountCalandarGetDay
(
date
:
Date
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment