abstract class Pioneer { public details : Structure . Person ; public show ( ) { $ . get ( "/static/templates/person.mst" , ( template ) => { let rendered = Mustache . render ( template , { person : this . details , years : this . years ( ) , remainingAchievements : ( ) => { return this . details . total_achievements - this . details . achievements . length ; } , parseDescription : Helpers . parseDescription , rating : Helpers . rating , flag : this . flagPath ( ) } ) ; let pioneer = $ ( "div#pioneer" ) ; $ ( "div#pioneer_overlay" ) . html ( rendered ) ; pioneer . show ( ) ; pioneer . find ( "a.all_achievements" ) . click ( ( e ) => { e . preventDefault ( ) ; this . allAchievements ( ) ; } ) ; pioneer . on ( "click" , "a.close" , ( e ) => { e . preventDefault ( ) ; this . close ( ) ; } ) ; $ ( document ) . on ( "keyup" , ( e ) => { if ( e . keyCode === 27 ) { this . close ( ) ; } } ) ; } ) ; } public close ( ) { $ ( document ) . off ( "keyup" ) ; $ ( "div#pioneer" ) . off ( "click" , "a.close" ) . hide ( ) ; } public allAchievements ( ) { $ . get ( `/people/${ this . details . id }/achievements` , ( resp ) => { $ . get ( "/static/templates/achievements.mst" , ( template ) => { let rendered = Mustache . render ( template , { achievements : resp . achievements , rating : Helpers . rating , parseDescription : Helpers . parseDescription } ) ; $ ( "div#pioneer_overlay ul.person_achievements" ) . html ( rendered ) ; $ ( "div#pioneer_overlay a.all_achievements" ) . hide ( ) ; } ) ; } , "json" ) ; } private years ( ) { if ( this . details . yod ) { return `${ this . details . yob } - ${ this . details . yod || "" }` ; } else { return `Born in ${ this . details . yob }.` ; } } public flagPath ( ) { return Helpers . imageSource ( "flags" , `${ this . details . country . toLowerCase ( ) . replace ( /\W/g , "_" ) }.png` ) ; } }