aboutsummaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/hud.coffee28
1 files changed, 14 insertions, 14 deletions
diff --git a/pages/hud.coffee b/pages/hud.coffee
index a1eef836..3f8eaa93 100644
--- a/pages/hud.coffee
+++ b/pages/hud.coffee
@@ -15,26 +15,26 @@ handlers =
hud.innerText = "/"
inputElement = document.createElement "span"
- inputElement.innerText = data.text
+ inputElement.textContent = data.text
inputElement.id = "hud-find-input"
hud.appendChild inputElement
- updateMatchesCount: ({matchCount, showMatchText}) ->
- inputElement = document.getElementById "hud-find-input"
- return unless inputElement? # Don't do anything if we're not in find mode.
- nodeAfter = inputElement.nextSibling # The node containing the old match text.
+ countElement = document.createElement "span"
+ countElement.id = "hud-match-count"
+ hud.appendChild countElement
- if showMatchText
- plural = if matchCount == 1 then "" else "es"
- countText = if matchCount > 0
- " (" + matchCount + " Match#{plural})"
- else
- " (No matches)"
+ UIComponentServer.postMessage {name: "search", query: inputElement.textContent}
- # Replace the old count (if there was one) with the new one.
- document.getElementById("hud").insertBefore document.createTextNode(countText), nodeAfter
+ updateMatchesCount: ({matchCount, showMatchText}) ->
+ countElement = document.getElementById "hud-match-count"
+ return unless countElement? # Don't do anything if we're not in find mode.
- nodeAfter?.remove() # Remove the old match text.
+ plural = if matchCount == 1 then "" else "es"
+ countText = if matchCount > 0
+ " (" + matchCount + " Match#{plural})"
+ else
+ " (No matches)"
+ countElement.textContent = if showMatchText then countText else ""
UIComponentServer.registerHandler (event) ->
{data} = event