Четверг, 25.04.2024, 10:58
Главная Регистрация RSS
Приветствую Вас, Гость
НОВЫЕ КОМЕНТАРИИ
Коментарий:Невероятно....это полезный веб-сайты.
Добавил:Stevensleed

Коментарий:Сколько лет прошло, старина?) зарегался, просто вспомнить те времена,
Добавил:Vj PitBulvjpitbul94

Коментарий:Всё исправил, проверил , скачивайте
Добавил:Modred

Коментарий:Классный скрипт , но на PHP
Добавил:ZemHU

Коментарий:Отличный движок Добавил:DexonEdutt

Коментарий:Легко установить Добавил:Mixhoarm

Статистика

Онлайн всего: 1
Гостей: 1
Пользователей: 0

Нас сегодня посетили :
Поиск
Главная » Файлы » Скрипты для UCOZ » Другие скрипты для UCOZ

Скрипт рейтинга для сайта

Скрипт рейтинга для сайта

Доброго времени суток увааемые пользователи и гости. Предлагаю скрипт рейтинга кинопоиска и IMDB.
Установка скрипта:
1. Залить kinopoisk.min.js в файловый менеджер в папку js;

2. В том месте где хотите вывести рейтинг вставляем код:

Код
<div class="site-rating">
<div class="kinopoisk2" data-movie="$OTHER1$"></div>
<script type="text/javascript" src="/js/kinopoisk.min.js"></script>
</div>

 


$OTHER1$ - При добавлении в доп. поле указываем ID фильма с Kinopoisk.
Например находим фильм https://www.kinopoisk.ru/film/582359/ - 582359 в конце это и есть ID фильма, его мы указываем в Доп. Поле 1 при добавлении.

3. В таблицу стилей CSS добавим:

 

Код
.site-rating {overflow:hidden;}
.site-rating b {display:block; color:#0DB9DD; font-size: 15px; margin-top:2px;}
.site-rating small {display:block;color: #8f95a3;font-size: 10px;}
.site-rating .kinopoisk {position:relative; float:left; height:46px; padding:0 20px 0 50px;}
.site-rating .kinopoisk:before {top: 0px; left: 0px; content: ""; width: 46px; height: 46px; position: absolute;background: url(../images/kinopoisk.png) no-repeat 0 0; background-size:90%;}
.site-rating .imdb {position:relative; float:left; height:46px; padding:0 0 0 50px;}
.site-rating .imdb:before {top: 0px; left: 0px; content: ""; width: 46px; height: 46px; position: absolute;background: url(../images/imdb.png) no-repeat 0 0; background-size:90%;}

 


4. В папку images заливаем 2 картинки: kinopoisk.png и imdb.png;
5. Готово! Все вопросы по установке и настройке можете оставлять в комментарии.

Дополнительно:
1. Содержимое скрипта:

 

Код
/**
  * jQuery Kinopoisk Plugin 0.5
  *
  * Kinopoisk is a jQuery plugin that let you easily add to your web page movie rating informer. This informer shows
  * movie rating from kinopois.ru and imdb.com. It does not use any server side scripts. It use javascript and css files only.
  *
  * @name kinopoisk
  * @version 0.6
  * @requires jQuery v1.5.0+
  * @author Dmitry Shamin <dmitry.shamin@gmail.com>
  * @license Dual licensed under the MIT or GPL Version 2 licenses.
  *
  */
!function(t){var e={movie:!1,url:"http://rating.kinopoisk.ru",range:10,fix:1,order:["kinopoisk","imdb"],kinopoisk_template:'<span class="kinopoisk" data-toggle="tooltip" data-placement="bottom" data-original-title="Рейтинг Кинопоиск"><b>$rating</b> <small>$vote</small></span>',imdb_template:'<span class="imdb" data-toggle="tooltip" data-placement="bottom" data-original-title="Рейтинг IMDB"><b>$rating</b> <small>$vote</small></span></span>',cache_time:864e5,no_data:"Нет данных",show_zero_rating:!0},a={init:function(a){return this.each(function(){var r=t(this),n=t.extend({},e,r.data(),a);for(var i in n)if("movie"==i){var o=n[i].toString().split("/");o.length>1?n[i]=o[4]:n[i]=o[0]}r.data({params:n}),r.kinopoisk2("getRating")})},getRating:function(){var e=t(this),r=e.data("params");if(!r.movie)throw"Не указан идентификатор фильма на кинопоиске (data-movie).";var n=a._getCache(e,r.movie);return n?a._showRating(e,n):void t.ajax({type:"GET",url:"http://query.yahooapis.com/v1/public/yql?q="+encodeURIComponent('select * from xml where url="'+r.url+"/"+r.movie+'.xml"')+"&format=xml&callback=?",dataType:"json",success:function(t){return n=a._setCache(e,r.movie,t.results[0]),a._showRating(e,n)},error:function(e){console.log(e),t.error(e.responseText)}})},_getCache:function(e,a){var r=e.data("params"),n=(new Date).getTime(),i=localStorage.getItem("movie_"+a);if(!i)return!1;var o=t.parseXML(i),s=t(o);return n-s.find("cache_time").text()>r.cache_time?(localStorage.removeItem("movie_"+a),!1):i},_setCache:function(e,a,r){var n=e.data("params"),i=(new Date).getTime(),o=localStorage.getItem("movie_"+a),s="<result>"+r+"<cache_time>"+i+"</cache_time></result>";if(o){var p=t.parseXML(o),c=t(p);i-c.find("cache_time").text()>n.cache_time?localStorage.setItem("movie_"+a,s):s=o}else localStorage.setItem("movie_"+a,s);return s},_showRating:function(e,r){var n=e.data("params");if(!r)throw'Проверьте правильность url "'+n.url+'"';var i=t.parseXML(r),o=t(i),s=o.find("kp_rating"),p=o.find("imdb_rating");if(0==s.text()&&0==s.attr("num_vote"))return n.no_data?e.html('<span class="kp_container">'+n.no_data+"</span>"):e;s.text(a.__roundRating(s,n.fix)),p.text(a.__roundRating(p,n.fix)),s.stars=a._getStar(s.text(),n.range),p.stars=a._getStar(p.text(),n.range);var c=a._getTemplate(n.kinopoisk_template,s),l=a._getTemplate(n.imdb_template,p);0==n.show_zero_rating&&(0==s.text()&&(c=""),0==p.text()&&(l=""));var m={kinopoisk:c,imdb:l},_="";for(var u in n.order)n.order.hasOwnProperty(u)&&"undefined"!=typeof m[n.order[u]]&&(_+=m[n.order[u]]);return e.hide().html('<span class="kp_container">'+_+"</span>").fadeIn()},__roundRating:function(t,e){return Math.round(parseFloat(t.text())*Math.pow(10,e))/Math.pow(10,e)},_getTemplate:function(t,e){return t.replace("$rating",e.text()).replace("$vote",e.attr("num_vote")).replace("$stars",e.stars)},_getStar:function(t,e){for(var a="",r=Math.round(t*e/10),n=1;e>=n;n++)a+=r>=n?"<span>★</span>":"<span>☆</span>";return a}};t.fn.kinopoisk2=function(e){try{if(a[e]){if("_"==e.charAt(0))throw"Нельзя вызывать приватный метод";return a[e].apply(this,Array.prototype.slice.call(arguments,1))}if("object"!=typeof e&&e)throw"Метод "+e+" не найден";return a.init.apply(this,arguments)}catch(r){t.error(r)}}}(jQuery),$(document).ready(function(){$(".kinopoisk2").kinopoisk2()});


2. Разберем скрипт:
$rating $vote

Этот код отвечает за шаблон рейтинга Кинопоиска.
$rating - Общий рейтинг (число);
$vote - Это количество проголосовавших.
$rating $vote

Этот код отвечает за шаблон рейтинга iMDB.
$rating - Общий рейтинг (число);
$vote - Это количество проголосовавших.

3. Вы так же можете вывести рейтинг в виде звездочек, заменив $rating на $stars в js скрипте.

4. Поиграв со скриптом и стилями можно получить такой вариант отображения.

СКАЧАТЬ /_ld/4/474_rating.rar [8.2 Kb] (cкачиваний: 147)

Вы можете скачать с нашего сервера бесплатно и без регистрации.

Похожие материалы:

Категория: Другие скрипты для UCOZ | Добавил: mytorrento | Теги: для, сайта, скрипт, рейтинга
Просмотров: 556 | Загрузок: 147 | Рейтинг: 0.0/0
Всего комментариев: 0