Enable drag & upload in code2 and prepare filepicker
This commit is contained in:
30
www/filepicker/index.html
Normal file
30
www/filepicker/index.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CryptPad</title>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="referrer" content="no-referrer" />
|
||||
<script async data-bootload="main.js" data-main="/common/boot.js?ver=1.0" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
#sbox-iframe {
|
||||
position:fixed;
|
||||
top:0px;
|
||||
left:0px;
|
||||
bottom:0px;
|
||||
right:0px;
|
||||
width:100%;
|
||||
height:100%;
|
||||
border:none;
|
||||
margin:0;
|
||||
padding:0;
|
||||
overflow:hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="sbox-iframe">
|
||||
11
www/filepicker/inner.html
Normal file
11
www/filepicker/inner.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html style="height: 100%;">
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||
<script async data-bootload="/filepicker/inner.js" data-main="/common/sframe-boot.js?ver=1.1" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
||||
<style> .loading-hidden { display: none; } </style>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
63
www/filepicker/inner.js
Normal file
63
www/filepicker/inner.js
Normal file
@@ -0,0 +1,63 @@
|
||||
define([
|
||||
'jquery',
|
||||
'/bower_components/chainpad-crypto/crypto.js',
|
||||
'/bower_components/textpatcher/TextPatcher.js',
|
||||
'/bower_components/chainpad-json-validator/json-ot.js',
|
||||
'/common/cryptpad-common.js',
|
||||
'/bower_components/nthen/index.js',
|
||||
'/common/sframe-common.js',
|
||||
|
||||
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
|
||||
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
||||
'less!/customize/src/less/cryptpad.less',
|
||||
'less!/customize/src/less/toolbar.less',
|
||||
'less!/common/file-dialog.less',
|
||||
], function (
|
||||
$,
|
||||
Crypto,
|
||||
TextPatcher,
|
||||
JsonOT,
|
||||
Cryptpad,
|
||||
nThen,
|
||||
SFCommon)
|
||||
{
|
||||
var Messages = Cryptpad.Messages;
|
||||
|
||||
var APP = window.APP = {
|
||||
Cryptpad: Cryptpad,
|
||||
};
|
||||
|
||||
var onConnectError = function () {
|
||||
Cryptpad.errorLoadingScreen(Messages.websocketError);
|
||||
};
|
||||
|
||||
var andThen = function (common) {
|
||||
//var metadataMgr = common.getMetadataMgr();
|
||||
var $body = $('body');
|
||||
var cfg = {
|
||||
$body: $body,
|
||||
common: common
|
||||
};
|
||||
common.createFileDialog(cfg);
|
||||
Cryptpad.removeLoadingScreen();
|
||||
};
|
||||
|
||||
var main = function () {
|
||||
var common;
|
||||
|
||||
nThen(function (waitFor) {
|
||||
$(waitFor(function () {
|
||||
Cryptpad.addLoadingScreen();
|
||||
}));
|
||||
SFCommon.create(waitFor(function (c) { APP.common = common = c; }));
|
||||
}).nThen(function (/*waitFor*/) {
|
||||
Cryptpad.onError(function (info) {
|
||||
if (info && info.type === "store") {
|
||||
onConnectError();
|
||||
}
|
||||
});
|
||||
andThen(common);
|
||||
});
|
||||
};
|
||||
main();
|
||||
});
|
||||
129
www/filepicker/main.js
Normal file
129
www/filepicker/main.js
Normal file
@@ -0,0 +1,129 @@
|
||||
// Load #1, load as little as possible because we are in a race to get the loading screen up.
|
||||
define([
|
||||
'/bower_components/nthen/index.js',
|
||||
'/api/config',
|
||||
'jquery',
|
||||
'/common/requireconfig.js',
|
||||
], function (nThen, ApiConfig, $, RequireConfig) {
|
||||
var requireConfig = RequireConfig();
|
||||
|
||||
// Loaded in load #2
|
||||
nThen(function (waitFor) {
|
||||
$(waitFor());
|
||||
}).nThen(function (waitFor) {
|
||||
var req = {
|
||||
cfg: requireConfig,
|
||||
req: [ '/common/loading.js' ],
|
||||
pfx: window.location.origin
|
||||
};
|
||||
window.rc = requireConfig;
|
||||
window.apiconf = ApiConfig;
|
||||
$('#sbox-iframe').attr('src',
|
||||
ApiConfig.httpSafeOrigin + '/filepicker/inner.html?' + requireConfig.urlArgs +
|
||||
'#' + encodeURIComponent(JSON.stringify(req)));
|
||||
|
||||
// This is a cheap trick to avoid loading sframe-channel in parallel with the
|
||||
// loading screen setup.
|
||||
var done = waitFor();
|
||||
var onMsg = function (msg) {
|
||||
var data = JSON.parse(msg.data);
|
||||
if (data.q !== 'READY') { return; }
|
||||
window.removeEventListener('message', onMsg);
|
||||
var _done = done;
|
||||
done = function () { };
|
||||
_done();
|
||||
};
|
||||
window.addEventListener('message', onMsg);
|
||||
}).nThen(function (/*waitFor*/) {
|
||||
var Cryptpad;
|
||||
var Crypto;
|
||||
var Cryptget;
|
||||
var sframeChan;
|
||||
|
||||
nThen(function (waitFor) {
|
||||
// Load #2, the loading screen is up so grab whatever you need...
|
||||
require([
|
||||
'/common/cryptpad-common.js',
|
||||
'/bower_components/chainpad-crypto/crypto.js',
|
||||
'/common/cryptget.js',
|
||||
'/common/sframe-channel.js',
|
||||
], waitFor(function (_Cryptpad, _Crypto, _Cryptget, SFrameChannel) {
|
||||
Cryptpad = _Cryptpad;
|
||||
Crypto = _Crypto;
|
||||
Cryptget = _Cryptget;
|
||||
SFrameChannel.create($('#sbox-iframe')[0].contentWindow, waitFor(function (sfc) {
|
||||
sframeChan = sfc;
|
||||
}));
|
||||
Cryptpad.ready(waitFor());
|
||||
}));
|
||||
}).nThen(function () {
|
||||
var proxy = Cryptpad.getProxy();
|
||||
var updateMeta = function () {
|
||||
//console.log('EV_METADATA_UPDATE');
|
||||
var name;
|
||||
nThen(function (waitFor) {
|
||||
Cryptpad.getLastName(waitFor(function (err, n) {
|
||||
if (err) { console.log(err); }
|
||||
name = n;
|
||||
}));
|
||||
}).nThen(function (/*waitFor*/) {
|
||||
sframeChan.event('EV_METADATA_UPDATE', {
|
||||
doc: {},
|
||||
user: {
|
||||
name: name,
|
||||
uid: Cryptpad.getUid(),
|
||||
avatar: Cryptpad.getAvatarUrl(),
|
||||
profile: Cryptpad.getProfileUrl(),
|
||||
curvePublic: proxy.curvePublic,
|
||||
netfluxId: Cryptpad.getNetwork().webChannels[0].myID,
|
||||
},
|
||||
priv: {
|
||||
accountName: Cryptpad.getAccountName(),
|
||||
origin: window.location.origin,
|
||||
pathname: window.location.pathname,
|
||||
feedbackAllowed: Cryptpad.isFeedbackAllowed(),
|
||||
friends: proxy.friends || {},
|
||||
settings: proxy.settings || {}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
Cryptpad.onDisplayNameChanged(updateMeta);
|
||||
sframeChan.onReg('EV_METADATA_UPDATE', updateMeta);
|
||||
proxy.on('change', 'settings', updateMeta);
|
||||
|
||||
Cryptpad.onError(function (info) {
|
||||
console.log('error');
|
||||
console.log(info);
|
||||
if (info && info.type === "store") {
|
||||
//onConnectError();
|
||||
}
|
||||
});
|
||||
|
||||
sframeChan.on('Q_ANON_RPC_MESSAGE', function (data, cb) {
|
||||
Cryptpad.anonRpcMsg(data.msg, data.content, function (err, response) {
|
||||
cb({error: err, response: response});
|
||||
});
|
||||
});
|
||||
|
||||
sframeChan.on('Q_GET_PIN_LIMIT_STATUS', function (data, cb) {
|
||||
Cryptpad.isOverPinLimit(function (e, overLimit, limits) {
|
||||
cb({
|
||||
error: e,
|
||||
overLimit: overLimit,
|
||||
limits: limits
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
sframeChan.on('Q_GET_FILES_LIST', function (data, cb) {
|
||||
Cryptpad.getSecureFilesList(function (err, data) {
|
||||
cb({
|
||||
error: err,
|
||||
data: data
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user