-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayground.js
executable file
·141 lines (126 loc) · 3.5 KB
/
playground.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//console.clear();
const HomeAct = new activity({name:"Home",code:`
<d-navbar position="top" content="left">
<d-tabs class="ripple" >Home</d-tabs>
<d-tabs class="ripple" onclick="openAboutAct()">About</d-tabs>
</d-navbar>
<d-content>
<div class="card">
<i class="spacer"></i>
<div class="blam">
<div class="blam">
<a>Show errors on result?</a>
<input onchange="disableErrors()" checked type="checkbox" >
</div>
<div class="blam">
<a>Execute?</a>
<input onchange="disableExecute()" type="checkbox" >
</div>
<div class="blam">
<a>Auto compile?</a>
<input onchange="disableAutoCompile()" checked type="checkbox" >
</div>
<button class="ripple" onclick="convert()">RUN</button>
</div>
</div>
<div class="card">
<div class="horizontal">
<div contentEditable="true" class="input" id="carbonara"></div>
<dconfigtEditable="true" class="input" id="javascript"></div>
</div>
</div>
</d-content>
`});
const colors = {
Name : 'main',
Primary : '#2979ff',
Light: '#75a7ff',
Secondary: '#1565c0',
Background: '#2d2d2d',
RippleEffect : 'rgba(255,255,255,0.6)'
}
newTheme(colors)
setTheme("main");
load({
home: HomeAct
});
function openAboutAct(){
const aboutAct = new activity({name:"about",code:`
<d-navbar position="top">
<img class="navbar-icon" onclick="closeActivity('slide_down')" src="arrow_back.svg"></img>
<d-title> About Carbonara <d-title>
</d-navbar>
<d-content>
<div content="center">
<p class="title2">CarbonaraScript</p>
<p> Version 0.1.4</p>
<button class="ripple" onclick="window.open('https://github.com/marc2332/carbonara-script')">Source</button>
<button class="ripple" onclick="window.open('https://github.com/marc2332/carbonara-script/blob/master/changelog.md')">Changelog</button>
</div>
</d-content>
`});
aboutAct.launch({
animation:"slide_up"
})
}
var _executeBool = false;
var _showErrors = true;
var _autoCompileBool = true;
function convert(){
const result = execute({
code:carbonara.getValue(),
compression:false,
consoleOutput:false,
execute:_executeBool,
showErrorsOnPlayground:_showErrors
});
javascript.setValue(result);
}
let carbonara = CodeMirror(document.getElementById("carbonara"), {
value: example,
mode: "javascript",
htmlMode: false,
theme: "default",
lineNumbers: true,
autoCloseTags: true,
indentUnits:2,
stleActiveLine:true
});
let javascript = CodeMirror(document.getElementById("javascript"), {
value: "",
mode: "javascript",
htmlMode: false,
theme: "default",
lineNumbers: true,
autoCloseTags: true
});
carbonara.on("change", function() {
if(_autoCompileBool){
console.clear()
convert()
}
});
function disableErrors(){
if(_showErrors){
_showErrors= false
}else{
_showErrors = true
}
convert()
}
function disableExecute(){
if(_executeBool){
_executeBool= false
}else{
_executeBool = true
}
convert()
}
function disableAutoCompile(){
if(_autoCompileBool){
_autoCompileBool= false
}else{
_autoCompileBool = true
}
convert()
}