ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject [2/4] incubator-ponymail git commit: fix indentation and use upvalue to work around inheritance
Date Fri, 02 Sep 2016 20:39:51 GMT
fix indentation and use upvalue to work around inheritance

we need to pass the HTTPRequest object as 'this',
not the xmlHttp object.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/1c126e77
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/1c126e77
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/1c126e77

Branch: refs/heads/coffee-and-cake
Commit: 1c126e775ba5f3a5a1e9a56b466929fdea23ca38
Parents: a20d11d
Author: Daniel Gruno <humbedooh@apache.org>
Authored: Fri Sep 2 22:38:54 2016 +0200
Committer: Daniel Gruno <humbedooh@apache.org>
Committed: Fri Sep 2 22:38:54 2016 +0200

----------------------------------------------------------------------
 site/js/coffee/http_utils.coffee | 60 +++++++++++++++++------------------
 1 file changed, 30 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/1c126e77/site/js/coffee/http_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/http_utils.coffee b/site/js/coffee/http_utils.coffee
index 20daeaa..56d8190 100644
--- a/site/js/coffee/http_utils.coffee
+++ b/site/js/coffee/http_utils.coffee
@@ -37,6 +37,7 @@ pendingURLStatus = () ->
             div = get('loading')
             if not div
                 div = new HTML('div', {
+                    id: 'loading'
                     class: "spinner"
                     },
                     [
@@ -136,40 +137,37 @@ class HTTPRequest
         ### Send data ###
         @request.send(@rdata)
         
-        ### Set onChange behavior ###
-        @request.onreadystatechange = @onchange
         
-        ### all done! ###
-        return this
+        ### Set onChange behavior ###
+        r = this
+        @request.onreadystatechange = () -> r.onchange()
         
-    ### HTTPRequest state change calback ###
     onchange: () ->
-        
-            ### Mark operation as done ###
-            if @request.readyState == 4
-                delete pending_url_operations[@uid]
+        ### Mark operation as done ###
+        if @request.readyState == 4
+            delete pending_url_operations[@uid]
+            
+        ### Internal Server Error: Try to call snap ###
+        if @request.readyState == 4 and @request.status == 500
+            if @snap
+                @snap(@state)
                 
-            ### Internal Server Error: Try to call snap ###
-            if @request.readyState == 4 and @request.status == 500
-                if @snap
-                    @snap(@state)
-                    
-            ### 200 OK, everything is okay, try to parse JSON response ###
-            if @request.readyState == 4 and @request.status == 200
-                if @callback
-                    ### Try to parse as JSON and deal with cache objects, fall back to old
style parse-and-pass ###
-                    try
-                        ### Parse JSON response ###
-                        @response = JSON.parse(@request.responseText)
-                        ### If loginRequired (rare!), redirect to oauth page ###
-                        if @response && @response.loginRequired
-                            location.href = "/oauth.html"
-                            return
-                        ### Otherwise, call the callback function ###
-                        @callback(@response, @state);
-                    #### JSON parse failed? Pass on the response as plain text then ###
-                    catch e
-                        @callback(@request.responseText, @state)
+        ### 200 OK, everything is okay, try to parse JSON response ###
+        if @request.readyState == 4 and @request.status == 200
+            if @callback
+                ### Try to parse as JSON and deal with cache objects, fall back to old style
parse-and-pass ###
+                try
+                    ### Parse JSON response ###
+                    @response = JSON.parse(@request.responseText)
+                    ### If loginRequired (rare!), redirect to oauth page ###
+                    if @response && @response.loginRequired
+                        location.href = "/oauth.html"
+                        return
+                    ### Otherwise, call the callback function ###
+                    @callback(@response, @state);
+                #### JSON parse failed? Pass on the response as plain text then ###
+                catch e
+                    @callback(@request.responseText, @state)
         
     ### Standard form data joiner for POST data ###
     formdata: (kv) ->
@@ -183,3 +181,5 @@ class HTTPRequest
                     ar.push(k + "=" + encodeURIComponent(v))
         ### Join the array with ampersands, so we get "foo=bar&foo2=baz" ###
         return ar.join("&")
+
+pm_snap = null
\ No newline at end of file


Mime
View raw message