aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/comments/api/frontends/latest/addratings.js
blob: b4d7c8e5aa221c4f49112a286a3d2fa575259c91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Add Like/Dislike link and count to template (addratings.js)
HashOverLatest.prototype.comments.addRatings = function (comment, template, action, commentKey)
{
	// Reference to the parent object
	var hashover = this.parent;

	// Check if the comment has been likes/dislikes
	if (comment[action + 's'] !== undefined) {
		// Add likes/dislikes to HTML template
		template[action + 's'] = comment[action + 's'];

		// Get "X Like/Dislike(s)" locale
		var plural = (comment[action + 's'] === 1 ? 0 : 1);
		var count = comment[action + 's'] + ' ' + hashover.locale[action][plural];
	}

	// Add like count to HTML template
	template[action + '-count'] = hashover.strings.parseTemplate (hashover.ui[action + '-count'], {
		permalink: commentKey,
		text: count || ''
	});
};