comparison core/modules/history/js/history.js @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
6 **/ 6 **/
7 7
8 (function ($, Drupal, drupalSettings, storage) { 8 (function ($, Drupal, drupalSettings, storage) {
9 var currentUserID = parseInt(drupalSettings.user.uid, 10); 9 var currentUserID = parseInt(drupalSettings.user.uid, 10);
10 10
11 var thirtyDaysAgo = Math.round(new Date().getTime() / 1000) - 30 * 24 * 60 * 60; 11 var secondsIn30Days = 2592000;
12 var thirtyDaysAgo = Math.round(new Date().getTime() / 1000) - secondsIn30Days;
12 13
13 var embeddedLastReadTimestamps = false; 14 var embeddedLastReadTimestamps = false;
14 if (drupalSettings.history && drupalSettings.history.lastReadTimestamps) { 15 if (drupalSettings.history && drupalSettings.history.lastReadTimestamps) {
15 embeddedLastReadTimestamps = drupalSettings.history.lastReadTimestamps; 16 embeddedLastReadTimestamps = drupalSettings.history.lastReadTimestamps;
16 } 17 }
26 url: Drupal.url('history/get_node_read_timestamps'), 27 url: Drupal.url('history/get_node_read_timestamps'),
27 type: 'POST', 28 type: 'POST',
28 data: { 'node_ids[]': nodeIDs }, 29 data: { 'node_ids[]': nodeIDs },
29 dataType: 'json', 30 dataType: 'json',
30 success: function success(results) { 31 success: function success(results) {
31 for (var nodeID in results) { 32 Object.keys(results || {}).forEach(function (nodeID) {
32 if (results.hasOwnProperty(nodeID)) { 33 storage.setItem('Drupal.history.' + currentUserID + '.' + nodeID, results[nodeID]);
33 storage.setItem('Drupal.history.' + currentUserID + '.' + nodeID, results[nodeID]); 34 });
34 }
35 }
36 callback(); 35 callback();
37 } 36 }
38 }); 37 });
39 }, 38 },
40 getLastRead: function getLastRead(nodeID) { 39 getLastRead: function getLastRead(nodeID) {