mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 05:54:19 +01:00
Closes: #2103
This commit is contained in:
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
@@ -1,10 +1,13 @@
|
||||
import $ from "jquery";
|
||||
import dayjs from "dayjs";
|
||||
import MarkdownIt from "markdown-it";
|
||||
|
||||
import "./patch";
|
||||
import fetch from "./fetch";
|
||||
import config from "./config";
|
||||
import { API } from "./api";
|
||||
import "./patch";
|
||||
import MarkdownIt from "markdown-it";
|
||||
import $ from "jquery";
|
||||
import ezq from "./ezq";
|
||||
import { getScript, htmlEntities, createHtmlNode } from "./utils";
|
||||
|
||||
const api = new API("/");
|
||||
const user = {};
|
||||
@@ -14,7 +17,8 @@ const ui = {
|
||||
};
|
||||
const lib = {
|
||||
$,
|
||||
markdown
|
||||
markdown,
|
||||
dayjs
|
||||
};
|
||||
|
||||
let initialized = false;
|
||||
@@ -46,12 +50,23 @@ function markdown(config) {
|
||||
return md;
|
||||
}
|
||||
|
||||
const utils = {
|
||||
ajax: {
|
||||
getScript
|
||||
},
|
||||
html: {
|
||||
createHtmlNode,
|
||||
htmlEntities
|
||||
}
|
||||
};
|
||||
|
||||
const CTFd = {
|
||||
init,
|
||||
config,
|
||||
fetch,
|
||||
user,
|
||||
ui,
|
||||
utils,
|
||||
api,
|
||||
lib,
|
||||
_internal,
|
||||
|
||||
@@ -193,12 +193,6 @@ export function colorHash(str) {
|
||||
return `hsl(${h}, ${s}%, ${l}%)`;
|
||||
}
|
||||
|
||||
export function htmlEntities(string) {
|
||||
return $("<div/>")
|
||||
.text(string)
|
||||
.html();
|
||||
}
|
||||
|
||||
export function cumulativeSum(arr) {
|
||||
let result = arr.concat();
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
@@ -303,3 +297,28 @@ export function makeSortableTables() {
|
||||
.text();
|
||||
}
|
||||
}
|
||||
|
||||
export function getScript(src) {
|
||||
const p = new Promise((resolve, reject) => {
|
||||
const script = document.createElement("script");
|
||||
document.body.appendChild(script);
|
||||
script.onload = resolve;
|
||||
script.onerror = reject;
|
||||
script.async = true;
|
||||
script.src = src;
|
||||
});
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
export function createHtmlNode(html) {
|
||||
const template = document.createElement("template");
|
||||
template.innerHTML = html.trim();
|
||||
return template.content.firstChild;
|
||||
}
|
||||
|
||||
export function htmlEntities(string) {
|
||||
return $("<div/>")
|
||||
.text(string)
|
||||
.html();
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
CTFd/themes/core/static/js/pages/main.min.js
vendored
2
CTFd/themes/core/static/js/pages/main.min.js
vendored
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
@@ -32,7 +32,7 @@
|
||||
"bootstrap-multimodal": "~1.0.4",
|
||||
"codemirror": "~5.58.2",
|
||||
"css-loader": "^3.6.0",
|
||||
"dayjs": "^1.9.6",
|
||||
"dayjs": "^1.11.1",
|
||||
"easymde": "^2.10.1",
|
||||
"echarts": "^4.8.0",
|
||||
"eslint": "~5.12.0",
|
||||
|
||||
@@ -2146,10 +2146,10 @@ date-now@^0.1.4:
|
||||
resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"
|
||||
integrity sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=
|
||||
|
||||
dayjs@^1.9.6:
|
||||
version "1.9.6"
|
||||
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.9.6.tgz#6f0c77d76ac1ff63720dd1197e5cb87b67943d70"
|
||||
integrity sha512-HngNLtPEBWRo8EFVmHFmSXAjtCX8rGNqeXQI0Gh7wCTSqwaKgPIDqu9m07wABVopNwzvOeCb+2711vQhDlcIXw==
|
||||
dayjs@^1.11.1:
|
||||
version "1.11.1"
|
||||
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.1.tgz#90b33a3dda3417258d48ad2771b415def6545eb0"
|
||||
integrity sha512-ER7EjqVAMkRRsxNCC5YqJ9d9VQYuWdGt7aiH2qA5R5wt8ZmWaP2dLUSIK6y/kVzLMlmh1Tvu5xUf4M/wdGJ5KA==
|
||||
|
||||
de-indent@^1.0.2:
|
||||
version "1.0.2"
|
||||
|
||||
Reference in New Issue
Block a user