Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging
This commit is contained in:
commit
26193aeaa7
@ -277,6 +277,11 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
//logFeedback: true,
|
//logFeedback: true,
|
||||||
|
|
||||||
|
/* If you wish to see which remote procedure calls clients request,
|
||||||
|
* set this to true
|
||||||
|
*/
|
||||||
|
//logRPC: true,
|
||||||
|
|
||||||
/* it is recommended that you serve CryptPad over https
|
/* it is recommended that you serve CryptPad over https
|
||||||
* the filepaths below are used to configure your certificates
|
* the filepaths below are used to configure your certificates
|
||||||
*/
|
*/
|
||||||
|
|||||||
1
rpc.js
1
rpc.js
@ -944,6 +944,7 @@ RPC.create = function (config /*:typeof(ConfigType)*/, cb /*:(?Error, ?Function)
|
|||||||
if (!Env.msgStore) { Env.msgStore = ctx.store; }
|
if (!Env.msgStore) { Env.msgStore = ctx.store; }
|
||||||
|
|
||||||
var handleMessage = function (privileged) {
|
var handleMessage = function (privileged) {
|
||||||
|
if (config.logRPC) { console.log(msg[0]); }
|
||||||
switch (msg[0]) {
|
switch (msg[0]) {
|
||||||
case 'COOKIE': return void Respond(void 0);
|
case 'COOKIE': return void Respond(void 0);
|
||||||
case 'RESET':
|
case 'RESET':
|
||||||
|
|||||||
@ -135,6 +135,25 @@ define([], function () {
|
|||||||
return g;
|
return g;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* takes a function (f) and a time (t) in ms. returns a function wrapper
|
||||||
|
which prevents the internal function from being called more than once
|
||||||
|
every t ms. if the function is prevented, returns time til next valid
|
||||||
|
execution, else null.
|
||||||
|
*/
|
||||||
|
Util.notAgainForAnother = function (f, t) {
|
||||||
|
if (typeof(f) !== 'function' || typeof(t) !== 'number') {
|
||||||
|
throw new Error("invalid inputs");
|
||||||
|
}
|
||||||
|
var last = null;
|
||||||
|
return function () {
|
||||||
|
var now = +new Date();
|
||||||
|
if (last && now <= last + t) { return t - (now - last); }
|
||||||
|
last = now;
|
||||||
|
f();
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
Util.createRandomInteger = function () {
|
Util.createRandomInteger = function () {
|
||||||
return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
|
return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -84,6 +84,7 @@ define([
|
|||||||
common.throttle = Util.throttle;
|
common.throttle = Util.throttle;
|
||||||
common.createRandomInteger = Util.createRandomInteger;
|
common.createRandomInteger = Util.createRandomInteger;
|
||||||
common.getAppType = Util.getAppType;
|
common.getAppType = Util.getAppType;
|
||||||
|
common.notAgainForAnother = Util.notAgainForAnother;
|
||||||
|
|
||||||
// import hash utilities for export
|
// import hash utilities for export
|
||||||
var createRandomHash = common.createRandomHash = Hash.createRandomHash;
|
var createRandomHash = common.createRandomHash = Hash.createRandomHash;
|
||||||
@ -848,19 +849,28 @@ define([
|
|||||||
rpc.uploadCancel(cb);
|
rpc.uploadCancel(cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Create a usage bar which keeps track of how much storage space is used
|
||||||
|
by your CryptDrive. The getPinnedUsage RPC is one of the heavier calls,
|
||||||
|
so we throttle its usage. Clients will not update more than once per
|
||||||
|
LIMIT_REFRESH_RATE. It will be update at least once every three such intervals
|
||||||
|
If changes are made to your drive in the interim, they will trigger an
|
||||||
|
update.
|
||||||
|
*/
|
||||||
var LIMIT_REFRESH_RATE = 30000; // milliseconds
|
var LIMIT_REFRESH_RATE = 30000; // milliseconds
|
||||||
common.createUsageBar = function (cb) {
|
common.createUsageBar = function (cb) {
|
||||||
// getPinnedUsage updates common.account.usage, and other values
|
// getPinnedUsage updates common.account.usage, and other values
|
||||||
// so we can just use those and only check for errors
|
// so we can just use those and only check for errors
|
||||||
var $container = $('<span>', {'class':'limit-container'});
|
var $container = $('<span>', {'class':'limit-container'});
|
||||||
var todo = function (err) {
|
var todo;
|
||||||
$container.html('');
|
var updateUsage = window.updateUsage = common.notAgainForAnother(function () {
|
||||||
if (err) {
|
console.log("updating usage bar");
|
||||||
return void window.setTimeout(function () {
|
common.getPinnedUsage(todo);
|
||||||
common.getPinnedUsage(todo);
|
}, LIMIT_REFRESH_RATE);
|
||||||
}, LIMIT_REFRESH_RATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
todo = function (err) {
|
||||||
|
if (err) { return void console.error(err); }
|
||||||
|
|
||||||
|
$container.html('');
|
||||||
var unit = Util.magnitudeOfBytes(common.account.limit);
|
var unit = Util.magnitudeOfBytes(common.account.limit);
|
||||||
|
|
||||||
var usage = unit === 'GB'? Util.bytesToGigabytes(common.account.usage):
|
var usage = unit === 'GB'? Util.bytesToGigabytes(common.account.usage):
|
||||||
@ -920,11 +930,25 @@ define([
|
|||||||
var $text = $('<span>', {'class': 'usageText'});
|
var $text = $('<span>', {'class': 'usageText'});
|
||||||
$text.text(usage + ' / ' + prettyLimit);
|
$text.text(usage + ' / ' + prettyLimit);
|
||||||
$limit.append($usage).append($text);
|
$limit.append($usage).append($text);
|
||||||
window.setTimeout(function () {
|
|
||||||
common.getPinnedUsage(todo);
|
|
||||||
}, LIMIT_REFRESH_RATE);
|
|
||||||
};
|
};
|
||||||
common.getPinnedUsage(todo);
|
|
||||||
|
setInterval(function () {
|
||||||
|
var t = updateUsage();
|
||||||
|
if (t) {
|
||||||
|
console.log("usage already updated. eligible for refresh in %sms", t);
|
||||||
|
}
|
||||||
|
}, LIMIT_REFRESH_RATE * 3);
|
||||||
|
|
||||||
|
updateUsage();
|
||||||
|
getProxy().on('change', ['drive'], function () {
|
||||||
|
var t = updateUsage();
|
||||||
|
if (t) {
|
||||||
|
console.log("usage bar update throttled due to overuse." +
|
||||||
|
" Eligible for update in %sms", t);
|
||||||
|
} else {
|
||||||
|
console.log("usage bar updated");
|
||||||
|
}
|
||||||
|
});
|
||||||
cb(null, $container);
|
cb(null, $container);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -465,6 +465,7 @@ define([
|
|||||||
window.frames["pad-iframe"].print();
|
window.frames["pad-iframe"].print();
|
||||||
}
|
}
|
||||||
}, {ok: Messages.printButton});
|
}, {ok: Messages.printButton});
|
||||||
|
Cryptpad.feedback('PRINT_SLIDES');
|
||||||
//$('body').append(createPrintDialog());
|
//$('body').append(createPrintDialog());
|
||||||
}).append($('<span>', {'class': 'drawer'}).text(Messages.printText));
|
}).append($('<span>', {'class': 'drawer'}).text(Messages.printText));
|
||||||
$drawer.append($printButton);
|
$drawer.append($printButton);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user