From f4c201f04ec91a1ddbd2253392d7f739199cf9f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Hn=C3=A1t?= Date: Wed, 2 Nov 2022 14:21:18 +0100 Subject: [PATCH] Added sort by time --- dashboard_static/js/code.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/dashboard_static/js/code.js b/dashboard_static/js/code.js index f98c27e..7c78603 100644 --- a/dashboard_static/js/code.js +++ b/dashboard_static/js/code.js @@ -154,22 +154,27 @@ function filterReplies(repliesTop, repliesBottom, tweets){ return tweets } -function sortTweets(tweets, likesDes=null, retweets=null, replies=null){ +function sortTweets(tweets, likesDes=null, retweetsDes=null, repliesDes=null, dateDes=null){ if(likesDes && likesDes!=null){ tweets.sort(function(a,b){return b.favorite_count-a.favorite_count}) } else if (!likesDes && likesDes!=null){ tweets.sort(function(a,b){return a.favorite_count-b.favorite_count}) } - if(retweets && retweets!=null){ + if(retweetsDes && retweetsDes!=null){ tweets.sort(function(a,b){return b.retweet_count-a.retweet_count}) - } else if (!retweets && retweets!=null){ + } else if (!retweetsDes && retweetsDes!=null){ tweets.sort(function(a,b){return a.retweet_count-b.retweet_count}) } - if(replies && replies!=null){ + if(repliesDes && repliesDes!=null){ tweets.sort(function(a,b){return b.reply_count-a.reply_count}) - } else if (!replies && replies!=null){ + } else if (!repliesDes && repliesDes!=null){ tweets.sort(function(a,b){return a.reply_count-b.reply_count}) } + if(dateDes && dateDes!=null){ + tweets.sort(function(a,b){return Date(b.created_at)-Date(a.reply_count)}) + } else if (!dateDes && dateDes!=null){ + tweets.sort(function(a,b){return Date(a.created_at)-Date(b.reply_count)}) + } return tweets }