From 92dd3d848eeb940bf3c78aa9aab33d2118743319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Wed, 8 Jul 2015 07:13:58 +0000 Subject: [PATCH] added missing files --- html/functions.php | 13 +++++++++++++ html/update-messages.js | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 html/functions.php create mode 100644 html/update-messages.js diff --git a/html/functions.php b/html/functions.php new file mode 100644 index 0000000..e27ad42 --- /dev/null +++ b/html/functions.php @@ -0,0 +1,13 @@ + false, 'txt' => $txt)); + exit; +} + +function success($txt) { + echo json_encode(array('success' => true, 'txt' => $txt)); + exit; +} + +?> \ No newline at end of file diff --git a/html/update-messages.js b/html/update-messages.js new file mode 100644 index 0000000..202f1a8 --- /dev/null +++ b/html/update-messages.js @@ -0,0 +1,40 @@ +importScripts('jquery.js'); +importScripts('openpgp.js'); + +function attachments(files) { + var res = ''; + if (files) files.forEach(function(file) { + if (file.type.match("^image/")) + res += ''; + }); + return res; +} + +addEventListener('message', function(data) { + var e = data.e; + var key = data.key; + var message = openpgp.message.readArmored(e["msg"]); + var privkey = privateKey().keys[0]; + if (privkey.decrypt(password)) + openpgp.decryptAndVerifyMessage(privkey, key.keys, message) + .then(function(msg) { + var message = JSON.parse(msg.text); + // todo: check msg.signatures[0].valid + postMessage('
'+ + ''+ + (new Date(1000*Number(e["time"]))).toLocaleString()+ + ''+ + ''+ + e["user"]+ + '
'+ + attachments(message.files)+ + '
'+ + message.text+ + '
'); + }) + .catch(function(e) { + // not for me + }); +}, false);