@@ -21,6 +21,7 @@ window.onload = function () {
21
21
ScrollSummaryWithWindow ( ) ;
22
22
RunPostProcessOfAllToolsTags ( ) ;
23
23
AsyncCheckForEachSummaryItemVisibility ( ) ;
24
+ CreateTheSearchMarkers ( ) ;
24
25
document . title = document . title + " Doc" ;
25
26
Rainbow . color ( ) ;
26
27
OnScrollSummary ( document . getElementById ( "summary" ) ) ;
@@ -60,6 +61,18 @@ function FillReadProgressBar() {
60
61
}
61
62
62
63
//Function to make summary search bar works
64
+ function CreateTheSearchMarkers ( ) {
65
+ //Create the search markers
66
+ var searchMarkersForSubItems = document . createElement ( "div" ) ;
67
+ searchMarkersForSubItems . setAttribute ( "id" , "summarySearchMarkersForSubItems" ) ;
68
+ searchMarkersForSubItems . setAttribute ( "style" , "display: none;" ) ;
69
+ document . getElementById ( "divider" ) . appendChild ( searchMarkersForSubItems ) ;
70
+
71
+ var searchMarkersForItems = document . createElement ( "div" ) ;
72
+ searchMarkersForItems . setAttribute ( "id" , "summarySearchMarkersForItems" ) ;
73
+ searchMarkersForItems . setAttribute ( "style" , "display: none;" ) ;
74
+ document . getElementById ( "divider" ) . appendChild ( searchMarkersForItems ) ;
75
+ }
63
76
function StartSearchJob ( ) {
64
77
//Change the buttons visibility
65
78
document . getElementById ( "summarySearchStart" ) . style . display = "none" ;
@@ -91,6 +104,8 @@ function StartSearchJob() {
91
104
alreadyAddedListenerToSearchBar = true ;
92
105
93
106
//Do the first call to search job
107
+ document . getElementById ( "summarySearchMarkersForSubItems" ) . setAttribute ( "style" , "display: block;" ) ;
108
+ document . getElementById ( "summarySearchMarkersForItems" ) . setAttribute ( "style" , "display: block;" ) ;
94
109
DoTheSearchJob ( document . getElementById ( "summarySearchBar" ) . getElementsByTagName ( "input" ) [ 0 ] . value . toLocaleLowerCase ( ) ) ;
95
110
}
96
111
function DoTheSearchJob ( searchKeywords ) {
@@ -101,6 +116,11 @@ function DoTheSearchJob(searchKeywords) {
101
116
//Prepare the search results
102
117
var searchResults = 0 ;
103
118
var summarySearchResult = document . getElementById ( "summarySearchResult" ) ;
119
+ var searchResultsForSubItemsPositions = [ ] ;
120
+ var searchResultsForItemsPositions = [ ] ;
121
+ var summarySearchMarkersForSubItems = document . getElementById ( "summarySearchMarkersForSubItems" ) ;
122
+ var summarySearchMarkersForItems = document . getElementById ( "summarySearchMarkersForItems" ) ;
123
+ var summaryTotalHeight = document . getElementById ( "summary" ) . getElementsByTagName ( "ul" ) [ 0 ] . offsetHeight ;
104
124
105
125
//If search keywords is not empty
106
126
if ( searchKeywords != "" ) {
@@ -114,11 +134,13 @@ function DoTheSearchJob(searchKeywords) {
114
134
for ( var i = 0 ; i < allSummarySubItems . length ; i ++ )
115
135
if ( allSummarySubItems [ i ] . innerHTML . toLowerCase ( ) . includes ( searchKeywords ) == true ) {
116
136
allSummarySubItems [ i ] . setAttribute ( "style" , "list-style-type: circle; opacity: 1.0;" ) ;
137
+ searchResultsForSubItemsPositions . push ( allSummarySubItems [ i ] . offsetTop / summaryTotalHeight * 100.0 ) ;
117
138
searchResults += 1 ;
118
139
}
119
140
for ( var i = 0 ; i < allSummaryItems . length ; i ++ )
120
141
if ( allSummaryItems [ i ] . innerHTML . toLowerCase ( ) . includes ( searchKeywords ) == true ) {
121
142
allSummaryItems [ i ] . parentElement . setAttribute ( "style" , "opacity: 1.0;" ) ;
143
+ searchResultsForItemsPositions . push ( allSummaryItems [ i ] . parentElement . offsetTop / summaryTotalHeight * 100.0 ) ;
122
144
searchResults += 1 ;
123
145
}
124
146
}
@@ -130,7 +152,38 @@ function DoTheSearchJob(searchKeywords) {
130
152
allSummaryItems [ i ] . parentElement . removeAttribute ( "style" ) ;
131
153
}
132
154
133
- //Publish the search results
155
+ //Publish the search results in the search markers
156
+ //----- Publish on Search Markers for Summary SubItems -------
157
+ var generatedGradientForSubItems = "linear-gradient(top, transparent 0%," ;
158
+ for ( var i = 0 ; i < searchResultsForSubItemsPositions . length ; i ++ ) {
159
+ //Get the current percent fixed
160
+ var currentPercent = Math . round ( searchResultsForSubItemsPositions [ i ] ) ;
161
+ if ( currentPercent > 100.0 )
162
+ currentPercent = 100.0 ;
163
+ if ( currentPercent < 0.0 )
164
+ currentPercent = 0.0 ;
165
+
166
+ //Add the current percent to backgroud image
167
+ generatedGradientForSubItems += " transparent " + ( currentPercent - 0.5 ) + "%, red " + ( currentPercent - 0.5 ) + "%, red " + currentPercent + "%, transparent " + currentPercent + "%," ;
168
+ }
169
+ generatedGradientForSubItems += " transparent 100%)" ;
170
+ summarySearchMarkersForSubItems . setAttribute ( "style" , "position: absolute; top: 0px; right: 2px; width: 2px; height: 100%; opacity: 0.8; pointer-events: none; background-image: " + generatedGradientForSubItems + "; background-image: -webkit-" + generatedGradientForSubItems + ";" ) ;
171
+ //----- Publish on Search Markers for Summary Items -------
172
+ var generatedGradientForItems = "linear-gradient(top, transparent 0%," ;
173
+ for ( var i = 0 ; i < searchResultsForItemsPositions . length ; i ++ ) {
174
+ //Get the current percent fixed
175
+ var currentPercent = Math . round ( searchResultsForItemsPositions [ i ] ) ;
176
+ if ( currentPercent > 100.0 )
177
+ currentPercent = 100.0 ;
178
+ if ( currentPercent < 0.0 )
179
+ currentPercent = 0.0 ;
180
+
181
+ //Add the current percent to backgroud image
182
+ generatedGradientForItems += " transparent " + ( currentPercent - 0.5 ) + "%, red " + ( currentPercent - 0.5 ) + "%, red " + currentPercent + "%, transparent " + currentPercent + "%," ;
183
+ }
184
+ generatedGradientForItems += " transparent 100%)" ;
185
+ summarySearchMarkersForItems . setAttribute ( "style" , "position: absolute; top: 0px; right: 2px; width: 2px; height: 100%; opacity: 0.8; pointer-events: none; background-image: " + generatedGradientForItems + "; background-image: -webkit-" + generatedGradientForItems + ";" ) ;
186
+ //Publish the search results below search box
134
187
if ( searchResults > 0 ) {
135
188
summarySearchResult . style . opacity = "0.7" ;
136
189
summarySearchResult . innerHTML = "Found " + searchResults + " results" ;
@@ -164,6 +217,8 @@ function FinishSearchJob() {
164
217
165
218
//Do the last call to search job, to reset the summary
166
219
DoTheSearchJob ( "" ) ;
220
+ document . getElementById ( "summarySearchMarkersForSubItems" ) . setAttribute ( "style" , "display: none;" ) ;
221
+ document . getElementById ( "summarySearchMarkersForItems" ) . setAttribute ( "style" , "display: none;" ) ;
167
222
}
168
223
169
224
//Scroll vertically the summary div code
0 commit comments