From fc39f233d77e1cfbf47e076736809bf789147574 Mon Sep 17 00:00:00 2001 From: dbs Date: Thu, 18 Oct 2007 17:24:00 +0000 Subject: [PATCH] This commit breaks compatibility with OpenSRF 0.9. Removes JSON.js copies from EG trunk. JSON_v0.js (legacy JSON) and JSON_v1.js (modern JSON) are copied from the installed OpenSRF javascript libs. ScriptRunner.pm no longer loads another copy of JSON.js from . All Evergreen files now use modern JSON (JSON_v1.js). git-svn-id: svn://svn.open-ils.org/ILS/trunk@7894 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/server/patron/ue.xhtml | 2 +- Open-ILS/examples/opensrf.xml.example | 4 + Open-ILS/src/Makefile | 1 + .../backend/catalog/biblio_descriptor.js | 1 + .../backend/catalog/biblio_fingerprint.js | 1 + .../javascript/backend/catalog/record_type.js | 1 + .../javascript/backend/circ/circ_duration.js | 1 + .../backend/circ/circ_item_config.js | 1 + .../src/javascript/backend/circ/circ_lib.js | 1 + .../backend/circ/circ_permit_copy.js | 1 + .../backend/circ/circ_permit_hold.js | 1 + .../backend/circ/circ_permit_patron.js | 1 + .../backend/circ/circ_permit_renew.js | 1 + Open-ILS/src/javascript/backend/libs/JSON.js | 136 ---------------- .../backend/libs/jsonopensrfrequest.js | 2 +- .../backend/penalty/patron_penalty.js | 1 + .../perlmods/OpenILS/Utils/ScriptRunner.pm | 146 +----------------- Open-ILS/src/reporter/templates/header.ttk | 2 +- Open-ILS/web/opac/common/js/JSON.js | 140 ----------------- Open-ILS/xul/staff_client/Makefile | 2 + .../server/OpenILS/util_overlay.xul | 2 +- .../server/admin/cash_reports.xhtml | 2 +- .../server/admin/closed_dates.xhtml | 2 +- .../server/admin/copy_locations.xhtml | 2 +- .../server/admin/hold_pull_list.xhtml | 2 +- .../server/admin/hold_pull_list_classic.xhtml | 2 +- .../server/admin/non_cat_types.xhtml | 2 +- .../server/admin/org_settings.xhtml | 2 +- .../server/admin/printer_settings.html | 2 +- .../server/admin/stat_cat_editor.xhtml | 2 +- .../server/admin/upload_xacts.xhtml | 2 +- .../xul/staff_client/server/patron/ue.xhtml | 2 +- .../staff_client/server/patron/user_edit.xml | 2 +- .../server/patron/user_editor.xhtml | 2 +- 34 files changed, 37 insertions(+), 437 deletions(-) delete mode 100644 Open-ILS/src/javascript/backend/libs/JSON.js delete mode 100644 Open-ILS/web/opac/common/js/JSON.js diff --git a/Evergreen/xul/staff_client/server/patron/ue.xhtml b/Evergreen/xul/staff_client/server/patron/ue.xhtml index bdbefc0d60..e3cecf3273 100644 --- a/Evergreen/xul/staff_client/server/patron/ue.xhtml +++ b/Evergreen/xul/staff_client/server/patron/ue.xhtml @@ -16,7 +16,7 @@ - + diff --git a/Open-ILS/examples/opensrf.xml.example b/Open-ILS/examples/opensrf.xml.example index 9c77656af6..7239f46e09 100644 --- a/Open-ILS/examples/opensrf.xml.example +++ b/Open-ILS/examples/opensrf.xml.example @@ -377,6 +377,7 @@ Example opensrf config file for OpenILS penalty/patron_penalty.js + /openils/lib/javascript /openils/var /openils/var/catalog @@ -404,6 +405,7 @@ Example opensrf config file for OpenILS + /openils/lib/javascript /openils/var /openils/var/catalog @@ -494,6 +496,7 @@ Example opensrf config file for OpenILS 5 + /openils/lib/javascript/ /openils/var/catalog/ /openils/var/web/opac/common/js/ @@ -519,6 +522,7 @@ Example opensrf config file for OpenILS 5 + /openils/lib/javascript/ /openils/var/catalog/ biblio_fingerprint.js diff --git a/Open-ILS/src/Makefile b/Open-ILS/src/Makefile index 70141570ec..fdf8080497 100644 --- a/Open-ILS/src/Makefile +++ b/Open-ILS/src/Makefile @@ -70,6 +70,7 @@ webcore-install: mkdir -p $(WEBDIR) mkdir -p $(WEBDIR)/opac/extras/xsl/ cp -r ../web/* $(WEBDIR) + cp $(OPENSRF_LIBS)/javascript/* $(WEBDIR)/opac/common/js/ ln -sf $(WEBDIR)/opac/skin/default/xml/index.xml $(WEBDIR)/opac/skin/default/xml/mresult.xml ln -sf $(WEBDIR)/opac/skin/default/xml/index.xml $(WEBDIR)/opac/skin/default/xml/rresult.xml ln -sf $(WEBDIR)/opac/skin/default/xml/index.xml $(WEBDIR)/opac/skin/default/xml/rdetail.xml diff --git a/Open-ILS/src/javascript/backend/catalog/biblio_descriptor.js b/Open-ILS/src/javascript/backend/catalog/biblio_descriptor.js index fb2b9aa0d0..492882d27d 100644 --- a/Open-ILS/src/javascript/backend/catalog/biblio_descriptor.js +++ b/Open-ILS/src/javascript/backend/catalog/biblio_descriptor.js @@ -2,6 +2,7 @@ load_lib('fmall.js'); load_lib('fmgen.js'); load_lib('record_type.js'); +load_lib('JSON_v1.js'); var marcdoc = new XML(environment.marc); var marc_ns = new Namespace('http://www.loc.gov/MARC21/slim'); diff --git a/Open-ILS/src/javascript/backend/catalog/biblio_fingerprint.js b/Open-ILS/src/javascript/backend/catalog/biblio_fingerprint.js index 15b991e0ff..83992c239c 100644 --- a/Open-ILS/src/javascript/backend/catalog/biblio_fingerprint.js +++ b/Open-ILS/src/javascript/backend/catalog/biblio_fingerprint.js @@ -1,5 +1,6 @@ // so we can tell if it's a book or other type load_lib('record_type.js'); +load_lib('JSON_v1.js'); environment.result = {}; diff --git a/Open-ILS/src/javascript/backend/catalog/record_type.js b/Open-ILS/src/javascript/backend/catalog/record_type.js index edb7ccb795..0a6988b734 100644 --- a/Open-ILS/src/javascript/backend/catalog/record_type.js +++ b/Open-ILS/src/javascript/backend/catalog/record_type.js @@ -1,6 +1,7 @@ // Constants ... load_lib('phys_char.js'); load_lib('fixed_fields.js'); +load_lib('JSON_v1.js'); function recordType (rec) { diff --git a/Open-ILS/src/javascript/backend/circ/circ_duration.js b/Open-ILS/src/javascript/backend/circ/circ_duration.js index 55468ab128..6f6a3d4b34 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_duration.js +++ b/Open-ILS/src/javascript/backend/circ/circ_duration.js @@ -1,6 +1,7 @@ function go(){ load_lib('circ/circ_item_config.js'); +load_lib('JSON_v1.js'); log_vars('circ_duration'); diff --git a/Open-ILS/src/javascript/backend/circ/circ_item_config.js b/Open-ILS/src/javascript/backend/circ/circ_item_config.js index cc0795123f..9cfd9463ee 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_item_config.js +++ b/Open-ILS/src/javascript/backend/circ/circ_item_config.js @@ -1,4 +1,5 @@ load_lib('circ/circ_lib.js'); +load_lib('JSON_v1.js'); log_debug('loading circ_item_config.js ...'); diff --git a/Open-ILS/src/javascript/backend/circ/circ_lib.js b/Open-ILS/src/javascript/backend/circ/circ_lib.js index acf80aa727..5cad8b40c9 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_lib.js +++ b/Open-ILS/src/javascript/backend/circ/circ_lib.js @@ -1,5 +1,6 @@ load_lib('catalog/record_type.js'); load_lib('circ/circ_groups.js'); +load_lib('JSON_v1.js'); try { diff --git a/Open-ILS/src/javascript/backend/circ/circ_permit_copy.js b/Open-ILS/src/javascript/backend/circ/circ_permit_copy.js index a08e897438..6043e5fe65 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_permit_copy.js +++ b/Open-ILS/src/javascript/backend/circ/circ_permit_copy.js @@ -2,6 +2,7 @@ function go() { /* load the lib script */ load_lib('circ/circ_lib.js'); +load_lib('JSON_v1.js'); log_vars('circ_permit_copy'); diff --git a/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js b/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js index 2474a5e808..142c0527bb 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js +++ b/Open-ILS/src/javascript/backend/circ/circ_permit_hold.js @@ -1,6 +1,7 @@ function go() { load_lib('circ/circ_lib.js'); +load_lib('JSON_v1.js'); log_vars('circ_permit_hold'); diff --git a/Open-ILS/src/javascript/backend/circ/circ_permit_patron.js b/Open-ILS/src/javascript/backend/circ/circ_permit_patron.js index da6f71917e..95496884a2 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_permit_patron.js +++ b/Open-ILS/src/javascript/backend/circ/circ_permit_patron.js @@ -2,6 +2,7 @@ function go() { /* load the script library */ load_lib('circ/circ_lib.js'); +load_lib('JSON_v1.js'); log_vars('circ_permit_patron'); diff --git a/Open-ILS/src/javascript/backend/circ/circ_permit_renew.js b/Open-ILS/src/javascript/backend/circ/circ_permit_renew.js index aca8de0e9e..2eaac55278 100644 --- a/Open-ILS/src/javascript/backend/circ/circ_permit_renew.js +++ b/Open-ILS/src/javascript/backend/circ/circ_permit_renew.js @@ -2,6 +2,7 @@ function go() { /* load the lib script */ load_lib('circ/circ_lib.js'); +load_lib('JSON_v1.js'); log_vars('circ_permit_renew'); } go(); diff --git a/Open-ILS/src/javascript/backend/libs/JSON.js b/Open-ILS/src/javascript/backend/libs/JSON.js deleted file mode 100644 index 1f7b805e3e..0000000000 --- a/Open-ILS/src/javascript/backend/libs/JSON.js +++ /dev/null @@ -1,136 +0,0 @@ -// in case we run on an implimentation that doesn't have "undefined"; -var undefined; - -function Cast (obj, class_constructor) { - try { - if (eval(class_constructor + '["_isfieldmapper"]')) { - obj = eval("new " + class_constructor + "(obj)"); - } - } catch( E ) { - alert( E + "\n"); - } finally { - return obj; - } -} - -function JSON2js (json) { - - json = String(json).replace( /\/\*--\s*S\w*?\s*?\s+\w+\s*--\*\//g, 'Cast('); - json = String(json).replace( /\/\*--\s*E\w*?\s*?\s+(\w+)\s*--\*\//g, ', "$1")'); - - var obj; - if (json != '') { - try { - eval( 'obj = ' + json ); - } catch(E) { - debug("Error building JSON object with string " + E + "\nString:\n" + json ); - return null; - } - } - return obj; -} - - -function object2Array(obj) { - if( obj == null ) return null; - - var arr = new Array(); - for( var i = 0; i < obj.length; i++ ) { - arr[i] = obj[i]; - } - return arr; -} - - -function js2JSON(arg) { - return _js2JSON(arg); -} - -function _js2JSON(arg) { - var i, o, u, v; - - switch (typeof arg) { - case 'object': - - if(arg) { - - if (arg._isfieldmapper) { /* magi-c-ast for fieldmapper objects */ - - if( arg.a.constructor != Array ) { - var arr = new Array(); - for( var i = 0; i < arg.a.length; i++ ) { - if( arg.a[i] == null ) { - arr[i] = null; continue; - } - - if( typeof arg.a[i] != 'object' ) { - arr[i] = arg.a[i]; - - } else if( typeof arg.a[i] == 'object' - && arg.a[i]._isfieldmapper) { - - arr[i] = arg.a[i]; - - } else { - arr[i] = object2Array(arg.a[i]); - } - } - arg.a = arr; - } - - return "/*--S " + arg.classname + " --*/" + js2JSON(arg.a) + "/*--E " + arg.classname + " --*/"; - - } else { - - if (arg.constructor == Array) { - o = ''; - for (i = 0; i < arg.length; ++i) { - v = js2JSON(arg[i]); - if (o) { - o += ','; - } - if (v !== u) { - o += v; - } else { - o += 'null'; - } - } - return '[' + o + ']'; - - } else if (typeof arg.toString != 'undefined') { - o = ''; - for (i in arg) { - v = js2JSON(arg[i]); - if (v !== u) { - if (o) { - o += ','; - } - o += js2JSON(i) + ':' + v; - } - } - - o = '{' + o + '}'; - return o; - - } else { - return; - } - } - } - return 'null'; - - case 'unknown': - case 'number': - if( isNaN(arg) ) throw "JSON.js encountered NaN in js2JSON()"; - return arg; - - case 'undefined': - case 'function': - return u; - - case 'string': - default: - return '"' + String(arg).replace(/(["\\])/g, '\\$1') + '"'; - } - -} diff --git a/Open-ILS/src/javascript/backend/libs/jsonopensrfrequest.js b/Open-ILS/src/javascript/backend/libs/jsonopensrfrequest.js index fd9a8d1796..7f2de1d06b 100644 --- a/Open-ILS/src/javascript/backend/libs/jsonopensrfrequest.js +++ b/Open-ILS/src/javascript/backend/libs/jsonopensrfrequest.js @@ -1,6 +1,6 @@ try { load_lib('jsOO.js'); - load_lib('JSON.js'); + load_lib('JSON_v1.js'); } catch (e) {} var __jsonopensrfreqid = 1; diff --git a/Open-ILS/src/javascript/backend/penalty/patron_penalty.js b/Open-ILS/src/javascript/backend/penalty/patron_penalty.js index f297a57dc6..07ed2ee9b1 100644 --- a/Open-ILS/src/javascript/backend/penalty/patron_penalty.js +++ b/Open-ILS/src/javascript/backend/penalty/patron_penalty.js @@ -2,6 +2,7 @@ function go() { /* load the lib script */ load_lib('circ/circ_lib.js'); +load_lib('JSON_v1.js'); log_vars('patron_penalty'); var config = findGroupConfig(patronProfile); diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/ScriptRunner.pm b/Open-ILS/src/perlmods/OpenILS/Utils/ScriptRunner.pm index 42353d2b7b..72265f6f67 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/ScriptRunner.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/ScriptRunner.pm @@ -7,9 +7,7 @@ use JavaScript::SpiderMonkey; use LWP::UserAgent; use XML::LibXML; use Time::HiRes qw/time/; -use vars qw/%_paths $__json_js/; - -{ local $/ = undef; $__json_js = ; } +use vars qw/%_paths/; sub DESTROY { my $self = shift; @@ -176,7 +174,7 @@ sub run { if ($_real) { $self->insert('__' => {'OILS_RESULT' => ''}); - $js->eval($__json_js."__.OILS_RESULT = js2JSON(environment.result);"); + $js->eval("__.OILS_RESULT = js2JSON(environment.result);"); $res = $self->retrieve('__.OILS_RESULT'); } } @@ -599,143 +597,3 @@ sub _JS_DOM { 1; - -__DATA__ - -// in case we run on an implimentation that doesn't have "undefined"; -var undefined; - -function Cast (obj, class_constructor) { - try { - if (eval(class_constructor + '["_isfieldmapper"]')) { - obj = eval("new " + class_constructor + "(obj)"); - } - } catch( E ) { - alert( E + "\n"); - } finally { - return obj; - } -} - -function JSON2js (json) { - - json = String(json).replace( /\/\*--\s*S\w*?\s*?\s+\w+\s*--\*\//g, 'Cast('); - json = String(json).replace( /\/\*--\s*E\w*?\s*?\s+(\w+)\s*--\*\//g, ', "$1")'); - - var obj; - if (json != '') { - try { - eval( 'obj = ' + json ); - } catch(E) { - debug("Error building JSON object with string " + E + "\nString:\n" + json ); - return null; - } - } - return obj; -} - - -function object2Array(obj) { - if( obj == null ) return null; - - var arr = new Array(); - for( var i = 0; i < obj.length; i++ ) { - arr[i] = obj[i]; - } - return arr; -} - - -function js2JSON(arg) { - return _js2JSON(arg); -} - -function _js2JSON(arg) { - var i, o, u, v; - - switch (typeof arg) { - case 'object': - - if(arg) { - - if (arg._isfieldmapper) { /* magi-c-ast for fieldmapper objects */ - - if( arg.a.constructor != Array ) { - var arr = new Array(); - for( var i = 0; i < arg.a.length; i++ ) { - if( arg.a[i] == null ) { - arr[i] = null; continue; - } - - if( typeof arg.a[i] != 'object' ) { - arr[i] = arg.a[i]; - - } else if( typeof arg.a[i] == 'object' - && arg.a[i]._isfieldmapper) { - - arr[i] = arg.a[i]; - - } else { - arr[i] = object2Array(arg.a[i]); - } - } - arg.a = arr; - } - - return "/*--S " + arg.classname + " --*/" + js2JSON(arg.a) + "/*--E " + arg.classname + " --*/"; - - } else { - - if (arg.constructor == Array) { - o = ''; - for (i = 0; i < arg.length; ++i) { - v = js2JSON(arg[i]); - if (o) { - o += ','; - } - if (v !== u) { - o += v; - } else { - o += 'null'; - } - } - return '[' + o + ']'; - - } else if (typeof arg.toString != 'undefined') { - o = ''; - for (i in arg) { - v = js2JSON(arg[i]); - if (v !== u) { - if (o) { - o += ','; - } - o += js2JSON(i) + ':' + v; - } - } - - o = '{' + o + '}'; - return o; - - } else { - return; - } - } - } - return 'null'; - - case 'unknown': - case 'number': - if( isNaN(arg) ) throw "JSON.js encountered NaN in js2JSON()"; - return arg; - - case 'undefined': - case 'function': - return u; - - case 'string': - default: - return '"' + String(arg).replace(/(["\\])/g, '\\$1') + '"'; - } - -} - diff --git a/Open-ILS/src/reporter/templates/header.ttk b/Open-ILS/src/reporter/templates/header.ttk index 93ca9c30ae..8714e0d9b9 100644 --- a/Open-ILS/src/reporter/templates/header.ttk +++ b/Open-ILS/src/reporter/templates/header.ttk @@ -7,7 +7,7 @@ - + - + diff --git a/Open-ILS/xul/staff_client/server/admin/closed_dates.xhtml b/Open-ILS/xul/staff_client/server/admin/closed_dates.xhtml index 9bcc84249b..ec96cc6f5c 100644 --- a/Open-ILS/xul/staff_client/server/admin/closed_dates.xhtml +++ b/Open-ILS/xul/staff_client/server/admin/closed_dates.xhtml @@ -8,7 +8,7 @@ - + diff --git a/Open-ILS/xul/staff_client/server/admin/copy_locations.xhtml b/Open-ILS/xul/staff_client/server/admin/copy_locations.xhtml index 133c995efc..207eb20657 100644 --- a/Open-ILS/xul/staff_client/server/admin/copy_locations.xhtml +++ b/Open-ILS/xul/staff_client/server/admin/copy_locations.xhtml @@ -8,7 +8,7 @@ - + diff --git a/Open-ILS/xul/staff_client/server/admin/hold_pull_list.xhtml b/Open-ILS/xul/staff_client/server/admin/hold_pull_list.xhtml index b7213303bf..082af821af 100644 --- a/Open-ILS/xul/staff_client/server/admin/hold_pull_list.xhtml +++ b/Open-ILS/xul/staff_client/server/admin/hold_pull_list.xhtml @@ -16,7 +16,7 @@ - + diff --git a/Open-ILS/xul/staff_client/server/admin/hold_pull_list_classic.xhtml b/Open-ILS/xul/staff_client/server/admin/hold_pull_list_classic.xhtml index d10133ce7a..48fd2d3009 100644 --- a/Open-ILS/xul/staff_client/server/admin/hold_pull_list_classic.xhtml +++ b/Open-ILS/xul/staff_client/server/admin/hold_pull_list_classic.xhtml @@ -16,7 +16,7 @@ - + diff --git a/Open-ILS/xul/staff_client/server/admin/non_cat_types.xhtml b/Open-ILS/xul/staff_client/server/admin/non_cat_types.xhtml index 5e53675a60..4e3c64cbc6 100644 --- a/Open-ILS/xul/staff_client/server/admin/non_cat_types.xhtml +++ b/Open-ILS/xul/staff_client/server/admin/non_cat_types.xhtml @@ -8,7 +8,7 @@ - + diff --git a/Open-ILS/xul/staff_client/server/admin/org_settings.xhtml b/Open-ILS/xul/staff_client/server/admin/org_settings.xhtml index aefbf5481b..19cb0ed8d6 100644 --- a/Open-ILS/xul/staff_client/server/admin/org_settings.xhtml +++ b/Open-ILS/xul/staff_client/server/admin/org_settings.xhtml @@ -8,7 +8,7 @@ - + diff --git a/Open-ILS/xul/staff_client/server/admin/printer_settings.html b/Open-ILS/xul/staff_client/server/admin/printer_settings.html index fdb05b3070..9c559f2e84 100644 --- a/Open-ILS/xul/staff_client/server/admin/printer_settings.html +++ b/Open-ILS/xul/staff_client/server/admin/printer_settings.html @@ -3,7 +3,7 @@ - + diff --git a/Open-ILS/xul/staff_client/server/admin/stat_cat_editor.xhtml b/Open-ILS/xul/staff_client/server/admin/stat_cat_editor.xhtml index b4be9861cd..d84f22db0a 100644 --- a/Open-ILS/xul/staff_client/server/admin/stat_cat_editor.xhtml +++ b/Open-ILS/xul/staff_client/server/admin/stat_cat_editor.xhtml @@ -8,7 +8,7 @@ - + diff --git a/Open-ILS/xul/staff_client/server/admin/upload_xacts.xhtml b/Open-ILS/xul/staff_client/server/admin/upload_xacts.xhtml index d3c13f8bc4..c0f553ed86 100644 --- a/Open-ILS/xul/staff_client/server/admin/upload_xacts.xhtml +++ b/Open-ILS/xul/staff_client/server/admin/upload_xacts.xhtml @@ -19,7 +19,7 @@ - + diff --git a/Open-ILS/xul/staff_client/server/patron/user_edit.xml b/Open-ILS/xul/staff_client/server/patron/user_edit.xml index f06d5cfa4e..2b5411feb8 100644 --- a/Open-ILS/xul/staff_client/server/patron/user_edit.xml +++ b/Open-ILS/xul/staff_client/server/patron/user_edit.xml @@ -9,7 +9,7 @@ - + diff --git a/Open-ILS/xul/staff_client/server/patron/user_editor.xhtml b/Open-ILS/xul/staff_client/server/patron/user_editor.xhtml index 50dfc7eb2d..5dd240979b 100644 --- a/Open-ILS/xul/staff_client/server/patron/user_editor.xhtml +++ b/Open-ILS/xul/staff_client/server/patron/user_editor.xhtml @@ -17,7 +17,7 @@ - + -- 2.43.2