aboutsummaryrefslogtreecommitdiffstats
path: root/pages/completion_engines.coffee
blob: 94381fb59da87694665afdbf02236ab37740d245 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
cleanUpRegexp = (re) ->
  re.toString()
    .replace /^\//, ''
    .replace /\/$/, ''
    .replace /\\\//g, "/"

DomUtils.documentReady ->
  html = []
  for engine in CompletionEngines[0...CompletionEngines.length-1]
    engine = new engine
    html.push "<h4>#{engine.constructor.name}</h4>\n"
    html.push "<div class=\"engine\">"
    if engine.regexps
      html.push "<pre>"
      html.push "#{cleanUpRegexp re}\n" for re in engine.regexps
      html.push "</pre>"
    if engine.prefix
      html.push "<p>This uses the general Google completion engine, but adds the prefix \"<tt>#{engine.prefix.trim()}</tt>\" to the query.</p>"
    if engine.exampleSearchUrl and engine.exampleKeyword
      engine.exampleDescription ||= engine.constructor.name
      html.push "<p>"
      html.push "Example:"
      html.push "<pre>"
      html.push "#{engine.exampleKeyword}: #{engine.exampleSearchUrl} #{engine.exampleDescription}"
      html.push "</pre>"
      html.push "</p>"
    html.push "</div>"

  document.getElementById("engineList").innerHTML = html.join ""