            (if (= (aget data "status") 200)
                (let [shortUrl (aget data "shortUrl")]
                  (.val $urlShortenerInput shortUrl)
+                 ; perform actions before setting in localStorage
+                 (doseq [action (get SHORTENING-IN-PROGRESS currentUrl)]
+                   (do-action-after-url-shortening shortUrl action))
                  (.setItem localStorage localStorageKey
                            shortUrl))
+
+               ; else status != 200
                (.val $urlShortenerInput
                      (aget data "message"))))
 

        (initialize-exhibit3 (aget js/window "MODULES")
                             (aget js/window "AUXMODULES")))))

(def ^{:doc     "The set of urls that have been sent for shortening, but whose
                 ajax requests have not yet completed"
       :private true}
  SHORTENING-IN-PROGRESS #{})

(defn- make-request-to-get-short-url
  "Makes the ajax request to the server to obtain a short url"
  [currentUrl $urlShortenerInput localStorage localStorageKey]
  (set! SHORTENING-IN-PROGRESS
        (conj SHORTENING-IN-PROGRESS currentUrl))
  (ajax "/shorten"
        {:data     {:url (js/encodeURI currentUrl)}
         :dataType "json"


         :complete (fn []
                     (set! SHORTENING-IN-PROGRESS
                           (dissoc SHORTENING-IN-PROGRESS currentUrl)))}))

(defn- get-short-url-jq-evt-handler-maker
  "Returns a function suitable for a jQuery event handler; the returned function
   tries to obtain a short url and sets the result in the #url-shortener
   <input>"
  [$urlShortenerInput localStorage & [actionAfterDone]]
  (fn []
    (let [currentUrl (aget js/document "URL")
          localStorageKey (str "shortUrl-" currentUrl)
