Skip to content

Commit 1f93c17

Browse files
committed
Move all window/keystroke setup into start/ui.js
1 parent 7d61145 commit 1f93c17

File tree

2 files changed

+28
-50
lines changed

2 files changed

+28
-50
lines changed

index.js

+1-50
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,4 @@
44

55
require('./start/setup.js');
66
require('./start/plugins.js');
7-
8-
// -----
9-
// Create UI
10-
//
11-
// TODO
12-
// - move all of this out of index.js into a ./start/
13-
// file and setup ui/input from there. It was just
14-
// in index.js here for easy testing purposes.
15-
//
16-
// -----
17-
18-
window = require('./lib/ui/window.js');
19-
strokes = require('./lib/input/strokes.js');
20-
21-
22-
var irc=require("irc");
23-
24-
var con={
25-
nick:"utterbot"
26-
,server:"irc.hypeirc.net"
27-
,channels:["#utter"]
28-
};
29-
30-
con.nect=function(){
31-
return new irc.Client(con.server,con.nick,{channels:con.channels});
32-
};
33-
34-
var client=con.nect();
35-
36-
client.addListener('error', function(message) {
37-
console.error('ERROR: %s: %s', message.command, message.args.join(' '));
38-
});
39-
40-
client.addListener('message',function(from,to,message){
41-
window.BODY.content += '\n[00:00:00] <'+from+'> ' + message;
42-
window.render();
43-
});
44-
45-
46-
window.render();
47-
strokes.init({
48-
display: function() {
49-
window.INPUT.content = strokes.currentBufferText();
50-
window.render();
51-
}
52-
,send: function(msg){
53-
window.BODY.content += "\n[00:00:00] <@username> "+msg;
54-
client.say('#utter', msg);
55-
}
56-
});
7+
require('./start/ui.js');

start/ui.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// -----
2+
// Load our window and keystrokes
3+
// -----
4+
5+
window = require('../lib/ui/window.js');
6+
strokes = require('../lib/input/strokes.js');
7+
8+
// -----
9+
// Initialize our keystrokes and add our basic
10+
// functionality.
11+
// -----
12+
13+
strokes.init({
14+
display: function() {
15+
window.INPUT.content = strokes.currentBufferText();
16+
window.render();
17+
}
18+
,send: function(msg){
19+
window.BODY.content += "\n[00:00:00] <@username> "+msg;
20+
}
21+
});
22+
23+
// -----
24+
// Render the initial window
25+
// -----
26+
27+
window.render();

0 commit comments

Comments
 (0)