Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Girgias committed Dec 5, 2024
1 parent 5bf392d commit 46b1e1f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions js/interactive-examples.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import phpBinary from "/js/php-web.mjs";

function generateExampleOutputTitle(phpVersion) {
return "Output of the above example in PHP "+ phpVersion +":";
}

function createOutput(output) {
const container = document.createElement("div");
container.classList.add("screen", "example-contents");
const title = document.createElement("p");
title.innerText = "Output of the above example in PHP "+ PHP.version +":";
title.innerText = generateExampleOutputTitle(PHP.version);
container.appendChild(title);
const div = document.createElement("div");
div.classList.add("examplescode");
Expand Down Expand Up @@ -56,13 +60,12 @@ async function main() {
return;
}

let exampleTitleContainer = example.nextElementSibling;
const exampleTitleContainer = example.nextElementSibling;
let exampleTitleParagraphElement = null;
let exampleScreenContainer = null;
let exampleScreenPreElement = null;
if (exampleTitleContainer !== null) {
exampleTitleParagraphElement = exampleTitleContainer.querySelector("p")
exampleScreenContainer = exampleTitleContainer.nextElementSibling;
const exampleScreenContainer = exampleTitleContainer.nextElementSibling;
exampleScreenPreElement = exampleScreenContainer.querySelector("pre");
}

Expand All @@ -79,7 +82,7 @@ async function main() {
const runPhp = await PHP.loadPhp();
runPhp(phpcode.innerText);
if (exampleScreenPreElement !== null) {
exampleTitleParagraphElement.innerText = "Output of the above example in PHP "+ PHP.version +":";
exampleTitleParagraphElement.innerText = generateExampleOutputTitle(PHP.version);
exampleScreenPreElement.innerText = PHP.buffer.join("");
} else {
lastOutput = createOutput(PHP.buffer.join(""));
Expand Down

0 comments on commit 46b1e1f

Please sign in to comment.