File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ( function Core ( ) {
2+ this . init = function init ( ) {
3+ var gui = require ( 'nw.gui' ) ;
4+ var win = gui . Window . get ( ) ;
5+
6+ document . addEventListener ( 'click' , function onClick ( event ) {
7+ if ( ! event ) {
8+ event = window . event ;
9+ }
10+
11+ var parent = Tools . getClosest ( event . target , '[data-action]' ) ;
12+
13+ if ( typeof ( parent ) != 'undefined' && typeof ( parent . dataset ) != 'undefined' && typeof ( parent . dataset . action ) != 'undefined' ) {
14+ switch ( parent . dataset . action ) {
15+ case 'window:close' :
16+ win . close ( true ) ;
17+ break
18+ case 'window:maximize' :
19+ document . querySelector ( 'button[data-action="window:maximize"]' ) . dataset . action = 'window:restore' ;
20+ win . maximize ( ) ;
21+ break ;
22+ case 'window:restore' :
23+ win . restore ( ) ;
24+ document . querySelector ( 'button[data-action="window:restore"]' ) . dataset . action = 'window:maximize' ;
25+ break ;
26+ case 'window:minimize' :
27+ win . minimize ( ) ;
28+ break ;
29+ case 'settings:save' :
30+ case 'settings:close' :
31+ case 'settings:toggle' :
32+ var element = document . querySelector ( 'overlay[data-view="settings"]' ) ;
33+ element . classList . toggle ( 'show' ) ;
34+ this . checkOverlay ( ) ;
35+ break ;
36+ }
37+ }
38+ } . bind ( this ) ) ;
39+
40+ this . checkOverlay ( ) ;
41+ } ;
42+
43+ this . checkOverlay = function checkOverlay ( ) {
44+ var elements = document . querySelectorAll ( 'overlay' ) ;
45+ document . body . dataset . overlay = null ;
46+
47+ [ ] . forEach . call ( elements , function ( element ) {
48+ if ( element . classList . contains ( 'show' ) ) {
49+ document . body . dataset . overlay = 'settings' ;
50+ }
51+ } ) ;
52+ } ;
53+
54+ this . init ( ) ;
55+ } ( ) ) ;
Original file line number Diff line number Diff line change 1+ var Client = function Client ( host , port , password , options ) {
2+ var net = require ( 'net' ) ;
3+
4+ var host = '' ,
5+ port = 0 ,
6+ password = '' ;
7+
8+ var socket ;
9+
10+ this . init = function init ( host , port , password , options ) {
11+ this . host = host ;
12+ this . port = port ;
13+ this . password = password ;
14+ } ;
15+
16+ this . connect = function connect ( ) {
17+ console . log ( 'Connecting..' ) ;
18+ socket = net . createConnection ( { port : 11000 , host : 'localhost' } ) ;
19+ socket . on ( 'data' , function ( data ) {
20+ console . log ( 'data' , data ) ;
21+ } ) ;
22+ socket . on ( 'connect' , function ( ) { console . log ( 'connect' ) ; } ) ;
23+ socket . on ( 'error' , function ( err ) { console . log ( 'error' , err ) ; } ) ;
24+ socket . on ( 'end' , function ( ) { console . log ( 'end' ) ; } ) ;
25+ } ;
26+
27+ this . init ( host , port , password , options ) ;
28+ } ;
Original file line number Diff line number Diff line change 1+ var Tools = ( new function Tools ( ) {
2+ this . getClosest = function getClosest ( element , selector ) {
3+ if ( ! Element . prototype . matches ) {
4+ Element . prototype . matches = Element . prototype . matchesSelector || Element . prototype . mozMatchesSelector || Element . prototype . msMatchesSelector || Element . prototype . oMatchesSelector || Element . prototype . webkitMatchesSelector || function MatchesSelector ( selector ) {
5+ var matches = ( this . document || this . ownerDocument ) . querySelectorAll ( selector ) ;
6+ var index = matches . length ;
7+
8+ while ( -- index >= 0 && matches . item ( index ) !== this ) {
9+ /* Do Nothing */
10+ }
11+
12+ return index > - 1 ;
13+ } ;
14+ }
15+
16+ for ( ; element && element !== document ; element = element . parentNode ) {
17+ if ( element . matches ( selector ) ) {
18+ return element ;
19+ }
20+ }
21+
22+ return undefined ;
23+ } ;
24+
25+ this . zeroize = function zeroize ( number ) {
26+ return ( number <= 9 ? '0' + number : number ) ;
27+ } ;
28+ } ( ) ) ;
You can’t perform that action at this time.
0 commit comments