-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpreview.html
More file actions
404 lines (354 loc) · 12.7 KB
/
Copy pathpreview.html
File metadata and controls
404 lines (354 loc) · 12.7 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>C++ Qt Learning Book - LaTeX Preview</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
color: #333;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.header {
text-align: center;
color: white;
margin-bottom: 40px;
}
.header h1 {
font-size: 2.5rem;
margin-bottom: 10px;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
.header p {
font-size: 1.2rem;
opacity: 0.9;
}
.main-content {
background: white;
border-radius: 15px;
padding: 30px;
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
margin-bottom: 30px;
}
.build-section {
background: #f8f9fa;
border-radius: 10px;
padding: 25px;
margin-bottom: 30px;
border-left: 5px solid #007bff;
}
.build-section h2 {
color: #007bff;
margin-bottom: 15px;
font-size: 1.5rem;
}
.build-options {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 15px;
margin-bottom: 20px;
}
.build-option {
background: white;
padding: 15px;
border-radius: 8px;
border: 2px solid #e9ecef;
transition: all 0.3s ease;
cursor: pointer;
}
.build-option:hover {
border-color: #007bff;
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0,123,255,0.2);
}
.build-option h3 {
color: #007bff;
margin-bottom: 8px;
font-size: 1.1rem;
}
.build-option p {
color: #6c757d;
font-size: 0.9rem;
}
.command {
background: #2d3748;
color: #e2e8f0;
padding: 10px;
border-radius: 5px;
font-family: 'Courier New', monospace;
font-size: 0.9rem;
margin: 10px 0;
overflow-x: auto;
}
.pdf-section {
background: #e8f5e8;
border-radius: 10px;
padding: 25px;
margin-bottom: 30px;
border-left: 5px solid #28a745;
}
.pdf-section h2 {
color: #28a745;
margin-bottom: 15px;
}
.pdf-link {
display: inline-block;
background: #28a745;
color: white;
padding: 12px 25px;
text-decoration: none;
border-radius: 8px;
font-weight: bold;
transition: all 0.3s ease;
}
.pdf-link:hover {
background: #218838;
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(40,167,69,0.3);
}
.structure-section {
background: #fff3cd;
border-radius: 10px;
padding: 25px;
border-left: 5px solid #ffc107;
}
.structure-section h2 {
color: #856404;
margin-bottom: 15px;
}
.chapter-list {
list-style: none;
}
.chapter-list li {
padding: 8px 0;
border-bottom: 1px solid #ffeaa7;
}
.chapter-list li:last-child {
border-bottom: none;
}
.part-title {
font-weight: bold;
color: #856404;
margin-top: 15px;
margin-bottom: 10px;
font-size: 1.1rem;
}
.status {
display: inline-block;
padding: 4px 8px;
border-radius: 4px;
font-size: 0.8rem;
font-weight: bold;
margin-left: 10px;
}
.status.ready {
background: #d4edda;
color: #155724;
}
.status.building {
background: #fff3cd;
color: #856404;
}
.status.error {
background: #f8d7da;
color: #721c24;
}
.footer {
text-align: center;
color: white;
margin-top: 40px;
opacity: 0.8;
}
@media (max-width: 768px) {
.container {
padding: 10px;
}
.header h1 {
font-size: 2rem;
}
.build-options {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>📚 C++ Qt Learning Book</h1>
<p>LaTeX Document Preview & Build System</p>
</div>
<div class="main-content">
<div class="build-section">
<h2>🚀 Build Options</h2>
<div class="build-options">
<div class="build-option" onclick="buildDocument('all')">
<h3>📄 Build PDF</h3>
<p>Generate the complete PDF document</p>
<div class="command">make all</div>
</div>
<div class="build-option" onclick="buildDocument('index')">
<h3>📑 Build with Index</h3>
<p>Generate PDF with table of contents and index</p>
<div class="command">make index</div>
</div>
<div class="build-option" onclick="buildDocument('bib')">
<h3>📚 Build with Bibliography</h3>
<p>Generate PDF with bibliography</p>
<div class="command">make bib</div>
</div>
<div class="build-option" onclick="buildDocument('clean')">
<h3>🧹 Clean Files</h3>
<p>Remove auxiliary files</p>
<div class="command">make clean</div>
</div>
</div>
</div>
<div class="pdf-section">
<h2>📖 Generated PDF</h2>
<p>Once built, you can view the generated PDF document:</p>
<a href="output/book.pdf" class="pdf-link" target="_blank">
📄 Open Book PDF
</a>
<div id="pdf-status" class="status ready">Ready to build</div>
<div id="installation-help" style="display: none; margin-top: 15px; padding: 15px; background: #fff3cd; border-radius: 5px; border-left: 4px solid #ffc107;"></div>
</div>
<div class="structure-section">
<h2>📋 Book Structure</h2>
<ul class="chapter-list">
<div class="part-title">Part 1: Dasar (Basics)</div>
<li>Chapter 1: Mukadimah (Introduction)</li>
<li>Chapter 2: Tipe Data, Identifier dan Operator</li>
<li>Chapter 3: Control Statement</li>
<li>Chapter 4: Array dan String</li>
<li>Chapter 5: Fungsi</li>
<li>Chapter 6: Pointer dan References</li>
<div class="part-title">Part 2: OOP</div>
<li>Chapter 7: Class dan Object</li>
<li>Chapter 8: Inheritance</li>
<li>Chapter 9: Operator Types dan Operator Overloading</li>
<li>Chapter 10: Polymorphism</li>
<li>Chapter 11: Casting dan Database</li>
<div class="part-title">Part 3: Interface</div>
<li>Chapter 12: GUI</li>
<div class="part-title">Part 4: Widget</div>
<li>Chapter 13: File, Stream, dan XML</li>
<li>Chapter 14: Qt Webkit</li>
<div class="part-title">Part 5: Library</div>
<li>Chapter 15: Library</li>
</ul>
</div>
</div>
<div class="footer">
<p>© 2024 Nur Wachid - C++ Qt Learning Book</p>
<p>Built with ❤️ using LaTeX</p>
</div>
</div>
<script>
function buildDocument(type) {
const status = document.getElementById('pdf-status');
status.textContent = 'Building...';
status.className = 'status building';
// Call the build API
fetch('/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ type: type })
})
.then(response => response.json())
.then(data => {
console.log('Build response:', data);
if (data.status === 'error') {
status.textContent = 'LaTeX not installed';
status.className = 'status error';
showInstallationHelp(data.suggestions);
} else {
// Poll for completion
pollBuildStatus();
}
})
.catch(error => {
console.error('Build error:', error);
status.textContent = 'Build failed';
status.className = 'status error';
});
}
function showInstallationHelp(suggestions) {
const helpDiv = document.getElementById('installation-help');
if (helpDiv && suggestions) {
helpDiv.innerHTML = '<h3>📋 Installation Options:</h3><ul>' +
suggestions.map(s => '<li>' + s + '</li>').join('') + '</ul>';
helpDiv.style.display = 'block';
}
}
function pollBuildStatus() {
const status = document.getElementById('pdf-status');
let attempts = 0;
const maxAttempts = 30; // 30 seconds
const poll = () => {
attempts++;
fetch('output/book.pdf', { method: 'HEAD' })
.then(response => {
if (response.ok) {
status.textContent = 'Build completed!';
status.className = 'status ready';
// Update PDF link to refresh
const pdfLink = document.querySelector('.pdf-link');
pdfLink.href = 'output/book.pdf?' + new Date().getTime();
} else if (attempts < maxAttempts) {
setTimeout(poll, 1000);
} else {
status.textContent = 'Build timeout';
status.className = 'status error';
}
})
.catch(() => {
if (attempts < maxAttempts) {
setTimeout(poll, 1000);
} else {
status.textContent = 'Build failed';
status.className = 'status error';
}
});
};
poll();
}
// Check if PDF exists
function checkPDFStatus() {
fetch('output/book.pdf', { method: 'HEAD' })
.then(response => {
const status = document.getElementById('pdf-status');
if (response.ok) {
status.textContent = 'PDF available';
status.className = 'status ready';
} else {
status.textContent = 'PDF not found';
status.className = 'status error';
}
})
.catch(() => {
const status = document.getElementById('pdf-status');
status.textContent = 'PDF not found';
status.className = 'status error';
});
}
// Check status on page load
window.addEventListener('load', checkPDFStatus);
</script>
</body>
</html>