kolobdur74
Вот концовка скрипта - пагинатор лениво стало переделывать, прилепил костыли:
Свернутый текст
Код://End //Скрипт HTML5 menu.
//888888888888888888888888888888888888888888888888888
//888888888888888888888888888888888888888888888888888
// paginator Ч1.
//888888888888888888888888888888888888888888888888888
(function($){
/*******************************************************************************************/
// jquery.pajinate.js - version 0.2
// A jQuery plugin for paginating through any number of DOM elements
//
// Copyright (c) 2010, Wes Nolte (http://wesnolte.com)
// Liscensed under the MIT License (MIT-LICENSE.txt)
// http://www.opensource.org/licenses/mit-license.php
// Created: 2010-04-16 | Updated: 2010-04-26
/*******************************************************************************************/
$.fn.pajinate = function(options){
// Set some state information
var current_page = 'current_page';
var items_per_page = 'items_per_page';
var meta;
// Setup default option values
window.defaults = {
item_container_id : '.content',
items_per_page : 1,
nav_panel_id : '.page_navigation',
num_page_links_to_display : 10,
start_page : 0,
nav_label_first : 'Первое',
nav_label_prev : 'Назад',
nav_label_next : 'Вперед',
nav_label_last : 'Последнее'
};
var options = $.extend(defaults,options);
var $item_container;
var $page_container;
var $items;
var $nav_panels;
return this.each(function(){
$page_container = $(this);
$item_container = $(this).find(options.item_container_id);
$items = $page_container.find(options.item_container_id).children();
meta = $page_container;
// Initialise meta data
meta.data(current_page,0);
meta.data(items_per_page, options.items_per_page);
// Get the total number of items
var total_items = $item_container.children().size();
// Calculate the number of pages needed
var number_of_pages = Math.ceil(total_items/options.items_per_page);
// Construct the nav bar
var more = '<span class="ellipse more">...</span>';
var less = '<span class="ellipse less">...</span>';
var navigation_html = '<a class="first_link" href="">'+ options.nav_label_first +' </a>';
navigation_html += '<a class="previous_link" href="">'+ options.nav_label_prev +' </a>'+ less;
var current_link = 0;
while(number_of_pages > current_link){
navigation_html += '<a class="page_link" href="" longdesc="' + current_link +'">'+ (current_link + 1) +' </a>';
current_link++;
}
navigation_html += more + '<a class="next_link" href="">'+ options.nav_label_next +' </a>';
navigation_html += '<a class="last_link" href="">'+ options.nav_label_last +' </a>';
// And add it to the appropriate area of the DOM
$nav_panels = $page_container.find(options.nav_panel_id);
$nav_panels.html(navigation_html).each(function(){
$(this).find('.page_link:first').addClass('first');
$(this).find('.page_link:last').addClass('last');
});
// Hide the more/less indicators
$nav_panels.children('.ellipse').hide();
// Set the active page link styling
$nav_panels.find('.previous_link').next().next().addClass('active_page');
/* Setup Page Display */
// And hide all pages
$items.hide();
// Show the first page
$items.slice(0, meta.data(items_per_page)).show();
/* Setup Nav Menu Display */
// Page number slices
var total_page_no_links = $page_container.children(options.nav_panel_id+':first').children('.page_link').size();
options.num_page_links_to_display = Math.min(options.num_page_links_to_display,total_page_no_links);
$nav_panels.children('.page_link').hide(); // Hide all the page links
// And only show the number we should be seeing
$nav_panels.each(function(){
$(this).children('.page_link').slice(0, options.num_page_links_to_display).show();
});
/* Bind the actions to their respective links */
// Event handler for 'First' link
$page_container.find('.first_link').click(function(e){
e.preventDefault();
movePageNumbersRight($(this),0);
goto(0);
});
// Event handler for 'Last' link
$page_container.find('.last_link').click(function(e){
e.preventDefault();
var lastPage = total_page_no_links - 1;
movePageNumbersLeft($(this),lastPage);
goto(lastPage);
});
// Event handler for 'Prev' link
$page_container.find('.previous_link').click(function(e){
e.preventDefault();
showPrevPage($(this));
});
// Event handler for 'Next' link
$page_container.find('.next_link').click(function(e){
e.preventDefault();
showNextPage($(this));
});
// Event handler for each 'Page' link
$page_container.find('.page_link').click(function(e){
e.preventDefault();
goto($(this).attr('longdesc'));
});
// Goto the required page
goto(parseInt(options.start_page));
toggleMoreLess();
});
function showPrevPage(e){
new_page = parseInt(meta.data(current_page)) - 1;
// Check that we aren't on a boundary link
if($(e).siblings('.active_page').prev('.page_link').length==true){
movePageNumbersRight(e,new_page);
goto(new_page);
}
};
function showNextPage(e){
new_page = parseInt(meta.data(current_page)) + 1;
// Check that we aren't on a boundary link
if($(e).siblings('.active_page').next('.page_link').length==true){
movePageNumbersLeft(e,new_page);
goto(new_page);
}
};
function goto(page_num){
var ipp = meta.data(items_per_page);
var isLastPage = false;
// Find the start of the next slice
start_from = page_num * ipp;
// Find the end of the next slice
end_on = start_from + ipp;
// Hide the current page
$items.hide()
.slice(start_from, end_on)
.show();
// Reassign the active class
$page_container.find(options.nav_panel_id).children('.page_link[longdesc=' + page_num +']').addClass('active_page').css('color', 'red')
.siblings('.active_page')
.removeClass('active_page').css('color', 'inherit');
// Set the current page meta data
meta.data(current_page,page_num);
// Hide the more and/or less indicators
toggleMoreLess();
};
// Methods to shift the diplayed index of page numbers to the left or right
function movePageNumbersLeft(e, new_p){
var new_page = new_p;
var $current_active_link = $(e).siblings('.active_page');
if($current_active_link.siblings('.page_link[longdesc=' + new_page +']').css('display') == 'none'){
$nav_panels.each(function(){
$(this).children('.page_link')
.hide() // Hide all the page links
.slice(parseInt(new_page - options.num_page_links_to_display + 1) , new_page + 1)
.show();
});
}
}
function movePageNumbersRight(e, new_p){
var new_page = new_p;
var $current_active_link = $(e).siblings('.active_page');
if($current_active_link.siblings('.page_link[longdesc=' + new_page +']').css('display') == 'none'){
$nav_panels.each(function(){
$(this).children('.page_link')
.hide() // Hide all the page links
.slice( new_page , new_page + parseInt(options.num_page_links_to_display))
.show();
});
}
}
// Show or remove the ellipses that indicate that more page numbers exist in the page index than are currently shown
function toggleMoreLess(){
if(!$nav_panels.children('.page_link:visible').hasClass('last')){
$nav_panels.children('.more').show();
}else {
$nav_panels.children('.more').hide();
}
if(!$nav_panels.children('.page_link:visible').hasClass('first')){
$nav_panels.children('.less').show();
}else {
$nav_panels.children('.less').hide();
}
}
};
})(jQuery);
//End //paginator Ч1.
//888888888888888888888888888888888888888888888888888
//888888888888888888888888888888888888888888888888888
// Скрипт Новости
//888888888888888888888888888888888888888888888888888
$(function () {
for(var i=1;i<11;i++){
$('div.boxrss'+i).append('<div id="bib'+i+'" cellspacing="0" width=100%></div>');
}
$.get('/export.php?type=rss&max=50','',processXML);
function processXML(data){
var NpstPage = 5; //число постов на странице;
var numPost = $(data).find('item:lt(50)').length;
var numPage = parseInt( numPost/NpstPage + (numPost % NpstPage ? 1:0)); //число страниц
for(var i=numPage;i<10;i++){
$('.page_navigation').find('#bib'+(i+1)+',a.page_link[longdesc="'+i+'"]').remove();//div.boxrss'+(i+1),,a.page_link[longdesc="'+i+'"]
}
defaults.num_page_links_to_display = numPage;
var txt = "$('a.page_link:last').click();return false"
$('<a href="" onclick="'+txt+'">Последнее</a>').replaceAll($('.page_navigation').find('a.last_link'))
$(data).find('item').each(function(j){
var N = parseInt(j/NpstPage)+1;
var JAuthor=$(this).find('author').text().slice(14,-1);
var JTitle=$(this).find('title').text();
var JLink=$(this).find('link').text();
var JContent=$(this).find('description').text();
//=======ДОБАВКА ====
var JContTXT = $(JContent);
var JContIMG = JContTXT.find('img.postimg').remove();
var div =$('<div></div>');JContIMG.appendTo(div);
JContIMG = div.html();div.empty();
JContTXT = JContTXT.appendTo(div);
JContTXT = div.html()
//===End//ДОБАВКА ====
var JPosted=$(this).find('pubDate').text().slice(4,-9);
$('#bib'+N).append('<div class="zag"><table style="width:100%" border="0" cellspacing="0" cellpadding="0"><tr><td class="menucaptionleft"></td><td class="menucaption" style="white-space:nowrap">'+ JTitle +'</td><td class="menucaptionright"></td></tr></table></br></div><table width="100%"><tr><td style="text-align: right;vertical-align: middle;color: #FF1493;">'+ JAuthor +' '+ JPosted +'</br></td></tr></table><table width="100%"><tr><td style="vertical-align: middle; width:5%;"><img src="http://s4.uploads.ru/XTQ9m.gif" /></td><td style="vertical-align: middle; width:75%;"></br>'+ JContIMG +' '+ JContTXT +'</br></td></tr><tr><td class="lin"></td><td class="lin"></br><a href="'+ JLink +'" title="'+JTitle+'">Читать далее »</a></br></br></td></tr></table>');
});
//+Audio
$('#paging_container1 div[id^="bib"] td').each (function () {
var bib = $(this);
$(this).map(function () {
var stText = '<embed src="http://forumstatic.ru/files/0013/49/9f/32316.swf?mp3='; var endTxt = '&action=stop&title=Player MP3&color=b1eb95&loop=no&lma=yes&textcolor=000000" quality="high" bgcolor="#ffffff" width="260" height="60" name="FMP3" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
bib.parents('div[id^="bib"]').find('td:contains("[audio]"):contains(".mp3")').each(function(){
var html = $(this).html().replace(/\[audio\]([^\[]+)\[\/audio\]/ig,stText+'$1'+endTxt);
$(this).html(html)
});
text = $(this).html();
if(text.indexOf("pleer.com") != -1) {
player = /\[audio\](.*?)\/tracks\/(.*?)\[\/audio\]/gi
$(this).html(text.replace(player, "<br /><embed src='http://embed.pleer.com/track?id=$2' type='application/x-shockwave-flash' wmode='transparent' width='550' height='124'></embed>"));
}
if(text.indexOf("zippyshare.com") != -1) {
player = /\[audio\]http:\/\/www(\d+)\.zippyshare\.com\/v\/(\d+)\/file\.html\[\/audio\]/gi
$(this).html(text.replace(player, "<br /><embed type='application/x-shockwave-flash' src='http://api.zippyshare.com/api/mediaplayer/mediaplayer.swf' flashvars='height=20&width=400&file=http://www$1.zippyshare.com/downloadMusic%3Fkey%3D$2%26&volume=80&autostart=false&frontcolor=0x000000&backcolor=0xffffff&lightcolor=0x000000&type=flv' quality='high' menu='false' wmode='transparent' allowscriptaccess='always' height='20' width='400' name='mp3player' border='0' style='margin-bottom: 6px;'/>"));
}
if(text.indexOf("http://rghost.ru") != -1) {
player = /\[audio\](.*?)\/(\d+)\[\/audio\]/g
$(this).html(text.replace(player, "<br /><object height='20' width='455' type='application/x-shockwave-flash' data='http://rghost.ru/flash/mediaplayer.swf' id='preview_mp3' style='visibility: visible;'><param name='flashvars' value='file=http://rghost.ru/download/action/$2/mp3&streamer=http://rghost.ru/download/action/$2/mp3'></object>"));
}
}); });
//End//+Audio
} });
//End //Скрипт Новости
//888888888888888888888888888888888888888888888888888
//888888888888888888888888888888888888888888888888888
// Скрипт Дата
//888888888888888888888888888888888888888888888888888
// Дата.
var dayarray=new Array("Понедельник","Вторник","Среда","Четверг","Пятница","Суббота","Воскресенье")
var montharray=new Array("Января","Февраля","Марта","Апреля","Мая","Июня","Июля","Августа","Сентября","Октября","Ноября","Декабря")
function getthedate() {
var mydate=new Date()
var year=mydate.getFullYear()
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym < 10) {
daym="0"+daym
}
var cdate= ""+dayarray[day]+" "+" "+daym+" "+montharray[month]+" "+" "+year+" "+"года"+" "
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit() {
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}
window.onload=goforit
//End //Скрипт Дата
//888888888888888888888888888888888888888888888888888
По крупному еще два дела
Заменить эти куки для меню (//Скрипт HTML5 menu.)
И добавить функцию, дающую возможности вставки внешних дополнительных скриптов перераспарса контента, дабы не лопатить каждый раз скрипт.
К примеру быстрая добавка слайдера сериалов или новых видеохостингов
Функция будет добавляться перед скриптом(если есть необходимость)
типо
<script type="text/javascript">
function addContentParse_ (pstContent){
//Тут перераспарс вставленного контента;
}
</script>
<script type="text/javascript" src="http://forumstatic.ru/files/0013/49/9f/33549.js"></script>
Отредактировано Deff (Пт, 13 Сен 2013 19:19:28)