Hello, yuna. Sorry for waiting for the code.
Administration Control Panel (ACP) Modules HTML & Javascript Javascript codes management and create a new code - upon verifying that Javascript codes management is enabled.
Title: Most liked postWhere: In the topics - Code:
$(document).ready(function() {
var posts = $(".rep-nb").length;
var postLikeObjs = [];
var likes = [];
var maxPostsID;
for (i = 0; i < posts; i++) {
var postLikeObj = {
postID: $(".post-header").parent()[i],
likes: $(".rep-nb")[i]
};
postLikeObjs.push(postLikeObj);
}
for (i = 0; i < posts; i++) {
if (postLikeObjs[i]["likes"].innerHTML == "") {
likes.push(0);
continue;
}
likes.push(+postLikeObjs[i]["likes"].innerHTML);
}
var max = likes[0];
maxPostsID = postLikeObjs[0]["postID"].getAttribute("id");
for (let i = 1; i < likes.length; ++i) {
if (likes[i] > max) {
maxPostsID = postLikeObjs[i]["postID"].getAttribute("id");
max = likes[i];
}
}
if (max != 0) {
$(`#${maxPostsID}` + " .post").css("background-color", "#dfedd1");
$(`#${maxPostsID}` + " .post").css("border", "2px solid #a2b391");
$(`#${maxPostsID}` + " .post-footer").css("background-color", "#dfedd1");
}
});
Notice: This script makes most liked post per page to stand out. So, it's not in topic, but for every page in topic. It's not possible to gain most liked post in complete topic by JS.
If there are two or more posts with same number of likes, script will chose first one.
If you need different styling, please let me know.
One last thing. In order for script to work, only likes must be enabled.