Merge branch 'echidna' into serviceworker

pull/1/head
yflory 7 years ago
commit 14db9fad8e

@ -16,13 +16,14 @@ define([
Messaging, Constants, Feedback, LocalStore, /*AStore, */Channel,
AppConfig, Nthen) {
/* This file exposes functionality which is specific to Cryptpad, but not to
any particular pad type. This includes functions for committing metadata
about pads to your local storage for future use and improved usability.
Additionally, there is some basic functionality for import/export.
*/
var urlArgs = Util.find(Config, ['requireConf', 'urlArgs']) || '';
var postMessage = function (/*cmd, data, cb*/) {
/*setTimeout(function () {
AStore.query(cmd, data, cb);
@ -768,7 +769,7 @@ define([
var postMsg, worker;
Nthen(function (waitFor2) {
if (SharedWorker) {
worker = new SharedWorker('/common/outer/sharedworker.js');
worker = new SharedWorker('/common/outer/sharedworker.js' + urlArgs);
console.log(worker);
worker.port.onmessage = function (ev) {
if (ev.data === "SW_READY") {
@ -788,7 +789,7 @@ define([
if (worker) { return void worker.postMessage(data); }
};
navigator.serviceWorker.register('/common/outer/serviceworker.js', {scope: '/'})
navigator.serviceWorker.register('/common/outer/serviceworker.js' + urlArgs, {scope: '/'})
.then(function(reg) {
// Add handler for receiving messages from the service worker
navigator.serviceWorker.addEventListener('message', function (ev) {
@ -828,7 +829,7 @@ define([
/**/console.log('Registration failed with ' + error);
});
} else if (Worker) {
worker = new Worker('/common/outer/webworker.js');
worker = new Worker('/common/outer/webworker.js' + urlArgs);
worker.onmessage = function (ev) {
msgEv.fire(ev);
};

@ -1,28 +1,16 @@
/* jshint ignore:start */
importScripts('/bower_components/requirejs/require.js');
require.config({
// fix up locations so that relative urls work.
baseUrl: '/',
paths: {
// jquery declares itself as literally "jquery" so it cannot be pulled by path :(
"jquery": "/bower_components/jquery/dist/jquery.min",
// json.sortify same
"json.sortify": "/bower_components/json.sortify/dist/JSON.sortify",
cm: '/bower_components/codemirror'
},
map: {
'*': {
'css': '/bower_components/require-css/css.js',
'less': '/common/RequireLess.js',
}
}
});
window = self;
localStorage = {
setItem: function (k, v) { localStorage[k] = v; },
getItem: function (k) { return localStorage[k]; }
};
require([
'/common/requireconfig.js'
], function (RequireConfig) {
require.config(RequireConfig());
require([
'/common/common-util.js',
'/common/outer/worker-channel.js',
@ -31,7 +19,6 @@ require([
var msgEv = Util.mkEvent();
Channel.create(msgEv, postMessage, function (chan) {
console.log('ww ready');
var clientId = '1';
Object.keys(Rpc.queries).forEach(function (q) {
if (q === 'CONNECT') { return; }
@ -48,7 +35,6 @@ require([
});
});
chan.on('CONNECT', function (cfg, cb) {
console.log('onConnect');
// load Store here, with cfg, and pass a "query" (chan.query)
// cId is a clientId used in ServiceWorker or SharedWorker
cfg.query = function (cId, cmd, data, cb) {
@ -67,7 +53,6 @@ require([
});
};
Rpc.queries['CONNECT'](clientId, cfg, function (data) {
console.log(data);
if (data && data.state === "ALREADY_INIT") {
return void cb(data);
}
@ -110,3 +95,4 @@ require([
msgEv.fire(e);
};
});
});

@ -1,3 +1,4 @@
/* jshint ignore:start */
var id;
//= Math.floor(Math.random()*100000);

@ -1 +0,0 @@
worker/
Loading…
Cancel
Save