$(document).ready(function () { //Create a new api key $(document).on('click', 'a.createApiKey', function () { var dialog = bootbox.dialog({ title: 'Generating new key...', message: '
\n' + ' Generating...\n' + '
', closeButton: false, buttons: { ok: { label: "Ok", className: 'btn-info', callback: function () { location.reload(); } } } }); dialog.init(function () { $.ajax({ url: '/cgi/auth/create_api_key', type: 'GET', dataType: 'json', error: function () { dialog.find('.bootbox-body').html('

The api key creation call failed.

'); }, success: function (data) { if (data.status === "true") { dialog.find('.modal-title').html('New Key'); dialog.find('.bootbox-body').html('' + '
' + '

Please record these values. This is the only time you will see the secret.

' + '
' + '' + '
' ); } else { dialog.find('.bootbox-body').html('

' + data.description + '

'); } } }); }); return false; }); //Delete key $(document).on('click', 'a.keyManageDelete', function () { var keyval = $(this).data('keyval'); var dialog = bootbox.dialog({ title: 'Deleting key...', message: '
\n' + ' Deleting...\n' + '
', closeButton: false, buttons: { ok: { label: "Ok", className: 'btn-info', callback: function () { location.reload(); } } } }); dialog.init(function () { $.ajax({ url: '/cgi/auth/delete_api_key', type: 'GET', data: { keyval: keyval }, dataType: 'json', error: function () { dialog.find('.bootbox-body').html('

The api key delete failed.

'); }, success: function (data) { if (data.status === "true") { dialog.find('.modal-title').html('Key Deleted'); dialog.find('.bootbox-body').html('' + '

Key was deleted successfully.

' ); } else { dialog.find('.bootbox-body').html('

' + data.description + '

'); } } }); }); return false; }); //Request key upgrade $(document).on('click', 'a.keyManageRequestUpgrade', function () { var keyval = $(this).data('keyval'); var dialog = bootbox.dialog({ title: 'Sending request...', message: '
\n' + ' Sending...\n' + '
', closeButton: false, buttons: { ok: { label: "Ok", className: 'btn-info', callback: function () { location.reload(); } } } }); dialog.init(function () { $.ajax({ url: '/cgi/auth/request_key_upgrade', type: 'GET', data: { keyval: keyval }, dataType: 'json', error: function () { dialog.find('.bootbox-body').html('

The key upgrade request failed.

'); }, success: function (data) { if (data.status === "true") { dialog.find('.modal-title').html('Request Sent'); dialog.find('.bootbox-body').html('' + '

' + data.description + '

' ); } else { dialog.find('.bootbox-body').html('

' + data.description + '

'); } } }); }); return false; }); });