You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.5 KiB
JavaScript
95 lines
2.5 KiB
JavaScript
8 years ago
|
define([
|
||
|
'/api/config?cb=' + Math.random().toString(16).substring(2),
|
||
|
'/customize/messages.js',
|
||
8 years ago
|
'board.js',
|
||
8 years ago
|
'/bower_components/textpatcher/TextPatcher.js',
|
||
|
'/bower_components/chainpad-listmap/chainpad-listmap.js',
|
||
|
'/bower_components/chainpad-crypto/crypto.js',
|
||
|
'/common/cryptpad-common.js',
|
||
|
'/common/visible.js',
|
||
|
'/common/notify.js',
|
||
|
'/bower_components/file-saver/FileSaver.min.js',
|
||
|
'/bower_components/jquery/dist/jquery.min.js',
|
||
|
], function (Config, Messages, Board, TextPatcher, Listmap, Crypto, Cryptpad, Visible, Notify) {
|
||
|
var $ = window.jQuery;
|
||
|
var saveAs = window.saveAs;
|
||
|
|
||
|
Cryptpad.styleAlerts();
|
||
|
console.log("Initializing your realtime session...");
|
||
|
|
||
|
var secret = Cryptpad.getSecrets();
|
||
|
|
||
|
var module = window.APP = {
|
||
|
Board: Board,
|
||
|
};
|
||
|
|
||
|
var unnotify = function () {
|
||
|
if (!(module.tabNotification &&
|
||
|
typeof(module.tabNotification.cancel) === 'function')) { return; }
|
||
|
module.tabNotification.cancel();
|
||
|
};
|
||
|
|
||
|
var notify = function () {
|
||
|
if (!(Visible.isSupported() && !Visible.currently())) { return; }
|
||
|
unnotify();
|
||
8 years ago
|
module.tabNotification = Notify.tab(1000, 10);
|
||
8 years ago
|
};
|
||
|
|
||
|
var setEditable = function (bool) {
|
||
|
|
||
|
};
|
||
|
|
||
|
setEditable(false);
|
||
|
|
||
|
|
||
|
var $lists = $('#lists');
|
||
|
|
||
|
var $addList = $('#create-list').click(function () {
|
||
|
Board.List.draw($lists);
|
||
|
});
|
||
|
|
||
|
var firstUser = function () {
|
||
|
Cryptpad.log("You are the first user to visit this board");
|
||
|
};
|
||
|
|
||
|
var whenReady = function (opt) {
|
||
|
var rt = module.rt;
|
||
|
var proxy = rt.proxy;
|
||
|
|
||
|
var first = Board.initialize(proxy);
|
||
|
|
||
|
//var board = module.board = Board.create(proxy);
|
||
|
|
||
|
Board.Draw($lists);
|
||
|
|
||
|
if (first) { firstUser(); }
|
||
|
|
||
|
};
|
||
|
|
||
|
var config = {
|
||
|
websocketURL: Config.websocketURL,
|
||
|
channel: secret.channel,
|
||
|
data: {},
|
||
|
crypto: Crypto.createEncryptor(secret.key),
|
||
|
};
|
||
|
|
||
|
Cryptpad.ready(function () {
|
||
|
var rt = module.rt = Listmap.create(config);
|
||
|
var proxy = rt.proxy;
|
||
|
proxy
|
||
|
.on('create', function (info) {
|
||
|
var realtime = module.realtime = info.realtime;
|
||
|
window.location.hash = info.channel + secret.key;
|
||
|
})
|
||
|
.on('ready', function (info) {
|
||
|
Cryptpad.log("Ready!");
|
||
|
whenReady({
|
||
|
|
||
|
});
|
||
|
})
|
||
|
.on('disconnect', function () {
|
||
|
Cryptpad.warn("Disconnected!");
|
||
|
});
|
||
|
});
|
||
|
});
|