11var gui = require ( 'nw.gui' )
22 , moment = require ( 'moment' )
3+ , fs = require ( 'fs' )
4+ , Tail = require ( 'tail' ) . Tail
35
46function startSpinner ( ) { $ ( '#bottom-menu-spinner' ) . fadeIn ( 1500 ) ; }
57function stopSpinner ( ) { $ ( '#bottom-menu-spinner' ) . fadeOut ( 1500 ) ; }
@@ -9,7 +11,7 @@ function pollClipboard() {
911 setTimeout ( function ( ) {
1012 var cb = gui . Clipboard . get ( ) ;
1113 var clipboard = document . getElementById ( 'clipboard' )
12- var event = { 'type' : 'report ' , 'time' : moment ( ) . utc ( ) . format ( 'HH:mm:ss' ) , 'text' : cb . get ( 'text' ) } ;
14+ var event = { 'type' : 'clipboard ' , 'time' : moment ( ) . utc ( ) . format ( 'HH:mm:ss' ) , 'text' : cb . get ( 'text' ) } ;
1315
1416 var renderedEvent = $ ( Templates . event ( event ) )
1517 $ ( '#clipboard' ) . prepend ( renderedEvent ) ;
@@ -19,8 +21,40 @@ function pollClipboard() {
1921 } , 10000 ) ;
2022}
2123
24+ function tailLogs ( ) {
25+ if ( process . platform === 'win32' ) {
26+ var path = '%userprofile%\\documents\\EVE\\logs\\Chatlogs\\'
27+ } else {
28+ var path = '/Users/rcreasey/Library/Application\ Support/EVE\ Online/p_drive/User/My\ Documents/EVE/logs/Chatlogs/'
29+ }
30+
31+ console . log ( path )
32+ var logs = fs . readdirSync ( path )
33+ . map ( function ( v ) {
34+ return { name :v ,
35+ time :fs . statSync ( path + v ) . mtime . getTime ( )
36+ } ;
37+ } )
38+ . sort ( function ( a , b ) { return a . time - b . time ; } )
39+ . map ( function ( v ) { return v . name ; } ) ;
40+
41+ console . log ( logs )
42+
43+
44+ // var tail = new Tail( path + filename );
45+ // tail.on('line', function(data) {
46+ // startSpinner();
47+ // var event = {'type': 'log', 'time': moment().utc().format('HH:mm:ss'), 'text': data};
48+ // var renderedEvent = $(Templates.event(event))
49+ // $('#clipboard').prepend(renderedEvent);
50+ //
51+ // stopSpinner();
52+ // });
53+ }
54+
2255window . onload = function ( ) {
2356 stopSpinner ( ) ;
2457 pollClipboard ( ) ;
58+ tailLogs ( ) ;
2559 gui . Window . get ( ) . show ( ) ;
2660}
0 commit comments