|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let tradingPairs = [];
|
|
|
|
|
|
|
|
|
async function loadTradingPairs() {
|
|
|
try {
|
|
|
const response = await fetch('/trading_pairs.txt');
|
|
|
const text = await response.text();
|
|
|
tradingPairs = text.trim().split('\n').filter(pair => pair.trim());
|
|
|
console.log(`Loaded ${tradingPairs.length} trading pairs`);
|
|
|
return tradingPairs;
|
|
|
} catch (error) {
|
|
|
console.error('Error loading trading pairs:', error);
|
|
|
|
|
|
tradingPairs = ['BTCUSDT', 'ETHUSDT', 'BNBUSDT', 'SOLUSDT', 'XRPUSDT'];
|
|
|
return tradingPairs;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
function createTradingPairCombobox(id, placeholder = 'Select trading pair', selectedPair = 'BTCUSDT') {
|
|
|
const datalistId = `${id}-datalist`;
|
|
|
const options = tradingPairs.map(pair => `<option value="${pair}">`).join('');
|
|
|
|
|
|
return `
|
|
|
<input
|
|
|
type="text"
|
|
|
id="${id}"
|
|
|
class="form-input trading-pair-input"
|
|
|
list="${datalistId}"
|
|
|
placeholder="${placeholder}"
|
|
|
value="${selectedPair}"
|
|
|
autocomplete="off"
|
|
|
style="padding: 10px 15px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-primary); border-radius: 8px; font-size: 14px; width: 100%;"
|
|
|
/>
|
|
|
<datalist id="${datalistId}">
|
|
|
${options}
|
|
|
</datalist>
|
|
|
`;
|
|
|
}
|
|
|
|
|
|
|
|
|
function createTradingPairSelect(id, selectedPair = 'BTCUSDT', className = 'form-select') {
|
|
|
const options = tradingPairs.map(pair =>
|
|
|
`<option value="${pair}" ${pair === selectedPair ? 'selected' : ''}>${pair}</option>`
|
|
|
).join('');
|
|
|
|
|
|
return `
|
|
|
<select
|
|
|
id="${id}"
|
|
|
class="${className}"
|
|
|
style="padding: 10px 15px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-primary); border-radius: 8px; font-size: 14px; width: 100%; cursor: pointer;"
|
|
|
>
|
|
|
${options}
|
|
|
</select>
|
|
|
`;
|
|
|
}
|
|
|
|
|
|
|
|
|
function getSvgIcon(iconId, size = 20, className = '') {
|
|
|
return `<svg width="${size}" height="${size}" class="${className}"><use href="#icon-${iconId}"></use></svg>`;
|
|
|
}
|
|
|
|
|
|
|
|
|
function replaceEmojiWithSvg(text, emojiMap) {
|
|
|
let result = text;
|
|
|
for (const [emoji, iconId] of Object.entries(emojiMap)) {
|
|
|
result = result.replace(new RegExp(emoji, 'g'), getSvgIcon(iconId));
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
const emojiToSvg = {
|
|
|
'π': 'market',
|
|
|
'π': 'refresh',
|
|
|
'β
': 'check',
|
|
|
'β': 'close',
|
|
|
'β οΈ': 'warning',
|
|
|
'π°': 'diamond',
|
|
|
'π': 'rocket',
|
|
|
'π': 'trending-up',
|
|
|
'π': 'trending-down',
|
|
|
'π': 'whale',
|
|
|
'π': 'diamond',
|
|
|
'π₯': 'fire',
|
|
|
'π―': 'fire',
|
|
|
'π±': 'monitor',
|
|
|
'βοΈ': 'settings',
|
|
|
'π ': 'home',
|
|
|
'π°': 'news',
|
|
|
'π': 'sentiment',
|
|
|
'π§ ': 'brain',
|
|
|
'π': 'link',
|
|
|
'πΎ': 'database',
|
|
|
'βΏ': 'bitcoin'
|
|
|
};
|
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', async function() {
|
|
|
await loadTradingPairs();
|
|
|
console.log('Trading pairs loaded and ready');
|
|
|
|
|
|
|
|
|
document.dispatchEvent(new CustomEvent('tradingPairsLoaded', { detail: { pairs: tradingPairs } }));
|
|
|
});
|
|
|
|
|
|
|
|
|
window.TradingPairsLoader = {
|
|
|
loadTradingPairs,
|
|
|
createTradingPairCombobox,
|
|
|
createTradingPairSelect,
|
|
|
getSvgIcon,
|
|
|
replaceEmojiWithSvg,
|
|
|
emojiToSvg,
|
|
|
getTradingPairs: () => tradingPairs
|
|
|
};
|
|
|
|
|
|
|