explicit number casting for JSON results
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 8 Mar 2008 07:55:15 +0000 (07:55 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 8 Mar 2008 07:55:15 +0000 (07:55 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@8923 dcc99617-32d9-48b4-a31d-7c20da2025e4

14 files changed:
Open-ILS/xul/staff_client/chrome/content/auth/session.js
Open-ILS/xul/staff_client/server/cat/copy_browser.js
Open-ILS/xul/staff_client/server/cat/copy_buckets.js
Open-ILS/xul/staff_client/server/cat/copy_editor.js
Open-ILS/xul/staff_client/server/cat/copy_summary.xul
Open-ILS/xul/staff_client/server/cat/z3950.js
Open-ILS/xul/staff_client/server/circ/copy_status.js
Open-ILS/xul/staff_client/server/circ/in_house_use.js
Open-ILS/xul/staff_client/server/main/ws_info.xul
Open-ILS/xul/staff_client/server/patron/bill_details.xul
Open-ILS/xul/staff_client/server/patron/bill_history.xul
Open-ILS/xul/staff_client/server/patron/bills.js
Open-ILS/xul/staff_client/server/patron/holds.js
Open-ILS/xul/staff_client/server/patron/items.js

index 363d318..db1cff8 100644 (file)
@@ -47,7 +47,7 @@ auth.session.prototype = {
 
                                var robj = this.network.simple_request( 'AUTH_COMPLETE', [ params ]);
 
-                               switch (robj.ilsevent) {
+                               switch (Number(robj.ilsevent)) {
                                        case 0:
                                                this.key = robj.payload.authtoken;
                                                this.authtime = robj.payload.authtime;
index ec56a84..f6e8796 100644 (file)
@@ -547,7 +547,7 @@ cat.copy_browser.prototype = {
                                                                                        [ ses(), volumes, true ]
                                                                                );
                                                                                if (typeof r.ilsevent != 'undefined') {
-                                            switch(r.ilsevent) {
+                                            switch(Number(r.ilsevent)) {
                                                 case 1705 /* VOLUME_LABEL_EXISTS */ :
                                                     alert("Edit failed:  You tried to change a volume's callnumber to one that is already in use for the given library.  You should transfer the items to the desired callnumber instead.");
                                                     break;
index cd07338..a24cb09 100644 (file)
@@ -433,7 +433,7 @@ cat.copy_buckets.prototype = {
 
                                                                var robj = obj.network.simple_request('FM_ACP_FLESHED_BATCH_UPDATE',[ ses(), copies, true]);
                                                                if (typeof robj.ilsevent != 'undefined') {
-                                                                       switch(robj.ilsevent) {
+                                                                       switch(Number(robj.ilsevent)) {
                                                                                case 1227 /* COPY_DELETE_WARNING */ : 
                                                                                        var copy;
                                                                                        for (var i = 0; i < copies.length; i++) { if (copies[i].id()==robj.payload) copy = function(a){return a;}(copies[i]); }
index 70bc6a4..63812f3 100644 (file)
@@ -827,7 +827,7 @@ g.panes_and_field_names = {
        [
                "Loan Duration",
                { 
-                       render: 'switch(fm.loan_duration()){ case 1: case "1": "Short"; break; case 2: case "2": "Normal"; break; case 3:case "3": "Long"; break; }',
+                       render: 'switch(Number(fm.loan_duration())){ case 1: "Short"; break; case 2: "Normal"; break; case 3: "Long"; break; }',
                        input: 'c = function(v){ g.apply("loan_duration",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ "Short", "1" ], [ "Normal", "2" ], [ "Long", "3" ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
 
                }
@@ -835,7 +835,7 @@ g.panes_and_field_names = {
        [
                "Fine Level",
                {
-                       render: 'switch(fm.fine_level()){ case 1: case "1": "Low"; break; case 2: case "2": "Normal"; break; case 3: case "3": "High"; break; }',
+                       render: 'switch(Number(fm.fine_level())){ case 1: "Low"; break; case 2: "Normal"; break; case 3: "High"; break; }',
                        input: 'c = function(v){ g.apply("fine_level",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ "Low", "1" ], [ "Normal", "2" ], [ "High", "3" ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
                }
        ],
index b7943d9..6951718 100644 (file)
                                                        try {
                                                                var cn = rreq.getResultObject();
                                                                if (typeof cn.ilsevent != 'undefined') {
-                                                                       switch(cn.ilsevent) {
+                                                                       switch(Number(cn.ilsevent)) {
                                                                                case 1508 /* ASSET_CALL_NUMBER_NOT_FOUND */ :
                                                                                        $w('callnumber','Not Cataloged');       
                                                                                break;
index c4790dc..24924f2 100644 (file)
@@ -530,7 +530,7 @@ cat.z3950.prototype = {
                                                try {
                                                        var r = obj.network.simple_request('MARC_XML_RECORD_IMPORT', [ ses(), new_marcxml, biblio_source ]);
                                                        if (typeof r.ilsevent != 'undefined') {
-                                                               switch(r.ilsevent) {
+                                                               switch(Number(r.ilsevent)) {
                                                                        case 1704 /* TCN_EXISTS */ :
                                                                                var msg = 'A record with TCN ' + r.payload.tcn + ' already exists.\nFIXME: add record summary here';
                                                                                var title = 'Import Collision';
@@ -655,7 +655,7 @@ cat.z3950.prototype = {
                                                        if (! obj.confirm_overlay( [ obj.data.marked_record ] ) ) { return; }
                                                        var r = obj.network.simple_request('MARC_XML_RECORD_REPLACE', [ ses(), obj.data.marked_record, new_marcxml, biblio_source ]);
                                                        if (typeof r.ilsevent != 'undefined') {
-                                                               switch(r.ilsevent) {
+                                                               switch(Number(r.ilsevent)) {
                                                                        case 1704 /* TCN_EXISTS */ :
                                                                                var msg = 'A record with TCN ' + r.payload.tcn + ' already exists.\nFIXME: add record summary here';
                                                                                var title = 'Import Collision';
index 586a75f..575bc7c 100644 (file)
@@ -478,7 +478,7 @@ circ.copy_status.prototype = {
                                                                );
        
                                 if (typeof robj.ilsevent != 'undefined') {
-                                                                       switch(robj.ilsevent) {
+                                                                       switch(Number(robj.ilsevent)) {
                                                                                case 1208 /* TITLE_LAST_COPY */:
                                                                                case 1227 /* COPY_DELETE_WARNING */:
                                                                                break;
@@ -699,7 +699,7 @@ circ.copy_status.prototype = {
                                                                                        [ ses(), volumes, false ]
                                                                                );
                                         if (typeof r.ilsevent != 'undefined') {
-                                            switch(r.ilsevent) {
+                                            switch(Number(r.ilsevent)) {
                                                 case 1705 /* VOLUME_LABEL_EXISTS */ :
                                                     alert(document.getElementById('circStrings').getString('staff.circ.copy_status.edit_volumes.duplicate'));
                                                     break;
@@ -1002,7 +1002,7 @@ circ.copy_status.prototype = {
                                        if (details == null) {
                                                throw(document.getElementById('circStrings').getString('staff.circ.copy_status.status.null_result'));
                                        } else if (details.ilsevent) {
-                                               switch(details.ilsevent) {
+                                               switch(Number(details.ilsevent)) {
                                                        case -1: 
                                                                obj.error.standard_network_error_alert(); 
                                                                obj.controller.view.copy_status_barcode_entry_textbox.select();
index a46ea04..baa4e84 100644 (file)
@@ -259,7 +259,7 @@ circ.in_house_use.prototype = {
 
                                var copy = obj.network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ barcode ]); 
                                if (copy.ilsevent) { 
-                                       switch(copy.ilsevent) {
+                                       switch(Number(copy.ilsevent)) {
                                                case -1 : 
                                                        obj.error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.in_house_use.failed.verbose'));
                                                        break;
index 8b95f0a..c90dfda 100644 (file)
                                );
 
                                if (typeof robj.ilsevent != 'undefined') {
-                                       switch(robj.ilsevent) {
+                                       switch(Number(robj.ilsevent)) {
                                                case -1 : g.error.standard_network_error_alert(); break;
                                                case 1703 /* WORKSTATION_NAME_EXISTS */ : /* handled with override request */ break;
                                                default: g.error.standard_unexpected_error_alert(document.getElementById('commonStrings').getFormattedString('staff.main.gen_offline_widgets.registration.error', ['1']), robj); break;
index afa4f28..cf7e5d1 100644 (file)
                                if (r == 0) {
                                        var robj = g.network.simple_request('FM_MB_VOID',[ses()].concat(util.functional.map_list(mb_list,function(o){return o.id();})));
                                        if (robj.ilsevent) {
-                                               switch(robj.ilsevent) {
+                                               switch(Number(robj.ilsevent)) {
                                                        default: 
                                                                g.error.standard_unexpected_error_alert('Error voiding bills.',robj); 
                                                                retrieve_mbts();
index ca896d8..053404a 100644 (file)
@@ -61,7 +61,7 @@
                        if (xul_param('current')) method = 'FM_MBTS_IDS_RETRIEVE_ALL_HAVING_BALANCE';
                        g.mbts_ids = g.network.simple_request(method,[ses(),g.patron_id]);
                        if (g.mbts_ids.ilsevent) {
-                               switch(g.mbts_ids.ilsevent) {
+                               switch(Number(g.mbts_ids.ilsevent)) {
                                        case -1: g.error.standard_network_error_alert('Please close this window and try again.'); break;
                                        default: g.error.standard_unexpected_error_alert('Please close this window and try again.',g.mbts_ids); break;
                                }
                                        try {
                                                g.mbts = req.getResultObject();
                                                if (g.mbts.ilsevent) {
-                                                       switch(g.mbts.ilsevent) {
+                                                       switch(Number(g.mbts.ilsevent)) {
                                                                case -1: g.error.standard_network_error_alert('mbts_id = ' + g.mbts_id); break;
                                                                default: g.error.standard_unexpected_error_alert('mbts_id = ' + g.mbts_id,g.mbts); break;
                                                        }
index 32b22ee..763f8bf 100644 (file)
@@ -583,7 +583,7 @@ patron.bills.prototype = {
                        );
                        if (robj == 1) { return true; } 
                        if (typeof robj.ilsevent != 'undefined') {
-                               switch(robj.ilsevent) {
+                               switch(Number(robj.ilsevent)) {
                                        case 0 /* SUCCESS */ : return true; break;
                                        case 1226 /* REFUND_EXCEEDS_DESK_PAYMENTS */ : alert(robj.desc + '\n\nAnother way to "zero" this transaction is to use Add Billing and add a misc bill to counter the negative balance.'); return false; break;
                                        default: throw(robj); break;
@@ -1060,7 +1060,7 @@ patron.bills.prototype = {
                        if (r == 0) {
                                var robj = obj.network.simple_request('FM_MB_VOID',[ses()].concat(util.functional.map_list(mb_list,function(o){return o.id();})));
                                if (robj.ilsevent) {
-                                       switch(robj.ilsevent) {
+                                       switch(Number(robj.ilsevent)) {
                                                default: 
                                                        obj.error.standard_unexpected_error_alert('Error voiding bills.',robj); 
                                                        obj.refresh(); return; 
index b434c8b..6523fe1 100644 (file)
@@ -589,7 +589,7 @@ patron.holds.prototype = {
                                                 for (var i = 0; i < transits.length; i++) {
                                                     var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
                                                     if (typeof robj.ilsevent != 'undefined') {
-                                                        switch(robj.ilsevent) {
+                                                        switch(Number(robj.ilsevent)) {
                                                             case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
                                                                 alert(robj.desc);
                                                             break;
index f8f2a5b..75182d1 100644 (file)
@@ -376,7 +376,7 @@ patron.items.prototype = {
                                dump('Mark barcode lost = ' + barcode);
                                var robj = obj.network.simple_request( 'MARK_ITEM_LOST', [ ses(), { barcode: barcode } ]);
                                if (typeof robj.ilsevent != 'undefined') { 
-                    switch(robj.ilsevent) {
+                    switch(Number(robj.ilsevent)) {
                         case 7018 /* COPY_MARKED_LOST */ :
                             alert( 'Item Barcode ' + barcode + '\n' + robj.desc );
                         break;