Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | minor cleanups in the /json/wiki/get and AJAJ code. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | json |
Files: | files | file ages | folders |
SHA1: |
a9c8a31df50ab273647c8d5f11e5f183 |
User & Date: | stephan 2011-09-22 16:27:08.692 |
Context
2011-09-22
| ||
17:02 | Added initial prototype of JSON wiki editor (cannot save yet). Minor cleanup in ajax/index.html. ... (check-in: 475c61fd user: stephan tags: json) | |
16:27 | minor cleanups in the /json/wiki/get and AJAJ code. ... (check-in: a9c8a31d user: stephan tags: json) | |
16:21 | Added rudimentary timer to AJAX test page. ... (check-in: 07a2c43c user: stephan tags: json) | |
Changes
Changes to ajax/index.html.
︙ | ︙ | |||
123 124 125 126 127 128 129 | keyup(function(event){ if(event.keyCode == 13){ TheApp.sendRequest(); } }); TheApp.cgi = new FossilAjaj(); | | > | | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | keyup(function(event){ if(event.keyCode == 13){ TheApp.sendRequest(); } }); TheApp.cgi = new FossilAjaj(); TheApp.timer = { _tstart:0,_tend:0,duration:0, start:function(){ this._tstart = (new Date()).getTime(); }, end:function(){ this._tend = (new Date()).getTime(); return this.duration = this._tend - this._tstart; } }; var opt = TheApp.cgi.ajaj.options; opt.beforeSend = function(req,opt) { TheApp.timer.start(); var val = req ? |
︙ | ︙ |
Changes to ajax/js/whajaj.js.
︙ | ︙ | |||
992 993 994 995 996 997 998 999 1000 1001 1002 | /** FIXME: how to handle the error, vis-a-vis- the callbacks, if normalizeAjaxParameters() throws? It can throw if (de)JSON-izing fails. */ var norm = this.normalizeAjaxParameters( WhAjaj.isObject(opt) ? opt : {} ); norm.url = WhAjaj.Connector.sendHelper.normalizeURL(norm); if( WhAjaj.isFunction(norm.beforeSend) ) { norm.beforeSend( request, norm ); } | > < | 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 | /** FIXME: how to handle the error, vis-a-vis- the callbacks, if normalizeAjaxParameters() throws? It can throw if (de)JSON-izing fails. */ var norm = this.normalizeAjaxParameters( WhAjaj.isObject(opt) ? opt : {} ); norm.url = WhAjaj.Connector.sendHelper.normalizeURL(norm); if( ! request ) norm.method = 'GET'; if( WhAjaj.isFunction(norm.beforeSend) ) { norm.beforeSend( request, norm ); } //alert( WhAjaj.stringify(request)+'\n'+WhAjaj.stringify(norm)); try { this.sendImpl( request, norm ); } catch(e) { ex = e; } if(ex) throw ex; }; /** |
︙ | ︙ |
Changes to src/json.c.
︙ | ︙ | |||
929 930 931 932 933 934 935 936 937 938 939 940 941 942 | case 3: modulo = 1000; break; default: break; } if( modulo ) code = code - (code % modulo); return code; } } /* ** Creates a new Fossil/JSON response envelope skeleton. It is owned ** by the caller, who must eventually free it using cson_value_free(), ** or add it to a cson container to transfer ownership. Returns NULL ** on error. ** | > > > > > > > > > > > | 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 | case 3: modulo = 1000; break; default: break; } if( modulo ) code = code - (code % modulo); return code; } } /* ** Convenience routine which converts a Julian time value into a Unix ** Epoch timestamp. Requires the db, so this cannot be used before the ** repo is opened (will trigger a fatal error in db_xxx()). */ static cson_value * json_julian_to_timestamp(double j){ return cson_value_new_integer((cson_int_t) db_int64(0,"SELECT strftime('%%s',%lf)",j) ); } /* ** Creates a new Fossil/JSON response envelope skeleton. It is owned ** by the caller, who must eventually free it using cson_value_free(), ** or add it to a cson container to transfer ownership. Returns NULL ** on error. ** |
︙ | ︙ | |||
1565 1566 1567 1568 1569 1570 1571 | cson_object * pay = cson_value_get_object(payV); cson_object_set(pay,"name",json_new_string(zPageName)); cson_object_set(pay,"version",json_new_string(pWiki->zBaseline)) /*FIXME: pWiki->zBaseline is NULL. How to get the version number?*/ ; cson_object_set(pay,"rid",cson_value_new_integer((cson_int_t)rid)); cson_object_set(pay,"lastSavedBy",json_new_string(pWiki->zUser)); | | < < < < < < < | 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 | cson_object * pay = cson_value_get_object(payV); cson_object_set(pay,"name",json_new_string(zPageName)); cson_object_set(pay,"version",json_new_string(pWiki->zBaseline)) /*FIXME: pWiki->zBaseline is NULL. How to get the version number?*/ ; cson_object_set(pay,"rid",cson_value_new_integer((cson_int_t)rid)); cson_object_set(pay,"lastSavedBy",json_new_string(pWiki->zUser)); cson_object_set(pay,"timestamp", json_julian_to_timestamp(pWiki->rDate)); cson_object_set(pay,"contentLength",cson_value_new_integer((cson_int_t)len)); cson_object_set(pay,"contentFormat",json_new_string(doParse?"html":"raw")); cson_object_set(pay,"content",cson_value_new_string(zBody,len)); /*TODO: add 'T' (tag) fields*/ /*TODO: add the 'A' card (file attachment) entries?*/ manifest_destroy(pWiki); return payV; |
︙ | ︙ |