@@ -8,17 +8,18 @@ import scala.concurrent.duration._
8
8
class SearchbarComponent (engine : SearchbarEngine , inkuireEngine : InkuireJSSearchEngine , parser : QueryParser ):
9
9
val resultsChunkSize = 100
10
10
extension (p : PageEntry )
11
- def toHTML ( inkuire : Boolean = false ) =
11
+ def toHTML =
12
12
val wrapper = document.createElement(" div" ).asInstanceOf [html.Div ]
13
13
wrapper.classList.add(" scaladoc-searchbar-result" )
14
+ wrapper.classList.add(" scaladoc-searchbar-result-row" )
14
15
wrapper.classList.add(" monospace" )
15
16
16
17
val icon = document.createElement(" span" ).asInstanceOf [html.Span ]
17
18
icon.classList.add(" micon" )
18
19
icon.classList.add(p.kind.take(2 ))
19
20
20
21
val resultA = document.createElement(" a" ).asInstanceOf [html.Anchor ]
21
- resultA.href = if inkuire then p.location else Globals .pathToRoot + p.location
22
+ resultA.href = Globals .pathToRoot + p.location
22
23
resultA.text = s " ${p.fullName}"
23
24
24
25
val location = document.createElement(" span" )
@@ -34,8 +35,52 @@ class SearchbarComponent(engine: SearchbarEngine, inkuireEngine: InkuireJSSearch
34
35
})
35
36
wrapper
36
37
38
+ extension (m : InkuireMatch )
39
+ def toHTML =
40
+ val wrapper = document.createElement(" div" ).asInstanceOf [html.Div ]
41
+ wrapper.classList.add(" scaladoc-searchbar-result" )
42
+ wrapper.classList.add(" monospace" )
43
+
44
+ val resultDiv = document.createElement(" div" ).asInstanceOf [html.Div ]
45
+ resultDiv.classList.add(" scaladoc-searchbar-result-row" )
46
+
47
+ val icon = document.createElement(" span" ).asInstanceOf [html.Span ]
48
+ icon.classList.add(" micon" )
49
+ icon.classList.add(m.entryType.take(2 ))
50
+
51
+ val resultA = document.createElement(" a" ).asInstanceOf [html.Anchor ]
52
+ resultA.href = m.pageLocation
53
+ resultA.text = m.functionName
54
+
55
+ val packageDiv = document.createElement(" div" ).asInstanceOf [html.Div ]
56
+ packageDiv.classList.add(" scaladoc-searchbar-inkuire-package" )
57
+
58
+ val packageIcon = document.createElement(" span" ).asInstanceOf [html.Span ]
59
+ packageIcon.classList.add(" micon" )
60
+ packageIcon.classList.add(" pa" )
61
+
62
+ val packageSpan = document.createElement(" span" ).asInstanceOf [html.Span ]
63
+ packageSpan.textContent = m.packageLocation
64
+
65
+ val signature = document.createElement(" span" )
66
+ signature.classList.add(" pull-right" )
67
+ signature.classList.add(" scaladoc-searchbar-inkuire-signature" )
68
+ signature.textContent = m.prettifiedSignature
69
+
70
+ wrapper.appendChild(resultDiv)
71
+ resultDiv.appendChild(icon)
72
+ resultDiv.appendChild(resultA)
73
+ resultA.appendChild(signature)
74
+ wrapper.appendChild(packageDiv)
75
+ packageDiv.appendChild(packageIcon)
76
+ packageDiv.appendChild(packageSpan)
77
+ wrapper.addEventListener(" mouseover" , {
78
+ case e : MouseEvent => handleHover(wrapper)
79
+ })
80
+ wrapper
81
+
37
82
def handleNewFluffQuery (matchers : List [Matchers ]) =
38
- val result = engine.query(matchers).map(_.toHTML(inkuire = false ) )
83
+ val result = engine.query(matchers).map(_.toHTML)
39
84
resultsDiv.scrollTop = 0
40
85
while (resultsDiv.hasChildNodes()) resultsDiv.removeChild(resultsDiv.lastChild)
41
86
val fragment = document.createDocumentFragment()
@@ -86,8 +131,8 @@ class SearchbarComponent(engine: SearchbarEngine, inkuireEngine: InkuireJSSearch
86
131
animation.classList.add(" loading" )
87
132
loading.appendChild(animation)
88
133
properResultsDiv.appendChild(loading)
89
- inkuireEngine.query(query) { (p : PageEntry ) =>
90
- properResultsDiv.appendChild(p .toHTML(inkuire = true ) )
134
+ inkuireEngine.query(query) { (m : InkuireMatch ) =>
135
+ properResultsDiv.appendChild(m .toHTML)
91
136
} { (s : String ) =>
92
137
animation.classList.remove(" loading" )
93
138
properResultsDiv.appendChild(s.toHTMLError)
0 commit comments