theWitcher commited on
Commit
07e7f0a
·
1 Parent(s): 26775a9

הוספת אפשרות להציע כלי חדש

Browse files
Files changed (1) hide show
  1. index.html +90 -24
index.html CHANGED
@@ -205,11 +205,12 @@ https://chatgpt.com/c/67efa5ae-ab80-8005-a7d4-de3ced6ccec4
205
  <button id="refreshBtn" class="px-4 py-2 bg-blue-50 text-blue-600 rounded-lg hover:bg-blue-100 transition">
206
  <i class="fas fa-sync-alt ml-2"></i> אפס תצוגה
207
  </button>
208
- <!-- /* --- Admin Edit Button - Uncomment if needed --- */
209
- /* <button id="editJsonBtn" class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition relative">
210
- <i class="fas fa-edit ml-2"></i> ערוך JSON
211
- <span class="admin-badge">A</span>
212
- </button> */ -->
 
213
  </div>
214
  </div>
215
 
@@ -219,11 +220,11 @@ https://chatgpt.com/c/67efa5ae-ab80-8005-a7d4-de3ced6ccec4
219
  <button id="refreshBtnMobile" class="px-4 py-2 bg-blue-50 text-blue-600 rounded-lg hover:bg-blue-100 transition text-right">
220
  <i class="fas fa-sync-alt ml-2"></i> אפס תצוגה
221
  </button>
222
- <!-- /* --- Admin Edit Button (Mobile) - Uncomment if needed --- */
223
- /* <button id="editJsonBtnMobile" class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition text-right relative">
224
- <i class="fas fa-edit ml-2"></i> ערוך JSON
225
- <span class="admin-badge">A</span>
226
- </button> */ -->
227
  </div>
228
  </div>
229
  </div>
@@ -365,6 +366,39 @@ https://chatgpt.com/c/67efa5ae-ab80-8005-a7d4-de3ced6ccec4
365
  </div>
366
  </div>
367
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
 
369
  <!-- /* --- Footer --- */ -->
370
  <footer class="bg-gray-100 border-t border-gray-200 py-6 mt-16">
@@ -711,21 +745,13 @@ https://chatgpt.com/c/67efa5ae-ab80-8005-a7d4-de3ced6ccec4
711
  mobileMenu.classList.toggle('open');
712
  });
713
 
714
- // JSON Editor Modal Logic (If admin buttons are enabled)
715
- const openEditorHandler = () => {
716
- // Load current data into editor (might be stale if user hasn't reloaded)
717
- showToolsBtn.click(); // Default to showing tools
718
- // Populate editor with the data currently held in `toolsData`
719
- // Note: If the user edits and saves, it saves to localStorage,
720
- // but this will be overwritten on the *next full page load*.
721
- jsonEditor.value = JSON.stringify(toolsData.tools, null, 2);
722
- jsonEditorModal.classList.remove('hidden');
723
- };
724
  // Uncomment if using admin buttons
725
- // const editJsonBtn = document.getElementById('editJsonBtn');
726
- // const editJsonBtnMobile = document.getElementById('editJsonBtnMobile');
727
- // if (editJsonBtn) editJsonBtn.addEventListener('click', openEditorHandler);
728
- // if (editJsonBtnMobile) editJsonBtnMobile.addEventListener('click', openEditorHandler);
729
 
730
  closeModalBtn.addEventListener('click', () => jsonEditorModal.classList.add('hidden'));
731
  cancelEditBtn.addEventListener('click', () => jsonEditorModal.classList.add('hidden'));
@@ -796,6 +822,46 @@ https://chatgpt.com/c/67efa5ae-ab80-8005-a7d4-de3ced6ccec4
796
  // --- Initialize the app ---
797
  document.addEventListener('DOMContentLoaded', init);
798
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
799
  </script>
800
  <!-- /* --------------------------------- */
801
  /* ------- END OF JAVASCRIPT ------- */
 
205
  <button id="refreshBtn" class="px-4 py-2 bg-blue-50 text-blue-600 rounded-lg hover:bg-blue-100 transition">
206
  <i class="fas fa-sync-alt ml-2"></i> אפס תצוגה
207
  </button>
208
+
209
+ <!-- /* --- Admin Edit Button - Uncomment if needed --- */ -->
210
+ <button id="editJsonBtn" class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition relative">
211
+ <i class="fas fa-edit ml-2"></i> הציעו כלי חדש
212
+ <span class="admin-badge">N</span>
213
+ </button>
214
  </div>
215
  </div>
216
 
 
220
  <button id="refreshBtnMobile" class="px-4 py-2 bg-blue-50 text-blue-600 rounded-lg hover:bg-blue-100 transition text-right">
221
  <i class="fas fa-sync-alt ml-2"></i> אפס תצוגה
222
  </button>
223
+ <!-- /* --- Admin Edit Button (Mobile) - Uncomment if needed --- */ -->
224
+ <button id="editJsonBtnMobile" class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition text-right relative">
225
+ <i class="fas fa-edit ml-2"></i> הציעו כלי חדש
226
+ <span class="admin-badge">N</span>
227
+ </button>
228
  </div>
229
  </div>
230
  </div>
 
366
  </div>
367
  </div>
368
  </div>
369
+ <div id="suggestToolModal" class="fixed inset-0 bg-black bg-opacity-40 flex items-center justify-center hidden z-50 px-4">
370
+ <div class="bg-white rounded-lg p-6 w-full max-w-md shadow-lg max-h-[90vh] overflow-y-auto text-right">
371
+ <h2 class="text-xl font-semibold mb-4">הצעת כלי חדש</h2>
372
+ <form id="suggestToolForm">
373
+
374
+ <label class="block mb-2">שם הכלי</label>
375
+ <input type="text" name="name" required class="w-full mb-4 border rounded p-2">
376
+
377
+ <label class="block mb-2">לינק</label>
378
+ <input type="url" name="url" required placeholder="כתובת URL של הכלי: לדוגמא: https://linktr.ee/sagib" dir="ltr" class="w-full mb-4 border rounded p-2">
379
+
380
+ <label class="block mb-2">תיאור קצר</label>
381
+ <textarea name="description" required class="w-full mb-4 border rounded p-2"></textarea>
382
+
383
+ <hr class="my-4">
384
+
385
+ <label class="block mb-2">השם שלך</label>
386
+ <input type="text" name="userName" placeholder="איך לקרוא לך כשנחזור אליך?" class="w-full mb-4 border rounded p-2">
387
+
388
+ <label class="block mb-2">מס' טלפון נייד</label>
389
+ <input type="tel" name="userPhone" placeholder="05X-XXXXXXX" class="w-full mb-2 border rounded p-2" dir="ltr">
390
+ <p class="text-sm text-gray-500">נשמח לחזור אליך כשהכלי שצעת נוסף לאתר ❤️</p>
391
+ <p class="text-sm text-gray-500 italic mt-1">
392
+ ✦ הפרטים שלך נשמרים אצלנו רק לצורך עדכון – אין שימוש אחר.
393
+ </p>
394
+
395
+ <div class="flex justify-end mt-4">
396
+ <button type="button" onclick="closeSuggestModal()" class="mr-2 px-4 py-2 bg-gray-300 rounded">ביטול</button>
397
+ <button type="submit" class="px-4 py-2 bg-purple-600 text-white rounded hover:bg-purple-700">שלח</button>
398
+ </div>
399
+ </form>
400
+ </div>
401
+ </div>
402
 
403
  <!-- /* --- Footer --- */ -->
404
  <footer class="bg-gray-100 border-t border-gray-200 py-6 mt-16">
 
745
  mobileMenu.classList.toggle('open');
746
  });
747
 
748
+
749
+
 
 
 
 
 
 
 
 
750
  // Uncomment if using admin buttons
751
+ const editJsonBtn = document.getElementById('editJsonBtn');
752
+ const editJsonBtnMobile = document.getElementById('editJsonBtnMobile');
753
+ if (editJsonBtn) editJsonBtn.addEventListener('click', openEditorHandler);
754
+ if (editJsonBtnMobile) editJsonBtnMobile.addEventListener('click', openEditorHandler);
755
 
756
  closeModalBtn.addEventListener('click', () => jsonEditorModal.classList.add('hidden'));
757
  cancelEditBtn.addEventListener('click', () => jsonEditorModal.classList.add('hidden'));
 
822
  // --- Initialize the app ---
823
  document.addEventListener('DOMContentLoaded', init);
824
 
825
+ // JSON Editor Modal Logic (If admin buttons are enabled)
826
+ const openEditorHandler = () => {
827
+ document.getElementById('suggestToolModal').classList.remove('hidden');
828
+ };
829
+
830
+ const closeSuggestModal = () => {
831
+ document.getElementById('suggestToolModal').classList.add('hidden');
832
+ };
833
+
834
+ document.getElementById('suggestToolForm').addEventListener('submit', async (e) => {
835
+ e.preventDefault();
836
+ const form = e.target;
837
+ const rawPhone = form.userPhone.value;
838
+ const cleanedPhone = rawPhone.replace(/\D/g, ''); // מסיר כל תו שאינו ספרה
839
+ // alert(cleanedPhone)
840
+ const data = {
841
+ name: form.name.value,
842
+ url: form.url.value,
843
+ description: form.description.value,
844
+ userName: form.userName.value,
845
+ userPhone: cleanedPhone,
846
+ };
847
+
848
+ try {
849
+ await fetch("https://hook.eu2.make.com/lgo6nh36dk804dq1msfmwxo34nzf4o3y", {
850
+ method: "POST",
851
+ headers: {
852
+ "Content-Type": "application/json"
853
+ },
854
+ body: JSON.stringify(data)
855
+ });
856
+
857
+ alert("הכלי נשלח בהצלחה!");
858
+ closeSuggestModal();
859
+ form.reset();
860
+ } catch (err) {
861
+ alert("שגיאה בשליחה 😢");
862
+ console.error(err);
863
+ }
864
+ });
865
  </script>
866
  <!-- /* --------------------------------- */
867
  /* ------- END OF JAVASCRIPT ------- */