Various fixes to the API

This commit is contained in:
Calvin Montgomery 2013-08-11 23:36:42 -04:00
parent 4aa0e7a4ef
commit 03e27a7720
4 changed files with 18 additions and 18 deletions

5
api.js
View File

@ -74,7 +74,7 @@ module.exports = function (Server) {
};
if(Server.channelLoaded(name))
data = getChannelData(name);
data = getChannelData(Server.getChannel(name));
res.type("application/json");
res.jsonp(data);
@ -137,7 +137,6 @@ module.exports = function (Server) {
}
var row = Auth.login(name, pw, session);
console.log(row);
if(!row) {
if(session && !pw) {
res.jsonp({
@ -528,7 +527,7 @@ module.exports = function (Server) {
}
types = types.split(",");
var actions = ActionLog.readLog(actiontypes);
var actions = ActionLog.readLog(types);
res.jsonp(actions);
});

View File

@ -21,7 +21,7 @@ if(uname && session) {
$.post(WEB_URL + "/api/login?callback=?", data, function (data) {
if(data.success)
onLogin();
});
}, "jsonp");
}
function onLogin() {
@ -141,7 +141,7 @@ $("#registerbtn").click(function() {
pw: pw
};
$.pos(WEB_URL + "/api/register?callback=?", data, function (data) {
$.post(WEB_URL + "/api/register?callback=?", data, function (data) {
if(data.success) {
uname = name;
session = data.session;
@ -157,7 +157,7 @@ $("#registerbtn").click(function() {
.text(data.error)
.insertBefore($("#registerpane form"));
}
});
}, "jsonp");
});
$("#loginbtn").click(function() {
@ -176,7 +176,7 @@ $("#loginbtn").click(function() {
name: uname,
pw: $("#loginpw").val()
};
$.getJSON(WEB_URL+"/api/login?callback=?", data, function(data) {
$.post(WEB_URL+"/api/login?callback=?", data, function(data) {
if(data.success) {
session = data.session;
onLogin();
@ -191,7 +191,7 @@ $("#loginbtn").click(function() {
.text(data.error)
.insertBefore($("#loginpane form"));
}
});
}, "jsonp");
});
$("#cpwbtn").click(function() {
@ -253,7 +253,7 @@ $("#cpwbtn").click(function() {
.text(data.error)
.insertBefore($("#changepwpane form"));
}
});
}, "jsonp");
});
$("#cebtn").click(function() {
@ -306,7 +306,7 @@ $("#cebtn").click(function() {
.text(data.error)
.insertBefore($("#changeemailpane form"));
}
});
}, "jsonp");
});
@ -334,7 +334,7 @@ $("#rpbtn").click(function() {
.text(data.error)
.insertBefore($("#pwresetpane form"));
}
});
}, "jsonp");
});
@ -362,7 +362,7 @@ $("#profilesave").click(function() {
.text(data.error)
.insertBefore($("#profilepane form"));
}
});
}, "jsonp");
});
$("#login").click(function() {

View File

@ -1,4 +1,3 @@
var BASE = WEB_URL + "/api/json/";
var AUTH = "";
var NO_WEBSOCKETS = false;
@ -156,20 +155,21 @@ function reverseLog() {
$("#log_reverse").click(reverseLog);
function getSyslog() {
$.ajax(WEB_URL+"/api/plain/readlog?type=sys&"+AUTH).done(function(data) {
$.ajax(WEB_URL+"/api/logging/syslog?"+AUTH).done(function(data) {
$("#log").text(data);
});
}
$("#syslog").click(getSyslog);
function getErrlog() {
$.ajax(WEB_URL+"/api/plain/readlog?type=err&"+AUTH).done(function(data) {
$.ajax(WEB_URL+"/api/logging/errorlog?"+AUTH).done(function(data) {
$("#log").text(data);
});
}
$("#errlog").click(getErrlog);
function getActionLog() {
var types = "&actions=" + $("#actionlog_filter").val().join(",");
$.getJSON(WEB_URL+"/api/json/readactionlog?"+AUTH+types+"&callback=?").done(function(entries) {
$.getJSON(WEB_URL+"/api/logging/actionlog?"+AUTH+types+"&callback=?")
.done(function(entries) {
var tbl = $("#actionlog table");
entries.forEach(function (e) {
e.time = parseInt(e.time);
@ -217,7 +217,8 @@ function getActionLog() {
}
function getChanlog() {
var chan = $("#channame").val();
$.ajax(WEB_URL+"/api/plain/readlog?type=channel&channel="+chan+"&"+AUTH).done(function(data) {
$.ajax(WEB_URL+"/api/logging/channels/"+chan+"?"+AUTH)
.done(function(data) {
$("#log").text(data);
});
}

View File

@ -73,7 +73,7 @@
$.post(WEB_URL+"/api/login", data, function (data) {
data.uname = $("#username").val();
source.postMessage("cytube-login:"+JSON.stringify(data), document.location);
});
}, "jsonp");
});
</script>
</body>