Merge branch 'staging' into newdrive
This commit is contained in:
@@ -9,18 +9,20 @@ define([
|
||||
var module = { exports: {} };
|
||||
var key = Config.requireConf.urlArgs;
|
||||
var localStorage = {};
|
||||
try {
|
||||
localStorage = window.localStorage || {};
|
||||
if (localStorage['LESS_CACHE'] !== key) {
|
||||
Object.keys(localStorage).forEach(function (k) {
|
||||
if (k.indexOf('LESS_CACHE|') !== 0) { return; }
|
||||
delete localStorage[k];
|
||||
});
|
||||
localStorage['LESS_CACHE'] = key;
|
||||
if (!window.cryptpadCache) {
|
||||
try {
|
||||
localStorage = window.localStorage || {};
|
||||
if (localStorage['LESS_CACHE'] !== key) {
|
||||
Object.keys(localStorage).forEach(function (k) {
|
||||
if (k.indexOf('LESS_CACHE|') !== 0) { return; }
|
||||
delete localStorage[k];
|
||||
});
|
||||
localStorage['LESS_CACHE'] = key;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
localStorage = {};
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
localStorage = {};
|
||||
}
|
||||
|
||||
var cacheGet = function (k, cb) {
|
||||
|
||||
@@ -135,6 +135,11 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
var $root = $t.parent();
|
||||
$t.on('tokenfield:removetoken', function () {
|
||||
$root.find('.token-input').focus();
|
||||
});
|
||||
|
||||
t.preventDuplicates = function (cb) {
|
||||
$t.on('tokenfield:createtoken', function (ev) {
|
||||
var val;
|
||||
@@ -181,26 +186,29 @@ define([
|
||||
UI.warn(Messages._getKey('tags_duplicate', [val]));
|
||||
});
|
||||
|
||||
var close = Util.once(function () {
|
||||
var $t = $(tagger).fadeOut(150, function () { $t.remove(); });
|
||||
var listener;
|
||||
var close = Util.once(function (result, ev) {
|
||||
var $frame = $(tagger).fadeOut(150, function () {
|
||||
stopListening(listener);
|
||||
$frame.remove();
|
||||
cb(result, ev);
|
||||
});
|
||||
});
|
||||
|
||||
var listener = listenForKeys(function () {}, function () {
|
||||
close();
|
||||
stopListening(listener);
|
||||
});
|
||||
|
||||
var CB = Util.once(cb);
|
||||
findOKButton(tagger).click(function () {
|
||||
var $ok = findOKButton(tagger).click(function () {
|
||||
var tokens = field.getTokens();
|
||||
close();
|
||||
CB(tokens);
|
||||
close(tokens);
|
||||
});
|
||||
findCancelButton(tagger).click(function () {
|
||||
close();
|
||||
CB(null);
|
||||
var $cancel = findCancelButton(tagger).click(function () {
|
||||
close(null);
|
||||
});
|
||||
listenForKeys(function () {
|
||||
$ok.click();
|
||||
}, function () {
|
||||
$cancel.click();
|
||||
});
|
||||
|
||||
document.body.appendChild(tagger);
|
||||
// :(
|
||||
setTimeout(function () {
|
||||
field.setTokens(tags);
|
||||
|
||||
@@ -18,7 +18,8 @@ define([], function () {
|
||||
fire: function () {
|
||||
if (fired) { return; }
|
||||
fired = true;
|
||||
handlers.forEach(function (h) { h(); });
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
handlers.forEach(function (h) { h.apply(null, args); });
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -111,12 +111,14 @@ define([
|
||||
var newFo = proxyData.fo;
|
||||
var oldRecentPads = parsed.drive[newFo.FILES_DATA];
|
||||
var newRecentPads = proxy.drive[newFo.FILES_DATA];
|
||||
var newFiles = newFo.getFiles([newFo.FILES_DATA]);
|
||||
var oldFiles = oldFo.getFiles([newFo.FILES_DATA]);
|
||||
var newHrefs = Object.keys(newRecentPads).map(function (id) {
|
||||
return newRecentPads[id].href;
|
||||
});
|
||||
oldFiles.forEach(function (id) {
|
||||
var href = oldRecentPads[id].href;
|
||||
// Do not migrate a pad if we already have it, it would create a duplicate in the drive
|
||||
if (newFiles.indexOf(id) !== -1) { return; }
|
||||
if (newHrefs.indexOf(href) !== -1) { return; }
|
||||
// If we have a stronger version, do not add the current href
|
||||
if (Cryptpad.findStronger(href, newRecentPads)) { return; }
|
||||
// If we have a weaker version, replace the href by the new one
|
||||
|
||||
@@ -623,19 +623,6 @@ define([
|
||||
throw new Error('unsupported datatype: '+ DeepProxy.type(cfg.data));
|
||||
}
|
||||
|
||||
if (!cfg.crypto) {
|
||||
// complain and stub
|
||||
console.log("[chainpad-listmap] no crypto module provided. messages will not be encrypted");
|
||||
cfg.crypto = {
|
||||
encrypt: function (msg) {
|
||||
return msg;
|
||||
},
|
||||
decrypt: function (msg) {
|
||||
return msg;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var realtimeOptions = {
|
||||
userName: cfg.userName,
|
||||
initialState: Sortify(cfg.data),
|
||||
|
||||
@@ -46,7 +46,21 @@ define([
|
||||
var metadataMgr = config.metadataMgr;
|
||||
config = undefined;
|
||||
|
||||
var chainpad;
|
||||
var chainpad = ChainPad.create({
|
||||
userName: userName,
|
||||
initialState: initialState,
|
||||
transformFunction: transformFunction,
|
||||
validateContent: validateContent,
|
||||
avgSyncMilliseconds: avgSyncMilliseconds,
|
||||
logLevel: logLevel
|
||||
});
|
||||
chainpad.onMessage(function(message, cb) {
|
||||
sframeChan.query('Q_RT_MESSAGE', message, cb);
|
||||
});
|
||||
chainpad.onPatch(function () {
|
||||
onRemote({ realtime: chainpad });
|
||||
});
|
||||
|
||||
var myID;
|
||||
var isReady = false;
|
||||
var evConnected = Util.mkEvent(true);
|
||||
@@ -67,33 +81,20 @@ define([
|
||||
|
||||
sframeChan.on('EV_RT_DISCONNECT', function () {
|
||||
isReady = false;
|
||||
if (chainpad) { chainpad.abort(); }
|
||||
chainpad.abort();
|
||||
onConnectionChange({ state: false });
|
||||
});
|
||||
sframeChan.on('EV_RT_CONNECT', function (content) {
|
||||
//content.members.forEach(userList.onJoin);
|
||||
myID = content.myID;
|
||||
isReady = false;
|
||||
if (chainpad) {
|
||||
if (myID) {
|
||||
// it's a reconnect
|
||||
if (chainpad) { chainpad.start(); }
|
||||
myID = content.myID;
|
||||
chainpad.start();
|
||||
onConnectionChange({ state: true, myId: myID });
|
||||
return;
|
||||
}
|
||||
chainpad = ChainPad.create({
|
||||
userName: userName,
|
||||
initialState: initialState,
|
||||
transformFunction: transformFunction,
|
||||
validateContent: validateContent,
|
||||
avgSyncMilliseconds: avgSyncMilliseconds,
|
||||
logLevel: logLevel
|
||||
});
|
||||
chainpad.onMessage(function(message, cb) {
|
||||
sframeChan.query('Q_RT_MESSAGE', message, cb);
|
||||
});
|
||||
chainpad.onPatch(function () {
|
||||
onRemote({ realtime: chainpad });
|
||||
});
|
||||
myID = content.myID;
|
||||
onInit({
|
||||
myID: myID,
|
||||
realtime: chainpad,
|
||||
@@ -130,7 +131,8 @@ define([
|
||||
getMyID: function () { return myID; },
|
||||
metadataMgr: metadataMgr,
|
||||
whenRealtimeSyncs: whenRealtimeSyncs,
|
||||
onInfiniteSpinner: evInfiniteSpinner.reg
|
||||
onInfiniteSpinner: evInfiniteSpinner.reg,
|
||||
chainpad: chainpad,
|
||||
});
|
||||
};
|
||||
return Object.freeze(module.exports);
|
||||
|
||||
@@ -112,10 +112,13 @@ define([
|
||||
};
|
||||
|
||||
onComplete = function (href) {
|
||||
var mdMgr = common.getMetadataMgr();
|
||||
var origin = mdMgr.getPrivateData().origin;
|
||||
$link.prepend($('<span>', {'class': 'fa fa-external-link'}));
|
||||
$link.attr('href', href)
|
||||
.click(function (e) {
|
||||
e.preventDefault();
|
||||
window.open($link.attr('href'), '_blank');
|
||||
window.open(origin + $link.attr('href'), '_blank');
|
||||
});
|
||||
var title = metadata.name;
|
||||
Cryptpad.log(Messages._getKey('upload_success', [title]));
|
||||
|
||||
@@ -205,12 +205,11 @@ define([
|
||||
.click(function () {
|
||||
sframeChan.query('Q_TAGS_GET', null, function (err, res) {
|
||||
if (err || res.error) { return void console.error(err || res.error); }
|
||||
var dialog = Cryptpad.dialog.tagPrompt(res.data, function (tags) {
|
||||
Cryptpad.dialog.tagPrompt(res.data, function (tags) {
|
||||
if (!Array.isArray(tags)) { return; }
|
||||
console.error(tags);
|
||||
sframeChan.event('EV_TAGS_SET', tags);
|
||||
});
|
||||
document.body.appendChild(dialog);
|
||||
});
|
||||
});
|
||||
break;
|
||||
@@ -418,7 +417,7 @@ define([
|
||||
$userAdminContent.append($userName);
|
||||
options.push({
|
||||
tag: 'p',
|
||||
attributes: {'class': 'accountData'},
|
||||
attributes: {'class': 'cp-toolbar-account'},
|
||||
content: $userAdminContent.html()
|
||||
});
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ define([
|
||||
if (msg) {
|
||||
msg = msg.replace(/^cp\|/, '');
|
||||
var decryptedMsg = crypto.decrypt(msg, secret.keys.validateKey);
|
||||
msgs.push(decryptedMsg)
|
||||
msgs.push(decryptedMsg);
|
||||
}
|
||||
};
|
||||
network.on('message', onMsg);
|
||||
|
||||
@@ -688,7 +688,7 @@ define([
|
||||
};
|
||||
|
||||
var typing = -1;
|
||||
var kickSpinner = function (toolbar, config, local) {
|
||||
var kickSpinner = function (toolbar, config/*, local*/) {
|
||||
if (!toolbar.spinner) { return; }
|
||||
var $spin = toolbar.spinner;
|
||||
|
||||
@@ -708,7 +708,7 @@ define([
|
||||
window.clearInterval($spin.interval);
|
||||
typing = -1;
|
||||
$spin.text(Messages.saved);
|
||||
}, local ? 0 : SPINNER_DISAPPEAR_TIME);
|
||||
}, /*local ? 0 :*/ SPINNER_DISAPPEAR_TIME);
|
||||
};
|
||||
config.sfCommon.whenRealtimeSyncs(onSynced);
|
||||
};
|
||||
|
||||
@@ -457,7 +457,7 @@ define([
|
||||
};
|
||||
exp.getRecentPads = function () {
|
||||
var allFiles = files[FILES_DATA];
|
||||
var sorted = Object.keys(allFiles)
|
||||
var sorted = Object.keys(allFiles).filter(function (a) { return allFiles[a]; })
|
||||
.sort(function (a,b) {
|
||||
return allFiles[a].atime < allFiles[b].atime;
|
||||
})
|
||||
@@ -1041,20 +1041,6 @@ define([
|
||||
}
|
||||
});
|
||||
};
|
||||
var migrateAttributes = function (el, id, parsed) {
|
||||
// Migrate old pad attributes
|
||||
['userid', 'previewMode'].forEach(function (attr) {
|
||||
var key = parsed.hash + '.' + attr;
|
||||
var key2 = parsed.hash.slice(0,-1) + '.' + attr;// old pads not ending with /
|
||||
if (typeof(files[key]) !== "undefined" || typeof(files[key2]) !== "undefined") {
|
||||
debug("Migrating pad attribute", attr, "for pad", id);
|
||||
el[attr] = files[key] || files[key2];
|
||||
delete files[key];
|
||||
delete files[key2];
|
||||
}
|
||||
});
|
||||
// Migration done
|
||||
};
|
||||
var fixFilesData = function () {
|
||||
if (typeof files[FILES_DATA] !== "object") { debug("OLD_FILES_DATA was not an object"); files[FILES_DATA] = {}; }
|
||||
var fd = files[FILES_DATA];
|
||||
@@ -1081,8 +1067,6 @@ define([
|
||||
continue;
|
||||
}
|
||||
|
||||
migrateAttributes(el, id, parsed);
|
||||
|
||||
if ((loggedIn || config.testMode) && rootFiles.indexOf(id) === -1) {
|
||||
debug("An element in filesData was not in ROOT, TEMPLATE or TRASH.", id, el);
|
||||
var newName = Cryptpad.createChannelId();
|
||||
|
||||
Reference in New Issue
Block a user