', { id: 'cp-creation-container' }).appendTo($body);
var $creation = $('
', { id: 'cp-creation' }).appendTo($creationContainer);
@@ -1182,6 +1460,11 @@ define([
]);
$creation.append(owned);
+ // If set to "open pad" or not set, check "open pad"
+ if (!cfg.owned && typeof cfg.owned !== "undefined") {
+ $creation.find('#cp-creation-owned-false').attr('checked', true);
+ }
+
// Life time
var expire = h('div.cp-creation-expire', [
h('h2', [
@@ -1223,6 +1506,8 @@ define([
]);
$creation.append(expire);
+ UIElements.setExpirationValue(cfg.expire, $creation);
+
// Create the pad
var create = function (template) {
// Type of pad
@@ -1240,11 +1525,7 @@ define([
expireVal = ($('#cp-creation-expire-val').val() || 0) * unit;
}
- // XXX TODO remove these lines
- ownedVal = undefined;
- expire = undefined;
-
- sframeChan.query("Q_CREATE_PAD", {
+ common.createPad({
owned: ownedVal,
expire: expireVal,
template: template
diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js
index ac81b7bc3..775c725ad 100644
--- a/www/common/cryptpad-common.js
+++ b/www/common/cryptpad-common.js
@@ -276,6 +276,7 @@ define([
};
common.setPadAttribute = function (attr, value, cb, href) {
+ cb = cb || function () {};
href = Hash.getRelativeHref(href || window.location.href);
postMessage("SET_PAD_ATTRIBUTE", {
href: href,
@@ -297,6 +298,7 @@ define([
});
};
common.setAttribute = function (attr, value, cb) {
+ cb = cb || function () {};
postMessage("SET_ATTRIBUTE", {
attr: attr,
value: value
diff --git a/www/common/metadata-manager.js b/www/common/metadata-manager.js
index bf99e4b84..0ec1c07ea 100644
--- a/www/common/metadata-manager.js
+++ b/www/common/metadata-manager.js
@@ -97,6 +97,8 @@ define(['json.sortify'], function (Sortify) {
change(true);
});
sframeChan.on('EV_RT_JOIN', function (ev) {
+ var idx = members.indexOf(ev);
+ if (idx !== -1) { console.log('Error: ' + ev + ' is already in members'); return; }
members.push(ev);
if (!meta.user) { return; }
change(false);
diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js
index fca25b3b1..82cbee00d 100644
--- a/www/common/outer/async-store.js
+++ b/www/common/outer/async-store.js
@@ -10,12 +10,13 @@ define([
'/common/common-messenger.js',
'/common/outer/chainpad-netflux-worker.js',
'/common/outer/network-config.js',
+ '/customize/application_config.js',
'/bower_components/chainpad-crypto/crypto.js?v=0.1.5',
'/bower_components/chainpad/chainpad.dist.js',
'/bower_components/chainpad-listmap/chainpad-listmap.js',
], function (UserObject, Migrate, Hash, Util, Constants, Feedback, Realtime, Messaging, Messenger,
- CpNfWorker, NetConfig,
+ CpNfWorker, NetConfig, AppConfig,
Crypto, ChainPad, Listmap) {
var Store = {};
@@ -361,6 +362,8 @@ define([
Store.addPad = function (data, cb) {
if (!data.href) { return void cb({error:'NO_HREF'}); }
var pad = makePad(data.href, data.title);
+ if (data.owners) { pad.owners = data.owners; }
+ if (data.expire) { pad.expire = data.expire; }
store.userObject.pushData(pad, function (e, id) {
if (e) { return void cb({error: "Error while adding a template:"+ e}); }
var path = data.path || ['root'];
@@ -522,6 +525,17 @@ define([
var p = Hash.parsePadUrl(href);
var h = p.hashData;
+ if (AppConfig.disableAnonymousStore && !store.loggedIn) { return void cb(); }
+
+ var owners;
+ if (Store.channel && Store.channel.wc && Util.base64ToHex(h.channel) === Store.channel.wc.id) {
+ owners = Store.channel.data.owners || undefined;
+ }
+ var expire;
+ if (Store.channel && Store.channel.wc && Util.base64ToHex(h.channel) === Store.channel.wc.id) {
+ expire = +Store.channel.data.expire || undefined;
+ }
+
var allPads = Util.find(store.proxy, ['drive', 'filesData']) || {};
var isStronger;
@@ -583,6 +597,8 @@ define([
Store.addPad({
href: href,
title: title,
+ owners: owners,
+ expire: expire,
path: data.path || (store.data && store.data.initialPath)
}, cb);
return;
@@ -735,12 +751,14 @@ define([
// TODO with sharedworker
// channel will be an object storing the webchannel associated to each browser tab
- var channel = {
- queue: []
+ var channel = Store.channel = {
+ queue: [],
+ data: {}
};
Store.joinPad = function (data, cb) {
var conf = {
- onReady: function () {
+ onReady: function (padData) {
+ channel.data = padData || {};
postMessage("PAD_READY");
}, // post EV_PAD_READY
onMessage: function (m) {
diff --git a/www/common/outer/chainpad-netflux-worker.js b/www/common/outer/chainpad-netflux-worker.js
index a60d73b3e..f136e2a1e 100644
--- a/www/common/outer/chainpad-netflux-worker.js
+++ b/www/common/outer/chainpad-netflux-worker.js
@@ -36,6 +36,7 @@ define([], function () {
var owners = conf.owners;
var password = conf.password;
var expire = conf.expire;
+ var padData;
conf = undefined;
var initializing = true;
@@ -43,11 +44,11 @@ define([], function () {
var messageFromOuter = function () {};
- var onRdy = function () {
+ var onRdy = function (padData) {
// Trigger onReady only if not ready yet. This is important because the history keeper sends a direct
// message through "network" when it is synced, and it triggers onReady for each channel joined.
if (!initializing) { return; }
- onReady();
+ onReady(padData);
//sframeChan.event('EV_RT_READY', null);
// we're fully synced
initializing = false;
@@ -92,13 +93,14 @@ define([], function () {
if (parsed.channel === wc.id && !validateKey) {
validateKey = parsed.validateKey;
}
+ padData = parsed;
// We have to return even if it is not the current channel:
// we don't want to continue with other channels messages here
return;
}
if (parsed.state && parsed.state === 1 && parsed.channel) {
if (parsed.channel === wc.id) {
- onRdy();
+ onRdy(padData);
}
// We have to return even if it is not the current channel:
// we don't want to continue with other channels messages here
diff --git a/www/common/outer/local-store.js b/www/common/outer/local-store.js
index d5fd03623..09cc68549 100644
--- a/www/common/outer/local-store.js
+++ b/www/common/outer/local-store.js
@@ -2,7 +2,8 @@ define([
'/common/common-constants.js',
'/common/common-hash.js',
'/bower_components/localforage/dist/localforage.min.js',
-], function (Constants, Hash, localForage) {
+ '/customize/application_config.js',
+], function (Constants, Hash, localForage, AppConfig) {
var LocalStore = {};
LocalStore.setThumbnail = function (key, value, cb) {
@@ -115,6 +116,10 @@ define([
if (typeof (h) === "function") { h(); }
});
+ if (typeof(AppConfig.customizeLogout) === 'function') {
+ return void AppConfig.customizeLogout(cb);
+ }
+
if (cb) { cb(); }
};
LocalStore.onLogout = function (h) {
@@ -125,6 +130,5 @@ define([
-
return LocalStore;
});
diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js
index cfb3462c3..9e4b1160a 100644
--- a/www/common/sframe-app-framework.js
+++ b/www/common/sframe-app-framework.js
@@ -300,7 +300,9 @@ define([
}
}
- if (newPad && !AppConfig.displayCreationScreen) {
+ var skipTemp = Util.find(privateDat, ['settings', 'general', 'creation', 'noTemplate']);
+ var skipCreation = Util.find(privateDat, ['settings', 'general', 'creation', 'skip']);
+ if (newPad && (!skipTemp && skipCreation)) {
common.openTemplatePicker();
}
};
@@ -368,9 +370,9 @@ define([
if (data.type !== 'file') { console.log('unhandled embed type ' + data.type); return; }
var privateDat = cpNfInner.metadataMgr.getPrivateData();
var origin = privateDat.fileHost || privateDat.origin;
- var src = origin + data.src;
+ var src = data.src = origin + data.src;
mediaTagEmbedder($('
'));
+ '" data-crypto-key="cryptpad:' + data.key + '">'), data);
}
});
$embedButton = $('