boards now show human readable public key authors

This commit is contained in:
Kevin Froman 2019-09-07 15:08:15 -05:00
parent 818a716cbf
commit 311dda91d6
5 changed files with 45 additions and 3 deletions

View File

@ -65,7 +65,7 @@ function appendMessages(msg, blockHash, beforeHash){
}
else{
humanDate.setUTCSeconds(msgDate)
msgDate = humanDate.toDateString()
msgDate = humanDate.toLocaleTimeString() + ' ' + humanDate.toLocaleDateString()
}
el.className = 'entry'
el.innerText = msg['content']
@ -92,8 +92,9 @@ function appendMessages(msg, blockHash, beforeHash){
div[0].setAttribute('data-bl', blockHash)
div[2].textContent = msg['content']
if (typeof msg['meta']['signer'] != 'undefined'){
if (typeof msg['meta']['signer'] != 'undefined' && msg['meta']['signer'].length > 0){
div[3].textContent = msg['meta']['signer'].substr(0, 5)
setHumanReadableIDOnPost(div[3], msg['meta']['signer'])
div[3].title = msg['meta']['signer']
}
div[4].textContent = msgDate

View File

@ -18,6 +18,7 @@
<script defer src='/shared/node_modules/pnotify/dist/iife/PNotifyButtons.js'></script>
<script defer src='/shared/navbar.js'></script>
<script defer src='/shared/misc.js'></script>
<script defer src='sethumanreadable.js'></script>
<script defer src='board.js'></script>
<script defer src='autorefresh.js'></script>
</head>

View File

@ -0,0 +1,39 @@
/*
Onionr - Private P2P Communication
Set human readable public keys onto post author elements
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
humanReadableKeys = {}
function setHumanReadableIDOnPost(el, key){
if (typeof humanReadableKeys[key] == "undefined"){
fetch('/getHumanReadable/' + key, {
method: 'GET',
headers: {
"token": webpass
}})
.then((resp) => resp.text()) // Transform the data into json
.then(function(data) {
if (data.includes('HTML')){
return
}
humanReadableKeys[key] = data
setHumanReadableIDOnPost(el, key)
})
return
}
el.innerText = humanReadableKeys[key].split(' ').slice(0, 3).join(' ')
}

View File

@ -2,4 +2,5 @@
.cMsg{
word-wrap:break-word;
word-break:break-word;
white-space: pre-wrap;
}

View File

@ -21,7 +21,7 @@ webpass = document.location.hash.replace('#', '')
nowebpass = false
myPub = ""
fetch('/getActivePubkey', {
fetch('/getHumanReadable', {
headers: {
"token": webpass
}})