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

View File

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

View File

@ -1,4 +1,3 @@
var BASE = WEB_URL + "/api/json/";
var AUTH = ""; var AUTH = "";
var NO_WEBSOCKETS = false; var NO_WEBSOCKETS = false;
@ -156,20 +155,21 @@ function reverseLog() {
$("#log_reverse").click(reverseLog); $("#log_reverse").click(reverseLog);
function getSyslog() { 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); $("#log").text(data);
}); });
} }
$("#syslog").click(getSyslog); $("#syslog").click(getSyslog);
function getErrlog() { 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); $("#log").text(data);
}); });
} }
$("#errlog").click(getErrlog); $("#errlog").click(getErrlog);
function getActionLog() { function getActionLog() {
var types = "&actions=" + $("#actionlog_filter").val().join(","); 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"); var tbl = $("#actionlog table");
entries.forEach(function (e) { entries.forEach(function (e) {
e.time = parseInt(e.time); e.time = parseInt(e.time);
@ -217,7 +217,8 @@ function getActionLog() {
} }
function getChanlog() { function getChanlog() {
var chan = $("#channame").val(); 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); $("#log").text(data);
}); });
} }

View File

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