mistpe commited on
Commit
3f4fb25
·
verified ·
1 Parent(s): e1dd24e

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +38 -3
index.html CHANGED
@@ -72,6 +72,24 @@
72
  background: #f5f5f5;
73
  border-radius: 5px;
74
  font-size: 12px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
76
 
77
  .dialog {
@@ -144,6 +162,7 @@
144
  let map;
145
  let marker;
146
  let checkinLocation;
 
147
  const STORAGE_KEY = 'mapCheckins';
148
 
149
  // 初始化地图
@@ -242,11 +261,16 @@
242
 
243
  // 加载已有的打卡记录
244
  function loadCheckins() {
 
 
 
 
245
  const checkins = JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]');
246
- checkins.forEach(checkin => {
247
- L.marker([checkin.location.lat, checkin.location.lng])
248
  .bindPopup(checkin.note)
249
  .addTo(map);
 
250
  });
251
  updateCheckinList();
252
  }
@@ -257,12 +281,13 @@
257
  const recordsContainer = document.getElementById('checkinRecords');
258
  recordsContainer.innerHTML = '';
259
 
260
- checkins.reverse().forEach(checkin => {
261
  const item = document.createElement('div');
262
  item.className = 'checkin-item';
263
  item.innerHTML = `
264
  <div>${checkin.note}</div>
265
  <div style="color: #666; font-size: 11px;">${checkin.timestamp}</div>
 
266
  `;
267
  recordsContainer.appendChild(item);
268
  });
@@ -274,6 +299,16 @@
274
  list.style.display = list.style.display === 'none' ? 'block' : 'none';
275
  }
276
 
 
 
 
 
 
 
 
 
 
 
277
  // 初始化地图
278
  initMap();
279
  </script>
 
72
  background: #f5f5f5;
73
  border-radius: 5px;
74
  font-size: 12px;
75
+ position: relative;
76
+ }
77
+
78
+ .delete-button {
79
+ position: absolute;
80
+ top: 8px;
81
+ right: 8px;
82
+ background: #ff4444;
83
+ color: white;
84
+ border: none;
85
+ border-radius: 3px;
86
+ padding: 2px 6px;
87
+ font-size: 11px;
88
+ cursor: pointer;
89
+ }
90
+
91
+ .delete-button:hover {
92
+ background: #ee3333;
93
  }
94
 
95
  .dialog {
 
162
  let map;
163
  let marker;
164
  let checkinLocation;
165
+ let markers = [];
166
  const STORAGE_KEY = 'mapCheckins';
167
 
168
  // 初始化地图
 
261
 
262
  // 加载已有的打卡记录
263
  function loadCheckins() {
264
+ // 清除现有标记
265
+ markers.forEach(marker => map.removeLayer(marker));
266
+ markers = [];
267
+
268
  const checkins = JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]');
269
+ checkins.forEach((checkin, index) => {
270
+ const marker = L.marker([checkin.location.lat, checkin.location.lng])
271
  .bindPopup(checkin.note)
272
  .addTo(map);
273
+ markers.push(marker);
274
  });
275
  updateCheckinList();
276
  }
 
281
  const recordsContainer = document.getElementById('checkinRecords');
282
  recordsContainer.innerHTML = '';
283
 
284
+ checkins.reverse().forEach((checkin, index) => {
285
  const item = document.createElement('div');
286
  item.className = 'checkin-item';
287
  item.innerHTML = `
288
  <div>${checkin.note}</div>
289
  <div style="color: #666; font-size: 11px;">${checkin.timestamp}</div>
290
+ <button class="delete-button" onclick="deleteCheckin(${checkins.length - 1 - index})">删除</button>
291
  `;
292
  recordsContainer.appendChild(item);
293
  });
 
299
  list.style.display = list.style.display === 'none' ? 'block' : 'none';
300
  }
301
 
302
+ // 删除打卡记录
303
+ function deleteCheckin(index) {
304
+ if (confirm('确定要删除这条记录吗?')) {
305
+ let checkins = JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]');
306
+ checkins.splice(index, 1);
307
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(checkins));
308
+ loadCheckins(); // 重新加载记录和标记
309
+ }
310
+ }
311
+
312
  // 初始化地图
313
  initMap();
314
  </script>