@@ -16,7 +16,9 @@ const instructions = document.querySelector(".browser-instructions");
1616const noSkillsMsg = document . getElementById ( "no-matching-skills" ) ;
1717const draggingCursor = skillSections [ 0 ] ? getComputedStyle ( skillSections [ 0 ] ) . getPropertyValue ( "--dragging-cursor" ) . trim ( ) : "grabbing" ;
1818
19- // Skills search
19+ /**
20+ * Skills search: Filter skills based on search input
21+ */
2022function filterBrowser ( ) {
2123 // Filter skills
2224 document . querySelectorAll ( ".skills-container .skill-entry" ) . forEach ( skill => {
@@ -25,13 +27,11 @@ function filterBrowser() {
2527
2628 // Hide section headings IFF ALL their skills are hidden
2729 document . querySelectorAll ( "#browser .inside h2" ) . forEach ( h2 => {
28- const section = h2 . nextElementSibling ;
29- if ( ! section ?. classList . contains ( "section" ) ) return ;
30- const skillsContainer = section . querySelector ( ".skills-container" ) ;
31- if ( ! skillsContainer ) return ;
30+ const skillsContainer = h2 . nextElementSibling ;
31+ if ( ! skillsContainer ?. classList . contains ( "section" ) ) return ;
3232 const anyVisible = Array . from ( skillsContainer . querySelectorAll ( ".skill-entry" ) )
3333 . some ( skill => skill . style . display !== "none" ) ;
34- section . style . display = h2 . style . display = anyVisible ? "" : "none" ;
34+ skillsContainer . style . display = h2 . style . display = anyVisible ? "" : "none" ;
3535 } ) ;
3636
3737 // Hide browser instructions ONLY when filtering
@@ -51,12 +51,12 @@ function filterBrowser() {
5151 }
5252}
5353
54- // Skills sorting
54+ /**
55+ * Skills sorting
56+ */
5557function sortSkills ( ) {
5658 skillSections . forEach ( section => {
57- const skillsContainer = section . querySelector ( ".skills-container" ) ;
58- if ( ! skillsContainer ) return ;
59- let skills = Array . from ( skillsContainer . querySelectorAll ( ".skill-entry" ) ) ;
59+ let skills = Array . from ( section . querySelectorAll ( ".skill-entry" ) ) ;
6060 if ( sortMode === 0 ) { // Ascending
6161 skills . sort ( ( a , b ) =>
6262 getText ( a , ".heading" ) . localeCompare ( getText ( b , ".heading" ) )
@@ -66,14 +66,16 @@ function sortSkills() {
6666 getText ( b , ".heading" ) . localeCompare ( getText ( a , ".heading" ) )
6767 ) ;
6868 } else { // Original
69- skills = skillsContainer . _originalOrder . slice ( ) ;
69+ skills = section . _originalOrder . slice ( ) ;
7070 }
71- skills . forEach ( skill => skillsContainer . appendChild ( skill ) ) ;
71+ skills . forEach ( skill => section . appendChild ( skill ) ) ;
7272 } ) ;
7373 sortMode = ( sortMode + 1 ) % 3 ;
7474}
7575
76- // Show/hide skill description
76+ /**
77+ * Show/hide skill description
78+ */
7779const toggleContent = item => {
7880 // Prevent toggling content when sorting
7981 if ( ! isSorting ) {
@@ -84,27 +86,28 @@ const toggleContent = item => {
8486 }
8587} ;
8688
89+ /**
90+ * Initialize browser functionality
91+ */
8792export function initBrowser ( ) {
8893 skillSections . forEach ( section => {
89- const skillsContainer = section . querySelector ( ".skills-container" ) ;
90- if ( skillsContainer ) {
91- skillsContainer . _originalOrder = Array . from ( skillsContainer . querySelectorAll ( ".skill-entry" ) ) ;
92- // Make skills sortable
93- $ ( skillsContainer ) . sortable ( {
94- axis : "y" ,
95- containment : "parent" ,
96- cursor : draggingCursor ,
97- handle : ".row" ,
98- opacity : sortOpacity ,
99- scroll : true ,
100- scrollSpeed : sortSpeed ,
101- start : function ( ) { isSorting = true ; } ,
102- stop : function ( ) { setTimeout ( ( ) => { isSorting = false ; } , 0 ) ; }
103- } ) . on ( "sortupdate" , function ( ) {
104- // Update original order after sorting
105- this . _originalOrder = Array . from ( this . querySelectorAll ( ".skill-entry" ) ) ;
106- } ) ;
107- }
94+ section . _originalOrder = Array . from ( section . querySelectorAll ( ".skill-entry" ) ) ;
95+
96+ // Make skills sortable
97+ $ ( section ) . sortable ( {
98+ axis : "y" ,
99+ containment : "parent" ,
100+ cursor : draggingCursor ,
101+ handle : ".row" ,
102+ opacity : sortOpacity ,
103+ scroll : true ,
104+ scrollSpeed : sortSpeed ,
105+ start : function ( ) { isSorting = true ; } ,
106+ stop : function ( ) { setTimeout ( ( ) => { isSorting = false ; } , 0 ) ; }
107+ } ) . on ( "sortupdate" , function ( ) {
108+ // Update original order after sorting
109+ this . _originalOrder = Array . from ( this . querySelectorAll ( ".skill-entry" ) ) ;
110+ } ) ;
108111 } ) ;
109112
110113 if ( browserInput ) {
0 commit comments