Skip to content

Commit

Permalink
chore: use jsdelivr cdn
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Mar 6, 2020
1 parent d5e0871 commit 3f03542
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
3 changes: 1 addition & 2 deletions static/__executor__.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Executor</title>
<style>body{margin: 0;padding: 10px;overflow: auto}#out{margin:0}</style>
<script src="https://wy-lang.org/dist/execute.js"></script>
<script src="https://cdn.jsdelivr.net/gh/wenyan-lang/cdn@wenyan-core/execute.min.js"></script>
</head>
<body>
<pre id="out"></pre>
Expand All @@ -22,7 +22,6 @@
};

window.addEventListener('message', (e) => {
console.log(e.data)
const { text, code, options } = e.data

if (text)
Expand Down
15 changes: 11 additions & 4 deletions static/assets/js/ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ function loadFile(name = currentFile.name) {
function parseUrlQuery() {
const query = new URLSearchParams(location.search);

if (query.get('import') !== undefined) {
if (query.has('import')) {
currentFile.name = query.get('name') || query.get('title') || 'Untitled'
currentFile.alias = query.get('alias') || currentFile.name
currentFile.author = query.get('author')
Expand Down Expand Up @@ -824,7 +824,7 @@ function updateCompiled(code) {
);

if (Config.lang === "js") {
jsCM.setValue(js_beautify(showcode, {
jsCM.setValue(beautifier.js(showcode, {
indent_size: 2,
}));
} else {
Expand Down Expand Up @@ -879,10 +879,17 @@ function sendToParent(data) {
function send(data) {
outIframe.onload = () => {
outIframe.contentWindow.postMessage(data, "*");
outIframe.contentWindow.document.body.style = `color: ${themeCache.forground}`
updateIframeStyle()
};
}

function updateIframeStyle() {
try {
outIframe.contentWindow.document.body.style = `color: ${themeCache.forground}`
}
catch{}
}

function executeCode(code) {
send({
code,
Expand Down Expand Up @@ -952,7 +959,7 @@ function updateTheme(name, overrides) {

themeCache.forground = theme.forground || (theme.dark ? '#fff' : '#000')

outIframe.contentWindow.document.body.style = `color: ${themeCache.forground}`
updateIframeStyle()

setView()
}
Expand Down
30 changes: 15 additions & 15 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@
})
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/codemirror.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/codemirror.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/addon/hint/show-hint.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/lib/codemirror.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/addon/hint/show-hint.css" />
<link rel='stylesheet' type='text/css' href='/assets/css/ide.css'/>
<link rel='stylesheet' type='text/css' href='/assets/css/layout.css'/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/addon/runmode/runmode.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/addon/mode/simple.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/addon/selection/active-line.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/addon/hint/show-hint.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/mode/javascript/javascript.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/mode/python/python.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/mode/ruby/ruby.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/codemirror.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/addon/runmode/runmode.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/addon/mode/simple.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/addon/selection/active-line.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/addon/hint/show-hint.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/mode/javascript/javascript.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/mode/python/python.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/mode/ruby/ruby.js"></script>
<script src="https://cdn.jsdelivr.net/gh/wenyan-lang/highlight/codemirror.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/FileSaver.min.js"></script>
<script src="https://code.iconify.design/1/1.0.0-rc1/iconify.min.js"></script>
<script src="https://unpkg.com/@wenyanlang/wyg/dist/runtime.umd.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.10.2/beautify.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@wenyanlang/wyg/dist/runtime.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/js-beautify@1.10.3/js/lib/beautifier.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js"></script>

<script src="https://cdn.jsdelivr.net/gh/wenyan-lang/cdn@wenyan-core/core.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/wenyan-lang/cdn@wenyan-core/examples.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/wenyan-lang/cdn@wenyan-core/render.min.js"></script>
<script src="/assets/js/show-invisibles.js"></script>
<script src="https://wy-lang.org/dist/core.js"></script>
<script src="https://wy-lang.org/dist/examples.js"></script>
<script src="https://wy-lang.org/dist/render.js"></script>
<script src="/assets/js/storage.js"></script>
<script src="/assets/js/theme.js"></script>
<style>
Expand Down

0 comments on commit 3f03542

Please sign in to comment.