Fossil SCM
Added rudimentary timer to AJAX test page.
Commit
07a2c43c8cc44b6312948dd021067a86a7987815
Parent
7dc8e9ac94fd752…
1 file changed
+26
-9
+26
-9
| --- ajax/index.html | ||
| +++ ajax/index.html | ||
| @@ -101,18 +101,21 @@ | ||
| 101 | 101 | this.animate( { color: 'rgb(' + color + ')' }, duration / 2); |
| 102 | 102 | this.animate( { color: current }, duration / 2 ); |
| 103 | 103 | }; |
| 104 | 104 | |
| 105 | 105 | jQuery(document).ready(function(){ |
| 106 | - var ids = ['textPath', // list of HTML element IDs we use often. | |
| 107 | - 'taResponse', | |
| 108 | - 'taRequest', | |
| 109 | - 'taRequestOpt', | |
| 110 | - 'ajaxNotification', | |
| 111 | - 'responseContainer', | |
| 112 | - 'btnSend', | |
| 113 | - 'currentAuthToken']; | |
| 106 | + var ids = [ | |
| 107 | + 'btnSend', | |
| 108 | + 'ajaxNotification', | |
| 109 | + 'currentAuthToken', | |
| 110 | + 'responseContainer', | |
| 111 | + 'taRequest', | |
| 112 | + 'taRequestOpt', | |
| 113 | + 'taResponse', | |
| 114 | + 'textPath', // list of HTML element IDs we use often. | |
| 115 | + 'timer' | |
| 116 | + ]; | |
| 114 | 117 | var i, k; |
| 115 | 118 | for( i = 0; i < ids.length; ++i ) { |
| 116 | 119 | k = ids[i]; |
| 117 | 120 | TheApp.jqe[k] = jQuery('#'+k); |
| 118 | 121 | } |
| @@ -122,12 +125,22 @@ | ||
| 122 | 125 | TheApp.sendRequest(); |
| 123 | 126 | } |
| 124 | 127 | }); |
| 125 | 128 | |
| 126 | 129 | TheApp.cgi = new FossilAjaj(); |
| 130 | + TheApp.timer = {_tstart:0,_tend:0,duration:0, | |
| 131 | + start:function(){ | |
| 132 | + this._tstart = (new Date()).getTime(); | |
| 133 | + }, | |
| 134 | + end:function(){ | |
| 135 | + this._tend = (new Date()).getTime(); | |
| 136 | + this.duration = this._tend - this._tstart; | |
| 137 | + } | |
| 138 | + }; | |
| 127 | 139 | var opt = TheApp.cgi.ajaj.options; |
| 128 | 140 | opt.beforeSend = function(req,opt) { |
| 141 | + TheApp.timer.start(); | |
| 129 | 142 | var val = |
| 130 | 143 | req ? |
| 131 | 144 | (('string'===typeof req) ? req : WhAjaj.stringify(req)) |
| 132 | 145 | : ''; |
| 133 | 146 | TheApp.jqe.taResponse.val(''); |
| @@ -134,11 +147,13 @@ | ||
| 134 | 147 | TheApp.jqe.taRequest.val( val ); |
| 135 | 148 | TheApp.jqe.taRequestOpt.val( opt ? WhAjaj.stringify(opt) : '' ); |
| 136 | 149 | TheApp.startAjaxNotif(); |
| 137 | 150 | }; |
| 138 | 151 | opt.afterSend = function(req,opt) { |
| 152 | + TheApp.timer.end(); | |
| 139 | 153 | TheApp.endAjaxNotif(); |
| 154 | + TheApp.jqe.timer.text( "(Round-trip time: "+TheApp.timer.duration+'ms)' ); | |
| 140 | 155 | }; |
| 141 | 156 | opt.onResponse = function(resp,req) { |
| 142 | 157 | var val; |
| 143 | 158 | try { |
| 144 | 159 | val = WhAjaj.stringify(resp); |
| @@ -180,10 +195,12 @@ | ||
| 180 | 195 | |
| 181 | 196 | <h2>Request...</h2> |
| 182 | 197 | |
| 183 | 198 | Path: <input type='text' size='40' id='textPath' value='/json/HAI'/> |
| 184 | 199 | <input type='button' value='Send...' id='btnSend' onclick='TheApp.sendRequest()' /><br/> |
| 200 | +If the POST textarea is not empty then it will be posted with the request. | |
| 201 | +<hr/> | |
| 185 | 202 | <strong>Quick-posts:</strong><br/> |
| 186 | 203 | <input type='button' value='HAI' onclick='TheApp.cgi.HAI()' /> |
| 187 | 204 | <input type='button' value='version' onclick='TheApp.cgi.sendCommand("/json/version")' /> |
| 188 | 205 | <input type='button' value='stat' onclick='TheApp.cgi.sendCommand("/json/stat")' /> |
| 189 | 206 | <input type='button' value='whoami' onclick='TheApp.cgi.sendCommand("/json/whoami")' /> |
| @@ -229,11 +246,11 @@ | ||
| 229 | 246 | <textarea id='taRequestOpt' rows='10' cols='40' readonly></textarea> |
| 230 | 247 | |
| 231 | 248 | </td> |
| 232 | 249 | </tr> |
| 233 | 250 | <tr> |
| 234 | - <th colspan='2'>Response</th> | |
| 251 | + <th colspan='2'>Response <span id='timer'></span></th> | |
| 235 | 252 | </tr> |
| 236 | 253 | <tr> |
| 237 | 254 | <td colspan='2' id='responseContainer'> |
| 238 | 255 | <textarea id='taResponse' rows='20' cols='80' readonly></textarea> |
| 239 | 256 | </td> |
| 240 | 257 |
| --- ajax/index.html | |
| +++ ajax/index.html | |
| @@ -101,18 +101,21 @@ | |
| 101 | this.animate( { color: 'rgb(' + color + ')' }, duration / 2); |
| 102 | this.animate( { color: current }, duration / 2 ); |
| 103 | }; |
| 104 | |
| 105 | jQuery(document).ready(function(){ |
| 106 | var ids = ['textPath', // list of HTML element IDs we use often. |
| 107 | 'taResponse', |
| 108 | 'taRequest', |
| 109 | 'taRequestOpt', |
| 110 | 'ajaxNotification', |
| 111 | 'responseContainer', |
| 112 | 'btnSend', |
| 113 | 'currentAuthToken']; |
| 114 | var i, k; |
| 115 | for( i = 0; i < ids.length; ++i ) { |
| 116 | k = ids[i]; |
| 117 | TheApp.jqe[k] = jQuery('#'+k); |
| 118 | } |
| @@ -122,12 +125,22 @@ | |
| 122 | TheApp.sendRequest(); |
| 123 | } |
| 124 | }); |
| 125 | |
| 126 | TheApp.cgi = new FossilAjaj(); |
| 127 | var opt = TheApp.cgi.ajaj.options; |
| 128 | opt.beforeSend = function(req,opt) { |
| 129 | var val = |
| 130 | req ? |
| 131 | (('string'===typeof req) ? req : WhAjaj.stringify(req)) |
| 132 | : ''; |
| 133 | TheApp.jqe.taResponse.val(''); |
| @@ -134,11 +147,13 @@ | |
| 134 | TheApp.jqe.taRequest.val( val ); |
| 135 | TheApp.jqe.taRequestOpt.val( opt ? WhAjaj.stringify(opt) : '' ); |
| 136 | TheApp.startAjaxNotif(); |
| 137 | }; |
| 138 | opt.afterSend = function(req,opt) { |
| 139 | TheApp.endAjaxNotif(); |
| 140 | }; |
| 141 | opt.onResponse = function(resp,req) { |
| 142 | var val; |
| 143 | try { |
| 144 | val = WhAjaj.stringify(resp); |
| @@ -180,10 +195,12 @@ | |
| 180 | |
| 181 | <h2>Request...</h2> |
| 182 | |
| 183 | Path: <input type='text' size='40' id='textPath' value='/json/HAI'/> |
| 184 | <input type='button' value='Send...' id='btnSend' onclick='TheApp.sendRequest()' /><br/> |
| 185 | <strong>Quick-posts:</strong><br/> |
| 186 | <input type='button' value='HAI' onclick='TheApp.cgi.HAI()' /> |
| 187 | <input type='button' value='version' onclick='TheApp.cgi.sendCommand("/json/version")' /> |
| 188 | <input type='button' value='stat' onclick='TheApp.cgi.sendCommand("/json/stat")' /> |
| 189 | <input type='button' value='whoami' onclick='TheApp.cgi.sendCommand("/json/whoami")' /> |
| @@ -229,11 +246,11 @@ | |
| 229 | <textarea id='taRequestOpt' rows='10' cols='40' readonly></textarea> |
| 230 | |
| 231 | </td> |
| 232 | </tr> |
| 233 | <tr> |
| 234 | <th colspan='2'>Response</th> |
| 235 | </tr> |
| 236 | <tr> |
| 237 | <td colspan='2' id='responseContainer'> |
| 238 | <textarea id='taResponse' rows='20' cols='80' readonly></textarea> |
| 239 | </td> |
| 240 |
| --- ajax/index.html | |
| +++ ajax/index.html | |
| @@ -101,18 +101,21 @@ | |
| 101 | this.animate( { color: 'rgb(' + color + ')' }, duration / 2); |
| 102 | this.animate( { color: current }, duration / 2 ); |
| 103 | }; |
| 104 | |
| 105 | jQuery(document).ready(function(){ |
| 106 | var ids = [ |
| 107 | 'btnSend', |
| 108 | 'ajaxNotification', |
| 109 | 'currentAuthToken', |
| 110 | 'responseContainer', |
| 111 | 'taRequest', |
| 112 | 'taRequestOpt', |
| 113 | 'taResponse', |
| 114 | 'textPath', // list of HTML element IDs we use often. |
| 115 | 'timer' |
| 116 | ]; |
| 117 | var i, k; |
| 118 | for( i = 0; i < ids.length; ++i ) { |
| 119 | k = ids[i]; |
| 120 | TheApp.jqe[k] = jQuery('#'+k); |
| 121 | } |
| @@ -122,12 +125,22 @@ | |
| 125 | TheApp.sendRequest(); |
| 126 | } |
| 127 | }); |
| 128 | |
| 129 | TheApp.cgi = new FossilAjaj(); |
| 130 | TheApp.timer = {_tstart:0,_tend:0,duration:0, |
| 131 | start:function(){ |
| 132 | this._tstart = (new Date()).getTime(); |
| 133 | }, |
| 134 | end:function(){ |
| 135 | this._tend = (new Date()).getTime(); |
| 136 | this.duration = this._tend - this._tstart; |
| 137 | } |
| 138 | }; |
| 139 | var opt = TheApp.cgi.ajaj.options; |
| 140 | opt.beforeSend = function(req,opt) { |
| 141 | TheApp.timer.start(); |
| 142 | var val = |
| 143 | req ? |
| 144 | (('string'===typeof req) ? req : WhAjaj.stringify(req)) |
| 145 | : ''; |
| 146 | TheApp.jqe.taResponse.val(''); |
| @@ -134,11 +147,13 @@ | |
| 147 | TheApp.jqe.taRequest.val( val ); |
| 148 | TheApp.jqe.taRequestOpt.val( opt ? WhAjaj.stringify(opt) : '' ); |
| 149 | TheApp.startAjaxNotif(); |
| 150 | }; |
| 151 | opt.afterSend = function(req,opt) { |
| 152 | TheApp.timer.end(); |
| 153 | TheApp.endAjaxNotif(); |
| 154 | TheApp.jqe.timer.text( "(Round-trip time: "+TheApp.timer.duration+'ms)' ); |
| 155 | }; |
| 156 | opt.onResponse = function(resp,req) { |
| 157 | var val; |
| 158 | try { |
| 159 | val = WhAjaj.stringify(resp); |
| @@ -180,10 +195,12 @@ | |
| 195 | |
| 196 | <h2>Request...</h2> |
| 197 | |
| 198 | Path: <input type='text' size='40' id='textPath' value='/json/HAI'/> |
| 199 | <input type='button' value='Send...' id='btnSend' onclick='TheApp.sendRequest()' /><br/> |
| 200 | If the POST textarea is not empty then it will be posted with the request. |
| 201 | <hr/> |
| 202 | <strong>Quick-posts:</strong><br/> |
| 203 | <input type='button' value='HAI' onclick='TheApp.cgi.HAI()' /> |
| 204 | <input type='button' value='version' onclick='TheApp.cgi.sendCommand("/json/version")' /> |
| 205 | <input type='button' value='stat' onclick='TheApp.cgi.sendCommand("/json/stat")' /> |
| 206 | <input type='button' value='whoami' onclick='TheApp.cgi.sendCommand("/json/whoami")' /> |
| @@ -229,11 +246,11 @@ | |
| 246 | <textarea id='taRequestOpt' rows='10' cols='40' readonly></textarea> |
| 247 | |
| 248 | </td> |
| 249 | </tr> |
| 250 | <tr> |
| 251 | <th colspan='2'>Response <span id='timer'></span></th> |
| 252 | </tr> |
| 253 | <tr> |
| 254 | <td colspan='2' id='responseContainer'> |
| 255 | <textarea id='taResponse' rows='20' cols='80' readonly></textarea> |
| 256 | </td> |
| 257 |