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

38 lines
1.1 KiB
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){
2019-07-27 07:29:16 +00:00
var convoEntry = document.createElement('li')
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()
2019-07-27 21:56:06 +00:00
})
// Correct conversation list height
function correctConvoList(){
margin = 50
els = document.getElementsByClassName('convoListContainer')
for (x = 0; x < els.length; x++){
els[x].style.height = window.innerHeight - (2 * margin) + 'px'
}
}
setInterval(function(){correctConvoList()}, 30)