chenguittiMaroua commited on
Commit
a6ffce9
·
verified ·
1 Parent(s): 7a0b602

Update static/test.js

Browse files
Files changed (1) hide show
  1. static/test.js +28 -61
static/test.js CHANGED
@@ -1,82 +1,49 @@
1
- // Function to show the selected section
2
- function showSection(sectionId) {
3
- // Hide all sections
4
- document.querySelectorAll('.tool-section').forEach(section => {
5
- section.classList.add('hidden');
6
- });
7
-
8
- // Hide cards view
9
- document.querySelector('.cards').classList.add('hidden');
10
 
11
- // Show the selected section
12
- const sectionToShow = document.getElementById(sectionId);
13
- if (sectionToShow) {
14
- sectionToShow.classList.remove('hidden');
15
- sectionToShow.scrollIntoView({ behavior: 'smooth', block: 'start' });
 
 
 
 
 
 
16
  }
17
  }
18
- function toggleSection(card) {
19
- const sectionId = card.getAttribute('data-section');
20
- const section = document.getElementById(sectionId);
21
-
22
- // Check if this is the currently shown section
23
- const isAlreadyShown = !section.classList.contains('hidden');
24
-
25
- // Hide all sections first
26
- document.querySelectorAll('.tool-section').forEach(sec => {
27
- sec.classList.add('hidden');
28
- });
29
-
30
- // Toggle this section
31
- if (!isAlreadyShown) {
32
- section.classList.remove('hidden');
33
- section.scrollIntoView({ behavior: 'smooth', block: 'start' });
34
- }
35
-
36
- // Update active card styling
37
- document.querySelectorAll('.card').forEach(c => {
38
- c.classList.remove('active');
39
- });
40
-
41
- if (!isAlreadyShown) {
42
- card.classList.add('active');
43
- }
44
- }
45
 
46
- // Function to go back to cards view
47
  function showCards() {
48
- document.querySelectorAll('.tool-section').forEach(section => {
49
- section.classList.add('hidden');
 
 
 
 
 
50
  });
51
- document.querySelector('.cards').classList.remove('hidden');
 
52
  window.scrollTo({ top: 0, behavior: 'smooth' });
53
  }
54
 
55
- // Only one DOMContentLoaded
56
- document.addEventListener('DOMContentLoaded', function() {
57
- // Hide all tool sections at the start
58
- document.querySelectorAll('.tool-section').forEach(section => {
59
- section.classList.add('hidden');
60
- });
61
-
62
- // Show only cards initially
63
- showCards();
64
-
65
  // Set up card click handlers
66
  document.querySelectorAll('.card').forEach(card => {
67
  card.addEventListener('click', function() {
68
- const sectionId = this.getAttribute('data-section');
69
  showSection(sectionId);
70
  });
71
  });
72
 
73
- // If you have a "Back to cards" button somewhere
74
- const backButtons = document.querySelectorAll('.back-to-cards');
75
- backButtons.forEach(button => {
76
- button.addEventListener('click', showCards);
77
  });
78
 
79
-
 
80
 
81
  // Helper functions
82
  function preventDefaults(e) {
 
 
 
 
 
 
 
 
 
 
1
 
2
+ // Function to show the selected section and hide the others
3
+ function showSection(sectionId) {
4
+ // Show the selected section (in case it was hidden)
5
+ const activeSection = document.getElementById(sectionId);
6
+ if (activeSection) {
7
+ activeSection.style.display = 'block';
8
+ // Scroll to the section smoothly
9
+ activeSection.scrollIntoView({
10
+ behavior: 'smooth',
11
+ block: 'start' // Aligns the section at the top of the viewport
12
+ });
13
  }
14
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
 
16
  function showCards() {
17
+ // Show cards section
18
+ document.querySelector('.cards').style.display = 'grid'; // or 'flex' depending on your layout
19
+
20
+ // Hide all tool sections
21
+ const sections = document.querySelectorAll('.tool-section');
22
+ sections.forEach(section => {
23
+ section.style.display = 'none';
24
  });
25
+
26
+ // Scroll to top
27
  window.scrollTo({ top: 0, behavior: 'smooth' });
28
  }
29
 
30
+ document.addEventListener('DOMContentLoaded', () => {
 
 
 
 
 
 
 
 
 
31
  // Set up card click handlers
32
  document.querySelectorAll('.card').forEach(card => {
33
  card.addEventListener('click', function() {
34
+ const sectionId = this.getAttribute('onclick').match(/'([^']+)'/)[1];
35
  showSection(sectionId);
36
  });
37
  });
38
 
39
+ // Hide all tool sections by default
40
+ const sections = document.querySelectorAll('.tool-section');
41
+ sections.forEach(section => {
42
+ section.style.display = 'none';
43
  });
44
 
45
+ // Show first section by default
46
+ showSection('document-image-analysis');
47
 
48
  // Helper functions
49
  function preventDefaults(e) {