|
|
@ -14,11 +14,14 @@ define([
|
|
|
|
'/customize/application_config.js',
|
|
|
|
'/customize/application_config.js',
|
|
|
|
'/customize/pages.js',
|
|
|
|
'/customize/pages.js',
|
|
|
|
'/bower_components/nthen/index.js',
|
|
|
|
'/bower_components/nthen/index.js',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'/bower_components/scrypt-async/scrypt-async.js',
|
|
|
|
'css!/customize/fonts/cptools/style.css',
|
|
|
|
'css!/customize/fonts/cptools/style.css',
|
|
|
|
'/bower_components/croppie/croppie.min.js',
|
|
|
|
'/bower_components/croppie/croppie.min.js',
|
|
|
|
'css!/bower_components/croppie/croppie.css',
|
|
|
|
'css!/bower_components/croppie/croppie.css',
|
|
|
|
], function ($, Config, Util, Hash, Language, UI, Constants, Feedback, h, MediaTag, Clipboard,
|
|
|
|
], function ($, Config, Util, Hash, Language, UI, Constants, Feedback, h, MediaTag, Clipboard,
|
|
|
|
Messages, AppConfig, Pages, NThen) {
|
|
|
|
Messages, AppConfig, Pages, NThen) {
|
|
|
|
|
|
|
|
var Scrypt = window.scrypt;
|
|
|
|
var UIElements = {};
|
|
|
|
var UIElements = {};
|
|
|
|
|
|
|
|
|
|
|
|
// Configure MediaTags to use our local viewer
|
|
|
|
// Configure MediaTags to use our local viewer
|
|
|
@ -1557,6 +1560,8 @@ define([
|
|
|
|
var team = privateData.teams[config.teamId];
|
|
|
|
var team = privateData.teams[config.teamId];
|
|
|
|
if (!team) { return void UI.warn(Messages.error); }
|
|
|
|
if (!team) { return void UI.warn(Messages.error); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var origin = privateData.origin;
|
|
|
|
|
|
|
|
|
|
|
|
var module = config.module || common.makeUniversal('team');
|
|
|
|
var module = config.module || common.makeUniversal('team');
|
|
|
|
|
|
|
|
|
|
|
|
// Invite contacts
|
|
|
|
// Invite contacts
|
|
|
@ -1629,12 +1634,13 @@ define([
|
|
|
|
buttons: contactsButtons,
|
|
|
|
buttons: contactsButtons,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var linkName, linkPassword, linkMessage;
|
|
|
|
var linkName, linkPassword, linkMessage, linkError, linkSpinText;
|
|
|
|
var linkError;
|
|
|
|
var linkForm, linkSpin, linkResult;
|
|
|
|
// Invite from link
|
|
|
|
// Invite from link
|
|
|
|
var linkContent = h('div.cp-share-modal', [
|
|
|
|
var linkContent = h('div.cp-share-modal', [
|
|
|
|
h('p', 'XXX Invite link description...'), // XXX
|
|
|
|
h('p', 'XXX Invite link description...'), // XXX
|
|
|
|
linkError = h('div.alert.alert-danger', {style : 'display: none;'}),
|
|
|
|
linkError = h('div.alert.alert-danger', {style : 'display: none;'}),
|
|
|
|
|
|
|
|
linkForm = h('div.cp-teams-invite-form', [
|
|
|
|
linkName = h('input', {
|
|
|
|
linkName = h('input', {
|
|
|
|
placeholder: 'name...' // XXX
|
|
|
|
placeholder: 'name...' // XXX
|
|
|
|
}),
|
|
|
|
}),
|
|
|
@ -1647,34 +1653,72 @@ define([
|
|
|
|
linkMessage = h('textarea', {
|
|
|
|
linkMessage = h('textarea', {
|
|
|
|
placeholder: 'note...'
|
|
|
|
placeholder: 'note...'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
linkSpin = h('div', {
|
|
|
|
|
|
|
|
style: 'display: none;'
|
|
|
|
|
|
|
|
}, [
|
|
|
|
|
|
|
|
h('i.fa.fa-spinner.fa-spin'),
|
|
|
|
|
|
|
|
linkSpinText = h('span', 'Scrypt...') // XXX
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
linkResult = h('div', {
|
|
|
|
|
|
|
|
style: 'display: none;'
|
|
|
|
|
|
|
|
}, h('textarea', {
|
|
|
|
|
|
|
|
readonly: 'readonly'
|
|
|
|
|
|
|
|
}))
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
var $linkContent = $(linkContent);
|
|
|
|
|
|
|
|
var href;
|
|
|
|
var process = function () {
|
|
|
|
var process = function () {
|
|
|
|
|
|
|
|
var $nav = $linkContent.closest('.alertify').find('nav');
|
|
|
|
$(linkError).text('').hide();
|
|
|
|
$(linkError).text('').hide();
|
|
|
|
var name = $(linkName).val();
|
|
|
|
var name = $(linkName).val();
|
|
|
|
var pw = $(linkPassword).val();
|
|
|
|
var pw = $(linkPassword).val();
|
|
|
|
var msg = $(linkMessage).val();
|
|
|
|
var msg = $(linkMessage).val();
|
|
|
|
|
|
|
|
var hash = Hash.createRandomHash('invite', pw);
|
|
|
|
|
|
|
|
var hashData = Hash.parseTypeHash('invite', hash);
|
|
|
|
|
|
|
|
href = origin + '/teams/#' + hash;
|
|
|
|
|
|
|
|
console.log(hashData);
|
|
|
|
if (!name || !name.trim()) {
|
|
|
|
if (!name || !name.trim()) {
|
|
|
|
$(linkError).text('empty name...').show(); // XXX
|
|
|
|
$(linkError).text('empty name...').show(); // XXX
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var bytes;
|
|
|
|
var bytes64;
|
|
|
|
NThen(function (waitFor) {
|
|
|
|
NThen(function (waitFor) {
|
|
|
|
|
|
|
|
$(linkForm).hide();
|
|
|
|
|
|
|
|
$(linkSpin).show();
|
|
|
|
|
|
|
|
$nav.find('button.cp-teams-invite-create').prop('disabled', 'disabled');
|
|
|
|
|
|
|
|
setTimeout(waitFor(), 150);
|
|
|
|
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
// Scrypt
|
|
|
|
// Scrypt
|
|
|
|
waitFor()(); // jshint
|
|
|
|
Scrypt(hashData.key,
|
|
|
|
bytes = bytes;
|
|
|
|
(pw || '') + (AppConfig.loginSalt || ''), // salt
|
|
|
|
|
|
|
|
8, // memoryCost (n)
|
|
|
|
|
|
|
|
1024, // block size parameter (r)
|
|
|
|
|
|
|
|
192, // dkLen
|
|
|
|
|
|
|
|
200, // interruptStep
|
|
|
|
|
|
|
|
waitFor(function (_bytes) {
|
|
|
|
|
|
|
|
bytes64 = _bytes;
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
'base64'); // format, could be 'base64'
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
|
|
|
|
$(linkSpinText).text('Add invite link to team'); // XXX
|
|
|
|
module.execCommand('CREATE_INVITE_LINK', {
|
|
|
|
module.execCommand('CREATE_INVITE_LINK', {
|
|
|
|
name: name,
|
|
|
|
name: name,
|
|
|
|
password: pw,
|
|
|
|
password: pw,
|
|
|
|
message: msg,
|
|
|
|
message: msg,
|
|
|
|
// send scrypt result
|
|
|
|
bytes64: bytes64,
|
|
|
|
|
|
|
|
href: href,
|
|
|
|
teamId: config.teamId,
|
|
|
|
teamId: config.teamId,
|
|
|
|
}, waitFor(function (obj) {
|
|
|
|
}, waitFor(function (obj) {
|
|
|
|
if (obj && obj.error) {
|
|
|
|
if (obj && obj.error) {
|
|
|
|
waitFor.abort();
|
|
|
|
waitFor.abort();
|
|
|
|
|
|
|
|
$(linkSpin).hide();
|
|
|
|
return void $(linkError).text('ERROR '+obj.error).show(); // XXX
|
|
|
|
return void $(linkError).text('ERROR '+obj.error).show(); // XXX
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Display result here
|
|
|
|
// Display result here
|
|
|
|
|
|
|
|
$(linkSpin).hide();
|
|
|
|
|
|
|
|
$(linkResult).show().find('textarea').text(href);
|
|
|
|
|
|
|
|
$nav.find('button.cp-teams-invite-copy').prop('disabled', '');
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -1685,17 +1729,27 @@ define([
|
|
|
|
onClick: function () {},
|
|
|
|
onClick: function () {},
|
|
|
|
keys: [27]
|
|
|
|
keys: [27]
|
|
|
|
}, {
|
|
|
|
}, {
|
|
|
|
className: 'primary',
|
|
|
|
className: 'primary cp-teams-invite-create',
|
|
|
|
name: 'CREATE LINK', // XXX
|
|
|
|
name: 'CREATE LINK', // XXX
|
|
|
|
onClick: function () {
|
|
|
|
onClick: function () {
|
|
|
|
return process();
|
|
|
|
return process();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
keys: [13]
|
|
|
|
keys: [13]
|
|
|
|
|
|
|
|
}, {
|
|
|
|
|
|
|
|
className: 'primary cp-teams-invite-copy',
|
|
|
|
|
|
|
|
name: 'COPY LINK', // XXX
|
|
|
|
|
|
|
|
onClick: function () {
|
|
|
|
|
|
|
|
if (!href) { return; }
|
|
|
|
|
|
|
|
var success = Clipboard.copy(href);
|
|
|
|
|
|
|
|
if (success) { UI.log(Messages.shareSuccess); }
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
keys: []
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
var frameLink = UI.dialog.customModal(linkContent, {
|
|
|
|
var frameLink = UI.dialog.customModal(linkContent, {
|
|
|
|
buttons: linkButtons,
|
|
|
|
buttons: linkButtons,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$(frameLink).find('.cp-teams-invite-copy').prop('disabled', 'disabled');
|
|
|
|
|
|
|
|
|
|
|
|
// Create modal
|
|
|
|
// Create modal
|
|
|
|
var tabs = [{
|
|
|
|
var tabs = [{
|
|
|
|