Fix issue with previewing some challenge plugins (#1579)

This commit is contained in:
Kevin Chung
2020-08-03 18:16:02 -04:00
committed by GitHub
parent 08f2f810fe
commit 324fdeda4a
3 changed files with 11 additions and 4 deletions

View File

@@ -237,20 +237,27 @@ function handleChallengeOptions(event) {
$(() => {
$(".preview-challenge").click(function(_e) {
window.challenge = new Object();
CTFd._internal.challenge = {};
$.get(
CTFd.config.urlRoot + "/api/v1/challenges/" + window.CHALLENGE_ID,
function(response) {
const challenge = CTFd._internal.challenge;
// Preview should not show any solves
var challenge_data = response.data;
challenge_data["solves"] = null;
$.getScript(
CTFd.config.urlRoot + challenge_data.type_data.scripts.view,
function() {
const challenge = CTFd._internal.challenge;
// Inject challenge data into the plugin
challenge.data = response.data;
$("#challenge-window").empty();
// Call preRender function in plugin
challenge.preRender();
$("#challenge-window").append(challenge_data.view);
$("#challenge-window #challenge-input").addClass("form-control");

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long