aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEv Bogue <ev@evbogue.com>2020-01-11 07:43:32 -0600
committerEv Bogue <ev@evbogue.com>2020-01-11 07:43:32 -0600
commit2995dfc6982846494f493a5eb1dc7ffc2e3687c1 (patch)
tree6709577d6b8643643740c744fca915ea253adb52
parentdac0064cf55e6a3f9321ea78875bfe8ca9952fc3 (diff)
finish adding backgrounds
-rw-r--r--css/style.css2
-rw-r--r--identify.js89
-rw-r--r--render.js20
-rw-r--r--views.js92
4 files changed, 169 insertions, 34 deletions
diff --git a/css/style.css b/css/style.css
index 26784e7..cfa5012 100644
--- a/css/style.css
+++ b/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;}
diff --git a/identify.js b/identify.js
index f56a0f9..acda8c8 100644
--- a/identify.js
+++ b/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
}
diff --git a/render.js b/render.js
index faf3c17..5ecbdda 100644
--- a/render.js
+++ b/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
diff --git a/views.js b/views.js
index d6fb5f2..f98b88c 100644
--- a/views.js
+++ b/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))
})