diff --git a/onionr/static-data/www/board/board.js b/onionr/static-data/www/board/board.js index 1f70b8fc..f94bd13d 100755 --- a/onionr/static-data/www/board/board.js +++ b/onionr/static-data/www/board/board.js @@ -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 diff --git a/onionr/static-data/www/board/index.html b/onionr/static-data/www/board/index.html index d52329ed..a5da4787 100755 --- a/onionr/static-data/www/board/index.html +++ b/onionr/static-data/www/board/index.html @@ -18,6 +18,7 @@ + diff --git a/onionr/static-data/www/board/sethumanreadable.js b/onionr/static-data/www/board/sethumanreadable.js new file mode 100644 index 00000000..6ebd3eb4 --- /dev/null +++ b/onionr/static-data/www/board/sethumanreadable.js @@ -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 . +*/ +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(' ') +} \ No newline at end of file diff --git a/onionr/static-data/www/board/theme.css b/onionr/static-data/www/board/theme.css index 2a9eeaff..be1c1ccd 100755 --- a/onionr/static-data/www/board/theme.css +++ b/onionr/static-data/www/board/theme.css @@ -2,4 +2,5 @@ .cMsg{ word-wrap:break-word; word-break:break-word; + white-space: pre-wrap; } \ No newline at end of file diff --git a/onionr/static-data/www/shared/misc.js b/onionr/static-data/www/shared/misc.js index a123fd70..dbdd786e 100755 --- a/onionr/static-data/www/shared/misc.js +++ b/onionr/static-data/www/shared/misc.js @@ -21,7 +21,7 @@ webpass = document.location.hash.replace('#', '') nowebpass = false myPub = "" -fetch('/getActivePubkey', { +fetch('/getHumanReadable', { headers: { "token": webpass }})