diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 02f682d4d..96b64ed10 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -254,6 +254,11 @@ define(function () { out.profile_description = "Description"; out.profile_fieldSaved = 'New value saved: {0}'; + out.profile_inviteButton = "Connect"; + out.profile_inviteButtonTitle ='Create a link that will invite this user to connect with you.'; + out.profile_inviteExplanation = "Clicking OK will create a link to a secure messaging session that only {0} will be able to redeem.

The link will be copied to your clipboard and can be shared publicly."; + out.profile_viewMyProfile = "View my profile"; + // File manager out.fm_rootName = "Documents"; diff --git a/www/profile/main.js b/www/profile/main.js index e87bc1f4b..1f08607e7 100644 --- a/www/profile/main.js +++ b/www/profile/main.js @@ -78,8 +78,11 @@ define([ var CREATE_ID = "createProfile"; var HEADER_ID = "header"; var HEADER_RIGHT_ID = "rightside"; + var CREATE_INVITE_BUTTON = 'inviteButton'; + var VIEW_PROFILE_BUTTON = 'viewProfileButton'; - var createEditableInput = function ($block, name, ph, getValue, setValue, realtime) { + var createEditableInput = function ($block, name, ph, getValue, setValue, realtime, fallbackValue) { + fallbackValue = fallbackValue || ''; // don't ever display 'null' or 'undefined' var lastVal; getValue(function (value) { lastVal = value; @@ -104,7 +107,7 @@ define([ if (err) { return void console.error(err); } Cryptpad.whenRealtimeSyncs(realtime, function () { lastVal = newVal; - Cryptpad.log(Messages._getKey('profile_fieldSaved', [newVal])); + Cryptpad.log(Messages._getKey('profile_fieldSaved', [newVal || fallbackValue])); editing = false; }); }); @@ -150,8 +153,69 @@ define([ createEditableInput($block, DISPLAYNAME_ID, placeholder, 32, getValue, setValue, rt); }; */ + + var addCreateInviteLinkButton = function ($container) { + var obj = APP.lm.proxy; + + var proxy = Cryptpad.getProxy(); + var userViewHash = Cryptpad.find(proxy, ['profile', 'view']); + + if (!APP.readOnly || !obj.curveKey || userViewHash === window.location.hash.slice(1)) { + console.log("edit mode or missing curve key, or you're viewing your own profile"); + return; + } + + // sanitize user inputs + + var unsafeName = obj.name || ''; + console.log(unsafeName); + var name = Cryptpad.fixHTML(unsafeName) || Messages.anonymous; + console.log(name); + + console.log("Creating invite button"); + var $button = $("