added sanity check
This commit is contained in:
@@ -5,6 +5,7 @@ import { OutputFrame } from "../output-frame/output-frame";
|
||||
import { debounceManager } from "../../../shared/ensure-debounce";
|
||||
import * as sessionApi from '../../../shared/session-api';
|
||||
import { isSessionPage } from "../../../shared/page";
|
||||
import { sanityConvert } from "../../../shared/sanity-code-check";
|
||||
|
||||
export class CodeEditor extends BaseElement {
|
||||
|
||||
@@ -45,13 +46,13 @@ export class CodeEditor extends BaseElement {
|
||||
localStorage.setItem(this.language + "LastInputCache", this.input);
|
||||
debounce.ensureDebounce(() => {
|
||||
sessionApi.setSessionData(this.language, this.input);
|
||||
this.outputFrame.setContent(this.language, this.input);
|
||||
this.outputFrame.setContent(this.language, this.language.toLowerCase() === "javascript" ? sanityConvert(this.input) : this.input);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.waitFor(this.outputFrame, () => {
|
||||
this.outputFrame.setContent(this.language, isSessionPage() ? "" : this.input);
|
||||
this.outputFrame.setContent(this.language, isSessionPage() ? "" : (this.language.toLowerCase() === "javascript" ? sanityConvert(this.input) : this.input));
|
||||
});
|
||||
|
||||
}
|
||||
@@ -62,7 +63,7 @@ export class CodeEditor extends BaseElement {
|
||||
this.lastInputCache = this.input;
|
||||
localStorage.setItem(this.language + "LastInputCache", this.input);
|
||||
this.editor.setValue(input);
|
||||
this.outputFrame.setContent(this.language, this.input);
|
||||
this.outputFrame.setContent(this.language, this.language.toLowerCase() === "javascript" ? sanityConvert(this.input) : this.input);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ export class OutputFrame extends BaseElement {
|
||||
|
||||
if (this.Iframe && this.hasChild(this.Iframe)) {
|
||||
this.Iframe.setAttribute("sandbox", "allow-pointer-lock allow-same-origin");
|
||||
console.log("REMOVING IFRAME!");
|
||||
this.removeChild(this.Iframe);
|
||||
}
|
||||
|
||||
@@ -38,28 +37,21 @@ export class OutputFrame extends BaseElement {
|
||||
this.Iframe.setAttribute("sandbox", "allow-pointer-lock allow-same-origin allow-scripts");
|
||||
if (onload) {
|
||||
this.Iframe.onload = ((ev) => {
|
||||
console.log("IFRAME LOADED");
|
||||
onload(ev);
|
||||
if (this.Iframe)
|
||||
this.Iframe.onload = () => { };
|
||||
});
|
||||
}
|
||||
console.log("IF SOURCE BEFORE", this.Iframe.src);
|
||||
if (source != null) {
|
||||
console.log("CUSOMSRC S:"+source, source);
|
||||
this.Iframe.src = source;
|
||||
}
|
||||
else {
|
||||
this.Iframe.src = GetOutputFrameUrl();
|
||||
}
|
||||
console.log("IF SOURCE AFTER", this.Iframe.src);
|
||||
|
||||
if (source !== "") {
|
||||
this.appendChild(this.Iframe);
|
||||
}
|
||||
else {
|
||||
console.log("SPPCHD");
|
||||
}
|
||||
|
||||
if (resetNotificationBubbles) {
|
||||
var bubbles = GetNotificationBubbles();
|
||||
@@ -70,18 +62,16 @@ export class OutputFrame extends BaseElement {
|
||||
}
|
||||
|
||||
setError() {
|
||||
console.log("RCALLED");
|
||||
this.reset(() => {
|
||||
console.log("ERROR RESET");
|
||||
if (this.Iframe) {
|
||||
// this.Iframe.contentWindow?.location.reload();
|
||||
console.log("RESET AFTER", this.Iframe.src);
|
||||
// this.Iframe.contentWindow?.location.reload();
|
||||
}
|
||||
}, true, "");//GetOutputFrameUrl("execution-time-error.html"));
|
||||
}, true, "");
|
||||
|
||||
}
|
||||
|
||||
setContent(language: string, value: string) {
|
||||
console.log("setting content", language, value);
|
||||
this.contents[language] = value;
|
||||
this.reset(() => {
|
||||
for (const lang in this.contents) {
|
||||
@@ -97,7 +87,6 @@ export class OutputFrame extends BaseElement {
|
||||
doPostMessage(language: string, value: string) {
|
||||
this.CurrentIframeScriptRemoveResponseListener = postMessage(this.Iframe?.contentWindow, language, this.contents[language], language == 'javascript' ?
|
||||
(executeTimeInMs, exceedTimeInMs) => {
|
||||
console.log("onresponse", executeTimeInMs + " " + exceedTimeInMs);
|
||||
if (executeTimeInMs === -1) {
|
||||
this.setError();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ export class WindowControlConnector extends BaseElement {
|
||||
|
||||
if (distTarget) {
|
||||
var visibleTargetChildren = this.visibleChildren(distTarget);
|
||||
console.log(visibleTargetChildren);
|
||||
|
||||
if (visibleTargetChildren.length === 0) {
|
||||
distTarget.classList.add("force-close");
|
||||
|
||||
Reference in New Issue
Block a user