Commit d714b8d5 authored by Alexei's avatar Alexei

Implement method for loading mentions timeline

Added a replacement method for oauth.get() that takes only two parameters, so we don't need to write the access token everytime we want to call an API method.
parent 25c1f8a6
......@@ -133,7 +133,12 @@ function changeTab(tab) {
}
}
/*$.get('https://quitter.se/rsd.xml', function (data) {
function get(url, callback) {
if (allowed && authenticated)
oauth.get(url, access_token.public, access_token.secret, callback);
}
$.get('https://quitter.no/rsd.xml', function (data) {
parseString(data, function (e, r) {
var apis = r.rsd.service[0].apis;
for (var i = 0; i < apis.length; i++) {
......@@ -145,7 +150,7 @@ function changeTab(tab) {
});
}, "text").done(function () {
getServerConfig();
});*/
});
function getServerConfig() {
$.getJSON(apiUrl + 'statusnet/config.json', function (data) {
......@@ -224,4 +229,60 @@ function loadHomeTimeline() {
tabs.children[0].id = 'selected';
tabs.children[1].id = '';
tabs.children[2].id = '';
}
function loadMentions() {
var notices = document.querySelector('#notices');
while (notices.firstChild) {
notices.removeChild(notices.firstChild);
}
get(apiUrl + 'statuses/mentions.json?include_rts=true', function(a, response, req) {
var data = JSON.parse(response);
console.log(data);
if (req.statusCode == 200 && req.statusMessage == 'OK') {
for (var i = 0; i < data.length; i++) {
var user = data[i].user;
var tweet = document.createElement('div');
tweet.id = 'tweet';
tweet.className = 'tweet';
var author = document.createElement('span');
author.id = 'author';
author.className = 'noticeAuthor';
var authorLink = document.createElement('a');
authorLink.text = user.name + ' @' + user.screen_name;
authorLink.href = user['statusnet:profile_url'];
authorLink.onclick = function () {
window.open(authorLink.href, authorLink.text);
};
author.appendChild(authorLink);
var avatarImage = document.createElement('img');
avatarImage.height = 48;
avatarImage.width = 48;
avatarImage.src = user.profile_image_url_https;
avatarImage.align = 'left';
avatarImage.className = 'authorAvatar';
var notice = document.createElement('p');
notice.id = 'notice';
notice.innerHTML = data[i].statusnet_html;
notice.className = 'notice';
tweet.appendChild(author);
tweet.appendChild(avatarImage);
tweet.appendChild(notice);
notices.appendChild(tweet);
notices.appendChild(document.createElement('br'));
}
}
});
var tabs = document.querySelector('.tabs');
tabs.children[0].id = '';
tabs.children[1].id = '';
tabs.children[2].id = 'selected';
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment