Skip to content

Commit a477baf

Browse files
committed
updated (Load project from URL GET parameter)
1 parent 78de242 commit a477baf

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

Browser_IDE/IDEStartupMain.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
async function StartIDE() {
22
makingNewProject = true;
3+
34
// Interface setup
45
createGutterSplitters();
56
setupLanguageSelectionBox();
67

78
// Initialize language
89
setupActiveLanguage();
9-
setupIDEButtonEvents(); // uses current language
10+
setupIDEButtonEvents();
1011

1112
// Create execution environment and project storage objects
1213
executionEnviroment = new ExecutionEnvironment(document.getElementById("ExecutionEnvironment"), activeLanguageSetup);
@@ -22,7 +23,6 @@ async function StartIDE() {
2223
setupProjectConflictAndConfirmationModals();
2324
setupCodeEditorCallbacks();
2425
setupFilePanelAndEvents();
25-
2626
setupMinifiedInterface();
2727

2828
// Initialize compiler in parallel with everything else
@@ -38,7 +38,7 @@ async function StartIDE() {
3838
await appStorage.attach();
3939
await storedProject.attachToProject();
4040

41-
// Check for projectURL and load project if provided
41+
// Load project from URL if specified
4242
if (SKO.projectURL) {
4343
try {
4444
console.log(`Loading project from URL: ${SKO.projectURL}`);
@@ -60,14 +60,14 @@ async function StartIDE() {
6060
})()
6161
]);
6262

63-
// Enable code execution once project is mirrored to the execution
64-
// environment and compiler is ready.
63+
// Enable code execution once project is mirrored to the execution environment and compiler is ready
6564
updateCodeExecutionState();
6665

6766
AddWindowListeners();
6867
}
6968

70-
StartIDE();
71-
72-
// Focus the window, this is used in order to detect if the user clicks inside the iFrame containing the program
69+
// Focus the window for detecting user interaction inside the iFrame
7370
window.focus();
71+
72+
// Start the IDE
73+
StartIDE();
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11
"use strict";
22

3-
// global object that can be used to configure the IDE
4-
5-
let SKO = (function(){
3+
// Global object that can be used to configure the IDE
4+
let SKO = (function () {
65
let page_url = new URL(window.location.href);
76

8-
// parse raw parameters as well
7+
// Parse raw parameters
98
var parsedRawParams = {};
10-
// just remove the ?, split by &, then split by = and assign each piece
11-
page_url.search.slice(1).split("&").forEach(function(param){
9+
page_url.search.slice(1).split("&").forEach(function (param) {
1210
var pieces = param.split("=");
1311
parsedRawParams[pieces[0]] = pieces[1];
1412
});
1513

16-
function getEnvParam(paramName, _default=null, decode=true){
14+
function getEnvParam(paramName, _default = null, decode = true) {
1715
if (decode)
1816
return page_url.searchParams.get(paramName) ?? _default;
1917
else
2018
return parsedRawParams[paramName] ?? _default;
2119
}
2220

23-
let isPreview = (page_url.pathname.indexOf("/pr-previews/") >= 0)
24-
|| (page_url.pathname.indexOf("/branch-previews/") >= 0);
21+
let isPreview = (page_url.pathname.indexOf("/pr-previews/") >= 0)
22+
|| (page_url.pathname.indexOf("/branch-previews/") >= 0);
2523

2624
return {
27-
language: getEnvParam("language", "JavaScript", false), /*don't decode, so + remains + rather than a space*/
28-
useCompressedBinaries: getEnvParam("useCompressedBinaries", "on", true) == "on",
29-
useMinifiedInterface: getEnvParam("useMinifiedInterface") == "on",
30-
isPRPreview: getEnvParam("isPRPreview", isPreview ? "on" : "off") == "on",
31-
projectURL: getEnvParam("projectURL", null, true), // Add projectURL parameter
25+
language: getEnvParam("language", "JavaScript", false), // Don't decode, so + remains +
26+
useCompressedBinaries: getEnvParam("useCompressedBinaries", "on", true) === "on",
27+
useMinifiedInterface: getEnvParam("useMinifiedInterface") === "on",
28+
isPRPreview: getEnvParam("isPRPreview", isPreview ? "on" : "off") === "on",
29+
projectURL: getEnvParam("projectURL", null, true) // Added projectURL parameter
3230
};
3331
})();

0 commit comments

Comments
 (0)