parthmax commited on
Commit
a40fdda
·
verified ·
1 Parent(s): 9c580f0

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +276 -495
index.html CHANGED
@@ -1,508 +1,289 @@
1
-
2
  <!DOCTYPE html>
3
  <html lang="en">
4
  <head>
5
- <meta charset="utf-8" />
6
- <meta name="viewport" content="width=device-width,initial-scale=1" />
7
- <title>Java Learner Mini IDE</title>
8
-
9
- <!-- Font (modern, clean) -->
10
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap" rel="stylesheet">
11
-
12
- <!-- Font Awesome (free icons) -->
13
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" integrity="sha512-t9f6b...." crossorigin="anonymous" referrerpolicy="no-referrer" />
14
-
15
- <!-- CodeMirror 5 -->
16
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/codemirror.min.css">
17
- <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/codemirror.min.js"></script>
18
- <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/mode/clike/clike.min.js"></script>
19
- <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/addon/edit/closebrackets.min.js"></script>
20
- <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/addon/edit/matchbrackets.min.js"></script>
21
- <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/addon/edit/indentation.min.js"></script>
22
- <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/addon/format/formatting.min.js"></script>
23
- <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/addon/indent/auto-indent.min.js"></script>
24
- <!-- Note: some addons are bundled differently across versions; the code uses indent/auto features -->
25
-
26
- <style>
27
- :root{
28
- --bg:#0f1720;
29
- --glass: rgba(255,255,255,0.04);
30
- --glass-2: rgba(255,255,255,0.025);
31
- --accent: #6c8cff;
32
- --accent-2: #8be5d0;
33
- --muted: #9aa4b2;
34
- --card-shadow: 0 8px 30px rgba(2,6,23,0.6);
35
- --radius: 14px;
36
- }
37
- *{box-sizing:border-box}
38
- html,body{height:100%}
39
- body{
40
- margin:0;
41
- font-family:Inter,system-ui,Segoe UI,Roboto,"Helvetica Neue",Arial;
42
- background: linear-gradient(180deg, #071227 0%, #0d1a2b 100%);
43
- color:#e6eef8;
44
- -webkit-font-smoothing:antialiased;
45
- -moz-osx-font-smoothing:grayscale;
46
- padding:20px;
47
- display:flex;
48
- flex-direction:column;
49
- gap:14px;
50
- min-height:100vh;
51
- }
52
-
53
- /* App container */
54
- .app {
55
- display:grid;
56
- grid-template-columns: 260px 1fr;
57
- gap:18px;
58
- align-items:stretch;
59
- width:100%;
60
- max-width:1200px;
61
- margin:0 auto;
62
- flex:1 1 auto;
63
- }
64
-
65
- /* Glass panel */
66
- .panel {
67
- background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
68
- border-radius:var(--radius);
69
- backdrop-filter: blur(8px) saturate(1.05);
70
- box-shadow: var(--card-shadow);
71
- border: 1px solid rgba(255,255,255,0.04);
72
- padding:14px;
73
- transition: transform .18s ease, box-shadow .2s ease;
74
- }
75
- .panel:hover{ transform: translateY(-4px); box-shadow: 0 16px 40px rgba(8,14,40,0.6); }
76
-
77
- /* File sidebar */
78
- .files {
79
- display:flex;
80
- flex-direction:column;
81
- gap:12px;
82
- min-height:200px;
83
- }
84
- .files .top {
85
- display:flex; gap:8px; align-items:center; justify-content:space-between;
86
- }
87
- .brand {
88
- display:flex; gap:12px; align-items:center;
89
- font-weight:600; font-size:16px; color:var(--accent);
90
- }
91
- .brand i { font-size:20px; opacity:0.95; transform:translateY(-1px) }
92
-
93
- .file-actions { display:flex; gap:8px; align-items:center; }
94
- .btn {
95
- background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
96
- border: 1px solid rgba(255,255,255,0.04);
97
- color:var(--muted);
98
- padding:8px 10px;
99
- border-radius:10px;
100
- font-weight:600;
101
- display:inline-flex; gap:8px; align-items:center;
102
- cursor:pointer;
103
- transition: all .14s ease;
104
- white-space:nowrap;
105
- }
106
- .btn:hover{ transform: translateY(-3px); color:#fff; box-shadow: 0 8px 20px rgba(0,0,0,0.4); }
107
-
108
- /* File list */
109
- .file-list { display:flex; flex-direction:column; gap:8px; overflow:auto; padding-right:6px; }
110
- .file-item {
111
- display:flex; align-items:center; gap:10px; justify-content:space-between;
112
- padding:8px; border-radius:9px; cursor:pointer; color:#dbe8ff; font-weight:600;
113
- transition: background .12s ease, transform .12s ease;
114
- background: linear-gradient(180deg, rgba(255,255,255,0.01), rgba(255,255,255,0.005));
115
- border:1px solid rgba(255,255,255,0.02);
116
- }
117
- .file-item:hover{ transform: translateY(-3px); box-shadow: 0 6px 18px rgba(8,12,32,0.45); }
118
- .file-item.active { background: linear-gradient(90deg, rgba(108,140,255,0.12), rgba(139,229,208,0.03)); color:#fff; }
119
-
120
- .file-meta { display:flex; gap:8px; align-items:center; }
121
-
122
- /* Editor area */
123
- .editor-area { display:flex; flex-direction:column; gap:10px; min-height:400px; }
124
- .topbar {
125
- display:flex; align-items:center; justify-content:space-between; gap:6px;
126
- }
127
- .title {
128
- font-size:14px; color:var(--muted);
129
- }
130
- .controls { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
131
-
132
- .primary {
133
- background: linear-gradient(90deg,var(--accent), #7bd0ff);
134
- color:#04253b; padding:10px 14px; border-radius:10px; font-weight:700; border:none; cursor:pointer;
135
- box-shadow: 0 8px 30px rgba(108,140,255,0.14);
136
- display:inline-flex; gap:8px; align-items:center;
137
- }
138
- .secondary { background: transparent; border:1px solid rgba(255,255,255,0.05); color:var(--muted); padding:8px 12px; border-radius:10px; cursor:pointer; }
139
-
140
- /* CodeMirror container */
141
- .cm-wrap { border-radius:12px; overflow:hidden; border:1px solid rgba(255,255,255,0.02); }
142
- .CodeMirror { height: calc(100vh - 360px); min-height:240px; background: linear-gradient(180deg, rgba(2,6,23,0.6), rgba(2,6,23,0.55)); color:#e8f1ff; font-size:13px; }
143
-
144
- /* Output console */
145
- .console {
146
- margin-top:6px;
147
- background: linear-gradient(180deg, rgba(0,0,0,0.5), rgba(2,6,23,0.6));
148
- border-radius:10px; padding:12px; font-family:monospace; color:#cfe7ff; height:140px; overflow:auto;
149
- border:1px solid rgba(255,255,255,0.02);
150
- }
151
-
152
- /* Footer */
153
- footer { text-align:center; color:var(--muted); font-size:13px; padding:10px 0; }
154
- .note { color:#c7d7ff; font-weight:600; }
155
-
156
- /* Responsive */
157
- @media (max-width:900px) {
158
- .app { grid-template-columns: 1fr; padding-bottom:8px; }
159
- .files { order:2; }
160
- .editor-area { order:1; }
161
- .CodeMirror { height: calc(100vh - 420px); }
162
- }
163
- @media (max-width:480px) {
164
- body{padding:12px}
165
- .brand { font-size:14px }
166
- .btn { padding:6px 8px; font-size:13px }
167
- .primary { padding:8px 10px; font-size:14px }
168
- .CodeMirror { font-size:12px }
169
- }
170
- </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  </head>
172
  <body>
173
- <div class="app">
174
- <!-- Files Sidebar -->
175
- <div class="panel files" id="sidebar">
176
- <div class="top">
177
- <div class="brand"><i class="fa-solid fa-flask"></i> Java Learner</div>
178
- <div style="display:flex;gap:8px;align-items:center">
179
- <button class="btn" id="toggleSidebar" title="Hide files"><i class="fa-solid fa-bars"></i></button>
180
- <button class="btn" id="newBtn" title="New file"><i class="fa-solid fa-file-circle-plus"></i> New</button>
181
- </div>
182
- </div>
183
-
184
- <div style="display:flex;gap:8px;align-items:center;">
185
- <input id="searchFile" placeholder="Search files..." style="flex:1;background:transparent;border:1px solid rgba(255,255,255,0.03);padding:8px;border-radius:8px;color:var(--muted)" />
186
- <button class="btn" id="importBtn" title="Import .java"><i class="fa-solid fa-file-import"></i></button>
187
- </div>
188
-
189
- <div class="file-list" id="fileList" aria-live="polite" style="margin-top:8px;"></div>
190
-
191
- <div style="margin-top:auto;font-size:13px;color:var(--muted);padding-top:10px">
192
- <div style="display:flex;gap:8px;align-items:center">
193
- <i class="fa-solid fa-circle-notch fa-spin" style="opacity:0.18"></i>
194
- <div>Local-only — your files stay on your device</div>
195
  </div>
196
- </div>
 
197
  </div>
198
 
199
- <!-- Editor area -->
200
  <div class="panel editor-area">
201
- <div class="topbar">
202
- <div class="title">Interactive Java editor • Friendly for mobile & desktop</div>
203
- <div class="controls">
204
- <button class="primary" id="runBtn"><i class="fa-solid fa-play"></i> Run</button>
205
- <button class="secondary" id="saveBtn" title="Save to device"><i class="fa-solid fa-floppy-disk"></i> Save</button>
206
- <button class="secondary" id="downloadBtn" title="Download file"><i class="fa-solid fa-download"></i> Download</button>
207
- <button class="secondary" id="formatBtn" title="Auto-indent / format"><i class="fa-solid fa-align-left"></i> Format</button>
208
- <button class="secondary" id="cutBtn" title="Cut selection"><i class="fa-solid fa-cut"></i></button>
209
- <button class="secondary" id="copyBtn" title="Copy selection"><i class="fa-solid fa-copy"></i></button>
210
- <button class="secondary" id="pasteBtn" title="Paste"><i class="fa-solid fa-clipboard"></i></button>
211
- <button class="secondary" id="deleteBtn" title="Delete file"><i class="fa-solid fa-trash"></i></button>
 
212
  </div>
213
- </div>
214
-
215
- <div class="cm-wrap" id="cmWrap">
216
- <div id="editor"></div>
217
- </div>
218
-
219
- <div style="display:flex;gap:10px;align-items:center;justify-content:space-between;">
220
- <div style="display:flex;gap:8px;align-items:center">
221
- <div style="font-size:13px;color:var(--muted)">Active file: <span id="activeFile" style="color:#eafbff;font-weight:700">—</span></div>
222
- </div>
223
- <div style="font-size:13px;color:var(--muted)">Execution timeout: <strong>5s</strong></div>
224
- </div>
225
-
226
- <div class="console" id="console">Console output will appear here.</div>
227
  </div>
228
- </div>
229
-
230
- <footer>
231
- <div>Made with care for <span class="note">Ragini didi — happy learning!</span></div>
232
- </footer>
233
-
234
- <!-- Hidden file input for import -->
235
- <input type="file" id="fileInput" accept=".java" style="display:none" />
236
-
237
- <script>
238
- // ---------- Editor setup ----------
239
- const editor = CodeMirror(document.getElementById('editor'), {
240
- mode: "text/x-java",
241
- lineNumbers: true,
242
- tabSize: 4,
243
- indentUnit: 4,
244
- autoCloseBrackets: true,
245
- matchBrackets: true,
246
- theme: "default",
247
- value: "// Start here\nclass Main {\n public static void main(String[] args) {\n System.out.println(\"Hello from Java Learner\");\n }\n}\n"
248
- });
249
-
250
- // Keep editor responsive height
251
- function resizeEditor(){
252
- const wrap = document.querySelector('.CodeMirror');
253
- if(wrap) {
254
- // compute available height
255
- let vh = window.innerHeight;
256
- // set a comfortable height based on screen
257
- const base = Math.max(240, vh - 360);
258
- wrap.style.height = base + 'px';
259
- editor.refresh();
260
- }
261
- }
262
- window.addEventListener('resize', resizeEditor);
263
- setTimeout(resizeEditor,300);
264
-
265
- // ---------- Local file storage ----------
266
- let files = JSON.parse(localStorage.getItem('java_learner_files') || '{}');
267
- let active = localStorage.getItem('java_learner_active') || null;
268
- const fileListEl = document.getElementById('fileList');
269
- const activeFileEl = document.getElementById('activeFile');
270
- const consoleEl = document.getElementById('console');
271
-
272
- // Utilities
273
- function saveToStorage(){
274
- localStorage.setItem('java_learner_files', JSON.stringify(files));
275
- }
276
- function setActive(name){
277
- active = name;
278
- localStorage.setItem('java_learner_active', active);
279
- activeFileEl.innerText = active || '—';
280
- renderFiles();
281
- if(active) editor.setValue(files[active]);
282
- }
283
-
284
- function renderFiles(filter=''){
285
- fileListEl.innerHTML = '';
286
- const names = Object.keys(files).filter(n => n.toLowerCase().includes(filter.toLowerCase())).sort();
287
- if(names.length===0){
288
- fileListEl.innerHTML = `<div style="color:var(--muted);padding:10px;font-size:13px">No files yet. Create one.</div>`;
289
- return;
290
- }
291
- names.forEach(name=>{
292
- const div = document.createElement('div');
293
- div.className = 'file-item' + (name===active ? ' active':'');
294
- div.innerHTML = `<div class="file-meta"><i class="fa-solid fa-file-code"></i><div style="margin-left:8px">${name}</div></div>
295
- <div style="display:flex;gap:8px;align-items:center">
296
- <button class="btn" title="Rename" style="padding:6px 8px" onclick="renameFile(event,'${encodeURIComponent(name)}')"><i class="fa-solid fa-pen"></i></button>
297
- <button class="btn" title="Duplicate" style="padding:6px 8px" onclick="duplicateFile(event,'${encodeURIComponent(name)}')"><i class="fa-solid fa-clone"></i></button>
298
- <button class="btn" title="Open" style="padding:6px 8px" onclick="openFile(event,'${encodeURIComponent(name)}')"><i class="fa-solid fa-folder-open"></i></button>
299
- </div>`;
300
  fileListEl.appendChild(div);
301
- });
302
- }
303
-
304
- // Actions
305
- function newFile(){
306
- let name = prompt('Filename (end with .java):','Main.java');
307
- if(!name) return;
308
- if(!name.endsWith('.java')) { alert('Filename must end with .java'); return; }
309
- if(files[name]) { alert('File exists'); return; }
310
- const classname = name.replace('.java','').replace(/[^A-Za-z0-9_]/g,'') || 'Main';
311
- files[name] = `class ${classname} {\n public static void main(String[] args) {\n System.out.println("Hello ${classname}!");\n }\n}\n`;
312
- saveToStorage();
313
- setActive(name);
314
- }
315
-
316
- function openFile(e, nameEnc){
317
- e.stopPropagation();
318
- const name = decodeURIComponent(nameEnc);
319
- setActive(name);
320
- }
321
-
322
- function renameFile(e,nameEnc){
323
- e.stopPropagation();
324
- const oldName = decodeURIComponent(nameEnc);
325
- const newName = prompt('Rename file to:', oldName);
326
- if(!newName || newName===oldName) return;
327
- if(!newName.endsWith('.java')) { alert('Filename must end with .java'); return; }
328
- if(files[newName]) { alert('A file with this name exists'); return; }
329
- files[newName] = files[oldName];
330
- delete files[oldName];
331
- saveToStorage();
332
- setActive(newName);
333
- }
334
-
335
- function duplicateFile(e,nameEnc){
336
- e.stopPropagation();
337
- const name = decodeURIComponent(nameEnc);
338
- let copyName = name.replace('.java','') + '_copy.java';
339
- let i=1;
340
- while(files[copyName]) { copyName = name.replace('.java','') + `_copy${i}.java`; i++; }
341
- files[copyName] = files[name];
342
- saveToStorage();
343
- setActive(copyName);
344
- }
345
-
346
- function deleteFile(){
347
- if(!active) return alert('No file selected');
348
- if(!confirm(`Delete ${active}?`)) return;
349
- delete files[active];
350
- saveToStorage();
351
- active = null;
352
- localStorage.removeItem('java_learner_active');
353
- activeFileEl.innerText = '—';
354
- editor.setValue('// Create a new file to start coding');
355
- renderFiles();
356
- }
357
-
358
- function saveFile(){
359
- if(!active) return alert('No file selected');
360
- files[active] = editor.getValue();
361
- saveToStorage();
362
- flashMessage('Saved ✔');
363
- }
364
-
365
- function downloadFile(){
366
- if(!active) return alert('No file selected');
367
- const blob = new Blob([editor.getValue()], {type:'text/plain'});
368
- const a = document.createElement('a');
369
- a.href = URL.createObjectURL(blob);
370
- a.download = active;
371
- a.click();
372
- URL.revokeObjectURL(a.href);
373
- }
374
-
375
- // Import from disk
376
- document.getElementById('importBtn').addEventListener('click', ()=>document.getElementById('fileInput').click());
377
- document.getElementById('fileInput').addEventListener('change', (e)=>{
378
- const f = e.target.files[0];
379
- if(!f) return;
380
- const reader = new FileReader();
381
- reader.onload = ()=> {
382
- let name = f.name;
383
- if(!name.endsWith('.java')) name = name + '.java';
384
- files[name] = reader.result;
385
- saveToStorage();
386
- setActive(name);
387
- };
388
- reader.readAsText(f);
389
- e.target.value = '';
390
- });
391
-
392
- // Search
393
- document.getElementById('searchFile').addEventListener('input', (e)=>renderFiles(e.target.value));
394
-
395
- // Toggle sidebar (mobile)
396
- document.getElementById('toggleSidebar').addEventListener('click', ()=>{
397
- const sb = document.getElementById('sidebar');
398
- if(sb.style.display === 'none'){ sb.style.display='flex'; } else { sb.style.display='none'; }
399
- setTimeout(()=>editor.refresh(),200);
400
  });
401
-
402
- // Clipboard actions (cut/copy/paste)
403
- document.getElementById('cutBtn').addEventListener('click', ()=>{
404
- const sel = editor.getSelection();
405
- if(!sel) return;
406
- navigator.clipboard.writeText(sel).then(()=> {
407
- editor.replaceSelection('');
408
- });
409
- });
410
- document.getElementById('copyBtn').addEventListener('click', ()=>{
411
- const sel = editor.getSelection();
412
- if(!sel) return;
413
- navigator.clipboard.writeText(sel);
414
- });
415
- document.getElementById('pasteBtn').addEventListener('click', async ()=>{
416
- const txt = await navigator.clipboard.readText();
417
- editor.replaceSelection(txt);
418
- });
419
-
420
- // Format (auto indent)
421
- document.getElementById('formatBtn').addEventListener('click', ()=>{
422
- try {
423
- // basic auto-indent by selecting all and auto indenting
424
- const total = {line: editor.lastLine()+1};
425
- editor.execCommand('selectAll');
426
- if(editor.execCommand('indentAuto')) {
427
- // indentAuto available
428
- } else {
429
- // fallback: indentMore a few times to normalize
430
- for(let i=0;i<3;i++) editor.execCommand('indentMore');
431
- }
432
- editor.execCommand('singleSelection');
433
- flashMessage('Formatted');
434
- } catch(e){
435
- flashMessage('Format not available');
436
- }
437
- });
438
-
439
- // Run code (send to FastAPI)
440
- async function runCode(){
441
- if(!active) return alert('No file selected');
442
- saveFile();
443
- consoleEl.innerText = '⏳ Running...';
444
- try {
445
- const resp = await fetch('/run-java', {
446
- method:'POST',
447
- headers:{'Content-Type':'application/json'},
448
- body: JSON.stringify({ code: editor.getValue(), filename: active })
449
- });
450
- const data = await resp.json();
451
- if(data.output) consoleEl.innerText = data.output;
452
- else if(data.error) consoleEl.innerText = 'Error:\n' + data.error;
453
- else consoleEl.innerText = JSON.stringify(data, null, 2);
454
- } catch(err){
455
- consoleEl.innerText = 'Network error: ' + err.message;
456
- }
457
- }
458
-
459
- // Hook buttons
460
- document.getElementById('newBtn').addEventListener('click', newFile);
461
- document.getElementById('saveBtn').addEventListener('click', saveFile);
462
- document.getElementById('downloadBtn').addEventListener('click', downloadFile);
463
- document.getElementById('runBtn').addEventListener('click', runCode);
464
- document.getElementById('deleteBtn').addEventListener('click', deleteFile);
465
-
466
- // Shortcut: Ctrl+S save, Ctrl+Enter run
467
- window.addEventListener('keydown', function(e){
468
- if((e.ctrlKey || e.metaKey) && e.key.toLowerCase()==='s'){ e.preventDefault(); saveFile(); }
469
- if((e.ctrlKey || e.metaKey) && e.key==='Enter'){ e.preventDefault(); runCode(); }
470
- });
471
-
472
- // Visual flash message
473
- function flashMessage(msg){
474
- const el = document.createElement('div');
475
- el.innerText = msg;
476
- el.style.position='fixed';
477
- el.style.right='18px';
478
- el.style.bottom='18px';
479
- el.style.background='linear-gradient(90deg, rgba(108,140,255,0.14), rgba(139,229,208,0.04))';
480
- el.style.border='1px solid rgba(255,255,255,0.04)';
481
- el.style.padding='10px 14px';
482
- el.style.borderRadius='10px';
483
- el.style.color='#eaf6ff';
484
- el.style.boxShadow='0 8px 26px rgba(0,0,0,0.5)';
485
- document.body.appendChild(el);
486
- setTimeout(()=> el.style.opacity='0', 1800);
487
- setTimeout(()=> el.remove(), 2400);
488
- }
489
-
490
- // Initialize app state
491
- if(Object.keys(files).length === 0) {
492
- // create default starter file
493
- files['Main.java'] = editor.getValue();
494
- saveToStorage();
495
- }
496
- if(!active) {
497
- setActive(Object.keys(files)[0]);
498
- } else {
499
- // ensure editor shows active file
500
- if(files[active]) editor.setValue(files[active]); else setActive(Object.keys(files)[0]);
501
- }
502
- renderFiles();
503
-
504
- // ensure refresh after everything loaded
505
- setTimeout(()=>editor.refresh(),250);
506
- </script>
507
- </body>
508
- </html>
 
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
  <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>JavaRunnerLearn & Run Java Online</title>
7
+ <meta name="description" content="JavaRunner is a mobile-friendly online Java IDE. Write, run, save, and download Java code. Perfect for beginners like Ragini Didi.">
8
+ <meta name="keywords" content="Java IDE, Online Java compiler, JavaRunner, Learn Java, Java code editor, mobile-friendly IDE, Ragini Didi">
9
+ <meta name="author" content="Saksham Pathak">
10
+ <meta name="robots" content="index, follow">
11
+
12
+ <!-- Open Graph for SEO & social -->
13
+ <meta property="og:title" content="JavaRunner — Learn & Run Java Online">
14
+ <meta property="og:description" content="JavaRunner is a mobile-friendly online Java IDE. Write, run, save, and download Java code. Perfect for beginners like Ragini Didi.">
15
+ <meta property="og:type" content="website">
16
+
17
+ <!-- Font -->
18
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap" rel="stylesheet">
19
+
20
+ <!-- Font Awesome -->
21
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
22
+
23
+ <!-- CodeMirror -->
24
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/codemirror.min.css">
25
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/codemirror.min.js"></script>
26
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/mode/clike/clike.min.js"></script>
27
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/addon/edit/closebrackets.min.js"></script>
28
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/addon/edit/matchbrackets.min.js"></script>
29
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.13/addon/edit/indentation.min.js"></script>
30
+
31
+ <style>
32
+ :root {
33
+ --bg:#0b1b2b;
34
+ --glass: rgba(255,255,255,0.05);
35
+ --glass-hover: rgba(255,255,255,0.08);
36
+ --accent:#6c8cff;
37
+ --accent-light:#8be5d0;
38
+ --text:#e6eef8;
39
+ --muted:#9aa4b2;
40
+ --radius:14px;
41
+ --shadow:0 8px 30px rgba(2,6,23,0.6);
42
+ }
43
+ *{box-sizing:border-box;}
44
+ body{
45
+ margin:0;
46
+ font-family: 'Inter', sans-serif;
47
+ background: linear-gradient(180deg, #071227, #0d1a2b);
48
+ color:var(--text);
49
+ min-height:100vh;
50
+ display:flex;
51
+ flex-direction:column;
52
+ align-items:center;
53
+ padding:10px;
54
+ }
55
+ h1,h2,h3,h4,h5{margin:0;padding:0;}
56
+ a{text-decoration:none;color:var(--accent);}
57
+ a:hover{color:var(--accent-light);}
58
+
59
+ /* App container */
60
+ .app{
61
+ display:flex;
62
+ flex-direction:row;
63
+ gap:12px;
64
+ width:100%;
65
+ max-width:1200px;
66
+ flex:1;
67
+ }
68
+ .panel{
69
+ background: var(--glass);
70
+ backdrop-filter: blur(12px) saturate(1.1);
71
+ border-radius: var(--radius);
72
+ padding:12px;
73
+ box-shadow: var(--shadow);
74
+ border:1px solid rgba(255,255,255,0.08);
75
+ transition: transform .2s ease, box-shadow .2s ease;
76
+ }
77
+ .panel:hover{transform:translateY(-3px);box-shadow:0 16px 40px rgba(8,14,40,0.5);}
78
+
79
+ /* Sidebar */
80
+ .sidebar{
81
+ flex:0 0 240px;
82
+ display:flex;
83
+ flex-direction:column;
84
+ gap:10px;
85
+ height:calc(100vh - 40px);
86
+ }
87
+ .sidebar-header{
88
+ display:flex;
89
+ justify-content:space-between;
90
+ align-items:center;
91
+ margin-bottom:8px;
92
+ }
93
+ .brand{
94
+ font-weight:700;
95
+ font-size:18px;
96
+ color:var(--accent);
97
+ display:flex;
98
+ align-items:center;
99
+ gap:8px;
100
+ }
101
+ .brand i{font-size:20px;}
102
+ .file-list{
103
+ flex:1;
104
+ overflow-y:auto;
105
+ display:flex;
106
+ flex-direction:column;
107
+ gap:6px;
108
+ }
109
+ .file-item{
110
+ display:flex;
111
+ justify-content:space-between;
112
+ align-items:center;
113
+ padding:6px 8px;
114
+ border-radius:10px;
115
+ cursor:pointer;
116
+ background: rgba(255,255,255,0.02);
117
+ transition:0.15s ease;
118
+ }
119
+ .file-item:hover{background:var(--glass-hover);}
120
+ .file-item.active{background:rgba(108,140,255,0.12);color:#fff;}
121
+ .file-actions{display:flex;gap:6px;align-items:center;}
122
+
123
+ /* Editor area */
124
+ .editor-area{
125
+ flex:1;
126
+ display:flex;
127
+ flex-direction:column;
128
+ gap:8px;
129
+ min-height:400px;
130
+ }
131
+ .cm-wrap{border-radius:12px;overflow:hidden;border:1px solid rgba(255,255,255,0.04);}
132
+ .CodeMirror{height:calc(100vh - 240px);background: rgba(2,6,23,0.7); color:#e8f1ff; font-size:13px;}
133
+
134
+ /* Buttons */
135
+ .btn{
136
+ background: rgba(255,255,255,0.03);
137
+ border:1px solid rgba(255,255,255,0.08);
138
+ color:var(--muted);
139
+ padding:6px 10px;
140
+ border-radius:10px;
141
+ cursor:pointer;
142
+ display:inline-flex;
143
+ align-items:center;
144
+ gap:6px;
145
+ transition:all .15s ease;
146
+ }
147
+ .btn:hover{color:#fff;transform:translateY(-2px);background:var(--glass-hover);}
148
+ .btn-primary{
149
+ background: linear-gradient(90deg,var(--accent),var(--accent-light));
150
+ color:#04253b;
151
+ padding:10px 14px;
152
+ font-weight:700;
153
+ border:none;
154
+ }
155
+ .console{
156
+ margin-top:6px;
157
+ background: rgba(0,0,0,0.5);
158
+ border-radius:10px;
159
+ padding:12px;
160
+ font-family:monospace;
161
+ color:#cfe7ff;
162
+ min-height:120px;
163
+ overflow:auto;
164
+ }
165
+
166
+ /* Footer */
167
+ footer{
168
+ text-align:center;
169
+ color:var(--muted);
170
+ font-size:14px;
171
+ padding:12px 0 4px 0;
172
+ }
173
+ footer .note{color:#c7d7ff;font-weight:600;}
174
+
175
+ /* Responsive */
176
+ @media (max-width:900px){
177
+ .app{flex-direction:column;}
178
+ .sidebar{width:100%;height:auto;order:2;}
179
+ .editor-area{order:1;}
180
+ .CodeMirror{height:300px;}
181
+ }
182
+ @media (max-width:480px){
183
+ body{padding:6px;}
184
+ .brand{font-size:16px;}
185
+ .btn{padding:5px 8px;font-size:13px;}
186
+ .btn-primary{padding:8px 10px;font-size:14px;}
187
+ }
188
+ </style>
189
  </head>
190
  <body>
191
+ <header class="sidebar-header">
192
+ <div class="brand"><i class="fa-solid fa-rocket"></i> JavaRunner</div>
193
+ </header>
194
+
195
+ <div class="app">
196
+ <!-- Sidebar -->
197
+ <div class="panel sidebar">
198
+ <div class="sidebar-header">
199
+ <button class="btn" id="newBtn"><i class="fa-solid fa-file-circle-plus"></i> New</button>
200
+ <button class="btn" id="importBtn"><i class="fa-solid fa-file-import"></i> Import</button>
 
 
 
 
 
 
 
 
 
 
 
 
201
  </div>
202
+ <input type="text" placeholder="Search files..." id="searchFile" style="width:100%;padding:6px;border-radius:8px;background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.08);color:var(--muted);margin-bottom:6px;">
203
+ <div class="file-list" id="fileList"></div>
204
  </div>
205
 
206
+ <!-- Editor -->
207
  <div class="panel editor-area">
208
+ <div style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;">
209
+ <div>Active File: <span id="activeFile">—</span></div>
210
+ <div style="display:flex;gap:6px;flex-wrap:wrap;">
211
+ <button class="btn-primary" id="runBtn"><i class="fa-solid fa-play"></i> Run</button>
212
+ <button class="btn" id="saveBtn"><i class="fa-solid fa-floppy-disk"></i> Save</button>
213
+ <button class="btn" id="downloadBtn"><i class="fa-solid fa-download"></i> Download</button>
214
+ <button class="btn" id="formatBtn"><i class="fa-solid fa-align-left"></i> Format</button>
215
+ <button class="btn" id="cutBtn"><i class="fa-solid fa-cut"></i></button>
216
+ <button class="btn" id="copyBtn"><i class="fa-solid fa-copy"></i></button>
217
+ <button class="btn" id="pasteBtn"><i class="fa-solid fa-clipboard"></i></button>
218
+ <button class="btn" id="deleteBtn"><i class="fa-solid fa-trash"></i></button>
219
+ </div>
220
  </div>
221
+ <div class="cm-wrap" id="cmWrap"><div id="editor"></div></div>
222
+ <div class="console" id="console">Console output will appear here.</div>
 
 
 
 
 
 
 
 
 
 
 
 
223
  </div>
224
+ </div>
225
+
226
+ <footer>
227
+ Made with ❤️ for <span class="note">Ragini Didi</span>
228
+ </footer>
229
+
230
+ <input type="file" id="fileInput" accept=".java" style="display:none">
231
+
232
+ <script>
233
+ // ---------- Editor setup ----------
234
+ const editor = CodeMirror(document.getElementById('editor'),{
235
+ mode:"text/x-java",
236
+ lineNumbers:true,
237
+ tabSize:4,
238
+ indentUnit:4,
239
+ autoCloseBrackets:true,
240
+ matchBrackets:true,
241
+ value:"class Main {\n public static void main(String[] args) {\n System.out.println(\"Hello Ragini!\");\n }\n}"
242
+ });
243
+
244
+ // Resize editor for mobile
245
+ function resizeEditor(){
246
+ const wrap=document.querySelector('.CodeMirror');
247
+ if(!wrap) return;
248
+ let vh=window.innerHeight;
249
+ wrap.style.height=(vh - 280)+'px';
250
+ editor.refresh();
251
+ }
252
+ window.addEventListener('resize',resizeEditor);
253
+ setTimeout(resizeEditor,200);
254
+
255
+ // ---------- Local storage ----------
256
+ let files=JSON.parse(localStorage.getItem('javaRunner_files')||'{}');
257
+ let active=localStorage.getItem('javaRunner_active')||null;
258
+ const fileListEl=document.getElementById('fileList');
259
+ const activeFileEl=document.getElementById('activeFile');
260
+ const consoleEl=document.getElementById('console');
261
+
262
+ function saveToStorage(){localStorage.setItem('javaRunner_files',JSON.stringify(files));}
263
+ function setActive(name){
264
+ active=name;
265
+ localStorage.setItem('javaRunner_active',active);
266
+ activeFileEl.innerText=name||'';
267
+ renderFiles();
268
+ if(active && files[active]) editor.setValue(files[active]);
269
+ }
270
+
271
+ function renderFiles(filter=''){
272
+ fileListEl.innerHTML='';
273
+ const names=Object.keys(files).filter(n=>n.toLowerCase().includes(filter.toLowerCase())).sort();
274
+ if(names.length===0){fileListEl.innerHTML='<div style="color:'+ 'var(--muted)' +';padding:10px;font-size:13px">No files yet.</div>';return;}
275
+ names.forEach(name=>{
276
+ const div=document.createElement('div');
277
+ div.className='file-item'+(name===active?' active':'');
278
+ div.innerHTML=`<div>${name}</div><div style="display:flex;gap:6px;">
279
+ <button class="btn" onclick="openFile('${name}')"><i class="fa-solid fa-folder-open"></i></button></div>`;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  fileListEl.appendChild(div);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  });
282
+ }
283
+
284
+ function newFile(){
285
+ let name=prompt('Filename (end with .java)','Main.java');
286
+ if(!name) return;if(!name.endsWith('.java')){alert('Filename must end with .java');return;}
287
+ if(files[name]){alert('File exists');return;}
288
+ const classname=name.replace('.java','').replace(/[^A-Za-z0-9_]/g,'')||'Main';
289
+ files[name]=`class ${classname} {\n public static void main(String[] args) {\