added missing files
This commit is contained in:
13
html/functions.php
Normal file
13
html/functions.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
function error($txt) {
|
||||
echo json_encode(array('success' => false, 'txt' => $txt));
|
||||
exit;
|
||||
}
|
||||
|
||||
function success($txt) {
|
||||
echo json_encode(array('success' => true, 'txt' => $txt));
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
40
html/update-messages.js
Normal file
40
html/update-messages.js
Normal file
@@ -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 += '<img src="'+'data:'+file.type+';base64,' + btoa(file.content)+'"/>';
|
||||
});
|
||||
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('<div id="id'+(e["id"])+'" class="msg '+
|
||||
(e["user"]==userid()?"me":"other")+
|
||||
'"><div class="header">'+
|
||||
'<span class="date">'+
|
||||
(new Date(1000*Number(e["time"]))).toLocaleString()+
|
||||
'</span><span class="sender">'+
|
||||
'<a href="javascript:void(0)" onclick="setreceiver(this.innerHTML)">'+
|
||||
e["user"]+
|
||||
'</a></span></div>'+
|
||||
attachments(message.files)+
|
||||
'<div class="text">'+
|
||||
message.text+
|
||||
'</div></div><div class="clear"/>');
|
||||
})
|
||||
.catch(function(e) {
|
||||
// not for me
|
||||
});
|
||||
}, false);
|
Reference in New Issue
Block a user