function changeVersionCompareTo (e) {
    e.preventDefault();

    const $root = $(this).parents('article');
    const selectedVersion = $(this).html();
    const $button = $root.find('.version');
    const currentVersion = $button.find('strong').html();
    $button.find('strong').html(selectedVersion);

    const group = $root.data('group');
    const name = $root.data('name');
    const version = $root.data('version');

    const compareVersion = $root.data('compare-version');

    if (compareVersion === selectedVersion) { return; }

    if (!compareVersion && version === selectedVersion) { return; }

    if ((compareVersion && (articleVersions[group][name][0] === selectedVersion)) || version === selectedVersion) { // eslint-disable-line no-extra-parens
      // the version of the entry is set to the highest version (reset)
      resetArticle(group, name, version);
    } else {
      let sourceEntry = {};
      let compareEntry = {};
      $.each(apiByGroupAndName[group][name], function (index, entry) {
        if (entry.version === version) { sourceEntry = entry; }
        if (entry.version === selectedVersion) { compareEntry = entry; }
      });

      const fields = {
        article: sourceEntry,
        compare: compareEntry,
        versions: articleVersions[group][name],
      };

      // add unique id
      // TODO: replace all group-name-version in template with id.
      fields.article.id = fields.article.group + '-' + fields.article.name + '-' + fields.article.version;
      fields.article.id = fields.article.id.replace(/\./g, '_');

      fields.compare.id = fields.compare.group + '-' + fields.compare.name + '-' + fields.compare.version;
      fields.compare.id = fields.compare.id.replace(/\./g, '_');

      let entry = sourceEntry;
      if (entry.parameter && entry.parameter.fields) { fields._hasTypeInParameterFields = _hasTypeInFields(entry.parameter.fields); }

      if (entry.error && entry.error.fields) { fields._hasTypeInErrorFields = _hasTypeInFields(entry.error.fields); }

      if (entry.success && entry.success.fields) { fields._hasTypeInSuccessFields = _hasTypeInFields(entry.success.fields); }

      if (entry.info && entry.info.fields) { fields._hasTypeInInfoFields = _hasTypeInFields(entry.info.fields); }

      entry = compareEntry;
      if (fields._hasTypeInParameterFields !== true && entry.parameter && entry.parameter.fields) { fields._hasTypeInParameterFields = _hasTypeInFields(entry.parameter.fields); }

      if (fields._hasTypeInErrorFields !== true && entry.error && entry.error.fields) { fields._hasTypeInErrorFields = _hasTypeInFields(entry.error.fields); }

      if (fields._hasTypeInSuccessFields !== true && entry.success && entry.success.fields) { fields._hasTypeInSuccessFields = _hasTypeInFields(entry.success.fields); }

      if (fields._hasTypeInInfoFields !== true && entry.info && entry.info.fields) { fields._hasTypeInInfoFields = _hasTypeInFields(entry.info.fields); }

      const content = templateCompareArticle(fields);
      $root.after(content);
      const $content = $root.next();

      // Event on.click re-assign
      $content.find('.versions li.version a').on('click', changeVersionCompareTo);

      // select navigation
      $('#sidenav li[data-group=\'' + group + '\'][data-name=\'' + name + '\'][data-version=\'' + currentVersion + '\']').addClass('has-modifications');

      $root.remove();
      // TODO: on change main version or select the highest version re-render
    }

    Prism.highlightAll();
  }
/**
     * Change version of an article to compare it to an other version.
     */
Change version of an article to compare it to an other version.
Change version of an article to compare it to an other version .
function changeVersionCompareTo (e) {
    e.preventDefault();
    const $root = $(this).parents('article');
    const selectedVersion = $(this).html();
    const $button = $root.find('.version');
    const currentVersion = $button.find('strong').html();
    $button.find('strong').html(selectedVersion);
    const group = $root.data('group');
    const name = $root.data('name');
    const version = $root.data('version');
    const compareVersion = $root.data('compare-version');
    if (compareVersion === selectedVersion) { return; }
    if (!compareVersion && version === selectedVersion) { return; }
    if ((compareVersion && (articleVersions[group][name][0] === selectedVersion)) || version === selectedVersion) { 
      resetArticle(group, name, version);
    } else {
      let sourceEntry = {};
      let compareEntry = {};
      $.each(apiByGroupAndName[group][name], function (index, entry) {
        if (entry.version === version) { sourceEntry = entry; }
        if (entry.version === selectedVersion) { compareEntry = entry; }
      });
      const fields = {
        article: sourceEntry,
        compare: compareEntry,
        versions: articleVersions[group][name],
      };
      fields.article.id = fields.article.group + '-' + fields.article.name + '-' + fields.article.version;
      fields.article.id = fields.article.id.replace(/\./g, '_');
      fields.compare.id = fields.compare.group + '-' + fields.compare.name + '-' + fields.compare.version;
      fields.compare.id = fields.compare.id.replace(/\./g, '_');
      let entry = sourceEntry;
      if (entry.parameter && entry.parameter.fields) { fields._hasTypeInParameterFields = _hasTypeInFields(entry.parameter.fields); }
      if (entry.error && entry.error.fields) { fields._hasTypeInErrorFields = _hasTypeInFields(entry.error.fields); }
      if (entry.success && entry.success.fields) { fields._hasTypeInSuccessFields = _hasTypeInFields(entry.success.fields); }
      if (entry.info && entry.info.fields) { fields._hasTypeInInfoFields = _hasTypeInFields(entry.info.fields); }
      entry = compareEntry;
      if (fields._hasTypeInParameterFields !== true && entry.parameter && entry.parameter.fields) { fields._hasTypeInParameterFields = _hasTypeInFields(entry.parameter.fields); }
      if (fields._hasTypeInErrorFields !== true && entry.error && entry.error.fields) { fields._hasTypeInErrorFields = _hasTypeInFields(entry.error.fields); }
      if (fields._hasTypeInSuccessFields !== true && entry.success && entry.success.fields) { fields._hasTypeInSuccessFields = _hasTypeInFields(entry.success.fields); }
      if (fields._hasTypeInInfoFields !== true && entry.info && entry.info.fields) { fields._hasTypeInInfoFields = _hasTypeInFields(entry.info.fields); }
      const content = templateCompareArticle(fields);
      $root.after(content);
      const $content = $root.next();
      $content.find('.versions li.version a').on('click', changeVersionCompareTo);
      $('#sidenav li[data-group=\'' + group + '\'][data-name=\'' + name + '\'][data-version=\'' + currentVersion + '\']').addClass('has-modifications');
      $root.remove();
    }
    Prism.highlightAll();
  }
function changeVersionCompareTo ( e ) { e . preventDefault ( ) ; const $root = $ ( this ) . parents ( 'article' ) ; const selectedVersion = $ ( this ) . html ( ) ; const $button = $root . find ( '.version' ) ; const currentVersion = $button . find ( 'strong' ) . html ( ) ; $button . find ( 'strong' ) . html ( selectedVersion ) ; const group = $root . data ( 'group' ) ; const name = $root . data ( 'name' ) ; const version = $root . data ( 'version' ) ; const compareVersion = $root . data ( 'compare-version' ) ; if ( compareVersion === selectedVersion ) { return ; } if ( ! compareVersion && version === selectedVersion ) { return ; } if ( ( compareVersion && ( articleVersions [ group ] [ name ] [ 0 ] === selectedVersion ) ) || version === selectedVersion ) { resetArticle ( group , name , version ) ; } else { let sourceEntry = { } ; let compareEntry = { } ; $ . each ( apiByGroupAndName [ group ] [ name ] , function ( index , entry ) { if ( entry . version === version ) { sourceEntry = entry ; } if ( entry . version === selectedVersion ) { compareEntry = entry ; } } ) ; const fields = { article : sourceEntry , compare : compareEntry , versions : articleVersions [ group ] [ name ] , } ; fields . article . id = fields . article . group + '-' + fields . article . name + '-' + fields . article . version ; fields . article . id = fields . article . id . replace ( / \. / g , '_' ) ; fields . compare . id = fields . compare . group + '-' + fields . compare . name + '-' + fields . compare . version ; fields . compare . id = fields . compare . id . replace ( / \. / g , '_' ) ; let entry = sourceEntry ; if ( entry . parameter && entry . parameter . fields ) { fields . _hasTypeInParameterFields = _hasTypeInFields ( entry . parameter . fields ) ; } if ( entry . error && entry . error . fields ) { fields . _hasTypeInErrorFields = _hasTypeInFields ( entry . error . fields ) ; } if ( entry . success && entry . success . fields ) { fields . _hasTypeInSuccessFields = _hasTypeInFields ( entry . success . fields ) ; } if ( entry . info && entry . info . fields ) { fields . _hasTypeInInfoFields = _hasTypeInFields ( entry . info . fields ) ; } entry = compareEntry ; if ( fields . _hasTypeInParameterFields !== true && entry . parameter && entry . parameter . fields ) { fields . _hasTypeInParameterFields = _hasTypeInFields ( entry . parameter . fields ) ; } if ( fields . _hasTypeInErrorFields !== true && entry . error && entry . error . fields ) { fields . _hasTypeInErrorFields = _hasTypeInFields ( entry . error . fields ) ; } if ( fields . _hasTypeInSuccessFields !== true && entry . success && entry . success . fields ) { fields . _hasTypeInSuccessFields = _hasTypeInFields ( entry . success . fields ) ; } if ( fields . _hasTypeInInfoFields !== true && entry . info && entry . info . fields ) { fields . _hasTypeInInfoFields = _hasTypeInFields ( entry . info . fields ) ; } const content = templateCompareArticle ( fields ) ; $root . after ( content ) ; const $content = $root . next ( ) ; $content . find ( '.versions li.version a' ) . on ( 'click' , changeVersionCompareTo ) ; $ ( '#sidenav li[data-group=\'' + group + '\'][data-name=\'' + name + '\'][data-version=\'' + currentVersion + '\']' ) . addClass ( 'has-modifications' ) ; $root . remove ( ) ; } Prism . highlightAll ( ) ; }
Change version of an article to compare it to an other version.
Change version of an article to compare it to an other version .
// eslint-disable-line no-extra-parens // the version of the entry is set to the highest version (reset) // add unique id // TODO: replace all group-name-version in template with id. // Event on.click re-assign // select navigation // TODO: on change main version or select the highest version re-render