 
 ;; ----- Result table building functions -----
 
-(defn- table-header [label]
-  [:tr [:th.text-center {:colspan 2} label]])
-
 (declare row-for) ; HTML snippet coming later in the namespace
 (defn- table-rows
   "Turn a cljs map into name/value rows in a table with hiccup."

  ;; Bind changes of user selections to update the generated POSTing URL
  (bind ($ "#url-uuid-input") :keyup update-post-url)
  (bind ($ "#url-scheme-input") :change update-post-url)
  (bind ($ "#url-status-input") :change update-post-url))

;; ----- Exported function for the results page -----

(defn ^:export setup-results []
  (doseq [result js/resultData]
    (.append ($ "#results") (result-template result)))
  (.initHighlightingOnLoad js/hljs)) ; syntax highlight the results

;; ----- Hiccup HTML snippets for the results page -----

(defhtml table-header
  "HTML for a table header."
  [label]
  [:tr [:th.text-center {:colspan 2} label]])

(defhtml row-for
  "HTML for a key/value row in a table."
  [key val]
  [:tr [:td key] [:td val]])

(defhtml request-query-string-table
  "Optional HTML table containing query string label and the query string content."
  [result]
  (if-let [query-string (aget result "parsed-query-string")]
    [:table.table.table-bordered.result-table
      [:thead
         (table-header "Query String")]
      [:tbody
        (map-content query-string result)]]))

(defhtml request-body-table
  "Optional HTML for a table containing body label row and the body content that was POSTed."
  [result]
  (if-let [body (aget result "body")]
    [:table.table.table-bordered.result-table
      [:thead
        (table-header "Body")]
      [:tbody
        (map-content body result)]]))

(defhtml request-headers-table
  "HTML for a table with all the HTTP header name/value pairs."
  [result]
  [:table.table.table-bordered.result-table
    [:thead
      [:tr
        [:th.text-center {:colspan 2} "Headers"]]]
    [:tbody
      (table-rows (js->clj (.-headers result)))]])

(defhtml result-metadata
  "HTML for timestamp and status."
  [result]
  [:div
    [:div.clearfix
