-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
112 lines (107 loc) · 5.56 KB
/
index.html
File metadata and controls
112 lines (107 loc) · 5.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTMLRunner</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.png">
<link rel="apple-touch-icon" href="favicon.png">
<link rel="manifest" href="manifest.json">
<!-- Font Awesome CDN -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<!-- CodeMirror CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.7/codemirror.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.7/theme/monokai.min.css">
<!-- CodeMirror Addons CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.7/addon/lint/lint.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.7/addon/dialog/dialog.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.7/addon/search/matchesonscrollbar.min.css">
<!-- Main Styles-->
<!-- prettier-ignore-start -->
<link rel="stylesheet" data-inline="true" href="styles.css">
<!-- prettier-ignore-end -->
</head>
<body>
<div class="loading" id="loading">
<div class="spinner"></div>
</div>
<div class="error-message" id="error-message"></div>
<div class="container">
<div class="header">
<div class="logo">HTMLRunner</div>
<div class="controls">
<button class="btn" id="install-button" hidden>Install App</button>
<button class="btn btn-run" onclick="runCode()"><i class="fas fa-play"></i> Run</button>
<button class="btn btn-format" onclick="formatCode()"><i class="fas fa-code"></i> Format</button>
<button class="btn btn-reset" onclick="resetCode()"><i class="fas fa-undo"></i> Reset</button>
<button class="btn btn-clear" onclick="clearConsole()"><i class="fas fa-trash"></i> Clear Console</button>
<button class="btn btn-download" onclick="exportAsZip()"><i class="fas fa-download"></i> Export Code</button>
<button class="btn btn-auto-run" onclick="toggleAutoRun()"><i class="fas fa-sync"></i> Auto-Run: <span id="auto-run-status">Off</span></button>
<button class="theme-toggle" onclick="toggleDarkMode()">
<i class="fas fa-moon"></i>
<span>Dark Mode</span>
</button>
</div>
</div>
<div class="main">
<div class="editor-panel" id="editor-panel">
<div class="editor-tabs">
<div class="tab active" data-tab="html" onclick="switchTab('html')">HTML</div>
<div class="tab" data-tab="css" onclick="switchTab('css')">CSS</div>
<div class="tab" data-tab="js" onclick="switchTab('js')">JavaScript</div>
</div>
<div class="editor-container" id="html-editor-container"></div>
<div class="editor-container" style="display: none;" id="css-editor-container"></div>
<div class="editor-container" style="display: none;" id="js-editor-container"></div>
</div>
<div class="output-panel" id="output-panel">
<div class="output-tabs">
<div class="tab active" data-output="preview" onclick="switchOutput('preview')">Preview</div>
<div class="tab" data-output="console" onclick="switchOutput('console')">Console</div>
</div>
<div class="output-content">
<iframe id="preview" class="preview active"></iframe>
<div id="console" class="console"></div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
// Register the service worker
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("service-worker.js");
}
let deferredPrompt;
const installButton = document.getElementById("install-button");
// Listen for the install prompt
window.addEventListener("beforeinstallprompt", (e) => {
e.preventDefault();
deferredPrompt = e;
installButton.hidden = false;
});
// Handle install button click
installButton.addEventListener("click", async () => {
const isStandalone = window.matchMedia("(display-mode: standalone)").matches || window.navigator.standalone;
if (isStandalone) {
console.log("App is already installed");
return;
}
if (deferredPrompt) {
deferredPrompt.prompt();
const { outcome } = await deferredPrompt.userChoice;
deferredPrompt = null;
console.log(outcome === "accepted" ? "User accepted install prompt" : "User dismissed install prompt");
} else {
if (window.matchMedia("(display-mode: browser)").matches) {
window.location.assign("chrome://apps/");
}
}
});
});
</script>
<!-- prettier-ignore-start -->
<script data-inline="true" src="main.js"></script>
<!-- prettier-ignore-end -->
</body>
</html>