CoreFiles by mySites.guru
admin-compare-compare.js54 lines, 1,638 bytes, from Joomla_4.0.0-beta1-Beta-Full_Package.zip
Raw History Compare with 3.9.0-beta4
md5
8ea0f4b3ecd010dbd0dc88c4ae099ade
sha1
e1b586ae468a4849d8e827b879f2019dece83e54
sha256
36acebe86a6d3944b2ee0efbc20b9f402263869c3c4644ca0b57b9a3f4ede33e
/**
* 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 - 2020 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */
(function () {
  'use strict'; // This method is used to decode HTML entities

  var decodeHtml = function decodeHtml(html) {
    var textarea = document.createElement('textarea');
    textarea.innerHTML = html;
    return textarea.value;
  };

  var compare = function compare(original, changed) {
    var display = changed.nextElementSibling;
    var diff = window.Diff.diffWords(original.innerHTML, changed.innerHTML);
    var fragment = document.createDocumentFragment();
    diff.forEach(function (part) {
      var color = '';

      if (part.added) {
        color = '#a6f3a6';
      }

      if (part.removed) {
        color = '#f8cbcb';
      } // @todo use the tag MARK here not SPAN


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

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

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

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

The same content is in 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.