mirror of https://github.com/JohnHammond/CTFd.git
Use sessionStorage to store most recently used tabs instead of the location hash
parent
494052fb44
commit
0ff9d142f7
|
@ -220,14 +220,4 @@ $(() => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (window.location.hash) {
|
|
||||||
let hash = window.location.hash.replace("<>[]'\"", "");
|
|
||||||
$('nav a[href="' + hash + '"]').tab("show");
|
|
||||||
}
|
|
||||||
|
|
||||||
$(".nav-tabs a").click(function(event) {
|
|
||||||
$(this).tab("show");
|
|
||||||
window.location.hash = this.hash;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -447,16 +447,6 @@ $(() => {
|
||||||
|
|
||||||
$("#challenge-create-options form").submit(handleChallengeOptions);
|
$("#challenge-create-options form").submit(handleChallengeOptions);
|
||||||
|
|
||||||
$(".nav-tabs a").click(function(e) {
|
|
||||||
$(this).tab("show");
|
|
||||||
window.location.hash = this.hash;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (window.location.hash) {
|
|
||||||
let hash = window.location.hash.replace("<>[]'\"", "");
|
|
||||||
$('nav a[href="' + hash + '"]').tab("show");
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#tags-add-input").keyup(addTag);
|
$("#tags-add-input").keyup(addTag);
|
||||||
$(".delete-tag").click(deleteTag);
|
$(".delete-tag").click(deleteTag);
|
||||||
|
|
||||||
|
|
|
@ -220,10 +220,6 @@ function exportConfig(event) {
|
||||||
window.location.href = $(this).attr("href");
|
window.location.href = $(this).attr("href");
|
||||||
}
|
}
|
||||||
|
|
||||||
function showTab(event) {
|
|
||||||
window.location.hash = this.hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
function insertTimezones(target) {
|
function insertTimezones(target) {
|
||||||
let current = $("<option>").text(moment.tz.guess());
|
let current = $("<option>").text(moment.tz.guess());
|
||||||
$(target).append(current);
|
$(target).append(current);
|
||||||
|
@ -258,7 +254,6 @@ $(() => {
|
||||||
$("#remove-logo").click(removeLogo);
|
$("#remove-logo").click(removeLogo);
|
||||||
$("#export-button").click(exportConfig);
|
$("#export-button").click(exportConfig);
|
||||||
$("#import-button").click(importConfig);
|
$("#import-button").click(importConfig);
|
||||||
$(".nav-pills a").click(showTab);
|
|
||||||
$("#config-color-update").click(function() {
|
$("#config-color-update").click(function() {
|
||||||
const hex_code = $("#config-color-picker").val();
|
const hex_code = $("#config-color-picker").val();
|
||||||
const user_css = $("#theme-header").val();
|
const user_css = $("#theme-header").val();
|
||||||
|
@ -287,12 +282,6 @@ $(() => {
|
||||||
loadDateValues("freeze");
|
loadDateValues("freeze");
|
||||||
});
|
});
|
||||||
|
|
||||||
let hash = window.location.hash;
|
|
||||||
if (hash) {
|
|
||||||
hash = hash.replace("<>[]'\"", "");
|
|
||||||
$('ul.nav a[href="' + hash + '"]').tab("show");
|
|
||||||
}
|
|
||||||
|
|
||||||
const start = $("#start").val();
|
const start = $("#start").val();
|
||||||
const end = $("#end").val();
|
const end = $("#end").val();
|
||||||
const freeze = $("#freeze").val();
|
const freeze = $("#freeze").val();
|
||||||
|
|
|
@ -163,7 +163,7 @@ function solveSelectedMissingChallenges(event) {
|
||||||
title: `Mark Correct`,
|
title: `Mark Correct`,
|
||||||
body: `Are you sure you want to mark ${
|
body: `Are you sure you want to mark ${
|
||||||
challengeIDs.length
|
challengeIDs.length
|
||||||
} correct for ${htmlEntities(TEAM_NAME)}?`,
|
} challenges correct for ${htmlEntities(TEAM_NAME)}?`,
|
||||||
success: function() {
|
success: function() {
|
||||||
ezAlert({
|
ezAlert({
|
||||||
title: `User Attribution`,
|
title: `User Attribution`,
|
||||||
|
|
|
@ -80,6 +80,20 @@ export default () => {
|
||||||
window.location.href = url.toString();
|
window.location.href = url.toString();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||||
|
sessionStorage.setItem('activeTab', $(e.target).attr('href'));
|
||||||
|
});
|
||||||
|
|
||||||
|
let activeTab = sessionStorage.getItem('activeTab');
|
||||||
|
if (activeTab) {
|
||||||
|
let target = $(`.nav-tabs a[href="${activeTab}"], .nav-pills a[href="${activeTab}"]`);
|
||||||
|
if (target.length) {
|
||||||
|
target.tab('show');
|
||||||
|
} else {
|
||||||
|
sessionStorage.removeItem('activeTab');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
makeSortableTables();
|
makeSortableTables();
|
||||||
$('[data-toggle="tooltip"]').tooltip();
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@ eval("\n\nvar _CTFd = _interopRequireDefault(__webpack_require__(/*! core/CTFd *
|
||||||
/***/ (function(module, exports, __webpack_require__) {
|
/***/ (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)(\"[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, _jquery.default)(\".page-select\").change(function () {\n var url = new URL(window.location);\n url.searchParams.set(\"page\", this.value);\n window.location.href = url.toString();\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, _jquery.default)(\".page-select\").change(function () {\n var url = new URL(window.location);\n url.searchParams.set(\"page\", this.value);\n window.location.href = url.toString();\n });\n (0, _jquery.default)('a[data-toggle=\"tab\"]').on('shown.bs.tab', function (e) {\n sessionStorage.setItem('activeTab', (0, _jquery.default)(e.target).attr('href'));\n });\n var activeTab = sessionStorage.getItem('activeTab');\n\n if (activeTab) {\n var target = (0, _jquery.default)(\".nav-tabs a[href=\\\"\".concat(activeTab, \"\\\"], .nav-pills a[href=\\\"\").concat(activeTab, \"\\\"]\"));\n\n if (target.length) {\n target.tab('show');\n } else {\n sessionStorage.removeItem('activeTab');\n }\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?");
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue