Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
saveRecentItem: function(recentItem) {
var recent = Sefaria.recentlyViewed;
if (recent.length && recent[0].ref == recentItem.ref) { return; }
recent = recent.filter(function(item) {
return item.book !== recentItem.book; // Remove this item if it's in the list already
});
recent.splice(0, 0, recentItem);
Sefaria.recentlyViewed = recent;
var packedRecent = recent.map(Sefaria.packRecentItem);
if (Sefaria._uid) {
$.post("/api/profile", {json: JSON.stringify({recentlyViewed: packedRecent})}, function(data) {} );
} else {
var cookie = INBROWSER ? $.cookie : Sefaria.util.cookie;
packedRecent = packedRecent.slice(0, 6);
cookie("recentlyViewed", JSON.stringify(packedRecent), {path: "/"});
}
},
packRecentItem: function(item) {