Manual merge of notify.js

pull/1/head
Caleb James DeLisle 7 years ago
commit 2ad9fcee17

@ -600,6 +600,7 @@ noscript {
width: ~"calc(100% - 6px)"; width: ~"calc(100% - 6px)";
height: 25px; height: 25px;
line-height: 25px; line-height: 25px;
overflow: hidden;
.usage { .usage {
height: 100%; height: 100%;
display: inline-block; display: inline-block;

@ -685,13 +685,13 @@ define(function () {
// Tips // Tips
out.tips = {}; out.tips = {};
out.tips.lag = "The green icon in the upper right shows the quality of your internet connection to the CryptPad server.";
out.tips.shortcuts = "`ctrl+b`, `ctrl+i` and `ctrl+u` are quick shortcuts for bold, italic and underline."; out.tips.shortcuts = "`ctrl+b`, `ctrl+i` and `ctrl+u` are quick shortcuts for bold, italic and underline.";
out.tips.indent = "In numbered and bulleted lists, you can use tab or shift+tab to quickly increase or decrease indentation."; out.tips.indent = "In numbered and bulleted lists, you can use tab or shift+tab to quickly increase or decrease indentation.";
out.tips.title = "You can set the title of your pad by clicking the top center.";
out.tips.store = "Every time you visit a pad, if you're logged in it will be saved to your CryptDrive."; out.tips.store = "Every time you visit a pad, if you're logged in it will be saved to your CryptDrive.";
out.tips.marker = "You can highlight text in a pad using the \"marker\" item in the styles dropdown menu."; out.tips.marker = "You can highlight text in a pad using the \"marker\" item in the styles dropdown menu.";
out.tips.driveUpload = "Registered users can upload encrypted files by dragging and dropping them into their CryptDrive."; out.tips.driveUpload = "Registered users can upload encrypted files by dragging and dropping them into their CryptDrive.";
out.tips.filenames = "You can rename files in your CryptDrive, this name is just for you.";
out.tips.drive = "Logged in users can organize their files in their CryptDrive, accessible from the CryptPad icon at the top left of all pads.";
out.feedback_about = "If you're reading this, you were probably curious why CryptPad is requesting web pages when you perform certain actions"; out.feedback_about = "If you're reading this, you were probably curious why CryptPad is requesting web pages when you perform certain actions";
out.feedback_privacy = "We care about your privacy, and at the same time we want CryptPad to be very easy to use. We use this file to figure out which UI features matter to our users, by requesting it along with a parameter specifying which action was taken."; out.feedback_privacy = "We care about your privacy, and at the same time we want CryptPad to be very easy to use. We use this file to figure out which UI features matter to our users, by requesting it along with a parameter specifying which action was taken.";

@ -256,7 +256,7 @@ define([
var $friend = ui.getFriend(curvePublic); var $friend = ui.getFriend(curvePublic);
var $chat = ui.getChannel(curvePublic); var $chat = ui.getChannel(curvePublic);
$friend.remove(); $friend.remove();
$chat.remove(); if ($chat) { $chat.remove(); }
ui.showInfo(); ui.showInfo();
}; };
@ -892,7 +892,7 @@ define([
var addToFriendList = Msg.addToFriendList = function (common, data, cb) { var addToFriendList = Msg.addToFriendList = function (common, data, cb) {
var proxy = common.getProxy(); var proxy = common.getProxy();
var friends = getFriendList(proxy); var friends = getFriendList(proxy);
var pubKey = data.curvePublic; var pubKey = data.curvePublic; // todo validata data
if (pubKey === proxy.curvePublic) { return void cb("E_MYKEY"); } if (pubKey === proxy.curvePublic) { return void cb("E_MYKEY"); }
@ -938,7 +938,7 @@ define([
var todo = function (yes) { var todo = function (yes) {
if (yes) { if (yes) {
pending[sender] = msgData; pending[sender] = msgData;
msg = ["FRIEND_REQ_OK", chan, createData(common, msgData.channel)]; msg = ["FRIEND_REQ_OK", chan, createData(proxy, msgData.channel)];
} }
msgStr = Crypto.encrypt(JSON.stringify(msg), key); msgStr = Crypto.encrypt(JSON.stringify(msg), key);
network.sendto(sender, msgStr); network.sendto(sender, msgStr);
@ -1005,7 +1005,7 @@ define([
if (!parsed.hashData) { return; } if (!parsed.hashData) { return; }
// Message // Message
var chan = parsed.hashData.channel; var chan = parsed.hashData.channel;
var myData = createData(common); var myData = createData(common.getProxy());
var msg = ["FRIEND_REQ", chan, myData]; var msg = ["FRIEND_REQ", chan, myData];
// Encryption // Encryption
var keyStr = parsed.hashData.key; var keyStr = parsed.hashData.key;

@ -8,6 +8,8 @@ define([
var BAD_STATE_TIMEOUT = typeof(AppConfig.badStateTimeout) === 'number'? var BAD_STATE_TIMEOUT = typeof(AppConfig.badStateTimeout) === 'number'?
AppConfig.badStateTimeout: 30000; AppConfig.badStateTimeout: 30000;
var connected = false;
/* /*
TODO make this not blow up when disconnected or lagging... TODO make this not blow up when disconnected or lagging...
*/ */
@ -20,6 +22,7 @@ define([
} }
var to = setTimeout(function () { var to = setTimeout(function () {
if (!connected) { return; }
realtime.abort(); realtime.abort();
// don't launch more than one popup // don't launch more than one popup
if (common.infiniteSpinnerDetected) { return; } if (common.infiniteSpinnerDetected) { return; }
@ -38,5 +41,10 @@ define([
}, 0); }, 0);
}; };
common.setConnectionState = function (bool) {
if (typeof(bool) !== 'boolean') { return; }
connected = bool;
};
return common; return common;
}); });

@ -581,6 +581,7 @@ define([
_onDisplayNameChanged.forEach(function (h) { _onDisplayNameChanged.forEach(function (h) {
h(newName, isLocal); h(newName, isLocal);
}); });
common.clearTooltips();
}; };
// STORAGE // STORAGE
@ -1905,12 +1906,18 @@ define([
Store.ready(function (err, storeObj) { Store.ready(function (err, storeObj) {
store = common.store = env.store = storeObj; store = common.store = env.store = storeObj;
common.addDirectMessageHandler(common); common.addDirectMessageHandler(common);
var proxy = getProxy(); var proxy = getProxy();
var network = getNetwork(); var network = getNetwork();
network.on('disconnect', function () {
Realtime.setConnectionState(false);
});
network.on('reconnect', function () {
Realtime.setConnectionState(true);
});
if (Object.keys(proxy).length === 1) { if (Object.keys(proxy).length === 1) {
feedback("FIRST_APP_USE", true); feedback("FIRST_APP_USE", true);
} }

@ -50,6 +50,7 @@ define([
}; };
Curve.deriveKeys = function (theirs, mine) { Curve.deriveKeys = function (theirs, mine) {
try {
var pub = decodeBase64(theirs); var pub = decodeBase64(theirs);
var secret = decodeBase64(mine); var secret = decodeBase64(mine);
@ -66,9 +67,18 @@ define([
signKey: encodeBase64(signKp.secretKey), signKey: encodeBase64(signKp.secretKey),
validateKey: encodeBase64(signKp.publicKey) validateKey: encodeBase64(signKp.publicKey)
}; };
} catch (e) {
console.error('invalid keys or other problem deriving keys');
console.error(e);
return null;
}
}; };
Curve.createEncryptor = function (keys) { Curve.createEncryptor = function (keys) {
if (!keys || typeof(keys) !== 'object') {
return void console.error("invalid input for createEncryptor");
}
var cryptKey = decodeBase64(keys.cryptKey); var cryptKey = decodeBase64(keys.cryptKey);
var signKey = decodeBase64(keys.signKey); var signKey = decodeBase64(keys.signKey);
var validateKey = decodeBase64(keys.validateKey); var validateKey = decodeBase64(keys.validateKey);

File diff suppressed because one or more lines are too long

@ -110,6 +110,8 @@ define(['/api/config'], function (ApiConfig) {
cancel: cancel, cancel: cancel,
}; };
}; };
return Module;
};
return Module; return Module;
}); });

@ -341,25 +341,14 @@ function isDataSchema(url) {
return url.substr(i, 5).toLowerCase() === 'data:'; return url.substr(i, 5).toLowerCase() === 'data:';
} }
function getPDFFileNameFromURL(url) { function getPDFFileNameFromURL(url) {
var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf'; var query;
var title;
if (isDataSchema(url)) { if (/\#/.test(url)) {
console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.'); url.replace(/\#(.*)$/, function (all, t) {
return defaultFilename; title = t;
} });
var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
var splitURI = reURI.exec(url);
var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
if (suggestedFilename) {
suggestedFilename = suggestedFilename[0];
if (suggestedFilename.indexOf('%') !== -1) {
try {
suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
} catch (e) {}
}
} }
return suggestedFilename || defaultFilename; return title || 'document.pdf';
} }
function normalizeWheelEventDelta(evt) { function normalizeWheelEventDelta(evt) {
var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY); var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
@ -1192,11 +1181,13 @@ var PDFViewerApplication = {
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) { setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
this.url = url; this.url = url;
this.baseUrl = url.split('#')[0]; this.baseUrl = url.split('#')[0];
var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
var title = _ui_utils.getPDFFileNameFromURL(url);
if (!title) { if (!title) {
try { try {
title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url; title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
} catch (e) { } catch (e) {
console.error(e)
title = url; title = url;
} }
} }

@ -24,7 +24,7 @@ body {
} }
#app.ready { #app.ready {
background: url('/customize/bg3.jpg') no-repeat center center; //background: url('/customize/bg3.jpg') no-repeat center center;
background-size: cover; background-size: cover;
background-position: center; background-position: center;
} }

@ -91,7 +91,14 @@ define([
Title.updateTitle(title || Title.defaultTitle); Title.updateTitle(title || Title.defaultTitle);
toolbar.addElement(['pageTitle'], {pageTitle: title}); toolbar.addElement(['pageTitle'], {pageTitle: title});
var displayFile = function (ev, sizeMb) { var displayFile = function (ev, sizeMb, CB) {
var called_back;
var cb = function (e) {
if (called_back) { return; }
called_back = true;
if (CB) { CB(e); }
};
var $mt = $dlview.find('media-tag'); var $mt = $dlview.find('media-tag');
var cryptKey = secret.keys && secret.keys.fileKeyStr; var cryptKey = secret.keys && secret.keys.fileKeyStr;
var hexFileName = Cryptpad.base64ToHex(secret.channel); var hexFileName = Cryptpad.base64ToHex(secret.channel);
@ -127,7 +134,7 @@ define([
// make pdfs big // make pdfs big
var toolbarHeight = $iframe.find('#toolbar').height(); var toolbarHeight = $iframe.find('#toolbar').height();
$iframe.find('media-tag iframe').css({ var $another_iframe = $iframe.find('media-tag iframe').css({
'height': 'calc(100vh - ' + toolbarHeight + 'px)', 'height': 'calc(100vh - ' + toolbarHeight + 'px)',
'width': '100vw', 'width': '100vw',
'position': 'absolute', 'position': 'absolute',
@ -135,10 +142,19 @@ define([
'left': 0, 'left': 0,
'border': 0 'border': 0
}); });
if ($another_iframe.length) {
$another_iframe.load(function () {
cb();
});
} else {
cb();
}
}) })
.on('decryptionError', function (e) { .on('decryptionError', function (e) {
var error = e.originalEvent; var error = e.originalEvent;
Cryptpad.alert(error.message); //Cryptpad.alert(error.message);
cb(error.message);
}) })
.on('decryptionProgress', function (e) { .on('decryptionProgress', function (e) {
var progress = e.originalEvent; var progress = e.originalEvent;
@ -188,7 +204,9 @@ define([
var onClick = function (ev) { var onClick = function (ev) {
if (decrypting) { return; } if (decrypting) { return; }
decrypting = true; decrypting = true;
displayFile(ev, sizeMb); displayFile(ev, sizeMb, function (err) {
if (err) { Cryptpad.alert(err); }
});
}; };
if (typeof(sizeMb) === 'number' && sizeMb < 5) { return void onClick(); } if (typeof(sizeMb) === 'number' && sizeMb < 5) { return void onClick(); }
$dlform.find('#dl, #progress').click(onClick); $dlform.find('#dl, #progress').click(onClick);

@ -2,7 +2,7 @@
<html class="cp"> <html class="cp">
<!-- If this file is not called customize.dist/src/template.html, it is generated --> <!-- If this file is not called customize.dist/src/template.html, it is generated -->
<head> <head>
<title data-localization="main_title">Cryptpad: Zero Knowledge, Collaborative Real Time Editing</title> <title data-localization="main_title">CryptPad: Zero Knowledge, Collaborative Real Time Editing</title>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/> <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" type="image/png" href="/customize/main-favicon.png" id="favicon"/> <link rel="icon" type="image/png" href="/customize/main-favicon.png" id="favicon"/>

@ -2,7 +2,7 @@
<html class="cp"> <html class="cp">
<!-- If this file is not called customize.dist/src/template.html, it is generated --> <!-- If this file is not called customize.dist/src/template.html, it is generated -->
<head> <head>
<title data-localization="main_title">Cryptpad: Zero Knowledge, Collaborative Real Time Editing</title> <title data-localization="main_title">CryptPad: Zero Knowledge, Collaborative Real Time Editing</title>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/> <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" type="image/png" href="/customize/main-favicon.png" id="favicon"/> <link rel="icon" type="image/png" href="/customize/main-favicon.png" id="favicon"/>

Loading…
Cancel
Save