Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 5 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Showing with 47 additions and 25 deletions.
  1. +5 −1 .gitignore
  2. +16 −9 atheme.js
  3. +5 −9 public/js/dashboard.js
  4. +7 −3 public/js/login.js
  5. +13 −3 routes/index.js
  6. +1 −0 views/dashboard.jade
View
6 .gitignore
@@ -7,9 +7,13 @@ lib-cov
*.pid
*.gz
+*.swo
+*.swp
+*.un~
+
pids
logs
results
node_modules
-npm-debug.log
+npm-debug.log
View
25 atheme.js
@@ -1,4 +1,5 @@
var atheme = exports;
+var util = require('util');
function emptyReply(error, value) { };
@@ -92,20 +93,26 @@ atheme.memoserv = {
[client.authcookie, client.user, client.ip, 'MemoServ', 'LIST'],
function(error, value)
{
- var msgs = new Array();
+ var count = new Object();
var rawLine = value.split('\n');
- var total = rawLine[0].split(' ')[2];
- var newmsg = rawLine[0].split(' ')[4].substr(1);
- rawLine.shift;
- rawLine.shift;
- for(var i = 0; i > rawLine.length; i++)
+ count["new"] = rawLine[0].split("(")[1].split(" ")[0];
+ count["total"] = rawLine[0].split(" ")[2];
+
+ var i;
+ var messages = new Array;
+ for (i = 2; rawLine[i] != undefined; i++)
{
- msgs[i]["from"] = rawLine[i].split(' ')[2];
- msgs[i]["when"] = rawLine[i].split('Sent: ')[2];
+ messages[i - 2] = new Object();
+ messages[i - 2]["from"] = rawLine[i].split(" ")[3];
+ messages[i - 2]["when"] = rawLine[i].split(": ")[2];
}
- client.data.memoserv.list = {messages: msgs};
+ var list = new Object;
+ list["count"] = count;
+ list["messages"] = messages;
+ client.data.memoserv.list = JSON.stringify(list);
+ console.log(util.inspect(client.data.memoserv.list))
});
},
View
14 public/js/dashboard.js
@@ -4,18 +4,15 @@ $("#waiting").modal({
show: true
});
-console.log("Cookie UUID: " + $.cookie("awp_uuid"));
-
$.ajax({
url: '/atheme/do/memoserv/list',
type: 'POST',
data: 'uuid=' + $.cookie("awp_uuid"),
dataType: 'json',
success: function(res) {
- console.log("Succes!")
+ console.log(res);
if (res.list === null)
{
- console.log("Checked..");
window.setTimeout(checkMemos, 250);
}
}
@@ -31,7 +28,6 @@ function checkMemos()
success: function(res) {
if (res.list === undefined || res.list === null)
{
- console.log("Rechecking");
window.setTimeout(checkMemos, 250);
return;
}
@@ -42,10 +38,10 @@ function checkMemos()
}
else
{
- console.log("Looping");
- res.list.messages.forEach(function(element) {
- $("<p>" + element + "<p>").insertAfter($('h1'));
- console.log(element);
+ var listing = JSON.parse(res.list);
+ listing.messages.forEach(function(element) {
+ var listEl = $("<li>" + element.from + " [" + element.when + "]</li>");
+ $("#memos").append(listEl);
});
$("#waiting").modal("hide");
}
View
10 public/js/login.js
@@ -43,7 +43,7 @@ $("input.login").click(function(){
$.cookie("awp_uuid", uuid);
window.setTimeout(250, checkLogin());
}
- else alert("Something fucked up.");
+ else console.log("Something fucked up.");
}
});
});
@@ -63,10 +63,14 @@ function checkLogin()
}
else if (res.authcookie === -1)
{
- alert("Authentication failed!");
+ console.log("Authentication failed!");
return;
}
- else alert("Authcookie: " + res.authcookie);
+ else
+ {
+ console.log("Authcookie: " + res.authcookie);
+ window.location.href = "/dash";
+ }
}
});
}
View
16 routes/index.js
@@ -3,6 +3,13 @@ var ctrl = require("../atheme.js"),
uuid = require('node-uuid'),
util = require('util');
+function uuid(req, res)
+{
+ var date = new Date();
+ console.log(date.getTime);
+ return "goats";
+}
+
var au = {
login: function(req, res)
{
@@ -23,6 +30,7 @@ var au = {
client = ctrl.create(xml.createClient({host:'scylla.unlink.nswier.edu.au', port: 8080, path: '/xmlrpc'}),
req.body.user, req.connection.remoteAddress);
var id = uuid.v4(null, null, 16);
+ console.log(id);
clients[id] = client;
ctrl.login(client, req.body.pass);
@@ -43,10 +51,12 @@ var au = {
go: function(req, res)
{
+ console.log("Go 1 called");
if (req.params.service === "memoserv")
{
if (req.params.command === "list")
{
+ console.log("Go called");
return au.services.memoserv.list.go(req, res);
}
}
@@ -73,7 +83,6 @@ var au = {
}
}
-
/*
* GET home page.
*/
@@ -83,8 +92,7 @@ exports.index = function(req, res){
};
exports.dashboard = function(req, res){
- //res.render('dashboard', {words: "piss shit dicks", title: 'AWP Dashboard'});
- res.render('dashboard', {title: 'AWP Dashboard', words: JSON.stringify('words: ["piss", "shit", "dicks"]')});
+ res.render('dashboard', {title: 'AWP Dashboard'});
};
exports.lols = function(req, res)
@@ -106,12 +114,14 @@ exports.atheme = function(req, res)
if (req.params.verb === "check")
{
+ console.log("Check!");
if (req.body.uuid === undefined || clients[req.body.uuid] === undefined)
return;
return au.check(req, res);
}
else if (req.params.verb === "do")
{
+ console.log("Do!");
return au.go(req, res);
}
View
1 views/dashboard.jade
@@ -18,6 +18,7 @@ block content
div.well.span7
h1 Memos
+ ol#memos
block javascripts

No commit comments for this range

Something went wrong with that request. Please try again.