close
Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": /usr/lib/python2.7/dist-packages/libsvn/_fs.so: failed to map segment from shared object: Cannot allocate memory). Look in the Trac log for more information.
- Timestamp:
-
Oct 28, 2008, 2:15:00 PM (17 years ago)
- Author:
-
jazz
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
|
v19
|
v20
|
|
| 141 | 141 | // 627 initialize: function(url, options) { |
| 142 | 142 | // |
| | 143 | // 這裡的意思是當 AJAX XmlHttpRequest 完成 get amq.uri 時,執行 amq._pollHandler |
| 143 | 144 | new Ajax.Request(amq.uri, { method: 'get', parameters: 'timeout=0', onSuccess: amq._pollHandler }); |
| 144 | 145 | } |
| 145 | | }}} |
| | 146 | |
| | 147 | _pollHandler: function(request) |
| | 148 | { |
| | 149 | amq.startBatch(); |
| | 150 | try |
| | 151 | { |
| | 152 | amq._messageHandler(request); |
| | 153 | amq._pollEvent(amq._first); |
| | 154 | amq._first=false; |
| | 155 | } |
| | 156 | catch(e) |
| | 157 | { |
| | 158 | alert(e); |
| | 159 | } |
| | 160 | amq.endBatch(); |
| | 161 | |
| | 162 | if (amq._pollDelay>0) |
| | 163 | setTimeout('amq._sendPoll()',amq._pollDelay); |
| | 164 | else |
| | 165 | amq._sendPoll(); |
| | 166 | }, |
| | 167 | |
| | 168 | startBatch: function() |
| | 169 | { |
| | 170 | amq._queueMessages++; |
| | 171 | }, |
| | 172 | |
| | 173 | _messageHandler: function(request) |
| | 174 | { |
| | 175 | try |
| | 176 | { |
| | 177 | if (request.status == 200) |
| | 178 | { |
| | 179 | var response = request.responseXML.getElementsByTagName("ajax-response"); |
| | 180 | if (response != null && response.length == 1) |
| | 181 | { |
| | 182 | for ( var i = 0 ; i < response[0].childNodes.length ; i++ ) |
| | 183 | { |
| | 184 | var responseElement = response[0].childNodes[i]; |
| | 185 | |
| | 186 | // only process nodes of type element..... |
| | 187 | if ( responseElement.nodeType != 1 ) |
| | 188 | continue; |
| | 189 | |
| | 190 | var id = responseElement.getAttribute('id'); |
| | 191 | |
| | 192 | |
| | 193 | var handler = amq._handlers[id]; |
| | 194 | if (handler!=null) |
| | 195 | { |
| | 196 | for (var j = 0; j < responseElement.childNodes.length; j++) |
| | 197 | { |
| | 198 | handler(responseElement.childNodes[j]); |
| | 199 | } |
| | 200 | } |
| | 201 | } |
| | 202 | } |
| | 203 | } |
| | 204 | } |
| | 205 | catch(e) |
| | 206 | { |
| | 207 | alert(e); |
| | 208 | } |
| | 209 | }, |
| | 210 | |
| | 211 | endBatch: function() |
| | 212 | { |
| | 213 | amq._queueMessages--; |
| | 214 | if (amq._queueMessages==0 && amq._messages>0) |
| | 215 | { |
| | 216 | var body = amq._messageQueue; |
| | 217 | amq._messageQueue=''; |
| | 218 | amq._messages=0; |
| | 219 | amq._queueMessages++; |
| | 220 | new Ajax.Request(amq.uri, { method: 'post', postBody: body, onSuccess: amq.endBatch}); |
| | 221 | } |
| | 222 | }, |
| | 223 | }}} |