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.
cryptpad/www/examples/pin/main.js

54 lines
1.7 KiB
JavaScript

8 years ago
require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } });
define([
'/common/cryptpad-common.js',
'/common/pinpad.js',
'/bower_components/jquery/dist/jquery.min.js',
], function (Cryptpad, Pinpad) {
var $ = window.jQuery;
var APP = window.APP = {
Cryptpad: Cryptpad,
};
var synchronize = function (call) {
// provide a sorted list of unique channels
var list = Cryptpad.deduplicateString(Cryptpad.getUserChannelList())
.sort();
var localHash = call.hashChannelList(list);
var serverHash;
call.getFileListSize(function (e, bytes) {
if (e) { return void console.error(e); }
console.log("total %sK bytes used", bytes / 1000);
});
call.getServerHash(function (e, hash) {
if (e) { return void console.error(e); }
serverHash = hash;
if (serverHash === localHash) {
return console.log("all your pads are pinned. There is nothing to do");
}
call.reset(list, function (e, response) {
if (e) { return console.error(e); }
else {
return console.log('reset pin list. new hash is [%s]', response);
}
});
});
};
8 years ago
$(function () {
Cryptpad.ready(function (err, env) {
var network = Cryptpad.getNetwork();
var proxy = Cryptpad.getStore().getProxy().proxy;
Pinpad.create(network, proxy, function (e, call) {
8 years ago
if (e) { return void console.error(e); }
synchronize(call);
8 years ago
});
});
});
});