File size: 18,802 Bytes
2e6530e
 
 
 
 
 
8b97ea7
2e6530e
 
8b97ea7
2e6530e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b97ea7
2e6530e
 
7509a53
2e6530e
 
 
 
 
 
8b97ea7
ec80dc4
2e6530e
 
8b97ea7
2e6530e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b97ea7
2e6530e
 
8b97ea7
2e6530e
 
 
8b97ea7
2e6530e
 
 
 
 
 
8b97ea7
 
2e6530e
 
 
 
 
 
 
 
 
 
8b97ea7
2e6530e
8b97ea7
ec80dc4
 
 
2e6530e
 
 
 
 
 
 
 
 
7509a53
8b97ea7
 
2e6530e
7509a53
 
 
 
 
 
2e6530e
 
8b97ea7
 
2e6530e
7509a53
2e6530e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b97ea7
 
 
 
 
 
 
2e6530e
 
 
 
 
 
 
 
 
 
 
 
8b97ea7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2e6530e
8b97ea7
 
 
2e6530e
8b97ea7
2e6530e
 
8b97ea7
2e6530e
 
 
8b97ea7
 
 
2e6530e
 
 
 
8b97ea7
 
ec80dc4
 
8b97ea7
 
2e6530e
 
8b97ea7
 
 
 
 
 
 
 
 
 
 
 
 
2e6530e
 
 
7509a53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b97ea7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ec80dc4
2e6530e
 
8b97ea7
2e6530e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b97ea7
 
 
7509a53
8b97ea7
2e6530e
ec80dc4
2e6530e
 
 
 
 
8b97ea7
 
2e6530e
 
8b97ea7
2e6530e
 
 
 
 
 
ec80dc4
8b97ea7
 
2e6530e
 
ec80dc4
2e6530e
 
ec80dc4
 
 
 
2e6530e
8b97ea7
2e6530e
ec80dc4
 
 
 
 
 
 
 
 
2e6530e
8b97ea7
2e6530e
ec80dc4
8b97ea7
 
 
ec80dc4
8b97ea7
 
ec80dc4
 
 
2e6530e
 
8b97ea7
ec80dc4
2e6530e
 
8b97ea7
 
 
7509a53
8b97ea7
2e6530e
 
 
 
 
8b97ea7
 
7509a53
8b97ea7
 
2e6530e
8b97ea7
ec80dc4
 
2e6530e
 
8b97ea7
 
2e6530e
 
 
ec80dc4
 
 
2e6530e
8b97ea7
2e6530e
 
 
 
 
 
 
 
 
8b97ea7
2e6530e
8b97ea7
 
2e6530e
 
 
 
 
8b97ea7
2e6530e
 
 
 
ec80dc4
 
2e6530e
 
 
 
ec80dc4
 
 
 
2e6530e
ec80dc4
2e6530e
 
 
 
 
 
 
 
8b97ea7
7509a53
8b97ea7
2e6530e
 
 
 
 
8b97ea7
 
 
7509a53
8b97ea7
2e6530e
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
<!DOCTYPE html>
<html lang="id">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Aplikasi Catatan Pembelajaran</title>
  <!-- jsPDF + autoTable -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.8.2/jspdf.plugin.autotable.min.js"></script>
  <!-- SheetJS -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
  <style>
    body { font-family: 'Segoe UI', Arial, sans-serif; margin: 0; background: #f0f2f5; }
    h1 { text-align: center; color: #1a1a1a; margin: 20px 0; }
    .container { max-width: 1200px; margin: 0 auto; padding: 20px; }
    .card { background: white; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); overflow: hidden; }
    .tabs { display: flex; background: #f8f9fa; border-bottom: 1px solid #dee2e6; }
    .tablink { flex: 1; padding: 16px; text-align: center; font-size: 18px; font-weight: 600; cursor: pointer; border: none; background: transparent; }
    .tablink:hover { background: #e9ecef; }
    .tablink.active { background: #007bff; color: white; }
    .tabcontent { padding: 30px; display: none; }
    .tabcontent.active { display: block; }
    label { display: block; margin: 15px 0 8px; font-weight: 600; color: #333; }
    input, select, textarea { width: 100%; padding: 12px; border: 1px solid #ced4da; border-radius: 8px; box-sizing: border-box; font-size: 16px; }
    textarea { resize: vertical; min-height: 120px; }
    button { padding: 10px 20px; background: #007bff; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 15px; margin: 5px; }
    button:hover { background: #0056b3; }
    button.secondary { background: #6c757d; }
    button.secondary:hover { background: #545b62; }
    button.danger { background: #dc3545; }
    button.danger:hover { background: #c82333; }
    button.small { padding: 6px 12px; font-size: 13px; }
    .form-group { margin-bottom: 10px; }
    .filter-group { display: flex; gap: 15px; flex-wrap: wrap; align-items: end; margin-bottom: 20px; }
    .filter-group > div { flex: 1; min-width: 180px; }
    table { width: 100%; border-collapse: collapse; margin-top: 20px; font-size: 15px; }
    th { background: #007bff; color: white; padding: 14px; text-align: left; }
    td { padding: 12px; border-bottom: 1px solid #dee2e6; vertical-align: top; }
    tr:hover { background: #f8f9fa; }
    .text-wrap { white-space: pre-wrap; word-wrap: break-word; }
    .actions { margin: 20px 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
    .action-buttons { white-space: nowrap; }
    #editStatus { background: #e7f3ff; padding: 12px; border-radius: 8px; border-left: 4px solid #007bff; }
    @media (max-width: 768px) {
      .filter-group { flex-direction: column; }
      .action-buttons button { display: block; width: 100%; margin: 5px 0; }
    }
  </style>
</head>
<body>
  <div class="container">
    <h1>Aplikasi Catatan Pembelajaran</h1>

    <div class="card">
      <div class="tabs">
        <button class="tablink active" onclick="openTab(event, 'Input')">Input Pembelajaran</button>
        <button class="tablink" onclick="openTab(event, 'Daftar')">Daftar Pembelajaran</button>
      </div>

      <!-- Tab Input -->
      <div id="Input" class="tabcontent active">
        <h2 style="margin-top:0; color:#333;">Input / Edit Data Pembelajaran</h2>

        <label>Jenis Pembelajaran</label>
        <select id="jenisSelect" onchange="updateIndicatorDropdown()"></select>

        <div id="manualJenisInput" class="form-group" style="display:none;">
          <label>Tambah Jenis Baru</label>
          <input type="text" id="jenisManual" placeholder="Contoh: Pemrograman, Fisika, Sejarah">
        </div>

        <label>Indicator (Sub Bab yang Dibahas)</label>
        <select id="indicatorSelect"></select>

        <div id="manualIndicatorInput" class="form-group" style="display:none;">
          <label>Tambah Sub Bab Baru (untuk jenis ini)</label>
          <input type="text" id="indicatorManual" placeholder="Contoh: Aljabar, HTML, Perang Dunia II">
        </div>

        <label>Hasil Pembelajaran</label>
        <textarea id="hasil" placeholder="Tuliskan detail apa yang telah Anda pelajari..."></textarea>

        <label>Kesimpulan</label>
        <textarea id="kesimpulan" placeholder="Tuliskan poin penting atau kesimpulan..."></textarea>

        <div>
          <button onclick="simpanData()">Simpan Pembelajaran</button>
          <button class="secondary" onclick="resetForm()">Batal / Baru</button>
        </div>

        <div id="editStatus" style="display:none;">
          <strong>📝 Sedang mengedit entri nomor: <span id="editIndex"></span></span>
        </div>
      </div>

      <!-- Tab Daftar -->
      <div id="Daftar" class="tabcontent">
        <h2 style="margin-top:0; color:#333;">Daftar Semua Pembelajaran</h2>

        <div class="filter-group">
          <div>
            <label>Filter Jenis</label>
            <select id="filterJenis" onchange="updateFilterIndicator(); terapkanFilter()">
              <option value="">Semua Jenis</option>
            </select>
          </div>
          <div>
            <label>Filter Indicator (Sub Bab)</label>
            <select id="filterIndicator" onchange="terapkanFilter()">
              <option value="">Semua Sub Bab</option>
            </select>
          </div>
          <div>
            <label>Filter Kata Kunci</label>
            <input type="text" id="filterKata" list="suggestions" placeholder="Ketik untuk mencari..." oninput="terapkanFilter()">
            <datalist id="suggestions"></datalist>
          </div>
          <div style="align-self: end;">
            <button onclick="terapkanFilter()">Terapkan Filter</button>
            <button class="secondary" onclick="resetFilter()">Reset Filter</button>
          </div>
        </div>

        <div class="actions">
          <div>
            <label style="display:inline-block; margin-right:10px;">Import dari Excel:</label>
            <input type="file" id="importFile" accept=".xlsx, .xls" style="display:inline-block; width:auto;">
            <button onclick="importExcel()">Import Data</button>
          </div>
          <div>
            <button onclick="exportExcel()">Export ke Excel</button>
            <button onclick="exportPDF()">Export ke PDF</button>
          </div>
        </div>

        <table id="tabelPembelajaran">
          <thead>
            <tr>
              <th>No</th>
              <th>Tanggal</th>
              <th>Jenis</th>
              <th>Indicator</th>
              <th>Hasil Pembelajaran</th>
              <th>Kesimpulan</th>
              <th>Aksi</th>
            </tr>
          </thead>
          <tbody></tbody>
        </table>
      </div>
    </div>
  </div>

  <script>
    const { jsPDF } = window.jspdf;

    let dataPembelajaran = JSON.parse(localStorage.getItem('pembelajaran')) || [];
    let subBabByJenis = {};
    let editIndex = -1;

    function buildSubBabMapping() {
      subBabByJenis = {};
      dataPembelajaran.forEach(entry => {
        if (!subBabByJenis[entry.jenis]) {
          subBabByJenis[entry.jenis] = new Set();
        }
        subBabByJenis[entry.jenis].add(entry.indikator);
      });
      Object.keys(subBabByJenis).forEach(jenis => {
        subBabByJenis[jenis] = Array.from(subBabByJenis[jenis]).sort();
      });
    }

    function getJenisList() {
      return [...new Set(dataPembelajaran.map(d => d.jenis))].sort();
    }

    function updateJenisDropdown() {
      const jenisSelect = document.getElementById('jenisSelect');
      const filterJenis = document.getElementById('filterJenis');
      const jenisList = getJenisList();

      jenisSelect.innerHTML = '';
      filterJenis.innerHTML = '<option value="">Semua Jenis</option>';

      const defaultJenis = jenisList.length === 0 ? ["Matematika", "Bahasa", "Sains"] : jenisList;
      defaultJenis.forEach(j => {
        jenisSelect.add(new Option(j, j));
        filterJenis.add(new Option(j, j));
      });
      jenisSelect.add(new Option('--- Tambah Jenis Baru ---', 'new'));
    }

    function updateIndicatorDropdown(selectedJenis = null) {
      const jenis = selectedJenis || document.getElementById('jenisSelect').value;
      const indicatorSelect = document.getElementById('indicatorSelect');
      const manualDiv = document.getElementById('manualIndicatorInput');

      indicatorSelect.innerHTML = '';
      manualDiv.style.display = 'none';

      if (jenis === 'new' || !jenis) {
        indicatorSelect.innerHTML = '<option value="">-- Pilih jenis dulu --</option>';
        return;
      }

      const subBabList = subBabByJenis[jenis] || [];
      if (subBabList.length === 0) {
        indicatorSelect.add(new Option('-- Belum ada sub bab --', ''));
      } else {
        subBabList.forEach(sb => indicatorSelect.add(new Option(sb, sb)));
      }
      indicatorSelect.add(new Option('--- Tambah Sub Bab Baru ---', 'new'));
    }

    function updateFilterIndicator() {
      const selectedJenis = document.getElementById('filterJenis').value;
      const filterIndicator = document.getElementById('filterIndicator');

      filterIndicator.innerHTML = '<option value="">Semua Sub Bab</option>';

      if (!selectedJenis) {
        const allIndicators = [...new Set(dataPembelajaran.map(d => d.indikator))].sort();
        allIndicators.forEach(ind => filterIndicator.add(new Option(ind, ind)));
      } else {
        const subBabList = subBabByJenis[selectedJenis] || [];
        subBabList.forEach(ind => filterIndicator.add(new Option(ind, ind)));
      }
    }

    function updateAutocompleteSuggestions() {
      const datalist = document.getElementById('suggestions');
      datalist.innerHTML = '';

      const allWords = new Set();
      dataPembelajaran.forEach(entry => {
        [...entry.hasil.split(/\s+/), ...entry.kesimpulan.split(/\s+/)].forEach(word => {
          word = word.replace(/[.,!?()"]/g, '').toLowerCase();
          if (word.length >= 3) allWords.add(word);
        });
      });

      Array.from(allWords).sort().slice(0, 50).forEach(word => {
        const option = document.createElement('option');
        option.value = word;
        datalist.appendChild(option);
      });
    }

    // Event listeners
    document.getElementById('jenisSelect').addEventListener('change', function() {
      document.getElementById('manualJenisInput').style.display = this.value === 'new' ? 'block' : 'none';
      updateIndicatorDropdown();
    });

    document.getElementById('indicatorSelect').addEventListener('change', function() {
      document.getElementById('manualIndicatorInput').style.display = this.value === 'new' ? 'block' : 'none';
    });

    function simpanData() {
      let jenis = document.getElementById('jenisSelect').value;
      if (jenis === 'new') {
        jenis = document.getElementById('jenisManual').value.trim();
        if (!jenis) return alert('Masukkan nama jenis baru!');
      }

      let indikator = document.getElementById('indicatorSelect').value;
      if (indikator === 'new') {
        indikator = document.getElementById('indicatorManual').value.trim();
        if (!indikator) return alert('Masukkan nama sub bab baru!');
      }

      const hasil = document.getElementById('hasil').value.trim();
      const kesimpulan = document.getElementById('kesimpulan').value.trim();

      if (!jenis || !indikator || !hasil || !kesimpulan) {
        return alert('Semua field wajib diisi!');
      }

      const entry = {
        tanggal: editIndex === -1 ? new Date().toLocaleString('id-ID') : dataPembelajaran[editIndex].tanggal,
        jenis,
        indikator,
        hasil,
        kesimpulan
      };

      if (editIndex === -1) {
        dataPembelajaran.push(entry);
      } else {
        dataPembelajaran[editIndex] = entry;
      }

      localStorage.setItem('pembelajaran', JSON.stringify(dataPembelajaran));
      buildSubBabMapping();
      updateJenisDropdown();
      updateIndicatorDropdown();
      updateFilterIndicator();
      updateAutocompleteSuggestions();
      resetForm();
      alert(editIndex === -1 ? 'Data berhasil disimpan!' : 'Perubahan berhasil disimpan!');
      if (document.getElementById('Daftar').classList.contains('active')) tampilkanData();
    }

    function resetForm() {
      editIndex = -1;
      document.getElementById('editStatus').style.display = 'none';
      updateJenisDropdown();
      document.getElementById('manualJenisInput').style.display = 'none';
      document.getElementById('jenisManual').value = '';
      updateIndicatorDropdown();
      document.getElementById('manualIndicatorInput').style.display = 'none';
      document.getElementById('indicatorManual').value = '';
      document.getElementById('hasil').value = '';
      document.getElementById('kesimpulan').value = '';
    }

    // FUNGSI EDIT YANG DIPERBAIKI
    function editData(index) {
      const data = dataPembelajaran[index];
      editIndex = index;

      // Pindah ke tab Input
      openTab(null, 'Input');

      // Pastikan jenis ada di dropdown
      const jenisSelect = document.getElementById('jenisSelect');
      if (!Array.from(jenisSelect.options).find(opt => opt.value === data.jenis)) {
        jenisSelect.add(new Option(data.jenis, data.jenis), 0);
      }
      jenisSelect.value = data.jenis;

      // Update dropdown indicator sesuai jenis
      updateIndicatorDropdown(data.jenis);

      // Pastikan indicator ada di dropdown
      const indicatorSelect = document.getElementById('indicatorSelect');
      if (!Array.from(indicatorSelect.options).find(opt => opt.value === data.indikator)) {
        // Tambahkan sebelum opsi "Tambah baru"
        const newOption = new Option(data.indikator, data.indikator);
        indicatorSelect.insertBefore(newOption, indicatorSelect.lastElementChild);
      }
      indicatorSelect.value = data.indikator;

      // Isi teks
      document.getElementById('hasil').value = data.hasil;
      document.getElementById('kesimpulan').value = data.kesimpulan;

      // Tampilkan status edit
      document.getElementById('editStatus').style.display = 'block';
      document.getElementById('editIndex').textContent = index + 1;

      // Scroll ke atas form
      document.getElementById('Input').scrollIntoView({ behavior: 'smooth' });
    }

    function deleteData(index) {
      if (confirm('Yakin ingin menghapus entri ini? Tindakan ini tidak dapat dibatalkan.')) {
        dataPembelajaran.splice(index, 1);
        localStorage.setItem('pembelajaran', JSON.stringify(dataPembelajaran));
        buildSubBabMapping();
        updateJenisDropdown();
        updateIndicatorDropdown();
        updateFilterIndicator();
        updateAutocompleteSuggestions();
        tampilkanData();
        alert('Data berhasil dihapus!');
      }
    }

    function tampilkanData() {
      const filterJenis = document.getElementById('filterJenis').value;
      const filterIndicatorVal = document.getElementById('filterIndicator').value;
      const filterKata = document.getElementById('filterKata').value.toLowerCase().trim();

      let filtered = dataPembelajaran;

      if (filterJenis) filtered = filtered.filter(d => d.jenis === filterJenis);
      if (filterIndicatorVal) filtered = filtered.filter(d => d.indikator === filterIndicatorVal);
      if (filterKata) {
        filtered = filtered.filter(d =>
          d.hasil.toLowerCase().includes(filterKata) ||
          d.kesimpulan.toLowerCase().includes(filterKata)
        );
      }

      const tbody = document.querySelector('#tabelPembelajaran tbody');
      tbody.innerHTML = '';

      filtered.forEach((d, i) => {
        const originalIndex = dataPembelajaran.indexOf(d);
        const row = tbody.insertRow();
        row.insertCell(0).textContent = i + 1;
        row.insertCell(1).textContent = d.tanggal;
        row.insertCell(2).textContent = d.jenis;
        row.insertCell(3).textContent = d.indikator;
        row.insertCell(4).innerHTML = '<div class="text-wrap">' + d.hasil.replace(/\n/g, '<br>') + '</div>';
        row.insertCell(5).innerHTML = '<div class="text-wrap">' + d.kesimpulan.replace(/\n/g, '<br>') + '</div>';

        const cellAksi = row.insertCell(6);
        cellAksi.className = 'action-buttons';
        cellAksi.innerHTML = `
          <button class="small" onclick="editData(${originalIndex})" style="background:#28a745;">Edit</button>
          <button class="small danger" onclick="deleteData(${originalIndex})">Hapus</button>
        `;
      });
    }

    function terapkanFilter() {
      tampilkanData();
    }

    function resetFilter() {
      document.getElementById('filterJenis').value = '';
      updateFilterIndicator();
      document.getElementById('filterIndicator').value = '';
      document.getElementById('filterKata').value = '';
      tampilkanData();
    }

    // Import, Export tetap sama
    function importExcel() { /* ... kode import sama seperti sebelumnya ... */ }
    function exportExcel() { /* ... kode export sama ... */ }
    function exportPDF() { /* ... kode export sama ... */ }

    // Tambahkan kode import/export lengkap di sini jika diperlukan (sama seperti versi sebelumnya)

    function openTab(evt, tabName) {
      document.querySelectorAll(".tabcontent").forEach(el => el.classList.remove("active"));
      document.querySelectorAll(".tablink").forEach(el => el.classList.remove("active"));
      document.getElementById(tabName).classList.add("active");
      if (evt) evt.currentTarget.classList.add("active");

      if (tabName === 'Daftar') {
        updateJenisDropdown();
        updateFilterIndicator();
        updateAutocompleteSuggestions();
        tampilkanData();
      }
    }

    // Inisialisasi
    buildSubBabMapping();
    updateJenisDropdown();
    updateIndicatorDropdown();
    updateFilterIndicator();
    updateAutocompleteSuggestions();
  </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-qwensite.hf.space/logo.svg" alt="qwensite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-qwensite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >QwenSite</a> - 🧬 <a href="https://enzostvs-qwensite.hf.space?remix=alterzick/notepad-v1" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>