                 $$.addToSaved(line)
                 $$.processSaved(line)
 
-    makeAuthenticationUrl = (state) ->
-        dbx.getAuthenticationUrl(location.href.split("#")[0], state)
-
-    url = makeAuthenticationUrl(path)
-    authenticationLink = "<a href='#{url}'>#{url}</a>"
-
-    ensureDropboxToken = (state) =>
-        authenticationUrl = makeAuthenticationUrl(state)
-
-        promise = new Promise (resolve, reject) ->
-            if not dbx.accessToken
-                window.location = authenticationUrl
-                reject(authenticationUrl)
-
-            # test token with API call
-            dbx.usersGetCurrentAccount()
-                .then (accountData) ->
-                    resolve(accountData)
-                .catch (error) ->
-                    delete localStorage.accessToken
-                    window.location = authenticationUrl
-                    reject(error)
-
-    # User chose not to give access to Dropbox account
-    dropboxAccessDenied = hashKeys.error is 'access_denied'
-    if dropboxAccessDenied
-        path = 'BLANK'
-        log """
-
-            ATTENTION: You chose not to give access to your Dropbox account.
-            To give access later, just follow this link:
-            #{authenticationLink}
-
-            """
-
-
-    openDropboxChooserLink =
-        '<a onclick="dropboxChooser()" >Open Dropbox Chooser</a>'
-
-    expose.dropboxChooser = () ->
-        slog 'dropboxChooser'
-        # Check access token first; this allows a smoother login flow UX
-        # (Likely reduce login screens to one time instead of two)
-        if dbx.accessToken
-            Dropbox.choose options =
-                extensions: textExtensions
-                success: (files) ->
-                    window.location.hash = files[0].link
-        else
-            window.location = makeAuthenticationUrl('CHOOSE')
-
-    loadDropboxPath = (path) ->
-        promise = new Promise (resolve, reject) ->
-
-            options =
-                path: path
-            dropboxApiReady = not dropboxAccessDenied
-            if dropboxApiReady
-                p1 = dbx.filesGetMetadata options
-                p1.then (metaData) =>
-                    # source: http://stackoverflow.com/questions/190852
-                    fileExtension = (fname) ->
-                        fname.substr((~-fname.lastIndexOf(".") >>> 0) + 1)
-
-                    if metaData['.tag'] is 'folder'
-                        log "ERROR: #{path} is a folder. (Not supported)"
-                        history.pushState(null, null, "#BLANK")
-                        dropboxApiReady = false
-
-                    extension = fileExtension(metaData.name).toLowerCase()
-                    if extension not in textExtensions
-                        log "ERROR: File #{path} is not a text file (based on file extension)."
-                        history.pushState(null, null, "#BLANK")
-                        dropboxApiReady = false
-                        spy.name = metaData.name
-
-                    if dropboxApiReady
-                        p2 = dbx.filesDownload options
-
-                        p2.then (fileData) =>
-                            reader = new FileReader()
-
-                            reader.addEventListener 'loadend', () ->
-                                # reader.result contains the contents of blob as a typed array
-                                stringResult = new TextDecoder('utf8').decode(reader.result)
-
-                                data =
-                                    text: stringResult
-                                    rev: metaData.rev
-
-                                resolve(data)
-
-                            reader.readAsArrayBuffer(fileData.fileBlob)
-
-                p1.catch (error) =>
-                    slog error
-                    spy.error = error
-                    switch error.status
-                        when 409  # Path not found
-                            log "ERROR: File #{path} not found on Dropbox."
-                            history.pushState(null, null, "#BLANK")
-                        else
-                            ensureDropboxToken(path).then () ->
-                                log "ERROR: #{error.error} (Status: #{error.status})"
-                                history.pushState(null, null, "#BLANK")
-
     if path is '/' or path is ''
         path = 'WELCOME'
     history.pushState(null, null, "##{path}")

          else
            () -> true




slog = new Proxy(slog, handler(console.log))
sdir = new Proxy(sdir, handler(console.log))


        expose.amplify = amplify

        spy.parseQueryString = parseQueryString

        spy.hashKeys = hashKeys
        spy.path = path

    initPanel()
    exposeVariables()


window.onload = main

