Add models and plugins

This commit is contained in:
Mattias Erming 2014-06-26 16:05:47 -07:00
parent 7370b10c22
commit 8e4cdc3e9f
41 changed files with 6385 additions and 26 deletions

View File

@ -1,6 +1,13 @@
module.exports = function(grunt) {
var files = ["*.js", "lib/*"];
var files = [
"./lib/**/*.js",
"./client/js/shout.js"
];
grunt.initConfig({
watch: {
files: files,
tasks: ["jshint"]
},
jshint: {
files: files
},
@ -10,18 +17,14 @@ module.exports = function(grunt) {
"client/js/components.min.js": ["client/components/*.js"]
}
}
},
watch: {
files: files,
tasks: ["default"]
}
});
["jshint", "uglify", "watch"]
["watch", "jshint", "uglify"]
.forEach(function(task) {
grunt.loadNpmTasks("grunt-contrib-" + task);
});
grunt.registerTask(
"default",
["jshint", "uglify"]
["uglify"]
);
};

0
README.md Normal file
View File

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,4 @@
$(function() {
// ..
var socket = io();
socket.emit("h", "hello");
});

3
config.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
port: 9000
};

View File

@ -1,3 +1,3 @@
process.chdir(__dirname);
var shout = require("./lib/shout");
new shout();
shout();

View File

@ -0,0 +1,19 @@
var _ = require("lodash");
module.exports = Chan;
Chan.Type = {
CHANNEL: "channel",
LOBBY: "lobby",
QUERY: "query"
};
function Chan(attr) {
_.merge(this, _.extend({
id: global.id = ++global.id || 1,
type: Chan.Type.CHANNEL,
name: "",
messages: [],
users: []
}));
}

View File

@ -0,0 +1,9 @@
module.exports = Client;
function Client(attr) {
_.merge(this, _.extend({
name: "",
sockets: null,
networks: []
}, attr));
}

View File

@ -0,0 +1,28 @@
var _ = require("lodash");
var moment = require("moment");
Msg.Type = {
ERROR: "error",
JOIN: "join",
KICK: "kick",
MESSAGE: "message",
MODE: "mode",
MOTD: "motd",
NICK: "nick",
NOTICE: "notice",
PART: "part",
QUIT: "quit",
TOPIC: "topic",
WHOIS: "whois"
};
module.exports = Msg;
function Msg(attr) {
_.merge(this, _.extend({
type: Msg.Type.MESSAGE,
time: moment().format("HH:mm"),
from: "",
text: ""
}, attr));
}

View File

@ -0,0 +1,18 @@
var _ = require("lodash");
module.exports = Network;
function Network(attr) {
_.merge(this, _.extend({
id: global.id = ++global.id || 1,
connected: false,
slate: null,
host: "",
name: capitalize(this.host.split(".")[1]) || this.host,
channels: []
}, attr));
}
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}

View File

@ -0,0 +1,10 @@
var _ = require("lodash");
module.exports = User;
function User(attr) {
_.merge(this, _.extend({
mode: "",
name: ""
}, attr));
}

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -0,0 +1,2 @@
module.exports = function() {
};

View File

@ -1,20 +1,58 @@
var _ = require("lodash");
var connect = require("connect");
var _ = require("lodash");
var config = require("../config") || {};
var http = require("connect");
var io = require("socket.io");
module.exports = Shout;
var sockets = null;
var clients = [];
/**
* @class
*/
function Shout() {
this.listen();
}
var inputs = [
"action",
"connect",
"invite",
"join",
"kick",
"mode",
"msg",
"nick",
"notice",
"part",
"quit",
"raw",
"topic",
"whois"
];
/**
* @public
*/
Shout.prototype.listen = function() {
var http = connect()
.use(connect.static("client"))
.listen(9000);
var events = [
"errors",
"join",
"kick",
"mode",
"motd",
"message",
"names",
"nick",
"notice",
"part",
"quit",
"topic",
"welcome",
"whois"
];
module.exports = function() {
sockets = io(http().use(http.static("client")).listen(config.port || 9000));
sockets.on("connection", function(socket) {
init(socket);
});
};
var init = function(socket, client) {
if (!client) {
} else {
}
};
var auth = function(data) {
// ..
};