-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
78 lines (70 loc) · 2.29 KB
/
main.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
require.config({ paths: { 'vs': 'node_modules/monaco-editor/min/vs' }});
require(['vs/editor/editor.main'], main);
var editors = [];
function main() {
newEditor(0);
newRun(0);
$('#loading').css('display', 'none');
}
function run(i) {
i = parseInt(i, 10);
var basic_out = $('#run-'+i+' .basic_out')[0];
window.Basic(editors[i].getValue(), basic_out);
}
function newEditor(i)
{
i = parseInt(i, 10);
$('main').append('<section id="editor-'+i+'" checked><div class="editor"></div></section>');
//$('#tabs ul').append('<li><a href="#editor-'+i+'">Editor '+i+'</a></li>');
$('#tabs').append('<input name="tabs" type="radio" id="tab-editor-'+i+'" class="tab-input"/>');
$('#tabs').append('<label for="tab-editor-'+i+'" class="tab-label">Editor</label>');
editors[i] = monaco.editor.create($('#editor-'+i+' .editor')[0], {
value: [
'PRINT "Hello World!"',
'FOR i = 1 to 10',
'\tPRINT "Counting "; i',
'NEXT i',
].join('\n'),
language: 'basic',
theme: "vs-dark",
fontFamily: "VT323",
fontSize: 20
});
$('#tab-editor-'+i).on('change', function(e) {
if(this.checked)
{
$('section').css('display', 'none');
$('#editor-'+i).css('display', 'block');
editors[i].layout();
}
});
}
function newRun(i)
{
i = parseInt(i, 10);
$('main').append('<section id="run-'+i+'"><canvas class="basic_out" width="1280" height="960"></canvas></section>');
//$('#tabs ul').append('<li><a href="#run-'+i+'" onclick="run('+i+')">Run '+i+'</a></li>');
$('#tabs').append('<input name="tabs" type="radio" id="tab-run-'+i+'" class="tab-input"/>');
$('#tabs').append('<label for="tab-run-'+i+'" class="tab-label">Run</label>');
$('#tab-run-'+i).on('change', function(e) {
if(this.checked)
{
$('section').css('display', 'none');
$('#run-'+i).css('display', 'block');
run(i);
}
});
}
$(window).on('resize', function()
{
editors.forEach(function(e)
{
e.layout();
});
});
$('.button-close').on('click', function(){
$(this).closest('.dialog').css('display', 'none');
});
$('#menu-about').on('click', function(){
$('#about').css('display', 'block');
});