Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / tracker / js / tracker-history.js
index 877a9caec71b95ddbd342d0a4733383004cabe5a..c60f50d9be6a49c64df88a6dff1e04aeb7f3c2a4 100644 (file)
@@ -1,64 +1,47 @@
 /**
- * Attaches behaviors for the Tracker module's History module integration.
- *
- * May only be loaded for authenticated users, with the History module enabled.
- */
-(function ($, Drupal, window) {
-
-  'use strict';
+* DO NOT EDIT THIS FILE.
+* See the following change record for more information,
+* https://www.drupal.org/node/2815083
+* @preserve
+**/
 
-  /**
-   * Render "new" and "updated" node indicators, as well as "X new" replies links.
-   */
+(function ($, Drupal, window) {
   Drupal.behaviors.trackerHistory = {
-    attach: function (context) {
-      // Find all "new" comment indicator placeholders newer than 30 days ago that
-      // have not already been read after their last comment timestamp.
+    attach: function attach(context) {
       var nodeIDs = [];
-      var $nodeNewPlaceholders = $(context)
-        .find('[data-history-node-timestamp]')
-        .once('history')
-        .filter(function () {
-          var nodeTimestamp = parseInt(this.getAttribute('data-history-node-timestamp'), 10);
-          var nodeID = this.getAttribute('data-history-node-id');
-          if (Drupal.history.needsServerCheck(nodeID, nodeTimestamp)) {
+      var $nodeNewPlaceholders = $(context).find('[data-history-node-timestamp]').once('history').filter(function () {
+        var nodeTimestamp = parseInt(this.getAttribute('data-history-node-timestamp'), 10);
+        var nodeID = this.getAttribute('data-history-node-id');
+        if (Drupal.history.needsServerCheck(nodeID, nodeTimestamp)) {
+          nodeIDs.push(nodeID);
+          return true;
+        }
+
+        return false;
+      });
+
+      var $newRepliesPlaceholders = $(context).find('[data-history-node-last-comment-timestamp]').once('history').filter(function () {
+        var lastCommentTimestamp = parseInt(this.getAttribute('data-history-node-last-comment-timestamp'), 10);
+        var nodeTimestamp = parseInt(this.previousSibling.previousSibling.getAttribute('data-history-node-timestamp'), 10);
+
+        if (lastCommentTimestamp === nodeTimestamp) {
+          return false;
+        }
+        var nodeID = this.previousSibling.previousSibling.getAttribute('data-history-node-id');
+        if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) {
+          if (nodeIDs.indexOf(nodeID) === -1) {
             nodeIDs.push(nodeID);
-            return true;
-          }
-          else {
-            return false;
           }
-        });
+          return true;
+        }
 
-      // Find all "new" comment indicator placeholders newer than 30 days ago that
-      // have not already been read after their last comment timestamp.
-      var $newRepliesPlaceholders = $(context)
-        .find('[data-history-node-last-comment-timestamp]')
-        .once('history')
-        .filter(function () {
-          var lastCommentTimestamp = parseInt(this.getAttribute('data-history-node-last-comment-timestamp'), 10);
-          var nodeTimestamp = parseInt(this.previousSibling.previousSibling.getAttribute('data-history-node-timestamp'), 10);
-          // Discard placeholders that have zero comments.
-          if (lastCommentTimestamp === nodeTimestamp) {
-            return false;
-          }
-          var nodeID = this.previousSibling.previousSibling.getAttribute('data-history-node-id');
-          if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) {
-            if (nodeIDs.indexOf(nodeID) === -1) {
-              nodeIDs.push(nodeID);
-            }
-            return true;
-          }
-          else {
-            return false;
-          }
-        });
+        return false;
+      });
 
       if ($nodeNewPlaceholders.length === 0 && $newRepliesPlaceholders.length === 0) {
         return;
       }
 
-      // Fetch the node read timestamps from the server.
       Drupal.history.fetchTimestamps(nodeIDs, function () {
         processNodeNewIndicators($nodeNewPlaceholders);
         processNewRepliesIndicators($newRepliesPlaceholders);
       var lastViewTimestamp = Drupal.history.getLastRead(nodeID);
 
       if (timestamp > lastViewTimestamp) {
-        var message = (lastViewTimestamp === 0) ? newNodeString : updatedNodeString;
+        var message = lastViewTimestamp === 0 ? newNodeString : updatedNodeString;
         $(placeholder).append('<span class="marker">' + message + '</span>');
       }
     });
   }
 
   function processNewRepliesIndicators($placeholders) {
-    // Figure out which placeholders need the "x new" replies links.
     var placeholdersToUpdate = {};
     $placeholders.each(function (index, placeholder) {
       var timestamp = parseInt(placeholder.getAttribute('data-history-node-last-comment-timestamp'), 10);
       var nodeID = placeholder.previousSibling.previousSibling.getAttribute('data-history-node-id');
       var lastViewTimestamp = Drupal.history.getLastRead(nodeID);
 
-      // Queue this placeholder's "X new" replies link to be downloaded from the
-      // server.
       if (timestamp > lastViewTimestamp) {
         placeholdersToUpdate[nodeID] = placeholder;
       }
     });
 
-    // Perform an AJAX request to retrieve node view timestamps.
     var nodeIDs = Object.keys(placeholdersToUpdate);
     if (nodeIDs.length === 0) {
       return;
     $.ajax({
       url: Drupal.url('comments/render_new_comments_node_links'),
       type: 'POST',
-      data: {'node_ids[]': nodeIDs},
+      data: { 'node_ids[]': nodeIDs },
       dataType: 'json',
-      success: function (results) {
+      success: function success(results) {
         for (var nodeID in results) {
           if (results.hasOwnProperty(nodeID) && placeholdersToUpdate.hasOwnProperty(nodeID)) {
             var url = results[nodeID].first_new_comment_link;
       }
     });
   }
-
-})(jQuery, Drupal, window);
+})(jQuery, Drupal, window);
\ No newline at end of file