CoreFiles by mySites.guru
admin-compare-compare.es6.js48 lines, 1,394 bytes, from Joomla_4.0.0-alpha12-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha11
md5
1f206d0b2a3e51617c2392b90d96cac6
sha1
dccfb500d8ecaf0e123386f98bbdd756af85cdbc
sha256
533663452371e3698eeeaf0c96cd01455cd9723f72895dcdde2fc6be46dfd4cf
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
 * @copyright  Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */
(() => {
  'use strict';

  const compare = (original, changed) => {
    const display = changed.nextElementSibling;
    let color = ''; // @todo use the tag MARK here not SPAN

    let span = null;
    const diff = window.JsDiff.diffWords(original.innerHTML, changed.innerHTML);
    const fragment = document.createDocumentFragment();
    diff.forEach(part => {
      if (part.added) {
        color = '#a6f3a6';
      }

      if (part.removed) {
        color = '#f8cbcb';
      }

      span = document.createElement('span');
      span.style.backgroundColor = color;
      span.style.borderRadius = '.2rem';
      span.appendChild(document.createTextNode(part.value));
      fragment.appendChild(span);
    });
    display.appendChild(fragment);
  };

  const onBoot = () => {
    const diffs = [].slice.call(document.querySelectorAll('.original'));
    diffs.forEach(fragment => {
      compare(fragment, fragment.nextElementSibling);
    }); // Cleanup

    document.removeEventListener('DOMContentLoaded', onBoot);
  };

  document.addEventListener('DOMContentLoaded', onBoot);
})();

The same content is in 6 releases, Joomla 4.0.0-alpha7 to 4.0.0-alpha12. See them all, or every version of this file.