Created
March 3, 2022 08:54
-
-
Save jmlich/a6f6d0985c1a75f333ba65303cc29510 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body style="background-color: #333; color: #ccc;"> | |
<div id="news_frame" style="width:0; height:0"></div> | |
<script> | |
function news_frame(element_id, w, h) { | |
if (navigator.language != 'ru') { | |
return; | |
} | |
// var url = 'https://feeds.a.dj.com/rss/RSSWorldNews.xml'; | |
var url = 'http://feeds.bbci.co.uk/russian/rss.xml'; | |
var xhr = new XMLHttpRequest(); | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState == 4 && xhr.status == 200) { | |
var parser = new DOMParser(); | |
var xmlDoc = parser.parseFromString(xhr.responseText, 'text/xml'); | |
var posts = ''; | |
title = xmlDoc.getElementsByTagName('title'); | |
link = xmlDoc.getElementsByTagName('link'); | |
posts += '<ul>'; | |
for (i = 0; i < title.length; i++) { | |
posts += '<li><article class="blog-post"><a href="' + link[i].childNodes[0].nodeValue + '">' + title[i].childNodes[0].nodeValue + '</a></article></li>'; | |
} | |
posts += '</ul>'; | |
var el = document.getElementById(element_id); | |
el.innerHTML = "new frame"; | |
el.style.width = w; | |
el.style.height = h; | |
} | |
} | |
xhr.open('GET', url, true); | |
xhr.setRequestHeader('Access-Control-Allow-Origin','*'); | |
xhr.setRequestHeader('Content-type','application/json'); | |
xhr.setRequestHeader('Access-Control-Allow-Methods','GET'); | |
xhr.send(); | |
} | |
news_frame("news_frame", "100%","400px") | |
</script> | |
<a class="twitter-timeline" href="https://twitter.com/bbcrussian?ref_src=twsrc%5Etfw">Tweets by bbcrussian</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment