Merge branch 'staging' into code2

This commit is contained in:
yflory
2017-08-30 14:57:19 +02:00
17 changed files with 87 additions and 67 deletions

View File

@@ -10,7 +10,13 @@ define([
var module = { exports: {} };
var key = Config.requireConf.urlArgs;
var localStorage = window.localStorage || {};
var localStorage;
try {
localStorage = window.localStorage || {};
} catch (e) {
console.error(e);
localStorage = {};
}
var fixURL = function (url) {
var mark = (url.indexOf('?') !== -1) ? '&' : '?';

View File

@@ -1,4 +1,4 @@
define(function () {
define(['json.sortify'], function (Sortify) {
var module = {};
module.create = function (info, onLocal, Cryptget, Cryptpad) {
@@ -15,6 +15,7 @@ define(function () {
var parsed = Cryptpad.parsePadUrl(window.location.href);
var appType = parsed ? parsed.type : undefined;
var oldUserData = {};
var addToUserData = exp.addToUserData = function(data) {
var users = userList.users;
for (var attrname in data) { userData[attrname] = data[attrname]; }
@@ -28,6 +29,10 @@ define(function () {
}
if(userList && typeof userList.onChange === "function") {
// Make sure we don't update the userlist everytime someone makes a change to the pad
if (Sortify(oldUserData) === Sortify(userData)) { return; }
oldUserData = JSON.parse(JSON.stringify(userData));
userList.onChange(userData);
}
};

View File

@@ -1794,12 +1794,15 @@ define([
};
var $userAdmin = createDropdown(dropdownConfigUser);
var oldUrl;
if (account && !config.static && store) {
var $avatar = $userAdmin.find('.buttonTitle');
var updateButton = function (newName) {
var profile = store.getProfile();
var url = profile && profile.avatar;
if (oldUrl === url) { return; }
oldUrl = url;
$avatar.html('');
common.displayAvatar($avatar, url, newName, function ($img) {
if ($img) {

View File

@@ -18,14 +18,7 @@ define([
if (!document.body) { return; }
clearInterval(intr);
document.body.appendChild(elem);
require([
'/customize/messages.js',
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
], function (Messages) {
document.getElementById('cp-loading-message').innerText = Messages.loading;
});
};
intr = setInterval(append, 100);
append();
});
});

View File

@@ -1,4 +1,4 @@
define([], function () {
define(['json.sortify'], function (Sortify) {
var UNINIT = 'uninitialized';
var create = function (sframeChan) {
var meta = UNINIT;
@@ -102,7 +102,9 @@ define([], function () {
return Object.freeze({
updateMetadata: function (m) {
if (JSON.stringify(metadataObj) === JSON.stringify(m)) { return; }
// JSON.parse(JSON.stringify()) reorders the json, so we have to use sortify even
// if it's on our own computer
if (Sortify(metadataLazyObj) === Sortify(m)) { return; }
metadataObj = JSON.parse(JSON.stringify(m));
metadataLazyObj = JSON.parse(JSON.stringify(m));
change(false);

View File

@@ -1,30 +1,40 @@
// Stage 0, this gets cached which means we can't change it. boot2-sframe.js is changable.
// Note that this file is meant to be executed only inside of a sandbox iframe.
;(function () {
var req = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
req.cfg = req.cfg || {};
if (req.pfx) {
req.cfg.onNodeCreated = function (node /*, config, module, path*/) {
node.setAttribute('src', req.pfx + node.getAttribute('src'));
var afterLoaded = function (req) {
req.cfg = req.cfg || {};
if (req.pfx) {
req.cfg.onNodeCreated = function (node /*, config, module, path*/) {
node.setAttribute('src', req.pfx + node.getAttribute('src'));
};
}
require.config(req.cfg);
var txid = Math.random().toString(16).replace('0.', '');
var intr;
var ready = function () {
intr = setInterval(function () {
if (typeof(txid) !== 'string') { return; }
window.parent.postMessage(JSON.stringify({ q: 'READY', txid: txid }), '*');
}, 1);
};
}
require.config(req.cfg);
var txid = Math.random().toString(16).replace('0.', '');
var intr;
var ready = function () {
intr = setInterval(function () {
if (typeof(txid) !== 'string') { return; }
window.parent.postMessage(JSON.stringify({ q: 'READY', txid: txid }), '*');
}, 1);
if (req.req) { require(req.req, ready); } else { ready(); }
var onReply = function (msg) {
var data = JSON.parse(msg.data);
if (data.txid !== txid) { return; }
clearInterval(intr);
txid = {};
window.removeEventListener('message', onReply);
require(['/common/sframe-boot2.js'], function () { });
};
window.addEventListener('message', onReply);
};
if (req.req) { require(req.req, ready); } else { ready(); }
var onReply = function (msg) {
var data = JSON.parse(msg.data);
if (data.txid !== txid) { return; }
clearInterval(intr);
txid = {};
window.removeEventListener('message', onReply);
require(['/common/sframe-boot2.js'], function () { });
};
window.addEventListener('message', onReply);
var intr = setInterval(function () {
try {
var req = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
clearInterval(intr);
afterLoaded(req);
} catch (e) { console.error(e); }
}, 100);
}());

View File

@@ -208,15 +208,17 @@ define([
var $displayName = $userAdmin.find('.'+displayNameCls);
var $avatar = $userAdmin.find('.buttonTitle');
var oldUrl;
var updateButton = function () {
var myData = metadataMgr.getUserData();
if (!myData) { return; }
var newName = myData.name;
var url = myData.avatar;
$displayName.text(newName || Messages.anonymous);
if (accountName) {
if (accountName && oldUrl !== url) {
$avatar.html('');
UI.displayAvatar(Common, $avatar, url, newName, function ($img) {
oldUrl = url;
if ($img) {
$userAdmin.find('button').addClass('avatar');
}

View File

@@ -188,7 +188,6 @@ define([
var $editUsersList = $('<div>', {'class': 'userlist-others'});
// Editors
// TODO iframe enable friends
var pendingFriends = Common.getPendingFriends();
editUsersNames.forEach(function (data) {
var name = data.name || Messages.anonymous;