Browse Source

finish adding backgrounds

master
Ev Bogue 3 years ago
parent
commit
2995dfc698
  1. 2
      css/style.css
  2. 89
      identify.js
  3. 20
      render.js
  4. 92
      views.js

2
css/style.css

@ -240,7 +240,7 @@ form.search {
text-decoration: none;
}
.profileAvatar { width: 75px; vertical-align: top; border-radius: 5px; object-fit: cover; margin-right: .25em; margin-bottom: .25em;}
.profileAvatar { width: 95px; height: 95px; vertical-align: top; border-radius: 5px; object-fit: cover; margin-right: .25em; margin-bottom: .25em;}
.avatar { width: 25px; height: 25px; vertical-align: middle; object-fit: cover; border-radius: 5px; margin-right: .5em; }
.image { width: 75px; height: 75px; object-fit: cover; margin-right: .2em; border-radius: 5px; cursor: pointer;}

89
identify.js

@ -3,7 +3,10 @@ function identify (src, profile, keys, name) {
var identifyDiv = h('div')
if ((src[0] == '@') && (src != keys.publicKey)) {
identifyDiv.appendChild(h('p', ['Please note: ' + src + ' is not you.']))
identifyDiv.appendChild(h('p', [
'Please note: ' + src.substring(0, 10) + '... is not you. You are: ',
h('a', {href: '#' + keys.publicKey}, [keys.publicKey.substring(0, 10) + '...'])
]))
}
var photoURL = {}
@ -148,8 +151,67 @@ function identify (src, profile, keys, name) {
}, ['Publish'])
])
var descInput = h('textarea', {placeholder: 'New description'})
var newDescription = h('div', [
descInput,
h('button', {
onclick: function () {
if (descInput.value) {
content = {
type: 'description',
descripted: src,
description: descInput.value
}
publish(content, keys).then(post => {
open(post).then(msg => {
descInput.value = ''
scroller.insertBefore(render(msg, keys), scroller.childNodes[1])
})
})
newDescription.parentNode.removeChild(newDescription)
identifyDiv.appendChild(identifyButton)
}
}
}, ['Publish']),
h('button', {
onclick: function () {
identifyDiv.appendChild(identifyButtons)
newDescription.parentNode.removeChild(newDescription)
}
}, ['Cancel'])
])
var locInput = h('input', {placeholder: 'New location'})
var newLocation = h('div', [
locInput,
h('button', {
onclick: function () {
if (locInput.value) {
content = {
type: 'location',
located: src,
loc: locInput.value
}
publish(content, keys).then(post => {
open(post).then(msg => {
locationInput.value = ''
scroller.insertBefore(render(msg, keys), scroller.childNodes[1])
})
})
newLocation.parentNode.removeChild(newLocation)
identifyDiv.appendChild(identifyButton)
}
}
}, ['Publish']),
h('button', {
onclick: function () {
identifyDiv.appendChild(identifyButtons)
newLocation.parentNode.removeChild(newLocation)
}
}, ['Cancel'])
])
var nameInput = h('input', {placeholder: 'New name'})
@ -198,6 +260,13 @@ function identify (src, profile, keys, name) {
identifyButtons.parentNode.removeChild(identifyButtons)
}
}, ['New background']))
identifyButtons.appendChild(h('button', {
onclick: function () {
identifyDiv.appendChild(newDescription)
identifyButtons.parentNode.removeChild(identifyButtons)
}
}, ['New description']))
}
//}, ['Identify ' + src.substring(0, 10) + '... with a new name']),
identifyButtons.appendChild(h('button', {
@ -206,6 +275,15 @@ function identify (src, profile, keys, name) {
identifyButtons.parentNode.removeChild(identifyButtons)
}
}, ['New image']))
identifyButtons.appendChild(h('button', {
onclick: function () {
identifyDiv.appendChild(newLocation)
identifyButtons.parentNode.removeChild(identifyButtons)
}
}, ['New location']))
//}, ['Identify ' + src.substring(0, 10) + '... with a new photo']),
identifyButtons.appendChild(h('button', {
onclick: function () {
@ -213,7 +291,7 @@ function identify (src, profile, keys, name) {
identifyButtons.parentNode.removeChild(identifyButtons)
}
}, ['Cancel']))
if (src[0] == '@') {
/*if (src[0] == '@') {
var identifyButton = h('button', {
onclick: function () {
profile.appendChild(identifyDiv)
@ -221,15 +299,16 @@ function identify (src, profile, keys, name) {
identifyButton.parentNode.removeChild(identifyButton)
}
}, ['Identify ' + name])
} else {
} else { */
var identifyButton = h('button', {
onclick: function () {
profile.appendChild(identifyDiv)
profile.appendChild(identifyButtons)
identifyButton.parentNode.removeChild(identifyButton)
}
}, ['Add to ' + src.substring(0, 10) + '...'])
}
//}, ['Add to ' + src.substring(0, 10) + '...'])
}, ['+'])
//}
return identifyButton
}

20
render.js

@ -15,6 +15,8 @@ function getHeader (post, keys, mini) {
var head = h('span', [
h('p', {classList: 'right'}, [
getLoc(post),
' ',
h('a', {href: '#' + post.key}, [
human(new Date(post.timestamp)),
]),
@ -204,9 +206,25 @@ function render (msg, keys, preview) {
h('img', {src: msg.background, classList: 'avatar'})
])
message.appendChild(getHeader(msg, keys, mini))
}
} if (msg.type == 'description') {
var mini = h('span', [
' added a description to ',
h('a', { href: '#' + msg.descripted }, [msg.descripted.substring(0, 10) + '...']),
' ',
h('div', {innerHTML: marked(msg.description)})
])
message.appendChild(getHeader(msg, keys, mini))
} if (msg.type == 'location') {
var mini = h('span', [
' added a location to ',
h('a', { href: '#' + msg.located }, [msg.located.substring(0, 10) + '...']),
': ',
msg.loc
])
message.appendChild(getHeader(msg, keys, mini))
}
messageDiv.appendChild(message)
return messageDiv

92
views.js

@ -4,7 +4,36 @@ function threadPage (src, keys) {
})
}
function getLoc (src) {
var loc = h('span')
bog().then(log => {
if (log) {
for (var i = 0; i < log.length; i++) {
if (((log[i].located === src) && (log[i].author === src)) || ((log[i].located === src.key) && (log[i].author === src.author))) {
// if you've identified someone as something else show that something else
return loc.textContent = log[i].loc
}
}
}
})
return loc
}
function profilePage (src, keys) {
var interval = 500
timer = function() {
if (src === window.location.hash.substring(1)) {
if (interval < 10000) { interval = interval + 50 }
sync([src], keys)
setTimeout(timer, interval)
}
}
timer()
var msg = {}
msg.author = src
@ -12,6 +41,21 @@ function profilePage (src, keys) {
var profile = h('div', {classList: 'profile'})
var banner = h('div', {classList: 'banner'})
function getDesc (src) {
var desc = h('span')
bog().then(log => {
if (log) {
for (var i = 0; i < log.length; i++) {
if ((log[i].descripted === src) && (log[i].author === src)) {
// if you've identified someone as something else show that something else
return desc.innerHTML = marked(log[i].description)
}
}
}
})
return desc
}
function getBg (src, profile) {
bog().then(log => {
if (log) {
@ -26,33 +70,23 @@ function profilePage (src, keys) {
})
}
getBg(src, profile)
profileDiv.appendChild(banner)
profileDiv.appendChild(profile)
scroller.appendChild(profileDiv)
var subs = [src]
var interval = 2500
timer = function() {
if (src === window.location.hash.substring(1)) {
if (interval < 10000) { interval = interval + 50 }
sync(subs, keys)
setTimeout(timer, interval)
}
}
timer()
profile.appendChild(h('a', {href: '#' + src}, [
getImage(src, keys, 'profileAvatar'),
getName(src, keys),
profile.appendChild(h('span', {classList: 'right'}, [getLoc(src)]))
profile.appendChild(h('div', [
h('a', {href: '#' + src}, [
getImage(src, keys, 'profileAvatar'),
getName(src, keys)
]),
profile.appendChild(getDesc(src))
]))
profile.appendChild(h('br'))
quickName(src).then(name => {
profile.appendChild(identify(src, profile, keys, name))
var mentionsButton = h('button', {
onclick: function () {
location.href = '#?' + src
@ -66,6 +100,15 @@ function profilePage (src, keys) {
}, ['Reply to ' + name])
profile.appendChild(respond)
profile.appendChild(h('button', {
onclick: function () {
localforage.removeItem(src).then(function () {
var home = true
regenerate(home)
})
}
}, ['Delete ' + name + '\'s feed']))
if (src != keys.publicKey) {
localforage.getItem('subscriptions').then(function (subs) {
if (subs.includes(src)) {
@ -83,17 +126,12 @@ function profilePage (src, keys) {
}
}, ['Subscribe to ' + name]))
}
profile.appendChild(identify(src, profile, keys))
})
} else {
profile.appendChild(identify(src, profile, keys))
}
profile.appendChild(h('button', {
onclick: function () {
localforage.removeItem(src).then(function () {
var home = true
regenerate(home)
})
}
}, ['Delete ' + name + '\'s feed']))
//profile.appendChild(identify(src, profile, keys, name))
})

Loading…
Cancel
Save