File tree Expand file tree Collapse file tree 10 files changed +188
-59
lines changed Expand file tree Collapse file tree 10 files changed +188
-59
lines changed Original file line number Diff line number Diff line change
1
+ .vote-count {
2
+ padding-bottom : 6px ;
3
+ font-size : smaller;
4
+ }
5
+
6
+ .empty-circle {
7
+ background-color : transparent;
8
+ border-radius : 50% ;
9
+ border-style : solid;
10
+ border-width : 2px ;
11
+ display : block;
12
+ float : left;
13
+ height : 10px ;
14
+ left : 5px ;
15
+ position : relative;
16
+ top : 8px ;
17
+ width : 10px ;
18
+ }
19
+
20
+ .filled-circle {
21
+ border-radius : 50% ;
22
+ background-color : black;
23
+ float : left;
24
+ height : 6px ;
25
+ left : 2px ;
26
+ top : 2px ;
27
+ position : relative;
28
+ width : 6px ;
29
+ }
30
+
31
+ .option-text {
32
+ border-radius : 5px ;
33
+ border-style : solid;
34
+ border-width : 2px ;
35
+ padding : 5px 25px ;
36
+ }
37
+
38
+ .option {
39
+ padding-bottom : 10px ;
40
+ }
41
+
42
+ .correct-option {
43
+ background-color : # 78da71 ;
44
+ }
45
+
46
+ .incorrect-option {
47
+ background-color : # dd4e4e ;
48
+ }
49
+
50
+ .reveal-answer {
51
+ text-align : center;
52
+ cursor : pointer;
53
+ }
54
+
55
+ .reveal-answer : hover > .option-text , .reveal-answer : focus > .option-text {
56
+ background-color : var (--side-nav-hover-color )
57
+ }
Original file line number Diff line number Diff line change
1
+ import { defineComponent } from 'vue'
2
+ import { formatNumber } from '../../helpers/utils'
3
+
4
+ export default defineComponent ( {
5
+ name : 'FtCommunityPoll' ,
6
+ props : {
7
+ data : {
8
+ type : Object ,
9
+ required : true
10
+ }
11
+ } ,
12
+ data : function ( ) {
13
+ return {
14
+ revealAnswer : false
15
+ }
16
+ } ,
17
+ computed : {
18
+ formattedVotes : function ( ) {
19
+ return formatNumber ( this . data . totalVotes )
20
+ } ,
21
+ }
22
+ } )
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" poll" >
3
+ <div
4
+ class =" vote-count"
5
+ >
6
+ <!-- Format the votes to be split by commas ie. 1000 -> 1,000 -->
7
+ {{ $t('Channel.Community.votes', {votes: formattedVotes}) }}
8
+ </div >
9
+ <div
10
+ v-for =" (choice, index) in data.content"
11
+ :key =" index"
12
+ >
13
+ <div
14
+ v-if =" data.type === 'quiz'"
15
+ class =" option quiz-option"
16
+ >
17
+ <span class =" empty-circle" >
18
+ <span :class =" revealAnswer && choice.isCorrect ? 'filled-circle' : ''" />
19
+ </span >
20
+ <div
21
+ class =" option-text"
22
+ :class =" revealAnswer && choice.isCorrect ? 'correct-option' : ''"
23
+ >
24
+ {{ choice.text }}
25
+ </div >
26
+ </div >
27
+ <div
28
+ v-else
29
+ class =" option poll-option"
30
+ >
31
+ <span class =" empty-circle" />
32
+ <div class =" option-text" >
33
+ {{ choice.text }}
34
+ </div >
35
+ </div >
36
+ </div >
37
+ <div
38
+ v-if =" data.type === 'quiz'"
39
+ class =" reveal-answer option"
40
+ tabindex =" 0"
41
+ role =" button"
42
+ @click =" revealAnswer = !revealAnswer"
43
+ @keydown.enter.prevent =" revealAnswer = !revealAnswer"
44
+ @keydown.space.prevent =" revealAnswer = !revealAnswer"
45
+ >
46
+ <div
47
+ v-if =" !revealAnswer"
48
+ class =" option-text"
49
+ >
50
+ <font-awesome-icon :icon =" ['fas', 'eye']" /> {{ $t('Channel.Community.Reveal Answers') }}
51
+ </div >
52
+ <div
53
+ v-else
54
+ class =" option-text"
55
+ >
56
+ <font-awesome-icon :icon =" ['fas', 'eye-slash']" /> {{ $t('Channel.Community.Hide Answers') }}
57
+ </div >
58
+ </div >
59
+ </div >
60
+ </template >
61
+
62
+ <script src="./ft-community-poll.js " />
63
+ <style scoped src="./ft-community-poll.css " />
Original file line number Diff line number Diff line change 1
1
import { defineComponent } from 'vue'
2
2
import FtListVideo from '../ft-list-video/ft-list-video.vue'
3
3
import FtListPlaylist from '../ft-list-playlist/ft-list-playlist.vue'
4
+ import FtCommunityPoll from '../ft-community-poll/ft-community-poll.vue'
4
5
5
6
import autolinker from 'autolinker'
6
7
import VueTinySlider from 'vue-tiny-slider'
@@ -15,6 +16,7 @@ export default defineComponent({
15
16
components : {
16
17
'ft-list-playlist' : FtListPlaylist ,
17
18
'ft-list-video' : FtListVideo ,
19
+ 'ft-community-poll' : FtCommunityPoll ,
18
20
'tiny-slider' : VueTinySlider
19
21
} ,
20
22
props : {
@@ -37,7 +39,7 @@ export default defineComponent({
37
39
postContent : '' ,
38
40
commentCount : '' ,
39
41
isLoading : true ,
40
- author : ''
42
+ author : '' ,
41
43
}
42
44
} ,
43
45
computed : {
Original file line number Diff line number Diff line change 13
13
box-sizing : border-box ;
14
14
}
15
15
16
- .circle {
17
- background-color : transparent ;
18
- border-radius : 50% ;
19
- border-style : solid ;
20
- border-width : 2px ;
21
- display : block ;
22
- float : left ;
23
- height : 10px ;
24
- left : 5px ;
25
- position : relative ;
26
- top : 8px ;
27
- width : 10px ;
28
- }
29
-
30
- .poll-text {
31
- border-radius : 5px ;
32
- border-style : solid ;
33
- border-width : 2px ;
34
- padding : 5px 25px ;
35
- }
36
-
37
- .poll-option {
38
- padding-bottom : 10px ;
39
- }
40
-
41
16
.communityImage {
42
17
height : 100% ;
43
18
width : 100% ;
Original file line number Diff line number Diff line change 60
60
/>
61
61
</div >
62
62
<div
63
- v-if =" type === 'poll'"
63
+ v-if =" type === 'poll' || type === 'quiz' "
64
64
>
65
- <div
66
- class =" poll-count"
67
- >
68
- {{ postContent.totalVotes }}
69
- </div >
70
- <div
71
- v-for =" (poll, index) in postContent.content"
72
- :key =" index"
73
- >
74
- <div
75
- class =" poll-option"
76
- >
77
- <span
78
- class =" circle"
79
- />
80
- <div
81
- class =" poll-text"
82
- >
83
- <!-- <img
84
- v-if="poll.image != null && poll.image.length >0"
85
- :src="getBestQualityImage(poll.image)"
86
- class="poll-image"
87
- alt=""
88
- > -->
89
- {{ poll.text }}
90
- </div >
91
- </div >
92
- </div >
65
+ <ft-community-poll :data =" postContent" />
93
66
</div >
94
67
<div
95
68
v-if =" type === 'playlist'"
Original file line number Diff line number Diff line change @@ -257,14 +257,32 @@ function parseInvidiousCommunityAttachments(data) {
257
257
}
258
258
}
259
259
260
+ if ( data . type === 'quiz' ) {
261
+ return {
262
+ type : 'quiz' ,
263
+ totalVotes : data . totalVotes ?? 0 ,
264
+ content : data . choices . map ( choice => {
265
+ return {
266
+ text : choice . text ,
267
+ isCorrect : choice . isCorrect ,
268
+ image : choice . image ?. map ( thumbnail => {
269
+ thumbnail . url = youtubeImageUrlToInvidious ( thumbnail . url )
270
+ return thumbnail
271
+ } )
272
+ }
273
+ } )
274
+ }
275
+ }
276
+
260
277
if ( data . type === 'playlist' ) {
261
278
return {
262
279
type : data . type ,
263
280
content : data
264
281
}
265
282
}
266
283
267
- console . error ( 'New Invidious Community Post Type: ' + data . type )
284
+ console . error ( `Unknown Invidious community post type: ${ data . type } ` )
285
+ console . error ( data )
268
286
}
269
287
270
288
/**
Original file line number Diff line number Diff line change @@ -916,17 +916,29 @@ function parseLocalAttachment(attachment) {
916
916
} else if ( attachment . type === 'Poll' ) {
917
917
return {
918
918
type : 'poll' ,
919
- totalVotes : attachment . total_votes ?? 0 ,
919
+ totalVotes : parseLocalSubscriberCount ( attachment . total_votes . text ) ?? 0 ,
920
920
content : attachment . choices . map ( choice => {
921
921
return {
922
922
text : choice . text . text ,
923
923
image : choice . image
924
924
}
925
925
} )
926
926
}
927
+ } else if ( attachment . type === 'Quiz' ) {
928
+ return {
929
+ type : 'quiz' ,
930
+ totalVotes : parseLocalSubscriberCount ( attachment . total_votes . text ) ?? 0 ,
931
+ content : Object . values ( attachment . choices ) . map ( choice => {
932
+ return {
933
+ text : choice . text . text ,
934
+ isCorrect : choice . is_correct ,
935
+ image : choice . image
936
+ }
937
+ } )
938
+ }
927
939
} else {
940
+ console . error ( `Unknown Local community post type: ${ attachment . type } ` )
928
941
console . error ( attachment )
929
- console . error ( 'unknown type' )
930
942
}
931
943
}
932
944
Original file line number Diff line number Diff line change @@ -56,7 +56,9 @@ import {
56
56
faThumbtack ,
57
57
faTimes ,
58
58
faTimesCircle ,
59
- faUsers
59
+ faUsers ,
60
+ faEye ,
61
+ faEyeSlash ,
60
62
} from '@fortawesome/free-solid-svg-icons'
61
63
import {
62
64
faBitcoin ,
@@ -123,6 +125,8 @@ library.add(
123
125
faTimes ,
124
126
faTimesCircle ,
125
127
faUsers ,
128
+ faEye ,
129
+ faEyeSlash ,
126
130
127
131
// brand icons
128
132
faGithub ,
Original file line number Diff line number Diff line change @@ -590,6 +590,9 @@ Channel:
590
590
Community :
591
591
Community : Community
592
592
This channel currently does not have any posts : This channel currently does not have any posts
593
+ votes : ' {votes} votes'
594
+ Reveal Answers : Reveal Answers
595
+ Hide Answers : Hide Answers
593
596
Video :
594
597
Mark As Watched : Mark As Watched
595
598
Remove From History : Remove From History
You can’t perform that action at this time.
0 commit comments