[PHP-WEBMASTER] [web-php] better-js: Have a better button position and say if there is no output

Author: Derick Rethans (derickr)
Date: 2025-02-14T15:54:53Z

Commit: Have a better button position and say if there is no output · php/web-php@df92b9c · GitHub
Raw diff: https://github.com/php/web-php/commit/df92b9c24f26dcfc50dbc5990683958904b14682.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);
   });
}