diff --git a/Teknik/Scripts/.eslintrc b/Teknik/Scripts/.eslintrc index 6ed2981..99b4fa1 100644 --- a/Teknik/Scripts/.eslintrc +++ b/Teknik/Scripts/.eslintrc @@ -24,6 +24,7 @@ "Uint8Array": false, // Common.js Functions + "deleteConfirm": false, "disableButton": false, "enableButton": false, "removeAmp": false, diff --git a/Teknik/Scripts/Admin/UploadSearch.js b/Teknik/Scripts/Admin/UploadSearch.js index 434fae1..90ad618 100644 --- a/Teknik/Scripts/Admin/UploadSearch.js +++ b/Teknik/Scripts/Admin/UploadSearch.js @@ -33,7 +33,7 @@ function LinkUploadDelete(selector) { $(selector).click(function () { var deleteUrl = $(this).attr('id'); var uploadID = $(this).data('upload-id'); - bootbox.confirm("Are you sure you want to delete this upload?", function (result) { + deleteConfirm("Are you sure you want to delete this upload?", function (result) { if (result) { if (deleteUrl !== '') { window.open(deleteUrl, '_blank'); diff --git a/Teknik/Scripts/Admin/UserInfo.js b/Teknik/Scripts/Admin/UserInfo.js index d05cd6f..a4c4fb7 100644 --- a/Teknik/Scripts/Admin/UserInfo.js +++ b/Teknik/Scripts/Admin/UserInfo.js @@ -67,7 +67,7 @@ $(function () { }); $('#delete_account').click(function () { - bootbox.confirm("Are you sure you want to delete this account?", function (result) { + deleteConfirm("Are you sure you want to delete this account?", function (result) { if (result) { $.ajax({ type: "POST", diff --git a/Teknik/Scripts/Blog/Blog.js b/Teknik/Scripts/Blog/Blog.js index 0b73169..545d91e 100644 --- a/Teknik/Scripts/Blog/Blog.js +++ b/Teknik/Scripts/Blog/Blog.js @@ -170,7 +170,7 @@ function linkPostDelete(selector) { $(selector).click(function () { var object = $(this); var post_id = object.attr("id"); - bootbox.confirm("Are you sure you want to delete your post?", function (result) { + deleteConfirm("Are you sure you want to delete your post?", function (result) { if (result) { $.ajax({ type: "POST", @@ -195,7 +195,7 @@ function linkCommentDelete(selector) { $(selector).click(function () { var object = $(this); var post_id = object.attr("id"); - bootbox.confirm("Are you sure you want to delete your comment?", function (result) { + deleteConfirm("Are you sure you want to delete your comment?", function (result) { if (result) { $.ajax({ type: "POST", diff --git a/Teknik/Scripts/Paste/ViewPaste.js b/Teknik/Scripts/Paste/ViewPaste.js index 56bebea..8a550a3 100644 --- a/Teknik/Scripts/Paste/ViewPaste.js +++ b/Teknik/Scripts/Paste/ViewPaste.js @@ -9,7 +9,7 @@ $(document).ready(function () { $('#delete-paste').click(function () { var id = $(this).data('paste-url'); - bootbox.confirm("Are you sure you want to delete this paste?", function (result) { + deleteConfirm("Are you sure you want to delete this paste?", function (result) { if (result) { $.ajax({ type: "POST", diff --git a/Teknik/Scripts/User/AccountSettings.js b/Teknik/Scripts/User/AccountSettings.js index 56e99f7..13ac379 100644 --- a/Teknik/Scripts/User/AccountSettings.js +++ b/Teknik/Scripts/User/AccountSettings.js @@ -38,7 +38,7 @@ $(document).ready(function () { $('#delete_account').click(function () { disableButton('#delete_account', 'Deleting Account...'); - bootbox.confirm("Are you sure you want to delete your account?", function (result) { + deleteConfirm("Are you sure you want to delete your account?", function (result) { if (result) { $.ajax({ type: "POST", diff --git a/Teknik/Scripts/User/DeveloperSettings.js b/Teknik/Scripts/User/DeveloperSettings.js index a3b3a1a..cc1bb7d 100644 --- a/Teknik/Scripts/User/DeveloperSettings.js +++ b/Teknik/Scripts/User/DeveloperSettings.js @@ -127,29 +127,42 @@ function editClientSave() { function deleteClient(clientId) { disableButton('.deleteClient[data-clientId="' + clientId + '"]', 'Deleting...'); - bootbox.confirm("

Are you sure you want to delete this client?



This is irreversable and all applications using these client credentials will stop working.", function (result) { - if (result) { - $.ajax({ - type: "POST", - url: deleteClientURL, - data: AddAntiForgeryToken({ clientId: clientId }), - success: function (response) { - if (response.result) { - $('#client_' + clientId).remove(); - if ($('#clientList li').length <= 0) { - $('#clientList').html('
  • No Clients
  • '); + bootbox.confirm({ + message: "

    Are you sure you want to delete this client?



    This is irreversable and all applications using these client credentials will stop working.", + buttons: { + confirm: { + label: 'Delete', + className: 'btn-danger' + }, + cancel: { + label: 'Cancel', + className: 'btn-default' + } + }, + callback: function (result) { + if (result) { + $.ajax({ + type: "POST", + url: deleteClientURL, + data: AddAntiForgeryToken({ clientId: clientId }), + success: function (response) { + if (response.result) { + $('#client_' + clientId).remove(); + if ($('#clientList li').length <= 0) { + $('#clientList').html('
  • No Clients
  • '); + } + } + else { + $("#top_msg").css('display', 'inline', 'important'); + $("#top_msg").html('
    ' + parseErrorMessage(response) + '
    '); } } - else { - $("#top_msg").css('display', 'inline', 'important'); - $("#top_msg").html('
    ' + parseErrorMessage(response) + '
    '); - } - } - }).always(function () { + }).always(function () { + enableButton('.deleteClient[data-clientId="' + clientId + '"]', 'Delete'); + }); + } else { enableButton('.deleteClient[data-clientId="' + clientId + '"]', 'Delete'); - }); - } else { - enableButton('.deleteClient[data-clientId="' + clientId + '"]', 'Delete'); + } } }); } diff --git a/Teknik/Scripts/User/SecuritySettings.js b/Teknik/Scripts/User/SecuritySettings.js index 4463551..39e7d07 100644 --- a/Teknik/Scripts/User/SecuritySettings.js +++ b/Teknik/Scripts/User/SecuritySettings.js @@ -24,6 +24,7 @@ $(document).ready(function () { $('#disable_2fa_button').click(function () { bootbox.confirm({ + size: "small", message: "Are you sure you want to disable Two-Factor Authentication? This will also invalidate all current recovery codes.", buttons: { confirm: { @@ -89,6 +90,7 @@ $(document).ready(function () { $('#resetRecoveryCodes').click(function () { bootbox.confirm({ + size: "small", message: "Are you sure you want to reset your recovery codes? This will invalidate all current recovery codes.", buttons: { confirm: { diff --git a/Teknik/Scripts/User/ViewServiceData.js b/Teknik/Scripts/User/ViewServiceData.js index 5196536..abd6dd2 100644 --- a/Teknik/Scripts/User/ViewServiceData.js +++ b/Teknik/Scripts/User/ViewServiceData.js @@ -37,7 +37,7 @@ $(document).ready(function () { }); function deleteItem(url, id, element, confirmationMsg) { - bootbox.confirm(confirmationMsg, function (result) { + deleteConfirm(confirmationMsg, function (result) { if (result) { $.ajax({ type: "POST", diff --git a/Teknik/Scripts/Vault/Vault.js b/Teknik/Scripts/Vault/Vault.js index a57878a..188ef64 100644 --- a/Teknik/Scripts/Vault/Vault.js +++ b/Teknik/Scripts/Vault/Vault.js @@ -192,7 +192,7 @@ $(document).ready(function () { $('.delete-vault-button').click(function () { var vaultUrl = $(this).data('vault-url'); - bootbox.confirm("Are you sure you want to delete this vault?", function (result) { + deleteConfirm("Are you sure you want to delete this vault?", function (result) { if (result) { $.ajax({ type: "POST", diff --git a/Teknik/Scripts/common.js b/Teknik/Scripts/common.js index 4a134ee..aad8f38 100644 --- a/Teknik/Scripts/common.js +++ b/Teknik/Scripts/common.js @@ -1,4 +1,4 @@ -/* exported disableButton, enableButton, removeAmp, clearInputs, randomString, getFileExtension, SelectAll, getAnchor, GenerateBlobURL, AddAntiForgeryToken, +/* exported deleteConfirm, disableButton, enableButton, removeAmp, clearInputs, randomString, getFileExtension, SelectAll, getAnchor, GenerateBlobURL, AddAntiForgeryToken, copyTextToClipboard, getReadableBandwidthString, getReadableFileSizeString, moveUp, moveDown, addParamsToUrl, sleep, parseErrorMessage, isValidURL, pageloadTimerCount, pageloadDoTimer, pageloadStopTimer */ $(document).ready(function () { @@ -111,6 +111,23 @@ $(function () { }; }); +function deleteConfirm(message, callback) { + bootbox.confirm({ + message: "

    " + message + "

    ", + buttons: { + confirm: { + label: 'Delete', + className: 'btn-danger' + }, + cancel: { + label: 'Cancel', + className: 'btn-default' + } + }, + callback: callback + }); +} + function disableButton(btn, text) { $(btn).addClass('disabled'); $(btn).text(text); diff --git a/Teknik/bundleconfig.json b/Teknik/bundleconfig.json index 5206ba1..564322b 100644 --- a/Teknik/bundleconfig.json +++ b/Teknik/bundleconfig.json @@ -2,21 +2,18 @@ { "outputFileName": "./wwwroot/js/admin.min.js", "inputFiles": [ - "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/js/app/Admin/Admin.js" ] }, { "outputFileName": "./wwwroot/js/uploadSearch.min.js", "inputFiles": [ - "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/js/App/Admin/UploadSearch.js" ] }, { "outputFileName": "./wwwroot/js/userInfo.min.js", "inputFiles": [ - "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/js/app/Admin/UserInfo.js" ] }, @@ -29,7 +26,6 @@ { "outputFileName": "./wwwroot/js/blog.min.js", "inputFiles": [ - "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/lib/marked/js/marked.js", "./wwwroot/lib/sanitize-html/js/sanitize-html.js", "./wwwroot/js/app/Blog/Blog.js" @@ -50,7 +46,6 @@ { "outputFileName": "./wwwroot/js/error.min.js", "inputFiles": [ - "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/js/app/Error/Error.js" ] }, @@ -99,7 +94,6 @@ { "outputFileName": "./wwwroot/js/paste.view.min.js", "inputFiles": [ - "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/js/app/lib/Prism/prism.js", "./wwwroot/js/app/lib/Prism/prism-line-numbers.js", "./wwwroot/js/app/lib/Prism/prism-line-highlight.js", @@ -135,7 +129,6 @@ { "outputFileName": "./wwwroot/js/podcast.min.js", "inputFiles": [ - "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/lib/jquery/js/jquery.BlockUI.js", "./wwwroot/js/app/Podcast/Podcast.js" ] @@ -165,7 +158,6 @@ "inputFiles": [ "./wwwroot/js/app/lib/Blob.js", "./wwwroot/lib/file-saver/js/FileSaver.js", - "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/js/app/Upload/Download.js" ] }, @@ -194,7 +186,6 @@ "inputFiles": [ "./wwwroot/lib/dropzone/js/dropzone.js", "./wwwroot/lib/bootstrap/js/bootstrap-switch.js", - "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/js/app/Upload/Upload.js" ] }, @@ -214,14 +205,12 @@ { "outputFileName": "./wwwroot/js/user.profile.min.js", "inputFiles": [ - "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/js/app/User/Profile.js" ] }, { "outputFileName": "./wwwroot/js/user.serviceData.min.js", "inputFiles": [ - "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/js/app/User/ViewServiceData.js" ] }, @@ -234,7 +223,6 @@ { "outputFileName": "./wwwroot/js/user.settings.min.js", "inputFiles": [ - "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/js/app/User/Settings.js" ] }, @@ -290,7 +278,6 @@ { "outputFileName": "./wwwroot/js/vault.min.js", "inputFiles": [ - "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/lib/jquery/js/jquery.BlockUI.js", "./wwwroot/lib/marked/js/marked.js", "./wwwroot/lib/sanitize-html/js/sanitize-html.js", @@ -317,6 +304,7 @@ "./wwwroot/lib/bootstrap/js/bootstrap.js", "./wwwroot/lib/bootstrap/js/bootstrap-select.js", "./wwwroot/lib/underscore/js/underscore.js", + "./wwwroot/lib/bootbox/js/bootbox.js", "./wwwroot/js/app/common.js" ] },