javascript - Need to check history for duplicates and then remove them -


So my problem is that when a video is viewed it adds to history, but the problem is that many videos

Here is the code:

  Function clock (video) {document.location.hash = video ["id"]; Update (video); $ ("# Shareitlink") Val (document.location.href). 

{1}
{3} thoughts by "Var {@}" & lt; b & gt; {0} & lt; br & gt; $ ("# VideoInfo") Html (html.format (video ["title"], video ["uploader"], video ["length"], video ["thoughts"])); Ytplayer.loadVideoById (video ["id"]); Receive (video ["id"], true); return false; } Function Watch Video (Video ID) {$ .each (myhistory, function (key, val) {if (val ["id"] === video id) {clock (return); return back;}}); } Function Update History (Video) {Blacklist [Video ["ID"]] = True; Myhistory.push (video); Var html = "& lt; li class = \" history \ "& gt; + "& Lt; img class = \" img-rounded \ "src = \" {0} \ "/ & gt; + "& Lt; p & gt; & lt; b title = \" {2} \ "& gt; One square = \" extended link \ "href = \" javascript: watchHistoricVideo (\ '{1} \') ;
3} by & lt; br & gt; + "{4} | {5} views & lt; / p & gt; + "& Lt; / li & gt;"; $ ("# Myhistory") Video ["Thumbnail"], video ["id"], video ["title"], video ["uploader"], video ["length"], video ["thoughts"]); }

I have tried to use arrays, but I'm not sure what I'm doing (I'm new in javascript).

So if the video is already in history, then it should not be added? Or the video should be added in history, if it was not a past played drama (even if it was in earlier history)?

Scenario 1: The new video is anywhere in history:

Change:

  Document.location.hash = video ["id"]; Update (video);  

To:

  if ($ .grep (myhistory, function (item) {return item ["id"] == Video ["id"];}). Length == 0] {document.location.hash = video ["id"]; Update (video); }  Scenario 2: The new video is just the last seen video:   

Change:

  document.location .hash = video ["id"]; Update (video); If    

To:

  ID]]] {document.location.hash = video ["id"] ; Update (video);}  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -