Some more functionalities
This commit is contained in:
25
js/admin.js
Normal file
25
js/admin.js
Normal file
@@ -0,0 +1,25 @@
|
||||
$(document).ready(function() {
|
||||
$("#username").keypress(function(e) { if(e.which == 13) $("#password").focus(); });
|
||||
$("#password").keypress(function(e) { if(e.which == 13) $("#btnLogin").click(); });
|
||||
$("#btnLogin").click(function() {
|
||||
var username = $("#username").val();
|
||||
var password = $("#password").val();
|
||||
var errorDiv = $("#loginError");
|
||||
var createdDiv = $("#accountCreated");
|
||||
var btn = $(this);
|
||||
|
||||
errorDiv.hide();
|
||||
btn.prop("disabled", true);
|
||||
btn.html("Logging in… <i class=\"fa fa-spin fa-circle-notch\"></i>");
|
||||
jsCore.apiCall("login", {"username": username, "password": password}, function(data) {
|
||||
window.location.reload();
|
||||
}, function(err) {
|
||||
btn.html("Login");
|
||||
btn.prop("disabled", false);
|
||||
$("#password").val("");
|
||||
createdDiv.hide();
|
||||
errorDiv.html(err);
|
||||
errorDiv.show();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -11,7 +11,7 @@ var Core = function() {
|
||||
callback = typeof callback !== 'undefined' ? callback : function(data) { };
|
||||
onerror = typeof onerror !== 'undefined' ? onerror : function(msg) { bootbox.alert("Ein Fehler ist aufgetreten: " + msg); };
|
||||
|
||||
$.post('/php/api/' + func + '.php', aParams, function(data) {
|
||||
$.post('/api/' + func, aParams, function(data) {
|
||||
console.log(func + "(): success=" + data.success + " msg=" + data.msg);
|
||||
if(data.hasOwnProperty('logoutIn') && $("#logoutTimer").length > 0) {
|
||||
$("#logoutTimer").attr("data-time", data.logoutIn);
|
||||
@@ -24,7 +24,7 @@ var Core = function() {
|
||||
}
|
||||
}, "json").fail(function(jqXHR, textStatus, errorThrown) {
|
||||
console.log("API-Function Error: " + func + " Status: " + textStatus + " error thrown: " + errorThrown);
|
||||
onerror.call(this, "Ein Fehler ist aufgetreten. API-Funktion: " + func + " Status: " + textStatus + " - " + errorThrown);
|
||||
onerror.call(this, "An error occurred. API-Function: " + func + " Status: " + textStatus + " - " + errorThrown);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@ var Core = function() {
|
||||
var name = cname + "=";
|
||||
var decodedCookie = decodeURIComponent(document.cookie);
|
||||
var ca = decodedCookie.split(";");
|
||||
for(var i = 0; i <ca.length; i++) {
|
||||
for(var i = 0; i < ca.length; i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) == ' ') {
|
||||
c = c.substring(1);
|
||||
|
||||
Reference in New Issue
Block a user