 
          :complete (fn []
                      (set! SHORTENING-IN-PROGRESS
-                           (disj SHORTENING-IN-PROGRESS currentUrl)))}))
+                           (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]
+  [$urlShortenerInput localStorage & [actionAfterDone]]
   (fn []
     (let [currentUrl (aget js/document "URL")
           localStorageKey (str "shortUrl-" currentUrl)

    (.mouseenter $copy-to-clipboard get-url-evt-handler)
    ; Change text of qtip when user clicks the copy-to-clipboard <button>
    (.on zcbClient "copy" (fn [] (.set qtipApi "content.text" "Copied!")))
    (qtip-for-sharing-button ($ :#share-by-email) "Share via Email")
    (qtip-for-sharing-button ($ :#share-on-twitter) "Share via Twitter")))

; Main entry point of the program
(defn ^:export init [acad-year sem]

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

(def ^{:doc     "A map of urls that have been sent for shortening, but whose
                 ajax requests have not yet completed.

                 Values are a set of actions to be performed after the url
                 shortening has been done; refer to the
                 `action-after-url-shortening` function for more details on the
                 actions."
       :private true}
  SHORTENING-IN-PROGRESS {})

(defn- add-url-and-action-to-shortening-in-progress
  "Adds a url and its associated action to `SHORTENING-IN-PROGRESS`"
  [url action]
  (set! SHORTENING-IN-PROGRESS
        (update-in SHORTENING-IN-PROGRESS [url]
                   (fn [actionSet]
                     (if (nil? actionSet)
                         #{action}
                         (conj actionSet action))))))

(defn- do-action-after-url-shortening
  "Performs an action after url shortening"
  [shortUrl action]
  (case action
        :email   (aset js/window
                       "location"
                       (str "mailto:?"
                            "subject=My%20cljs-nusmods%20timetable&body="
                            "&body=" (js/encodeURI shortUrl)))
        :twitter nil
        nil      nil))

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