-
Notifications
You must be signed in to change notification settings - Fork 40
Changes request patterns and response handling to match Go backend. #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
16c4b12
Third time's the charm, baby.
krashanoff 9ed1912
New URL, fix response handling by deleteProgram.
krashanoff 6bd7d78
Add react to supported languages
timothycpoon 3d48d42
undo unintentional code style changes
timothycpoon 69c6f03
Format output
timothycpoon dc18b90
Throw error on bad response in CreateSketchModal and TextEditor. Confirm
krashanoff 874c9d9
add spacing
timothycpoon 8e52352
Merge pull request #377 from uclaacm/tpoon/react_editor
timothycpoon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { getJsSrcDocLoggingScript } from "./constants"; | ||
|
||
const getReactSrcDocHead = () => ` | ||
<head> | ||
<style>html,body: {margin:0, width:100%}</style> | ||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | ||
<script src="https://unpkg.com/react@17/umd/react.development.js" crossorigin></script> | ||
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js" crossorigin></script> | ||
<script src="https://unpkg.com/@material-ui/core@latest/umd/material-ui.development.js" crossorigin="anonymous"></script> | ||
<style> | ||
#inner { | ||
height:100px; | ||
background-color:#222; | ||
color: #DDD; | ||
font-family: monospace; | ||
word-wrap:break-word; | ||
overflow:auto; | ||
margin: 10px auto; | ||
position:relative; | ||
padding: 10px 35px 10px 10px; | ||
width: 100%; | ||
box-sizing: border-box; /* For IE and modern versions of Chrome */ | ||
-moz-box-sizing: border-box; /* For Firefox */ | ||
-webkit-box-sizing: border-box; /* For Safari */ | ||
} | ||
#output { | ||
display: block; | ||
position: relative; | ||
background: white; | ||
min-height: 70vh; | ||
padding: 10px 35px 10px 10px; | ||
} | ||
#closeConsoleButton { position: fixed; top: 20px; right: 30px; color: #ddd;} | ||
</style> | ||
</head> | ||
`; | ||
|
||
const getUserScript = (code) => ` | ||
<script type="text/babel"> | ||
${code} | ||
ReactDOM.render( | ||
<App />, | ||
document.getElementById('output'), | ||
); | ||
</script> | ||
`; | ||
|
||
const getReactSrcDocBody = (code, showConsole) => ` | ||
<body> | ||
${ | ||
showConsole | ||
? `<div id="outer"><textarea id="inner"></textarea></div>` | ||
: `<div id="outer" style="display:none;"><textarea id="inner"></textarea></div>` | ||
} | ||
${getJsSrcDocLoggingScript()} | ||
${getUserScript(code)} | ||
<div id="output"></div> | ||
</body> | ||
`; | ||
|
||
export default function (code, showConsole) { | ||
return `<html> ${getReactSrcDocHead()} ${getReactSrcDocBody(code, showConsole)}</html>`; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export const getJsSrcDocLoggingScript = () => ` | ||
<script type="text/javascript"> | ||
if (typeof console != "undefined") | ||
if (typeof console.log != 'undefined') | ||
console.olog = console.log; | ||
else | ||
console.olog = function() {}; | ||
|
||
console.log = (message) => { | ||
console.olog(message); | ||
let a = document.getElementById("inner") | ||
if(a){ | ||
// a.style.display = "block" | ||
a.value = a.value + "> " + message + "\\n"; | ||
if(a.scrollTop >= (a.scrollHeight - a.offsetHeight) - a.offsetHeight){ | ||
a.scrollTop = a.scrollHeight | ||
} | ||
} | ||
}; | ||
|
||
window.onerror = (err)=> { | ||
let a = document.getElementById("outer") | ||
if(a){ | ||
a.style.display = "block" | ||
} | ||
console.log("\\n\\nERROR: " + err + "\\n") | ||
} | ||
|
||
console.error = console.debug = console.info = console.log; | ||
|
||
function closeConsole(){ | ||
var mypre = document.getElementById("inner"); | ||
mypre.style.display = "none" | ||
} | ||
</script> | ||
`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.