Author: Derick Rethans (derickr)
Date: 2025-03-07T02:05:35+01:00

Commit: 
https://github.com/php/web-php/commit/c4c91d9435b69855e7e38db49d96c976cfabfad4
Raw diff: 
https://github.com/php/web-php/commit/c4c91d9435b69855e7e38db49d96c976cfabfad4.diff

Have a better button position and say if there is no output

Changed paths:
  M  js/interactive-examples.js


Diff:

diff --git a/js/interactive-examples.js b/js/interactive-examples.js
index 808bf2f858..8a2e692482 100644
--- a/js/interactive-examples.js
+++ b/js/interactive-examples.js
@@ -7,16 +7,24 @@ function generateExampleOutputTitle(phpVersion) {
 function createOutput(output) {
   const container = document.createElement("div");
   container.classList.add("screen", "example-contents");
+
+  if (output != "") {
+    const title = document.createElement("p");
+    title.innerText = generateExampleOutputTitle(PHP.version);
+    container.appendChild(title);
+    const div = document.createElement("div");
+    div.classList.add("examplescode");
+    container.appendChild(div);
+    const pre = document.createElement("pre");
+    pre.classList.add("examplescode");
+    pre.innerText = output;
+    div.appendChild(pre);
+    return container;
+  }
+
   const title = document.createElement("p");
-  title.innerText = generateExampleOutputTitle(PHP.version);
+  title.innerText = "This example did not produce any output."
   container.appendChild(title);
-  const div = document.createElement("div");
-  div.classList.add("examplescode");
-  container.appendChild(div);
-  const pre = document.createElement("pre");
-  pre.classList.add("examplescode");
-  pre.innerText = output;
-  div.appendChild(pre);
   return container;
 }
 
@@ -91,7 +99,7 @@ async function main() {
       PHP.buffer.length = 0;
     };
 
-    phpcode.before(button);
+    phpcode.after(button);
   });
 }
 

Reply via email to