Created At: 2026-06-14T15:00:52Z
Completed At: 2026-06-14T15:00:52Z
File Path: `file:///c:/Users/HP/Downloads/climate-system/climate-system/index.php`
Total Lines: 4628
Total Bytes: 195635
Showing lines 3900 to 3955
The following code has been modified to include a line number before every line, in the format: <line_number>: <original_line>. Please note that any changes targeting the original code should remove the line number, colon, and leading space.
3900:       const period = document.getElementById('futurePeriodMap').value;
3901:       const statistic = document.getElementById('futureStatisticTS').value;
3902:       const startYear = document.getElementById('futureStartYearTS').value;
3903:       const endYear = document.getElementById('futureEndYearTS').value;
3904: 
3905:       if (!lokasi || !variable) {
3906:         alert('Silakan pilih lokasi dan variabel terlebih dahulu.');
3907:         return;
3908:       }
3909: 
3910:       let loadedCSV = false;
3911: 
3912:       try {
3913:         // 1. Fetch metadata and check if there is custom CSV data stored in the database
3914:         const res = await fetch(`?action=get_future&location=${encodeURIComponent(lokasi)}&variable=${encodeURIComponent(variable)}&period=${encodeURIComponent(period)}`);
3915:         const result = await res.json();
3916: 
3917:         if (result.success && result.data && result.data.csvData && result.data.csvData !== '') {
3918:           // If custom CSV data exists in the database, render it using renderFutureClimateChart
3919:           renderFutureClimateChart(variable, result.data, period);
3920:           loadedCSV = true;
3921:         } else {
3922:           // If no custom CSV data in DB, try to load split CSV files from disk
3923:           try {
3924:             const csvRes = await fetch(`?action=get_future_csv&location=${encodeURIComponent(lokasi)}&variable=${encodeURIComponent(variable)}&statistic=${encodeURIComponent(statistic)}&start_year=${encodeURIComponent(startYear)}&end_year=${encodeURIComponent(endYear)}`);
3925:             const csvResult = await csvRes.json();
3926:             if (csvResult.success && csvResult.mean && csvResult.mean.length > 0) {
3927:               renderFutureCSVChart(csvResult, variable, statistic, startYear, endYear, period);
3928:               loadedCSV = true;
3929:             }
3930:           } catch (err) {
3931:             console.error("Kesalahan AJAX CSV:", err);
3932:           }
3933: 
3934:           // Fallback to default simulation if split CSV files also failed to load
3935:           if (!loadedCSV) {
3936:             if (result.success && result.data) {
3937:               renderFutureClimateChart(variable, result.data, period);
3938:             } else {
3939:               renderFutureClimateChart(variable, null, period);
3940:             }
3941:           }
3942:         }
3943:       } catch (err) {
3944:         console.error(err);
3945:         // Fallback to default simulation
3946:         renderFutureClimateChart(variable, null, period);
3947:       }
3948: 
3949:       // Future Time Series metadata
3950:       document.getElementById('futureCategoryTitleTimeSeries').innerText = "Future Time Series Graph";
3951:       document.getElementById('futureVariableTextTS').innerText = "Variabel: " + variable;
3952:       document.getElementById('futurePeriodTextTS').innerText = "Rentang Tahun: " + startYear + " - " + endYear;
3953:     }
3954: 
3955:     async function loadFutureMapSettingsData() {
The above content does NOT show the entire file contents. If you need to view any lines of the file which were not shown to complete your task, call this tool again to view those lines.
