migrate canvas to netflux
This commit is contained in:
parent
d4943511fe
commit
be1ef7abe3
@ -4,7 +4,7 @@ require.config({ paths: {
|
|||||||
|
|
||||||
define([
|
define([
|
||||||
'/api/config?cb=' + Math.random().toString(16).substring(2),
|
'/api/config?cb=' + Math.random().toString(16).substring(2),
|
||||||
'/common/RealtimeTextarea.js',
|
'/common/realtime-input.js',
|
||||||
'/common/messages.js',
|
'/common/messages.js',
|
||||||
'/common/crypto.js',
|
'/common/crypto.js',
|
||||||
'/common/TextPatcher.js',
|
'/common/TextPatcher.js',
|
||||||
@ -17,12 +17,15 @@ define([
|
|||||||
var $ = module.$ = window.jQuery;
|
var $ = module.$ = window.jQuery;
|
||||||
var Fabric = module.Fabric = window.fabric;
|
var Fabric = module.Fabric = window.fabric;
|
||||||
|
|
||||||
$(window).on('hashchange', function() {
|
|
||||||
window.location.reload();
|
var key;
|
||||||
});
|
var channel = '';
|
||||||
if (window.location.href.indexOf('#') === -1) {
|
if (!/#/.test(window.location.href)) {
|
||||||
window.location.href = window.location.href + '#' + Crypto.genKey();
|
key = Crypto.genKey();
|
||||||
return;
|
} else {
|
||||||
|
var hash = window.location.hash.slice(1);
|
||||||
|
channel = hash.slice(0, 32);
|
||||||
|
key = hash.slice(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize Fabric */
|
/* Initialize Fabric */
|
||||||
@ -56,17 +59,22 @@ define([
|
|||||||
$canvas.css('border-color', bool? 'black': 'red');
|
$canvas.css('border-color', bool? 'black': 'red');
|
||||||
};
|
};
|
||||||
|
|
||||||
var key = Crypto.parseKey(window.location.hash.substring(1));
|
|
||||||
var initializing = true;
|
var initializing = true;
|
||||||
|
|
||||||
var config = module.config = {
|
var config = module.config = {
|
||||||
websocketURL: Config.websocketURL + '_old',
|
// TODO initialState ?
|
||||||
|
websocketURL: Config.websocketURL,
|
||||||
userName: Crypto.rand64(8),
|
userName: Crypto.rand64(8),
|
||||||
channel: key.channel,
|
channel: channel,
|
||||||
cryptKey: key.cryptKey
|
cryptKey: key,
|
||||||
};
|
};
|
||||||
|
|
||||||
var onInit = config.onInit = function (info) { };
|
var onInit = config.onInit = function (info) {
|
||||||
|
window.location.hash = info.channel + key;
|
||||||
|
$(window).on('hashchange', function() {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var onRemote = config.onRemote = function () {
|
var onRemote = config.onRemote = function () {
|
||||||
if (initializing) { return; }
|
if (initializing) { return; }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user