@@ -7,14 +7,14 @@ const _ = require('lodash');
77var md = require ( 'markdown-it' ) ( {
88 html : true ,
99 linkify : true ,
10- typographer : true
10+ typographer : true ,
1111} ) ;
1212let talks ;
1313
14- function templateContent ( selector , allIssues , label ) {
14+ function templateContent ( selector , allIssues , label ) {
1515 let issues = allIssues ;
16- if ( label ) {
17- issues = allIssues . filter ( function ( data ) {
16+ if ( label ) {
17+ issues = allIssues . filter ( function ( data ) {
1818 const foundLabel = ! ! data . labels . map ( a => a . name ) . includes ( label ) ;
1919 return foundLabel ;
2020 } ) ;
@@ -27,13 +27,13 @@ function templateContent(selector, allIssues, label){
2727 templateElement . parentNode . appendChild ( element ) ;
2828}
2929
30- function hashChange ( options ) {
30+ function hashChange ( options ) {
3131 const hash = window . location . hash . substring ( 1 ) || 'home' ;
3232 Array . from ( document . querySelectorAll ( '[data-page]' ) ) . forEach ( page => {
3333 const thisHash = page . dataset . page ;
3434 const links = document . querySelectorAll ( `.page-${ thisHash } ` ) ;
35- try {
36- if ( thisHash === hash ) {
35+ try {
36+ if ( thisHash === hash ) {
3737 page . style . display = 'block' ;
3838 links [ 0 ] . className += ' active' ;
3939 links [ 1 ] && ( links [ 1 ] . className += ' active' ) ;
@@ -43,41 +43,39 @@ function hashChange(options){
4343 links [ 1 ] && ( links [ 1 ] . className = links [ 1 ] . className . replace ( / a c t i v e / , '' ) ) ;
4444 }
4545 document . querySelector ( '[data-page=talk-single]' ) . innerHTML = '' ;
46- } catch ( e ) { }
47- if ( options . jump !== false ) document . body . scrollTop = 0 ;
46+ } catch ( e ) { }
47+ if ( options . jump !== false ) document . body . scrollTop = 0 ;
4848 document . body . className = hash ;
49-
5049 } ) ;
5150 const talkId = hash . match ( / ^ t a l k - ( \d + ) $ / ) ;
52- if ( talkId && talkId [ 1 ] && talks ) {
51+ if ( talkId && talkId [ 1 ] && talks ) {
5352 const talk = talks . find ( meetup => meetup . id === talkId [ 1 ] ) ;
54- if ( ! talk ) return ;
53+ if ( ! talk ) return ;
5554 const template = require ( './templates/talk.hbs' ) ;
5655 const page = document . querySelector ( '[data-page=talk-single]' ) ;
5756 page . innerHTML = template ( talk ) ;
5857 page . style . display = 'block' ;
5958 }
6059}
6160
62- function init ( ) {
61+ function init ( ) {
6362 fetch ( config . dataSources . events )
6463 . then ( response => response . json ( ) )
65- . then ( function ( events ) {
64+ . then ( function ( events ) {
6665 const latest = events [ 0 ] ;
6766 latest . dateHuman = dateFns . format ( new Date ( latest . time ) , 'd MMM' ) ;
68- Array . from ( document . querySelectorAll ( '[data-latest]' ) )
69- . forEach ( ( element ) => {
70- const data = _ . get ( latest , element . dataset . latest ) ;
71- const isHtml = element . dataset . html ;
72- if ( data ) element [ isHtml ? 'innerHTML' : 'innerText' ] = data ;
73- } ) ;
67+ Array . from ( document . querySelectorAll ( '[data-latest]' ) ) . forEach ( element => {
68+ const data = _ . get ( latest , element . dataset . latest ) ;
69+ const isHtml = element . dataset . html ;
70+ if ( data ) element [ isHtml ? 'innerHTML' : 'innerText' ] = data ;
71+ } ) ;
7472 } ) ;
7573
7674 fetch ( config . dataSources . githubIssues )
7775 . then ( response => response . json ( ) )
78- . then ( function ( issues ) {
76+ . then ( function ( issues ) {
7977 // render markdown
80- issues = issues . map ( function ( issue ) {
78+ issues = issues . map ( function ( issue ) {
8179 issue . html = md . render ( issue . body ) ;
8280 issue . dateHuman = dateFns . format ( new Date ( issue . updated_at ) , 'd MMM' ) ;
8381 return issue ;
@@ -90,26 +88,25 @@ function init(){
9088 fetch ( config . dataSources . talks )
9189 . then ( response => response . text ( ) )
9290 . then ( tsv => {
93- const twitterData = require ( './data/twitter' ) ;
94- talks = tsvTalks . parseTsv ( tsv , twitterData ) ;
95- talks . reverse ( ) ;
96- const meetups = tsvTalks . getTalksByMeetup ( talks ) ;
97- templateContent ( '#template-talks' , meetups , '' ) ;
98- hashChange ( {
99- jump : false
100- } ) ;
91+ const twitterData = require ( './data/twitter' ) ;
92+ talks = tsvTalks . parseTsv ( tsv , twitterData ) ;
93+ talks . reverse ( ) ;
94+ const meetups = tsvTalks . getTalksByMeetup ( talks ) ;
95+ templateContent ( '#template-talks' , meetups , '' ) ;
96+ hashChange ( {
97+ jump : false ,
98+ } ) ;
10199 } ) ;
102100
103101 const contacts = require ( './data/contact' ) ;
104102 templateContent ( '#template-contact' , contacts , '' ) ;
105103
106104 // initialize semantic ui sidebar
107- $ ( '.ui.sidebar' )
108- . sidebar ( 'attach events' , '.toc.item' ) ;
105+ $ ( '.ui.sidebar' ) . sidebar ( 'attach events' , '.toc.item' ) ;
109106
110107 // set the pages ups
111108 hashChange ( {
112- jump : false
109+ jump : false ,
113110 } ) ;
114111}
115112
0 commit comments