From 2f46f61ed049100a4bef8205d7cded974f13a629 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Sat, 29 Feb 2020 15:21:22 -0500 Subject: [PATCH] Fix ezq toast timeout and fix yarn build command for Python 3 (#1266) * Fix `ezToast()` timeout * Force `yarn build` to use Python 3 * Closes #1265 --- CTFd/themes/admin/static/js/core.dev.js | 2 +- CTFd/themes/admin/static/js/pages/challenge.min.js | 2 +- CTFd/themes/admin/static/js/pages/configs.min.js | 2 +- CTFd/themes/admin/static/js/pages/editor.min.js | 2 +- CTFd/themes/admin/static/js/pages/main.min.js | 2 +- CTFd/themes/admin/static/js/pages/notifications.min.js | 2 +- CTFd/themes/admin/static/js/pages/pages.min.js | 2 +- CTFd/themes/admin/static/js/pages/reset.min.js | 2 +- CTFd/themes/admin/static/js/pages/scoreboard.min.js | 2 +- CTFd/themes/admin/static/js/pages/statistics.min.js | 2 +- CTFd/themes/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 +- CTFd/themes/admin/static/js/pages/users.min.js | 2 +- CTFd/themes/core/assets/js/ezq.js | 6 ++++-- CTFd/themes/core/static/js/core.dev.js | 2 +- CTFd/themes/core/static/js/pages/challenges.min.js | 2 +- CTFd/themes/core/static/js/pages/main.min.js | 2 +- CTFd/themes/core/static/js/pages/notifications.min.js | 2 +- CTFd/themes/core/static/js/pages/scoreboard.min.js | 2 +- CTFd/themes/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 +- CTFd/themes/core/static/js/pages/teams/private.min.js | 2 +- webpack.config.js | 2 +- 25 files changed, 28 insertions(+), 26 deletions(-) diff --git a/CTFd/themes/admin/static/js/core.dev.js b/CTFd/themes/admin/static/js/core.dev.js index 8b7c6f5..5a4b83e 100644 --- a/CTFd/themes/admin/static/js/core.dev.js +++ b/CTFd/themes/admin/static/js/core.dev.js @@ -80,7 +80,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n /***/ (function(module, exports, __webpack_require__) { ; -eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.ezAlert = ezAlert;\nexports.ezToast = ezToast;\nexports.ezQuery = ezQuery;\nexports.ezProgressBar = ezProgressBar;\nexports.ezBadge = ezBadge;\nexports.default = void 0;\n\n__webpack_require__(/*! bootstrap/js/dist/modal */ \"./node_modules/bootstrap/js/dist/modal.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 modalTpl = '
' + '
' + '
' + '
' + '
{0}
' + ' \" + \"
\" + '
' + \"
\" + '
' + \"
\" + \"
\" + \"
\" + \"
\";\nvar toastTpl = '
' + '
' + ' {0}' + ' \" + \"
\" + '
{1}
' + \"
\";\nvar progressTpl = '
' + '
' + \"
\" + \"
\";\nvar errorTpl = '
\\n' + ' Error:\\n' + \" {0}\\n\" + ' \\n' + \"
\";\nvar successTpl = '
\\n' + \" Success!\\n\" + \" {0}\\n\" + ' \\n' + \"
\";\nvar buttonTpl = '';\nvar noTpl = '';\nvar yesTpl = '';\n\nfunction ezAlert(args) {\n var modal = modalTpl.format(args.title, args.body);\n var obj = (0, _jquery.default)(modal);\n\n if (typeof args.body === \"string\") {\n obj.find(\".modal-body\").append(\"

\".concat(args.body, \"

\"));\n } else {\n obj.find(\".modal-body\").append((0, _jquery.default)(args.body));\n }\n\n var button = (0, _jquery.default)(buttonTpl.format(args.button));\n\n if (args.success) {\n (0, _jquery.default)(button).click(function () {\n args.success();\n });\n }\n\n if (args.large) {\n obj.find(\".modal-dialog\").addClass(\"modal-lg\");\n }\n\n obj.find(\".modal-footer\").append(button);\n (0, _jquery.default)(\"main\").append(obj);\n obj.modal(\"show\");\n (0, _jquery.default)(obj).on(\"hidden.bs.modal\", function () {\n (0, _jquery.default)(this).modal(\"dispose\");\n });\n return obj;\n}\n\nfunction ezToast(args) {\n var container_available = (0, _jquery.default)(\"#ezq--notifications-toast-container\").length;\n\n if (!container_available) {\n (0, _jquery.default)(\"body\").append((0, _jquery.default)(\"
\").attr({\n id: \"ezq--notifications-toast-container\"\n }).css({\n position: \"fixed\",\n bottom: \"0\",\n right: \"0\",\n \"min-width\": \"20%\"\n }));\n }\n\n var res = toastTpl.format(args.title, args.body);\n var obj = (0, _jquery.default)(res);\n\n if (args.onclose) {\n (0, _jquery.default)(obj).find(\"button[data-dismiss=toast]\").click(function () {\n args.onclose();\n });\n }\n\n if (args.onclick) {\n var body = (0, _jquery.default)(obj).find(\".toast-body\");\n body.addClass(\"cursor-pointer\");\n body.click(function () {\n args.onclick();\n });\n }\n\n var autohide = args.autohide || false;\n var delay = args.delay || 10000; // 10 seconds\n\n (0, _jquery.default)(\"#ezq--notifications-toast-container\").prepend(obj);\n obj.toast({\n autohide: autohide,\n delay: delay\n });\n obj.toast(\"show\");\n return obj;\n}\n\nfunction ezQuery(args) {\n var modal = modalTpl.format(args.title, args.body);\n var obj = (0, _jquery.default)(modal);\n\n if (typeof args.body === \"string\") {\n obj.find(\".modal-body\").append(\"

\".concat(args.body, \"

\"));\n } else {\n obj.find(\".modal-body\").append((0, _jquery.default)(args.body));\n }\n\n var yes = (0, _jquery.default)(yesTpl);\n var no = (0, _jquery.default)(noTpl);\n obj.find(\".modal-footer\").append(no);\n obj.find(\".modal-footer\").append(yes);\n (0, _jquery.default)(\"main\").append(obj);\n (0, _jquery.default)(obj).on(\"hidden.bs.modal\", function () {\n (0, _jquery.default)(this).modal(\"dispose\");\n });\n (0, _jquery.default)(yes).click(function () {\n args.success();\n });\n obj.modal(\"show\");\n return obj;\n}\n\nfunction ezProgressBar(args) {\n if (args.target) {\n var _obj = (0, _jquery.default)(args.target);\n\n var pbar = _obj.find(\".progress-bar\");\n\n pbar.css(\"width\", args.width + \"%\");\n return _obj;\n }\n\n var progress = progressTpl.format(args.width);\n var modal = modalTpl.format(args.title, progress);\n var obj = (0, _jquery.default)(modal);\n (0, _jquery.default)(\"main\").append(obj);\n return obj.modal(\"show\");\n}\n\nfunction ezBadge(args) {\n var mapping = {\n success: successTpl,\n error: errorTpl\n };\n var tpl = mapping[args.type].format(args.body);\n return (0, _jquery.default)(tpl);\n}\n\nvar ezq = {\n ezAlert: ezAlert,\n ezToast: ezToast,\n ezQuery: ezQuery,\n ezProgressBar: ezProgressBar,\n ezBadge: ezBadge\n};\nvar _default = ezq;\nexports.default = _default;\n\n//# sourceURL=webpack:///./CTFd/themes/core/assets/js/ezq.js?"); +eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.ezAlert = ezAlert;\nexports.ezToast = ezToast;\nexports.ezQuery = ezQuery;\nexports.ezProgressBar = ezProgressBar;\nexports.ezBadge = ezBadge;\nexports.default = void 0;\n\n__webpack_require__(/*! bootstrap/js/dist/modal */ \"./node_modules/bootstrap/js/dist/modal.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 modalTpl = '
' + '
' + '
' + '
' + '
{0}
' + ' \" + \"
\" + '
' + \"
\" + '
' + \"
\" + \"
\" + \"
\" + \"
\";\nvar toastTpl = '
' + '
' + ' {0}' + ' \" + \"
\" + '
{1}
' + \"
\";\nvar progressTpl = '
' + '
' + \"
\" + \"
\";\nvar errorTpl = '
\\n' + ' Error:\\n' + \" {0}\\n\" + ' \\n' + \"
\";\nvar successTpl = '
\\n' + \" Success!\\n\" + \" {0}\\n\" + ' \\n' + \"
\";\nvar buttonTpl = '';\nvar noTpl = '';\nvar yesTpl = '';\n\nfunction ezAlert(args) {\n var modal = modalTpl.format(args.title, args.body);\n var obj = (0, _jquery.default)(modal);\n\n if (typeof args.body === \"string\") {\n obj.find(\".modal-body\").append(\"

\".concat(args.body, \"

\"));\n } else {\n obj.find(\".modal-body\").append((0, _jquery.default)(args.body));\n }\n\n var button = (0, _jquery.default)(buttonTpl.format(args.button));\n\n if (args.success) {\n (0, _jquery.default)(button).click(function () {\n args.success();\n });\n }\n\n if (args.large) {\n obj.find(\".modal-dialog\").addClass(\"modal-lg\");\n }\n\n obj.find(\".modal-footer\").append(button);\n (0, _jquery.default)(\"main\").append(obj);\n obj.modal(\"show\");\n (0, _jquery.default)(obj).on(\"hidden.bs.modal\", function () {\n (0, _jquery.default)(this).modal(\"dispose\");\n });\n return obj;\n}\n\nfunction ezToast(args) {\n var container_available = (0, _jquery.default)(\"#ezq--notifications-toast-container\").length;\n\n if (!container_available) {\n (0, _jquery.default)(\"body\").append((0, _jquery.default)(\"
\").attr({\n id: \"ezq--notifications-toast-container\"\n }).css({\n position: \"fixed\",\n bottom: \"0\",\n right: \"0\",\n \"min-width\": \"20%\"\n }));\n }\n\n var res = toastTpl.format(args.title, args.body);\n var obj = (0, _jquery.default)(res);\n\n if (args.onclose) {\n (0, _jquery.default)(obj).find(\"button[data-dismiss=toast]\").click(function () {\n args.onclose();\n });\n }\n\n if (args.onclick) {\n var body = (0, _jquery.default)(obj).find(\".toast-body\");\n body.addClass(\"cursor-pointer\");\n body.click(function () {\n args.onclick();\n });\n }\n\n var autohide = args.autohide !== false;\n var animation = args.animation !== false;\n var delay = args.delay || 10000; // 10 seconds\n\n (0, _jquery.default)(\"#ezq--notifications-toast-container\").prepend(obj);\n obj.toast({\n autohide: autohide,\n delay: delay,\n animation: animation\n });\n obj.toast(\"show\");\n return obj;\n}\n\nfunction ezQuery(args) {\n var modal = modalTpl.format(args.title, args.body);\n var obj = (0, _jquery.default)(modal);\n\n if (typeof args.body === \"string\") {\n obj.find(\".modal-body\").append(\"

\".concat(args.body, \"

\"));\n } else {\n obj.find(\".modal-body\").append((0, _jquery.default)(args.body));\n }\n\n var yes = (0, _jquery.default)(yesTpl);\n var no = (0, _jquery.default)(noTpl);\n obj.find(\".modal-footer\").append(no);\n obj.find(\".modal-footer\").append(yes);\n (0, _jquery.default)(\"main\").append(obj);\n (0, _jquery.default)(obj).on(\"hidden.bs.modal\", function () {\n (0, _jquery.default)(this).modal(\"dispose\");\n });\n (0, _jquery.default)(yes).click(function () {\n args.success();\n });\n obj.modal(\"show\");\n return obj;\n}\n\nfunction ezProgressBar(args) {\n if (args.target) {\n var _obj = (0, _jquery.default)(args.target);\n\n var pbar = _obj.find(\".progress-bar\");\n\n pbar.css(\"width\", args.width + \"%\");\n return _obj;\n }\n\n var progress = progressTpl.format(args.width);\n var modal = modalTpl.format(args.title, progress);\n var obj = (0, _jquery.default)(modal);\n (0, _jquery.default)(\"main\").append(obj);\n return obj.modal(\"show\");\n}\n\nfunction ezBadge(args) {\n var mapping = {\n success: successTpl,\n error: errorTpl\n };\n var tpl = mapping[args.type].format(args.body);\n return (0, _jquery.default)(tpl);\n}\n\nvar ezq = {\n ezAlert: ezAlert,\n ezToast: ezToast,\n ezQuery: ezQuery,\n ezProgressBar: ezProgressBar,\n ezBadge: ezBadge\n};\nvar _default = ezq;\nexports.default = _default;\n\n//# sourceURL=webpack:///./CTFd/themes/core/assets/js/ezq.js?"); /***/ }), diff --git a/CTFd/themes/admin/static/js/pages/challenge.min.js b/CTFd/themes/admin/static/js/pages/challenge.min.js index ac5b2ee..e0290ea 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 j(t){i.default.api.get_hint({hintId:t,preview:!0}).then(function(e){e.data.content?function(e){(0,s.ezAlert)({title:"Hint",body:h.render(e.content),button:"Got it!"})}(e.data):displayUnlock(t)})}var h=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){j((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){e.success&&(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)("