2019-02-11 22:36:43 +00:00
|
|
|
/*
|
2019-06-12 00:05:15 +00:00
|
|
|
Onionr - Private P2P Communication
|
2019-02-11 22:36:43 +00:00
|
|
|
|
|
|
|
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 <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-01-16 05:57:47 +00:00
|
|
|
webpass = document.location.hash.replace('#', '')
|
2019-01-17 05:31:56 +00:00
|
|
|
nowebpass = false
|
2019-09-06 22:22:33 +00:00
|
|
|
myPub = ""
|
2019-02-04 23:48:21 +00:00
|
|
|
|
2019-09-07 20:08:15 +00:00
|
|
|
fetch('/getHumanReadable', {
|
2019-09-06 22:22:33 +00:00
|
|
|
headers: {
|
|
|
|
"token": webpass
|
|
|
|
}})
|
2020-03-20 08:46:33 +00:00
|
|
|
.then((resp) => resp.text())
|
2019-09-06 22:22:33 +00:00
|
|
|
.then(function(resp) {
|
|
|
|
myPub = resp
|
|
|
|
})
|
2019-04-15 23:48:11 +00:00
|
|
|
|
2019-02-22 21:04:03 +00:00
|
|
|
function post_to_url(path, params) {
|
|
|
|
|
|
|
|
var form = document.createElement("form")
|
|
|
|
|
|
|
|
form.setAttribute("method", "POST")
|
|
|
|
form.setAttribute("action", path)
|
|
|
|
|
|
|
|
for(var key in params) {
|
|
|
|
var hiddenField = document.createElement("input")
|
|
|
|
hiddenField.setAttribute("type", "hidden")
|
|
|
|
hiddenField.setAttribute("name", key)
|
|
|
|
hiddenField.setAttribute("value", params[key])
|
|
|
|
form.appendChild(hiddenField)
|
|
|
|
}
|
|
|
|
|
|
|
|
document.body.appendChild(form)
|
2020-03-20 08:46:33 +00:00
|
|
|
form.submit()
|
2019-02-22 21:04:03 +00:00
|
|
|
}
|
|
|
|
|
2019-01-16 05:57:47 +00:00
|
|
|
if (typeof webpass == "undefined"){
|
|
|
|
webpass = localStorage['webpass']
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
localStorage['webpass'] = webpass
|
2019-02-01 06:38:12 +00:00
|
|
|
//document.location.hash = ''
|
2019-01-16 05:57:47 +00:00
|
|
|
}
|
|
|
|
if (typeof webpass == "undefined" || webpass == ""){
|
|
|
|
alert('Web password was not found in memory or URL')
|
2019-01-17 05:31:56 +00:00
|
|
|
nowebpass = true
|
2019-01-16 05:57:47 +00:00
|
|
|
}
|
|
|
|
|
2019-02-04 23:48:21 +00:00
|
|
|
function arrayContains(needle, arrhaystack) {
|
|
|
|
return (arrhaystack.indexOf(needle) > -1);
|
|
|
|
}
|
|
|
|
|
2019-01-16 05:57:47 +00:00
|
|
|
function httpGet(theUrl) {
|
2019-01-14 06:14:02 +00:00
|
|
|
var xmlHttp = new XMLHttpRequest()
|
|
|
|
xmlHttp.open( "GET", theUrl, false ) // false for synchronous request
|
|
|
|
xmlHttp.setRequestHeader('token', webpass)
|
|
|
|
xmlHttp.send( null )
|
|
|
|
if (xmlHttp.status == 200){
|
|
|
|
return xmlHttp.responseText
|
|
|
|
}
|
|
|
|
else{
|
2019-01-16 05:57:47 +00:00
|
|
|
return ""
|
2019-01-14 06:14:02 +00:00
|
|
|
}
|
2019-01-16 05:57:47 +00:00
|
|
|
}
|
|
|
|
function overlay(overlayID) {
|
|
|
|
el = document.getElementById(overlayID)
|
|
|
|
el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible"
|
2019-02-10 22:26:47 +00:00
|
|
|
scroll(0,0)
|
2019-01-16 05:57:47 +00:00
|
|
|
}
|
2019-02-01 06:38:12 +00:00
|
|
|
|
|
|
|
var passLinks = document.getElementsByClassName("idLink")
|
|
|
|
for(var i = 0; i < passLinks.length; i++) {
|
|
|
|
passLinks[i].href += '#' + webpass
|
|
|
|
}
|
2020-03-20 08:46:33 +00:00
|
|
|
|
2019-02-01 06:38:12 +00:00
|
|
|
var refreshLinks = document.getElementsByClassName("refresh")
|
|
|
|
|
|
|
|
for(var i = 0; i < refreshLinks.length; i++) {
|
|
|
|
//Can't use .reload because of webpass
|
|
|
|
refreshLinks[i].onclick = function(){
|
|
|
|
location.reload()
|
|
|
|
}
|
|
|
|
}
|
2019-02-22 21:04:03 +00:00
|
|
|
|
2019-03-13 04:56:26 +00:00
|
|
|
for (var i = 0; i < document.getElementsByClassName('closeOverlay').length; i++){
|
|
|
|
document.getElementsByClassName('closeOverlay')[i].onclick = function(e){
|
|
|
|
document.getElementById(e.target.getAttribute('overlay')).style.visibility = 'hidden'
|
|
|
|
}
|
2019-04-15 23:48:11 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 22:22:33 +00:00
|
|
|
function setIdStrings(){
|
|
|
|
if (myPub === ""){
|
|
|
|
setTimeout(function(){setIdStrings()}, 700)
|
|
|
|
return
|
2019-04-15 23:48:11 +00:00
|
|
|
}
|
2019-09-06 22:22:33 +00:00
|
|
|
var idStrings = document.getElementsByClassName('myPub')
|
|
|
|
for (var i = 0; i < idStrings.length; i++){
|
|
|
|
if (idStrings[i].tagName.toLowerCase() == 'input'){
|
|
|
|
idStrings[i].value = myPub
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
idStrings[i].innerText = myPub
|
|
|
|
}
|
2019-04-15 23:48:11 +00:00
|
|
|
}
|
2019-06-28 21:24:34 +00:00
|
|
|
}
|
2019-09-06 22:22:33 +00:00
|
|
|
setIdStrings()
|
2019-06-28 21:24:34 +00:00
|
|
|
|
|
|
|
/* Copy public ID on homepage */
|
2019-08-31 10:56:44 +00:00
|
|
|
if (typeof myPubCopy != "undefined"){
|
|
|
|
|
|
|
|
myPubCopy.onclick = function() {
|
|
|
|
var copyText = document.getElementById("myPub");
|
|
|
|
copyText.select()
|
|
|
|
document.execCommand("copy")
|
2019-09-04 06:20:11 +00:00
|
|
|
if (typeof PNotify != 'undefined'){
|
|
|
|
PNotify.success({
|
|
|
|
text: "Copied to clipboard"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
console.log("copied pubkey to clipboard")
|
2020-03-20 08:46:33 +00:00
|
|
|
}
|
2019-08-31 10:56:44 +00:00
|
|
|
}
|
2019-06-28 21:24:34 +00:00
|
|
|
|
|
|
|
/* For Config toggle on homepage */
|
2019-09-04 06:20:11 +00:00
|
|
|
var toggle = document.getElementById("configToggle")
|
|
|
|
var content = document.getElementById("configContent")
|
2019-06-28 21:24:34 +00:00
|
|
|
|
2019-07-02 22:34:26 +00:00
|
|
|
if(typeof toggle !== 'undefined' && toggle !== null) {
|
|
|
|
toggle.addEventListener("click", function() {
|
|
|
|
content.classList.toggle("show");
|
|
|
|
})
|
2019-09-04 06:20:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var aboutBtns = document.getElementsByClassName('aboutLink')
|
|
|
|
var aboutModals = document.getElementsByClassName('aboutModal')
|
|
|
|
var aboutCloseBtns = document.getElementsByClassName('closeAboutModal')
|
|
|
|
|
|
|
|
var aboutText = ''
|
|
|
|
|
|
|
|
setAbout = function(){
|
|
|
|
if (aboutText === ''){
|
|
|
|
setTimeout(function(){setAbout()}, 100)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
let aboutBody = document.getElementsByClassName('aboutBody')
|
|
|
|
for (i = 0; i < aboutBody.length; i++){
|
|
|
|
aboutBody[i].innerHTML = aboutText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (x = 0; x < aboutBtns.length; x++){
|
|
|
|
aboutBtns[x].onclick = function(){
|
|
|
|
for (i = 0; i < aboutModals.length; i++){
|
|
|
|
aboutModals[i].classList.add('is-active')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < aboutCloseBtns.length; i++){
|
|
|
|
aboutCloseBtns[i].onclick = function(e){
|
|
|
|
e.target.parentElement.parentElement.parentElement.classList.remove('is-active')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setAbout()
|