From 6ed731fbe9ca7570e0f55a1b4e1c36532aa81bbc Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 3 Feb 2019 18:31:03 -0600 Subject: [PATCH] more work on mail --- onionr/api.py | 8 +++ onionr/static-data/www/mail/index.html | 6 +- onionr/static-data/www/mail/mail.css | 10 +++ onionr/static-data/www/mail/mail.js | 71 +++++++++++++++++++- onionr/static-data/www/shared/main/style.css | 2 +- 5 files changed, 91 insertions(+), 6 deletions(-) diff --git a/onionr/api.py b/onionr/api.py index 19f3db97..be793772 100755 --- a/onionr/api.py +++ b/onionr/api.py @@ -436,6 +436,14 @@ class API: @app.route('/getuptime') def showUptime(): return Response(str(self.getUptime())) + + @app.route('/getActivePubkey') + def getActivePubkey(): + return Response(self._core._crypto.pubKey) + + @app.route('/getHumanReadable/') + def getHumanReadable(name): + return Response(self._core._utils.getHumanReadableID(name)) self.httpServer = WSGIServer((self.host, bindPort), app, log=None, handler_class=FDSafeHandler) self.httpServer.serve_forever() diff --git a/onionr/static-data/www/mail/index.html b/onionr/static-data/www/mail/index.html index a811eaa7..2723677a 100755 --- a/onionr/static-data/www/mail/index.html +++ b/onionr/static-data/www/mail/index.html @@ -15,10 +15,10 @@ Onionr Mail
- +
Current Used Identity:


-
- +
+
Nothing here yet 😞
diff --git a/onionr/static-data/www/mail/mail.css b/onionr/static-data/www/mail/mail.css index 304e6803..50b86b49 100755 --- a/onionr/static-data/www/mail/mail.css +++ b/onionr/static-data/www/mail/mail.css @@ -30,4 +30,14 @@ input{ .btn-group { margin-bottom: 2em; + } + +#tabBtns{ + margin-bottom: 3em; + display: block; +} + + .activeTab{ + color: black; + background-color: gray; } \ No newline at end of file diff --git a/onionr/static-data/www/mail/mail.js b/onionr/static-data/www/mail/mail.js index 900ec14c..8199e35f 100755 --- a/onionr/static-data/www/mail/mail.js +++ b/onionr/static-data/www/mail/mail.js @@ -1,6 +1,47 @@ +/* + Onionr - P2P Anonymous Storage Network + + This file handles the mail interface + + 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 . +*/ + pms = '' threadPart = document.getElementById('threads') threadPlaceholder = document.getElementById('threadPlaceholder') +tabBtns = document.getElementById('tabBtns') + +myPub = httpGet('/getActivePubkey') + +function setActiveTab(tabName){ + threadPart.innerHTML = "" + switch(tabName){ + case 'inbox': + getInbox(); + break + case 'sentbox': + console.log(tabName) + break + case 'drafts': + console.log(tabName) + break + case 'send message': + console.log(tabName) + break + } +} + function getInbox(){ var showed = false for(var i = 0; i < pms.length; i++) { @@ -26,7 +67,7 @@ function getInbox(){ var dateStr = document.createElement('span') var humanDate = new Date(0) humanDate.setUTCSeconds(resp['meta']['time']) - senderInput.value = resp['meta']['signer'] + senderInput.value = httpGet('/getHumanReadable/' + resp['meta']['signer']) bHashDisplay.innerText = pms[i - 1].substring(0, 10) bHashDisplay.setAttribute('hash', pms[i - 1]); senderInput.readOnly = true @@ -52,6 +93,7 @@ function getInbox(){ } + fetch('/getblocksbytype/pm', { headers: { "token": webpass @@ -59,6 +101,31 @@ fetch('/getblocksbytype/pm', { .then((resp) => resp.text()) // Transform the data into json .then(function(data) { pms = data.split(',') - getInbox(pms) + setActiveTab('inbox') }) +tabBtns.onclick = function(event){ + var children = tabBtns.children + for (var i = 0; i < children.length; i++) { + var btn = children[i] + btn.classList.remove('activeTab') + } + event.target.classList.add('activeTab') + setActiveTab(event.target.innerText.toLowerCase()) +} + + +var idStrings = document.getElementsByClassName('myPub') +var myHumanReadable = httpGet('/getHumanReadable/' + myPub) +for (var i = 0; i < idStrings.length; i++){ + if (idStrings[i].tagName.toLowerCase() == 'input'){ + idStrings[i].value = myHumanReadable + } + else{ + idStrings[i].innerText = myHumanReadable + } +} + +for (var i = 0; i < document.getElementsByClassName('refresh').length; i++){ + document.getElementsByClassName('refresh')[i].style.float = 'right' +} \ No newline at end of file diff --git a/onionr/static-data/www/shared/main/style.css b/onionr/static-data/www/shared/main/style.css index 69e1a407..d2ff44e3 100755 --- a/onionr/static-data/www/shared/main/style.css +++ b/onionr/static-data/www/shared/main/style.css @@ -37,7 +37,7 @@ body{ align-items:center; } .logo{ - max-width: 25%; + max-width: 20%; vertical-align: middle; } .logoText{