Introduction:
This plugin will serve to make a special post "popular", according to the number of votes.
Below is the code that should be added with placement in topics:
Result:
This plugin will serve to make a special post "popular", according to the number of votes.
Below is the code that should be added with placement in topics:
- Code:
/*
* Application: Popular post
* Date: 14/07/2015
* Version: 1.323072017
* Copyright (c) 2017 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
$(function() {
var qtd = 5; // Number of votes for the post to become popular
$("head").append(
'<style type="text/css">' +
'.popular_post {' +
' background: #D5DEE5;' +
' border-radius: 5px 5px 5px 5px;' +
' color: #1D3652;' +
' float: right;' +
' font-size: 0.8em;' +
' font-weight: bold;' +
' margin: 5px 10px 10px;' +
' padding: 5px;' +
' text-align: center;' +
'}' +
'.popular_post img {' +
' max-width: 20px;' +
'}' +
'</style>'
);
var x = $(".vote");
var popular = "<p class='popular_post'><img src='http://imgur.com/hds8Nup.png'><br>POPULAR</p>";
var value, votebar, numbar;
for(var i = 0, l = x.length; i < l; i++) {
var v = x[i];
value = 0;
votebar = $(".vote-bar", v)[0];
if(votebar) {
numbar = votebar.title.match(/\d+/g);
value = Math.round(parseInt(numbar[1]) * parseInt(numbar[0])) / 100;
}
if(value >= qtd) {
v.insertAdjacentHTML("afterbegin", popular);
}
}
});
Result:
Last edited by Daemon on July 23rd 2017, 7:21 pm; edited 3 times in total