Skip to content

Commit 6909ca0

Browse files
committed
1.0.0
1 parent 218a4ae commit 6909ca0

File tree

4 files changed

+120
-0
lines changed

4 files changed

+120
-0
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.js linguist-detectable=true
2+
*.css linguist-detectable=false
3+
*.html linguist-detectable=false

css/index.css

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
html, body {
2+
background-color: #272822;
3+
}
4+
5+
#editor{
6+
position: fixed;
7+
top: 48px;
8+
right: 0;
9+
left: 0;
10+
height: calc(100% - 48px);
11+
}
12+
13+
button{
14+
position: fixed;
15+
height: 48px;
16+
border: 0;
17+
font-weight: bold;
18+
cursor: pointer;
19+
background: #8b8c86;
20+
color: #2f3129;
21+
font-family: sans-serif;
22+
font-size: 16px;
23+
text-align: center;
24+
margin: 0;
25+
z-index: 9999;
26+
}
27+
28+
#btnMin{
29+
top: 0;
30+
left: 0;
31+
border-right: 1px solid #272822;
32+
width: 48px;
33+
}
34+
35+
#btnRun{
36+
top: 0;
37+
left: 48px;
38+
width: calc(100% - 94px);
39+
}
40+
41+
#btnMax{
42+
top: 0;
43+
right: 0;
44+
border-left: 1px solid #272822;
45+
width: 48px;
46+
}

index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<html lang="en">
2+
<head>
3+
<title>JSExecution</title>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0">
6+
<link rel="stylesheet" href="./css/index.css" type="text/css"/>
7+
</head>
8+
<body>
9+
<button id="btnMin" onclick="setFontSize(false);"></button>
10+
<button id="btnRun">EXECUTION</button>
11+
<button id="btnMax" onclick="setFontSize(true);"></button>
12+
<div id="editor"></div>
13+
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/ace.min.js" integrity="sha512-hDyKEpCc9jPn3u2VffFjScCtNqZI+BAbThAhhDYqqqZbxMqmTSNIgdU0OU9BRD/8wFxHIWLAo561hh9fW7j6sA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
14+
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/theme-monokai.min.js" integrity="sha512-wZYGbdk0giM73l8BLDNfSEziApAmH8DvXey6zNLG3QUgDeDsMAPm3FIdjhLwrGOWO0vdVHkVxeUzOBR0Hc/xBA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
15+
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/mode-javascript.min.js" integrity="sha512-37ta5K4KVYs+MEmIg2xnZxJrdiQmBSKt+JInvyPrq9uz7aF67lMJT/t91EYoYj520jEcGlih41kCce7BRTmE3Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
16+
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.14/worker-javascript.min.js" integrity="sha512-hwPBZJdHUlQzk8FedQ6S0eqJw/26H3hQ1vjpdAVJLaZU/AJSkhU29Js3/J+INYpxEUbgD3gubC7jBBr+WDqS2w==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
17+
<script src="./js/index.js"></script>
18+
</body>
19+
</html>

js/index.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
var fontSize = 16;
2+
var editor = ace.edit("editor");
3+
editor.setTheme("ace/theme/monokai");
4+
editor.session.setMode("ace/mode/javascript");
5+
editor.setAutoScrollEditorIntoView(true);
6+
editor.setFontSize(fontSize);
7+
8+
if(localStorage.JScode!=null){
9+
editor.setValue(localStorage.JScode);
10+
}
11+
12+
editor.setOptions({
13+
wrap: true
14+
});
15+
16+
function setFontSize(plus){
17+
if(plus){
18+
fontSize=fontSize+4;
19+
editor.setFontSize(fontSize);
20+
}else{
21+
if((fontSize-4)>0){
22+
fontSize=fontSize-4;
23+
editor.setFontSize(fontSize);
24+
}
25+
}
26+
}
27+
28+
document.getElementById('btnRun').onclick = function(){
29+
var text = editor.getValue();
30+
localStorage.setItem('JScode', text);
31+
try{
32+
if(text==''){
33+
alert('EMPTY CODE');
34+
}else{
35+
eval(text);
36+
}
37+
}catch(e){
38+
alert('ERROR -> '+e);
39+
}
40+
}
41+
42+
if(window.screen.width < window.screen.height){
43+
editor.on("focus", function(){
44+
document.getElementById('editor').style.height = 'calc(50% - 36px)';
45+
editor.resize();
46+
});
47+
48+
editor.on("blur", function(){
49+
document.getElementById('editor').style.height = 'calc(100% - 48px)';
50+
editor.resize();
51+
});
52+
}

0 commit comments

Comments
 (0)