Skip to content

Commit c4c91d9

Browse files
committed
Have a better button position and say if there is no output
1 parent af6da3d commit c4c91d9

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

js/interactive-examples.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,24 @@ function generateExampleOutputTitle(phpVersion) {
77
function createOutput(output) {
88
const container = document.createElement("div");
99
container.classList.add("screen", "example-contents");
10+
11+
if (output != "") {
12+
const title = document.createElement("p");
13+
title.innerText = generateExampleOutputTitle(PHP.version);
14+
container.appendChild(title);
15+
const div = document.createElement("div");
16+
div.classList.add("examplescode");
17+
container.appendChild(div);
18+
const pre = document.createElement("pre");
19+
pre.classList.add("examplescode");
20+
pre.innerText = output;
21+
div.appendChild(pre);
22+
return container;
23+
}
24+
1025
const title = document.createElement("p");
11-
title.innerText = generateExampleOutputTitle(PHP.version);
26+
title.innerText = "This example did not produce any output."
1227
container.appendChild(title);
13-
const div = document.createElement("div");
14-
div.classList.add("examplescode");
15-
container.appendChild(div);
16-
const pre = document.createElement("pre");
17-
pre.classList.add("examplescode");
18-
pre.innerText = output;
19-
div.appendChild(pre);
2028
return container;
2129
}
2230

@@ -91,7 +99,7 @@ async function main() {
9199
PHP.buffer.length = 0;
92100
};
93101

94-
phpcode.before(button);
102+
phpcode.after(button);
95103
});
96104
}
97105

0 commit comments

Comments
 (0)