static.js.clients.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of formkiq-server Show documentation
Show all versions of formkiq-server Show documentation
Server-side integration for the FormKiQ ios application
function saveClient(sel, url) {
var data = sel.serialize();
$.ajax({
headers: {
Accept : "application/vnd.formkiq.v1+json"
},
type : 'POST',
url : url + "?" + data,
contentType: 'application/json; charset=utf-8',
dataType : 'json',
success : function(data) {
hidemessages();
showsuccess(sel, "Client Saved");
},
error: function (data) {
hidemessages();
var text = JSON.parse(data.responseText)
showerror(sel, "Unable to Save Client - " + text.message);
}
});
}
function updateClientListTable() {
$.getJSON("/api/clients/list", function() {
})
.done(function(data) {
$("#clientlisttable > tbody").html("");
$("#clientlisttable").append(
$.map(data.clients, function (item, index) {
return '' + item.client + ' '
+ '' + item.clientname + ' '
+ ' ';
}).join());
})
.fail(function(data) {
var text = JSON.parse(data.responseText)
showerror("#clienteditdiv", "Unable to Save Client - " + text.data);
});
}
function backbutton() {
updateClientListTable();
$("#clientlist").slideDown( "slow", function() {
$("#clientadd").hide();
});
}
$(document).ready(function() {
$("#clientadd").hide();
updateClientListTable();
$("#generatetokens").click(function() {
$('#client').attr("value", makeid(5));
$('#clientsecret').attr("value", makeid(10));
});
$('#clientaddform').submit(function(event) {
saveClient($(this), "/api/clients/create")
return false;
});
$("#addclientbutton").click(function() {
$("#clientadd").show();
$("#clientlist").slideUp( "slow", function() {
});
});
$(".backbutton").click(function(){
backbutton();
});
});