|
|
@ -271,14 +271,12 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
console.log('koko');
|
|
|
|
|
|
|
|
// Send the command
|
|
|
|
// Send the command
|
|
|
|
sframeChan.query('Q_SET_PAD_METADATA', {
|
|
|
|
sframeChan.query('Q_SET_PAD_METADATA', {
|
|
|
|
channel: channel,
|
|
|
|
channel: channel,
|
|
|
|
command: 'ADD_PENDING_OWNERS',
|
|
|
|
command: 'ADD_PENDING_OWNERS',
|
|
|
|
value: toAdd
|
|
|
|
value: toAdd
|
|
|
|
}, waitFor(function (err, res) {
|
|
|
|
}, waitFor(function (err, res) {
|
|
|
|
console.error(arguments);
|
|
|
|
|
|
|
|
err = err || (res && res.error);
|
|
|
|
err = err || (res && res.error);
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
waitFor.abort();
|
|
|
|
waitFor.abort();
|
|
|
@ -286,8 +284,6 @@ define([
|
|
|
|
} // XXX
|
|
|
|
} // XXX
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
console.log('okok');
|
|
|
|
|
|
|
|
// TODO send notifications
|
|
|
|
|
|
|
|
sel.forEach(function (el) {
|
|
|
|
sel.forEach(function (el) {
|
|
|
|
var friend = friends[$(el).attr('data-curve')];
|
|
|
|
var friend = friends[$(el).attr('data-curve')];
|
|
|
|
if (!friend) { return; }
|
|
|
|
if (!friend) { return; }
|
|
|
@ -318,13 +314,17 @@ define([
|
|
|
|
return $div2;
|
|
|
|
return $div2;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pending = false;
|
|
|
|
redrawAll = function () {
|
|
|
|
redrawAll = function () {
|
|
|
|
$div1.empty();
|
|
|
|
if (pending) { return; }
|
|
|
|
$div2.empty();
|
|
|
|
pending = true;
|
|
|
|
common.getPadMetadata(null, function (obj) {
|
|
|
|
common.getPadMetadata(null, function (obj) {
|
|
|
|
|
|
|
|
pending = false;
|
|
|
|
if (obj && obj.error) { return; }
|
|
|
|
if (obj && obj.error) { return; }
|
|
|
|
owners = obj.owners;
|
|
|
|
owners = obj.owners;
|
|
|
|
pending_owners = obj.pending_owners;
|
|
|
|
pending_owners = obj.pending_owners;
|
|
|
|
|
|
|
|
$div1.empty();
|
|
|
|
|
|
|
|
$div2.empty();
|
|
|
|
$div1.append(drawRemove(false)).append(drawRemove(true));
|
|
|
|
$div1.append(drawRemove(false)).append(drawRemove(true));
|
|
|
|
$div2.append(drawAdd());
|
|
|
|
$div2.append(drawAdd());
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -333,6 +333,15 @@ define([
|
|
|
|
$div1.append(drawRemove(false)).append(drawRemove(true));
|
|
|
|
$div1.append(drawRemove(false)).append(drawRemove(true));
|
|
|
|
$div2.append(drawAdd());
|
|
|
|
$div2.append(drawAdd());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var handler = sframeChan.on('EV_RT_METADATA', function (md) {
|
|
|
|
|
|
|
|
if (!$div1.length) {
|
|
|
|
|
|
|
|
return void handler.stop();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
owners = md.owners;
|
|
|
|
|
|
|
|
pending_owners = md.pending_owners;
|
|
|
|
|
|
|
|
redrawAll();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Create modal
|
|
|
|
// Create modal
|
|
|
|
var link = h('div.cp-share-columns', [
|
|
|
|
var link = h('div.cp-share-columns', [
|
|
|
|
div1,
|
|
|
|
div1,
|
|
|
@ -349,139 +358,158 @@ define([
|
|
|
|
return UI.dialog.customModal(link, {buttons: linkButtons});
|
|
|
|
return UI.dialog.customModal(link, {buttons: linkButtons});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var getRightsProperties = function (common, data, cb) {
|
|
|
|
var getRightsProperties = function (common, data, cb) {
|
|
|
|
var $d = $('<div>');
|
|
|
|
var $div = $('<div>');
|
|
|
|
if (!data) { return void cb(void 0, $d); }
|
|
|
|
if (!data) { return void cb(void 0, $div); }
|
|
|
|
|
|
|
|
|
|
|
|
$('<label>', {'for': 'cp-app-prop-owners'}).text(Messages.creation_owners)
|
|
|
|
var draw = function () {
|
|
|
|
.appendTo($d);
|
|
|
|
var $d = $('<div>');
|
|
|
|
var owners = Messages.creation_noOwner;
|
|
|
|
$('<label>', {'for': 'cp-app-prop-owners'}).text(Messages.creation_owners)
|
|
|
|
var priv = common.getMetadataMgr().getPrivateData();
|
|
|
|
.appendTo($d);
|
|
|
|
var edPublic = priv.edPublic;
|
|
|
|
var owners = Messages.creation_noOwner;
|
|
|
|
var owned = false;
|
|
|
|
var priv = common.getMetadataMgr().getPrivateData();
|
|
|
|
if (data.owners && data.owners.length) {
|
|
|
|
var edPublic = priv.edPublic;
|
|
|
|
if (data.owners.indexOf(edPublic) !== -1) {
|
|
|
|
var owned = false;
|
|
|
|
owned = true;
|
|
|
|
if (data.owners && data.owners.length) {
|
|
|
|
}
|
|
|
|
if (data.owners.indexOf(edPublic) !== -1) {
|
|
|
|
var names = [];
|
|
|
|
owned = true;
|
|
|
|
var strangers = 0;
|
|
|
|
|
|
|
|
data.owners.forEach(function (ed) {
|
|
|
|
|
|
|
|
// If a friend is an owner, add their name to the list
|
|
|
|
|
|
|
|
// otherwise, increment the list of strangers
|
|
|
|
|
|
|
|
if (ed === edPublic) {
|
|
|
|
|
|
|
|
names.push(Messages.yourself);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!Object.keys(priv.friends || {}).some(function (c) {
|
|
|
|
var names = [];
|
|
|
|
var friend = priv.friends[c] || {};
|
|
|
|
var strangers = 0;
|
|
|
|
if (friend.edPublic !== ed || c === 'me') { return; }
|
|
|
|
data.owners.forEach(function (ed) {
|
|
|
|
names.push(friend.displayName);
|
|
|
|
// If a friend is an owner, add their name to the list
|
|
|
|
return true;
|
|
|
|
// otherwise, increment the list of strangers
|
|
|
|
})) {
|
|
|
|
if (ed === edPublic) {
|
|
|
|
strangers++;
|
|
|
|
names.push(Messages.yourself);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Object.keys(priv.friends || {}).some(function (c) {
|
|
|
|
|
|
|
|
var friend = priv.friends[c] || {};
|
|
|
|
|
|
|
|
if (friend.edPublic !== ed || c === 'me') { return; }
|
|
|
|
|
|
|
|
names.push(friend.displayName);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
})) {
|
|
|
|
|
|
|
|
strangers++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (strangers) {
|
|
|
|
|
|
|
|
names.push(Messages._getKey('properties_unknownUser', [strangers]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
owners = names.join(', ');
|
|
|
|
if (strangers) {
|
|
|
|
|
|
|
|
names.push(Messages._getKey('properties_unknownUser', [strangers]));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
owners = names.join(', ');
|
|
|
|
$d.append(UI.dialog.selectable(owners, {
|
|
|
|
}
|
|
|
|
id: 'cp-app-prop-owners',
|
|
|
|
$d.append(UI.dialog.selectable(owners, {
|
|
|
|
}));
|
|
|
|
id: 'cp-app-prop-owners',
|
|
|
|
if (owned) {
|
|
|
|
}));
|
|
|
|
var manageOwners = h('button.no-margin', 'Manage owners'); // XXX
|
|
|
|
if (owned) {
|
|
|
|
$(manageOwners).click(function () {
|
|
|
|
var manageOwners = h('button.no-margin', 'Manage owners'); // XXX
|
|
|
|
var modal = createOwnerModal(common, data);
|
|
|
|
$(manageOwners).click(function () {
|
|
|
|
UI.openCustomModal(modal, {
|
|
|
|
var modal = createOwnerModal(common, data);
|
|
|
|
wide: true,
|
|
|
|
UI.openCustomModal(modal, {
|
|
|
|
});
|
|
|
|
wide: true,
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$d.append(h('p', manageOwners));
|
|
|
|
$d.append(h('p', manageOwners));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!data.noExpiration) {
|
|
|
|
|
|
|
|
var expire = Messages.creation_expireFalse;
|
|
|
|
|
|
|
|
if (data.expire && typeof (data.expire) === "number") {
|
|
|
|
|
|
|
|
expire = new Date(data.expire).toLocaleString();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('<label>', {'for': 'cp-app-prop-expire'}).text(Messages.creation_expiration)
|
|
|
|
|
|
|
|
.appendTo($d);
|
|
|
|
|
|
|
|
$d.append(UI.dialog.selectable(expire, {
|
|
|
|
|
|
|
|
id: 'cp-app-prop-expire',
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!data.noPassword) {
|
|
|
|
if (!data.noExpiration) {
|
|
|
|
var hasPassword = data.password;
|
|
|
|
var expire = Messages.creation_expireFalse;
|
|
|
|
if (hasPassword) {
|
|
|
|
if (data.expire && typeof (data.expire) === "number") {
|
|
|
|
$('<label>', {'for': 'cp-app-prop-password'}).text(Messages.creation_passwordValue)
|
|
|
|
expire = new Date(data.expire).toLocaleString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$('<label>', {'for': 'cp-app-prop-expire'}).text(Messages.creation_expiration)
|
|
|
|
.appendTo($d);
|
|
|
|
.appendTo($d);
|
|
|
|
var password = UI.passwordInput({
|
|
|
|
$d.append(UI.dialog.selectable(expire, {
|
|
|
|
id: 'cp-app-prop-password',
|
|
|
|
id: 'cp-app-prop-expire',
|
|
|
|
readonly: 'readonly'
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
|
|
|
var $pwInput = $(password).find('.cp-password-input');
|
|
|
|
|
|
|
|
$pwInput.val(data.password).click(function () {
|
|
|
|
|
|
|
|
$pwInput[0].select();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$d.append(password);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var parsed = Hash.parsePadUrl(data.href || data.roHref);
|
|
|
|
if (!data.noPassword) {
|
|
|
|
if (!data.noEditPassword && owned && parsed.hashData.type === 'pad' && parsed.type !== "sheet") { // FIXME SHEET fix password change for sheets
|
|
|
|
var hasPassword = data.password;
|
|
|
|
var sframeChan = common.getSframeChannel();
|
|
|
|
if (hasPassword) {
|
|
|
|
var changePwTitle = Messages.properties_changePassword;
|
|
|
|
$('<label>', {'for': 'cp-app-prop-password'}).text(Messages.creation_passwordValue)
|
|
|
|
var changePwConfirm = Messages.properties_confirmChange;
|
|
|
|
.appendTo($d);
|
|
|
|
if (!hasPassword) {
|
|
|
|
var password = UI.passwordInput({
|
|
|
|
changePwTitle = Messages.properties_addPassword;
|
|
|
|
id: 'cp-app-prop-password',
|
|
|
|
changePwConfirm = Messages.properties_confirmNew;
|
|
|
|
readonly: 'readonly'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
var $pwInput = $(password).find('.cp-password-input');
|
|
|
|
|
|
|
|
$pwInput.val(data.password).click(function () {
|
|
|
|
|
|
|
|
$pwInput[0].select();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$d.append(password);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('<label>', {'for': 'cp-app-prop-change-password'})
|
|
|
|
|
|
|
|
.text(changePwTitle).appendTo($d);
|
|
|
|
var parsed = Hash.parsePadUrl(data.href || data.roHref);
|
|
|
|
var newPassword = UI.passwordInput({
|
|
|
|
if (!data.noEditPassword && owned && parsed.hashData.type === 'pad' && parsed.type !== "sheet") { // FIXME SHEET fix password change for sheets
|
|
|
|
id: 'cp-app-prop-change-password',
|
|
|
|
var sframeChan = common.getSframeChannel();
|
|
|
|
style: 'flex: 1;'
|
|
|
|
var changePwTitle = Messages.properties_changePassword;
|
|
|
|
});
|
|
|
|
var changePwConfirm = Messages.properties_confirmChange;
|
|
|
|
var passwordOk = h('button', Messages.properties_changePasswordButton);
|
|
|
|
if (!hasPassword) {
|
|
|
|
var changePass = h('span.cp-password-container', [
|
|
|
|
changePwTitle = Messages.properties_addPassword;
|
|
|
|
newPassword,
|
|
|
|
changePwConfirm = Messages.properties_confirmNew;
|
|
|
|
passwordOk
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
$(passwordOk).click(function () {
|
|
|
|
|
|
|
|
var newPass = $(newPassword).find('input').val();
|
|
|
|
|
|
|
|
if (data.password === newPass ||
|
|
|
|
|
|
|
|
(!data.password && !newPass)) {
|
|
|
|
|
|
|
|
return void UI.alert(Messages.properties_passwordSame);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UI.confirm(changePwConfirm, function (yes) {
|
|
|
|
$('<label>', {'for': 'cp-app-prop-change-password'})
|
|
|
|
if (!yes) { return; }
|
|
|
|
.text(changePwTitle).appendTo($d);
|
|
|
|
sframeChan.query("Q_PAD_PASSWORD_CHANGE", {
|
|
|
|
var newPassword = UI.passwordInput({
|
|
|
|
href: data.href || data.roHref,
|
|
|
|
id: 'cp-app-prop-change-password',
|
|
|
|
password: newPass
|
|
|
|
style: 'flex: 1;'
|
|
|
|
}, function (err, data) {
|
|
|
|
});
|
|
|
|
if (err || data.error) {
|
|
|
|
var passwordOk = h('button', Messages.properties_changePasswordButton);
|
|
|
|
return void UI.alert(Messages.properties_passwordError);
|
|
|
|
var changePass = h('span.cp-password-container', [
|
|
|
|
}
|
|
|
|
newPassword,
|
|
|
|
UI.findOKButton().click();
|
|
|
|
passwordOk
|
|
|
|
// If we didn't have a password, we have to add the /p/
|
|
|
|
]);
|
|
|
|
// If we had a password and we changed it to a new one, we just have to reload
|
|
|
|
$(passwordOk).click(function () {
|
|
|
|
// If we had a password and we removed it, we have to remove the /p/
|
|
|
|
var newPass = $(newPassword).find('input').val();
|
|
|
|
if (data.warning) {
|
|
|
|
if (data.password === newPass ||
|
|
|
|
return void UI.alert(Messages.properties_passwordWarning, function () {
|
|
|
|
(!data.password && !newPass)) {
|
|
|
|
|
|
|
|
return void UI.alert(Messages.properties_passwordSame);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UI.confirm(changePwConfirm, function (yes) {
|
|
|
|
|
|
|
|
if (!yes) { return; }
|
|
|
|
|
|
|
|
sframeChan.query("Q_PAD_PASSWORD_CHANGE", {
|
|
|
|
|
|
|
|
href: data.href || data.roHref,
|
|
|
|
|
|
|
|
password: newPass
|
|
|
|
|
|
|
|
}, function (err, data) {
|
|
|
|
|
|
|
|
if (err || data.error) {
|
|
|
|
|
|
|
|
return void UI.alert(Messages.properties_passwordError);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UI.findOKButton().click();
|
|
|
|
|
|
|
|
// If we didn't have a password, we have to add the /p/
|
|
|
|
|
|
|
|
// If we had a password and we changed it to a new one, we just have to reload
|
|
|
|
|
|
|
|
// If we had a password and we removed it, we have to remove the /p/
|
|
|
|
|
|
|
|
if (data.warning) {
|
|
|
|
|
|
|
|
return void UI.alert(Messages.properties_passwordWarning, function () {
|
|
|
|
|
|
|
|
common.gotoURL(hasPassword && newPass ? undefined : (data.href || data.roHref));
|
|
|
|
|
|
|
|
}, {force: true});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return void UI.alert(Messages.properties_passwordSuccess, function () {
|
|
|
|
common.gotoURL(hasPassword && newPass ? undefined : (data.href || data.roHref));
|
|
|
|
common.gotoURL(hasPassword && newPass ? undefined : (data.href || data.roHref));
|
|
|
|
}, {force: true});
|
|
|
|
}, {force: true});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return void UI.alert(Messages.properties_passwordSuccess, function () {
|
|
|
|
|
|
|
|
common.gotoURL(hasPassword && newPass ? undefined : (data.href || data.roHref));
|
|
|
|
|
|
|
|
}, {force: true});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$d.append(changePass);
|
|
|
|
$d.append(changePass);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $d;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sframeChan = common.getSframeChannel();
|
|
|
|
|
|
|
|
var handler = sframeChan.on('EV_RT_METADATA', function (md) {
|
|
|
|
|
|
|
|
if (!$div.length) {
|
|
|
|
|
|
|
|
handler.stop();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
md = JSON.parse(JSON.stringify(md));
|
|
|
|
|
|
|
|
data.owners = md.owners;
|
|
|
|
|
|
|
|
data.expire = md.expire;
|
|
|
|
|
|
|
|
data.pending_owners = md.pending_owners;
|
|
|
|
|
|
|
|
$div.empty();
|
|
|
|
|
|
|
|
$div.append(draw());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$div.append(draw());
|
|
|
|
|
|
|
|
|
|
|
|
cb(void 0, $d);
|
|
|
|
cb(void 0, $div);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var getPadProperties = function (common, data, cb) {
|
|
|
|
var getPadProperties = function (common, data, cb) {
|
|
|
|
var $d = $('<div>');
|
|
|
|
var $d = $('<div>');
|
|
|
@ -568,6 +596,8 @@ define([
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
cb(void 0, $d);
|
|
|
|
cb(void 0, $d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
UIElements.getProperties = function (common, data, cb) {
|
|
|
|
UIElements.getProperties = function (common, data, cb) {
|
|
|
|
var c1;
|
|
|
|
var c1;
|
|
|
|