diff options
author | friendica <info@friendica.com> | 2015-02-03 21:19:29 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2015-02-03 21:19:29 -0800 |
commit | 4ead2cd79d3c7e5c29a11785a3ceefef6d3ba93f (patch) | |
tree | b2f366402f79f162471b8285ffbea76dd8f44960 /view/js | |
parent | 86771547e6d04d046d3beeabb8e4486a59a7fcc6 (diff) | |
download | volse-hubzilla-4ead2cd79d3c7e5c29a11785a3ceefef6d3ba93f.tar.gz volse-hubzilla-4ead2cd79d3c7e5c29a11785a3ceefef6d3ba93f.tar.bz2 volse-hubzilla-4ead2cd79d3c7e5c29a11785a3ceefef6d3ba93f.zip |
final cleanup on ratings feature
Diffstat (limited to 'view/js')
-rw-r--r-- | view/js/mod_directory.js | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/view/js/mod_directory.js b/view/js/mod_directory.js index 09b103352..87e4f92b5 100644 --- a/view/js/mod_directory.js +++ b/view/js/mod_directory.js @@ -6,14 +6,38 @@ function dirdetails(hash) { } +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); +} - var html = '<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="0" name="rating" style="display: none;" /><div class="rating-text">'+aStr['rating_text']+'<input type="text" name="rating-text" class="directory-rating-text" /><br /><input name="submit" class="directory-rating-submit" type="submit" value="submit" ></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>'; +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%", 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(); |