18
| <![CDATA[<script type="text/javascript">
/************************************************************************************************************
(C) www.dhtmlgoodies.com, January 2006
This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.
Version: 1.0 : January 16th - 2006
Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.
Thank you!
www.dhtmlgoodies.com
Alf Magne Kalleland
************************************************************************************************************/
var rssBoxTxt_readMore = 'Leia mais...';
var rssBoxOpenLinksInNewWindow = true;
var rssBoxPadding = 2;
var rssBox_slideSpeed = 7; // Higher = faster slide
var rssBox_waitBetweenEachSlideStep = 5; // Lower = faster
var rssBoxAjaxObjects = new Array();
var currentZIndex = 0;
var slideCounter = 0;
function changeSlide(boxId,secondBetweenSlides,slideIndex)
{
var el = document.getElementById(boxId);
var divs = el.getElementsByTagName('DIV');
divs[slideIndex].style.left = divs[slideIndex].parentNode.offsetWidth + 'px';
divs[slideIndex].style.display='block';
divs[slideIndex].style.zIndex = currentZIndex;
currentZIndex++;
slideRssBox(boxId,slideIndex,secondBetweenSlides,divs[slideIndex].id);
}
function slideRssBox(boxId,slideIndex,secondBetweenSlides,slideId)
{
var obj = document.getElementById(slideId)
var left = obj.style.left.replace('px','')/1;
left = left - rssBox_slideSpeed;
if(left<rssBoxPadding)left=rssBoxPadding;
obj.style.left = left + 'px';
if(left>rssBoxPadding){
setTimeout('slideRssBox("' + boxId + '",' + slideIndex + ',' + secondBetweenSlides + ',"' + slideId + '")',rssBox_waitBetweenEachSlideStep);
}else{
slideIndex++;
var el = document.getElementById(boxId)
var divs = el.getElementsByTagName('DIV');
if(slideIndex>=divs.length)slideIndex = 0;
setTimeout('changeSlide("' + boxId + '",' + secondBetweenSlides + ',' + slideIndex + ')',secondBetweenSlides*1000);
}
}
function openUrlInNewWindow()
{
var rssBoxWin = window.open(this.href);
return false;
}
function showAjaxContent(ajaxIndex,boxId,secondBetweenSlides)
{
var rssContent = rssBoxAjaxObjects[ajaxIndex].response;
tokens = rssContent.split(/\n\n/g);
var destinationObj = document.getElementById(boxId);
destinationObj.innerHTML = '';
var headerTokens = tokens[0].split(/\n/g);
if(headerTokens[0]=='0'){
headerTokens[1] = '';
headerTokens[0] = 'Invalid source';
}
for(var no=1;no<tokens.length;no++){ // Looping through RSS items
var string = '';
var itemTokens = tokens[no].split(/##/g);
var div = document.createElement('DIV');
div.style.position = 'absolute';
div.style.top = '0px';
div.className='slide';
div.id = 'rssSlide' + slideCounter;
slideCounter ++;
if(no>1)div.style.display='none';
destinationObj.appendChild(div);
div.style.width = (div.parentNode.clientWidth - (rssBoxPadding*2)) + 'px';
div.style.height = (div.parentNode.offsetHeight + 10) + 'px';
// Adding date
var date = document.createElement('P');
date.className='rssBoxDate';
date.innerHTML = itemTokens[1];
div.appendChild(date);
// Adding heading
var heading = document.createElement('P');
heading.className = 'rssBoxHeading';
heading.innerHTML = itemTokens[0];
div.appendChild(heading);
// Adding description
var description = document.createElement('P');
description.className='rssBoxDescription';
description.innerHTML = itemTokens[2];
div.appendChild(description);
// Adding link
var link = document.createElement('A');
link.className = 'rssBoxLink';
link.innerHTML = rssBoxTxt_readMore;
link.href = itemTokens[3];
if(rssBoxOpenLinksInNewWindow){
link.onclick = openUrlInNewWindow;
}
div.appendChild(link);
}
setTimeout('changeSlide("' + boxId + '",' + secondBetweenSlides + ',1)',secondBetweenSlides*1000);
}
function insertAjaxContent(destinationId,url,maxItems,secondBetweenSlides)
{
var ajaxIndex = rssBoxAjaxObjects.length;
rssBoxAjaxObjects[ajaxIndex] = new sack();
rssBoxAjaxObjects[ajaxIndex].requestFile = 'readRSS.php?rssURL=' + url + '&maxRssItems=' + maxItems; // Specifying which file to get
rssBoxAjaxObjects[ajaxIndex].onCompletion = function(){ showAjaxContent(ajaxIndex,destinationId,secondBetweenSlides); }; // Specify function that will be executed after file has been found
rssBoxAjaxObjects[ajaxIndex].runAJAX(); // Execute AJAX function
}
function initRssBoxScript()
{
insertAjaxContent('rssBox','rss.xml',5,4);
}
window.onload = initRssBoxScript;
</script>]]>
|