Scratper commited on
Commit
05580b6
·
verified ·
1 Parent(s): 23d3c9f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +88 -18
index.html CHANGED
@@ -1,19 +1,89 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="vi">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Nhân bản Text & Xuất File Thông Minh</title>
6
+ <style>
7
+ body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; padding: 30px; background-color: #f0f2f5; color: #333; }
8
+ .card { background: white; padding: 25px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); max-width: 600px; margin: auto; }
9
+ h2 { margin-top: 0; color: #007bff; }
10
+ .form-group { margin-bottom: 15px; }
11
+ label { display: block; margin-bottom: 5px; font-weight: bold; }
12
+ input[type="text"], input[type="number"] { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; box-sizing: border-box; }
13
+ button { width: 100%; padding: 12px; background: #007bff; color: white; border: none; border-radius: 6px; font-size: 16px; cursor: pointer; transition: 0.3s; }
14
+ button:hover { background: #0056b3; }
15
+ #preview { margin-top: 20px; white-space: pre-wrap; background: #fafafa; border: 1px dashed #bbb; padding: 10px; max-height: 150px; overflow-y: auto; font-size: 14px; }
16
+ </style>
17
+ </head>
18
+ <body>
19
+
20
+ <div class="card">
21
+ <h2>Nhân bản & Xuất file</h2>
22
+
23
+ <div class="form-group">
24
+ <label>Nội dung văn bản:</label>
25
+ <input type="text" id="inputText" placeholder="Nhập nội dung tại đây..." value="Cộng hòa xã hội chủ nghĩa Việt Nam">
26
+ </div>
27
+
28
+ <div class="form-group">
29
+ <label>Số lượng dòng:</label>
30
+ <input type="number" id="repeatCount" value="100" min="1">
31
+ </div>
32
+
33
+ <button onclick="processAndDownload()">Tạo và Tải File .txt</button>
34
+
35
+ <div id="preview">Xem trước nội dung...</div>
36
+ </div>
37
+
38
+ <script>
39
+ // Hàm chuẩn hóa tiếng Việt: Bỏ dấu, bỏ khoảng cách, lấy 5 chữ đầu
40
+ function slugify(text, count) {
41
+ // 1. Chuyển về chữ thường và bỏ dấu
42
+ let str = text.toLowerCase();
43
+ str = str.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); // Bỏ dấu tiếng Việt
44
+ str = str.replace(/[đĐ]/g, 'd');
45
+
46
+ // 2. Chỉ giữ lại chữ cái và khoảng trắng
47
+ str = str.replace(/[^a-z0-9\s]/g, '');
48
+
49
+ // 3. Tách lấy 5 từ đầu tiên
50
+ let words = str.split(/\s+/).filter(w => w.length > 0).slice(0, 5);
51
+
52
+ // 4. Nối lại không cách + thêm số lượng
53
+ return words.join('') + count;
54
+ }
55
+
56
+ function processAndDownload() {
57
+ const text = document.getElementById('inputText').value;
58
+ const count = document.getElementById('repeatCount').value;
59
+
60
+ if (!text) {
61
+ alert("Vui lòng nhập nội dung!");
62
+ return;
63
+ }
64
+
65
+ // Tạo nội dung lặp lại
66
+ let finalContent = "";
67
+ for (let i = 0; i < count; i++) {
68
+ finalContent += text + "\n";
69
+ }
70
+
71
+ // Cập nhật preview
72
+ document.getElementById('preview').textContent = finalContent;
73
+
74
+ // Tạo tên file: 5 chữ đầu không dấu không cách + số lượng
75
+ const fileName = slugify(text, count) + ".txt";
76
+
77
+ // Tạo và tải file
78
+ const blob = new Blob([finalContent], { type: 'text/plain' });
79
+ const link = document.createElement('a');
80
+ link.href = URL.createObjectURL(blob);
81
+ link.download = fileName;
82
+ link.click();
83
+
84
+ URL.revokeObjectURL(link.href);
85
+ }
86
+ </script>
87
+
88
+ </body>
89
  </html>