<commit_before>(function () {

  var Pontoon = {
        app: {
          win: window.opener || window.top,
          path: "",
          external: false,
          links: false
       },
        project: {
          win: window,
          url: window.location.href,
          title: "",
          entities: [],
          pk: null,
          type: 'gettext'
        },
        locale: {
          code: "",
          language: ""
        },
        user: {
          name: "",
          email: ""
        }
      },
      jqueryAppended = false,
      script = document.createElement('script');

  // Main code
  function jqueryLoaded() {
    $(function() {



      /**
       * Send data to main Pontoon code
       */
      function sendData() {
        // Deep copy: http://api.jquery.com/jQuery.extend
        var entities = $.extend(true, [], Pontoon.project.entities);
        $(entities).each(function () {
          delete this.node;
        });

        postMessage("DATA", {
          entities: entities
        });
      }



      /**
       * Sync content of duplicate entities
       *
       * entity Entity object
       * content Node content
       *
       * TODO: Advanced mode
       */
      function syncDuplicates(entity, content) {
        var entities = Pontoon.project.entities,
            duplicates = entity.duplicates;

        if (!duplicates && entities[entity.master]) {
          duplicates = entities[entity.master].duplicates;
        }

        $(duplicates).each(function() {
          entities[this].node.html(content);
          entities[this].translation = (entity.node.html() !== entity.original) ? content : '';
        });
      }



      /**
       * Render main UI and handle events
       */
      function renderHandle() {
        sendData();
        postMessage("RENDER", {
          url: Pontoon.project.url,
          title: Pontoon.project.title,
          type: Pontoon.project.type
        });

        // Update UI and progress when saved
        $(".editableToolbar > .save").click(function () {
          var element = $(this).parent().get(0).target,
              entity = element.entity;

          syncDuplicates(entity, $($(element).clone()).html());
          sendData();
          postMessage("UPDATE", entity.master || entity.id);
        });

        // Do not change anything when cancelled
        $(".editableToolbar > .cancel").click(function () {
          var element = $(this).parent().get(0).target,
              entity = element.entity;

          $(element).html(entity.translation || entity.original);
        });<commit_msg>Whoops, non-duplicated entities were b0rken<commit_after>(function () {

  var Pontoon = {
        app: {
          win: window.opener || window.top,
          path: "",
          external: false,
          links: false
       },
        project: {
          win: window,
          url: window.location.href,
          title: "",
          entities: [],
          pk: null,
          type: 'gettext'
        },
        locale: {
          code: "",
          language: ""
        },
        user: {
          name: "",
          email: ""
        }
      },
      jqueryAppended = false,
      script = document.createElement('script');

  // Main code
  function jqueryLoaded() {
    $(function() {



      /**
       * Send data to main Pontoon code
       */
      function sendData() {
        // Deep copy: http://api.jquery.com/jQuery.extend
        var entities = $.extend(true, [], Pontoon.project.entities);
        $(entities).each(function () {
          delete this.node;
        });

        postMessage("DATA", {
          entities: entities
        });
      }



      /**
       * Sync content of duplicate entities
       *
       * entity Entity object
       * content Node content
       */
      function syncDuplicates(entity, content) {
        var entities = Pontoon.project.entities,
            duplicates = entity.duplicates;

        if (!duplicates && entities[entity.master]) {
          duplicates = entities[entity.master].duplicates;
        }

        $(duplicates).each(function() {
          entities[this].node.html(content);
          entities[this].translation = (entity.node.html() !== entity.original) ? content : '';
        });
      }



      /**
       * Render main UI and handle events
       */
      function renderHandle() {
        sendData();
        postMessage("RENDER", {
          url: Pontoon.project.url,
          title: Pontoon.project.title,
          type: Pontoon.project.type
        });

        // Update UI and progress when saved
        $(".editableToolbar > .save").click(function () {
          var element = $(this).parent().get(0).target,
              entity = element.entity,
              content = $(element).html();

          if (!entity.duplicates && entity.master === undefined ) {
            entity.translation = (entity.node.html() !== entity.original) ? content : '';
          } else {
            syncDuplicates(entity, content);
          }
          sendData();
          postMessage("UPDATE", entity.master || entity.id);
        });

        // Do not change anything when cancelled
        $(".editableToolbar > .cancel").click(function () {
          var element = $(this).parent().get(0).target,
              entity = element.entity;

          $(element).html(entity.translation || entity.original);
        });
{'fraction_non_alphanumeric': 0.13739612188365652, 'fraction_numerical': 0.0009233610341643582, 'mean_word_length': 1.5889101338432123, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4894599', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1408, 'n_words': 296}