public static function renderRateFileJS($small = 1)
{
$document = Factory::getDocument();
$url = 'index.php?option=com_phocadownload&view=ratingfilea&task=rate&format=json&' . Session::getFormToken() . '=1';
$urlRefresh = 'index.php?option=com_phocadownload&view=ratingfilea&task=refreshrate&small=' . $small . '&format=json&' . Session::getFormToken() . '=1';
$imgLoadingUrl = Uri::base() . 'media/com_phocadownload/images/icon-loading2.gif';
$imgLoadingHTML = '<img src="' . $imgLoadingUrl . '" alt="" />';
$js = '<script type="text/javascript">' . "\n" . '<!--' . "\n";
//$js .= 'window.addEvent("domready",function() {
$js .= '
function pdRating(id, vote) {
var result = "#pdresult" + id;
var resultvoting = "#pdvoting" + id;
jQuery(result).html("' . addslashes($imgLoadingHTML) . '");
var dataPost = {"ratingId": id, "ratingVote": vote, "format":"json"};
var dataPost2= {"ratingId": id, "ratingVote": vote, "format":"json"};
phRequestActive = jQuery.ajax({
url: "' . $url . '",
type:\'POST\',
data:dataPost,
dataType:\'JSON\',
success:function(data1){
if ( data1.status == 1 ){
jQuery(result).html(data1.message);
phRequestActive2 = jQuery.ajax({
url: "' . $urlRefresh . '",
type:\'POST\',
data:dataPost2,
dataType:\'JSON\',
success:function(data2){
if ( data2.status == 1 ){
jQuery(resultvoting).html(data2.message);
} else {
jQuery(resultvoting).html(data2.message);
}
},
error:function(data2){
jQuery(resultvoting).html("' . Text::_('COM_PHOCADOWNLOAD_ERROR_REQUESTING_RATING') . '");
}
});
} else {
jQuery(result).html(data1.message);
}
},
error:function(data1){
jQuery(result).html("' . Text::_('COM_PHOCADOWNLOAD_ERROR_REQUESTING_RATING') . '");
}
})
}';
$js .= "\n" . '//-->' . "\n" . '</script>';
$document->addCustomTag($js);
}