천현우

Merge branch 'main' of http://khuhub.khu.ac.kr/2019102168/Voicoding into main

...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
2 --text-color:#fffde7; 2 --text-color:#fffde7;
3 --background-color:#ff94c2; 3 --background-color:#ff94c2;
4 --accent-color:#ba2d65; 4 --accent-color:#ba2d65;
5 + --output-color:#ff7043;
6 + --output-accent-color:#c63f17;
5 } 7 }
6 8
7 body{ 9 body{
...@@ -13,7 +15,7 @@ a{ ...@@ -13,7 +15,7 @@ a{
13 color:var(--text-color); 15 color:var(--text-color);
14 16
15 } 17 }
16 -.menu{ 18 +.voi_menu{
17 display:flex; 19 display:flex;
18 justify-content:space-between; 20 justify-content:space-between;
19 align-items:center; 21 align-items:center;
...@@ -23,10 +25,12 @@ a{ ...@@ -23,10 +25,12 @@ a{
23 .menu_bar_content li:hover{ 25 .menu_bar_content li:hover{
24 background-color:var(--accent-color); 26 background-color:var(--accent-color);
25 border-radius: 4px; 27 border-radius: 4px;
28 + color:var(--text-color);
26 } 29 }
27 .menu_bar_icons li:hover{ 30 .menu_bar_icons li:hover{
28 background-color:var(--accent-color); 31 background-color:var(--accent-color);
29 border-radius: 4px; 32 border-radius: 4px;
33 + color:var(--text-color);
30 } 34 }
31 .menu_bar_logo{ 35 .menu_bar_logo{
32 font-size: 20px; 36 font-size: 20px;
...@@ -35,6 +39,9 @@ a{ ...@@ -35,6 +39,9 @@ a{
35 .menu_bar_logo i{ 39 .menu_bar_logo i{
36 color:var(--accent-color); 40 color:var(--accent-color);
37 } 41 }
42 +.basic:hover{
43 + color:var(--text-color);
44 +}
38 .menu_bar_content{ 45 .menu_bar_content{
39 display:flex; 46 display:flex;
40 list-style: none; 47 list-style: none;
...@@ -52,13 +59,17 @@ a{ ...@@ -52,13 +59,17 @@ a{
52 padding: 8px 12px; 59 padding: 8px 12px;
53 } 60 }
54 .menu_toggle{ 61 .menu_toggle{
62 + color:var(--text-color);
55 display: none; 63 display: none;
56 position: absolute; 64 position: absolute;
57 right:32px; 65 right:32px;
58 font-size: 24px; 66 font-size: 24px;
59 } 67 }
68 +.menu_toggle:hover{
69 + color:var(--text-color);
70 +}
60 @media screen and (max-width: 500px) { 71 @media screen and (max-width: 500px) {
61 - .menu{ 72 + .voi_menu{
62 flex-direction: column; 73 flex-direction: column;
63 align-items: flex-start; 74 align-items: flex-start;
64 padding: 8px 24px; 75 padding: 8px 24px;
...@@ -80,6 +91,7 @@ a{ ...@@ -80,6 +91,7 @@ a{
80 } 91 }
81 .menu_toggle{ 92 .menu_toggle{
82 display: block; 93 display: block;
94 + color:var(--text-color);
83 } 95 }
84 .menu_bar_content.active, 96 .menu_bar_content.active,
85 .menu_bar_icons.active{ 97 .menu_bar_icons.active{
...@@ -87,25 +99,55 @@ a{ ...@@ -87,25 +99,55 @@ a{
87 } 99 }
88 } 100 }
89 button{ 101 button{
90 - background-color:#60ad5e; 102 + background-color:var(--output-color);
91 border:none; 103 border:none;
92 color:var(--text-color); 104 color:var(--text-color);
93 font-size:50px; 105 font-size:50px;
94 - padding:12px 24px 24px 24px; 106 + padding: 24px;
95 border-radius: 4px; 107 border-radius: 4px;
96 } 108 }
97 button:hover{ 109 button:hover{
98 - background-color:#005005; 110 + background-color:var(--output-accent-color);
99 border-radius: 4px; 111 border-radius: 4px;
100 } 112 }
101 .controls{ 113 .controls{
102 - padding:12px 24px;
103 height:70px; 114 height:70px;
104 font-size:100px; 115 font-size:100px;
105 display:flex; 116 display:flex;
106 justify-content:space-around; 117 justify-content:space-around;
107 border-radius:4px; 118 border-radius:4px;
119 + margin: 23px;
120 +}
121 +#output{
122 + margin:20px;
123 + display:flex;
124 + align-items:center;
125 + height:700px;
126 + background-color:rgba(0,0,0,.87);
127 + color:var(--text-color);
108 } 128 }
109 #recordButton{ 129 #recordButton{
110 - 130 + line-height: 22px;
131 + font-size:50px;
132 +}
133 +#transcribeButton{
134 + line-height: 22px;
135 + font-size:50px;
136 +}
137 +.output_bar{
138 + display:flex;
139 + justify-content:center;
140 + color:black;
141 + margin: 20px;
142 + font-size:100px;
143 +}
144 +.basic{
145 + color:var(--text-color);
146 + font-size:20px;
147 +}
148 +.fas.fa-arrow-circle-down{
149 + color:var(--background-color);
150 + font-size:70px;
151 + display:block;
152 + text-align:center;
111 } 153 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -6,25 +6,82 @@ ...@@ -6,25 +6,82 @@
6 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 6 <meta http-equiv="X-UA-Compatible" content="IE=edge">
7 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 7 <meta name="viewport" content="width=device-width, initial-scale=1.0">
8 <title>Voicoding</title> 8 <title>Voicoding</title>
9 - <script src="https://kit.fontawesome.com/a5f26fa106.js" crossorigin="anonymous"></script> 9 + <script defer src="https://kit.fontawesome.com/a5f26fa106.js" crossorigin="anonymous"></script>
10 - <script src="menu.js" defer></script> 10 + <script defer src="menu.js"></script>
11 <link rel="preconnect" href="https://fonts.gstatic.com"> 11 <link rel="preconnect" href="https://fonts.gstatic.com">
12 <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300&display=swap" rel="stylesheet"> 12 <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300&display=swap" rel="stylesheet">
13 + <script defer src="https://cdn.rawgit.com/mattdiamond/Recorderjs/08e7abd9/dist/recorder.js"></script>
14 + <script defer src="client.js"></script>
15 + <meta name="description" content="Free and open-source online code editor that allows you to write and execute code from a rich set of languages.">
16 + <meta name="keywords" content="online editor, online code editor, online ide, online compiler, online interpreter, run code online, learn programming online,
17 + online debugger, programming in browser, online code runner, online code execution, debug online, debug C code online, debug C++ code online,
18 + programming online, snippet, snippets, code snippet, code snippets, pastebin, execute code, programming in browser, run c online, run C++ online,
19 + run java online, run python online, run ruby online, run c# online, run rust online, run pascal online, run basic online">
20 + <meta name="author" content="Herman Zvonimir Došilović">
21 +
22 +
23 + <meta property="og:title" content="Judge0 IDE - Free and open-source online code editor">
24 + <meta property="og:description" content="Free and open-source online code editor that allows you to write and execute code from a rich set of languages.">
25 + <meta property="og:image" content="https://raw.githubusercontent.com/judge0/ide/master/.github/wallpaper.png">
26 +
27 + <script defer src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
28 +
29 + <script defer src="https://cdnjs.cloudflare.com/ajax/libs/golden-layout/1.5.9/goldenlayout.min.js" integrity="sha256-NhJAZDfGgv4PiB+GVlSrPdh3uc75XXYSM4su8hgTchI=" crossorigin="anonymous"></script>
30 + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/golden-layout/1.5.9/css/goldenlayout-base.css" integrity="sha256-oIDR18yKFZtfjCJfDsJYpTBv1S9QmxYopeqw2dO96xM=" crossorigin="anonymous" />
31 + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/golden-layout/1.5.9/css/goldenlayout-dark-theme.css" integrity="sha256-ygw8PvSDJJUGLf6Q9KIQsYR3mOmiQNlDaxMLDOx9xL0=" crossorigin="anonymous" />
32 +
33 + <script>
34 + var require = {
35 + paths: {
36 + "vs": "https://unpkg.com/monaco-editor/min/vs",
37 + "monaco-vim": "https://unpkg.com/monaco-vim/dist/monaco-vim",
38 + "monaco-emacs": "https://unpkg.com/monaco-emacs/dist/monaco-emacs"
39 + }
40 + };
41 + </script>
42 + <script defer src="https://unpkg.com/monaco-editor/min/vs/loader.js"></script>
43 + <script defer src="https://unpkg.com/monaco-editor@0.23.0/min/vs/editor/editor.main.nls.js"></script>
44 + <script defer src="https://unpkg.com/monaco-editor@0.23.0/min/vs/editor/editor.main.js"></script>
45 +
46 + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css" integrity="sha256-9mbkOfVho3ZPXfM7W8sV2SndrGDuh7wuyLjtsWeTI1Q=" crossorigin="anonymous" />
47 + <script defer src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js" integrity="sha256-t8GepnyPmw9t+foMh3mKNvcorqNHamSKtKRxxpUEgFI=" crossorigin="anonymous"></script>
48 +
49 + <link href="https://fonts.googleapis.com/css?family=Exo+2" rel="stylesheet">
50 +
51 + <script type="text/javascript" defer src="third_party/download.js"></script>
52 +
53 + <script type="text/javascript" defer src="js/ide.js"></script>
54 +
55 + <link type="text/css" rel="stylesheet" href="css/ide.css">
56 +
57 + <title>Judge0 IDE - Free and open-source online code editor</title>
58 + <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon">
59 + <link rel="icon" href="./favicon.ico" type="image/x-icon">
60 +
61 + <script async defer src="https://www.googletagmanager.com/gtag/js?id=G-RHNJ50BJ2F"></script>
62 + <script>
63 + window.dataLayer = window.dataLayer || [];
64 + function gtag(){dataLayer.push(arguments);}
65 + gtag('js', new Date());
66 + gtag('config', 'G-RHNJ50BJ2F');
67 + </script>
68 +
69 + <script defer type="text/javascript">window.$crisp=[];window.CRISP_WEBSITE_ID="ee4621ff-c682-44ac-8cfa-1835beddb98a";(function(){d=document;s=d.createElement("script"); src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script>
13 </head> 70 </head>
14 <body> 71 <body>
15 - <nav class="menu"> 72 + <nav class="voi_menu">
16 <div class="menu_bar_logo"> 73 <div class="menu_bar_logo">
17 <i class="fas fa-microphone-alt"></i> 74 <i class="fas fa-microphone-alt"></i>
18 - <a href="Voico_Home.html">Voicoding</a> 75 + <a class = "basic" href="Voico_Menu.html">Voicoding</a>
19 </div> 76 </div>
20 <ul class="menu_bar_content"> 77 <ul class="menu_bar_content">
21 - <a href="Voico_Home.html"><li>Home</li></a> 78 + <a class = "basic" href="Voico_Home.html"><li>Home</li></a>
22 - <a href="\Manual.txt"><li>Manual</li></a> 79 + <a class = "basic" href="\Manual.txt"><li>Manual</li></a>
23 - <a href="Voico_Info.html"><li>info</li></a> 80 + <a class = "basic" href="Voico_Info.html"><li>Info</li></a>
24 </ul> 81 </ul>
25 <ul class="menu_bar_icons"> 82 <ul class="menu_bar_icons">
26 - <li><a = href="https://www.instagram.com/waterinbottle48/"><i class="fab fa-instagram"></i></a></li> 83 + <li><a class = "basic" href="https://www.instagram.com/waterinbottle48/"><i class="fab fa-instagram"></i></a></li>
27 - <li><a = href="http://khuhub.khu.ac.kr/2019102168/Voicoding"><i class="fab fa-github"></i></a></li> 84 + <li><a class = "basic" href="http://khuhub.khu.ac.kr/2019102168/Voicoding"><i class="fab fa-github"></i></a></li>
28 </ul> 85 </ul>
29 <a href="#" class="menu_toggle"><i class="fas fa-bars"></i></a> 86 <a href="#" class="menu_toggle"><i class="fas fa-bars"></i></a>
30 </nav> 87 </nav>
...@@ -32,8 +89,107 @@ ...@@ -32,8 +89,107 @@
32 <button id="recordButton">Speech</button> 89 <button id="recordButton">Speech</button>
33 <button id="transcribeButton" disabled>To text</button> 90 <button id="transcribeButton" disabled>To text</button>
34 </div> 91 </div>
92 + <div class="output_bar">
93 + <h2>Transcription Raw Data</h2>
94 + </div>
35 <div id="output"></div> 95 <div id="output"></div>
36 - <script src="https://cdn.rawgit.com/mattdiamond/Recorderjs/08e7abd9/dist/recorder.js"></script> 96 + <i class="fas fa-arrow-circle-down"></i>
37 - <script src="\client.js"></script> 97 + <div class="output_bar">
98 + <h2>TTP</h2>
99 + </div>
100 + <div id="site-navigation" class="ui small inverted menu" style="margin:20px 20px 0px 20px;">
101 + <div id="site-header" class="header item">
102 +
103 + </div>
104 + <div class="left menu" >
105 + <div class="ui dropdown item site-links on-hover">
106 + File <i class="dropdown icon"></i>
107 + <div class="menu">
108 + <a class="item" target="_blank" href="/"><i class="file code icon"></i> New File</a>
109 + <div class="item" onclick="downloadSource()"><i class="download icon"></i> Download</div>
110 + <div id="insert-template-btn" class="item"><i class="file code outline icon"></i> Insert template
111 + for current language</div>
112 + </div>
113 + </div>
114 +
115 + <div class="item borderless">
116 +
117 + </div>
118 + <div class="item fitted borderless wide screen only">
119 + <div class="ui input">
120 + <p id="compiler-options" type="text" placeholder="Compiler options"></p>
121 + </div>
122 + </div>
123 + <div class="item borderless wide screen only">
124 + <div class="ui input">
125 + <p id="command-line-arguments" type="text" placeholder="Command line arguments"></p>
126 + </div>
127 + </div>
128 + <div class="item no-left-padding borderless">
129 + <button id="run-btn" class="ui primary labeled icon button"><i class="play icon"></i>Run (F9)</button>
130 + </div>
131 +
132 + </div>
133 +
134 + </div>
135 +
136 + <div id="site-content"style="margin:0px 20px 20px 20px;"></div>
137 +
138 + <div id="site-modal" class="ui modal">
139 + <div class="header">
140 + <i class="close icon"></i>
141 + <span id="title"></span>
142 + </div>
143 + <div class="scrolling content"></div>
144 + <div class="actions">
145 + <div class="ui small labeled icon cancel button">
146 + <i class="remove icon"></i>
147 + Close (ESC)
148 + </div>
149 + </div>
150 + </div>
151 +
152 + <div id="site-settings" class="ui modal">
153 + <i class="close icon"></i>
154 + <div class="header">
155 + <i class="cog icon"></i>
156 + Settings
157 + </div>
158 + <div class="content">
159 + <div class="ui form">
160 + <div class="inline fields">
161 + <label>Editor Mode</label>
162 + <div class="field">
163 + <div class="ui radio checkbox">
164 + <input type="radio" name="editor-mode" value="normal" checked="checked">
165 + <label>Normal</label>
166 + </div>
167 + </div>
168 + <div class="field">
169 + <div class="ui radio checkbox">
170 + <input type="radio" name="editor-mode" value="vim">
171 + <label>Vim</label>
172 + </div>
173 + </div>
174 + <div class="field">
175 + <div class="ui radio checkbox">
176 + <input type="radio" name="editor-mode" value="emacs">
177 + <label>Emacs</label>
178 + </div>
179 + </div>
180 + </div>
181 + <div class="inline field">
182 + <div class="ui checkbox">
183 + <input type="checkbox" name="redirect-output">
184 + <label>Redirect stderr to stdout</label>
185 + </div>
186 + </div>
187 + </div>
188 + </div>
189 + </div>
190 +
191 +
192 + <div id="editor-status-line"></div>
193 +
38 </body> 194 </body>
39 </html> 195 </html>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -13,7 +13,7 @@ a{ ...@@ -13,7 +13,7 @@ a{
13 color:var(--text-color); 13 color:var(--text-color);
14 14
15 } 15 }
16 -.menu{ 16 +.voi_menu{
17 display:flex; 17 display:flex;
18 justify-content:space-between; 18 justify-content:space-between;
19 align-items:center; 19 align-items:center;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
12 <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300&display=swap" rel="stylesheet"> 12 <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300&display=swap" rel="stylesheet">
13 </head> 13 </head>
14 <body> 14 <body>
15 - <nav class="menu"> 15 + <nav class="voi_menu">
16 <div class="menu_bar_logo"> 16 <div class="menu_bar_logo">
17 <i class="fas fa-microphone-alt"></i> 17 <i class="fas fa-microphone-alt"></i>
18 <a href="Voico_Home.html">Voicoding</a> 18 <a href="Voico_Home.html">Voicoding</a>
......
...@@ -13,7 +13,7 @@ a{ ...@@ -13,7 +13,7 @@ a{
13 color:var(--text-color); 13 color:var(--text-color);
14 14
15 } 15 }
16 -.menu{ 16 +.voi_menu{
17 display:flex; 17 display:flex;
18 justify-content:space-between; 18 justify-content:space-between;
19 align-items:center; 19 align-items:center;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
12 <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300&display=swap" rel="stylesheet"> 12 <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300&display=swap" rel="stylesheet">
13 </head> 13 </head>
14 <body> 14 <body>
15 - <nav class="menu"> 15 + <nav class="voi_menu">
16 <div class="menu_bar_logo"> 16 <div class="menu_bar_logo">
17 <i class="fas fa-microphone-alt"></i> 17 <i class="fas fa-microphone-alt"></i>
18 <a href="Voico_Home.html">Voicoding</a> 18 <a href="Voico_Home.html">Voicoding</a>
......
...@@ -4,6 +4,7 @@ const recordButton = document.getElementById("recordButton"); ...@@ -4,6 +4,7 @@ const recordButton = document.getElementById("recordButton");
4 const transcribeButton = document.getElementById("transcribeButton"); 4 const transcribeButton = document.getElementById("transcribeButton");
5 recordButton.addEventListener("click", startRecording); 5 recordButton.addEventListener("click", startRecording);
6 transcribeButton.addEventListener("click", transcribeText); 6 transcribeButton.addEventListener("click", transcribeText);
7 +let cnt = 0;
7 function startRecording() { 8 function startRecording() {
8 let constraints = { audio: true, video:false } 9 let constraints = { audio: true, video:false }
9 recordButton.disabled = true; 10 recordButton.disabled = true;
...@@ -32,7 +33,7 @@ function uploadSoundData(blob) { ...@@ -32,7 +33,7 @@ function uploadSoundData(blob) {
32 let formData = new FormData(); 33 let formData = new FormData();
33 xhr.onload = function(e) { 34 xhr.onload = function(e) {
34 if(this.readyState === 4) { 35 if(this.readyState === 4) {
35 - document.getElementById("output").innerHTML += '<br><br><strong>Result: </strong>' + JSON.parse(e.target.responseText); 36 + document.getElementById("output").innerHTML += `${cnt++}: ${JSON.parse(e.target.responseText)}<br>`;
36 } 37 }
37 }; 38 };
38 formData.append("audio_data", blob, filename); 39 formData.append("audio_data", blob, filename);
......
1 +body {
2 + background: url(/images/judge0_background.png) no-repeat center center fixed;
3 + -webkit-background-size: cover;
4 + -moz-background-size: cover;
5 + -o-background-size: cover;
6 + background-size: cover;
7 +}
8 +
9 +.ui[class*="left action"].input>.dropdown {
10 + border-radius: 0 .28571429rem .28571429rem 0;
11 +}
12 +
13 +.ui.selection.dropdown {
14 + width: 205px;
15 +}
16 +
17 +.lm_header .lm_tab {
18 + padding-bottom: 3px;
19 + height: 16px;
20 + font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback";
21 + font-size: 14px;
22 +}
23 +
24 +.lm_header .lm_tab.lm_active {
25 + box-shadow: none;
26 + padding-bottom: 3px;
27 +}
28 +
29 +#site-navigation {
30 + border-radius: 0;
31 + margin: 0;
32 + background: #1e1e1e;
33 + border-bottom: 1px solid rgba(255, 255, 255, 0.08);
34 + height: 45px;
35 +}
36 +
37 +#navigation-message {
38 + font-size: 1.2em;
39 + white-space: nowrap;
40 + overflow: hidden;
41 +}
42 +
43 +@keyframes slide {
44 + 0% { transform: translateX(570px); }
45 + 100% { transform: translateX(-100%); }
46 +}
47 +@-webkit-keyframes slide {
48 + 0% { transform: translateX(570px); }
49 + 100% { transform: translateX(-100%); }
50 +}
51 +
52 +.navigation-message-text {
53 + white-space: nowrap;
54 + -moz-animation: slide 60s linear infinite;
55 + -webkit-animation: slide 60s linear infinite;
56 + animation: slide 60s linear infinite;
57 +}
58 +
59 +.navigation-message-text:hover {
60 + -moz-animation-play-state: paused;
61 + -webkit-animation-play-state: paused;
62 + animation-play-state: paused;
63 +}
64 +
65 +#navigation-message a {
66 + color: #41a5f1;
67 + font-weight: bold;
68 +}
69 +
70 +#site-icon {
71 + width: 30px;
72 + height: 30px;
73 + vertical-align: middle;
74 +}
75 +
76 +#site-header {
77 + padding-left: 0;
78 + padding-top: 0;
79 + padding-bottom: 0;
80 +}
81 +
82 +#site-header h2 {
83 + display: inline;
84 + vertical-align: middle;
85 + font-family: 'Exo 2', sans-serif;
86 +}
87 +
88 +#site-content {
89 + display:flex;
90 + height: calc(100% - 45px - 19px);
91 +}
92 +
93 +#site-modal .header {
94 + color: #db2828;
95 +}
96 +
97 +#site-footer, #status-line, #donate-line {
98 + background-color: #0E6EB8;
99 + bottom: 0;
100 + font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback";
101 + font-size: 13px;
102 + height: 19px;
103 + padding-left: 16px;
104 + padding-right: 16px;
105 + position: fixed;
106 +}
107 +
108 +#site-footer {
109 + color: #41a5f1;
110 + left: 0;
111 + text-align: center;
112 + width: 100%;
113 +}
114 +
115 +#site-footer a {
116 + color: #41a5f1;
117 + font-weight: bold;
118 +}
119 +
120 +#site-footer a:hover {
121 + color: #a0d2f8;
122 +}
123 +
124 +#donate-line {
125 + float: left;
126 + left: 0;
127 + text-align: left;
128 + width: fit-content;
129 +}
130 +
131 +#status-line {
132 + color: #fff;
133 + float: right;
134 + right: 0;
135 + text-align: right;
136 + width: fit-content;
137 +}
138 +
139 +#editor-status-line {
140 + background: transparent;
141 + color: #fff;
142 + font-family: monospace;
143 + height: 19px;
144 + padding: 0px 16px;
145 + width: inherit;
146 +}
147 +
148 +#editor-status-line input[type=text] {
149 + background: transparent;
150 + border: none;
151 + color: #fff;
152 + font-family: monospace;
153 + outline: none;
154 +}
155 +
156 +#editor-status-line input[type=text]::selection {
157 + background-color: #cce2ff;
158 + color: #fff;
159 +}
160 +
161 +.blink {
162 + animation: blinker 1s linear infinite;
163 +}
164 +
165 +@keyframes blinker {
166 + 50% {
167 + background: #FFD700;
168 + }
169 +}
170 +
171 +.dot {
172 + background: #0E6EB8;
173 + position: absolute;
174 + border-radius: 50px;
175 + width: 5px;
176 + height: 5px;
177 + right: 7.5px;
178 + top: 7.5px;
179 +}
180 +
181 +.no-left-padding {
182 + padding-left: 0 !important;
183 +}
184 +
185 +input[type="text"] {
186 + width: 205px !important;
187 +}
...\ No newline at end of file ...\ No newline at end of file
1 +var defaultUrl = localStorageGetItem("api-url") || "https://ce.judge0.com";
2 +var apiUrl = defaultUrl;
3 +var wait = localStorageGetItem("wait") || false;
4 +var check_timeout = 300;
5 +
6 +var blinkStatusLine = ((localStorageGetItem("blink") || "true") === "true");
7 +var editorMode = localStorageGetItem("editorMode") || "normal";
8 +var redirectStderrToStdout = ((localStorageGetItem("redirectStderrToStdout") || "false") === "true");
9 +var editorModeObject = null;
10 +
11 +var fontSize = 14;
12 +
13 +var MonacoVim;
14 +var MonacoEmacs;
15 +
16 +var layout;
17 +
18 +var sourceEditor;
19 +var stdinEditor;
20 +var stdoutEditor;
21 +var stderrEditor;
22 +var compileOutputEditor;
23 +var sandboxMessageEditor;
24 +
25 +var isEditorDirty = false;
26 +var currentLanguageId;
27 +
28 +var $selectLanguage;
29 +var $compilerOptions;
30 +var $commandLineArguments;
31 +var $insertTemplateBtn;
32 +var $runBtn;
33 +var $navigationMessage;
34 +var $updates;
35 +var $statusLine;
36 +
37 +var timeStart;
38 +var timeEnd;
39 +
40 +var messagesData;
41 +
42 +var layoutConfig = {
43 + settings: {
44 + showPopoutIcon: false,
45 + reorderEnabled: true
46 + },
47 + dimensions: {
48 + borderWidth: 3,
49 + headerHeight: 22
50 + },
51 + content: [{
52 + type: "row",
53 + content: [{
54 + type: "component",
55 + componentName: "source",
56 + title: "SOURCE",
57 + isClosable: false,
58 + componentState: {
59 + readOnly: false
60 + },
61 + width: 60
62 + }, {
63 + type: "column",
64 + content: [{
65 + type: "stack",
66 + content: [{
67 + type: "component",
68 + componentName: "stdin",
69 + title: "STDIN",
70 + isClosable: false,
71 + componentState: {
72 + readOnly: false
73 + }
74 + }]
75 + }, {
76 + type: "stack",
77 + content: [{
78 + type: "component",
79 + componentName: "stdout",
80 + title: "STDOUT",
81 + isClosable: false,
82 + componentState: {
83 + readOnly: true
84 + }
85 + }, {
86 + type: "component",
87 + componentName: "stderr",
88 + title: "STDERR",
89 + isClosable: false,
90 + componentState: {
91 + readOnly: true
92 + }
93 + }, {
94 + type: "component",
95 + componentName: "compile output",
96 + title: "COMPILE OUTPUT",
97 + isClosable: false,
98 + componentState: {
99 + readOnly: true
100 + }
101 + }, {
102 + type: "component",
103 + componentName: "sandbox message",
104 + title: "SANDBOX MESSAGE",
105 + isClosable: false,
106 + componentState: {
107 + readOnly: true
108 + }
109 + }]
110 + }]
111 + }]
112 + }]
113 +};
114 +
115 +function encode(str) {
116 + return btoa(unescape(encodeURIComponent(str || "")));
117 +}
118 +
119 +function decode(bytes) {
120 + var escaped = escape(atob(bytes || ""));
121 + try {
122 + return decodeURIComponent(escaped);
123 + } catch {
124 + return unescape(escaped);
125 + }
126 +}
127 +
128 +function localStorageSetItem(key, value) {
129 + try {
130 + localStorage.setItem(key, value);
131 + } catch (ignorable) {
132 + }
133 +}
134 +
135 +function localStorageGetItem(key) {
136 + try {
137 + return localStorage.getItem(key);
138 + } catch (ignorable) {
139 + return null;
140 + }
141 +}
142 +
143 +function showMessages() {
144 + var width = 100//$updates.offset().left - parseFloat($updates.css("padding-left")) -
145 + //$navigationMessage.parent().offset().left - parseFloat($navigationMessage.parent().css("padding-left")) - 5;
146 +
147 + if (width < 200 || messagesData === undefined) {
148 + return;
149 + }
150 +
151 + var messages = messagesData["messages"];
152 +
153 + $navigationMessage.css("animation-duration", messagesData["duration"]);
154 + $navigationMessage.parent().width(width - 5);
155 +
156 + var combinedMessage = "";
157 + for (var i = 0; i < messages.length; ++i) {
158 + combinedMessage += `${messages[i]}`;
159 + if (i != messages.length - 1) {
160 + combinedMessage += "&nbsp".repeat(Math.min(200, messages[i].length));
161 + }
162 + }
163 +
164 + $navigationMessage.html(combinedMessage);
165 +}
166 +
167 +function loadMessages() {
168 + $.ajax({
169 + url: `https://minio.judge0.com/public/ide/messages.json?${Date.now()}`,
170 + type: "GET",
171 + headers: {
172 + "Accept": "application/json"
173 + },
174 + success: function (data, textStatus, jqXHR) {
175 + messagesData = data;
176 + showMessages();
177 + }
178 + });
179 +}
180 +
181 +function showError(title, content) {
182 + $("#site-modal #title").html(title);
183 + $("#site-modal .content").html(content);
184 + $("#site-modal").modal("show");
185 +}
186 +
187 +function handleError(jqXHR, textStatus, errorThrown) {
188 + showError(`${jqXHR.statusText} (${jqXHR.status})`, `<pre>${JSON.stringify(jqXHR, null, 4)}</pre>`);
189 +}
190 +
191 +function handleRunError(jqXHR, textStatus, errorThrown) {
192 + handleError(jqXHR, textStatus, errorThrown);
193 + $runBtn.removeClass("loading");
194 +}
195 +
196 +function handleResult(data) {
197 + timeEnd = performance.now();
198 + console.log("It took " + (timeEnd - timeStart) + " ms to get submission result.");
199 +
200 + var status = data.status;
201 + var stdout = decode(data.stdout);
202 + var stderr = decode(data.stderr);
203 + var compile_output = decode(data.compile_output);
204 + var sandbox_message = decode(data.message);
205 + var time = (data.time === null ? "-" : data.time + "s");
206 + var memory = (data.memory === null ? "-" : data.memory + "KB");
207 +
208 + $statusLine.html(`${status.description}, ${time}, ${memory}`);
209 +
210 + if (blinkStatusLine) {
211 + $statusLine.addClass("blink");
212 + setTimeout(function() {
213 + blinkStatusLine = false;
214 + localStorageSetItem("blink", "false");
215 + $statusLine.removeClass("blink");
216 + }, 3000);
217 + }
218 +
219 + stdoutEditor.setValue(stdout);
220 + stderrEditor.setValue(stderr);
221 + compileOutputEditor.setValue(compile_output);
222 + sandboxMessageEditor.setValue(sandbox_message);
223 +
224 + if (stdout !== "") {
225 + var dot = document.getElementById("stdout-dot");
226 + if (!dot.parentElement.classList.contains("lm_active")) {
227 + dot.hidden = false;
228 + }
229 + }
230 + if (stderr !== "") {
231 + var dot = document.getElementById("stderr-dot");
232 + if (!dot.parentElement.classList.contains("lm_active")) {
233 + dot.hidden = false;
234 + }
235 + }
236 + if (compile_output !== "") {
237 + var dot = document.getElementById("compile-output-dot");
238 + if (!dot.parentElement.classList.contains("lm_active")) {
239 + dot.hidden = false;
240 + }
241 + }
242 + if (sandbox_message !== "") {
243 + var dot = document.getElementById("sandbox-message-dot");
244 + if (!dot.parentElement.classList.contains("lm_active")) {
245 + dot.hidden = false;
246 + }
247 + }
248 +
249 + $runBtn.removeClass("loading");
250 +}
251 +
252 +function getIdFromURI() {
253 + var uri = location.search.substr(1).trim();
254 + return uri.split("&")[0];
255 +}
256 +
257 +function downloadSource() {
258 + var value = parseInt(71);
259 + download(sourceEditor.getValue(), fileNames[value], "text/plain");
260 +}
261 +
262 +function loadSavedSource() {
263 + snippet_id = getIdFromURI();
264 +
265 + if (snippet_id.length == 36) {
266 + $.ajax({
267 + url: apiUrl + "/submissions/" + snippet_id + "?fields=source_code,language_id,stdin,stdout,stderr,compile_output,message,time,memory,status,compiler_options,command_line_arguments&base64_encoded=true",
268 + type: "GET",
269 + success: function(data, textStatus, jqXHR) {
270 + sourceEditor.setValue(decode(data["source_code"]));
271 + $selectLanguage.dropdown("set selected", data["language_id"]);
272 + $compilerOptions.val(data["compiler_options"]);
273 + $commandLineArguments.val(data["command_line_arguments"]);
274 + stdinEditor.setValue(decode(data["stdin"]));
275 + stdoutEditor.setValue(decode(data["stdout"]));
276 + stderrEditor.setValue(decode(data["stderr"]));
277 + compileOutputEditor.setValue(decode(data["compile_output"]));
278 + sandboxMessageEditor.setValue(decode(data["message"]));
279 + var time = (data.time === null ? "-" : data.time + "s");
280 + var memory = (data.memory === null ? "-" : data.memory + "KB");
281 + $statusLine.html(`${data.status.description}, ${time}, ${memory}`);
282 + changeEditorLanguage();
283 + },
284 + error: handleRunError
285 + });
286 + } else {
287 + loadRandomLanguage();
288 + }
289 +}
290 +
291 +function run() {
292 + if (sourceEditor.getValue().trim() === "") {
293 + showError("Error", "Source code can't be empty!");
294 + return;
295 + } else {
296 + $runBtn.addClass("loading");
297 + }
298 +
299 + document.getElementById("stdout-dot").hidden = true;
300 + document.getElementById("stderr-dot").hidden = true;
301 + document.getElementById("compile-output-dot").hidden = true;
302 + document.getElementById("sandbox-message-dot").hidden = true;
303 +
304 + stdoutEditor.setValue("");
305 + stderrEditor.setValue("");
306 + compileOutputEditor.setValue("");
307 + sandboxMessageEditor.setValue("");
308 +
309 + var sourceValue = encode(sourceEditor.getValue());
310 + var stdinValue = encode(stdinEditor.getValue());
311 + var languageId = resolveLanguageId(71);
312 + var compilerOptions = $compilerOptions.val();
313 + var commandLineArguments = $commandLineArguments.val();
314 +
315 + if (parseInt(languageId) === 44) {
316 + sourceValue = sourceEditor.getValue();
317 + }
318 +
319 + var data = {
320 + source_code: sourceValue,
321 + language_id: languageId,
322 + stdin: stdinValue,
323 + compiler_options: compilerOptions,
324 + command_line_arguments: commandLineArguments,
325 + redirect_stderr_to_stdout: redirectStderrToStdout
326 + };
327 +
328 + var sendRequest = function(data) {
329 + timeStart = performance.now();
330 + $.ajax({
331 + url: apiUrl + `/submissions?base64_encoded=true&wait=${wait}`,
332 + type: "POST",
333 + async: true,
334 + contentType: "application/json",
335 + data: JSON.stringify(data),
336 + xhrFields: {
337 + withCredentials: apiUrl.indexOf("/secure") != -1 ? true : false
338 + },
339 + success: function (data, textStatus, jqXHR) {
340 + console.log(`Your submission token is: ${data.token}`);
341 + if (wait == true) {
342 + handleResult(data);
343 + } else {
344 + setTimeout(fetchSubmission.bind(null, data.token), check_timeout);
345 + }
346 + },
347 + error: handleRunError
348 + });
349 + }
350 +
351 + var fetchAdditionalFiles = false;
352 + if (parseInt(languageId) === 82) {
353 + if (sqliteAdditionalFiles === "") {
354 + fetchAdditionalFiles = true;
355 + $.ajax({
356 + url: `https://minio.judge0.com/public/ide/sqliteAdditionalFiles.base64.txt?${Date.now()}`,
357 + type: "GET",
358 + async: true,
359 + contentType: "text/plain",
360 + success: function (responseData, textStatus, jqXHR) {
361 + sqliteAdditionalFiles = responseData;
362 + data["additional_files"] = sqliteAdditionalFiles;
363 + sendRequest(data);
364 + },
365 + error: handleRunError
366 + });
367 + }
368 + else {
369 + data["additional_files"] = sqliteAdditionalFiles;
370 + }
371 + }
372 +
373 + if (!fetchAdditionalFiles) {
374 + sendRequest(data);
375 + }
376 +}
377 +
378 +function fetchSubmission(submission_token) {
379 + $.ajax({
380 + url: apiUrl + "/submissions/" + submission_token + "?base64_encoded=true",
381 + type: "GET",
382 + async: true,
383 + success: function (data, textStatus, jqXHR) {
384 + if (data.status.id <= 2) { // In Queue or Processing
385 + setTimeout(fetchSubmission.bind(null, submission_token), check_timeout);
386 + return;
387 + }
388 + handleResult(data);
389 + },
390 + error: handleRunError
391 + });
392 +}
393 +
394 +function changeEditorLanguage() {
395 + monaco.editor.setModelLanguage(sourceEditor.getModel(), $selectLanguage.find(":selected").attr("mode"));
396 + currentLanguageId = parseInt(71);
397 + $(".lm_title")[0].innerText = fileNames[currentLanguageId];
398 + apiUrl = resolveApiUrl(71);
399 +}
400 +
401 +function insertTemplate() {
402 + currentLanguageId = parseInt(71);
403 + sourceEditor.setValue(sources[currentLanguageId]);
404 + changeEditorLanguage();
405 +}
406 +
407 +function loadRandomLanguage() {
408 + // $selectLanguage.dropdown("set selected", values[Math.floor(Math.random() * $selectLanguage[0].length)]);
409 + //$selectLanguage.dropdown("set selected", 71);
410 + apiUrl = resolveApiUrl(71);
411 + insertTemplate();
412 +}
413 +
414 +function resizeEditor(layoutInfo) {
415 + if (editorMode != "normal") {
416 + var statusLineHeight = $("#editor-status-line").height();
417 + layoutInfo.height -= statusLineHeight;
418 + layoutInfo.contentHeight -= statusLineHeight;
419 + }
420 +}
421 +
422 +function disposeEditorModeObject() {
423 + try {
424 + editorModeObject.dispose();
425 + editorModeObject = null;
426 + } catch(ignorable) {
427 + }
428 +}
429 +
430 +function changeEditorMode() {
431 + disposeEditorModeObject();
432 +
433 + if (editorMode == "vim") {
434 + editorModeObject = MonacoVim.initVimMode(sourceEditor, $("#editor-status-line")[0]);
435 + } else if (editorMode == "emacs") {
436 + var statusNode = $("#editor-status-line")[0];
437 + editorModeObject = new MonacoEmacs.EmacsExtension(sourceEditor);
438 + editorModeObject.onDidMarkChange(function(e) {
439 + statusNode.textContent = e ? "Mark Set!" : "Mark Unset";
440 + });
441 + editorModeObject.onDidChangeKey(function(str) {
442 + statusNode.textContent = str;
443 + });
444 + editorModeObject.start();
445 + }
446 +}
447 +
448 +function resolveLanguageId(id) {
449 + id = parseInt(id);
450 + return languageIdTable[id] || id;
451 +}
452 +
453 +function resolveApiUrl(id) {
454 + id = parseInt(id);
455 + return languageApiUrlTable[id] || defaultUrl;
456 +}
457 +
458 +function editorsUpdateFontSize(fontSize) {
459 + sourceEditor.updateOptions({fontSize: fontSize});
460 + stdinEditor.updateOptions({fontSize: fontSize});
461 + stdoutEditor.updateOptions({fontSize: fontSize});
462 + stderrEditor.updateOptions({fontSize: fontSize});
463 + compileOutputEditor.updateOptions({fontSize: fontSize});
464 + sandboxMessageEditor.updateOptions({fontSize: fontSize});
465 +}
466 +
467 +function updateScreenElements() {
468 + var display = window.innerWidth <= 1200 ? "none" : "";
469 + $(".wide.screen.only").each(function(index) {
470 + $(this).css("display", display);
471 + });
472 +}
473 +
474 +$(window).resize(function() {
475 + layout.updateSize();
476 + updateScreenElements();
477 + showMessages();
478 +});
479 +
480 +$(document).ready(function () {
481 + updateScreenElements();
482 +
483 + console.log("Hey, Judge0 IDE is open-sourced: https://github.com/judge0/ide. Have fun!");
484 +
485 + $selectLanguage = $("#select-language");
486 + $selectLanguage.change(function (e) {
487 + if (!isEditorDirty) {
488 + insertTemplate();
489 + } else {
490 + changeEditorLanguage();
491 + }
492 + });
493 +
494 + $compilerOptions = $("#compiler-options");
495 + $commandLineArguments = $("#command-line-arguments");
496 + $commandLineArguments.attr("size", $commandLineArguments.attr("placeholder").length);
497 +
498 + $insertTemplateBtn = $("#insert-template-btn");
499 + $insertTemplateBtn.click(function (e) {
500 + if (isEditorDirty && confirm("Are you sure? Your current changes will be lost.")) {
501 + insertTemplate();
502 + }
503 + });
504 +
505 + $runBtn = $("#run-btn");
506 + $runBtn.click(function (e) {
507 + run();
508 + });
509 +
510 + $navigationMessage = $("#navigation-message span");
511 + $updates = $("#judge0-more");
512 +
513 + $(`input[name="editor-mode"][value="${editorMode}"]`).prop("checked", true);
514 + $("input[name=\"editor-mode\"]").on("change", function(e) {
515 + editorMode = e.target.value;
516 + localStorageSetItem("editorMode", editorMode);
517 +
518 + resizeEditor(sourceEditor.getLayoutInfo());
519 + changeEditorMode();
520 +
521 + sourceEditor.focus();
522 + });
523 +
524 + $("input[name=\"redirect-output\"]").prop("checked", redirectStderrToStdout)
525 + $("input[name=\"redirect-output\"]").on("change", function(e) {
526 + redirectStderrToStdout = e.target.checked;
527 + localStorageSetItem("redirectStderrToStdout", redirectStderrToStdout);
528 + });
529 +
530 + $statusLine = $("#status-line");
531 +
532 + $("body").keydown(function (e) {
533 + var keyCode = e.keyCode || e.which;
534 + if (keyCode == 120) { // F9
535 + e.preventDefault();
536 + run();
537 + } else if (keyCode == 119) { // F8
538 + e.preventDefault();
539 + var url = prompt("Enter URL of Judge0 API:", apiUrl);
540 + if (url != null) {
541 + url = url.trim();
542 + }
543 + if (url != null && url != "") {
544 + apiUrl = url;
545 + localStorageSetItem("api-url", apiUrl);
546 + }
547 + } else if (keyCode == 118) { // F7
548 + e.preventDefault();
549 + wait = !wait;
550 + localStorageSetItem("wait", wait);
551 + alert(`Submission wait is ${wait ? "ON. Enjoy" : "OFF"}.`);
552 + } else if (event.ctrlKey && keyCode == 107) { // Ctrl++
553 + e.preventDefault();
554 + fontSize += 1;
555 + editorsUpdateFontSize(fontSize);
556 + } else if (event.ctrlKey && keyCode == 109) { // Ctrl+-
557 + e.preventDefault();
558 + fontSize -= 1;
559 + editorsUpdateFontSize(fontSize);
560 + }
561 + });
562 +
563 + $("select.dropdown").dropdown();
564 + $(".ui.dropdown").dropdown();
565 + $(".ui.dropdown.site-links").dropdown({action: "hide", on: "hover"});
566 + $(".ui.checkbox").checkbox();
567 + $(".message .close").on("click", function () {
568 + $(this).closest(".message").transition("fade");
569 + });
570 +
571 + loadMessages();
572 +
573 + require(["vs/editor/editor.main", "monaco-vim", "monaco-emacs"], function (ignorable, MVim, MEmacs) {
574 + layout = new GoldenLayout(layoutConfig, $("#site-content"));
575 +
576 + MonacoVim = MVim;
577 + MonacoEmacs = MEmacs;
578 +
579 + layout.registerComponent("source", function (container, state) {
580 + sourceEditor = monaco.editor.create(container.getElement()[0], {
581 + automaticLayout: true,
582 + theme: "vs-dark",
583 + scrollBeyondLastLine: true,
584 + readOnly: state.readOnly,
585 + language: "python",
586 + minimap: {
587 + enabled: false
588 + }
589 + });
590 +
591 + changeEditorMode();
592 +
593 + sourceEditor.getModel().onDidChangeContent(function (e) {
594 + currentLanguageId = parseInt(71);
595 + isEditorDirty = sourceEditor.getValue() != sources[currentLanguageId];
596 + });
597 +
598 + sourceEditor.onDidLayoutChange(resizeEditor);
599 + });
600 +
601 + layout.registerComponent("stdin", function (container, state) {
602 + stdinEditor = monaco.editor.create(container.getElement()[0], {
603 + automaticLayout: true,
604 + theme: "vs-dark",
605 + scrollBeyondLastLine: false,
606 + readOnly: state.readOnly,
607 + language: "plaintext",
608 + minimap: {
609 + enabled: false
610 + }
611 + });
612 + });
613 +
614 + layout.registerComponent("stdout", function (container, state) {
615 + stdoutEditor = monaco.editor.create(container.getElement()[0], {
616 + automaticLayout: true,
617 + theme: "vs-dark",
618 + scrollBeyondLastLine: false,
619 + readOnly: state.readOnly,
620 + language: "plaintext",
621 + minimap: {
622 + enabled: false
623 + }
624 + });
625 +
626 + container.on("tab", function(tab) {
627 + tab.element.append("<span id=\"stdout-dot\" class=\"dot\" hidden></span>");
628 + tab.element.on("mousedown", function(e) {
629 + e.target.closest(".lm_tab").children[3].hidden = true;
630 + });
631 + });
632 + });
633 +
634 + layout.registerComponent("stderr", function (container, state) {
635 + stderrEditor = monaco.editor.create(container.getElement()[0], {
636 + automaticLayout: true,
637 + theme: "vs-dark",
638 + scrollBeyondLastLine: false,
639 + readOnly: state.readOnly,
640 + language: "plaintext",
641 + minimap: {
642 + enabled: false
643 + }
644 + });
645 +
646 + container.on("tab", function(tab) {
647 + tab.element.append("<span id=\"stderr-dot\" class=\"dot\" hidden></span>");
648 + tab.element.on("mousedown", function(e) {
649 + e.target.closest(".lm_tab").children[3].hidden = true;
650 + });
651 + });
652 + });
653 +
654 + layout.registerComponent("compile output", function (container, state) {
655 + compileOutputEditor = monaco.editor.create(container.getElement()[0], {
656 + automaticLayout: true,
657 + theme: "vs-dark",
658 + scrollBeyondLastLine: false,
659 + readOnly: state.readOnly,
660 + language: "plaintext",
661 + minimap: {
662 + enabled: false
663 + }
664 + });
665 +
666 + container.on("tab", function(tab) {
667 + tab.element.append("<span id=\"compile-output-dot\" class=\"dot\" hidden></span>");
668 + tab.element.on("mousedown", function(e) {
669 + e.target.closest(".lm_tab").children[3].hidden = true;
670 + });
671 + });
672 + });
673 +
674 + layout.registerComponent("sandbox message", function (container, state) {
675 + sandboxMessageEditor = monaco.editor.create(container.getElement()[0], {
676 + automaticLayout: true,
677 + theme: "vs-dark",
678 + scrollBeyondLastLine: false,
679 + readOnly: state.readOnly,
680 + language: "plaintext",
681 + minimap: {
682 + enabled: false
683 + }
684 + });
685 +
686 + container.on("tab", function(tab) {
687 + tab.element.append("<span id=\"sandbox-message-dot\" class=\"dot\" hidden></span>");
688 + tab.element.on("mousedown", function(e) {
689 + e.target.closest(".lm_tab").children[3].hidden = true;
690 + });
691 + });
692 + });
693 +
694 + layout.on("initialised", function () {
695 + $(".monaco-editor")[0].appendChild($("#editor-status-line")[0]);
696 + if (getIdFromURI()) {
697 + loadSavedSource();
698 + } else {
699 + loadRandomLanguage();
700 + }
701 + $("#site-navigation").css("border-bottom", "1px solid black");
702 + sourceEditor.focus();
703 + editorsUpdateFontSize(fontSize);
704 + });
705 +
706 + layout.init();
707 + });
708 +});
709 +
710 +// Template Sources
711 +var assemblySource = "\
712 +section .text\n\
713 + global _start\n\
714 +\n\
715 +_start:\n\
716 +\n\
717 + xor eax, eax\n\
718 + lea edx, [rax+len]\n\
719 + mov al, 1\n\
720 + mov esi, msg\n\
721 + mov edi, eax\n\
722 + syscall\n\
723 +\n\
724 + xor edi, edi\n\
725 + lea eax, [rdi+60]\n\
726 + syscall\n\
727 +\n\
728 +section .rodata\n\
729 +\n\
730 +msg db 'hello, world', 0xa\n\
731 +len equ $ - msg\n\
732 +";
733 +
734 +var bashSource = "echo \"hello, world\"";
735 +
736 +var basicSource = "PRINT \"hello, world\"";
737 +
738 +var cSource = "\
739 +// Powered by Judge0\n\
740 +#include <stdio.h>\n\
741 +\n\
742 +int main(void) {\n\
743 + printf(\"Hello Judge0!\\n\");\n\
744 + return 0;\n\
745 +}\n\
746 +";
747 +
748 +var csharpSource = "\
749 +public class Hello {\n\
750 + public static void Main() {\n\
751 + System.Console.WriteLine(\"hello, world\");\n\
752 + }\n\
753 +}\n\
754 +";
755 +
756 +var cppSource = "\
757 +#include <iostream>\n\
758 +\n\
759 +int main() {\n\
760 + std::cout << \"hello, world\" << std::endl;\n\
761 + return 0;\n\
762 +}\n\
763 +";
764 +
765 +var clojureSource = "(println \"hello, world\")\n";
766 +
767 +var cobolSource = "\
768 +IDENTIFICATION DIVISION.\n\
769 +PROGRAM-ID. MAIN.\n\
770 +PROCEDURE DIVISION.\n\
771 +DISPLAY \"hello, world\".\n\
772 +STOP RUN.\n\
773 +";
774 +
775 +var lispSource = "(write-line \"hello, world\")";
776 +
777 +var dSource = "\
778 +import std.stdio;\n\
779 +\n\
780 +void main()\n\
781 +{\n\
782 + writeln(\"hello, world\");\n\
783 +}\n\
784 +";
785 +
786 +var elixirSource = "IO.puts \"hello, world\"";
787 +
788 +var erlangSource = "\
789 +main(_) ->\n\
790 + io:fwrite(\"hello, world\\n\").\n\
791 +";
792 +
793 +var executableSource = "\
794 +Judge0 IDE assumes that content of executable is Base64 encoded.\n\
795 +\n\
796 +This means that you should Base64 encode content of your binary,\n\
797 +paste it here and click \"Run\".\n\
798 +\n\
799 +Here is an example of compiled \"hello, world\" NASM program.\n\
800 +Content of compiled binary is Base64 encoded and used as source code.\n\
801 +\n\
802 +https://ide.judge0.com/?kS_f\n\
803 +";
804 +
805 +var fsharpSource = "printfn \"hello, world\"\n";
806 +
807 +var fortranSource = "\
808 +program main\n\
809 + print *, \"hello, world\"\n\
810 +end\n\
811 +";
812 +
813 +var goSource = "\
814 +package main\n\
815 +\n\
816 +import \"fmt\"\n\
817 +\n\
818 +func main() {\n\
819 + fmt.Println(\"hello, world\")\n\
820 +}\n\
821 +";
822 +
823 +var groovySource = "println \"hello, world\"\n";
824 +
825 +var haskellSource = "main = putStrLn \"hello, world\"";
826 +
827 +var javaSource = "\
828 +public class Main {\n\
829 + public static void main(String[] args) {\n\
830 + System.out.println(\"hello, world\");\n\
831 + }\n\
832 +}\n\
833 +";
834 +
835 +var javaScriptSource = "console.log(\"hello, world\");";
836 +
837 +var kotlinSource = "\
838 +fun main() {\n\
839 + println(\"hello, world\")\n\
840 +}\n\
841 +";
842 +
843 +var luaSource = "print(\"hello, world\")";
844 +
845 +var objectiveCSource = "\
846 +#import <Foundation/Foundation.h>\n\
847 +\n\
848 +int main() {\n\
849 + @autoreleasepool {\n\
850 + char name[10];\n\
851 + scanf(\"%s\", name);\n\
852 + NSString *message = [NSString stringWithFormat:@\"hello, %s\\n\", name];\n\
853 + printf(\"%s\", message.UTF8String);\n\
854 + }\n\
855 + return 0;\n\
856 +}\n\
857 +";
858 +
859 +var ocamlSource = "print_endline \"hello, world\"";
860 +
861 +var octaveSource = "printf(\"hello, world\\n\");";
862 +
863 +var pascalSource = "\
864 +program Hello;\n\
865 +begin\n\
866 + writeln ('hello, world')\n\
867 +end.\n\
868 +";
869 +
870 +var perlSource = "\
871 +my $name = <STDIN>;\n\
872 +print \"hello, $name\";\n\
873 +";
874 +
875 +var phpSource = "\
876 +<?php\n\
877 +print(\"hello, world\\n\");\n\
878 +?>\n\
879 +";
880 +
881 +var plainTextSource = "hello, world\n";
882 +
883 +var prologSource = "\
884 +:- initialization(main).\n\
885 +main :- write('hello, world\\n').\n\
886 +";
887 +
888 +var pythonSource = "print(\"hello, world\")";
889 +
890 +var rSource = "cat(\"hello, world\\n\")";
891 +
892 +var rubySource = "puts \"hello, world\"";
893 +
894 +var rustSource = "\
895 +fn main() {\n\
896 + println!(\"hello, world\");\n\
897 +}\n\
898 +";
899 +
900 +var scalaSource = "\
901 +object Main {\n\
902 + def main(args: Array[String]) = {\n\
903 + val name = scala.io.StdIn.readLine()\n\
904 + println(\"hello, \"+ name)\n\
905 + }\n\
906 +}\n\
907 +";
908 +
909 +var sqliteSource = "\
910 +-- On Judge0 IDE your SQL script is run on chinook database (https://www.sqlitetutorial.net/sqlite-sample-database).\n\
911 +-- For more information about how to use SQL with Judge0 API please\n\
912 +-- watch this asciicast: https://asciinema.org/a/326975.\n\
913 +SELECT\n\
914 + Name, COUNT(*) AS num_albums\n\
915 +FROM artists JOIN albums\n\
916 +ON albums.ArtistID = artists.ArtistID\n\
917 +GROUP BY Name\n\
918 +ORDER BY num_albums DESC\n\
919 +LIMIT 4;\n\
920 +";
921 +var sqliteAdditionalFiles = "";
922 +
923 +var swiftSource = "\
924 +import Foundation\n\
925 +let name = readLine()\n\
926 +print(\"hello, \\(name!)\")\n\
927 +";
928 +
929 +var typescriptSource = "console.log(\"hello, world\");";
930 +
931 +var vbSource = "\
932 +Public Module Program\n\
933 + Public Sub Main()\n\
934 + Console.WriteLine(\"hello, world\")\n\
935 + End Sub\n\
936 +End Module\n\
937 +";
938 +
939 +var c3Source = "\
940 +// On the Judge0 IDE, C3 is automatically\n\
941 +// updated every hour to the latest commit on master branch.\n\
942 +module main;\n\
943 +\n\
944 +extern func void printf(char *str, ...);\n\
945 +\n\
946 +func int main()\n\
947 +{\n\
948 + printf(\"hello, world\\n\");\n\
949 + return 0;\n\
950 +}\n\
951 +";
952 +
953 +var javaTestSource = "\
954 +import static org.junit.jupiter.api.Assertions.assertEquals;\n\
955 +\n\
956 +import org.junit.jupiter.api.Test;\n\
957 +\n\
958 +class MainTest {\n\
959 + static class Calculator {\n\
960 + public int add(int x, int y) {\n\
961 + return x + y;\n\
962 + }\n\
963 + }\n\
964 +\n\
965 + private final Calculator calculator = new Calculator();\n\
966 +\n\
967 + @Test\n\
968 + void addition() {\n\
969 + assertEquals(2, calculator.add(1, 1));\n\
970 + }\n\
971 +}\n\
972 +";
973 +
974 +var mpiccSource = "\
975 +// Try adding \"-n 5\" (without quotes) into command line arguments. \n\
976 +#include <mpi.h>\n\
977 +\n\
978 +#include <stdio.h>\n\
979 +\n\
980 +int main()\n\
981 +{\n\
982 + MPI_Init(NULL, NULL);\n\
983 +\n\
984 + int world_size;\n\
985 + MPI_Comm_size(MPI_COMM_WORLD, &world_size);\n\
986 +\n\
987 + int world_rank;\n\
988 + MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);\n\
989 +\n\
990 + printf(\"Hello from processor with rank %d out of %d processors.\\n\", world_rank, world_size);\n\
991 +\n\
992 + MPI_Finalize();\n\
993 +\n\
994 + return 0;\n\
995 +}\n\
996 +";
997 +
998 +var mpicxxSource = "\
999 +// Try adding \"-n 5\" (without quotes) into command line arguments. \n\
1000 +#include <mpi.h>\n\
1001 +\n\
1002 +#include <iostream>\n\
1003 +\n\
1004 +int main()\n\
1005 +{\n\
1006 + MPI_Init(NULL, NULL);\n\
1007 +\n\
1008 + int world_size;\n\
1009 + MPI_Comm_size(MPI_COMM_WORLD, &world_size);\n\
1010 +\n\
1011 + int world_rank;\n\
1012 + MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);\n\
1013 +\n\
1014 + std::cout << \"Hello from processor with rank \"\n\
1015 + << world_rank << \" out of \" << world_size << \" processors.\\n\";\n\
1016 +\n\
1017 + MPI_Finalize();\n\
1018 +\n\
1019 + return 0;\n\
1020 +}\n\
1021 +";
1022 +
1023 +var mpipySource = "\
1024 +# Try adding \"-n 5\" (without quotes) into command line arguments. \n\
1025 +from mpi4py import MPI\n\
1026 +\n\
1027 +comm = MPI.COMM_WORLD\n\
1028 +world_size = comm.Get_size()\n\
1029 +world_rank = comm.Get_rank()\n\
1030 +\n\
1031 +print(f\"Hello from processor with rank {world_rank} out of {world_size} processors\")\n\
1032 +";
1033 +
1034 +var nimSource = "\
1035 +# On the Judge0 IDE, Nim is automatically\n\
1036 +# updated every day to the latest stable version.\n\
1037 +echo \"hello, world\"\n\
1038 +";
1039 +
1040 +var pythonForMlSource = "\
1041 +import mlxtend\n\
1042 +import numpy\n\
1043 +import pandas\n\
1044 +import scipy\n\
1045 +import sklearn\n\
1046 +\n\
1047 +print(\"hello, world\")\n\
1048 +";
1049 +
1050 +var bosqueSource = "\
1051 +// On the Judge0 IDE, Bosque (https://github.com/microsoft/BosqueLanguage)\n\
1052 +// is automatically updated every hour to the latest commit on master branch.\n\
1053 +\n\
1054 +namespace NSMain;\n\
1055 +\n\
1056 +concept WithName {\n\
1057 + invariant $name != \"\";\n\
1058 +\n\
1059 + field name: String;\n\
1060 +}\n\
1061 +\n\
1062 +concept Greeting {\n\
1063 + abstract method sayHello(): String;\n\
1064 + \n\
1065 + virtual method sayGoodbye(): String {\n\
1066 + return \"goodbye\";\n\
1067 + }\n\
1068 +}\n\
1069 +\n\
1070 +entity GenericGreeting provides Greeting {\n\
1071 + const instance: GenericGreeting = GenericGreeting@{};\n\
1072 +\n\
1073 + override method sayHello(): String {\n\
1074 + return \"hello world\";\n\
1075 + }\n\
1076 +}\n\
1077 +\n\
1078 +entity NamedGreeting provides WithName, Greeting {\n\
1079 + override method sayHello(): String {\n\
1080 + return String::concat(\"hello\", \" \", this.name);\n\
1081 + }\n\
1082 +}\n\
1083 +\n\
1084 +entrypoint function main(arg?: String): String {\n\
1085 + var val = arg ?| \"\";\n\
1086 + if (val == \"1\") {\n\
1087 + return GenericGreeting@{}.sayHello();\n\
1088 + }\n\
1089 + elif (val == \"2\") {\n\
1090 + return GenericGreeting::instance.sayHello();\n\
1091 + }\n\
1092 + else {\n\
1093 + return NamedGreeting@{name=\"bob\"}.sayHello();\n\
1094 + }\n\
1095 +}\n\
1096 +";
1097 +
1098 +var cppTestSource = "\
1099 +#include <gtest/gtest.h>\n\
1100 +\n\
1101 +int add(int x, int y) {\n\
1102 + return x + y;\n\
1103 +}\n\
1104 +\n\
1105 +TEST(AdditionTest, NeutralElement) {\n\
1106 + EXPECT_EQ(1, add(1, 0));\n\
1107 + EXPECT_EQ(1, add(0, 1));\n\
1108 + EXPECT_EQ(0, add(0, 0));\n\
1109 +}\n\
1110 +\n\
1111 +TEST(AdditionTest, CommutativeProperty) {\n\
1112 + EXPECT_EQ(add(2, 3), add(3, 2));\n\
1113 +}\n\
1114 +\n\
1115 +int main(int argc, char **argv) {\n\
1116 + ::testing::InitGoogleTest(&argc, argv);\n\
1117 + return RUN_ALL_TESTS();\n\
1118 +}\n\
1119 +";
1120 +
1121 +var csharpTestSource ="\
1122 +using NUnit.Framework;\n\
1123 +\n\
1124 +public class Calculator\n\
1125 +{\n\
1126 + public int add(int a, int b)\n\
1127 + {\n\
1128 + return a + b;\n\
1129 + }\n\
1130 +}\n\
1131 +\n\
1132 +[TestFixture]\n\
1133 +public class Tests\n\
1134 +{\n\
1135 + private Calculator calculator;\n\
1136 +\n\
1137 + [SetUp]\n\
1138 + protected void SetUp()\n\
1139 + {\n\
1140 + calculator = new Calculator();\n\
1141 + }\n\
1142 +\n\
1143 + [Test]\n\
1144 + public void NeutralElement()\n\
1145 + {\n\
1146 + Assert.AreEqual(1, calculator.add(1, 0));\n\
1147 + Assert.AreEqual(1, calculator.add(0, 1));\n\
1148 + Assert.AreEqual(0, calculator.add(0, 0));\n\
1149 + }\n\
1150 +\n\
1151 + [Test]\n\
1152 + public void CommutativeProperty()\n\
1153 + {\n\
1154 + Assert.AreEqual(calculator.add(2, 3), calculator.add(3, 2));\n\
1155 + }\n\
1156 +}\n\
1157 +";
1158 +
1159 +var sources = {
1160 + 45: assemblySource,
1161 + 46: bashSource,
1162 + 47: basicSource,
1163 + 48: cSource,
1164 + 49: cSource,
1165 + 50: cSource,
1166 + 51: csharpSource,
1167 + 52: cppSource,
1168 + 53: cppSource,
1169 + 54: cppSource,
1170 + 55: lispSource,
1171 + 56: dSource,
1172 + 57: elixirSource,
1173 + 58: erlangSource,
1174 + 44: executableSource,
1175 + 59: fortranSource,
1176 + 60: goSource,
1177 + 61: haskellSource,
1178 + 62: javaSource,
1179 + 63: javaScriptSource,
1180 + 64: luaSource,
1181 + 65: ocamlSource,
1182 + 66: octaveSource,
1183 + 67: pascalSource,
1184 + 68: phpSource,
1185 + 43: plainTextSource,
1186 + 69: prologSource,
1187 + 70: pythonSource,
1188 + 71: pythonSource,
1189 + 72: rubySource,
1190 + 73: rustSource,
1191 + 74: typescriptSource,
1192 + 75: cSource,
1193 + 76: cppSource,
1194 + 77: cobolSource,
1195 + 78: kotlinSource,
1196 + 79: objectiveCSource,
1197 + 80: rSource,
1198 + 81: scalaSource,
1199 + 82: sqliteSource,
1200 + 83: swiftSource,
1201 + 84: vbSource,
1202 + 85: perlSource,
1203 + 86: clojureSource,
1204 + 87: fsharpSource,
1205 + 88: groovySource,
1206 + 1001: cSource,
1207 + 1002: cppSource,
1208 + 1003: c3Source,
1209 + 1004: javaSource,
1210 + 1005: javaTestSource,
1211 + 1006: mpiccSource,
1212 + 1007: mpicxxSource,
1213 + 1008: mpipySource,
1214 + 1009: nimSource,
1215 + 1010: pythonForMlSource,
1216 + 1011: bosqueSource,
1217 + 1012: cppTestSource,
1218 + 1013: cSource,
1219 + 1014: cppSource,
1220 + 1015: cppTestSource,
1221 + 1021: csharpSource,
1222 + 1022: csharpSource,
1223 + 1023: csharpTestSource,
1224 + 1024: fsharpSource
1225 +};
1226 +
1227 +var fileNames = {
1228 + 45: "main.asm",
1229 + 46: "script.sh",
1230 + 47: "main.bas",
1231 + 48: "main.c",
1232 + 49: "main.c",
1233 + 50: "main.c",
1234 + 51: "Main.cs",
1235 + 52: "main.cpp",
1236 + 53: "main.cpp",
1237 + 54: "main.cpp",
1238 + 55: "script.lisp",
1239 + 56: "main.d",
1240 + 57: "script.exs",
1241 + 58: "main.erl",
1242 + 44: "a.out",
1243 + 59: "main.f90",
1244 + 60: "main.go",
1245 + 61: "main.hs",
1246 + 62: "Main.java",
1247 + 63: "script.js",
1248 + 64: "script.lua",
1249 + 65: "main.ml",
1250 + 66: "script.m",
1251 + 67: "main.pas",
1252 + 68: "script.php",
1253 + 43: "text.txt",
1254 + 69: "main.pro",
1255 + 70: "script.py",
1256 + 71: "script.py",
1257 + 72: "script.rb",
1258 + 73: "main.rs",
1259 + 74: "script.ts",
1260 + 75: "main.c",
1261 + 76: "main.cpp",
1262 + 77: "main.cob",
1263 + 78: "Main.kt",
1264 + 79: "main.m",
1265 + 80: "script.r",
1266 + 81: "Main.scala",
1267 + 82: "script.sql",
1268 + 83: "Main.swift",
1269 + 84: "Main.vb",
1270 + 85: "script.pl",
1271 + 86: "main.clj",
1272 + 87: "script.fsx",
1273 + 88: "script.groovy",
1274 + 1001: "main.c",
1275 + 1002: "main.cpp",
1276 + 1003: "main.c3",
1277 + 1004: "Main.java",
1278 + 1005: "MainTest.java",
1279 + 1006: "main.c",
1280 + 1007: "main.cpp",
1281 + 1008: "script.py",
1282 + 1009: "main.nim",
1283 + 1010: "script.py",
1284 + 1011: "main.bsq",
1285 + 1012: "main.cpp",
1286 + 1013: "main.c",
1287 + 1014: "main.cpp",
1288 + 1015: "main.cpp",
1289 + 1021: "Main.cs",
1290 + 1022: "Main.cs",
1291 + 1023: "Test.cs",
1292 + 1024: "script.fsx"
1293 +};
1294 +
1295 +var languageIdTable = {
1296 + 1001: 1,
1297 + 1002: 2,
1298 + 1003: 3,
1299 + 1004: 4,
1300 + 1005: 5,
1301 + 1006: 6,
1302 + 1007: 7,
1303 + 1008: 8,
1304 + 1009: 9,
1305 + 1010: 10,
1306 + 1011: 11,
1307 + 1012: 12,
1308 + 1013: 13,
1309 + 1014: 14,
1310 + 1015: 15,
1311 + 1021: 21,
1312 + 1022: 22,
1313 + 1023: 23,
1314 + 1024: 24
1315 +}
1316 +
1317 +var extraApiUrl = "https://extra-ce.judge0.com";
1318 +var languageApiUrlTable = {
1319 + 1001: extraApiUrl,
1320 + 1002: extraApiUrl,
1321 + 1003: extraApiUrl,
1322 + 1004: extraApiUrl,
1323 + 1005: extraApiUrl,
1324 + 1006: extraApiUrl,
1325 + 1007: extraApiUrl,
1326 + 1008: extraApiUrl,
1327 + 1009: extraApiUrl,
1328 + 1010: extraApiUrl,
1329 + 1011: extraApiUrl,
1330 + 1012: extraApiUrl,
1331 + 1013: extraApiUrl,
1332 + 1014: extraApiUrl,
1333 + 1015: extraApiUrl,
1334 + 1021: extraApiUrl,
1335 + 1022: extraApiUrl,
1336 + 1023: extraApiUrl,
1337 + 1024: extraApiUrl
1338 +}
1 +{
2 + "lockfileVersion": 1
3 +}
File mode changed
...@@ -3,7 +3,7 @@ const multer = require('multer'); ...@@ -3,7 +3,7 @@ const multer = require('multer');
3 const fs = require('fs'); 3 const fs = require('fs');
4 const upload = multer(); 4 const upload = multer();
5 const app = express(); 5 const app = express();
6 -const port = 5501; 6 +const port = 5500;
7 app.use(express.static('Voicoding_web')); 7 app.use(express.static('Voicoding_web'));
8 app.use(express.static('./')); 8 app.use(express.static('./'));
9 async function testGoogleTextToSpeech(audioBuffer) { 9 async function testGoogleTextToSpeech(audioBuffer) {
......