trip/tripPane.js
function () {
        var total = {}
        var trans = kb.each(undefined, TRIP('trip'), subject)
        // complain("@@ Number of transactions in this trip: " + trans.length);
        trans.map(function (t) {
          var ty = kb.the(t, ns.rdf('type'))
          // complain(" -- one trans: "+t.uri + ' -> '+kb.any(t, UI.ns.qu('in_USD')));
          if (!ty) ty = UI.ns.qu('ErrorNoType')
          if (ty && ty.uri) {
            var tyuri = ty.uri
            if (!total[tyuri]) total[tyuri] = 0.0
            var lit = kb.any(t, UI.ns.qu('in_USD'))
            if (!lit) {
              complain('    @@ No amount in USD: ' + lit + ' for ' + t)
            }
            if (lit) {
              total[tyuri] = total[tyuri] + parseFloat(lit.value)
              // complain('      Trans type ='+ty+'; in_USD "' + lit
              //       +'; total[tyuri] = '+total[tyuri]+';')
            }
          }
        })
        var str = ''
        var types = 0
        var grandTotal = 0.0
        for (var uri in total) {
          str += UI.utils.label(kb.sym(uri)) + ': ' + total[uri] + '; '
          types++
          grandTotal += total[uri]
        }
        complain('Totals of ' + trans.length + ' transactions: ' + str, '') // @@@@@  yucky -- need 2 col table
        if (types > 1) complain('Overall net: ' + grandTotal, 'text-treatment: bold;')
      }
function () {
        var total = {}
        var trans = kb.each(undefined, TRIP('trip'), subject)
        // complain("@@ Number of transactions in this trip: " + trans.length);
        trans.map(function (t) {
          var ty = kb.the(t, ns.rdf('type'))
          // complain(" -- one trans: "+t.uri + ' -> '+kb.any(t, UI.ns.qu('in_USD')));
          if (!ty) ty = UI.ns.qu('ErrorNoType')
          if (ty && ty.uri) {
            var tyuri = ty.uri
            if (!total[tyuri]) total[tyuri] = 0.0
            var lit = kb.any(t, UI.ns.qu('in_USD'))
            if (!lit) {
              complain('    @@ No amount in USD: ' + lit + ' for ' + t)
            }
            if (lit) {
              total[tyuri] = total[tyuri] + parseFloat(lit.value)
              // complain('      Trans type ='+ty+'; in_USD "' + lit
              //       +'; total[tyuri] = '+total[tyuri]+';')
            }
          }
        })
        var str = ''
        var types = 0
        var grandTotal = 0.0
        for (var uri in total) {
          str += UI.utils.label(kb.sym(uri)) + ': ' + total[uri] + '; '
          types++
          grandTotal += total[uri]
        }
        complain('Totals of ' + trans.length + ' transactions: ' + str, '') // @@@@@  yucky -- need 2 col table
        if (types > 1) complain('Overall net: ' + grandTotal, 'text-treatment: bold;')
      }
function ( ) { var total = { } var trans = kb . each ( undefined , TRIP ( 'trip' ) , subject ) // complain("@@ Number of transactions in this trip: " + trans.length); trans . map ( function ( t ) { var ty = kb . the ( t , ns . rdf ( 'type' ) ) // complain(" -- one trans: "+t.uri + ' -> '+kb.any(t, UI.ns.qu('in_USD'))); if ( ! ty ) ty = UI . ns . qu ( 'ErrorNoType' ) if ( ty && ty . uri ) { var tyuri = ty . uri if ( ! total [ tyuri ] ) total [ tyuri ] = 0.0 var lit = kb . any ( t , UI . ns . qu ( 'in_USD' ) ) if ( ! lit ) { complain ( '    @@ No amount in USD: ' + lit + ' for ' + t ) } if ( lit ) { total [ tyuri ] = total [ tyuri ] + parseFloat ( lit . value ) // complain('      Trans type ='+ty+'; in_USD "' + lit //       +'; total[tyuri] = '+total[tyuri]+';') } } } ) var str = '' var types = 0 var grandTotal = 0.0 for ( var uri in total ) { str += UI . utils . label ( kb . sym ( uri ) ) + ': ' + total [ uri ] + '; ' types ++ grandTotal += total [ uri ] } complain ( 'Totals of ' + trans . length + ' transactions: ' + str , '' ) // @@@@@  yucky -- need 2 col table if ( types > 1 ) complain ( 'Overall net: ' + grandTotal , 'text-treatment: bold;' ) }
query.pat.optional.push(opt);
query . pat . optional . push ( opt ) ;