@@ -98,89 +98,6 @@ window.addEventListener("popstate", function (event) {
9898 }
9999} ) ;
100100
101- function updateArticleVisibility ( ) {
102- const showEmptyDescription = document . getElementById ( "show-empty-description" ) . checked ;
103- const kindVisibilityMap = {
104- "パッケージ" : document . getElementById ( "show-package" ) . checked ,
105- "クラス" : document . getElementById ( "show-class" ) . checked ,
106- "メソッド" : document . getElementById ( "show-method" ) . checked ,
107- "フィールド" : document . getElementById ( "show-field" ) . checked ,
108- } ;
109-
110- const searchKeyword = document . getElementById ( "search-input" ) . value . toLowerCase ( ) ;
111- const termArticles = document . getElementsByClassName ( "term" ) ;
112-
113- Array . from ( termArticles ) . forEach ( term => {
114- const kindText = term . getElementsByClassName ( "kind" ) [ 0 ] ?. textContent || "" ;
115-
116- // 種類で絞り込む
117- if ( ! kindVisibilityMap [ kindText ] ) {
118- term . classList . add ( "hidden" ) ;
119- return ;
120- }
121-
122- // 以降の判定で使用する説明文を取得
123- const description = term . getElementsByClassName ( "description" ) [ 0 ] ?. textContent ?. toLowerCase ( ) || "" ;
124-
125- // 説明文有無での判定
126- if ( ! showEmptyDescription && ! description ) {
127- term . classList . add ( "hidden" ) ;
128- return ;
129- }
130- // 検索キーワードでの判定(タイトルと説明文)
131- const title = term . getElementsByClassName ( "term-title" ) [ 0 ] ?. textContent ?. toLowerCase ( ) || "" ;
132- if ( searchKeyword && ! title . includes ( searchKeyword ) && ! description . includes ( searchKeyword ) ) {
133- term . classList . add ( "hidden" ) ;
134- return ;
135- }
136-
137- // すべての条件をパスした場合に表示
138- term . classList . remove ( "hidden" ) ;
139- } ) ;
140-
141- // 表示が変わるのでnavも更新する
142- updateLetterNavigationVisibility ( ) ;
143- }
144-
145- function updateLetterNavigationVisibility ( ) {
146- const letterNavigations = Array . from ( document . getElementsByClassName ( "letter-navigation" ) ) ;
147- const showNavigation = document . getElementById ( "show-letter-navigation" ) . checked ;
148- if ( ! showNavigation ) {
149- letterNavigations . forEach ( nav => nav . classList . add ( "invisible" ) ) ;
150- return ;
151- }
152-
153- letterNavigations . forEach ( ( nav , index ) => {
154- // 1件目は無視
155- if ( index === 0 ) {
156- nav . classList . remove ( "invisible" ) ;
157- return ;
158- }
159-
160- let visibleCount = 0 ;
161- let sibling = nav . previousElementSibling ;
162- while ( sibling ) {
163- // 表示しているものだけ対象にする
164- if ( ! sibling . classList . contains ( "invisible" ) ) {
165- // letter-navigationはカウント対象外
166- if ( sibling . classList . contains ( "letter-navigation" ) ) break ;
167- visibleCount ++ ;
168- // これ以上カウントする意味がないので抜ける
169- if ( visibleCount >= 10 ) break ;
170- }
171- sibling = sibling . previousElementSibling ;
172- }
173-
174- // 10個以上表示するものがあったら表示する
175- if ( visibleCount >= 10 ) {
176- nav . classList . remove ( "invisible" ) ;
177- } else {
178- nav . classList . add ( "invisible" ) ;
179- }
180- } ) ;
181- }
182-
183-
184101function setupSortableTables ( ) {
185102 document . querySelectorAll ( "table.sortable" ) . forEach ( table => {
186103 const headers = table . querySelectorAll ( "thead th" ) ;
@@ -281,17 +198,7 @@ function zoomFamilyTables(baseTable, baseRow) {
281198// ページ読み込み時のイベント
282199// リスナーの登録はそのページだけでやる
283200document . addEventListener ( "DOMContentLoaded" , function ( ) {
284- if ( document . body . classList . contains ( "glossary" ) ) {
285- document . getElementById ( "search-input" ) . addEventListener ( "input" , updateArticleVisibility ) ;
286- document . getElementById ( "show-empty-description" ) . addEventListener ( "change" , updateArticleVisibility ) ;
287- document . getElementById ( "show-package" ) . addEventListener ( "change" , updateArticleVisibility ) ;
288- document . getElementById ( "show-class" ) . addEventListener ( "change" , updateArticleVisibility ) ;
289- document . getElementById ( "show-method" ) . addEventListener ( "change" , updateArticleVisibility ) ;
290- document . getElementById ( "show-field" ) . addEventListener ( "change" , updateArticleVisibility ) ;
291- document . getElementById ( "show-letter-navigation" ) . addEventListener ( "change" , updateLetterNavigationVisibility ) ;
292-
293- updateLetterNavigationVisibility ( ) ;
294- } else if ( document . body . classList . contains ( "insight" ) ) {
201+ if ( document . body . classList . contains ( "insight" ) ) {
295202 setupSortableTables ( ) ;
296203 setupZoomIcons ( ) ;
297204 document . getElementById ( "cancel-zoom" ) . addEventListener ( "click" , cancelZoom ) ;
0 commit comments