');
+ // There should always be a title here (defaultTitle if nothing else)
+ // so we don't ever need to supply a uid for an animal avatar
common.displayAvatar($div, null, name, function () {
$mAvatar.html($div.html());
$lAvatar.find('.cp-app-contacts-right-col').before($div.html());
});
});
+*/
// TODO room
// var onJoinRoom
@@ -878,7 +888,7 @@ define([
h('i.fa.fa-bell'),
Messages.contacts_unmute || 'unmute'
]);
- common.displayAvatar($(avatar), data.avatar, data.name);
+ common.displayAvatar($(avatar), data.avatar, data.name, Util.noop, data.uid);
$(button).click(function () {
unmuteUser(curve, button);
execCommand('UNMUTE_USER', curve, function (e, data) {
@@ -894,7 +904,7 @@ define([
});
return h('div.cp-contacts-muted-user', [
h('span', avatar),
- h('span', data.name),
+ h('span', UI.getDisplayName(data.name)),
button
]);
});
diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js
index 130926e6a..cd8887a15 100644
--- a/www/common/outer/async-store.js
+++ b/www/common/outer/async-store.js
@@ -26,9 +26,9 @@ define([
'/bower_components/chainpad-crypto/crypto.js',
'/bower_components/chainpad/chainpad.dist.js',
- '/bower_components/chainpad-netflux/chainpad-netflux.js',
- '/bower_components/chainpad-listmap/chainpad-listmap.js',
- '/bower_components/netflux-websocket/netflux-client.js',
+ 'chainpad-netflux',
+ 'chainpad-listmap',
+ 'netflux-client',
'/bower_components/nthen/index.js',
'/bower_components/saferphore/index.js',
], function (ApiConfig, Sortify, UserObject, ProxyManager, Migrate, Hash, Util, Constants, Feedback,
diff --git a/www/common/outer/cache-store.js b/www/common/outer/cache-store.js
index d1c3795c0..17fea6b16 100644
--- a/www/common/outer/cache-store.js
+++ b/www/common/outer/cache-store.js
@@ -97,7 +97,7 @@ define([
var checkCheckpoints = function (array) {
if (!Array.isArray(array)) { return; }
// Keep the last 100 messages
- if (array.length > 100) { // XXX 4.11.0
+ if (array.length > 100) { // FIXME this behaviour is only valid for chainpad-style documents
array.splice(0, array.length - 100);
}
// Remove every message before the first checkpoint
diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js
index bea22db6b..a0b990e89 100644
--- a/www/common/outer/calendar.js
+++ b/www/common/outer/calendar.js
@@ -6,7 +6,7 @@ define([
'/common/outer/cache-store.js',
'/customize/messages.js',
'/bower_components/nthen/index.js',
- '/bower_components/chainpad-listmap/chainpad-listmap.js',
+ 'chainpad-listmap',
'/bower_components/chainpad-crypto/crypto.js',
'/bower_components/chainpad/chainpad.dist.js',
], function (Util, Hash, Constants, Realtime, Cache, Messages, nThen, Listmap, Crypto, ChainPad) {
diff --git a/www/common/outer/cursor.js b/www/common/outer/cursor.js
index 95b2b34c6..b1a5e7cd0 100644
--- a/www/common/outer/cursor.js
+++ b/www/common/outer/cursor.js
@@ -187,6 +187,7 @@ define([
data.color = Util.find(proxy, ['settings', 'general', 'cursor', 'color']);
data.name = proxy[Constants.displayNameKey] || ctx.store.noDriveName || Messages.anonymous;
data.avatar = Util.find(proxy, ['profile', 'avatar']);
+ data.uid = Util.find(proxy, ['uid']) || ctx.store.noDriveUid;
c.cursor = data;
sendMyCursor(ctx, client);
cb();
diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js
index a7269c6e5..dbe95e84d 100644
--- a/www/common/outer/mailbox.js
+++ b/www/common/outer/mailbox.js
@@ -7,7 +7,7 @@ define([
'/common/common-messaging.js',
'/common/notify.js',
'/common/outer/mailbox-handlers.js',
- '/bower_components/chainpad-netflux/chainpad-netflux.js',
+ 'chainpad-netflux',
'/bower_components/chainpad-crypto/crypto.js',
], function (Config, BCast, Util, Hash, Realtime, Messaging, Notify, Handlers, CpNetflux, Crypto) {
var Mailbox = {};
diff --git a/www/common/outer/profile.js b/www/common/outer/profile.js
index 733b2b4c4..7cba963c7 100644
--- a/www/common/outer/profile.js
+++ b/www/common/outer/profile.js
@@ -3,7 +3,7 @@ define([
'/common/common-hash.js',
'/common/common-constants.js',
'/common/common-realtime.js',
- '/bower_components/chainpad-listmap/chainpad-listmap.js',
+ 'chainpad-listmap',
'/bower_components/chainpad-crypto/crypto.js',
'/bower_components/chainpad/chainpad.dist.js',
], function (Util, Hash, Constants, Realtime, Listmap, Crypto, ChainPad) {
diff --git a/www/common/outer/roster.js b/www/common/outer/roster.js
index e395891b7..6aa80e5d8 100644
--- a/www/common/outer/roster.js
+++ b/www/common/outer/roster.js
@@ -918,7 +918,7 @@ var factory = function (Util, Hash, CPNetflux, Sortify, nThen, Crypto, Feedback)
define([
'/common/common-util.js',
'/common/common-hash.js',
- '/bower_components/chainpad-netflux/chainpad-netflux.js',
+ 'chainpad-netflux',
'json.sortify',
'/bower_components/nthen/index.js',
'/bower_components/chainpad-crypto/crypto.js',
diff --git a/www/common/outer/sharedfolder.js b/www/common/outer/sharedfolder.js
index 6735330b4..4579492ba 100644
--- a/www/common/outer/sharedfolder.js
+++ b/www/common/outer/sharedfolder.js
@@ -6,7 +6,7 @@ define([
'/bower_components/nthen/index.js',
'/bower_components/chainpad-crypto/crypto.js',
- '/bower_components/chainpad-listmap/chainpad-listmap.js',
+ 'chainpad-listmap',
'/bower_components/chainpad/chainpad.dist.js',
], function (Hash, Util, UserObject, Cache,
nThen, Crypto, Listmap, ChainPad) {
diff --git a/www/common/outer/team.js b/www/common/outer/team.js
index 94f91c807..32ce35f3b 100644
--- a/www/common/outer/team.js
+++ b/www/common/outer/team.js
@@ -14,9 +14,9 @@ define([
'/common/cryptget.js',
'/common/outer/cache-store.js',
- '/bower_components/chainpad-listmap/chainpad-listmap.js',
+ 'chainpad-listmap',
'/bower_components/chainpad-crypto/crypto.js',
- '/bower_components/chainpad-netflux/chainpad-netflux.js',
+ 'chainpad-netflux',
'/bower_components/chainpad/chainpad.dist.js',
'/bower_components/nthen/index.js',
'/bower_components/saferphore/index.js',
diff --git a/www/common/requireconfig.js b/www/common/requireconfig.js
index 4e3baf857..7ed772575 100644
--- a/www/common/requireconfig.js
+++ b/www/common/requireconfig.js
@@ -16,6 +16,9 @@ define([
cm: '/bower_components/codemirror',
'tui-code-snippet': '/lib/calendar/tui-code-snippet.min',
'tui-date-picker': '/lib/calendar/date-picker',
+ 'netflux-client': '/bower_components/netflux-websocket/netflux-client',
+ 'chainpad-netflux': '/bower_components/chainpad-netflux/chainpad-netflux',
+ 'chainpad-listmap': '/bower_components/chainpad-listmap/chainpad-listmap',
},
map: {
'*': {
diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js
index 1286da14d..facd27f22 100644
--- a/www/common/sframe-common-file.js
+++ b/www/common/sframe-common-file.js
@@ -11,10 +11,12 @@ define([
'/common/hyperscript.js',
'/customize/messages.js',
'/customize/pages.js',
+ '/bower_components/nthen/index.js',
+ '/common/media-tag.js',
'/bower_components/file-saver/FileSaver.min.js',
'/bower_components/tweetnacl/nacl-fast.min.js',
-], function ($, ApiConfig, FileCrypto, MakeBackup, Thumb, UI, UIElements, Util, Hash, h, Messages, Pages) {
+], function ($, ApiConfig, FileCrypto, MakeBackup, Thumb, UI, UIElements, Util, Hash, h, Messages, Pages, nThen, MT) {
var Nacl = window.nacl;
var module = {};
@@ -312,7 +314,8 @@ define([
});
return manualStore;
};
- var fileUploadModal = function (defaultFileName, cb) {
+
+ var fileUploadModal = function (defaultFileName, cb, preview) {
var parsedName = /^(\.?.+?)(\.[^.]+)?$/.exec(defaultFileName) || [];
var ext = parsedName[2] || "";
@@ -321,9 +324,14 @@ define([
// Ask for name, password and owner
var content = h('div', [
h('h4', Messages.upload_modal_title),
+ (preview? h('div#cp-upload-preview-container', preview): undefined),
UIElements.setHTML(h('label', {for: 'cp-upload-name'}),
Messages._getKey('upload_modal_filename', [ext])),
h('input#cp-upload-name', {type: 'text', placeholder: defaultFileName, value: defaultFileName}),
+
+ h('label', {for: 'cp-upload-alt'}, Messages.upload_addOptionalAlt),
+ h('input#cp-upload-alt', {type: 'text', placeholder: Messages.upload_modal_alt}),
+
h('label', {for: 'cp-upload-password'}, Messages.addOptionalPassword),
UI.passwordInput({id: 'cp-upload-password'}),
h('span', {
@@ -335,7 +343,8 @@ define([
manualStore
]);
- $(content).find('#cp-upload-owned').on('change', function () {
+ var $content = $(content);
+ $content.find('#cp-upload-owned').on('change', function () {
var val = Util.isChecked($(content).find('#cp-upload-owned'));
if (val) {
$(content).find('#cp-upload-store').prop('checked', true).prop('disabled', true);
@@ -348,8 +357,9 @@ define([
if (!yes) { return void cb(); }
// Get the values
- var newName = $(content).find('#cp-upload-name').val();
- var password = $(content).find('#cp-upload-password').val() || undefined;
+ var newName = $content.find('#cp-upload-name').val();
+ var password = $content.find('#cp-upload-password').val() || undefined;
+ var alt = $content.find('#cp-upload-alt').val() || undefined;
var owned = Util.isChecked($(content).find('#cp-upload-owned'));
var forceSave = owned || Util.isChecked($(content).find('#cp-upload-store'));
@@ -366,7 +376,8 @@ define([
name: newName,
password: password,
owned: owned,
- forceSave: forceSave
+ forceSave: forceSave,
+ alt: alt,
});
});
};
@@ -437,6 +448,8 @@ define([
}
var thumb;
+ var preview;
+ var alt;
var file_arraybuffer;
var name = file.name;
var password;
@@ -447,6 +460,7 @@ define([
var metadata = {
name: name,
type: type,
+ alt: alt,
};
if (thumb) { metadata.thumbnail = thumb; }
queue.push({
@@ -486,8 +500,9 @@ define([
password = obj.password;
owned = obj.owned;
forceSave = obj.forceSave;
+ alt = obj.alt;
finish();
- });
+ }, preview);
}
};
@@ -495,11 +510,20 @@ define([
if (e) { console.error(e); }
file_arraybuffer = buffer;
if (!Thumb.isSupportedType(file)) { return getName(); }
- // make a resized thumbnail from the image..
- Thumb.fromBlob(file, function (e, thumb64) {
- if (e) { console.error(e); }
- if (!thumb64) { return getName(); }
- thumb = thumb64;
+ nThen(function (w) {
+ // make a resized thumbnail from the image..
+ Thumb.fromBlob(file, w(function (e, thumb64) {
+ if (e) { console.error(e); }
+ if (!thumb64) { return; }
+ thumb = thumb64;
+ }));
+ MT.preview(buffer, {
+ type: file.type,
+ }, void 0, w(function (err, el) {
+ if (err) { return void console.error(err); }
+ preview = el;
+ }));
+ }).nThen(function () {
getName();
});
});
diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js
index 575971368..5223898d1 100644
--- a/www/common/sframe-common-outer.js
+++ b/www/common/sframe-common-outer.js
@@ -618,6 +618,7 @@ define([
prefersDriveRedirect: Utils.LocalStore.getDriveRedirectPreference(),
isPresent: parsed.hashData && parsed.hashData.present,
isEmbed: parsed.hashData && parsed.hashData.embed,
+ canEdit: hashes && hashes.editHash,
oldVersionHash: parsed.hashData && parsed.hashData.version < 2, // password
isHistoryVersion: parsed.hashData && parsed.hashData.versionHash,
notifications: notifs,
@@ -1749,6 +1750,22 @@ define([
});
});
+ sframeChan.on('Q_COPY_VIEW_URL', function (data, cb) {
+ require(['/common/clipboard.js'], function (Clipboard) {
+ var url = window.location.origin +
+ Utils.Hash.hashToHref(hashes.viewHash, 'form');
+ var success = Clipboard.copy(url);
+ cb(success);
+ });
+ });
+ sframeChan.on('EV_OPEN_VIEW_URL', function () {
+ var url = Utils.Hash.hashToHref(hashes.viewHash, 'form');
+ var a = window.open(url);
+ if (!a) {
+ sframeChan.event('EV_POPUP_BLOCKED');
+ }
+ });
+
if (cfg.messaging) {
sframeChan.on('Q_CHAT_OPENPADCHAT', function (data, cb) {
Cryptpad.universal.execCommand({
diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js
index c05bdfe3f..b7efd9f4f 100644
--- a/www/common/sframe-common.js
+++ b/www/common/sframe-common.js
@@ -235,9 +235,6 @@ define([
};
};
- funcs.getAuthorId = function () {
- };
-
var authorUid = function(existing) {
if (!Array.isArray(existing)) { existing = []; }
var n;
@@ -249,11 +246,25 @@ define([
if (existing.indexOf(n) !== -1) { n = 0; }
return n;
};
- funcs.getAuthorId = function(authors, curve) {
+ funcs.getAuthorId = function(authors, curve, tokenId) {
var existing = Object.keys(authors || {}).map(Number);
- if (!funcs.isLoggedIn()) { return authorUid(existing); }
-
var uid;
+ var loggedIn = funcs.isLoggedIn();
+ if (!loggedIn && !tokenId) { return authorUid(existing); }
+ if (!loggedIn) {
+ existing.some(function (id) {
+ var author = authors[id];
+ if (!author || author.uid !== tokenId) { return; }
+ uid = Number(id);
+ return true;
+ });
+ return uid || authorUid(existing);
+ }
+ // TODO this should check for a matching curvePublic / uid if:
+ // 1. you are logged in OR
+ // 2. you have a token
+ // so that users that register recognize comments from before
+ // they registered as their own (same uid)
existing.some(function(id) {
var author = authors[id] || {};
if (author.curvePublic !== curve) { return; }
@@ -921,9 +932,10 @@ define([
});
ctx.sframeChan.on('EV_WORKER_TIMEOUT', function () {
- UI.errorLoadingScreen(Messages.timeoutError, false, function () { // XXX 4.11.0 mobile users can't necessarily hit 'ESC' as this message suggests. provice a click option
- funcs.gotoURL('');
- });
+ var message = UI.setHTML(h('span'), Messages.timeoutError);
+ var cb = Util.once(function () { funcs.gotoURL(''); });
+ $(message).find('em').on('touchend', cb);
+ UI.errorLoadingScreen(message, false, cb);
});
ctx.sframeChan.on('EV_CHROME_68', function () {
diff --git a/www/common/toolbar.js b/www/common/toolbar.js
index 47c0b578e..8931c57f5 100644
--- a/www/common/toolbar.js
+++ b/www/common/toolbar.js
@@ -65,7 +65,9 @@ MessengerUI, Messages, Pages) {
if (!config.$container) { return; }
var $container = config.$container;
- var isEmbed = Bar.isEmbed = config.metadataMgr.getPrivateData().isEmbed;
+ var priv = config.metadataMgr.getPrivateData();
+ var isEmbed = Bar.isEmbed = priv.isEmbed ||
+ (priv.app === 'form' && priv.readOnly && !priv.form_auditorHash);
if (isEmbed) {
$container.hide();
}
@@ -249,6 +251,7 @@ MessengerUI, Messages, Pages) {
var friendRequests = Common.getFriendRequests(); // Friend requests received
editUsersNames.forEach(function (data) {
var name = data.name || Messages.anonymous;
+ var safeName = Util.fixHTML(name);
var $span = $('
', {'class': 'cp-avatar'});
if (data.color && showColors) {
$span.css('border-color', data.color);
@@ -323,7 +326,7 @@ MessengerUI, Messages, Pages) {
$('