<script>
$(function() {
const existCoins = <?php echo $exist_json; ?>;
const currentVal = "<?php echo $subject; ?>";
let finalSymbols = [];
const fetchLinear = $.ajax({ url: "https://api.bybit.com/v5/market/instruments-info?category=linear&limit=1000" });
const fetchInverse = $.ajax({ url: "https://api.bybit.com/v5/market/instruments-info?category=inverse&limit=1000" });
$.when(fetchLinear, fetchInverse).done(function(resLinear, resInverse) {
if (resLinear[0].retCode === 0 && resLinear[0].result.list) {
resLinear[0].result.list.forEach(item => {
if(item.symbol.endsWith('USDT')) finalSymbols.push(item.symbol);
});
}
let filtered = [...new Set(finalSymbols)].filter(symbol => {
return !existCoins.includes(symbol) || symbol === currentVal;
});
filtered.sort((a, b) => a.localeCompare(b));
const $select = $('#coin_select');
$select.empty().append('<option value="">USDT 자산 선택</option>');
filtered.forEach(symbol => {
const selected = (symbol === currentVal) ? 'selected' : '';
$select.append('<option value="' + symbol + '" ' + selected + '>' + symbol + '</option>');
});
updateFeedback();
}).fail(function() {
$('#coin_select').empty().append('<option value="">API 연결 오류</option>');
});
function updateFeedback() {
const state = $('#id_x2_run').is(':checked') ? '활성(ON)' : '중지(OFF)';
$('#res_state').text(state).css('color', $('#id_x2_run').is(':checked') ? '#00d4ff' : '#ff2d55');
$('#res_coin').text($('#coin_select').val() || '-');
$('#res_korean_name').text($('#id_x2_korean_name').val() || '-');
$('#res_cat').text($('#id_ca_name option:selected').text() || '-');
$('#res_mode').text(($('#id_x2_ca2 option:selected').text() || '-') + ' / ' + ($('#id_x2_ca3 option:selected').text() || '-'));
$('#res_time').text($('#id_date').val() + ' ' + $('#id_time').val());
$('#res_ver').text($('#id_x2_ver').val() || '-');
}
$('input, select').on('change keyup input', updateFeedback);
setTimeout(updateFeedback, 500);
$('#id_x2_memo_button').on('change', function() {
const $panel = $('#memo_panel');
if ($(this).is(':checked')) {
$panel.removeClass('is-close').addClass('is-open').stop(true, true).slideDown(180);
} else {
$panel.removeClass('is-open').addClass('is-close').stop(true, true).slideUp(180);
$('#id_x2_memo_clean').prop('checked', false);
}
});
if ($('#id_x2_memo_button').is(':checked')) {
$('#memo_panel').removeClass('is-close').addClass('is-open').show();
} else {
$('#memo_panel').removeClass('is-open').addClass('is-close').hide();
}
});
function updateFileInfo(input, index) {
if(input.files.length > 0) {
document.getElementById('f_name_' + index).innerText = input.files[0].name;
document.getElementById('f_name_' + index).style.color = "#00d4ff";
}
}
function addFileSlot() {
const $next = $('.file-box-custom:not(.active)').first();
if ($next.length) {
$next.addClass('active');
}
}
function toggleExtraArea() {
const area = $('#extra_area');
const icon = $('#btn_extra_toggle i');
if(area.is(':visible')) {
area.removeClass('is-open').addClass('is-close').slideUp(250);
icon.removeClass('fa-chevron-up').addClass('fa-chevron-down');
} else {
area.removeClass('is-close').addClass('is-open').slideDown(250);
icon.removeClass('fa-chevron-down').addClass('fa-chevron-up');
}
}
function fwrite_submit(f) {
<?php echo $editor_js; ?>
return true;
}
</script>