Merge branch 'staging' into hide-kanban-controls
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 7.3 KiB |
@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360.4 94.7"><defs><style>.cls-1{fill:#4591c4}.cls-2{fill:#999}</style></defs><title>CryptPad_logo_color</title><g id="Layer_2" data-name="Layer 2"><g id="svg2"><g id="g4845"><path id="path4811" class="cls-1" d="M99.5 63.6a24.8 24.8 0 0 1-5.9-.6 8.5 8.5 0 0 1-3.8-1.9 7.1 7.1 0 0 1-2-3.4 19.4 19.4 0 0 1-.6-5.2v-10a19.4 19.4 0 0 1 .6-5.1 7.1 7.1 0 0 1 2-3.4 8.5 8.5 0 0 1 3.8-2 24.8 24.8 0 0 1 5.9-.6h22.3v6.2h-22a11.8 11.8 0 0 0-2.7.3 3.5 3.5 0 0 0-1.7.9 3.3 3.3 0 0 0-.9 1.6 11.1 11.1 0 0 0-.2 2.5v9.4a11.1 11.1 0 0 0 .2 2.5 3.3 3.3 0 0 0 .9 1.6 3.3 3.3 0 0 0 1.7.8l2.7.2h22v6.1z"/><path id="path4813" class="cls-1" d="M126.5 63.6V48.8a16 16 0 0 1 .7-4.9 7.5 7.5 0 0 1 2.1-3.3 8.9 8.9 0 0 1 3.7-1.9 21.4 21.4 0 0 1 5.5-.6h4.6v5.7h-4.4l-2.5.2a3.3 3.3 0 0 0-1.6.8 3.2 3.2 0 0 0-.8 1.6 10.1 10.1 0 0 0-.3 2.5v14.7z"/><path id="path4815" class="cls-1" d="M154.1 51.4a3.8 3.8 0 0 0 .9 3 4.6 4.6 0 0 0 3.1.8h15.7V38h6.8v25.2q0 4.3-2.1 6.2t-6.9 1.9h-10.2v-5.8h9.6a3.3 3.3 0 0 0 2.1-.6 2.7 2.7 0 0 0 .7-2.2v-2h-16.1a19 19 0 0 1-4.9-.5 7.8 7.8 0 0 1-3.3-1.7 6.5 6.5 0 0 1-1.8-2.8 12.7 12.7 0 0 1-.6-4V38h6.9z"/><path id="path4817" class="cls-1" d="M207.5 38a25.1 25.1 0 0 1 5.9.6 8.5 8.5 0 0 1 3.8 1.9 7.1 7.1 0 0 1 2 3.4 19.7 19.7 0 0 1 .6 5.2v3.4a19.4 19.4 0 0 1-.6 5.2 7.1 7.1 0 0 1-2 3.4 8.5 8.5 0 0 1-3.8 1.9 25.1 25.1 0 0 1-5.9.6h-14.3v7.6h-7V49.1a19.7 19.7 0 0 1 .6-5.2 7.1 7.1 0 0 1 2-3.4 8.6 8.6 0 0 1 3.8-1.9 25.1 25.1 0 0 1 5.9-.6zm5.3 11.3a11.7 11.7 0 0 0-.3-2.7 2.9 2.9 0 0 0-1-1.6 4 4 0 0 0-1.9-.8l-3-.2h-7.8l-2.7.2a3.5 3.5 0 0 0-1.7.8 3.2 3.2 0 0 0-.8 1.6 11.7 11.7 0 0 0-.2 2.6v8.4h13.4l3-.2a3.8 3.8 0 0 0 1.9-.7 2.9 2.9 0 0 0 1-1.6 11.9 11.9 0 0 0 .3-2.8z"/><path id="path4819" class="cls-1" d="M226.5 63.6V43.8H223V38h3.6v-7.2h7.2V38h8.1v5.7h-8.1v19.9z"/><path id="path4821" class="cls-2" d="M252.4 54.4v9.2h-7.2V31.4H271a25.7 25.7 0 0 1 5.8.5 8.4 8.4 0 0 1 3.7 1.8 6.8 6.8 0 0 1 2 3.2 17.1 17.1 0 0 1 .6 4.8v2.8a16.9 16.9 0 0 1-.6 4.8 6 6 0 0 1-2 3 8.3 8.3 0 0 1-3.7 1.6 31.6 31.6 0 0 1-5.9.4zm23.5-12.3q0-2.6-1.1-3.5t-4-.9h-18.4v11h18.5a6.5 6.5 0 0 0 3.9-.9q1.1-.9 1.1-3.4z"/><path id="path4823" class="cls-2" d="M296.2 63.6a18.4 18.4 0 0 1-4.6-.5 7.4 7.4 0 0 1-2.9-1.3 4.6 4.6 0 0 1-1.5-2.1 8.7 8.7 0 0 1-.4-2.8v-2.4a9.3 9.3 0 0 1 .4-2.9 4.7 4.7 0 0 1 1.4-2.1 6.5 6.5 0 0 1 2.7-1.3 17.7 17.7 0 0 1 4.4-.4h18.9v-.6q0-2.5-1-3.3a5.3 5.3 0 0 0-3.4-.8h-7V38h7a20.7 20.7 0 0 1 5.2.6 8.9 8.9 0 0 1 3.5 1.7 6.7 6.7 0 0 1 2 2.9 12.5 12.5 0 0 1 .6 4.2v6.2a17.2 17.2 0 0 1-.5 4.7 6.3 6.3 0 0 1-1.9 3.1 7.9 7.9 0 0 1-3.6 1.7 26.8 26.8 0 0 1-5.6.5zM314.7 52h-18.2a3.1 3.1 0 0 0-1.9.5 2.5 2.5 0 0 0-.7 2.1v1.7a2.1 2.1 0 0 0 .8 1.9 3.7 3.7 0 0 0 2.1.5H310l2.1-.2a3.2 3.2 0 0 0 1.5-.7 3 3 0 0 0 .9-1.4 7.8 7.8 0 0 0 .3-2.3z"/><path id="path4825" class="cls-2" d="M339.1 63.6a25.4 25.4 0 0 1-6-.6 8.6 8.6 0 0 1-3.8-1.9 7.1 7.1 0 0 1-2-3.4 19.4 19.4 0 0 1-.6-5.2v-3.4a19.7 19.7 0 0 1 .6-5.2 7.1 7.1 0 0 1 2-3.4 8.6 8.6 0 0 1 3.8-1.9 25.4 25.4 0 0 1 6-.6h14.2v-8.2h7v22.8a19.4 19.4 0 0 1-.6 5.2 7.1 7.1 0 0 1-2 3.4A8.5 8.5 0 0 1 354 63a25.1 25.1 0 0 1-5.9.6zm-5.3-11.2a11.7 11.7 0 0 0 .3 2.7 2.9 2.9 0 0 0 1 1.6 4 4 0 0 0 1.9.8l3.1.2h7.8l2.7-.2a3.3 3.3 0 0 0 1.7-.8 3.2 3.2 0 0 0 .9-1.6 11.9 11.9 0 0 0 .2-2.6v-8.4H340l-3 .2a4 4 0 0 0-1.9.8 2.9 2.9 0 0 0-1 1.6 11.7 11.7 0 0 0-.3 2.7z"/><path id="path4827" class="cls-1" d="M39.2 0L9.9 5.4A6.3 6.3 0 1 0 3.2 16v42.2c0 4 1.8 8.3 5.3 12.7A65.5 65.5 0 0 0 21.6 83a128.2 128.2 0 0 0 17.6 10.5A128.1 128.1 0 0 0 56.7 83a65.4 65.4 0 0 0 13.1-12.1c3.5-4.5 5.3-8.8 5.3-12.7V16A6.3 6.3 0 0 0 72 4.2a6.2 6.2 0 0 0-3.6 1.2zm-.1 6.2l26.7 4.9a5.9 5.9 0 0 0 .2 1.1L50.3 22.5a15.3 15.3 0 0 0-22.6.1l-15.5-10a6.3 6.3 0 0 0 .3-1.4zm28.8 9a6.5 6.5 0 0 0 1.8 1.1v41a10.4 10.4 0 0 1-.1 1.7 21.5 21.5 0 0 1-4.1 7.8 56.1 56.1 0 0 1-11.3 10.4 110.6 110.6 0 0 1-15 9 110.8 110.8 0 0 1-15-9A55.8 55.8 0 0 1 13 66.8a19.8 19.8 0 0 1-4.4-9.3V16.4a6.3 6.3 0 0 0 1.7-1l19.8 12.7a10.1 10.1 0 0 1 9-5.4 10 10 0 0 1 9 5.4z"/><g id="g4829"><path id="path4831" class="cls-2" d="M23 54.8a4.6 4.6 0 1 0 0 9.3 4.6 4.6 0 0 0 0-9.3z"/><path id="path4833" class="cls-2" d="M24.3 28.5a14.9 14.9 0 0 0 4.2 15.4l-7.3 14.8a2.8 2.8 0 0 0 2.3 3.8h11v-5.2h-6.8l6.4-12.8a2.7 2.7 0 0 0-.8-3.3 9.7 9.7 0 0 1-4.3-9.6z"/></g><g id="g4835"><path id="path4837" class="cls-2" d="M55.3 54.8a4.6 4.6 0 1 0 0 9.3 4.6 4.6 0 0 0 0-9.3z"/><path id="path4839" class="cls-2" d="M53.8 28.6l-4.7 3.1a10.2 10.2 0 0 1 .1 1.2 10 10 0 0 1-4.3 8.3 2.7 2.7 0 0 0-.8 3.3l6.3 12.8h-6.8v5.2h11a2.8 2.8 0 0 0 2.3-3.8l-7.3-14.8a15.2 15.2 0 0 0 4.8-11 15.3 15.3 0 0 0-.6-4.3z"/></g><path id="path4841" class="cls-1" d="M43.2 33.3a4.2 4.2 0 1 1-4.2-4.2 4.2 4.2 0 0 1 4.2 4.2z"/><path id="path4843" class="cls-1" d="M45.3 88.4a6.3 6.3 0 1 1-6.3-6.3 6.3 6.3 0 0 1 6.3 6.3z"/></g></g></g></svg>
|
Before Width: | Height: | Size: 4.7 KiB |
@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 393.94 476.2"><defs><style>.cls-1{opacity:0.04;}.cls-2{fill:#999;}.cls-3{fill:#4591c4;}</style></defs><title>CryptPadlogo</title><g id="Layer_2" data-name="Layer 2"><g id="svg2"><g id="g4764" class="cls-1"><path class="cls-2" d="M139.36,288.16l32.07-64.43a13.59,13.59,0,0,0-4.23-16.62,48.65,48.65,0,0,1-21.28-48.25l-23.47-15.31a75.74,75.74,0,0,0-3.36,21.87c0,22,9.52,41.45,24.35,55.54l-27.24,54.8c-.11,0-.2,0-.31,0a23.27,23.27,0,1,0,0,46.53,23,23,0,0,0,17.31-7.86h40.27V288.16Z"/><path class="cls-2" d="M278.28,275.73c-.57,0-1.11.13-1.68.17l-27.33-55.09c14.75-14.07,24.2-33.47,24.2-55.39a77.13,77.13,0,0,0-3.06-21.72l-23.62,15.45a51.69,51.69,0,0,1,.44,6.27A50.21,50.21,0,0,1,225.65,207a13.58,13.58,0,0,0-4.22,16.62l31.77,64.58h-34V314.4h41.63a23.23,23.23,0,1,0,17.41-38.67Z"/><polygon class="cls-2" points="270.41 143.7 270.41 143.7 270.41 143.7 270.41 143.7"/><circle class="cls-3" cx="196.06" cy="167.4" r="21.21"/><path class="cls-3" d="M362.25,21.36a31.14,31.14,0,0,0-18.1,5.8L197,0,50,27.16a31.62,31.62,0,1,0-33.68,53.4v212c0,19.95,8.93,41.51,26.62,64.08,15.66,20,37.82,40.46,65.89,60.83a603,603,0,0,0,57,36.21,31.54,31.54,0,0,0,60,1.25,606,606,0,0,0,59.26-37.46c28.09-20.37,50.23-40.86,65.9-60.83,17.7-22.6,26.61-44.13,26.61-64.08V80.38a31.46,31.46,0,0,0-15.39-59ZM62.82,55.94,196.61,31.32l134.33,24.8a29.58,29.58,0,0,0,.9,5.61L253.09,113a76.78,76.78,0,0,0-113.69.36L61.55,62.82A31.8,31.8,0,0,0,62.82,55.94ZM350.49,288.21a51.41,51.41,0,0,1-.73,8.51c-3.16,12.6-10.11,25.8-20.82,39.47-13.41,17.09-32.43,34.52-56.48,51.95a532.75,532.75,0,0,1-54.19,34.09,31.5,31.5,0,0,0-43.73-.62,534,534,0,0,1-53.06-33.47c-24-17.43-42.9-34.86-56.31-51.95-12.77-16.31-20.25-31.94-22.26-46.71,0-.41,0-.86,0-1.27V82.37a31.51,31.51,0,0,0,8.69-5.25l88.88,57.75.37-.36,10.5,6.88a51,51,0,0,1,45.07-27,50.37,50.37,0,0,1,45.08,27.15l22.09-14.3L341.44,76.4A32.55,32.55,0,0,0,350.49,82Z"/></g></g></g></svg>
|
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 9.8 KiB |
@ -0,0 +1,68 @@
|
||||
/*jshint esversion: 6 */
|
||||
const Stats = module.exports;
|
||||
|
||||
Stats.instanceData = function (Env) {
|
||||
var data = {
|
||||
version: Env.version,
|
||||
installMethod: Env.installMethod,
|
||||
|
||||
domain: Env.myDomain,
|
||||
subdomain: Env.mySubdomain,
|
||||
|
||||
httpUnsafeOrigin: Env.httpUnsafeOrigin,
|
||||
httpSafeOrigin: Env.httpSafeOrigin,
|
||||
|
||||
adminEmail: Env.consentToContact? Env.adminEmail: undefined,
|
||||
consentToContact: Boolean(Env.consentToContact),
|
||||
|
||||
instancePurpose: Env.instancePurpose === 'noanswer'? undefined: Env.instancePurpose,
|
||||
};
|
||||
|
||||
/* We reserve the right to choose not to include instances
|
||||
in our public directory at our discretion.
|
||||
|
||||
The following details will be included in your telemetry
|
||||
as factors that may contribute to that decision.
|
||||
|
||||
These values are publicly available via /api/config
|
||||
posting them to our server just makes it easier for us.
|
||||
*/
|
||||
if (Env.listMyInstance) {
|
||||
// clearly indicate that you want to be listed
|
||||
data.listMyInstance = Env.listMyInstance;
|
||||
|
||||
// you should have enabled your admin panel
|
||||
data.adminKeys = Env.admins.length > 0;
|
||||
|
||||
// we expect that you enable your support mailbox
|
||||
data.supportMailbox = Boolean(Env.supportMailbox);
|
||||
|
||||
// do you allow registration?
|
||||
data.restrictRegistration = Boolean(Env.restrictRegistration);
|
||||
|
||||
// have you removed the donate button?
|
||||
data.removeDonateButton = Boolean(Env.removeDonateButton);
|
||||
|
||||
// after how long do you consider a document to be inactive?
|
||||
data.inactiveTime = Env.inactiveTime;
|
||||
|
||||
// how much storage do you offer to registered users?
|
||||
data.defaultStorageLimit = Env.defaultStorageLimit;
|
||||
|
||||
// what size file upload do you permit
|
||||
data.maxUploadSize = Env.maxUploadSize;
|
||||
|
||||
// how long do you retain inactive accounts?
|
||||
data.accountRetentionTime = Env.accountRetentionTime;
|
||||
|
||||
// how long do you retain archived data?
|
||||
//data.archiveRetentionTime = Env.archiveRetentionTime,
|
||||
}
|
||||
|
||||
// we won't consider instances for public listings
|
||||
// unless they opt to provide more info about themselves
|
||||
if (!Env.provideAggregateStatistics) { return data; }
|
||||
|
||||
return data;
|
||||
};
|
||||
|
@ -0,0 +1,88 @@
|
||||
/*jshint esversion: 6 */
|
||||
const Block = module.exports;
|
||||
const Util = require("../common-util");
|
||||
const Path = require("path");
|
||||
const Fs = require("fs");
|
||||
const Fse = require("fs-extra");
|
||||
const nThen = require("nthen");
|
||||
|
||||
Block.mkPath = function (Env, publicKey) {
|
||||
// prepare publicKey to be used as a file name
|
||||
var safeKey = Util.escapeKeyCharacters(publicKey);
|
||||
|
||||
// validate safeKey
|
||||
if (typeof(safeKey) !== 'string') { return; }
|
||||
|
||||
// derive the full path
|
||||
// /home/cryptpad/cryptpad/block/fg/fg32kefksjdgjkewrjksdfksjdfsdfskdjfsfd
|
||||
return Path.join(Env.paths.block, safeKey.slice(0, 2), safeKey);
|
||||
};
|
||||
|
||||
Block.mkArchivePath = function (Env, publicKey) {
|
||||
// prepare publicKey to be used as a file name
|
||||
var safeKey = Util.escapeKeyCharacters(publicKey);
|
||||
|
||||
// validate safeKey
|
||||
if (typeof(safeKey) !== 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
// derive the full path
|
||||
// /home/cryptpad/cryptpad/block/fg/fg32kefksjdgjkewrjksdfksjdfsdfskdjfsfd
|
||||
return Path.join(Env.paths.archive, 'block', safeKey.slice(0, 2), safeKey);
|
||||
};
|
||||
|
||||
Block.archive = function (Env, publicKey, _cb) {
|
||||
var cb = Util.once(Util.mkAsync(_cb));
|
||||
|
||||
// derive the filepath
|
||||
var currentPath = Block.mkPath(Env, publicKey);
|
||||
|
||||
// make sure the path is valid
|
||||
if (typeof(currentPath) !== 'string') {
|
||||
return void cb('E_INVALID_BLOCK_PATH');
|
||||
}
|
||||
|
||||
var archivePath = Block.mkArchivePath(Env, publicKey);
|
||||
// make sure the path is valid
|
||||
if (typeof(archivePath) !== 'string') {
|
||||
return void cb('E_INVALID_BLOCK_ARCHIVAL_PATH');
|
||||
}
|
||||
|
||||
Fse.move(currentPath, archivePath, {
|
||||
overwrite: true,
|
||||
}, cb);
|
||||
};
|
||||
|
||||
Block.check = function (Env, publicKey, _cb) { // 'check' because 'exists' implies boolean
|
||||
var cb = Util.once(Util.mkAsync(_cb));
|
||||
var path = Block.mkPath(Env, publicKey);
|
||||
Fs.access(path, Fs.constants.F_OK, cb);
|
||||
};
|
||||
|
||||
Block.write = function (Env, publicKey, buffer, _cb) {
|
||||
var cb = Util.once(Util.mkAsync(_cb));
|
||||
var path = Block.mkPath(Env, publicKey);
|
||||
if (typeof(path) !== 'string') { return void cb('INVALID_PATH'); }
|
||||
var parsed = Path.parse(path);
|
||||
|
||||
nThen(function (w) {
|
||||
Fse.mkdirp(parsed.dir, w(function (err) {
|
||||
if (!err) { return; }
|
||||
w.abort();
|
||||
cb(err);
|
||||
}));
|
||||
}).nThen(function (w) {
|
||||
Block.archive(Env, publicKey, w(function (/* err */) {
|
||||
/*
|
||||
we proceed even if there are errors.
|
||||
it might be ENOENT (there is no file to archive)
|
||||
or EACCES (bad filesystem permissions for the existing archived block?)
|
||||
or lots of other things, none of which justify preventing the write
|
||||
*/
|
||||
}));
|
||||
}).nThen(function () {
|
||||
Fs.writeFile(path, buffer, { encoding: 'binary' }, cb);
|
||||
});
|
||||
};
|
||||
|
@ -0,0 +1,8 @@
|
||||
// TODO unify the following scripts
|
||||
// unused-translations.js
|
||||
// find-html-translations
|
||||
|
||||
// more linting
|
||||
// Search for 'Cryptpad' string (should be 'CryptPad')
|
||||
// Search English for -ise\s
|
||||
|
@ -0,0 +1,36 @@
|
||||
define([
|
||||
], function () {
|
||||
var Tools = {};
|
||||
Tools.supportsSharedArrayBuffers = function () {
|
||||
try {
|
||||
return Object.prototype.toString.call(new window.WebAssembly.Memory({
|
||||
shared: true,
|
||||
initial: 0,
|
||||
maximum: 0,
|
||||
}).buffer) === '[object SharedArrayBuffer]';
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
Tools.isSafari = function () {
|
||||
return navigator.vendor.match(/apple/i);
|
||||
};
|
||||
|
||||
Tools.isChrome = function () {
|
||||
return navigator.vendor.match(/google/i);
|
||||
};
|
||||
|
||||
Tools.guessBrowser = function () {
|
||||
if (Tools.isChrome()) { return 'chrome/blink'; }
|
||||
if (Tools.isSafari()) { return 'safari/webkit'; }
|
||||
if (navigator.userAgent.match(/firefox\//i)) { return 'firefox/gecko'; }
|
||||
if (navigator.userAgent.match(/edge\//i)) { return 'edge/edgehtml'; }
|
||||
if (navigator.userAgent.match(/trident\//i)) { return 'ie/trident'; }
|
||||
return navigator.userAgent + "\n" + navigator.vendor;
|
||||
};
|
||||
|
||||
return Tools;
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<script data-bootload="main.js" data-main="/common/boot.js" src="/bower_components/requirejs/require.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="cp-progress"></div>
|
||||
<iframe-placeholder>
|
||||
|
@ -0,0 +1,78 @@
|
||||
define([
|
||||
'jquery',
|
||||
'/common/common-util.js',
|
||||
'/checkup/checkup-tools.js',
|
||||
|
||||
'/bower_components/tweetnacl/nacl-fast.min.js',
|
||||
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
||||
'less!/checkup/app-checkup.less',
|
||||
], function ($, Util, Tools) {
|
||||
var postMessage = function (content) {
|
||||
window.parent.postMessage(JSON.stringify(content), '*');
|
||||
};
|
||||
postMessage({ command: "READY", });
|
||||
var getHeaders = function (url, cb) {
|
||||
$.ajax(url + "?test=" + (+new Date()), {
|
||||
dataType: 'text',
|
||||
complete: function (xhr) {
|
||||
var allHeaders = xhr.getAllResponseHeaders();
|
||||
return void cb(void 0, allHeaders, xhr);
|
||||
},
|
||||
});
|
||||
};
|
||||
var COMMANDS = {};
|
||||
COMMANDS.GET_HEADER = function (content, cb) {
|
||||
var url = content.url;
|
||||
getHeaders(url, function (err, headers, xhr) {
|
||||
cb(xhr.getResponseHeader(content.header));
|
||||
});
|
||||
};
|
||||
|
||||
COMMANDS.CHECK_JS_APIS = function (content, cb) {
|
||||
var globalAPIs = content['globals'] || [];
|
||||
var response = {};
|
||||
globalAPIs.forEach(function (key) {
|
||||
if (Array.isArray(key)) {
|
||||
response[key.join('.')] = Boolean(Util.find(window, key));
|
||||
return;
|
||||
}
|
||||
|
||||
response[key] = Boolean(window[key]);
|
||||
});
|
||||
cb(response);
|
||||
};
|
||||
|
||||
COMMANDS.FANCY_API_CHECKS = function (content, cb) {
|
||||
cb({
|
||||
SharedArrayBufferFallback: Tools.supportsSharedArrayBuffers(),
|
||||
});
|
||||
};
|
||||
|
||||
window.addEventListener("message", function (event) {
|
||||
var txid, command;
|
||||
if (event && event.data) {
|
||||
try {
|
||||
//console.log(JSON.parse(event.data));
|
||||
var msg = JSON.parse(event.data);
|
||||
command = msg.command;
|
||||
txid = msg.txid;
|
||||
if (!txid) { return; }
|
||||
COMMANDS[command](msg.content, function (response) {
|
||||
// postMessage with same txid
|
||||
postMessage({
|
||||
txid: txid,
|
||||
content: response,
|
||||
});
|
||||
});
|
||||
} catch (err) {
|
||||
postMessage({
|
||||
txid: txid,
|
||||
content: err,
|
||||
});
|
||||
console.error(err, command);
|
||||
}
|
||||
} else {
|
||||
console.error(event);
|
||||
}
|
||||
});
|
||||
});
|