aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/mod_directory.js
blob: e850963c1cf808308bf500e47f61921bebbe1505 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function dirdetails(hash) {
	$.get('dirprofile' + '?f=&hash=' + hash, function( data ) {
		$.colorbox({ maxWidth: "80%", maxHeight: "75%", scrolling: false, html: data });
	});
}

var ratingVal = 0;
var ratingText = '';
var currentHash = '';

function fetchRatings(hash) {
	$.get('prate/' + hash, function(data) {
		if(typeof(data.rating) !== 'undefined') {
			ratingVal = data.rating;
			ratingText = data.rating_text;
		}
		buildRatingForm(hash);
	});
}

function doRatings(hash) {
	fetchRatings(hash);
}

function buildRatingForm(hash) {
	var html = '<form id="ratings_form" action="prate" method="post"><input type="hidden" name="target" value="'+hash+'" /><div class="rating-desc">' + aStr.rating_desc + '</div><input id="dir-rating-range" class="directory-slider" type="text" value="' + ratingVal + '" name="rating" style="display: none;" /><div class="rating-text-label">' + aStr.rating_text + '<input type="text" name="rating_text" class="directory-rating-text" value="' + ratingText + '" /><br /><input name="submit" class="directory-rating-submit" type="submit" value="' + aStr.submit + '" onclick="postRatings(); return false;"></form><div class="clear"></div><script>$("#dir-rating-range").jRange({ from: -10, to: 10, step: 1, showLabels: false, showScale: true, scale: [ "-10","-5","0","5","10" ], onstatechange: function(v) { $("#dir-rating-range").val(v); } });</script>';

	$.colorbox({maxwidth: "50%", maxHeight: "50%", scrolling: false, html: html, close: 'X' });
	currentHash = hash;
}

function postRatings() {
	$.post('prate', $('#ratings_form').serialize(), function(data) {
		$.colorbox.remove();
		$('#edited-' + currentHash).show();
	},'json');
}

$(document).ready(function() {
	collapseHeight();
});