4242 <p >Daily</p >
4343 <ul >
4444 <li
45- v-for =" (item, index) in result. timeline"
45+ v-for =" (item, index) in timeline"
4646 :key =" index" >
4747 <span class =" timestamp" >{{ item.timestamp.month }} {{ item.timestamp.date }}, {{ item.timestamp.year }}</span >
4848 <span class =" summary" v-html =" item.summary" />
4949 </li >
5050 </ul >
51+ <div class =" pagination" >
52+ <button
53+ class =" controls prev"
54+ :class =" { 'is-disabled': currentPage <= 1 }"
55+ :disabled =" currentPage <= 1"
56+ @click =" previous" >
57+ <svg xmlns =" http://www.w3.org/2000/svg" x =" 0px" y =" 0px"
58+ width =" 40" height =" 40"
59+ viewBox =" 0 0 172 172"
60+ style =" fill :#000000 ; " ><g fill =" none" fill-rule =" nonzero" stroke =" none" stroke-width =" 1" stroke-linecap =" butt" stroke-linejoin =" miter" stroke-miterlimit =" 10" stroke-dasharray =" " stroke-dashoffset =" 0" font-family =" none" font-weight =" none" font-size =" none" text-anchor =" none" style =" mix-blend-mode : normal " ><path d =" M0,172v-172h172v172z" fill =" none" ></path ><g fill =" #000000" ><path d =" M86,14.33333c-39.5815,0 -71.66667,32.08517 -71.66667,71.66667c0,39.5815 32.08517,71.66667 71.66667,71.66667c39.5815,0 71.66667,-32.08517 71.66667,-71.66667c0,-39.5815 -32.08517,-71.66667 -71.66667,-71.66667zM78.83333,122.34217l-10.75,-10.75l25.59217,-25.59217l-25.59217,-25.59217l10.75,-10.75l36.34217,36.34217z" ></path ></g ></g >
61+ </svg >
62+ </button >
63+ <span >{{ currentPage }} / {{ totalPage }}</span >
64+ <button
65+ class =" controls next"
66+ :class =" { 'is-disabled': currentPage >= totalPage }"
67+ :disabled =" currentPage >= totalPage"
68+ @click =" next" >
69+ <svg xmlns =" http://www.w3.org/2000/svg" x =" 0px" y =" 0px"
70+ width =" 40" height =" 40"
71+ viewBox =" 0 0 172 172"
72+ style =" fill :#000000 ; " ><g fill =" none" fill-rule =" nonzero" stroke =" none" stroke-width =" 1" stroke-linecap =" butt" stroke-linejoin =" miter" stroke-miterlimit =" 10" stroke-dasharray =" " stroke-dashoffset =" 0" font-family =" none" font-weight =" none" font-size =" none" text-anchor =" none" style =" mix-blend-mode : normal " ><path d =" M0,172v-172h172v172z" fill =" none" ></path ><g fill =" #000000" ><path d =" M86,14.33333c-39.5815,0 -71.66667,32.08517 -71.66667,71.66667c0,39.5815 32.08517,71.66667 71.66667,71.66667c39.5815,0 71.66667,-32.08517 71.66667,-71.66667c0,-39.5815 -32.08517,-71.66667 -71.66667,-71.66667zM78.83333,122.34217l-10.75,-10.75l25.59217,-25.59217l-25.59217,-25.59217l10.75,-10.75l36.34217,36.34217z" ></path ></g ></g >
73+ </svg >
74+ </button >
75+ </div >
5176 </div >
5277 </div >
5378 </div >
@@ -102,12 +127,44 @@ export default {
102127 horizontalAlign: ' left'
103128 }
104129 }
130+ },
131+ getTimeline () {
132+ return this .result .timeline
133+ },
134+ totalDaily () {
135+ return this .result .timeline .length
136+ },
137+ totalPage () {
138+ return this .totalDaily / this .perPage
139+ }
140+ },
141+ data () {
142+ return {
143+ perPage: 6 ,
144+ currentPage: 1 ,
145+ timeline: []
105146 }
106147 },
107148 methods: {
108149 onClose () {
109150 this .$emit (' close' )
151+ },
152+ paginate (a , perPage , page ) {
153+ return a .slice (perPage * (page - 1 ), perPage * page)
154+ },
155+ previous () {
156+ if (this .currentPage >= 1 ) {
157+ this .timeline = this .paginate (this .getTimeline , this .perPage , -- this .currentPage )
158+ }
159+ },
160+ next () {
161+ if (this .currentPage <= this .totalDaily ) {
162+ this .timeline = this .paginate (this .getTimeline , this .perPage , ++ this .currentPage )
163+ }
110164 }
165+ },
166+ mounted () {
167+ this .timeline = this .paginate (this .getTimeline , this .perPage , 1 )
111168 }
112169}
113170 </script >
@@ -309,6 +366,41 @@ export default {
309366 font-weight : 700 ;
310367 color : #66a266 ;
311368 }
369+
370+ .pagination {
371+ text-align : center ;
372+
373+ span {
374+ display : inline-block ;
375+ margin : 8px 0 ;
376+ line-height : 40px ;
377+ vertical-align : top ;
378+ }
379+ }
380+
381+ .controls {
382+ border : 0 ;
383+ margin : 8px 4px ;
384+ padding : 0 ;
385+ width : 40px ;
386+ height : 40px ;
387+ display : inline-block ;
388+ vertical-align : top ;
389+ background : none ;
390+ cursor : pointer ;
391+ outline : none ;
392+
393+ & .is-disabled {
394+ opacity : 0.6 ;
395+ }
396+
397+ & .prev {
398+
399+ svg {
400+ transform : rotate (-180deg );
401+ }
402+ }
403+ }
312404 }
313405}
314406 </style >
0 commit comments