outline/userInput.js
function fillInRequest (type, selectedTd, inputTerm) {
      var tr = selectedTd.parentNode
      var stat; var isInverse
      stat = tr.AJAR_statement; isInverse = tr.AJAR_inverse

      var reqTerm = (type === 'object') ? stat.object : stat.predicate
      var newStat
      var doNext = false

        // RDF Event

      var eventhandler
      if (kb.any(reqTerm, UI.ns.link('onfillin'))) {
        /*    2017 -- Not sure what is supposed to happen here -- timbl @@@@
        eventhandler = function(subject) {
          return kb.any(reqTerm, UI.ns.link('onfillin')).value)
        }
        */
      }

      if (type === 'predicate') {
            // ToDo: How to link two things with an inverse relationship
        let newTd = outline.outlinePredicateTD(inputTerm, tr, false, false)
        if (selectedTd.nextSibling.className !== 'undetermined') {
          var s = new UI.rdf.Statement(stat.subject, inputTerm, stat.object, stat.why)

          try {
            UI.store.updater.update([], [s], function (uri, success, errorBody) {
              if (success) {
                newStat = kb.anyStatementMatching(stat.subject, inputTerm, stat.object, stat.why)
                tr.AJAR_statement = newStat
                newTd.className = newTd.className.replace(/ pendingedit/g, '')
              } else {
                        // outline.UserInput.deleteTriple(newTd,true);
                        // Warn the user that the write has failed.
                UI.log.warn('Failure occurs (#2) while inserting ' + tr.AJAR_statement + '\n\n' + errorBody)
              }
            })
          } catch (e) {
            UI.log.error(e)
                    // Warn the user that the write has failed.
            UI.log.warn('Error when insert (#2) of statement ' + s + ':\n\t' + e)
            return
          }

          newTd.className += ' pendingedit'
          this.lastModified = null
        } else {
          this.formUndetStat(tr, stat.subject, inputTerm, stat.object, stat.why, false)
          outline.walk('right')
          doNext = true
        }
        outline.replaceTD(newTd, selectedTd)
        TempFormula.remove(stat)
      } else if (type === 'object') {     // Object value has been edited
        let newTd = outline.outlineObjectTD(inputTerm)
        outline.replaceTD(newTd, selectedTd)
        if (!selectedTd.previousSibling || selectedTd.previousSibling.className !== 'undetermined') {
          let s
          if (!isInverse) { s = new UI.rdf.Statement(stat.subject, stat.predicate, inputTerm, stat.why) } else { s = new UI.rdf.Statement(inputTerm, stat.predicate, stat.object, stat.why) }

          try {
            UI.store.updater.update([], [s], function (uri, success, errorBody) {
              UI.log.info('@@ usinput.js (object) callback ok=' + success + ' for statement:' + s + '\n ')
              var newStats
              if (success) {
                newTd.className = newTd.className.replace(/ pendingedit/g, '') // User feedback
                if (!isInverse) { newStats = kb.statementsMatching(stat.subject, stat.predicate, inputTerm, stat.why) } else { newStats = kb.statementsMatching(inputTerm, stat.predicate, stat.object, stat.why) }
                if (!newStats.length) UI.log.error("userinput.js 1711: Can't find statememt!")
                tr.AJAR_statement = newStats[0]
              } else {
                UI.log.warn('userinput.js (object): Fail trying to insert statement ' + s)
                            // outline.UserInput.deleteTriple(newTd,true);
              }
            })
          } catch (e) {
                    // outline.UserInput.deleteTriple(newTd,true);
            UI.log.error('userinput.js (object): exception trying to insert statement ' +
                            s + ': ' + UI.utils.stackString(e))
            UI.log.warn('Error trying to insert statement ' + s + ':\n' + e)
            return
          }

          this.lastModified = null
          newTd.className += ' pendingedit'
        } else {
                // ?this.formUndetStat(tr...)
          outline.walk('left')
          doNext = true
        }
            // removal of the undetermined statement
        TempFormula.remove(stat)
      }
        // do not throw away user's work even update fails
      UserInputFormula.statements.push(newStat)
      if (eventhandler) eventhandler(stat.subject)
      if (doNext) { this.startFillInText(outline.getSelection()[0]) } else { return true } // can clearMenu
    }
function fillInRequest (type, selectedTd, inputTerm) {
      var tr = selectedTd.parentNode
      var stat; var isInverse
      stat = tr.AJAR_statement; isInverse = tr.AJAR_inverse

      var reqTerm = (type === 'object') ? stat.object : stat.predicate
      var newStat
      var doNext = false

        // RDF Event

      var eventhandler
      if (kb.any(reqTerm, UI.ns.link('onfillin'))) {
        /*    2017 -- Not sure what is supposed to happen here -- timbl @@@@
        eventhandler = function(subject) {
          return kb.any(reqTerm, UI.ns.link('onfillin')).value)
        }
        */
      }

      if (type === 'predicate') {
            // ToDo: How to link two things with an inverse relationship
        let newTd = outline.outlinePredicateTD(inputTerm, tr, false, false)
        if (selectedTd.nextSibling.className !== 'undetermined') {
          var s = new UI.rdf.Statement(stat.subject, inputTerm, stat.object, stat.why)

          try {
            UI.store.updater.update([], [s], function (uri, success, errorBody) {
              if (success) {
                newStat = kb.anyStatementMatching(stat.subject, inputTerm, stat.object, stat.why)
                tr.AJAR_statement = newStat
                newTd.className = newTd.className.replace(/ pendingedit/g, '')
              } else {
                        // outline.UserInput.deleteTriple(newTd,true);
                        // Warn the user that the write has failed.
                UI.log.warn('Failure occurs (#2) while inserting ' + tr.AJAR_statement + '\n\n' + errorBody)
              }
            })
          } catch (e) {
            UI.log.error(e)
                    // Warn the user that the write has failed.
            UI.log.warn('Error when insert (#2) of statement ' + s + ':\n\t' + e)
            return
          }

          newTd.className += ' pendingedit'
          this.lastModified = null
        } else {
          this.formUndetStat(tr, stat.subject, inputTerm, stat.object, stat.why, false)
          outline.walk('right')
          doNext = true
        }
        outline.replaceTD(newTd, selectedTd)
        TempFormula.remove(stat)
      } else if (type === 'object') {     // Object value has been edited
        let newTd = outline.outlineObjectTD(inputTerm)
        outline.replaceTD(newTd, selectedTd)
        if (!selectedTd.previousSibling || selectedTd.previousSibling.className !== 'undetermined') {
          let s
          if (!isInverse) { s = new UI.rdf.Statement(stat.subject, stat.predicate, inputTerm, stat.why) } else { s = new UI.rdf.Statement(inputTerm, stat.predicate, stat.object, stat.why) }

          try {
            UI.store.updater.update([], [s], function (uri, success, errorBody) {
              UI.log.info('@@ usinput.js (object) callback ok=' + success + ' for statement:' + s + '\n ')
              var newStats
              if (success) {
                newTd.className = newTd.className.replace(/ pendingedit/g, '') // User feedback
                if (!isInverse) { newStats = kb.statementsMatching(stat.subject, stat.predicate, inputTerm, stat.why) } else { newStats = kb.statementsMatching(inputTerm, stat.predicate, stat.object, stat.why) }
                if (!newStats.length) UI.log.error("userinput.js 1711: Can't find statememt!")
                tr.AJAR_statement = newStats[0]
              } else {
                UI.log.warn('userinput.js (object): Fail trying to insert statement ' + s)
                            // outline.UserInput.deleteTriple(newTd,true);
              }
            })
          } catch (e) {
                    // outline.UserInput.deleteTriple(newTd,true);
            UI.log.error('userinput.js (object): exception trying to insert statement ' +
                            s + ': ' + UI.utils.stackString(e))
            UI.log.warn('Error trying to insert statement ' + s + ':\n' + e)
            return
          }

          this.lastModified = null
          newTd.className += ' pendingedit'
        } else {
                // ?this.formUndetStat(tr...)
          outline.walk('left')
          doNext = true
        }
            // removal of the undetermined statement
        TempFormula.remove(stat)
      }
        // do not throw away user's work even update fails
      UserInputFormula.statements.push(newStat)
      if (eventhandler) eventhandler(stat.subject)
      if (doNext) { this.startFillInText(outline.getSelection()[0]) } else { return true } // can clearMenu
    }
function fillInRequest ( type , selectedTd , inputTerm ) { var tr = selectedTd . parentNode var stat ; var isInverse stat = tr . AJAR_statement ; isInverse = tr . AJAR_inverse var reqTerm = ( type === 'object' ) ? stat . object : stat . predicate var newStat var doNext = false // RDF Event var eventhandler if ( kb . any ( reqTerm , UI . ns . link ( 'onfillin' ) ) ) { /*    2017 -- Not sure what is supposed to happen here -- timbl @@@@
        eventhandler = function(subject) {
          return kb.any(reqTerm, UI.ns.link('onfillin')).value)
        }
        */ } if ( type === 'predicate' ) { // ToDo: How to link two things with an inverse relationship let newTd = outline . outlinePredicateTD ( inputTerm , tr , false , false ) if ( selectedTd . nextSibling . className !== 'undetermined' ) { var s = new UI . rdf . Statement ( stat . subject , inputTerm , stat . object , stat . why ) try { UI . store . updater . update ( [ ] , [ s ] , function ( uri , success , errorBody ) { if ( success ) { newStat = kb . anyStatementMatching ( stat . subject , inputTerm , stat . object , stat . why ) tr . AJAR_statement = newStat newTd . className = newTd . className . replace ( /  pendingedit / g , '' ) } else { // outline.UserInput.deleteTriple(newTd,true); // Warn the user that the write has failed. UI . log . warn ( 'Failure occurs (#2) while inserting ' + tr . AJAR_statement + '\n\n' + errorBody ) } } ) } catch ( e ) { UI . log . error ( e ) // Warn the user that the write has failed. UI . log . warn ( 'Error when insert (#2) of statement ' + s + ':\n\t' + e ) return } newTd . className += ' pendingedit' this . lastModified = null } else { this . formUndetStat ( tr , stat . subject , inputTerm , stat . object , stat . why , false ) outline . walk ( 'right' ) doNext = true } outline . replaceTD ( newTd , selectedTd ) TempFormula . remove ( stat ) } else if ( type === 'object' ) { // Object value has been edited let newTd = outline . outlineObjectTD ( inputTerm ) outline . replaceTD ( newTd , selectedTd ) if ( ! selectedTd . previousSibling || selectedTd . previousSibling . className !== 'undetermined' ) { let s if ( ! isInverse ) { s = new UI . rdf . Statement ( stat . subject , stat . predicate , inputTerm , stat . why ) } else { s = new UI . rdf . Statement ( inputTerm , stat . predicate , stat . object , stat . why ) } try { UI . store . updater . update ( [ ] , [ s ] , function ( uri , success , errorBody ) { UI . log . info ( '@@ usinput.js (object) callback ok=' + success + ' for statement:' + s + '\n ' ) var newStats if ( success ) { newTd . className = newTd . className . replace ( /  pendingedit / g , '' ) // User feedback if ( ! isInverse ) { newStats = kb . statementsMatching ( stat . subject , stat . predicate , inputTerm , stat . why ) } else { newStats = kb . statementsMatching ( inputTerm , stat . predicate , stat . object , stat . why ) } if ( ! newStats . length ) UI . log . error ( "userinput.js 1711: Can't find statememt!" ) tr . AJAR_statement = newStats [ 0 ] } else { UI . log . warn ( 'userinput.js (object): Fail trying to insert statement ' + s ) // outline.UserInput.deleteTriple(newTd,true); } } ) } catch ( e ) { // outline.UserInput.deleteTriple(newTd,true); UI . log . error ( 'userinput.js (object): exception trying to insert statement ' + s + ': ' + UI . utils . stackString ( e ) ) UI . log . warn ( 'Error trying to insert statement ' + s + ':\n' + e ) return } this . lastModified = null newTd . className += ' pendingedit' } else { // ?this.formUndetStat(tr...) outline . walk ( 'left' ) doNext = true } // removal of the undetermined statement TempFormula . remove ( stat ) } // do not throw away user's work even update fails UserInputFormula . statements . push ( newStat ) if ( eventhandler ) eventhandler ( stat . subject ) if ( doNext ) { this . startFillInText ( outline . getSelection ( ) [ 0 ] ) } else { return true } // can clearMenu }
funciton showMenu /* When a blank is filled. This happens even for blue-cross editing.
funciton showMenu / * When a blank is filled . This happens even for blue - cross editing .