lib/components/Diagram.js
function Diagram(index, options, question) {

  this.index    = index;
  this.options  = options;
  this.question = question;

  this.element = createElement(h('li.list-group-item', {
    style: {
      width: '100%',
      height: '500px'
    }
  }));

  this.viewer;

  if (options.xml) {

    // Load XML
    this.xml = options.xml;

  } else if (options.url) {

    var that = this;

    // Load XML via AJAX
    var xhr = new XMLHttpRequest();

    xhr.onreadystatechange = function() {
      if (xhr.readyState == 4 && xhr.status == 200) {

        that.xml = xhr.responseText;

      }
    };

    xhr.open("GET", options.url, true);
    xhr.send();

  } else {
    throw new Error('Unable to load diagram, no resource specified');
  }

  this.initState = Immutable({
    selected: []
  });

  this.state = this.initState.asMutable({deep: true});

}
function Diagram(index, options, question) {

  this.index    = index;
  this.options  = options;
  this.question = question;

  this.element = createElement(h('li.list-group-item', {
    style: {
      width: '100%',
      height: '500px'
    }
  }));

  this.viewer;

  if (options.xml) {

    // Load XML
    this.xml = options.xml;

  } else if (options.url) {

    var that = this;

    // Load XML via AJAX
    var xhr = new XMLHttpRequest();

    xhr.onreadystatechange = function() {
      if (xhr.readyState == 4 && xhr.status == 200) {

        that.xml = xhr.responseText;

      }
    };

    xhr.open("GET", options.url, true);
    xhr.send();

  } else {
    throw new Error('Unable to load diagram, no resource specified');
  }

  this.initState = Immutable({
    selected: []
  });

  this.state = this.initState.asMutable({deep: true});

}
function Diagram ( index , options , question ) { this . index = index ; this . options = options ; this . question = question ; this . element = createElement ( h ( 'li.list-group-item' , { style : { width : '100%' , height : '500px' } } ) ) ; this . viewer ; if ( options . xml ) { // Load XML this . xml = options . xml ; } else if ( options . url ) { var that = this ; // Load XML via AJAX var xhr = new XMLHttpRequest ( ) ; xhr . onreadystatechange = function ( ) { if ( xhr . readyState == 4 && xhr . status == 200 ) { that . xml = xhr . responseText ; } } ; xhr . open ( "GET" , options . url , true ) ; xhr . send ( ) ; } else { throw new Error ( 'Unable to load diagram, no resource specified' ) ; } this . initState = Immutable ( { selected : [ ] } ) ; this . state = this . initState . asMutable ( { deep : true } ) ; }
Diagram component.

@param {number} index - Index of question.
@param {Object} options - Options.
@param {Object} question - Reference to the Question instance.
Diagram component .