-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathrapidmovers.html
More file actions
319 lines (267 loc) · 10.3 KB
/
rapidmovers.html
File metadata and controls
319 lines (267 loc) · 10.3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Crypto Rapid Movements Scanner</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/list.js/2.3.1/list.min.js"></script>
<LINK rel="shortcut icon" type="image/png" href="images/favicon.png">
</head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-40B0DD4ZBX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-40B0DD4ZBX');
</script>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #0f0f0f;
}
h1 {
text-align: center;
font-size: 1.5em;
color: #DBDBDB;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
.controls {
margin-bottom: 20px;
display: flex;
justify-content: center;
width: 60%;
/* Matches the width of the table */
margin: 0 auto;
/* Centers the controls */
}
.search {
width: 100%;
/* Takes up the full width of the .controls container */
padding: 10px;
font-size: 16px;
border-radius: 5px;
border: 1px solid #ddd;
}
#table-container {
margin-top: 20px;
overflow-x: auto;
}
table {
width: 60%;
justify-self: center;
border-collapse: collapse;
background-color: #0f0f0f;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
th,
td {
border: 1px solid #ddd;
padding: 10px 15px;
text-align: center;
cursor: pointer;
}
th {
background-color: #2962ff;
}
td,
th {
font-size: 1.25em;
color: #DBDBDB;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
a {
color: #007bff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.sort {
cursor: pointer;
}
tr:hover {
background-color: #1f1f1f;
}
@media (max-width: 768px) {
.search {
width: 100%;
}
table {
font-size: 12px;
}
th,
td {
padding: 8px;
}
}
</style>
<body>
<h1>Crypto Rapid Movements</h1>
<div style="display: flex; flex-direction: column; align-items: center; padding-bottom: 1em;">
<!-- Top button spans full width, centered -->
<button id="top-tokens" style="margin-bottom: 0.5em;">Show Top 9 Tokens</button>
<!-- Row: Enable Alerts + Last Refresh, aligned horizontally -->
<div style="display: flex; gap: 10px; align-items: center;">
<button id="enable-alerts">Enable Audio Alerts</button>
<span id="last-refresh" style="font-size: 0.9em; color: white;"></span>
</div>
<!-- Link result spans below -->
<div id="top-links" style="margin-top: 0.5em;"></div>
</div>
<audio id="alert-sound" src="https://www.myinstants.com/media/sounds/taco-bell-bong-sfx.mp3" preload="auto"></audio>
<div class="controls">
<input class="search" id="search" placeholder="Search..." />
<button id="refresh">Refresh</button>
</div>
<div id="table-container">
<table id="data-table">
<thead>
<tr>
<th class="sort" data-sort="pair">Pair</th>
<th class="sort" data-sort="exchange">Exchange</th>
<th class="sort" data-sort="change_detected" data-sort-custom="true">Change Detected (%)</th>
<th class="sort" data-sort="side">Side</th>
<th class="sort" data-sort="timestamp" data-sort-custom="true">Timestamp</th>
</tr>
</thead>
<tbody class="list">
<!-- Data will be inserted here -->
</tbody>
</table>
</div>
<script>
const searchBox = document.getElementById('search');
document.addEventListener('DOMContentLoaded', () => {
let tableList = null;
let previousData = new Map();
let alertsEnabled = false;
// Enable alerts when user clicks the button
document.getElementById('enable-alerts').addEventListener('click', () => {
alertsEnabled = true;
document.getElementById('enable-alerts').textContent = 'Alerts Enabled ✅';
});
// Function to update the URL with search query
const updateURL = (query) => {
const url = new URL(window.location);
if (query) {
url.searchParams.set('search', query);
} else {
url.searchParams.delete('search');
}
window.history.replaceState({}, '', url);
};
// Function to get search query from URL
const getSearchFromURL = () => {
const params = new URLSearchParams(window.location.search);
return params.get('search') || '';
};
const fetchData = () => {
const currentSearch = searchBox.value.trim().toLowerCase();
fetch('https://search.multicoincharts.com/cryptometer')
.then(response => response.json())
.then(data => {
if (data.success === 'true' && data.error === 'false') {
const tableBody = document.querySelector('#data-table tbody');
tableBody.innerHTML = '';
let newData = new Map();
let alertTriggered = false;
data.data.forEach(item => {
let cleanExchange = item.exchange.replace(/_(spot|futures|pro|us)/gi, '');
let cleanPair = item.pair.replace('-', '');
const row = document.createElement('tr');
const link = `https://www.multicoincharts.com/?c=${cleanExchange}:${cleanPair}&p=1&s=1`;
row.innerHTML = `
<td class="pair"><a href="${link}" target="_blank">${item.pair}</a></td>
<td class="exchange">${item.exchange}</td>
<td class="change_detected" data-change="${parseFloat(item.change_detected)}">${item.change_detected}</td>
<td class="side">${item.side}</td>
<td class="timestamp" data-timestamp="${new Date(item.timestamp).getTime()}">${new Date(item.timestamp).toLocaleString()}</td>
`;
tableBody.appendChild(row);
let dataKey = `${item.exchange}-${item.pair}`;
let dataValue = `${item.change_detected}-${item.timestamp}`;
newData.set(dataKey, dataValue);
const matchesSearch =
item.pair.toLowerCase().includes(currentSearch) ||
item.exchange.toLowerCase().includes(currentSearch);
if (matchesSearch && (!previousData.has(dataKey) || previousData.get(dataKey) !== dataValue)) {
alertTriggered = true;
}
});
if (alertTriggered && alertsEnabled) {
playAlertSound();
}
previousData = newData;
if (!tableList) {
tableList = new List('table-container', {
valueNames: ['pair', 'exchange', 'change_detected', 'side', { name: 'timestamp', attr: 'data-timestamp' }],
sortFunction: (a, b, options) => {
const sortBy = options.valueName;
if (sortBy === 'change_detected') {
return parseFloat(a.values()[sortBy]) - parseFloat(b.values()[sortBy]);
} else if (sortBy === 'timestamp') {
return parseInt(a.values()[sortBy]) - parseInt(b.values()[sortBy]);
} else {
return a.values()[sortBy].localeCompare(b.values()[sortBy]);
}
}
});
searchBox.addEventListener('input', () => {
tableList.search(searchBox.value);
updateURL(searchBox.value); // Update URL as user types
});
} else {
tableList.reIndex();
tableList.update();
}
if (currentSearch) {
tableList.search(currentSearch);
}
document.getElementById('last-refresh').textContent = `Last Refresh: ${new Date().toLocaleString()}`;
} else {
console.error('API reported an error:', data);
}
})
.catch(error => {
console.error('Fetch error:', error.message);
});
};
// Function to play alert sound
const playAlertSound = () => {
const audio = document.getElementById('alert-sound');
audio.play().catch(error => console.error('Error playing sound:', error));
};
// Populate search box from URL on page load
searchBox.value = getSearchFromURL();
fetchData();
document.getElementById('refresh').addEventListener('click', fetchData);
setInterval(fetchData, 30000);
});
document.getElementById('top-tokens').addEventListener('click', () => {
const currentSearch = searchBox.value.trim().toLowerCase();
const matchedRows = Array.from(document.querySelectorAll('#data-table tbody tr')).filter(row => {
const pair = row.querySelector('.pair').textContent.toLowerCase();
const exchange = row.querySelector('.exchange').textContent.toLowerCase();
return pair.includes(currentSearch) || exchange.includes(currentSearch);
});
const latestRows = matchedRows
.map(row => {
const timestamp = parseInt(row.querySelector('.timestamp').dataset.timestamp);
const pair = row.querySelector('.pair').textContent;
const exchange = row.querySelector('.exchange').textContent;
const cleanExchange = exchange.replace(/_(spot|futures|pro|us)/gi, '');
const cleanPair = pair.replace('-', '');
return { timestamp, cleanExchange, cleanPair };
})
.sort((a, b) => b.timestamp - a.timestamp) // newest first
.slice(0, 9); // top 9 in correct order
if (latestRows.length === 0) return;
const combined = latestRows.map(item => `${item.cleanExchange}:${item.cleanPair}`).join(',');
const fullURL = `https://www.multicoincharts.com/?c=${combined}&p=1#nav`;
// Open in new tab
window.open(fullURL, '_blank');
});
</script>
</body>
</html>