web/static/scripts/redisCommander.js
function addInputValidator(inputId, format, currentState) {
  var input;
  if (typeof inputId === 'string') {
    input = $('#' + inputId)
  }
  else if (typeof inputId === 'object') {
    input = inputId;
  }

  if (!input){
    console.log('Invalid html id given to validate format: ', inputId);
    return;
  }

  switch (format) {
    case 'json':
        input.on('keyup', validateInputAsJson);
        break;
    default:
        console.log('Invalid format given to validate input: ', format);
        return;
  }

  // set initial state if requested
  if (typeof currentState === 'boolean') {
    setValidationClasses(input.get(0), currentState);
  }
  else {
    input.trigger( "keyup" );
  }
}
function addInputValidator(inputId, format, currentState) {
  var input;
  if (typeof inputId === 'string') {
    input = $('#' + inputId)
  }
  else if (typeof inputId === 'object') {
    input = inputId;
  }

  if (!input){
    console.log('Invalid html id given to validate format: ', inputId);
    return;
  }

  switch (format) {
    case 'json':
        input.on('keyup', validateInputAsJson);
        break;
    default:
        console.log('Invalid format given to validate input: ', format);
        return;
  }

  // set initial state if requested
  if (typeof currentState === 'boolean') {
    setValidationClasses(input.get(0), currentState);
  }
  else {
    input.trigger( "keyup" );
  }
}
function addInputValidator ( inputId , format , currentState ) { var input ; if ( typeof inputId === 'string' ) { input = $ ( '#' + inputId ) } else if ( typeof inputId === 'object' ) { input = inputId ; } if ( ! input ) { console . log ( 'Invalid html id given to validate format: ' , inputId ) ; return ; } switch ( format ) { case 'json' : input . on ( 'keyup' , validateInputAsJson ) ; break ; default : console . log ( 'Invalid format given to validate input: ' , format ) ; return ; } // set initial state if requested if ( typeof currentState === 'boolean' ) { setValidationClasses ( input . get ( 0 ) , currentState ) ; } else { input . trigger ( "keyup" ) ; } }
Add data format validation function to an input element.
The field gets decorated to visualize if input is valid for given data format.

@param {string|object} inputId id of html input element to watch or jquery object
@param {string} format data format to validate against, possible values: "json"
@param {boolean} [currentState] optional start state to set now
Add data format validation function to an input element . The field gets decorated to visualize if input is valid for given data format .