diff --git a/class/Game.php b/class/Game.php index f8535b2..2ab023e 100644 --- a/class/Game.php +++ b/class/Game.php @@ -430,8 +430,12 @@ class Game extends AutoStoring // obfuscate image filename if ($a["image_data"] !== "") { - $a["image_data"] = $this->obfuscateAttachedImage($a["image_data"]); - $a["image_type"] = "url"; + if (in_array("codeimage", $flags)) { + $a["image_type"] = "code"; + } else { + $a["image_data"] = $this->obfuscateAttachedImage($a["image_data"]); + $a["image_type"] = "url"; + } } // generate the task diff --git a/class/Tasks/PicturedTask.php b/class/Tasks/PicturedTask.php index e572e76..6018dbe 100644 --- a/class/Tasks/PicturedTask.php +++ b/class/Tasks/PicturedTask.php @@ -10,6 +10,7 @@ class PicturedTask extends Task function __construct(string $type, array &$a = null) { parent::__construct($type, $a); + $this->image_data = $a["image_data"] ?? ($a["image_url"] ?? ""); $this->image_type = $a["image_type"] ?? "none"; } diff --git a/js/tasks.js b/js/tasks.js index 7e780cf..5cc0737 100644 --- a/js/tasks.js +++ b/js/tasks.js @@ -283,11 +283,27 @@ class PicturedTask extends Task { } break; case "html": + case "code": { this.img = document.createElement("section"); this.img.classList.add("question-image"); - this.img.innerHTML = data; + + if (this.img_type === "html") { + this.img.innerHTML = data; + } else if (this.img_type === "code") { + let pre = document.createElement("pre"); + let code = document.createElement("code"); + pre.append(code); + code.innerHTML = data; + hljs.highlightElement(pre); + + this.img.innerHTML = ``; + this.img.style.textAlign = "left"; + this.img.append(pre); + } + } + break; } diff --git a/testground.php b/testground.php index 1f1ea41..85dda5d 100644 --- a/testground.php +++ b/testground.php @@ -37,6 +37,9 @@ if ($testid === "") { + + +