Onionr/onionr/static-data/www/clandestine/js/main.js

28 lines
774 B
JavaScript
Raw Normal View History

2019-06-20 07:59:32 +00:00
friendList = {}
convoListElement = document.getElementsByClassName('conversationList')[0]
function createConvoList(){
2019-06-20 07:59:32 +00:00
console.log(friendList)
for (friend in friendList){
var convoEntry = document.createElement('div')
convoEntry.classList.add('convoEntry')
2019-06-20 07:59:32 +00:00
convoEntry.setAttribute('data-pubkey', friend)
convoEntry.innerText = friendList[friend]
convoListElement.append(convoEntry)
}
}
fetch('/friends/list', {
headers: {
"token": webpass
}})
.then((resp) => resp.json()) // Transform the data into json
.then(function(resp) {
var keys = []
for(var k in resp) keys.push(k)
for (var i = 0; i < keys.length; i++){
2019-06-20 07:59:32 +00:00
friendList[keys[i]] = resp[keys[i]]['name']
}
createConvoList()
})