[Request] Ajax Ratings (like IMDB)

Started by denede, October 13, 2013, 04:06:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

denede

#9
fixed.

R3VUK

ahh right ok sorry then bud, was goin off what i have on v3
Learning every day

denede

Quote from: R3V1V4L on October 13, 2013, 07:55:02 PM
try the updated one i updated css i will have a look what my php file looks like
make sure you have the star images in /template/pic/ folders too

try this bud i had to change things slightly on some themes

Code (xml) Select
       /*rating*/
       .rating_load { background:url(pic/ratingload.gif) no-repeat right; width:100px; height:16px;}
.star-rating,
.star-rating a:hover,
.star-rating a:active,
.star-rating .current-rating{
background: url(pic/star.png) left -1000px repeat-x;
margin:0;
font-size:0;
}
.star-rating{
position:relative;
width:80px;
height:16px;
overflow:hidden;
list-style:none;
margin:0;
float:none;
padding:0;

background-position: left top;
}
.star-rating li{
display: inline;
}
.star-rating a,
.star-rating .current-rating{
position:absolute;
top:0;
left:0;
text-indent:-1000em;
height:16px;
padding:0;
float:none;
line-height:16px;
outline:none;
overflow:hidden;
border: none;
}
.star-rating a:hover{
background-position: left bottom;
float:none;
cursor:pointer;
padding:0px;
}
.star-rating a.one-star{
width:20%;
float:none;
padding:0px;
z-index:6;
}
.star-rating a.two-stars{
width:40%;
float:none;
padding:0px;
z-index:5;
}
.star-rating a.three-stars{
width:60%;
float:none;
padding:0px;
z-index:4;
}
.star-rating a.four-stars{
width:80%;
float:none;
padding:0px;
z-index:3;
}
.star-rating a.five-stars{
width:100%;
float:none;
padding:0px;
z-index:2;
}
.star-rating .current-rating{
z-index:1;
float:none;
padding:0px;
background-position: left center;
}
/* rating */


that query won't work on me cuz i'm on 09 version.

still the same. pics are in pic folder from /template/1/ and in pic folder from root

R3VUK

#6
try the updated one i updated css i will have a look what my php file looks like
make sure you have the star images in /template/pic/ folders too

try this bud i had to change things slightly on some themes

Code (xml) Select
       /*rating*/
       .rating_load { background:url(pic/ratingload.gif) no-repeat right; width:100px; height:16px;}
.star-rating,
.star-rating a:hover,
.star-rating a:active,
.star-rating .current-rating{
background: url(pic/star.png) left -1000px repeat-x;
margin:0;
font-size:0;
}
.star-rating{
position:relative;
width:80px;
height:16px;
overflow:hidden;
list-style:none;
margin:0;
float:none;
padding:0;

background-position: left top;
}
.star-rating li{
display: inline;
}
.star-rating a,
.star-rating .current-rating{
position:absolute;
top:0;
left:0;
text-indent:-1000em;
height:16px;
padding:0;
float:none;
line-height:16px;
outline:none;
overflow:hidden;
border: none;
}
.star-rating a:hover{
background-position: left bottom;
float:none;
cursor:pointer;
padding:0px;
}
.star-rating a.one-star{
width:20%;
float:none;
padding:0px;
z-index:6;
}
.star-rating a.two-stars{
width:40%;
float:none;
padding:0px;
z-index:5;
}
.star-rating a.three-stars{
width:60%;
float:none;
padding:0px;
z-index:4;
}
.star-rating a.four-stars{
width:80%;
float:none;
padding:0px;
z-index:3;
}
.star-rating a.five-stars{
width:100%;
float:none;
padding:0px;
z-index:2;
}
.star-rating .current-rating{
z-index:1;
float:none;
padding:0px;
background-position: left center;
}
/* rating */



Learning every day

denede

Quote from: R3V1V4L on October 13, 2013, 07:49:25 PM
try this bud i had to change things slightly on some themes

Code (xml) Select
       /*rating*/
       .rating_load { background:url(/pic/ratingload.gif) no-repeat right; width:100px; height:16px;}
.star-rating,
.star-rating a:hover,
.star-rating a:active,
.star-rating .current-rating{
background: url(/pic/star.png) left -500px repeat-x;
margin:0;
font-size:0;
}
.star-rating{
position:relative;
width:80px;
height:16px;
overflow:hidden;
list-style:none;
margin:0;
float:none;
padding:0;

background-position: left top;
}
.star-rating li{
display: inline;
}
.star-rating a,
.star-rating .current-rating{
position:absolute;
top:0;
left:0;
text-indent:-1000em;
height:16px;
padding:0;
float:none;
line-height:16px;
outline:none;
overflow:hidden;
border: none;
}
.star-rating a:hover{
background-position: left bottom;
float:none;
cursor:pointer;
padding:0px;
}
.star-rating a.one-star{
width:20%;
float:none;
padding:0px;
z-index:6;
}
.star-rating a.two-stars{
width:40%;
float:none;
padding:0px;
z-index:5;
}
.star-rating a.three-stars{
width:60%;
float:none;
padding:0px;
z-index:4;
}
.star-rating a.four-stars{
width:80%;
float:none;
padding:0px;
z-index:3;
}
.star-rating a.five-stars{
width:100%;
float:none;
padding:0px;
z-index:2;
}
.star-rating .current-rating{
z-index:1;
float:none;
padding:0px;
background-position: left center;
}
/* rating */


still nothing.. ..i think it's from the query...

R3VUK

#4
updated
Learning every day

denede

#3
hmm.. but i've made a pic folder into templates/1/ directory..
will try to see if it works
later edit: no, still the same.
i think it has to do with the query line in details.php

$res = mysql_query("SELECT torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, torrents.points, torrents.last_reseed, torrents.poster, torrents.free, torrents.anonymous, torrents.description, torrents.nuked, torrents.nukereason, LENGTH(torrents.nfo) AS nfosz, torrents.last_action AS lastseed, torrents.rating_sum, torrents.num_ratings, torrents.name, IF(torrents.num_ratings < {$TBDEV['minvotes']}, NULL, ROUND(torrents.rating_sum / torrents.num_ratings, 1)) AS rating, torrents.comments, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, categories.name AS cat_name, users.username, freeslots.free AS freeslot, freeslots.double AS doubleslot, freeslots.tid AS slotid, freeslots.uid AS slotuid FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN users ON torrents.owner = users.id LEFT JOIN freeslots ON (torrents.id=freeslots.tid AND freeslots.uid = {$CURUSER['id']}) WHERE torrents.id = $id") or sqlerr();

R3VUK

yes easy one

in your rating.css change this

.star-rating .current-rating{
   background: url(../pic/star.png) left -1000px repeat-x;

to this

.star-rating .current-rating{
   background: url(pic/star.png) left -1000px repeat-x;
Learning every day

denede

#1
Anyone has this on a test site working? If so can share the code?
Thank you.

edit: tried to rip the code from V3. and to my surprise it works, except one thing.
I can't see the ratings and what i'm rating in details.php

If i hover over where ratings should be, i can see that it is showing 1 of 5, 2 of 5.. etc.. and if i rate it, if i hover over it says that this was rated 5 stars, etc..  it adds the seedbonus , but i can't see anything on details..(before and after rating) it looks like this:

http://i.imgur.com/5bjm53i.png

from what i'm debugging i can see that it is some problem with output part from include/function_rating.php .. i guess.
i have the rating_style.css code into my css
and i have the rating.js file from scripts directory into head section in template.php
the function looks like this:

<?php
/**
 *   https://github.com/Bigjoos/
 *   Licence Info: GPL
 *   Copyright (C) 2010 U-232 v.3
 *   A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
 *   Project Leaders: Mindless, putyn.
 *
 */
//putyn's rate mod
function getRate($id$what)
{
    global 
$CURUSER;
    if (
$id == || !in_array($what, array(
        
'topic',
        
'torrent'
    
))) return;
    
//== lets memcache $what fucker
    
$keys['rating'] = 'rating_'.$what.'_'.$id.'_'.$CURUSER['id'];
        
$qy mysql_query("SELECT sum(r.rating) as sum, count(r.rating) as count, r2.id as rated, r2.rating  FROM rating as r LEFT JOIN rating as r2 ON (r2.".$what." = ".sqlesc($id)." AND r2.user = ".sqlesc($CURUSER["id"]).") WHERE r.".$what." = ".sqlesc($id)." GROUP BY r.".$what) or sqlerr(__FILE____LINE__);
        
$rating_cache mysql_fetch_assoc($qy);
        
    
// outputs
    
$p = ($rating_cache["count"] > round((($rating_cache["sum"] / $rating_cache["count"]) * 20) , 2) : 0);
    if (
$rating_cache["rated"]) $rate "<ul class=\"star-rating\" title=\"You rated this ".$what." ".htmlsafechars($rating_cache["rating"])." star".(htmlsafechars($rating_cache["rating"]) > "s" "")."\"><li style=\"width: ".$p."%;\" class=\"current-rating\">.</li></ul>";
    else {
        
$i 1;
        
$rate "<ul class=\"star-rating\"><li style=\"width: ".$p."%;\" class=\"current-rating\">.</li>";
        foreach (array(
            
"one-star",
            
"two-stars",
            
"three-stars",
            
"four-stars",
            
"five-stars"
        
) as $star) {
            
$rate.= "<li><a href=\"rating.php?id=".(int)$id."&amp;rate=".$i."&amp;ref=".urlencode($_SERVER["REQUEST_URI"])."&amp;what=".$what."\" class=\"".$star."\" onclick=\"do_rate(".$i.",".$id.",'".$what."'); return false\" title=\"".$i." star".($i "s" "")." out of 5\" >$i</a></li>";
            
$i++;
        }
        
$rate.= "</ul>";
    }
    switch (
$what) {
    case 
"torrent":
        
$return "<div id=\"rate_".$id."\">".$rate."</div>";
        break;

    case 
"topic":
        
$return "<div id=\"rate_".$id."\">".$rate."</div>";
        break;
    }
    return 
$return;
}
function 
showRate($rate_sum$rate_count)
{
    
$p = ($rate_count round((($rate_sum $rate_count) * 20) , 2) : 0);
    return 
"<ul class=\"star-rating\"><li style=\"width: ".$p."%;\" class=\"current-rating\" >.</li></ul>";
}
//end putyn's rate mode

?>