simV1 / sim_free_V30.html
IndividualGamer's picture
Upload sim_free_V30.html
5f81005 verified
Raw History Blame Contribute Delete
126 kB
<!DOCTYPE html> <html lang="id"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>JELAJAH — Kebun Apel Lembah Fajar</title> <style> :root { --bg-main: #0b0e11; --bg-card: #181a20; --text-main: #eaecef; --text-muted: #848e9c; --up-color: #0ecb81; --down-color: #f6465d; --accent: #f0b90b; --edu-color: #4fc3f7; } * { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; -webkit-tap-highlight-color: transparent; } html, body { height: 100%; } body { background-color: #000; color: var(--text-main); display: flex; justify-content: center; align-items: center; min-height: 100vh; min-height: 100dvh; overflow: hidden; } .phone-container { width: 100%; max-width: 412px; height: 100vh; height: 100dvh; max-height: 892px; background-color: var(--bg-main); display: flex; flex-direction: column; overflow: hidden; position: relative; box-shadow: 0 0 20px rgba(0, 0, 0, 0.8); transform: scale(var(--display-scale, 1)); transform-origin: center center; transition: transform 0.2s ease-out; } .edu-banner { background: linear-gradient(90deg, rgba(79, 195, 247, 0.15), rgba(240, 185, 11, 0.12)); border-bottom: 1px solid #2b3139; padding: 5px 10px; font-size: 10.5px; color: #c9cdd4; text-align: center; line-height: 1.35; flex-shrink: 0; } .edu-banner strong { color: var(--edu-color); } .header { background-color: var(--bg-card); padding: 12px; border-bottom: 1px solid #2b3139; } .header-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; gap: 6px; } .header-title { font-size: 14px; color: var(--text-muted); } .upgrade-btn { font-size: 12px; font-weight: 700; color: #000; background-color: var(--edu-color); border: 1px solid var(--edu-color); text-decoration: none; padding: 2px 8px; border-radius: 4px; cursor: pointer; font-family: inherit; letter-spacing: 0.3px; margin-left: auto; margin-right: 6px; transition: background-color 0.2s, color 0.2s, opacity 0.2s; user-select: none; -webkit-user-select: none; flex-shrink: 0; } .upgrade-btn:hover, .upgrade-btn:active { background-color: #29b6f6; border-color: #29b6f6; color: #fff; } .upgrade-btn:active { opacity: 0.85; } .mode-link { font-size: 12px; font-weight: 700; color: var(--accent); text-decoration: none; padding: 2px 8px; border: 1px solid var(--accent); border-radius: 4px; transition: background-color 0.2s, color 0.2s; flex-shrink: 0; cursor: pointer; user-select: none; -webkit-user-select: none; background: none; font-family: inherit; line-height: 1.2; letter-spacing: 0.3px; outline: none; -webkit-appearance: none; appearance: none; } .mode-link:hover, .mode-link:active { background-color: var(--accent); color: #000; } .mode-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; } .balance-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; } .balance-value { font-size: 24px; font-weight: 700; color: var(--text-main); } .pnl-badge { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 4px; background: rgba(79, 195, 247, 0.12); color: var(--edu-color); transition: background-color .2s, color .2s; } .stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; font-size: 12px; } .stat-box { background: rgba(255, 255, 255, 0.03); padding: 8px; border-radius: 6px; } .stat-label { color: var(--text-muted); margin-bottom: 2px; } .stat-val { font-weight: 600; } .ticker-bar { display: flex; justify-content: space-between; padding: 8px 12px; background: #12161a; font-size: 13px; border-bottom: 1px solid #2b3139; align-items: center; gap: 8px; } .chart-type-select { flex-shrink: 0; background-color: #2b3139; color: var(--text-main); border: 1px solid #3a4048; border-radius: 5px; padding: 3px 16px 3px 8px; font-size: 11px; font-weight: 600; font-family: inherit; cursor: pointer; outline: none; -webkit-appearance: none; -moz-appearance: none; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'><path d='M0 2 L4 6 L8 2 Z' fill='%23848e9c'/></svg>"); background-repeat: no-repeat; background-position: right 5px center; user-select: none; -webkit-user-select: none; } .chart-type-select:focus { border-color: var(--accent); } .indicator-bar { display: flex; gap: 6px; padding: 6px 8px; background: #12161a; border-bottom: 1px solid #2b3139; position: relative; z-index: 50; } .ind-select { flex: 1 1 0; min-width: 0; background-color: #2b3139; color: var(--text-main); border: 1px solid #3a4048; border-radius: 5px; padding: 5px 16px 5px 6px; font-size: 11px; font-family: inherit; cursor: pointer; outline: none; -webkit-appearance: none; -moz-appearance: none; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'><path d='M0 2 L4 6 L8 2 Z' fill='%23848e9c'/></svg>"); background-repeat: no-repeat; background-position: right 5px center; } .ind-select:focus { border-color: var(--accent); } .ind-wrap { flex: 1 1 0; min-width: 0; display: flex; gap: 4px; } .ind-select.ind-native-hidden { display: none !important; } .ind-trigger { flex: 1 1 0; min-width: 0; background-color: #2b3139; color: var(--text-main); border: 1px solid #3a4048; border-radius: 5px; padding: 5px 16px 5px 6px; font-size: 11px; font-family: inherit; text-align: left; cursor: pointer; outline: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'><path d='M0 2 L4 6 L8 2 Z' fill='%23848e9c'/></svg>"); background-repeat: no-repeat; background-position: right 5px center; user-select: none; -webkit-user-select: none; transition: color 0.2s, border-color 0.2s, background-color 0.2s, box-shadow 0.2s; } .ind-trigger:focus { border-color: var(--accent); } .ind-trigger.slot-color-0 { color: #f0b90b; border-color: #f0b90b; background-color: rgba(240, 185, 11, 0.12); font-weight: 700; } .ind-trigger.slot-color-1 { color: #4fc3f7; border-color: #4fc3f7; background-color: rgba(79, 195, 247, 0.12); font-weight: 700; } .ind-trigger.slot-color-2 { color: #e91e63; border-color: #e91e63; background-color: rgba(233, 30, 99, 0.12); font-weight: 700; } .ind-info-btn { flex: 0 0 auto; width: 24px; background: #2b3139; color: var(--edu-color); border: 1px solid #3a4048; border-radius: 5px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; padding: 0; line-height: 1; transition: background-color 0.15s; } .ind-info-btn:hover, .ind-info-btn:active { background: #3a4048; color: #fff; } .ind-panel { position: absolute; top: 100%; left: 8px; width: 220px; z-index: 200; background: #1e2329; border: 1px solid #3a4048; border-radius: 6px; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.65); padding: 8px; display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow: hidden; } .ind-panel[hidden] { display: none; } .ind-search { flex: 0 0 auto; width: 100%; background-color: #2b3139; color: var(--text-main); border: 1px solid #3a4048; border-radius: 4px; padding: 8px 10px; font-size: 13px; font-family: inherit; outline: none; } .ind-search:focus { border-color: var(--accent); } .ind-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; -webkit-overflow-scrolling: touch; } .ind-opt { flex: 0 0 auto; padding: 8px 10px; font-size: 13px; line-height: 1.45; border-radius: 4px; cursor: pointer; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .ind-opt:hover, .ind-opt.highlight { background-color: #2b3139; } .ind-opt.selected { color: var(--accent); font-weight: 700; } .ind-opt.disabled { color: #5b636e; font-style: italic; cursor: default; pointer-events: none; } .ind-empty { flex: 0 0 auto; padding: 10px; font-size: 13px; color: var(--text-muted); text-align: center; } .ind-info-panel { position: absolute; top: 100%; right: 8px; width: 260px; z-index: 250; background: #1e2329; border: 1px solid var(--edu-color); border-radius: 6px; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.75); padding: 12px; max-height: 380px; overflow-y: auto; -webkit-overflow-scrolling: touch; } .ind-info-panel[hidden] { display: none; } .ind-info-title { color: var(--edu-color); font-size: 13px; font-weight: 700; margin-bottom: 6px; letter-spacing: 0.3px; } .ind-info-body { font-size: 11.5px; line-height: 1.55; color: #c9cdd4; margin-bottom: 8px; } .ind-info-formula { background: #12161a; border-left: 3px solid var(--edu-color); padding: 6px 8px; font-family: 'Courier New', monospace; font-size: 10.5px; color: #eaecef; border-radius: 3px; margin-bottom: 8px; white-space: pre-wrap; word-break: break-word; } .ind-info-note { font-size: 10.5px; color: #f6465d; font-style: italic; border-top: 1px dashed #3a4048; padding-top: 6px; line-height: 1.4; } .ind-info-close { position: absolute; top: 6px; right: 8px; background: none; border: none; color: var(--text-muted); font-size: 16px; cursor: pointer; padding: 2px 6px; font-family: inherit; line-height: 1; } .ind-info-close:hover { color: #fff; } .fee-row { display: flex; gap: 12px; padding: 6px 12px; background: #12161a; border-bottom: 1px solid #2b3139; font-size: 12px; color: var(--text-muted); align-items: center; } .fee-row label { display: flex; align-items: center; gap: 6px; flex: 1; } .fee-row input { width: 60px; background-color: #2b3139; color: var(--text-main); border: 1px solid #3a4048; border-radius: 4px; padding: 4px 6px; font-size: 12px; font-family: inherit; outline: none; } .fee-row input:focus { border-color: var(--accent); } .brand-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: rgba(18, 22, 26, 0.92); border-bottom: 1px solid #2b3139; border-top: 1px solid #2b3139; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); gap: 8px; } .brand-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.3px; color: var(--accent); text-decoration: none; padding: 3px 8px; border-radius: 4px; transition: background-color 0.2s, color 0.2s; flex-shrink: 0; } .brand-link:hover, .brand-link:active { background-color: var(--accent); color: #000; } .datasource-group { display: flex; gap: 0; background: #2b3139; border-radius: 5px; padding: 2px; flex-shrink: 0; } .ds-btn { background: transparent; color: var(--text-muted); border: none; padding: 4px 9px; font-size: 11px; font-weight: 700; border-radius: 4px; cursor: pointer; font-family: inherit; letter-spacing: 0.3px; transition: background-color 0.15s, color 0.15s; user-select: none; -webkit-user-select: none; } .ds-btn:hover:not(.active) { color: var(--text-main); background: rgba(255, 255, 255, 0.06); } .ds-btn.active { background: var(--accent); color: #000; } /* ===== SIKLUS ALAM MODE SELECTOR ===== */ .synthetic-mode-row { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: #12161a; border-bottom: 1px solid #2b3139; font-size: 11px; flex-shrink: 0; } .synthetic-mode-row.hidden { display: none; } .synthetic-mode-label { color: var(--text-muted); flex-shrink: 0; font-weight: 700; letter-spacing: 0.2px; } .synthetic-mode-select { flex: 1 1 auto; min-width: 0; background-color: #2b3139; color: var(--text-main); border: 1px solid #3a4048; border-radius: 5px; padding: 5px 22px 5px 8px; font-size: 11px; font-weight: 700; font-family: inherit; cursor: pointer; outline: none; -webkit-appearance: none; -moz-appearance: none; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'><path d='M0 2 L4 6 L8 2 Z' fill='%23848e9c'/></svg>"); background-repeat: no-repeat; background-position: right 6px center; user-select: none; -webkit-user-select: none; transition: border-color 0.2s, color 0.2s; } .synthetic-mode-select:focus { border-color: var(--accent); } .synthetic-mode-select.mode-random { color: #eaecef; } .synthetic-mode-select.mode-subur { color: #0ecb81; border-color: rgba(14, 203, 129, 0.5); } .synthetic-mode-select.mode-paceklik { color: #f6465d; border-color: rgba(246, 70, 93, 0.5); } .synthetic-mode-hint { font-size: 9.5px; color: var(--text-muted); font-style: italic; flex-shrink: 0; max-width: 40%; text-align: right; line-height: 1.2; } .chart-container { flex: 1.8 1 0; position: relative; background-color: var(--bg-main); width: 100%; min-height: 100px; overflow: hidden; } .subchart-container { flex: 0.9 1 0; position: relative; background-color: var(--bg-main); width: 100%; min-height: 50px; border-top: 1px solid #2b3139; overflow: hidden; } canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; } .control-panel { background-color: var(--bg-card); padding: 12px; border-top: 1px solid #2b3139; } .playback-controls { display: flex; gap: 8px; margin-bottom: 10px; } .btn { flex: 1; border: none; padding: 10px; font-size: 14px; font-weight: 600; border-radius: 8px; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 6px; transition: opacity 0.2s; user-select: none; } .btn:active { opacity: 0.8; } .btn:disabled { opacity: 0.4; cursor: not-allowed; } .btn-secondary { background-color: #2b3139; color: var(--text-main); } .btn-buy { background-color: #2b5a4a; color: #fff; font-size: 13px; } .btn-sell { background-color: #5a3038; color: #fff; font-size: 13px; } .trade-actions { display: flex; gap: 12px; } .pos-indicator { text-align: center; font-size: 12px; color: var(--text-muted); margin-bottom: 8px; min-height: 15px; } .btn .btn-icon { display: inline-block; width: 14px; height: 14px; flex-shrink: 0; vertical-align: middle; pointer-events: none; } .speed-select { flex: 0.5; min-width: 0; background-color: #2b3139; color: var(--text-main); border: 1px solid #3a4048; border-radius: 8px; padding: 10px 14px 10px 4px; font-size: 12px; font-weight: 700; font-family: inherit; text-align: center; text-align-last: center; cursor: pointer; outline: none; -webkit-appearance: none; -moz-appearance: none; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'><path d='M0 2 L4 6 L8 2 Z' fill='%23848e9c'/></svg>"); background-repeat: no-repeat; background-position: right 4px center; user-select: none; -webkit-user-select: none; transition: opacity 0.2s, border-color 0.2s; } .speed-select:focus { border-color: var(--accent); } .speed-select:active { opacity: 0.8; } #countdown-timer { flex: 1 1 auto; min-width: 0; text-align: center; font-size: 10px; font-weight: 700; letter-spacing: 0.2px; line-height: 1.25; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none; -webkit-user-select: none; } #countdown-timer.expired { color: var(--down-color); } #upload-btn:disabled { color: #5b636e; cursor: not-allowed; } #ojk-disclaimer-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.96); z-index: 99999; display: flex; justify-content: center; align-items: flex-start; padding: 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; } #ojk-disclaimer-modal .modal-card { max-width: 420px; width: 100%; background: #181a20; padding: 22px; border-radius: 12px; border: 1px solid #f0b90b; box-shadow: 0 10px 40px rgba(240, 185, 11, 0.15); margin: auto; flex-shrink: 0; } #ojk-disclaimer-modal h2 { color: #f0b90b; margin-bottom: 14px; font-size: 17px; text-align: center; } #ojk-disclaimer-modal p { font-size: 12.5px; line-height: 1.6; color: #eaecef; margin-bottom: 12px; } #ojk-disclaimer-modal ul { font-size: 12px; line-height: 1.55; color: #c9cdd4; margin: 0 0 14px 18px; padding: 0; } #ojk-disclaimer-modal li { margin-bottom: 6px; } #ojk-disclaimer-modal .strong-warning { color: #f6465d; font-weight: 700; } #ojk-disclaimer-modal .strong-edu { color: #4fc3f7; font-weight: 700; } #ojk-disclaimer-modal .legal-box { background: #12161a; border-left: 3px solid #f6465d; padding: 10px 12px; border-radius: 4px; margin-bottom: 14px; font-size: 11.5px; line-height: 1.6; color: #c9cdd4; } #ojk-disclaimer-modal .legal-box strong { color: #f6465d; } #ojk-disclaimer-accept { width: 100%; padding: 12px; background: #f0b90b; color: #000; border: none; border-radius: 8px; font-weight: 700; font-size: 14px; font-family: inherit; cursor: pointer; letter-spacing: 0.3px; transition: background-color 0.2s; } #ojk-disclaimer-accept:hover, #ojk-disclaimer-accept:active { background: #d9a609; } .ojk-footer { background: #12161a; border-top: 1px solid #2b3139; padding: 5px 10px; font-size: 9.5px; line-height: 1.35; color: #848e9c; text-align: center; flex-shrink: 0; } .ojk-footer strong { color: #f0b90b; } .ojk-footer .legal-strong { color: #f6465d; font-weight: 700; } </style> </head> <body> <!-- MODAL INTRO GAME --> <div id="ojk-disclaimer-modal" role="dialog" aria-modal="true" aria-labelledby="game-modal-title"> <div class="modal-card"> <h2 id="game-modal-title">🍎 JELAJAH: Kebun Apel Lembah Fajar</h2> <p> Kamu adalah <span class="strong-edu">Penjaga Kebun</span> baru di Lembah Fajar — sebuah perkebunan apel tua yang berbuah mengikuti irama alam yang misterius. Setiap musim, produksinya berubah acak. </p> <p><strong>🎯 Cara Bermain:</strong></p> <ul> <li>Bekal awal: <span class="strong-edu">1.000.000 unit Energi Kehidupan</span>.</li> <li><span class="strong-edu">Setiap 1 apel = 1 energi</span> untuk dipetik.</li> <li>Pengambilan hanya bisa dalam <span class="strong-edu">kelipatan 100</span> — minimal 100, maksimal 10.000 apel per petik.</li> <li>Petik di musim subur (nilai tukar rendah), tukar di musim paceklik (nilai tukar tinggi).</li> <li>Apel hanya bisa ditukar kembali ke energi dalam <span class="strong-edu">kelipatan 100</span>.</li> <li>Perjalanan berlangsung <span class="strong-edu">250 musim</span>. Raih skor tertinggi!</li> </ul> <p><strong>🛠️ Alat Bantu (Mode Mahir):</strong></p> <ul> <li>Garis Rata-rata, Garis Cepat, Garis Berat, Garis Halus</li> <li>Pita Batas, Zona Sempit</li> <li>Meteran Energi, Detektor Arah</li> </ul> <p><strong>🌤️ Tiga Siklus Alam:</strong></p> <ul> <li><strong style="color:#0ecb81">Random</strong> — musim seimbang, naik-turun alami (default).</li> <li><strong style="color:#4fc3f7">Subur</strong> — harga cenderung murah. Tantangan: tunggu harga naik untuk panen besar.</li> <li><strong style="color:#f6465d">Paceklik</strong> — harga cenderung mahal. Kepuasan: jual apel dengan nilai tukar tinggi.</li> </ul> <div class="legal-box"> <strong>⚠️ Penafian Penting:</strong><br> Ini murni <strong>permainan hiburan dan simulasi edukasi</strong>. Seluruh istilah "apel", "musim", "energi", "petik", dan "tukar" adalah metafora permainan — <strong>bukan</strong> aset keuangan riil, <strong>bukan</strong> rekomendasi investasi, dan <strong>bukan</strong> ajakan untuk bertransaksi di pasar keuangan mana pun. Tidak ada uang sungguhan, tidak ada jaminan hasil, dan tidak ada keterkaitan dengan produk atau jasa keuangan apa pun. Materi edukasi dalam game ini <strong>tidak bekerja sama dengan Pelaku Usaha Jasa Keuangan (PUJK)</strong> manapun dan tidak mempromosikan merek produk keuangan tertentu. </div> <button type="button" id="ojk-disclaimer-accept">Mulai Menjaga Kebun 🍎</button> </div> </div> <div class="phone-container"> <div class="edu-banner"> 🍎 <strong>JELAJAH</strong> — Kebun Apel Lembah Fajar. Game edukasi simulasi. Bukan rekomendasi investasi. </div> <div class="header"> <div class="header-title-row"> <span class="header-title">ENERGI TOTAL</span> <button type="button" id="upgrade-btn" class="upgrade-btn" title="Panduan lengkap bermain">Panduan</button> <button type="button" id="mode-basic-link" class="mode-link" title="Klik untuk beralih ke MODE:MAHIR (alat bantu lanjutan)">MODE:DASAR</button> </div> <div class="balance-row"> <span class="balance-value" id="equity-val">1.000.000</span> <span class="pnl-badge" id="pnl-pct">Perubahan: 0</span> </div> <div class="stats-grid"> <div class="stat-box"> <div class="stat-label">Energi Awal</div> <div class="stat-val" id="cash-val">1.000.000</div> </div> <div class="stat-box"> <div class="stat-label">Nilai Apel Saat Ini</div> <div class="stat-val" id="asset-val">0</div> </div> </div> </div> <div class="ticker-bar"> <div> <strong style="color:var(--edu-color)">MUSIM KE</strong> <span id="bar-progress" style="color:var(--text-muted)">0/250</span> </div> <select id="chart-type-select" class="chart-type-select" title="Tampilan Panen" aria-label="Tampilan Panen"> <option value="line" selected title="Aliran Panen — 1 nilai rata-rata per musim">Aliran Panen</option> <option value="candle" title="Rentang Panen — 4 nilai penuh per musim (awal, puncak, terendah, akhir)">Rentang Panen</option> </select> <div id="ticker-price" style="font-weight:700; color:var(--text-main)">0</div> </div> <div class="indicator-bar"> <select id="ind1" class="ind-select" title="Alat bantu visual 1"> <option value="">Nonaktif</option> <option value="ma5">Rata 5</option> <option value="ma10">Rata 10</option> <option value="ma20">Rata 20</option> <option value="ma50">Rata 50</option> <option value="ma100">Rata 100</option> <option value="ma200">Rata 200</option> <option value="ema5">Cepat 5</option> <option value="ema10">Cepat 10</option> <option value="ema20">Cepat 20</option> <option value="ema50">Cepat 50</option> <option value="ema100">Cepat 100</option> <option value="ema200">Cepat 200</option> <option value="wma5">Berat 5</option> <option value="wma10">Berat 10</option> <option value="wma20">Berat 20</option> <option value="wma50">Berat 50</option> <option value="wma100">Berat 100</option> <option value="wma200">Berat 200</option> <option value="wilders5">Halus 5</option> <option value="wilders10">Halus 10</option> <option value="wilders20">Halus 20</option> <option value="wilders50">Halus 50</option> <option value="wilders100">Halus 100</option> <option value="wilders200">Halus 200</option> <option value="bollinger">Pita Batas</option> <option value="squeeze">Zona Sempit</option> <option value="mahir" disabled>== MODE:MAHIR ==</option> <option value="supnresv01" disabled>Bantuan Lanjutan</option> </select> <select id="ind2" class="ind-select" title="Alat bantu visual 2"> <option value="">Nonaktif</option> <option value="ma5">Rata 5</option> <option value="ma10">Rata 10</option> <option value="ma20">Rata 20</option> <option value="ma50">Rata 50</option> <option value="ma100">Rata 100</option> <option value="ma200">Rata 200</option> <option value="ema5">Cepat 5</option> <option value="ema10">Cepat 10</option> <option value="ema20">Cepat 20</option> <option value="ema50">Cepat 50</option> <option value="ema100">Cepat 100</option> <option value="ema200">Cepat 200</option> <option value="wma5">Berat 5</option> <option value="wma10">Berat 10</option> <option value="wma20">Berat 20</option> <option value="wma50">Berat 50</option> <option value="wma100">Berat 100</option> <option value="wma200">Berat 200</option> <option value="wilders5">Halus 5</option> <option value="wilders10">Halus 10</option> <option value="wilders20">Halus 20</option> <option value="wilders50">Halus 50</option> <option value="wilders100">Halus 100</option> <option value="wilders200">Halus 200</option> <option value="bollinger">Pita Batas</option> <option value="squeeze">Zona Sempit</option> <option value="mahir" disabled>== MODE:MAHIR ==</option> <option value="supnresv01" disabled>Bantuan Lanjutan</option> </select> <select id="ind3" class="ind-select" title="Alat bantu visual 3"> <option value="">Nonaktif</option> <option value="ma5">Rata 5</option> <option value="ma10">Rata 10</option> <option value="ma20">Rata 20</option> <option value="ma50">Rata 50</option> <option value="ma100">Rata 100</option> <option value="ma200">Rata 200</option> <option value="ema5">Cepat 5</option> <option value="ema10">Cepat 10</option> <option value="ema20">Cepat 20</option> <option value="ema50">Cepat 50</option> <option value="ema100">Cepat 100</option> <option value="ema200">Cepat 200</option> <option value="wma5">Berat 5</option> <option value="wma10">Berat 10</option> <option value="wma20">Berat 20</option> <option value="wma50">Berat 50</option> <option value="wma100">Berat 100</option> <option value="wma200">Berat 200</option> <option value="wilders5">Halus 5</option> <option value="wilders10">Halus 10</option> <option value="wilders20">Halus 20</option> <option value="wilders50">Halus 50</option> <option value="wilders100">Halus 100</option> <option value="wilders200">Halus 200</option> <option value="bollinger">Pita Batas</option> <option value="squeeze">Zona Sempit</option> <option value="mahir" disabled>== MODE:MAHIR ==</option> <option value="supnresv01" disabled>Bantuan Lanjutan</option> </select> <select id="subchart" class="ind-select" title="Radar bawah"> <option value="rsi">Meteran Energi</option> <option value="macd">Detektor Arah</option> </select> </div> <div class="fee-row"> <label>Biaya Petik (%): <input type="number" id="fee-buy-input" value="0.3" step="0.01" min="0" max="10"></label> <label>Biaya Tukar (%): <input type="number" id="fee-sell-input" value="0.3" step="0.01" min="0" max="10"></label> </div> <div class="brand-bar"> <a class="brand-link" href="https://lynk.id/readthefuture" target="_blank" rel="noopener noreferrer"> <span>@readthefuture</span> </a> <div id="countdown-timer" aria-live="polite">Trial belum dimulai</div> <div class="datasource-group" role="group" aria-label="Sumber siklus alam"> <button type="button" class="ds-btn active" data-source="synthetic" title="Siklus alam bawaan — musim dibuat acak oleh Lembah Fajar">Siklus Alam</button> <button type="button" class="ds-btn" id="upload-btn" data-source="upload" title="Muat Data Siklus Alam — unggah data musimmu sendiri dari file" disabled>Muat 3x</button> </div> <input type="file" id="csv-input" accept=".csv,.txt,.tsv" hidden> </div> <!-- BARIS BARU: Pemilih mode Siklus Alam --> <div class="synthetic-mode-row" id="synthetic-mode-row"> <span class="synthetic-mode-label">🌤️ Mode:</span> <select id="synthetic-mode-select" class="synthetic-mode-select mode-random" title="Pilih karakter siklus alam bawaan"> <option value="random" selected>🎲 Siklus Alam Random (Default)</option> <option value="subur">🌱 Siklus Alam Subur — Harga Murah</option> <option value="paceklik">🔥 Siklus Alam Paceklik — Harga Mahal</option> </select> <span class="synthetic-mode-hint" id="synthetic-mode-hint">Seimbang</span> </div> <div class="chart-container" id="chart-parent"> <canvas id="tradingChart"></canvas> </div> <div class="subchart-container" id="subchart-parent"> <canvas id="subChart"></canvas> </div> <div class="control-panel"> <div class="pos-indicator" id="pos-info">Apel terkumpul: 0 (Nilai rata-rata: 0)</div> <div class="playback-controls"> <select id="speed-select" class="speed-select" title="Kecepatan Musim"> <option value="0.5">0.5x</option> <option value="1" selected>1x</option> <option value="5">2x</option> <option value="6">5x</option> <option value="9">10x</option> <option value="10">20x</option> </select> <button class="btn btn-secondary" id="btn-pause"> <svg class="btn-icon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false"> <rect x="6" y="5" width="4" height="14" rx="1"></rect> <rect x="14" y="5" width="4" height="14" rx="1"></rect> </svg> <span>Jeda</span> </button> <button class="btn btn-secondary" id="btn-restart"> <svg class="btn-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"> <path d="M21 12a9 9 0 1 1-3-6.7"></path> <polyline points="21 4 21 10 15 10"></polyline> </svg> <span>Ulang</span> </button> </div> <div class="trade-actions"> <button class="btn btn-buy" id="btn-buy">+ PETIK APEL</button> <button class="btn btn-sell" id="btn-sell">− TUKAR APEL</button> </div> </div> <div class="ojk-footer"> 🍎 <strong>JELAJAH</strong> — Game edukasi simulasi. <span class="legal-strong">Bukan rekomendasi investasi.</span> Tidak bekerja sama dengan PUJK. Tidak ada uang riil. </div> </div> <script> (function () { 'use strict'; const DISPLAY_SCALE = 1.0; window.setDisplayScale = function (scale) { let s = parseFloat(scale); if (!isFinite(s) || s <= 0) s = 1; if (s < 0.25) s = 0.25; if (s > 2.00) s = 2.00; document.documentElement.style.setProperty('--display-scale', String(s)); return s; }; window.setDisplayScale(DISPLAY_SCALE); })(); </script> <script> (function () { 'use strict'; const modal = document.getElementById('ojk-disclaimer-modal'); const acceptBtn = document.getElementById('ojk-disclaimer-accept'); if (!modal || !acceptBtn) return; let alreadyAccepted = false; try { alreadyAccepted = sessionStorage.getItem('ojk_disclaimer_accepted') === '1'; } catch (e) {} if (alreadyAccepted) { modal.style.display = 'none'; return; } acceptBtn.addEventListener('click', function () { try { sessionStorage.setItem('ojk_disclaimer_accepted', '1'); } catch (e) {} modal.style.display = 'none'; }); })(); </script> <script> const INDICATOR_INFO = { 'ma5': { title: 'Garis Rata-rata 5 Musim', body: 'Menampilkan garis rata-rata dari 5 musim terakhir. Membantu melihat arah nilai tukar dengan lebih halus tanpa terganggu naik-turun kecil.', formula: 'Rata(5) = (M1 + M2 + M3 + M4 + M5) / 5', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'ma10': { title: 'Garis Rata-rata 10 Musim', body: 'Rata-rata dari 10 musim terakhir. Menyeimbangkan kepekaan dan kestabilan.', formula: 'Rata(10) = Σ(Mi) / 10, i=1..10', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'ma20': { title: 'Garis Rata-rata 20 Musim', body: 'Rata-rata 20 musim terakhir. Lebih halus dari Rata 10.', formula: 'Rata(20) = Σ(Mi) / 20, i=1..20', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'ma50': { title: 'Garis Rata-rata 50 Musim', body: 'Rata-rata jangka menengah. Membutuhkan lebih banyak musim awal.', formula: 'Rata(50) = Σ(Mi) / 50, i=1..50', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'ma100': { title: 'Garis Rata-rata 100 Musim', body: 'Rata-rata jangka panjang. Halus namun lambat merespons.', formula: 'Rata(100) = Σ(Mi) / 100, i=1..100', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'ma200': { title: 'Garis Rata-rata 200 Musim', body: 'Rata-rata jangka sangat panjang. Membutuhkan data dalam jumlah besar.', formula: 'Rata(200) = Σ(Mi) / 200, i=1..200', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'ema5': { title: 'Garis Cepat 5 Musim', body: 'Memberi bobot lebih besar pada musim terbaru. Bobot menurun eksponensial. Faktor k = 2/(n+1).', formula: 'k = 2 / (n + 1)\nGaris_today = (Nilai_today × k) + (Garis_yesterday × (1 − k))', note: 'Nilai awal = rata-rata n musim. Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'ema10': { title: 'Garis Cepat 10 Musim', body: 'Garis cepat dengan k = 2/11 ≈ 0.1818.', formula: 'k = 2 / (10 + 1) = 0.1818', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'ema20': { title: 'Garis Cepat 20 Musim', body: 'Garis cepat dengan k = 2/21 ≈ 0.0952.', formula: 'k = 2 / (20 + 1) ≈ 0.0952', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'ema50': { title: 'Garis Cepat 50 Musim', body: 'Garis cepat dengan k ≈ 0.0392.', formula: 'k = 2 / (50 + 1) ≈ 0.0392', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'ema100': { title: 'Garis Cepat 100 Musim', body: 'Garis cepat dengan k ≈ 0.0198.', formula: 'k = 2 / (100 + 1) ≈ 0.0198', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'ema200': { title: 'Garis Cepat 200 Musim', body: 'Garis cepat dengan k ≈ 0.00995.', formula: 'k = 2 / (200 + 1) ≈ 0.00995', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'wma5': { title: 'Garis Berat 5 Musim', body: 'Memberi bobot linear: musim terbaru bobotnya paling besar. Total bobot = n(n+1)/2.', formula: 'Berat(n) = Σ(Pi × Wi) / Σ(Wi)\nWi = 1, 2, 3, ..., n', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'wma10': { title: 'Garis Berat 10 Musim', body: 'Bobot linear 1 sampai 10.', formula: 'Berat(10) = Σ(Pi × i) / 55', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'wma20': { title: 'Garis Berat 20 Musim', body: 'Bobot linear 1 sampai 20.', formula: 'Berat(20) = Σ(Pi × i) / 210', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'wma50': { title: 'Garis Berat 50 Musim', body: 'Bobot linear 1 sampai 50.', formula: 'Berat(50) = Σ(Pi × i) / 1275', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'wma100': { title: 'Garis Berat 100 Musim', body: 'Bobot linear 1 sampai 100.', formula: 'Berat(100) = Σ(Pi × i) / 5050', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'wma200': { title: 'Garis Berat 200 Musim', body: 'Bobot linear 1 sampai 200.', formula: 'Berat(200) = Σ(Pi × i) / 20100', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'wilders5': { title: 'Garis Halus 5 Musim', body: 'Metode penghalusan dengan faktor k = 1/n. Menghasilkan garis yang lebih halus dari rata-rata biasa.', formula: 'Halus_today = (Halus_yesterday × (n − 1) + Nilai_today) / n', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'wilders10': { title: 'Garis Halus 10 Musim', body: 'Penghalusan dengan k = 1/10 = 0.1', formula: 'H = (H_prev × 9 + M) / 10', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'wilders20': { title: 'Garis Halus 20 Musim', body: 'Penghalusan dengan k = 1/20 = 0.05', formula: 'H = (H_prev × 19 + M) / 20', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'wilders50': { title: 'Garis Halus 50 Musim', body: 'Penghalusan dengan k = 1/50 = 0.02', formula: 'H = (H_prev × 49 + M) / 50', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'wilders100': { title: 'Garis Halus 100 Musim', body: 'Penghalusan dengan k = 1/100 = 0.01', formula: 'H = (H_prev × 99 + M) / 100', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'wilders200': { title: 'Garis Halus 200 Musim', body: 'Penghalusan dengan k = 1/200 = 0.005', formula: 'H = (H_prev × 199 + M) / 200', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'bollinger': { title: 'Pita Batas Nilai Tukar', body: 'Terdiri dari 3 garis: garis tengah (rata-rata 20), pita atas (tengah + 2×SD), dan pita bawah (tengah − 2×SD). SD mengukur seberapa tersebar data.', formula: 'Tengah = Rata(20)\nSD = √(Σ(Mi − Tengah)² / n)\nAtas = Tengah + 2 × SD\nBawah = Tengah − 2 × SD', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'squeeze': { title: 'Zona Sempit', body: 'Mendeteksi kondisi nilai tukar yang sedang "terkompresi" dengan membandingkan dua metode perhitungan. Jika satu berada di dalam yang lain → zona sempit aktif.', formula: 'Pita_Atas < KC_Atas DAN Pita_Bawah > KC_Bawah\n→ Zona Sempit = ON (1)', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' } }; const SUB_INDICATOR_INFO = { 'rsi': { title: 'Meteran Energi', body: 'Mengukur ritme naik-turun nilai tukar apel. Nilainya berkisar 0-100. Semakin tinggi, semakin sering nilai tukar naik.', formula: 'RS = Rata Naik / Rata Turun\nMeteran = 100 − (100 / (1 + RS))', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }, 'macd': { title: 'Detektor Arah', body: 'Menunjukkan momentum nilai tukar dengan membandingkan dua garis cepat. Detektor Arah = selisih antara dua garis cepat. Garis sinyal = garis cepat dari Detektor Arah.', formula: 'Detektor = Cepat(12) − Cepat(26)\nSinyal = Cepat(9) dari Detektor\nHistogram = Detektor − Sinyal', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' } }; </script> <script> (function () { 'use strict'; const INITIAL_CASH = 1000000; const WARMUP_BARS = 30; const VISIBLE_BARS = 30; const INTERVAL_TIME = 1000; const START_PRICE_MIN = 100; const START_PRICE_MAX = 5000; const DEFAULT_TOTAL_BARS = 250; const MAX_UPLOAD_BARS = 5000; // ===== ATURAN KEBUN (sesuai cerita) ===== const COST_PER_APPLE = 1; // 1 apel = 1 energi (Hukum Pertama) const APPLE_STEP = 100; // kelipatan 100 (Hukum Kedua & Keenam) const MIN_APPLES = 100; // minimal 100 apel per petik (Hukum Ketiga) const MAX_APPLES_PICK = 10000; // maksimal 10.000 apel per petik (Hukum Keempat) let TOTAL_BARS = DEFAULT_TOTAL_BARS; let END_INDEX = WARMUP_BARS + TOTAL_BARS; let feeBeli = 0.003; let feeJual = 0.003; let speedMultiplier = 1; // ===== MODE SIKLUS ALAM ===== // 'random' → musim seimbang (default) // 'subur' → harga cenderung turun/rendah (tantangan: jual di harga tinggi) // 'paceklik' → harga cenderung naik/tinggi (kepuasan: jual mahal) let syntheticMode = 'random'; const SLOT_COLORS = ['#f0b90b', '#4fc3f7', '#e91e63']; const ICON_PAUSE = '<svg class="btn-icon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">' + '<rect x="6" y="5" width="4" height="14" rx="1"></rect>' + '<rect x="14" y="5" width="4" height="14" rx="1"></rect>' + '</svg>'; const ICON_PLAY = '<svg class="btn-icon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">' + '<path d="M8 5v14l11-7z"></path>' + '</svg>'; let fullData = []; let currentIndex = WARMUP_BARS; let isPaused = false; let finished = false; let timer = null; let cash = INITIAL_CASH; let positionVolume = 0; let avgBuyPrice = 0; let dpr = 1; let viewW = 0, viewH = 0; let subViewW = 0, subViewH = 0; let dataSource = 'synthetic'; let uploadedData = null; let uploadedLineData = null; let uploadedHasOHLC = false; let syntheticOHLC = null; let chartType = 'line'; let closesCache = null; const indicatorCache = new Map(); const subIndicatorCache = new Map(); function invalidateIndicatorCache() { closesCache = null; indicatorCache.clear(); subIndicatorCache.clear(); } function getClosesCached() { if (!closesCache) closesCache = fullData.map(function (d) { return d.close; }); return closesCache; } function getIndicatorCached(slot, sel) { const key = slot + ':' + sel; if (indicatorCache.has(key)) return indicatorCache.get(key); const series = getIndicatorSeries(sel, getClosesCached(), fullData); indicatorCache.set(key, series); return series; } function getSubIndicatorCached(type) { if (subIndicatorCache.has(type)) return subIndicatorCache.get(type); const closes = getClosesCached(); let result; if (type === 'rsi') result = calcRSI(closes, 14); else result = calcMACD(closes, 12, 26, 9); subIndicatorCache.set(type, result); return result; } function getEffectiveDpr() { const raw = window.devicePixelRatio || 1; const cores = navigator.hardwareConcurrency || 4; const maxDpr = cores <= 4 ? 1.5 : 2.0; const d = Math.min(raw, maxDpr); return d > 0 ? d : 1; } const canvas = document.getElementById('tradingChart'); const ctx = canvas.getContext('2d'); const equityValEl = document.getElementById('equity-val'); const cashValEl = document.getElementById('cash-val'); const assetValEl = document.getElementById('asset-val'); const pnlPctEl = document.getElementById('pnl-pct'); const tickerPriceEl = document.getElementById('ticker-price'); const barProgressEl = document.getElementById('bar-progress'); const posInfoEl = document.getElementById('pos-info'); const subCanvas = document.getElementById('subChart'); const sctx = subCanvas.getContext('2d'); const ind1El = document.getElementById('ind1'); const ind2El = document.getElementById('ind2'); const ind3El = document.getElementById('ind3'); const subSelectEl = document.getElementById('subchart'); const feeBuyInput = document.getElementById('fee-buy-input'); const feeSellInput = document.getElementById('fee-sell-input'); const btnPause = document.getElementById('btn-pause'); const btnRestart = document.getElementById('btn-restart'); const btnBuy = document.getElementById('btn-buy'); const btnSell = document.getElementById('btn-sell'); const speedSelectEl = document.getElementById('speed-select'); const chartTypeSelectEl = document.getElementById('chart-type-select'); const dsBtns = document.querySelectorAll('.ds-btn'); const csvInput = document.getElementById('csv-input'); // ===== REFERENSI BARU: Pemilih mode Siklus Alam ===== const syntheticModeRowEl = document.getElementById('synthetic-mode-row'); const syntheticModeSelectEl = document.getElementById('synthetic-mode-select'); const syntheticModeHintEl = document.getElementById('synthetic-mode-hint'); let infoPanelEl = null; let infoTitleEl = null; let infoBodyEl = null; let infoFormulaEl = null; let infoNoteEl = null; function createInfoPanel() { const barEl = document.querySelector('.indicator-bar'); if (!barEl) return; const panel = document.createElement('div'); panel.className = 'ind-info-panel'; panel.hidden = true; const closeBtn = document.createElement('button'); closeBtn.type = 'button'; closeBtn.className = 'ind-info-close'; closeBtn.innerHTML = '&times;'; closeBtn.setAttribute('aria-label', 'Tutup'); closeBtn.addEventListener('click', function () { panel.hidden = true; }); const title = document.createElement('div'); title.className = 'ind-info-title'; const body = document.createElement('div'); body.className = 'ind-info-body'; const formula = document.createElement('div'); formula.className = 'ind-info-formula'; const note = document.createElement('div'); note.className = 'ind-info-note'; panel.appendChild(closeBtn); panel.appendChild(title); panel.appendChild(body); panel.appendChild(formula); panel.appendChild(note); barEl.appendChild(panel); infoPanelEl = panel; infoTitleEl = title; infoBodyEl = body; infoFormulaEl = formula; infoNoteEl = note; } function showIndicatorInfo(which) { if (!infoPanelEl) return; let info = null; let key = ''; if (which === 'sub') { key = subSelectEl.value; info = SUB_INDICATOR_INFO[key]; } else { const selEl = which === 'ind1' ? ind1El : (which === 'ind2' ? ind2El : ind3El); key = selEl.value; if (!key) { info = { title: 'Belum Ada Alat Bantu Dipilih', body: 'Pilih salah satu alat bantu pada dropdown di samping untuk melihat penjelasan konsep, rumus matematika, dan catatan penggunaan.', formula: '—', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }; } else { info = INDICATOR_INFO[key]; } } if (!info) { info = { title: 'Penjelasan Belum Tersedia', body: 'Materi untuk alat bantu ini belum ditambahkan.', formula: '—', note: 'Materi edukasi simulasi. Bukan rekomendasi investasi.' }; } infoTitleEl.textContent = info.title; infoBodyEl.textContent = info.body; infoFormulaEl.textContent = info.formula; infoNoteEl.textContent = info.note; infoPanelEl.hidden = false; } function getTickSize(price) { if (price < 200) return 1; if (price < 500) return 2; if (price < 2000) return 5; if (price < 5000) return 10; return 25; } function bulatkanFraksi(price, up) { const tick = getTickSize(price); return up ? Math.ceil(price / tick) * tick : Math.floor(price / tick) * tick; } function formatUnit(num) { if (!isFinite(num)) num = 0; return Math.round(num).toLocaleString('id-ID'); } function toNum(str) { if (str === null || str === undefined) return NaN; let s = String(str).trim(); if (!s || s === '-' || s === 'null' || s === 'N/A' || s === 'n/a') return NaN; s = s.replace(/[^\d.\-]/g, ''); if (!s || s === '-' || s === '.') return NaN; return parseFloat(s); } function parseCSV(text) { text = text.replace(/^\uFEFF/, ''); const lines = text.split(/\r?\n/).map(l => l.trim()).filter(l => l.length > 0); if (lines.length < 2) throw new Error('File kosong atau terlalu pendek.'); const candidates = [',', ';', '\t']; let sep = ','; let maxCols = 0; for (let i = 0; i < candidates.length; i++) { const n = lines[0].split(candidates[i]).length; if (n > maxCols) { maxCols = n; sep = candidates[i]; } } const firstCells = lines[0].split(sep).map(c => c.trim().toLowerCase().replace(/["']/g, '')); const hasHeader = firstCells.some(c => /open|high|low|close|date|time|volume|adj|price|last|nilai|musim|step|apel/.test(c) ); let colMap = null; if (hasHeader) { const findCol = (patterns) => { for (let i = 0; i < firstCells.length; i++) { for (let p = 0; p < patterns.length; p++) { if (firstCells[i].indexOf(patterns[p]) !== -1) return i; } } return -1; }; const o = findCol(['open', 'awal', 'apel_1']); const h = findCol(['high', 'tertinggi', 'terbanyak', 'puncak', 'apel_2']); const l = findCol(['low', 'terendah', 'apel_3']); const c = findCol(['close', 'last', 'price', 'nilai', 'akhir', 'apel_4']); if (o !== -1 && h !== -1 && l !== -1 && c !== -1) { colMap = { open: o, high: h, low: l, close: c }; } } const startRow = hasHeader ? 1 : 0; const rawRows = []; for (let r = startRow; r < lines.length; r++) { const cells = lines[r].split(sep).map(c => c.trim().replace(/["']/g, '')); rawRows.push(cells); } let colCount = firstCells.length; for (let i = 0; i < rawRows.length; i++) { if (rawRows[i].length > colCount) colCount = rawRows[i].length; } let lineIdx; if (colMap && colMap.close >= 0) { lineIdx = colMap.close; } else if (colCount <= 2) { lineIdx = 1; } else if (colCount >= 6) { lineIdx = 4; } else { lineIdx = colCount - 1; } const ohlc = []; const line = []; let hasOHLC = false; for (let r = 0; r < rawRows.length; r++) { const cells = rawRows[r]; if (cells.length < 2) continue; let lv = toNum(cells[lineIdx]); if (!isFinite(lv)) { for (let k = cells.length - 1; k >= 0; k--) { const v = toNum(cells[k]); if (isFinite(v)) { lv = v; break; } } } if (!isFinite(lv) || lv <= 0) continue; const lineVal = bulatkanFraksi(lv, false); let o, h, l, c; if (colMap) { o = toNum(cells[colMap.open]); h = toNum(cells[colMap.high]); l = toNum(cells[colMap.low]); c = toNum(cells[colMap.close]); } else { const nums = []; for (let k = 0; k < cells.length; k++) { const v = toNum(cells[k]); if (isFinite(v)) nums.push(v); if (nums.length >= 4) break; } if (nums.length >= 4) { o = nums[0]; h = nums[1]; l = nums[2]; c = nums[3]; } } let bar; if (isFinite(o) && isFinite(h) && isFinite(l) && isFinite(c) && o > 0 && h > 0 && l > 0 && c > 0) { const realHigh = Math.max(o, h, l, c); const realLow = Math.min(o, h, l, c); bar = { open: bulatkanFraksi(o, false), high: bulatkanFraksi(realHigh, false), low: bulatkanFraksi(realLow, true), close: bulatkanFraksi(c, false) }; hasOHLC = true; } else { bar = { open: lineVal, high: lineVal, low: lineVal, close: lineVal }; } ohlc.push(bar); line.push(lineVal); } return { ohlc: ohlc, line: line, colCount: colCount, hasOHLC: hasOHC }; } function setDataSource(src) { dataSource = src; for (let i = 0; i < dsBtns.length; i++) { const b = dsBtns[i]; b.classList.toggle('active', b.getAttribute('data-source') === src); } // Tampilkan baris pemilih mode Siklus Alam hanya saat sumber = synthetic if (syntheticModeRowEl) { syntheticModeRowEl.classList.toggle('hidden', src !== 'synthetic'); } } // ===== Fungsi baru: update tampilan & nilai mode Siklus Alam ===== function applySyntheticMode(mode, restartIfSynthetic) { const valid = ['random', 'subur', 'paceklik']; if (valid.indexOf(mode) === -1) mode = 'random'; syntheticMode = mode; if (syntheticModeSelectEl) { syntheticModeSelectEl.value = mode; syntheticModeSelectEl.classList.remove('mode-random', 'mode-subur', 'mode-paceklik'); syntheticModeSelectEl.classList.add('mode-' + mode); } if (syntheticModeHintEl) { if (mode === 'subur') { syntheticModeHintEl.textContent = 'Harga cenderung murah'; } else if (mode === 'paceklik') { syntheticModeHintEl.textContent = 'Harga cenderung mahal'; } else { syntheticModeHintEl.textContent = 'Seimbang'; } } if (restartIfSynthetic && dataSource === 'synthetic') { startSimulation(); } } dsBtns.forEach(function (btn) { btn.addEventListener('click', function () { const src = btn.getAttribute('data-source'); if (src === 'upload') { // Muat Data Siklus Alam dari file pengguna csvInput.click(); } else { // Kembali ke Siklus Alam bawaan Lembah Fajar if (dataSource !== 'synthetic') { setDataSource('synthetic'); startSimulation(); } } }); }); // ===== Listener baru: perubahan mode Siklus Alam ===== if (syntheticModeSelectEl) { syntheticModeSelectEl.addEventListener('change', function () { applySyntheticMode(syntheticModeSelectEl.value, true); }); } csvInput.addEventListener('change', function (e) { const file = e.target.files && e.target.files[0]; csvInput.value = ''; if (!file) return; const reader = new FileReader(); reader.onload = function (ev) { try { const parsed = parseCSV(ev.target.result); const minBars = WARMUP_BARS + 20; const rowCount = parsed.ohlc.length; if (rowCount < minBars) { alert( 'Data Siklus Alam harus berisi minimal ' + minBars + ' musim yang valid.\n' + 'Ditemukan: ' + rowCount + ' musim.\n\n' + 'Format yang didukung:\n' + '• 2 kolom: nama musim, nilai tukar (mode Aliran Panen)\n' + '• apel_1 (awal), apel_2 (terbanyak), apel_3 (terendah), apel_4 (akhir)\n' + '• open,high,low,close\n' + '• date,open,high,low,close\n' + '• Date,Open,High,Low,Close,Volume (dengan header)' ); return; } if (rowCount > MAX_UPLOAD_BARS) { alert( 'Data Siklus Alam terlalu besar.\n\n' + 'Maksimum: ' + MAX_UPLOAD_BARS + ' musim.\n' + 'File Anda: ' + rowCount + ' musim.\n\n' + 'Silakan gunakan file yang lebih kecil agar permainan tetap lancar.' ); return; } uploadedData = parsed.ohlc; uploadedLineData = parsed.line; uploadedHasOHLC = parsed.hasOHLC; setDataSource('upload'); startSimulation(); } catch (err) { alert('Gagal memuat Data Siklus Alam: ' + err.message); } }; reader.onerror = function () { alert('Gagal membaca Data Siklus Alam.'); }; reader.readAsText(file); }); const dropdownRegistry = []; function normalizeSearch(str) { return String(str).toLowerCase().replace(/[^a-z0-9]/g, ''); } function closeAllDropdowns(except) { for (let i = 0; i < dropdownRegistry.length; i++) { const d = dropdownRegistry[i]; if (d !== except && d.isOpen()) d.close(); } } function createSearchableSelect(selectEl, barEl, infoKey, slotIndex) { const wrap = document.createElement('div'); wrap.className = 'ind-wrap'; selectEl.parentNode.insertBefore(wrap, selectEl); wrap.appendChild(selectEl); selectEl.classList.add('ind-native-hidden'); selectEl.setAttribute('aria-hidden', 'true'); selectEl.setAttribute('tabindex', '-1'); const trigger = document.createElement('button'); trigger.type = 'button'; trigger.className = 'ind-trigger'; trigger.setAttribute('aria-haspopup', 'listbox'); trigger.setAttribute('aria-expanded', 'false'); wrap.appendChild(trigger); if (infoKey) { const infoBtn = document.createElement('button'); infoBtn.type = 'button'; infoBtn.className = 'ind-info-btn'; infoBtn.textContent = 'i'; infoBtn.title = 'Pelajari alat bantu ini'; infoBtn.addEventListener('click', function (e) { e.stopPropagation(); e.preventDefault(); closeAllDropdowns(null); showIndicatorInfo(infoKey); }); wrap.appendChild(infoBtn); } const panel = document.createElement('div'); panel.className = 'ind-panel'; panel.hidden = true; const searchEl = document.createElement('input'); searchEl.type = 'text'; searchEl.className = 'ind-search'; searchEl.placeholder = 'Ketik untuk mencari...'; searchEl.autocomplete = 'off'; searchEl.spellcheck = false; searchEl.setAttribute('aria-label', 'Cari alat bantu'); const listEl = document.createElement('div'); listEl.className = 'ind-list'; listEl.setAttribute('role', 'listbox'); panel.appendChild(searchEl); panel.appendChild(listEl); barEl.appendChild(panel); let visibleOpts = []; let highlightIdx = -1; let isOpen = false; let lastToggleTime = 0; const instance = { trigger: trigger, panel: panel, isOpen: function () { return isOpen; }, close: closePanel, contains: function (node) { if (!node) return false; return wrap.contains(node) || panel.contains(node); } }; dropdownRegistry.push(instance); function applyTriggerColor() { trigger.classList.remove('slot-color-0', 'slot-color-1', 'slot-color-2'); if (typeof slotIndex === 'number' && slotIndex >= 0 && slotIndex <= 2 && selectEl.value) { trigger.classList.add('slot-color-' + slotIndex); } } function updateTriggerLabel() { const opt = selectEl.options[selectEl.selectedIndex]; const label = opt ? opt.textContent : ''; trigger.textContent = label; trigger.title = label; applyTriggerColor(); } function setHighlight(idx) { if (highlightIdx >= 0 && visibleOpts[highlightIdx]) { visibleOpts[highlightIdx].el.classList.remove('highlight'); } highlightIdx = idx; if (idx >= 0 && visibleOpts[idx]) { const el = visibleOpts[idx].el; el.classList.add('highlight'); if (el.scrollIntoView) { el.scrollIntoView({ block: 'nearest' }); } } } function moveHighlight(dir) { if (visibleOpts.length === 0) return; let i = highlightIdx; for (let step = 0; step < visibleOpts.length; step++) { i += dir; if (i < 0) i = visibleOpts.length - 1; if (i >= visibleOpts.length) i = 0; if (!visibleOpts[i].disabled) { setHighlight(i); return; } } } function choose(value) { selectEl.value = value; updateTriggerLabel(); closePanel(); try { trigger.focus({ preventScroll: true }); } catch (err) {} selectEl.dispatchEvent(new Event('change', { bubbles: true })); } function buildList(filter) { const nf = normalizeSearch(filter); listEl.innerHTML = ''; visibleOpts = []; highlightIdx = -1; const opts = selectEl.options; for (let i = 0; i < opts.length; i++) { const opt = opts[i]; const label = opt.textContent; if (nf && normalizeSearch(label).indexOf(nf) === -1) continue; const item = document.createElement('div'); item.className = 'ind-opt'; item.textContent = label; item.setAttribute('role', 'option'); const entry = { value: opt.value, label: label, disabled: !!opt.disabled, el: item }; visibleOpts.push(entry); listEl.appendChild(item); if (opt.disabled) { item.classList.add('disabled'); item.setAttribute('aria-disabled', 'true'); } else { if (opt.value === selectEl.value) item.classList.add('selected'); item.addEventListener('click', function () { choose(entry.value); }); item.addEventListener('mouseenter', function () { setHighlight(visibleOpts.indexOf(entry)); }); } } if (visibleOpts.length === 0) { const empty = document.createElement('div'); empty.className = 'ind-empty'; empty.textContent = 'Tidak ditemukan'; listEl.appendChild(empty); return; } let idx = -1; for (let i = 0; i < visibleOpts.length; i++) { if (!visibleOpts[i].disabled && visibleOpts[i].value === selectEl.value) { idx = i; break; } } if (idx === -1) { for (let i = 0; i < visibleOpts.length; i++) { if (!visibleOpts[i].disabled) { idx = i; break; } } } setHighlight(idx); } function positionPanel() { const PANEL_W = 220; const barRect = barEl.getBoundingClientRect(); const wrapRect = wrap.getBoundingClientRect(); const barW = barEl.clientWidth || barRect.width; let left = wrapRect.left - barRect.left; const maxLeft = Math.max(8, barW - PANEL_W - 8); if (left > maxLeft) left = maxLeft; if (left < 8) left = 8; panel.style.left = left + 'px'; panel.style.width = PANEL_W + 'px'; } function openPanel(initialChar) { closeAllDropdowns(instance); if (infoPanelEl) infoPanelEl.hidden = true; panel.hidden = false; isOpen = true; trigger.setAttribute('aria-expanded', 'true'); searchEl.value = initialChar || ''; buildList(searchEl.value); positionPanel(); try { searchEl.focus({ preventScroll: true }); } catch (err) { try { searchEl.focus(); } catch (err2) {} } if (searchEl.setSelectionRange) { const len = searchEl.value.length; try { searchEl.setSelectionRange(len, len); } catch (err) {} } } function closePanel() { if (!isOpen) return; panel.hidden = true; isOpen = false; trigger.setAttribute('aria-expanded', 'false'); } function togglePanel() { const now = Date.now(); if (now - lastToggleTime < 300) return; lastToggleTime = now; if (isOpen) closePanel(); else openPanel(''); } trigger.addEventListener('click', function (e) { e.stopPropagation(); e.preventDefault(); togglePanel(); }); trigger.addEventListener('touchend', function (e) { e.stopPropagation(); e.preventDefault(); togglePanel(); }, { passive: false }); trigger.addEventListener('keydown', function (e) { if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Enter' || e.key === ' ') { e.preventDefault(); if (!isOpen) openPanel(''); return; } if (e.key === 'Escape') { if (isOpen) { e.preventDefault(); closePanel(); } return; } if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) { e.preventDefault(); openPanel(e.key); } }); searchEl.addEventListener('input', function () { buildList(searchEl.value); }); searchEl.addEventListener('keydown', function (e) { if (e.key === 'ArrowDown') { e.preventDefault(); moveHighlight(1); } else if (e.key === 'ArrowUp') { e.preventDefault(); moveHighlight(-1); } else if (e.key === 'Enter') { e.preventDefault(); if (highlightIdx >= 0 && visibleOpts[highlightIdx] && !visibleOpts[highlightIdx].disabled) { choose(visibleOpts[highlightIdx].value); } } else if (e.key === 'Escape') { e.preventDefault(); closePanel(); try { trigger.focus({ preventScroll: true }); } catch (err) {} } else if (e.key === 'Tab') { closePanel(); } }); selectEl.addEventListener('change', function () { updateTriggerLabel(); }); updateTriggerLabel(); return instance; } function setupSearchableSelects() { createInfoPanel(); const barEl = document.querySelector('.indicator-bar'); if (!barEl) return; const s1 = document.getElementById('ind1'); const s2 = document.getElementById('ind2'); const s3 = document.getElementById('ind3'); const ss = document.getElementById('subchart'); if (s1) createSearchableSelect(s1, barEl, 'ind1', 0); if (s2) createSearchableSelect(s2, barEl, 'ind2', 1); if (s3) createSearchableSelect(s3, barEl, 'ind3', 2); if (ss) createSearchableSelect(ss, barEl, 'sub', -1); } document.addEventListener('click', function (e) { for (let i = 0; i < dropdownRegistry.length; i++) { const d = dropdownRegistry[i]; if (d.isOpen() && !d.contains(e.target)) d.close(); } if (infoPanelEl && !infoPanelEl.hidden) { const barEl = document.querySelector('.indicator-bar'); if (barEl && !barEl.contains(e.target)) { infoPanelEl.hidden = true; } } }); let lastViewportWidth = window.innerWidth; window.addEventListener('resize', function () { const newWidth = window.innerWidth; if (Math.abs(newWidth - lastViewportWidth) > 100) { closeAllDropdowns(null); lastViewportWidth = newWidth; } resizeCanvas(); resizeSubCanvas(); }); window.addEventListener('orientationchange', function () { setTimeout(function () { closeAllDropdowns(null); lastViewportWidth = window.innerWidth; resizeCanvas(); resizeSubCanvas(); }, 200); }); // ===== FUNGSI UTAMA: generateSyntheticData dengan MODE ===== function generateSyntheticData(totalBars, mode) { mode = mode || syntheticMode || 'random'; const data = []; // Rentang harga awal per mode let startMin, startMax; if (mode === 'subur') { // Subur: mulai dari harga rendah startMin = START_PRICE_MIN; startMax = 1500; } else if (mode === 'paceklik') { // Paceklik: mulai dari harga tinggi startMin = 2000; startMax = START_PRICE_MAX; } else { // Random: seluruh rentang startMin = START_PRICE_MIN; startMax = START_PRICE_MAX; } const rawStart = startMin + Math.random() * (startMax - startMin); let currentPrice = bulatkanFraksi(rawStart, false); if (currentPrice < START_PRICE_MIN) currentPrice = START_PRICE_MIN; // Parameter bias per mode // changePercent = (Math.random() + bias) * volatility // - random: rata-rata ≈ +0.0008 (datar, naik sedikit) // - subur: rata-rata ≈ -0.0025 (cenderung turun → tantangan) // - paceklik: rata-rata ≈ +0.0050 (cenderung naik → kepuasan) let bias, volatility, priceCeiling; if (mode === 'subur') { bias = -0.560; volatility = 0.042; priceCeiling = START_PRICE_MAX * 2; } else if (mode === 'paceklik') { bias = -0.380; volatility = 0.042; priceCeiling = START_PRICE_MAX * 8; } else { bias = -0.480; volatility = 0.040; priceCeiling = START_PRICE_MAX * 4; } const priceFloor = 50; for (let i = 0; i < totalBars; i++) { const changePercent = (Math.random() + bias) * volatility; let newPrice = currentPrice * (1 + changePercent); if (newPrice < priceFloor) newPrice = priceFloor; if (newPrice > priceCeiling) newPrice = priceCeiling; const open = bulatkanFraksi(currentPrice, false); const close = bulatkanFraksi(newPrice, false); let high = bulatkanFraksi(Math.max(open, close) * (1 + Math.random() * 0.015), false); let low = bulatkanFraksi(Math.min(open, close) * (1 - Math.random() * 0.015), true); high = Math.max(high, open, close); low = Math.min(low, open, close); if (low <= 0) low = Math.max(1, Math.round(open * 0.9)); data.push({ open, high, low, close }); currentPrice = close; } return data; } function calcSMA(values, period) { const out = new Array(values.length).fill(null); let sum = 0; for (let i = 0; i < values.length; i++) { sum += values[i]; if (i >= period) sum -= values[i - period]; if (i >= period - 1) out[i] = sum / period; } return out; } function calcEMA(values, period) { const out = new Array(values.length).fill(null); if (period < 1) return out; const k = 2 / (period + 1); let prev = null; for (let i = 0; i < values.length; i++) { if (i < period - 1) continue; if (prev === null) { let s = 0; for (let j = i - period + 1; j <= i; j++) s += values[j]; prev = s / period; } else { prev = values[i] * k + prev * (1 - k); } out[i] = prev; } return out; } function calcWMA(values, period) { const out = new Array(values.length).fill(null); const denom = period * (period + 1) / 2; for (let i = period - 1; i < values.length; i++) { let s = 0; for (let j = 0; j < period; j++) { s += values[i - period + 1 + j] * (j + 1); } out[i] = s / denom; } return out; } function calcWilders(values, period) { const out = new Array(values.length).fill(null); let prev = null; for (let i = 0; i < values.length; i++) { if (i < period - 1) continue; if (prev === null) { let s = 0; for (let j = i - period + 1; j <= i; j++) s += values[j]; prev = s / period; } else { prev = (prev * (period - 1) + values[i]) / period; } out[i] = prev; } return out; } function calcBollinger(closes, period, mult) { period = period || 20; mult = mult || 2; const middle = calcSMA(closes, period); const upper = new Array(closes.length).fill(null); const lower = new Array(closes.length).fill(null); for (let i = period - 1; i < closes.length; i++) { let s = 0; for (let j = i - period + 1; j <= i; j++) { const d = closes[j] - middle[i]; s += d * d; } const sd = Math.sqrt(s / period); upper[i] = middle[i] + mult * sd; lower[i] = middle[i] - mult * sd; } return { upper, middle, lower }; } function calcATR(data, period) { const tr = new Array(data.length).fill(0); for (let i = 0; i < data.length; i++) { if (i === 0) { tr[i] = data[i].high - data[i].low; } else { tr[i] = Math.max( data[i].high - data[i].low, Math.abs(data[i].high - data[i - 1].close), Math.abs(data[i].low - data[i - 1].close) ); } } return calcWilders(tr, period); } function calcSqueeze(data) { const closes = data.map(d => d.close); const bb = calcBollinger(closes, 20, 2); const atrArr = calcATR(data, 20); const kcMid = calcEMA(closes, 20); const squeezeOn = new Array(closes.length).fill(null); for (let i = 0; i < closes.length; i++) { if (bb.upper[i] === null || atrArr[i] === null || kcMid[i] === null) continue; const kcUp = kcMid[i] + 1.5 * atrArr[i]; const kcLo = kcMid[i] - 1.5 * atrArr[i]; squeezeOn[i] = (bb.upper[i] < kcUp && bb.lower[i] > kcLo) ? 1 : 0; } return squeezeOn; } function calcRSI(closes, period) { period = period || 14; const out = new Array(closes.length).fill(null); let avgGain = 0, avgLoss = 0; for (let i = 1; i < closes.length; i++) { const ch = closes[i] - closes[i - 1]; const g = Math.max(ch, 0); const l = Math.max(-ch, 0); if (i <= period) { avgGain += g; avgLoss += l; if (i === period) { avgGain /= period; avgLoss /= period; out[i] = avgLoss === 0 ? 100 : 100 - 100 / (1 + avgGain / avgLoss); } } else { avgGain = (avgGain * (period - 1) + g) / period; avgLoss = (avgLoss * (period - 1) + l) / period; out[i] = avgLoss === 0 ? 100 : 100 - 100 / (1 + avgGain / avgLoss); } } return out; } function calcMACD(closes, fast, slow, sigPeriod) { fast = fast || 12; slow = slow || 26; sigPeriod = sigPeriod || 9; const emaFast = calcEMA(closes, fast); const emaSlow = calcEMA(closes, slow); const macdLine = new Array(closes.length).fill(null); for (let i = 0; i < closes.length; i++) { if (emaFast[i] !== null && emaSlow[i] !== null) { macdLine[i] = emaFast[i] - emaSlow[i]; } } const signalLine = new Array(closes.length).fill(null); let prev = null, count = 0, sum = 0; const k = 2 / (sigPeriod + 1); for (let i = 0; i < closes.length; i++) { if (macdLine[i] === null) continue; count++; if (count < sigPeriod) { sum += macdLine[i]; } else if (count === sigPeriod) { sum += macdLine[i]; prev = sum / sigPeriod; signalLine[i] = prev; } else { prev = macdLine[i] * k + prev * (1 - k); signalLine[i] = prev; } } const hist = new Array(closes.length).fill(null); for (let i = 0; i < closes.length; i++) { if (macdLine[i] !== null && signalLine[i] !== null) { hist[i] = macdLine[i] - signalLine[i]; } } return { macd: macdLine, signal: signalLine, hist }; } function getIndicatorSeries(sel, closes, data) { const m = /^(ma|ema|wma|wilders)(\d+)$/.exec(sel); if (m) { const type = m[1]; const period = parseInt(m[2], 10); let values; if (type === 'ma') values = calcSMA(closes, period); else if (type === 'ema') values = calcEMA(closes, period); else if (type === 'wma') values = calcWMA(closes, period); else values = calcWilders(closes, period); return { type: 'line', lines: [{ values: values }] }; } switch (sel) { case 'bollinger': { const bb = calcBollinger(closes, 20, 2); return { type: 'line', lines: [ { values: bb.upper }, { values: bb.middle }, { values: bb.lower } ] }; } case 'squeeze': return { type: 'squeeze', values: calcSqueeze(data) }; default: return null; } } function resizeCanvas() { const parent = canvas.parentElement; if (!parent) return; const rect = parent.getBoundingClientRect(); const w = Math.round(rect.width); const h = Math.round(rect.height); if (w <= 0 || h <= 0) return; dpr = getEffectiveDpr(); const pw = Math.round(w * dpr); const ph = Math.round(h * dpr); if (canvas.width !== pw || canvas.height !== ph) { canvas.width = pw; canvas.height = ph; } viewW = w; viewH = h; drawChart(); } function resizeSubCanvas() { const parent = subCanvas.parentElement; if (!parent) return; const rect = parent.getBoundingClientRect(); const w = Math.round(rect.width); const h = Math.round(rect.height); if (w <= 0 || h <= 0) return; dpr = getEffectiveDpr(); const pw = Math.round(w * dpr); const ph = Math.round(h * dpr); if (subCanvas.width !== pw || subCanvas.height !== ph) { subCanvas.width = pw; subCanvas.height = ph; } subViewW = w; subViewH = h; drawSubChart(); } function drawChart() { if (!viewW || !viewH) return; const w = viewW; const h = viewH; ctx.setTransform(dpr, 0, 0, dpr, 0, 0); ctx.clearRect(0, 0, w, h); const start = Math.max(0, currentIndex - VISIBLE_BARS + 1); const displayData = fullData.slice(start, currentIndex + 1); if (displayData.length === 0) return; const indicators = []; const selVals = [ind1El.value, ind2El.value, ind3El.value]; for (let s = 0; s < 3; s++) { if (!selVals[s]) continue; const series = getIndicatorCached(s, selVals[s]); if (series) indicators.push({ sel: selVals[s], color: SLOT_COLORS[s], series }); } let highest = -Infinity; let lowest = Infinity; for (let i = 0; i < displayData.length; i++) { if (displayData[i].high > highest) highest = displayData[i].high; if (displayData[i].low < lowest) lowest = displayData[i].low; } for (let k = 0; k < indicators.length; k++) { const ind = indicators[k]; if (!ind.series || ind.series.type !== 'line') continue; for (let li = 0; li < ind.series.lines.length; li++) { const values = ind.series.lines[li].values; for (let i = start; i <= currentIndex; i++) { const v = values[i]; if (v === null || v === undefined) continue; if (v > highest) highest = v; if (v < lowest) lowest = v; } } } if (!isFinite(highest) || !isFinite(lowest)) return; const padding = (highest - lowest) * 0.15 || 10; highest += padding; lowest -= padding; const range = (highest - lowest) || 1; const candleWidth = w / VISIBLE_BARS; ctx.lineWidth = 1; ctx.font = '10px Arial'; ctx.textAlign = 'right'; ctx.textBaseline = 'middle'; for (let g = 1; g < 4; g++) { const yGrid = (h / 4) * g; ctx.strokeStyle = '#23282d'; ctx.beginPath(); ctx.moveTo(0, yGrid); ctx.lineTo(w, yGrid); ctx.stroke(); ctx.fillStyle = '#848e9c'; const priceLabel = highest - (range / 4) * g; ctx.fillText(formatUnit(priceLabel), w - 6, yGrid - 9); } const effType = getEffectiveChartType(); if (effType === 'candle') { const bodyW = Math.max(candleWidth * 0.7, 1); const wickW = Math.max(1, Math.min(2, candleWidth * 0.12)); for (let i = 0; i < displayData.length; i++) { const candle = displayData[i]; const x = i * candleWidth + (candleWidth - bodyW) / 2; const xc = x + bodyW / 2; const yOpen = h - ((candle.open - lowest) / range) * h; const yClose = h - ((candle.close - lowest) / range) * h; const yHigh = h - ((candle.high - lowest) / range) * h; const yLow = h - ((candle.low - lowest) / range) * h; const isBullish = candle.close >= candle.open; const color = isBullish ? '#0ecb81' : '#f6465d'; ctx.strokeStyle = color; ctx.fillStyle = color; ctx.lineWidth = wickW; ctx.beginPath(); ctx.moveTo(xc, yHigh); ctx.lineTo(xc, yLow); ctx.stroke(); const bodyTop = Math.min(yOpen, yClose); const bodyH = Math.max(Math.abs(yClose - yOpen), 1.5); ctx.fillRect(x, bodyTop, bodyW, bodyH); } } else { const xAt = function (i) { return i * candleWidth + candleWidth / 2; }; const yAt = function (v) { return h - ((v - lowest) / range) * h; }; let started = false; let firstX = 0, lastX = 0; ctx.beginPath(); for (let i = 0; i < displayData.length; i++) { const v = displayData[i].close; const x = xAt(i); const y = yAt(v); if (!started) { ctx.moveTo(x, y); firstX = x; started = true; } else ctx.lineTo(x, y); lastX = x; } if (started) { ctx.lineTo(lastX, h); ctx.lineTo(firstX, h); ctx.closePath(); const grad = ctx.createLinearGradient(0, 0, 0, h); grad.addColorStop(0, 'rgba(79, 195, 247, 0.22)'); grad.addColorStop(1, 'rgba(79, 195, 247, 0.02)'); ctx.fillStyle = grad; ctx.fill(); ctx.beginPath(); started = false; for (let i = 0; i < displayData.length; i++) { const v = displayData[i].close; const x = xAt(i); const y = yAt(v); if (!started) { ctx.moveTo(x, y); started = true; } else ctx.lineTo(x, y); } ctx.strokeStyle = '#4fc3f7'; ctx.lineWidth = 1.8; ctx.lineJoin = 'round'; ctx.stroke(); const lastBar = displayData[displayData.length - 1]; const lastY = yAt(lastBar.close); ctx.beginPath(); ctx.arc(lastX, lastY, 3, 0, Math.PI * 2); ctx.fillStyle = '#4fc3f7'; ctx.fill(); ctx.strokeStyle = '#0b0e11'; ctx.lineWidth = 1.5; ctx.stroke(); } } for (let k = 0; k < indicators.length; k++) { const ind = indicators[k]; if (!ind.series || ind.series.type !== 'line') continue; const lines = ind.series.lines; for (let li = 0; li < lines.length; li++) { const values = lines[li].values; const isMid = (lines.length === 3 && li === 1); ctx.strokeStyle = ind.color; ctx.lineWidth = isMid ? 1.6 : 1.1; ctx.setLineDash(!isMid && lines.length === 3 ? [4, 3] : []); ctx.beginPath(); let started = false; for (let i = 0; i < displayData.length; i++) { const gi = start + i; const v = values[gi]; if (v === null || v === undefined) { started = false; continue; } const x = i * candleWidth + candleWidth / 2; const y = h - ((v - lowest) / range) * h; if (!started) { ctx.moveTo(x, y); started = true; } else ctx.lineTo(x, y); } ctx.stroke(); ctx.setLineDash([]); } } for (let k = 0; k < indicators.length; k++) { const ind = indicators[k]; if (!ind.series || ind.series.type !== 'squeeze') continue; const values = ind.series.values; const dotY = h - 8; const dotR = Math.max(2, candleWidth * 0.14); ctx.fillStyle = ind.color; for (let i = 0; i < displayData.length; i++) { const gi = start + i; if (values[gi] !== 1) continue; const x = i * candleWidth + candleWidth / 2; ctx.beginPath(); ctx.arc(x, dotY, dotR, 0, Math.PI * 2); ctx.fill(); } } ctx.save(); const wmText = '@readthefuture'; const wmSize = Math.max(20, Math.min(h * 0.08, w * 0.09)); ctx.font = '900 ' + wmSize + 'px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; const wmX = w / 2; const wmY = h / 2; ctx.globalAlpha = 0.10; ctx.fillStyle = '#000000'; ctx.fillText(wmText, wmX + 1.5, wmY + 1.5); ctx.globalAlpha = 0.16; ctx.fillStyle = '#eaecef'; ctx.fillText(wmText, wmX, wmY); ctx.globalAlpha = 0.06; ctx.fillStyle = '#f0b90b'; ctx.fillText(wmText, wmX, wmY - 0.5); ctx.restore(); const lastCandle = displayData[displayData.length - 1]; const yLast = h - ((lastCandle.close - lowest) / range) * h; ctx.save(); ctx.setLineDash([4, 4]); ctx.strokeStyle = 'rgba(240, 185, 11, 0.55)'; ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(0, yLast); ctx.lineTo(w, yLast); ctx.stroke(); ctx.restore(); } function drawSubChart() { if (!subViewW || !subViewH) return; const w = subViewW; const h = subViewH; sctx.setTransform(dpr, 0, 0, dpr, 0, 0); sctx.clearRect(0, 0, w, h); sctx.fillStyle = '#0b0e11'; sctx.fillRect(0, 0, w, h); const type = subSelectEl.value; const start = Math.max(0, currentIndex - VISIBLE_BARS + 1); const count = currentIndex - start + 1; if (count <= 0) return; const candleWidth = w / VISIBLE_BARS; sctx.strokeStyle = '#23282d'; sctx.lineWidth = 1; for (let g = 1; g < 3; g++) { const yGrid = (h / 3) * g; sctx.beginPath(); sctx.moveTo(0, yGrid); sctx.lineTo(w, yGrid); sctx.stroke(); } if (type === 'rsi') { const rsiVals = getSubIndicatorCached('rsi'); const toY = (v) => h - (v / 100) * h; sctx.strokeStyle = 'rgba(132,142,156,0.35)'; sctx.setLineDash([4, 4]); [30, 70].forEach(lvl => { const y = toY(lvl); sctx.beginPath(); sctx.moveTo(0, y); sctx.lineTo(w, y); sctx.stroke(); }); sctx.setLineDash([]); sctx.fillStyle = '#848e9c'; sctx.font = '9px Arial'; sctx.textAlign = 'left'; sctx.textBaseline = 'middle'; sctx.fillText('70', 4, toY(70)); sctx.fillText('30', 4, toY(30)); sctx.textBaseline = 'top'; sctx.fillText('Meteran Energi', 4, 4); sctx.strokeStyle = '#f0b90b'; sctx.lineWidth = 1.5; sctx.beginPath(); let started = false; for (let i = 0; i < count; i++) { const gi = start + i; const v = rsiVals[gi]; if (v === null || v === undefined) { started = false; continue; } const x = i * candleWidth + candleWidth / 2; const y = toY(v); if (!started) { sctx.moveTo(x, y); started = true; } else sctx.lineTo(x, y); } sctx.stroke(); } else if (type === 'macd') { const m = getSubIndicatorCached('macd'); let hi = 0, lo = 0; for (let i = 0; i < count; i++) { const gi = start + i; const vals = [m.macd[gi], m.signal[gi], m.hist[gi]]; for (let k = 0; k < vals.length; k++) { const v = vals[k]; if (v === null || v === undefined) continue; if (v > hi) hi = v; if (v < lo) lo = v; } } if (hi === lo) { hi = 1; lo = -1; } const pad = (hi - lo) * 0.1; hi += pad; lo -= pad; const rng = (hi - lo) || 1; const toY = (v) => h - ((v - lo) / rng) * h; sctx.strokeStyle = 'rgba(132,142,156,0.4)'; sctx.setLineDash([4, 4]); sctx.beginPath(); sctx.moveTo(0, toY(0)); sctx.lineTo(w, toY(0)); sctx.stroke(); sctx.setLineDash([]); sctx.fillStyle = '#848e9c'; sctx.font = '9px Arial'; sctx.textAlign = 'left'; sctx.textBaseline = 'top'; sctx.fillText('Detektor Arah', 4, 4); for (let i = 0; i < count; i++) { const gi = start + i; const v = m.hist[gi]; if (v === null || v === undefined) continue; const x = i * candleWidth + candleWidth * 0.15; const bw = Math.max(candleWidth * 0.7, 1); const y0 = toY(0); const yv = toY(v); sctx.fillStyle = v >= 0 ? 'rgba(14,203,129,0.55)' : 'rgba(246,70,93,0.55)'; sctx.fillRect(x, Math.min(y0, yv), bw, Math.max(Math.abs(yv - y0), 1)); } sctx.strokeStyle = '#4fc3f7'; sctx.lineWidth = 1.5; sctx.beginPath(); let started = false; for (let i = 0; i < count; i++) { const gi = start + i; const v = m.macd[gi]; if (v === null || v === undefined) { started = false; continue; } const x = i * candleWidth + candleWidth / 2; const y = toY(v); if (!started) { sctx.moveTo(x, y); started = true; } else sctx.lineTo(x, y); } sctx.stroke(); sctx.strokeStyle = '#e91e63'; sctx.lineWidth = 1.5; sctx.beginPath(); started = false; for (let i = 0; i < count; i++) { const gi = start + i; const v = m.signal[gi]; if (v === null || v === undefined) { started = false; continue; } const x = i * candleWidth + candleWidth / 2; const y = toY(v); if (!started) { sctx.moveTo(x, y); started = true; } else sctx.lineTo(x, y); } sctx.stroke(); } } function getAppleExchangeValue() { // Nilai apel saat ini = (apel / 100) × harga pasar const bar = fullData[currentIndex]; if (!bar) return 0; return (positionVolume / APPLE_STEP) * bar.close; } function updateUI() { const bar = fullData[currentIndex]; const currentPrice = bar ? bar.close : 0; const appleValue = getAppleExchangeValue(); const totalEquity = cash + appleValue; const selisih = totalEquity - INITIAL_CASH; equityValEl.textContent = formatUnit(totalEquity); cashValEl.textContent = formatUnit(cash); assetValEl.textContent = formatUnit(appleValue); tickerPriceEl.textContent = formatUnit(currentPrice); const progress = Math.min(Math.max(currentIndex - WARMUP_BARS, 0), TOTAL_BARS); barProgressEl.textContent = progress + '/' + TOTAL_BARS; const sign = selisih >= 0 ? '+' : '−'; pnlPctEl.textContent = 'Perubahan: ' + sign + formatUnit(Math.abs(selisih)); pnlPctEl.style.backgroundColor = 'rgba(79, 195, 247, 0.12)'; pnlPctEl.style.color = '#4fc3f7'; posInfoEl.textContent = '🍎 Apel terkumpul: ' + formatUnit(positionVolume) + ' (Nilai tukar: ' + formatUnit(currentPrice) + ' energi / 100 apel)'; } // ============ PETIK APEL (sesuai cerita) ============ function doBuy() { const bar = fullData[currentIndex]; if (!bar || finished || isPaused) return; // Hukum Pertama: 1 apel = 1 energi // Hukum Kedua: kelipatan 100 // Hukum Ketiga: minimal 100 apel // Hukum Keempat: maksimal 10.000 apel per petik // Hitung volume maksimum berdasarkan energi tersedia (termasuk fee petik) let maxByEnergy = Math.floor(cash / (COST_PER_APPLE * (1 + feeBeli))); // Bulatkan ke bawah ke kelipatan 100 maxByEnergy = Math.floor(maxByEnergy / APPLE_STEP) * APPLE_STEP; // Terapkan batas maksimum 10.000 apel per petik let volume = Math.min(maxByEnergy, MAX_APPLES_PICK); // Terapkan minimal 100 apel per petik if (volume < MIN_APPLES) { posInfoEl.textContent = '⚠️ Energi tidak cukup untuk memetik minimal ' + MIN_APPLES + ' apel!'; return; } const totalCost = volume * COST_PER_APPLE; const totalFee = totalCost * feeBeli; cash -= (totalCost + totalFee); const totalCostOld = positionVolume * avgBuyPrice; const totalCostNew = volume * COST_PER_APPLE; positionVolume += volume; avgBuyPrice = (totalCostOld + totalCostNew) / positionVolume; updateUI(); } // ============ TUKAR APEL (sesuai cerita) ============ function doSell() { const bar = fullData[currentIndex]; if (!bar || finished || isPaused) return; // Hukum Keenam: penukaran dalam kelipatan 100 if (positionVolume < APPLE_STEP) { posInfoEl.textContent = '⚠️ Apel kurang dari ' + APPLE_STEP + ', tidak bisa ditukar!'; return; } // Bulatkan ke bawah ke kelipatan 100 const volume = Math.floor(positionVolume / APPLE_STEP) * APPLE_STEP; if (volume < APPLE_STEP) return; // Nilai tukar: harga pasar menunjukkan energi per 100 apel // Jadi revenue = (volume / 100) × harga pasar const marketPrice = bar.close; const revenue = (volume / APPLE_STEP) * marketPrice; const fee = revenue * feeJual; cash += (revenue - fee); positionVolume -= volume; if (positionVolume < 0) positionVolume = 0; if (positionVolume === 0) avgBuyPrice = 0; updateUI(); } function step() { if (isPaused || finished) return; currentIndex++; if (currentIndex >= END_INDEX) { currentIndex = END_INDEX; finished = true; clearInterval(timer); timer = null; updateUI(); drawChart(); drawSubChart(); btnBuy.disabled = true; btnSell.disabled = true; const finalEquity = cash + getAppleExchangeValue(); posInfoEl.textContent = '🍎 Musim ke-250 selesai! Skor akhir: ' + formatUnit(finalEquity) + ' — Tekan Ulang untuk main lagi.'; return; } updateUI(); drawChart(); drawSubChart(); } function updateSpeed() { let v = parseFloat(speedSelectEl.value); if (!isFinite(v) || v <= 0) v = 1; speedMultiplier = v; if (timer) { clearInterval(timer); timer = setInterval(step, INTERVAL_TIME / speedMultiplier); } } function canCandleChart() { if (dataSource === 'synthetic') return true; return uploadedHasOHLC; } function getEffectiveChartType() { if (chartType === 'candle' && canCandleChart()) return 'candle'; return 'line'; } function flattenToLine(bars) { return bars.map(function (d) { return { open: d.close, high: d.close, low: d.close, close: d.close }; }); } function buildFullData() { const useCandle = (getEffectiveChartType() === 'candle'); if (dataSource === 'upload' && uploadedData && uploadedData.length > 0) { if (useCandle) { fullData = uploadedData.slice(); } else { const src = (uploadedLineData && uploadedLineData.length === uploadedData.length) ? uploadedLineData : uploadedData.map(function (d) { return d.close; }); fullData = src.map(function (v) { return { open: v, high: v, low: v, close: v }; }); } END_INDEX = fullData.length - 1; TOTAL_BARS = Math.max(1, END_INDEX - WARMUP_BARS); } else { if (!syntheticOHLC || syntheticOHLC.length < WARMUP_BARS + DEFAULT_TOTAL_BARS + 10) { // Gunakan mode saat ini syntheticOHLC = generateSyntheticData(WARMUP_BARS + DEFAULT_TOTAL_BARS + 10, syntheticMode); } TOTAL_BARS = DEFAULT_TOTAL_BARS; END_INDEX = WARMUP_BARS + TOTAL_BARS; if (useCandle) { fullData = syntheticOHLC.slice(); } else { fullData = flattenToLine(syntheticOHLC); } } } function startSimulation() { clearInterval(timer); timer = null; if (dataSource === 'upload' && uploadedData && uploadedData.length > 0) { // Pakai data hasil muat (sudah tersimpan) } else { dataSource = 'synthetic'; setDataSource('synthetic'); // Gunakan mode Siklus Alam yang aktif syntheticOHLC = generateSyntheticData(WARMUP_BARS + DEFAULT_TOTAL_BARS + 10, syntheticMode); } buildFullData(); invalidateIndicatorCache(); cash = INITIAL_CASH; positionVolume = 0; avgBuyPrice = 0; currentIndex = WARMUP_BARS; isPaused = false; finished = false; btnPause.innerHTML = ICON_PAUSE + '<span>Jeda</span>'; btnBuy.disabled = false; btnSell.disabled = false; resizeCanvas(); resizeSubCanvas(); updateUI(); drawChart(); drawSubChart(); timer = setInterval(step, INTERVAL_TIME / speedMultiplier); } btnPause.addEventListener('click', function () { if (finished) return; isPaused = !isPaused; btnPause.innerHTML = isPaused ? ICON_PLAY + '<span>Lanjut</span>' : ICON_PAUSE + '<span>Jeda</span>'; }); btnRestart.addEventListener('click', startSimulation); btnBuy.addEventListener('click', doBuy); btnSell.addEventListener('click', doSell); ind1El.addEventListener('change', drawChart); ind2El.addEventListener('change', drawChart); ind3El.addEventListener('change', drawChart); subSelectEl.addEventListener('change', drawSubChart); speedSelectEl.addEventListener('change', updateSpeed); chartTypeSelectEl.addEventListener('change', function () { chartType = (chartTypeSelectEl.value === 'candle') ? 'candle' : 'line'; buildFullData(); invalidateIndicatorCache(); if (currentIndex > END_INDEX) currentIndex = END_INDEX; updateUI(); drawChart(); drawSubChart(); }); function updateFees() { let buyVal = parseFloat(feeBuyInput.value); let sellVal = parseFloat(feeSellInput.value); if (isNaN(buyVal) || buyVal < 0) buyVal = 0; if (isNaN(sellVal) || sellVal < 0) sellVal = 0; if (buyVal > 10) buyVal = 10; if (sellVal > 10) sellVal = 10; feeBeli = buyVal / 100; feeJual = sellVal / 100; } feeBuyInput.addEventListener('input', updateFees); feeSellInput.addEventListener('input', updateFees); if (typeof ResizeObserver !== 'undefined') { new ResizeObserver(resizeCanvas).observe(canvas.parentElement); new ResizeObserver(resizeSubCanvas).observe(subCanvas.parentElement); } function init() { setupSearchableSelects(); updateFees(); let v0 = parseFloat(speedSelectEl.value); if (!isFinite(v0) || v0 <= 0) v0 = 1; speedMultiplier = v0; if (chartTypeSelectEl) { chartType = (chartTypeSelectEl.value === 'candle') ? 'candle' : 'line'; } // Inisialisasi mode Siklus Alam (default: random) applySyntheticMode('random', false); setDataSource('synthetic'); startSimulation(); requestAnimationFrame(function () { resizeCanvas(); resizeSubCanvas(); }); setTimeout(function () { resizeCanvas(); resizeSubCanvas(); }, 150); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })(); </script> <script> (function () { 'use strict'; const upgradeBtn = document.getElementById('upgrade-btn'); if (!upgradeBtn) return; upgradeBtn.addEventListener('click', function (e) { e.preventDefault(); const lanjut = window.confirm( 'Buka Panduan Bermain?\n\n' + 'Panduan ini berisi materi edukasi simulasi: penjelasan konsep indikator, ' + 'rumus matematika lengkap, dan panduan replikasi di Excel/Google Sheets ' + 'untuk game JELAJAH: Kebun Apel Lembah Fajar.\n\n' + 'Materi ini BUKAN rekomendasi investasi dan tidak bekerja sama dengan PUJK manapun.\n\n' + 'Lanjutkan? Ya/Tidak' ); if (lanjut) { window.open( 'https://lynk.id/readthefuture', '_blank', 'noopener,noreferrer' ); } }); })(); </script> <script> (function () { 'use strict'; let isMahirMode = false; function applyMode() { const indicatorBar = document.querySelector('.indicator-bar'); const feeRow = document.querySelector('.fee-row'); const modeBtn = document.getElementById('mode-basic-link'); if (isMahirMode) { if (indicatorBar) indicatorBar.style.display = ''; if (feeRow) feeRow.style.display = ''; if (modeBtn) { modeBtn.textContent = 'MODE:MAHIR'; modeBtn.title = 'Klik untuk kembali ke MODE:DASAR'; } } else { if (indicatorBar) indicatorBar.style.display = 'none'; if (feeRow) feeRow.style.display = 'none'; if (modeBtn) { modeBtn.textContent = 'MODE:DASAR'; modeBtn.title = 'Klik untuk beralih ke MODE:MAHIR (alat bantu lanjutan)'; } } setTimeout(function () { window.dispatchEvent(new Event('resize')); }, 50); } function initModeToggle() { const modeBtn = document.getElementById('mode-basic-link'); if (!modeBtn) return; modeBtn.addEventListener('click', function () { isMahirMode = !isMahirMode; applyMode(); }); applyMode(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initModeToggle); } else { initModeToggle(); } })(); </script> <script> (function () { 'use strict'; const SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1000; const STORAGE_KEY = "ds_secure_epoch_token"; const UPLOAD_KEY = "ds_secure_upload_count"; const STORAGE_COOKIE = "ds_stk"; const UPLOAD_COOKIE = "ds_upk"; const MAX_UPLOADS = 3; const uploadBtn = document.getElementById('upload-btn'); const timerDisplay = document.getElementById('countdown-timer'); const csvInputEl = document.getElementById('csv-input'); if (!uploadBtn || !timerDisplay) return; let countdownInterval = null; let trialLocked = false; let uploadCount = 0; const XOR_KEY = "s4h4m_h4r14n_2024_pr0t3ct10n_k3y_v14"; function xorCipher(text) { let out = ''; const keyLen = XOR_KEY.length; for (let i = 0; i < text.length; i++) { out += String.fromCharCode(text.charCodeAt(i) ^ XOR_KEY.charCodeAt(i % keyLen)); } return out; } function encrypt(text) { try { return 'x2:' + btoa(xorCipher(String(text))); } catch (e) { return null; } } function decrypt(cipher) { if (!cipher) return null; try { if (String(cipher).indexOf('x2:') === 0) { return xorCipher(atob(String(cipher).substring(3))); } else { return atob(String(cipher)).split('').reverse().join(''); } } catch (e) { return null; } } function setCookieSecure(name, value, days) { try { const expires = new Date(Date.now() + days * 86400000).toUTCString(); document.cookie = name + '=' + encodeURIComponent(value) + '; expires=' + expires + '; path=/; SameSite=Lax'; } catch (e) {} } function getCookieSecure(name) { try { const target = name + '='; const parts = document.cookie.split(';'); for (let i = 0; i < parts.length; i++) { const c = parts[i].trim(); if (c.indexOf(target) === 0) { return decodeURIComponent(c.substring(target.length)); } } } catch (e) {} return null; } function fetchWithTimeout(url, options, timeoutMs) { return new Promise(function (resolve, reject) { const ctrl = new AbortController(); const tid = setTimeout(function () { ctrl.abort(); }, timeoutMs); fetch(url, Object.assign({ signal: ctrl.signal, cache: 'no-store' }, options || {})) .then(function (res) { clearTimeout(tid); resolve(res); }) .catch(function (err) { clearTimeout(tid); reject(err); }); }); } async function getSecureTime() { try { const res = await fetchWithTimeout(window.location.href, { method: 'HEAD' }, 3000); const h = res.headers.get('Date'); if (h) { const t = new Date(h).getTime(); if (isFinite(t) && t > 0) return t; } } catch (e) {} try { const res = await fetchWithTimeout('https://cloudflare.com/cdn-cgi/trace', { method: 'GET' }, 3000); const h = res.headers.get('Date'); if (h) { const t = new Date(h).getTime(); if (isFinite(t) && t > 0) return t; } } catch (e) {} try { const res = await fetchWithTimeout('https://cloudflare.com/', { method: 'HEAD' }, 3000); const h = res.headers.get('Date'); if (h) { const t = new Date(h).getTime(); if (isFinite(t) && t > 0) return t; } } catch (e) {} try { const res = await fetchWithTimeout('https://worldtimeapi.org/api/timezone/Etc/UTC', { method: 'GET' }, 3000); const data = await res.json(); const t = new Date(data.utc_datetime).getTime(); if (isFinite(t) && t > 0) return t; } catch (e) {} return Date.now(); } function openDB() { return new Promise(function (resolve, reject) { let request; try { request = indexedDB.open("SecureRegistry", 1); } catch (e) { reject(e); return; } request.onupgradeneeded = function (e) { const db = e.target.result; if (!db.objectStoreNames.contains("keys")) { db.createObjectStore("keys"); } }; request.onsuccess = function (e) { resolve(e.target.result); }; request.onerror = function () { reject(request.error); }; }); } function saveToIndexedDB(key, value) { return openDB().then(function (db) { return new Promise(function (resolve) { try { const tx = db.transaction("keys", "readwrite"); tx.objectStore("keys").put(value, key); tx.oncomplete = function () { resolve(true); }; tx.onerror = function () { resolve(false); }; tx.onabort = function () { resolve(false); }; } catch (e) { resolve(false); } }); }).catch(function () { return false; }); } function getFromIndexedDB(key) { return openDB().then(function (db) { return new Promise(function (resolve) { try { const tx = db.transaction("keys", "readonly"); const req = tx.objectStore("keys").get(key); req.onsuccess = function () { resolve(req.result || null); }; req.onerror = function () { resolve(null); }; } catch (e) { resolve(null); } }); }).catch(function () { return null; }); } function pad2(n) { return n < 10 ? '0' + n : '' + n; } function renderCountdown(timeLeft) { const totalSec = Math.max(0, Math.floor(timeLeft / 1000)); const hari = Math.floor(totalSec / 86400); const jam = Math.floor((totalSec % 86400) / 3600); const menit = Math.floor((totalSec % 3600) / 60); const detik = totalSec % 60; timerDisplay.textContent = 'Sisa ' + hari + 'h ' + pad2(jam) + 'j ' + pad2(menit) + 'm ' + pad2(detik) + 'd'; } function renderUploadBtn() { if (trialLocked) return; const remaining = Math.max(0, MAX_UPLOADS - uploadCount); uploadBtn.textContent = 'Muat ' + remaining + 'x'; uploadBtn.title = 'Muat Data Siklus Alam — unggah data musimmu sendiri (sisa ' + remaining + 'x)'; uploadBtn.disabled = false; } function lockUpload() { if (trialLocked) return; trialLocked = true; if (countdownInterval) { clearInterval(countdownInterval); countdownInterval = null; } uploadBtn.disabled = true; uploadBtn.textContent = 'Masa Trial Habis'; uploadBtn.title = 'Masa trial telah berakhir'; timerDisplay.textContent = 'Expired'; timerDisplay.classList.add('expired'); } async function startCountdown(startTime) { if (countdownInterval) { clearInterval(countdownInterval); countdownInterval = null; } const endTime = startTime + SEVEN_DAYS_MS; let now = await getSecureTime(); function tick() { if (trialLocked) return; const timeLeft = endTime - now; if (timeLeft <= 0) { lockUpload(); return; } timerDisplay.classList.remove('expired'); renderCountdown(timeLeft); now += 1000; } tick(); if (!trialLocked && (endTime - now > 0)) { countdownInterval = setInterval(tick, 1000); } } function saveStartTimeAllLayers(timestamp) { const encrypted = encrypt(timestamp); try { localStorage.setItem(STORAGE_KEY, encrypted); } catch (e) {} saveToIndexedDB(STORAGE_KEY, encrypted); setCookieSecure(STORAGE_COOKIE, encrypted, 7); } async function loadStartTimeAllLayers() { const candidates = []; try { const v = localStorage.getItem(STORAGE_KEY); if (v) { const dec = decrypt(v); const n = parseInt(dec, 10); if (isFinite(n) && n > 0) candidates.push(n); } } catch (e) {} try { const v = await getFromIndexedDB(STORAGE_KEY); if (v) { const dec = decrypt(v); const n = parseInt(dec, 10); if (isFinite(n) && n > 0) candidates.push(n); } } catch (e) {} try { const v = getCookieSecure(STORAGE_COOKIE); if (v) { const dec = decrypt(v); const n = parseInt(dec, 10); if (isFinite(n) && n > 0) candidates.push(n); } } catch (e) {} if (candidates.length === 0) return null; let oldest = candidates[0]; for (let i = 1; i < candidates.length; i++) { if (candidates[i] < oldest) oldest = candidates[i]; } return oldest; } function saveUploadCountAllLayers(count) { const encrypted = encrypt(count); try { localStorage.setItem(UPLOAD_KEY, encrypted); } catch (e) {} saveToIndexedDB(UPLOAD_KEY, encrypted); setCookieSecure(UPLOAD_COOKIE, encrypted, 7); } async function loadUploadCountAllLayers() { const candidates = []; try { const v = localStorage.getItem(UPLOAD_KEY); if (v !== null && v !== undefined) { const dec = decrypt(v); const n = parseInt(dec, 10); if (isFinite(n) && n >= 0) candidates.push(n); } } catch (e) {} try { const v = await getFromIndexedDB(UPLOAD_KEY); if (v !== null && v !== undefined) { const dec = decrypt(v); const n = parseInt(dec, 10); if (isFinite(n) && n >= 0) candidates.push(n); } } catch (e) {} try { const v = getCookieSecure(UPLOAD_COOKIE); if (v !== null && v !== undefined) { const dec = decrypt(v); const n = parseInt(dec, 10); if (isFinite(n) && n >= 0) candidates.push(n); } } catch (e) {} if (candidates.length === 0) return 0; let highest = candidates[0]; for (let i = 1; i < candidates.length; i++) { if (candidates[i] > highest) highest = candidates[i]; } return highest; } async function initFeature() { uploadCount = await loadUploadCountAllLayers(); const existingStartTime = await loadStartTimeAllLayers(); if (existingStartTime) { saveStartTimeAllLayers(existingStartTime); saveUploadCountAllLayers(uploadCount); startCountdown(existingStartTime); } else { timerDisplay.textContent = 'Memulai trial...'; const currentStartTime = await getSecureTime(); saveStartTimeAllLayers(currentStartTime); saveUploadCountAllLayers(uploadCount); startCountdown(currentStartTime); } if (uploadCount >= MAX_UPLOADS) { lockUpload(); } else { renderUploadBtn(); } } uploadBtn.addEventListener('click', function (e) { if (trialLocked) { e.preventDefault(); e.stopImmediatePropagation(); return false; } }, true); document.addEventListener('change', function (e) { if (!csvInputEl || e.target !== csvInputEl) return; const file = e.target.files && e.target.files[0]; if (!file) return; if (trialLocked) return; uploadCount++; saveUploadCountAllLayers(uploadCount); if (uploadCount >= MAX_UPLOADS) { lockUpload(); } else { renderUploadBtn(); } }, true); initFeature(); })(); </script> </body> </html>
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JELAJAH — Kebun Apel Lembah Fajar</title>
<style>
:root {
--bg-main: #0b0e11;
--bg-card: #181a20;
--text-main: #eaecef;
--text-muted: #848e9c;
--up-color: #0ecb81;
--down-color: #f6465d;
--accent: #f0b90b;
--edu-color: #4fc3f7;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
-webkit-tap-highlight-color: transparent;
}
html, body { height: 100%; }
body {
background-color: #000;
color: var(--text-main);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
min-height: 100dvh;
overflow: hidden;
}
.phone-container {
width: 100%;
max-width: 412px;
height: 100vh;
height: 100dvh;
max-height: 892px;
background-color: var(--bg-main);
display: flex;
flex-direction: column;
overflow: hidden;
position: relative;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
transform: scale(var(--display-scale, 1));
transform-origin: center center;
transition: transform 0.2s ease-out;
}
.edu-banner {
background: linear-gradient(90deg, rgba(79, 195, 247, 0.15), rgba(240, 185, 11, 0.12));
border-bottom: 1px solid #2b3139;
padding: 5px 10px;
font-size: 10.5px;
color: #c9cdd4;
text-align: center;
line-height: 1.35;
flex-shrink: 0;
}
.edu-banner strong { color: var(--edu-color); }
.header {
background-color: var(--bg-card);
padding: 12px;
border-bottom: 1px solid #2b3139;
}
.header-title-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 4px;
gap: 6px;
}
.header-title {
font-size: 14px;
color: var(--text-muted);
}
.upgrade-btn {
font-size: 12px;
font-weight: 700;
color: #000;
background-color: var(--edu-color);
border: 1px solid var(--edu-color);
text-decoration: none;
padding: 2px 8px;
border-radius: 4px;
cursor: pointer;
font-family: inherit;
letter-spacing: 0.3px;