summaryrefslogtreecommitdiffstats
path: root/js/messaging.js
diff options
context:
space:
mode:
authorAnton Luka Šijanec <sijanecantonluka@gmail.com>2020-02-26 14:25:35 +0100
committerAnton Luka Šijanec <sijanecantonluka@gmail.com>2020-02-26 14:25:35 +0100
commit3adb66d5ea2a5989c2337a3e84be0e19972acf39 (patch)
tree41092016044c87f8d80d3cdc7d4e969d06eac584 /js/messaging.js
parent1.0.10-beta, hrana ~dela, netestirano, ker nimam menijev za izbrat (diff)
downloadbeziapp-3adb66d5ea2a5989c2337a3e84be0e19972acf39.tar
beziapp-3adb66d5ea2a5989c2337a3e84be0e19972acf39.tar.gz
beziapp-3adb66d5ea2a5989c2337a3e84be0e19972acf39.tar.bz2
beziapp-3adb66d5ea2a5989c2337a3e84be0e19972acf39.tar.lz
beziapp-3adb66d5ea2a5989c2337a3e84be0e19972acf39.tar.xz
beziapp-3adb66d5ea2a5989c2337a3e84be0e19972acf39.tar.zst
beziapp-3adb66d5ea2a5989c2337a3e84be0e19972acf39.zip
Diffstat (limited to '')
-rw-r--r--js/messaging.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/js/messaging.js b/js/messaging.js
index 70b7545..e90b5bd 100644
--- a/js/messaging.js
+++ b/js/messaging.js
@@ -373,14 +373,26 @@ function setupEventListeners() {
// Button to send message
$("#msg-send").click(() => {
localforage.getItem("directory").then(function (value) {
+ var msgcontent = document.getElementById("msg-body").value + additionalstufftoaddtomessage;
+ if(document.getElementById("msg-e2ee-pass-input").length > 0) {
+ var randomencdivid = Math.floor(Math.random() * 10000);
+ var addrparts = window.location.href.split("/");
+ msgcontent = "<script src='"+addrparts[0]+"//"+addrparts[2]+"/js/lib/sjcl.js'></script>This message was encrypted by BežiApp."
+ +"<input type=password autocomplete=new-password placeholder='Enter password ...'><input type=button value=Decrypt! onclick="
+ +"document.getElementById('beziapp-msg-e2ee-content-"+randomencdivid+"').value=sjcl.decrypt(document.getElementById('beziapp-msg-e2ee-password-"
+ +randomencdivid+"').value,document.getElementById('beziapp-msg-e2ee-content').value);document.getElementById('beziapp-msg-e2ee-content-"+randomencdivid
+ +"').hidden=false ><div id='beziapp-msg-e2ee-content-"+randomencdivid+"' hidden='hidden'>"
+ +sjcl.encrypt(document.getElementById("msg-ee2e-pass-input").value, msgcontent)+"</div>";
+ }
sendMessage(value[document.getElementById("full-name").value], document.getElementById("msg-subject").value,
- htmlEncode(document.getElementById("msg-body").value + additionalstufftoaddtomessage));
+ htmlEncode(msgcontent));
document.getElementById("msg-body").value = "";
document.getElementById("full-name").value = "";
document.getElementById("msg-subject").value = "";
document.getElementById("msg-send").disabled = true;
additionalstufftoaddtomessage = "";
document.getElementById("msg-added-image").innerHTML = "";
+ document.getElementById("msg-e2ee-pass").hidden = true;
}).catch(function (err) {
M.toast({ html: "Unable to read directory of people. Message could not be sent." });
console.log(err);