Skip to content

Commit 3271d6d

Browse files
Add support for external run and showNavigation
1 parent 52e310c commit 3271d6d

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

embed/index.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<body>
22
<p>The source code for this example is available <a href="https://github.com/judge0/ide/tree/master/embed" target="_blank">here</a>.</p>
33

4-
<iframe id="judge0-ide" src="https://ide.judge0.com?judge0.style=minimal&judge0.theme=dark" frameborder="0" width="80%" height="300px"></iframe>
4+
<iframe id="judge0-ide" src="https://ide.judge0.com?judge0.style=minimal&judge0.theme=dark&judge0.styleOptions.showNavigation=false" frameborder="0" width="80%" height="300px"></iframe>
55

66
<hr />
77
<button onclick="getDataFromJudge0IDE()">Get Data</button>
8+
<button onclick="runCodeInsideJudge0IDE()">Run Code</button>
89
<pre id="judge0-ide-data-viewer" style="padding: 1rem; background-color: #eee;"></pre>
910

1011
<script>
@@ -44,5 +45,9 @@
4445
function getDataFromJudge0IDE() {
4546
judge0IDE.contentWindow.postMessage({action: "get"}, '*');
4647
}
48+
49+
function runCodeInsideJudge0IDE() {
50+
judge0IDE.contentWindow.postMessage({action: "run"}, '*');
51+
}
4752
</script>
4853
</body>

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
</head>
9292

9393
<body>
94-
<div id="judge0-site-navigation" class="ui top fixed borderless menu">
94+
<div id="judge0-site-navigation" class="ui top fixed borderless menu judge0-showNavigation">
9595
<a id="judge0-header" href="https://judge0.com" target="_blank" class="header item judge0-showLogo">
9696
<img id="judge0-logo" src="./images/icon_var2_rounded_512.png">
9797
</a>

js/configuration.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const DEFAULT_CONFIGURATIONS = {
1717
showThemeButton: true,
1818
showPuterSignInOutButton: true,
1919
showStatusLine: true,
20-
showCopyright: true
20+
showCopyright: true,
21+
showNavigation: true
2122
},
2223
appOptions: {
2324
showAIAssistant: true,
@@ -42,7 +43,8 @@ const DEFAULT_CONFIGURATIONS = {
4243
showThemeButton: false,
4344
showPuterSignInOutButton: false,
4445
showStatusLine: false,
45-
showCopyright: false
46+
showCopyright: false,
47+
showNavigation: true
4648
},
4749
appOptions: {
4850
showAIAssistant: false,
@@ -67,7 +69,8 @@ const DEFAULT_CONFIGURATIONS = {
6769
showThemeButton: true,
6870
showPuterSignInOutButton: true,
6971
showStatusLine: true,
70-
showCopyright: false
72+
showCopyright: false,
73+
showNavigation: true
7174
},
7275
appOptions: {
7376
showAIAssistant: true,
@@ -92,7 +95,8 @@ const DEFAULT_CONFIGURATIONS = {
9295
showThemeButton: true,
9396
showPuterSignInOutButton: true,
9497
showStatusLine: true,
95-
showCopyright: false
98+
showCopyright: false,
99+
showNavigation: true
96100
},
97101
appOptions: {
98102
showAIAssistant: true,
@@ -117,7 +121,8 @@ const DEFAULT_CONFIGURATIONS = {
117121
showThemeButton: true,
118122
showPuterSignInOutButton: false,
119123
showStatusLine: true,
120-
showCopyright: true
124+
showCopyright: true,
125+
showNavigation: true
121126
},
122127
appOptions: {
123128
showAIAssistant: true,

js/ide.js

+2
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ document.addEventListener("DOMContentLoaded", async function () {
748748
if (e.data.api_key) {
749749
AUTH_HEADERS["Authorization"] = `Bearer ${e.data.api_key}`;
750750
}
751+
} else if (e.data.action === "run") {
752+
run();
751753
}
752754
};
753755
});

0 commit comments

Comments
 (0)