-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.html
More file actions
209 lines (183 loc) · 7.81 KB
/
loop.html
File metadata and controls
209 lines (183 loc) · 7.81 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="manifest" href="manifest.json">
<title>Loop</title>
<style>
* { box-sizing: border-box; }
body {
background: #000; color: #fff;
margin: 0; height: 100vh; display: flex; flex-direction: column;
}
#dashboard { padding: 10px; background: #000; flex-shrink: 0; }
textarea {
width: 100%; height: 100px; background: #111; color: #66ff00;
padding: 8px; font-size: 16px; margin-bottom: 5px; outline: none; resize: none;
}
.row { display: flex; gap: 5px; }
input {
flex: 1;
background: #111;
color: gold;
padding: 10px;
font-size: 16px;
outline: none;
min-width: 0;
border: 1px solid #666; /* Явное указание одинаковой рамки для всех сторон */
} button { background: gold; color: #000; border: 1px solid black; font-weight: bold; padding: 10px; text-transform: uppercase; cursor: pointer; }
#cycle {
flex-grow: 1;
flex-shrink: 1;
min-height: 0;
padding: 10px; overflow-y: auto;
display: block; font-size: 1.4rem; line-height: 1.4;
}
.word { display: inline-block; cursor: pointer; margin-right: 4px; }
.word.active { color: gold; border-bottom: 2px solid gold; }
.known { border-bottom-color: #444; }
#billet {
height: 70px; background: #000;
padding: 10px; flex-shrink: 0; display: flex; align-items: top;
}
#out-def { color: gold; font-size: 1.2rem; }
.db-controls { margin-top: 5px; padding: 0 10px; display: flex; gap: 5px; flex-shrink: 0; }
.btn-db { background: #222; color: gold; border: 1px solid #444; font-size: 10px; padding: 5px 10px; }
:root { --creativity-color: #00ff00; }
footer { margin-top: 20px; padding: 0px 0; flex-shrink: 0; }
.donate-box { display: flex; flex-direction: column; gap: 10px; padding: 0 10px; }
.donate-btn { color: #888; border: 1px solid #888; padding: 5px 15px; background: transparent; cursor: pointer; font-family: monospace; width: fit-content; }
.crypto-info { display: none; flex-direction: column; gap: 5px; margin-top: 10px; }
.crypto-address-display { font-size: 11px; color: #fff; background: #111; padding: 8px 12px; border: 1px dashed #fff; cursor: copy; word-break: break-all; }
</style>
</head>
<body>
<script src="pwa-init.js"></script>
<div id="dashboard">
<textarea id="src-text" oninput="saveText()" placeholder="Source Text..."></textarea>
<div class="row">
<input type="text" id="w-key" placeholder="Word">
<input type="text" id="w-def" placeholder="Definition">
<button onclick="saveWord()">Save</button>
</div>
</div>
<div id="billet">
<div id="out-def">Select word to clarify...</div>
</div>
<div id="cycle"></div>
<div class="db-controls">
<button class="btn-db" onclick="exportFullData()">Export DB</button>
<button class="btn-db" onclick="document.getElementById('file-input').click()">Import DB</button>
<input type="file" id="file-input" style="display:none" onchange="importFullData(event)">
<a href="index.html" style="float: right;">
<img src="logo.png" alt="Feedback" style="height: 32px; opacity: 0.8; width: auto;">
</a>
</div>
<footer>
<div class="donate-box">
<button class="donate-btn" onclick="toggleDonate()">Support</button>
<div id="cryptoInfo" class="crypto-info">
<span style="font-size: 10px; color: #fff;">USDT BSC (BEP20)</span>
<div id="cryptoAddr" class="crypto-address-display" onclick="copyToClipboard()">0x769192cea8fbb7207f086d95fd653ebc3adb0c72</div>
<span id="copyHint" style="font-size: 9px; color: #aaa;">Click address to copy</span>
</div>
</div>
</footer>
<script>
if (navigator.storage && navigator.storage.persist) {
navigator.storage.persist();
}
let db = JSON.parse(localStorage.getItem('loop_db')) || {};
let txt = localStorage.getItem('loop_text') || "";
function saveText() {
txt = document.getElementById('src-text').value;
localStorage.setItem('loop_text', txt);
render();
}
function saveWord() {
const k = document.getElementById('w-key').value.toLowerCase().trim();
const d = document.getElementById('w-def').value;
if(k) {
db[k] = d;
localStorage.setItem('loop_db', JSON.stringify(db));
document.getElementById('w-key').value = "";
document.getElementById('w-def').value = "";
render();
}
}
function render() {
const area = document.getElementById('cycle');
area.innerHTML = txt.split(/\s+/).map(w => {
const clean = w.replace(/[^a-zA-Z]/g, "").toLowerCase();
const cls = db[clean] ? 'known' : '';
return `<span class="word ${cls}" onclick="clarify('${clean}', this)">${w}</span>`;
}).join(' ');
}
function clarify(k, el) {
document.querySelectorAll('.word').forEach(w => w.classList.remove('active'));
el.classList.add('active');
if (db[k]) {
document.getElementById('out-def').innerText = db[k];
} else {
document.getElementById('out-def').innerText = "Not defined.";
document.getElementById('w-key').value = k;
document.getElementById('w-def').focus();
}
}
function exportFullData() {
const backup = {
loop_db: JSON.parse(localStorage.getItem('loop_db')) || {},
loop_text: localStorage.getItem('loop_text') || ""
};
const blob = new Blob([JSON.stringify(backup, null, 2)], {type: 'application/json'});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `loop_backup_${new Date().toISOString().slice(0,10)}.json`;
a.click();
URL.revokeObjectURL(url);
}
function importFullData(event) {
const file = event.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = function(e) {
try {
const data = JSON.parse(e.target.result);
if (data.loop_db && data.loop_text !== undefined) {
localStorage.setItem('loop_db', JSON.stringify(data.loop_db));
localStorage.setItem('loop_text', data.loop_text);
db = data.loop_db;
txt = data.loop_text;
document.getElementById('src-text').value = txt;
render();
}
} catch (err) { alert("Invalid file format"); }
};
reader.readAsText(file);
}
function toggleDonate() {
const info = document.getElementById("cryptoInfo");
info.style.display = info.style.display === "flex" ? "none" : "flex";
}
function copyToClipboard() {
const addr = document.getElementById("cryptoAddr");
const hint = document.getElementById("copyHint");
const text = addr.innerText;
navigator.clipboard.writeText(text).then(() => {
addr.innerText = "Copied!";
addr.style.color = "#00ff00";
if (hint) hint.innerText = "Address saved to clipboard";
setTimeout(() => {
addr.innerText = text;
addr.style.color = "#fff";
if (hint) hint.innerText = "Click address to copy";
}, 1500);
});
}
document.getElementById('src-text').value = txt;
render();
</script>
</body>
</html>