function getRSS(url) { /*A*/ if (window.ActiveXObject) //IE xhr = new ActiveXObject("Microsoft.XMLHTTP"); else if (window.XMLHttpRequest) //other xhr = new XMLHttpRequest(); else alert("your browser does not support AJAX"); /*B*/ document.getElementById('waitImg').style.display = 'block'; xhr.open("GET",url,true); /*C*/ xhr.setRequestHeader("Cache-Control", "no-cache"); xhr.setRequestHeader("Pragma", "no-cache"); /*D*/ xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { /*F*/ if (xhr.responseXML != null) processRSS(xhr.responseXML); else { //alert("Failed to receive RSS file from the server - file not found."); document.getElementById('chan_title').innerHTML = "Failed to receive RSS file from the server - file not found."; document.getElementById('waitImg').style.display = 'none'; return false; } } else { //alert("Error code " + xhr.status + " received: " + xhr.statusText); errStr = "Error code " + xhr.status + " received: " + xhr.statusText; document.getElementById('chan_title').innerHTML = errStr; document.getElementById('waitImg').style.display = 'none'; } } } /*E*/ xhr.send(null); //document.getElementById('waitImg').style.display = 'none'; } function processRSS(rssxml) { RSS = new RSS2Channel(rssxml); showRSS(RSS); } function RSS2Channel(rssxml) { /*A*/ /*required string properties*/ this.title; this.link; this.description; /*optional string properties*/ this.language; this.copyright; this.managingEditor; this.webMaster; this.pubDate; this.lastBuildDate; this.generator; this.docs; this.ttl; this.rating; /*optional object properties*/ this.category; this.image; /*array of RSS2Item objects*/ this.items = new Array(); /*B*/ var chanElement = rssxml.getElementsByTagName("channel")[0]; var itemElements = rssxml.getElementsByTagName("item"); /*C*/ count = Math.min(itemElements.length, 20); for (var i=0; i0) imageHTML += " width='" + RSS.image.width + "'"; if(RSS.image.height>0) imageHTML += " height='" + RSS.image.height + "'"; imageHTML += "' src='"+RSS.image.url +"' "+"/>"; /*C2*/ document.getElementById("chan_image_link").innerHTML = imageHTML; } /*B*/ var properties = new Array("title", /* "link","description", "pubDate", */ "copyright"); for (var i=0; i "; item_html += (RSS.items[i].title == null) ? "" : "" + RSS.items[i].title + ""; item_html += ""; item_html += (RSS.items[i].description == null) ? "" : ""; dateString = ''; bufDateString = ''; if(RSS.items != null && RSS.items[i].pubDate != null) { itemDate = new Date(RSS.items[i].pubDate); if(!isNaN(itemDate.getDay())) { dateString = '[day]/[mon]/[year] [hour]:[min]:[sec]'; dateString = dateString.replace("[day]", itemDate.getDate()); dateString = dateString.replace('[mon]', itemDate.getMonth()+1); dateString = dateString.replace('[year]', itemDate.getFullYear()); dateString = dateString.replace('[hour]', itemDate.getHours()); dateString = dateString.replace('[min]', itemDate.getMinutes()); dateString = dateString.replace('[sec]', itemDate.getSeconds()); bufDateString = itemDate.getDate() + '/' + (itemDate.getMonth()+1) + '/' + itemDate.getYear(); } else { dateString = RSS.items[i].pubDate; bufDateString = RSS.items[i].pubDate; } item_html += "
" + dateString + "
"; } //item_html += (RSS.items[i].pubDate == null) ? "" : "
" + dateString + "
"; item_html += ""; document.getElementById("chan_items").innerHTML += item_html; /*D1*/ clipboardString += "--------------------------------------\r\n" + RSS.items[i].title + "\r\n" + bufDateString + "\r\n" + RSS.items[i].description + "\r\n" + RSS.items[i].link + "\r\n\r\n"; } document.getElementById('waitImg').style.display = 'none'; return true; } function descShowHide(id) { if(document.getElementById(id).style.display=='none') document.getElementById(id).style.display = 'block'; else document.getElementById(id).style.display = 'none'; } function copytobuff() { if (window.clipboardData) { window.clipboardData.setData('Text',clipboardString) } else { alert('Ваш браузер не поддерживает операции с буфером обмена'); } }