From 3a15c155c762a8cc5e85f020de76cb6f0ee9ba56 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Tue, 21 Apr 2020 22:38:46 -0400 Subject: [PATCH] Make it easier to click checkbox --- .../admin/assets/js/pages/scoreboard.js | 9 --------- .../admin/assets/js/pages/submissions.js | 9 --------- CTFd/themes/admin/assets/js/styles.js | 20 +++++++++++++++++++ CTFd/themes/admin/static/css/admin.dev.css | 2 +- CTFd/themes/admin/static/css/admin.min.css | 2 +- CTFd/themes/admin/static/js/core.dev.js | 2 +- .../admin/static/js/pages/challenge.min.js | 2 +- .../admin/static/js/pages/configs.min.js | 2 +- .../admin/static/js/pages/editor.min.js | 2 +- CTFd/themes/admin/static/js/pages/main.min.js | 2 +- .../static/js/pages/notifications.min.js | 2 +- .../themes/admin/static/js/pages/pages.min.js | 2 +- .../themes/admin/static/js/pages/reset.min.js | 2 +- .../admin/static/js/pages/scoreboard.dev.js | 2 +- .../admin/static/js/pages/scoreboard.min.js | 2 +- .../admin/static/js/pages/statistics.min.js | 2 +- .../admin/static/js/pages/submissions.dev.js | 2 +- .../admin/static/js/pages/submissions.min.js | 2 +- CTFd/themes/admin/static/js/pages/team.min.js | 2 +- CTFd/themes/admin/static/js/pages/user.min.js | 2 +- .../themes/admin/static/js/pages/users.min.js | 2 +- CTFd/themes/admin/templates/scoreboard.html | 6 +++--- CTFd/themes/admin/templates/submissions.html | 6 +++--- .../core/static/js/pages/challenges.min.js | 2 +- CTFd/themes/core/static/js/pages/main.min.js | 2 +- .../core/static/js/pages/notifications.min.js | 2 +- .../core/static/js/pages/scoreboard.min.js | 2 +- .../core/static/js/pages/settings.min.js | 2 +- CTFd/themes/core/static/js/pages/setup.min.js | 2 +- CTFd/themes/core/static/js/pages/stats.min.js | 2 +- .../core/static/js/pages/teams/private.min.js | 2 +- 31 files changed, 52 insertions(+), 50 deletions(-) diff --git a/CTFd/themes/admin/assets/js/pages/scoreboard.js b/CTFd/themes/admin/assets/js/pages/scoreboard.js index 9ab4341..dc9c7e4 100644 --- a/CTFd/themes/admin/assets/js/pages/scoreboard.js +++ b/CTFd/themes/admin/assets/js/pages/scoreboard.js @@ -79,17 +79,8 @@ function showSelectedAccounts(event) { }); } -function toggleScoreboardSelect(event) { - const checked = $(this).prop("checked"); - $(this) - .closest("table") - .find("input[data-account-id]") - .prop("checked", checked); -} - $(() => { $(".scoreboard-toggle").click(toggleAccount); - $("#scoreboard-bulk-select").click(toggleScoreboardSelect); $("#scoreboard-hide-button").click(hideSelectedAccounts); $("#scoreboard-show-button").click(showSelectedAccounts); }); diff --git a/CTFd/themes/admin/assets/js/pages/submissions.js b/CTFd/themes/admin/assets/js/pages/submissions.js index 651cd82..82c6fb3 100644 --- a/CTFd/themes/admin/assets/js/pages/submissions.js +++ b/CTFd/themes/admin/assets/js/pages/submissions.js @@ -61,16 +61,7 @@ function deleteSelectedSubmissions(event) { }); } -function toggleSubmissionSelect(event) { - const checked = $(this).prop("checked"); - $(this) - .closest("table") - .find("input[data-submission-id]") - .prop("checked", checked); -} - $(() => { $(".delete-correct-submission").click(deleteCorrectSubmission); - $("#submissions-bulk-select").change(toggleSubmissionSelect); $("#submission-delete-button").click(deleteSelectedSubmissions); }); diff --git a/CTFd/themes/admin/assets/js/styles.js b/CTFd/themes/admin/assets/js/styles.js index 88dd2e1..125293b 100644 --- a/CTFd/themes/admin/assets/js/styles.js +++ b/CTFd/themes/admin/assets/js/styles.js @@ -46,6 +46,26 @@ export default () => { return false; }); + $("[data-checkbox]").click(function(e){ + if ($(e.target).is("input[type=checkbox]")) { + e.stopImmediatePropagation(); + return; + } + let checkbox = $(this).find('input[type=checkbox]'); + // Doing it this way with an event allows data-checkbox-all to work + checkbox.click(); + e.stopImmediatePropagation(); + }); + + $("[data-checkbox-all]").on('click change', function(e){ + const checked = $(this).prop("checked"); + const idx = $(this).index() + 1; + $(this).closest("table") + .find(`tr td:nth-child(${idx}) input[type=checkbox]`) + .prop("checked", checked) + e.stopImmediatePropagation(); + }); + $("tr[data-href] a, tr[data-href] button").click(function(e) { // TODO: This is a hack to allow modal close buttons to work if (!$(this).attr("data-dismiss")) { diff --git a/CTFd/themes/admin/static/css/admin.dev.css b/CTFd/themes/admin/static/css/admin.dev.css index 9ad61a1..e015e2d 100644 --- a/CTFd/themes/admin/static/css/admin.dev.css +++ b/CTFd/themes/admin/static/css/admin.dev.css @@ -1,4 +1,4 @@ html{position:relative;min-height:100%}body{margin-bottom:60px}.footer{position:absolute;bottom:1px;width:100%;height:60px;line-height:normal !important;z-index:-20} -#score-graph{height:450px;display:block;clear:both}#solves-graph{display:block;height:350px}#keys-pie-graph{height:400px;display:block}#categories-pie-graph{height:400px;display:block}#solve-percentages-graph{height:400px;display:block}.no-decoration{color:inherit !important;text-decoration:none !important}.no-decoration:hover{color:inherit !important;text-decoration:none !important}.table td,.table th{vertical-align:inherit}pre{white-space:pre-wrap;margin:0;padding:0}.form-control{position:relative;display:block;border-radius:0;font-weight:400;font-family:"Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;-webkit-appearance:none}tbody tr:hover{background-color:rgba(0,0,0,0.1) !important}tr[data-href]{cursor:pointer}th{cursor:pointer}input[type=checkbox]{cursor:pointer} +#score-graph{height:450px;display:block;clear:both}#solves-graph{display:block;height:350px}#keys-pie-graph{height:400px;display:block}#categories-pie-graph{height:400px;display:block}#solve-percentages-graph{height:400px;display:block}.no-decoration{color:inherit !important;text-decoration:none !important}.no-decoration:hover{color:inherit !important;text-decoration:none !important}.table td,.table th{vertical-align:inherit}pre{white-space:pre-wrap;margin:0;padding:0}.form-control{position:relative;display:block;border-radius:0;font-weight:400;font-family:"Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;-webkit-appearance:none}tbody tr:hover{background-color:rgba(0,0,0,0.1) !important}tr[data-href]{cursor:pointer}.sort-col{cursor:pointer}input[type="checkbox"]{cursor:pointer} diff --git a/CTFd/themes/admin/static/css/admin.min.css b/CTFd/themes/admin/static/css/admin.min.css index d207c51..75edc2e 100644 --- a/CTFd/themes/admin/static/css/admin.min.css +++ b/CTFd/themes/admin/static/css/admin.min.css @@ -1 +1 @@ -html{position:relative;min-height:100%}body{margin-bottom:60px}.footer{position:absolute;bottom:1px;width:100%;height:60px;line-height:normal!important;z-index:-20}#score-graph{height:450px;display:block;clear:both}#solves-graph{display:block;height:350px}#categories-pie-graph,#keys-pie-graph,#solve-percentages-graph{height:400px;display:block}.no-decoration,.no-decoration:hover{color:inherit!important;text-decoration:none!important}.table td,.table th{vertical-align:inherit}pre{white-space:pre-wrap;margin:0;padding:0}.form-control{position:relative;display:block;border-radius:0;font-weight:400;font-family:Avenir Next,Helvetica Neue,Helvetica,Arial,sans-serif;-webkit-appearance:none}tbody tr:hover{background-color:rgba(0,0,0,.1)!important}tr[data-href]{cursor:pointer} \ No newline at end of file +html{position:relative;min-height:100%}body{margin-bottom:60px}.footer{position:absolute;bottom:1px;width:100%;height:60px;line-height:normal!important;z-index:-20}#score-graph{height:450px;display:block;clear:both}#solves-graph{display:block;height:350px}#categories-pie-graph,#keys-pie-graph,#solve-percentages-graph{height:400px;display:block}.no-decoration,.no-decoration:hover{color:inherit!important;text-decoration:none!important}.table td,.table th{vertical-align:inherit}pre{white-space:pre-wrap;margin:0;padding:0}.form-control{position:relative;display:block;border-radius:0;font-weight:400;font-family:Avenir Next,Helvetica Neue,Helvetica,Arial,sans-serif;-webkit-appearance:none}tbody tr:hover{background-color:rgba(0,0,0,.1)!important}.sort-col,input[type=checkbox],tr[data-href]{cursor:pointer} \ No newline at end of file diff --git a/CTFd/themes/admin/static/js/core.dev.js b/CTFd/themes/admin/static/js/core.dev.js index 9501d88..8b5c280 100644 --- a/CTFd/themes/admin/static/js/core.dev.js +++ b/CTFd/themes/admin/static/js/core.dev.js @@ -20,7 +20,7 @@ eval("\n\nvar _CTFd = _interopRequireDefault(__webpack_require__(/*! core/CTFd * /***/ (function(module, exports, __webpack_require__) { ; -eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\n__webpack_require__(/*! bootstrap/dist/js/bootstrap.bundle */ \"./node_modules/bootstrap/dist/js/bootstrap.bundle.js\");\n\nvar _utils = __webpack_require__(/*! core/utils */ \"./CTFd/themes/core/assets/js/utils.js\");\n\nvar _jquery = _interopRequireDefault(__webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar _default = function _default() {\n // TODO: This is kind of a hack to mimic a React-like state construct.\n // It should be removed once we have a real front-end framework in place.\n (0, _jquery.default)(\":input\").each(function () {\n (0, _jquery.default)(this).data(\"initial\", (0, _jquery.default)(this).val());\n });\n (0, _jquery.default)(\".form-control\").bind({\n focus: function focus() {\n (0, _jquery.default)(this).addClass(\"input-filled-valid\");\n },\n blur: function blur() {\n if ((0, _jquery.default)(this).val() === \"\") {\n (0, _jquery.default)(this).removeClass(\"input-filled-valid\");\n }\n }\n });\n (0, _jquery.default)(\".modal\").on(\"show.bs.modal\", function (e) {\n (0, _jquery.default)(\".form-control\").each(function () {\n if ((0, _jquery.default)(this).val()) {\n (0, _jquery.default)(this).addClass(\"input-filled-valid\");\n }\n });\n });\n (0, _jquery.default)(function () {\n (0, _jquery.default)(\".form-control\").each(function () {\n if ((0, _jquery.default)(this).val()) {\n (0, _jquery.default)(this).addClass(\"input-filled-valid\");\n }\n });\n (0, _jquery.default)(\"tr[data-href]\").click(function () {\n var sel = getSelection().toString();\n\n if (!sel) {\n var href = (0, _jquery.default)(this).attr(\"data-href\");\n\n if (href) {\n window.location = href;\n }\n }\n\n return false;\n });\n (0, _jquery.default)(\"tr[data-href] a, tr[data-href] button\").click(function (e) {\n // TODO: This is a hack to allow modal close buttons to work\n if (!(0, _jquery.default)(this).attr(\"data-dismiss\")) {\n e.stopPropagation();\n }\n });\n (0, _utils.makeSortableTables)();\n (0, _jquery.default)('[data-toggle=\"tooltip\"]').tooltip();\n });\n};\n\nexports.default = _default;\n\n//# sourceURL=webpack:///./CTFd/themes/admin/assets/js/styles.js?"); +eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\n__webpack_require__(/*! bootstrap/dist/js/bootstrap.bundle */ \"./node_modules/bootstrap/dist/js/bootstrap.bundle.js\");\n\nvar _utils = __webpack_require__(/*! core/utils */ \"./CTFd/themes/core/assets/js/utils.js\");\n\nvar _jquery = _interopRequireDefault(__webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar _default = function _default() {\n // TODO: This is kind of a hack to mimic a React-like state construct.\n // It should be removed once we have a real front-end framework in place.\n (0, _jquery.default)(\":input\").each(function () {\n (0, _jquery.default)(this).data(\"initial\", (0, _jquery.default)(this).val());\n });\n (0, _jquery.default)(\".form-control\").bind({\n focus: function focus() {\n (0, _jquery.default)(this).addClass(\"input-filled-valid\");\n },\n blur: function blur() {\n if ((0, _jquery.default)(this).val() === \"\") {\n (0, _jquery.default)(this).removeClass(\"input-filled-valid\");\n }\n }\n });\n (0, _jquery.default)(\".modal\").on(\"show.bs.modal\", function (e) {\n (0, _jquery.default)(\".form-control\").each(function () {\n if ((0, _jquery.default)(this).val()) {\n (0, _jquery.default)(this).addClass(\"input-filled-valid\");\n }\n });\n });\n (0, _jquery.default)(function () {\n (0, _jquery.default)(\".form-control\").each(function () {\n if ((0, _jquery.default)(this).val()) {\n (0, _jquery.default)(this).addClass(\"input-filled-valid\");\n }\n });\n (0, _jquery.default)(\"tr[data-href]\").click(function () {\n var sel = getSelection().toString();\n\n if (!sel) {\n var href = (0, _jquery.default)(this).attr(\"data-href\");\n\n if (href) {\n window.location = href;\n }\n }\n\n return false;\n });\n (0, _jquery.default)(\"[data-checkbox]\").click(function (e) {\n if ((0, _jquery.default)(e.target).is(\"input[type=checkbox]\")) {\n e.stopImmediatePropagation();\n return;\n }\n\n var checkbox = (0, _jquery.default)(this).find('input[type=checkbox]'); // Doing it this way with an event allows data-checkbox-all to work\n\n checkbox.click();\n e.stopImmediatePropagation();\n });\n (0, _jquery.default)(\"[data-checkbox-all]\").on('click change', function (e) {\n var checked = (0, _jquery.default)(this).prop(\"checked\");\n var idx = (0, _jquery.default)(this).index() + 1;\n (0, _jquery.default)(this).closest(\"table\").find(\"tr td:nth-child(\".concat(idx, \") input[type=checkbox]\")).prop(\"checked\", checked);\n e.stopImmediatePropagation();\n });\n (0, _jquery.default)(\"tr[data-href] a, tr[data-href] button\").click(function (e) {\n // TODO: This is a hack to allow modal close buttons to work\n if (!(0, _jquery.default)(this).attr(\"data-dismiss\")) {\n e.stopPropagation();\n }\n });\n (0, _utils.makeSortableTables)();\n (0, _jquery.default)('[data-toggle=\"tooltip\"]').tooltip();\n });\n};\n\nexports.default = _default;\n\n//# sourceURL=webpack:///./CTFd/themes/admin/assets/js/styles.js?"); /***/ }), diff --git a/CTFd/themes/admin/static/js/pages/challenge.min.js b/CTFd/themes/admin/static/js/pages/challenge.min.js index 17618b6..4059220 100644 --- a/CTFd/themes/admin/static/js/pages/challenge.min.js +++ b/CTFd/themes/admin/static/js/pages/challenge.min.js @@ -1 +1 @@ -!function(d){function e(e){for(var t,o,n=e[0],s=e[1],a=e[2],i=0,l=[];i -- ");for(var s in o.append(n),t)t.hasOwnProperty(s)&&(n=(0,a.default)("".format(s,t[s].name)),o.append(n));(0,a.default)("#flag-edit-modal").modal()}),(0,a.default)("#flag-edit-modal form").submit(function(e){e.preventDefault();var t=(0,a.default)(this).serializeJSON(!0);t.challenge=CHALLENGE_ID,i.default.fetch("/api/v1/flags",{method:"POST",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){window.location.reload()})}),(0,a.default)("#flag-edit-modal").modal()},t.editFlagModal=function(e){e.preventDefault();var n=(0,a.default)(this).attr("flag-id"),s=(0,a.default)(this).parent().parent();a.default.get(i.default.config.urlRoot+"/api/v1/flags/"+n,function(e){var o=e.data;a.default.get(i.default.config.urlRoot+o.templates.update,function(e){(0,a.default)("#edit-flags form").empty(),(0,a.default)("#edit-flags form").off();var t=l.default.compile(e);(0,a.default)("#edit-flags form").append(t.render(o)),(0,a.default)("#edit-flags form").submit(function(e){e.preventDefault();var t=(0,a.default)("#edit-flags form").serializeJSON();i.default.fetch("/api/v1/flags/"+n,{method:"PATCH",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){e.success&&((0,a.default)(s).find(".flag-content").text(e.data.content),(0,a.default)("#edit-flags").modal("toggle"))})}),(0,a.default)("#edit-flags").modal()})})},t.flagTypeSelect=function(e){e.preventDefault();var t=(0,a.default)(this).find("option:selected").text();a.default.get(i.default.config.urlRoot+"/api/v1/flags/types/"+t,function(e){var t=e.data;a.default.get(i.default.config.urlRoot+t.templates.create,function(e){var t=l.default.compile(e);(0,a.default)("#create-keys-entry-div").html(t.render()),(0,a.default)("#create-keys-button-div").show()})})};var a=s(o("./node_modules/jquery/dist/jquery.js")),i=s(o("./CTFd/themes/core/assets/js/CTFd.js")),l=s(o("./node_modules/nunjucks/browser/nunjucks.js")),n=o("./CTFd/themes/core/assets/js/ezq.js");function s(e){return e&&e.__esModule?e:{default:e}}},"./CTFd/themes/admin/assets/js/challenges/hints.js":function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.showHintModal=function(e){e.preventDefault(),(0,s.default)("#hint-edit-modal form").find("input, textarea").val(""),(0,s.default)("#new-hint-edit").on("shown.bs.tab",function(e){if("#hint-preview"==e.target.hash){var t=a.default.lib.markdown(),o=(0,s.default)("#hint-write textarea").val();(0,s.default)(e.target.hash).html(t.render(o))}}),(0,s.default)("#hint-edit-modal").modal()},t.showEditHintModal=function(e){e.preventDefault();var t=(0,s.default)(this).attr("hint-id");a.default.fetch("/api/v1/hints/"+t+"?preview=true",{method:"GET",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(e){return e.json()}).then(function(e){e.success&&((0,s.default)("#hint-edit-form input[name=content],textarea[name=content]").val(e.data.content),(0,s.default)("#hint-edit-form input[name=cost]").val(e.data.cost),(0,s.default)("#hint-edit-form input[name=id]").val(e.data.id),(0,s.default)("#new-hint-edit").on("shown.bs.tab",function(e){if("#hint-preview"==e.target.hash){var t=a.default.lib.markdown(),o=(0,s.default)("#hint-write textarea").val();(0,s.default)(e.target.hash).html(t.render(o))}}),(0,s.default)("#hint-edit-modal").modal())})},t.deleteHint=function(e){e.preventDefault();var t=(0,s.default)(this).attr("hint-id"),o=(0,s.default)(this).parent().parent();(0,n.ezQuery)({title:"Delete Hint",body:"Are you sure you want to delete this hint?",success:function(){a.default.fetch("/api/v1/hints/"+t,{method:"DELETE"}).then(function(e){return e.json()}).then(function(e){e.success&&o.remove()})}})},t.editHint=function(e){e.preventDefault();var t=(0,s.default)(this).serializeJSON(!0);t.challenge=CHALLENGE_ID;var o="POST",n="/api/v1/hints";t.id&&(o="PATCH",n="/api/v1/hints/"+t.id);a.default.fetch(n,{method:o,credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){e.success&&window.location.reload()})};var s=i(o("./node_modules/jquery/dist/jquery.js")),a=i(o("./CTFd/themes/core/assets/js/CTFd.js")),n=o("./CTFd/themes/core/assets/js/ezq.js");function i(e){return e&&e.__esModule?e:{default:e}}},"./CTFd/themes/admin/assets/js/challenges/requirements.js":function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.addRequirement=function(e){e.preventDefault();var t=(0,s.default)("#prerequisite-add-form").serializeJSON();if(!t.prerequisite)return;CHALLENGE_REQUIREMENTS.prerequisites.push(parseInt(t.prerequisite));var o={requirements:CHALLENGE_REQUIREMENTS};a.default.fetch("/api/v1/challenges/"+CHALLENGE_ID,{method:"PATCH",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(o)}).then(function(e){return e.json()}).then(function(e){e.success&&window.location.reload()})},t.deleteRequirement=function(e){var t=(0,s.default)(this).attr("challenge-id"),o=(0,s.default)(this).parent().parent();CHALLENGE_REQUIREMENTS.prerequisites.pop(t);var n={requirements:CHALLENGE_REQUIREMENTS};a.default.fetch("/api/v1/challenges/"+CHALLENGE_ID,{method:"PATCH",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(n)}).then(function(e){return e.json()}).then(function(e){e.success&&o.remove()})};var s=n(o("./node_modules/jquery/dist/jquery.js")),a=n(o("./CTFd/themes/core/assets/js/CTFd.js"));function n(e){return e&&e.__esModule?e:{default:e}}},"./CTFd/themes/admin/assets/js/challenges/tags.js":function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.deleteTag=i,t.addTag=function(e){if(13!=e.keyCode)return;var t=(0,n.default)(this),o={value:t.val(),challenge:CHALLENGE_ID};s.default.api.post_tag_list({},o).then(function(e){if(e.success){var t=(0,n.default)("{0}×".format(e.data.value,e.data.id));(0,n.default)("#challenge-tags").append(t),t.click(i)}}),t.val("")};var n=a(o("./node_modules/jquery/dist/jquery.js")),s=a(o("./CTFd/themes/core/assets/js/CTFd.js"));function a(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=(0,n.default)(this),o=t.attr("tag-id");s.default.api.delete_tag({tagId:o}).then(function(e){e.success&&t.parent().remove()})}},"./CTFd/themes/admin/assets/js/pages/challenge.js":function(e,t,o){o("./CTFd/themes/admin/assets/js/pages/main.js");var n=o("./CTFd/themes/core/assets/js/utils.js"),l=f(o("./node_modules/jquery/dist/jquery.js"));o("./node_modules/bootstrap/js/dist/tab.js");var i=f(o("./CTFd/themes/core/assets/js/CTFd.js")),s=o("./CTFd/themes/core/assets/js/ezq.js"),a=f(o("./node_modules/nunjucks/browser/nunjucks.js")),d=f(o("./CTFd/themes/core/assets/js/helpers.js")),r=o("./CTFd/themes/admin/assets/js/challenges/files.js"),c=o("./CTFd/themes/admin/assets/js/challenges/tags.js"),u=o("./CTFd/themes/admin/assets/js/challenges/requirements.js"),m=o("./CTFd/themes/admin/assets/js/challenges/hints.js"),p=o("./CTFd/themes/admin/assets/js/challenges/flags.js");function f(e){return e&&e.__esModule?e:{default:e}}function h(t){i.default.api.get_hint({hintId:t,preview:!0}).then(function(e){e.data.content?function(e){(0,s.ezAlert)({title:"Hint",body:j.render(e.content),button:"Got it!"})}(e.data):displayUnlock(t)})}var j=i.default.lib.markdown();function _(e,t){var o=e.data,n=(0,l.default)("#result-message"),s=(0,l.default)("#result-notification"),a=(0,l.default)("#submission-input");s.removeClass(),n.text(o.message),"authentication_required"!==o.status?("incorrect"===o.status?(s.addClass("alert alert-danger alert-dismissable text-center"),s.slideDown(),a.removeClass("correct"),a.addClass("wrong"),setTimeout(function(){a.removeClass("wrong")},3e3)):"correct"===o.status?(s.addClass("alert alert-success alert-dismissable text-center"),s.slideDown(),(0,l.default)(".challenge-solves").text(parseInt((0,l.default)(".challenge-solves").text().split(" ")[0])+1+" Solves"),a.val(""),a.removeClass("wrong"),a.addClass("correct")):"already_solved"===o.status?(s.addClass("alert alert-info alert-dismissable text-center"),s.slideDown(),a.addClass("correct")):"paused"===o.status?(s.addClass("alert alert-warning alert-dismissable text-center"),s.slideDown()):"ratelimited"===o.status&&(s.addClass("alert alert-warning alert-dismissable text-center"),s.slideDown(),a.addClass("too-fast"),setTimeout(function(){a.removeClass("too-fast")},3e3)),setTimeout(function(){(0,l.default)(".alert").slideUp(),(0,l.default)("#submit-key").removeClass("disabled-button"),(0,l.default)("#submit-key").prop("disabled",!1)},3e3),t&&t(o)):window.location=i.default.config.urlRoot+"/login?next="+i.default.config.urlRoot+window.location.pathname+window.location.hash}function g(o){i.default._internal.challenge={},l.default.getScript(i.default.config.urlRoot+o.scripts.view,function(){l.default.get(i.default.config.urlRoot+o.templates.create,function(e){var t=a.default.compile(e);(0,l.default)("#create-chal-entry-div").html(t.render({nonce:i.default.config.csrfNonce,script_root:i.default.config.urlRoot})),l.default.getScript(i.default.config.urlRoot+o.scripts.create,function(){(0,l.default)("#create-chal-entry-div form").submit(function(e){e.preventDefault();var t=(0,l.default)("#create-chal-entry-div form").serializeJSON();i.default.fetch("/api/v1/challenges",{method:"POST",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){e.success&&((0,l.default)("#challenge-create-options #challenge_id").val(e.data.id),(0,l.default)("#challenge-create-options").modal())})})})})})}function v(s){s.preventDefault();var a=(0,l.default)(s.target).serializeJSON(!0),o={challenge_id:a.challenge_id,content:a.flag||"",type:a.flag_type,data:a.flag_data?a.flag_data:""};Promise.all([new Promise(function(t,e){0!=o.content.length?i.default.fetch("/api/v1/flags",{method:"POST",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(o)}).then(function(e){t(e.json())}):t()}),new Promise(function(e,t){var o=s.target,n={challenge:a.challenge_id,type:"challenge"};(0,l.default)(o.elements.file).val()&&d.default.files.upload(o,n),e()})]).then(function(e){i.default.fetch("/api/v1/challenges/"+a.challenge_id,{method:"PATCH",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({state:a.state})}).then(function(e){return e.json()}).then(function(e){e.success&&setTimeout(function(){window.location=i.default.config.urlRoot+"/admin/challenges/"+a.challenge_id},700)})})}function y(e){var t=(0,l.default)(this).find("option:selected").data("meta");void 0!==t?g(t):(0,l.default)("#create-chal-entry-div").empty()}(0,l.default)(function(){if((0,l.default)(".preview-challenge").click(function(e){window.challenge=new Object,i.default._internal.challenge={},l.default.get(i.default.config.urlRoot+"/api/v1/challenges/"+CHALLENGE_ID,function(e){var o=i.default._internal.challenge,n=e.data;n.solves=null,l.default.getScript(i.default.config.urlRoot+n.type_data.scripts.view,function(){l.default.get(i.default.config.urlRoot+n.type_data.templates.view,function(e){(0,l.default)("#challenge-window").empty();var t=a.default.compile(e);o.data=n,o.preRender(),n.description=o.render(n.description),n.script_root=i.default.config.urlRoot,(0,l.default)("#challenge-window").append(t.render(n)),(0,l.default)(".challenge-solves").click(function(e){getsolves((0,l.default)("#challenge-id").val())}),(0,l.default)(".nav-tabs a").click(function(e){e.preventDefault(),(0,l.default)(this).tab("show")}),(0,l.default)("#challenge-window").on("hide.bs.modal",function(e){(0,l.default)("#submission-input").removeClass("wrong"),(0,l.default)("#submission-input").removeClass("correct"),(0,l.default)("#incorrect-key").slideUp(),(0,l.default)("#correct-key").slideUp(),(0,l.default)("#already-solved").slideUp(),(0,l.default)("#too-fast").slideUp()}),(0,l.default)(".load-hint").on("click",function(e){h((0,l.default)(this).data("hint-id"))}),(0,l.default)("#submit-key").click(function(e){e.preventDefault(),(0,l.default)("#submit-key").addClass("disabled-button"),(0,l.default)("#submit-key").prop("disabled",!0),i.default._internal.challenge.submit(!0).then(_)}),(0,l.default)("#submission-input").keyup(function(e){13==e.keyCode&&(0,l.default)("#submit-key").click()}),(0,l.default)(".input-field").bind({focus:function(){(0,l.default)(this).parent().addClass("input--filled"),$label=(0,l.default)(this).siblings(".input-label")},blur:function(){""===(0,l.default)(this).val()&&((0,l.default)(this).parent().removeClass("input--filled"),$label=(0,l.default)(this).siblings(".input-label"),$label.removeClass("input--hide"))}}),o.postRender(),window.location.replace(window.location.href.split("#")[0]+"#preview"),(0,l.default)("#challenge-window").modal()})})})}),(0,l.default)(".delete-challenge").click(function(e){(0,s.ezQuery)({title:"Delete Challenge",body:"Are you sure you want to delete {0}".format(""+(0,n.htmlEntities)(CHALLENGE_NAME)+""),success:function(){i.default.fetch("/api/v1/challenges/"+CHALLENGE_ID,{method:"DELETE"}).then(function(e){return e.json()}).then(function(e){e.success&&(window.location=i.default.config.urlRoot+"/admin/challenges")})}})}),(0,l.default)("#challenge-update-container > form").submit(function(e){e.preventDefault();var o=(0,l.default)(e.target).serializeJSON(!0);i.default.fetch("/api/v1/challenges/"+CHALLENGE_ID+"/flags",{method:"GET",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(e){return e.json()}).then(function(e){function t(){i.default.fetch("/api/v1/challenges/"+CHALLENGE_ID,{method:"PATCH",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(o)}).then(function(e){return e.json()}).then(function(e){if(e.success){switch((0,l.default)(".challenge-state").text(e.data.state),e.data.state){case"visible":(0,l.default)(".challenge-state").removeClass("badge-danger").addClass("badge-success");break;case"hidden":(0,l.default)(".challenge-state").removeClass("badge-success").addClass("badge-danger")}(0,s.ezToast)({title:"Success",body:"Your challenge has been updated!"})}})}0===e.data.length&&"visible"===o.state?(0,s.ezQuery)({title:"Missing Flags",body:"This challenge does not have any flags meaning it is unsolveable. Are you sure you'd like to update this challenge?",success:t}):t()})}),(0,l.default)("#challenge-create-options form").submit(v),(0,l.default)(".nav-tabs a").click(function(e){(0,l.default)(this).tab("show"),window.location.hash=this.hash}),window.location.hash){var e=window.location.hash.replace("<>[]'\"","");(0,l.default)('nav a[href="'+e+'"]').tab("show")}(0,l.default)("#tags-add-input").keyup(c.addTag),(0,l.default)(".delete-tag").click(c.deleteTag),(0,l.default)("#prerequisite-add-form").submit(u.addRequirement),(0,l.default)(".delete-requirement").click(u.deleteRequirement),(0,l.default)("#file-add-form").submit(r.addFile),(0,l.default)(".delete-file").click(r.deleteFile),(0,l.default)("#hint-add-button").click(m.showHintModal),(0,l.default)(".delete-hint").click(m.deleteHint),(0,l.default)(".edit-hint").click(m.showEditHintModal),(0,l.default)("#hint-edit-form").submit(m.editHint),(0,l.default)("#flag-add-button").click(p.addFlagModal),(0,l.default)(".delete-flag").click(p.deleteFlag),(0,l.default)("#flags-create-select").change(p.flagTypeSelect),(0,l.default)(".edit-flag").click(p.editFlagModal),l.default.get(i.default.config.urlRoot+"/api/v1/challenges/types",function(e){(0,l.default)("#create-chals-select").empty();var t=e.data,o=Object.keys(t).length;if(1 -- "),t){var s=t[n],a=(0,l.default)("