// Create Elem function createElem(type, className, appendTo) { var elem = document.createElement(type || 'div'); elem.className = className || ""; appendTo.appendChild(elem); return elem; }
function insertHTML(HTMLcontents, appendTo) { var elem = document.createElement('div'); elem.innerHTML = HTMLcontents; appendTo.appendChild(elem.firstChild); console.log(elem.firstChild); return elem; }
// Add style node function addStyle(css) { var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); style.type = 'text/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } head.appendChild(style); }
// CSS // var css = {}; // css.header = '.ryot-header { transition: all 0.5s ease; opacity:0; font-size:50px; position:absolute; z-index:9999; text-align:center; color:#FFFFFF; box-sizing: border-box; top: 50%; transform: translateY(-50%) translateX(-50%); left: 50%; } .ryot-header img { width:100%; }'; // for (var key in css) { // addStyle(css[key]); // }
// Add HTML Contents to head var heroImage = document.getElementsByClassName('top-media-wrapper')[0]; var headline = createElem("h2", "ryot-header", heroImage); headline.innerHTML = "";
// Show header setTimeout(function() { headline.style.opacity = 1; }, 1500);
function hasClass(elem, className) { return new RegExp(' ' + className + ' ').test(' ' + elem.className + ' '); }
function addClass(elem, className) { if (!hasClass(elem, className)) { elem.className += ' ' + className; } }
function removeClass(elem, className) { var newClass = ' ' + elem.className.replace( /[\t\r\n]/g, ' ') + ' '; if (hasClass(elem, className)) { while (newClass.indexOf(' ' + className + ' ') >= 0 ) { newClass = newClass.replace(' ' + className + ' ', ' '); } elem.className = newClass.replace(/^\s+|\s+$/g, ''); } }
function getWindowHeight() { var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; return height; }
function getScrollPos() { var top = window.pageYOffset || document.documentElement.scrollTop; return top; }
function getOffsetTop(elem) { var yPosition = 0; while(elem) { yPosition += (elem.offsetTop - elem.scrollTop + elem.clientTop); elem = elem.offsetParent; } return yPosition; }
function isInViewport(elem) { var rect = elem.getBoundingClientRect(); var elementTop = getOffsetTop(elem); var elementBottom = elementTop + elem.offsetHeight; var viewportTop = getScrollPos(); var viewportBottom = viewportTop + getWindowHeight(); return elementBottom > viewportTop && elementTop + (elem.offsetHeight/4) < viewportBottom; } function checkVisible() { var elems = document.getElementsByClassName("img-wrapper"); for (var i = 0; i < elems.length; i++) { if (isInViewport(elems[i])) { addClass(elems[i], 'visible') } } } // Changes XML to JSON function xmlToJson(xml) { // Create the return object var obj = {}; if (xml.nodeType == 1) { // element // do attributes if (xml.attributes.length > 0) { obj["@attributes"] = {}; for (var j = 0; j < xml.attributes.length; j++) { var attribute = xml.attributes.item(j); obj["@attributes"][attribute.nodeName] = attribute.nodeValue; } } } else if (xml.nodeType == 3) { // text obj = xml.nodeValue; } else if (xml.nodeType == 4) { // cdata section obj = xml.nodeValue } // do children if (xml.hasChildNodes()) { for(var i = 0; i < xml.childNodes.length; i++) { var item = xml.childNodes.item(i); var nodeName = item.nodeName; if (typeof(obj[nodeName]) == "undefined") { obj[nodeName] = xmlToJson(item); } else { if (typeof(obj[nodeName].push) == "undefined") { var old = obj[nodeName]; obj[nodeName] = []; obj[nodeName].push(old); } obj[nodeName].push(xmlToJson(item)); } } } return obj; }; function strip(html) { var tmp = document.createElement("DIV"); tmp.innerHTML = html; return tmp.textContent || tmp.innerText || ""; } function getHTML(str) { var el = document.createElement( 'html' ); el.innerHTML = str; return el; } function pushPost(item, list) { // Data var title = item.title["#cdata-section"]; var link = item.link["#text"]; var author = item["dc:creator"]["#text"]; var date = item.pubDate["#text"]; var publisher = item["dc:publisher"]; var content = item["content:encoded"]["#cdata-section"]; var stripped = strip(content); var html = getHTML(content); var img = html.getElementsByTagName('img')[0].src; var excerpt = (stripped.length > 200 ? stripped.substring(0,200)+'...' : stripped); // HTML Content var html = `
`; // Push to HTML var li = document.createElement("li"); li.innerHTML = html; list.appendChild(li); }
window.onresize = function() { checkVisible(); } window.onscroll = function() { checkVisible(); }
checkVisible();
var x = new XMLHttpRequest(); x.open("GET", "https://feeds.contenthub.aol.com/syndication/2.0/feed/5b34e062ef0e2", true); x.onreadystatechange = function () { if (x.readyState == 4 && x.status == 200) { var xml = x.responseXML; var data = xmlToJson(xml) var items = data.rss.channel.item; for (var i = 0; i < items.length; i++) { posts.push(items[i]); } } }; x.send(null); var posts = []; window.onload = function() { var feed = document.getElementsByClassName('feed')[0]; var feedList = feed.getElementsByTagName("ul")[0]; for (var i = 0; i < posts.length; i++) { pushPost(posts[i], feedList); } };
HuffPost wants to step away from the media bubble and tell the real story of the UK. For one week we relocate our newsroom to the heart of Birmingham and invite people to tell us what they care about. Listening to the stories of Birmingham, opening up our newsroom to its people and telling the real story of Britain from the heart of one of its biggest and best cities. You decide the news. We'll tell your story. Birmingham, be heard. #HuffPostListens
There's a global problem of trust in the media. Maybe it's because of fake news on the internet. Maybe it's because the American media misread the public mood and called the Trump election wrong. Maybe it's because parts of the UK media called Brexit wrong. But maybe there's also a bigger problem: journalists are spending less time out and about listening to their audience and talking to people. If we can put down our pens, step away from our laptops, turn off social media and really listen to the people, maybe we will understand more and report better.
- Visit our open newsroom at the Bullring and tell us your story
The Newsroom, by the Rotunda, next door to Next
Upper East Mall
Bullring
Birmingham
B5 4BG
Opening times:
Mon-Friday: 10-8
Sat 9-8pm
Sunday 11-5pm - Find us across the city on mobile "Listening Posts" and tell us your story
Top of News Street, near Victoria Square
Town Centre, Marks & Spencer - Email listentobirmingham@huffpost.com, or WhatsApp +44 78968 04043 and tell us your story
- Join our Facebook group and tell us your story
- Visit huffpost.com from Monday and read your stories there
Polly Curtis
Editor-In-Chief HuffPost UK
Dear readers,
Journalism is about telling stories. I became a journalist because I loved the feeling of knowing something, and sharing that with people, making them laugh, cry, or enrage them at an injustice to the point that they just have to do something about it. The question people ask me most about journalism is this: how is news made? How do you know what's happening?
This is how you know: you listen to people, you ask questions, you build relationships with people who know more than you do, you keep an open mind. You ask open ended questions. The full truth is always more complex and messy and fascinating than the headline.
So I am delighted to announce our HuffPost Listens project. We have brought our team of 45 journalists to Birmingham for the week, to open up our newsroom and go out into the city and listen to the people, asking them what the issues that really matter to them are and what we should be reporting on. We hope to find surprising stories, challenge our own ideas about what people want to read about and form a deep relationship with this city that will live on beyond the first week. We are also hiring the established Birmingham journalist, Amardeep Bassey, to join our team permanently and have partnered with the Birmingham Mail on this project.
We want to shift the centre of our gravity outside of London - we will hire in the north of England next and keep expanding into the country to better reflect the country we're in. Join us, tell us your story, we're waiting and ready to listen.
All best,
Polly Curtis