chenguittiMaroua commited on
Commit
8bd3946
·
verified ·
1 Parent(s): ec3e108

Update static/test.js

Browse files
Files changed (1) hide show
  1. static/test.js +19 -16
static/test.js CHANGED
@@ -1,39 +1,42 @@
1
  // Function to show the selected section and hide the others
2
  function showSection(sectionId) {
3
- // Show the selected section (in case it was hidden)
 
 
 
 
 
 
 
 
4
  const activeSection = document.getElementById(sectionId);
5
  if (activeSection) {
6
  activeSection.style.display = 'block';
7
- // Scroll to the section smoothly
8
  activeSection.scrollIntoView({
9
  behavior: 'smooth',
10
- block: 'start' // Aligns the section at the top of the viewport
11
  });
12
  }
13
  }
14
 
 
15
  function showCards() {
16
- // Show cards section
17
- document.querySelector('.cards').style.display = 'grid'; // or 'flex' depending on your layout
18
-
19
  // Hide all tool sections
20
- const sections = document.querySelectorAll('.tool-section');
21
- sections.forEach(section => {
22
  section.style.display = 'none';
23
  });
24
 
25
- // Scroll to top
 
26
  window.scrollTo({ top: 0, behavior: 'smooth' });
27
  }
28
 
 
29
  document.addEventListener('DOMContentLoaded', () => {
30
- // Set up card click handlers
31
- document.querySelectorAll('.card').forEach(card => {
32
- card.addEventListener('click', function() {
33
- const sectionId = this.getAttribute('onclick').match(/'([^']+)'/)[1];
34
- showSection(sectionId);
35
- });
36
- });
37
 
38
  // Hide all tool sections by default
39
  const sections = document.querySelectorAll('.tool-section');
 
1
  // Function to show the selected section and hide the others
2
  function showSection(sectionId) {
3
+ // Hide all tool sections
4
+ document.querySelectorAll('.tool-section').forEach(section => {
5
+ section.style.display = 'none';
6
+ });
7
+
8
+ // Hide the cards container
9
+ document.querySelector('.cards').style.display = 'none';
10
+
11
+ // Show the selected section
12
  const activeSection = document.getElementById(sectionId);
13
  if (activeSection) {
14
  activeSection.style.display = 'block';
 
15
  activeSection.scrollIntoView({
16
  behavior: 'smooth',
17
+ block: 'start'
18
  });
19
  }
20
  }
21
 
22
+ // Add a function to go back to cards view
23
  function showCards() {
 
 
 
24
  // Hide all tool sections
25
+ document.querySelectorAll('.tool-section').forEach(section => {
 
26
  section.style.display = 'none';
27
  });
28
 
29
+ // Show the cards
30
+ document.querySelector('.cards').style.display = 'flex';
31
  window.scrollTo({ top: 0, behavior: 'smooth' });
32
  }
33
 
34
+ // Initialize - show only cards on page load
35
  document.addEventListener('DOMContentLoaded', () => {
36
+ showCards();
37
+
38
+ // Your existing event listeners and other code...
39
+ });
 
 
 
40
 
41
  // Hide all tool sections by default
42
  const sections = document.querySelectorAll('.tool-section');