2016-07-04 21:21:23 +08:00
|
|
|
define([
|
2016-07-12 21:53:58 +08:00
|
|
|
'/customize/messages.js',
|
2016-09-13 17:01:10 +08:00
|
|
|
'/customize/application_config.js',
|
2016-07-04 21:21:23 +08:00
|
|
|
'/common/cryptpad-common.js',
|
|
|
|
'/bower_components/lil-uri/uri.min.js',
|
2016-12-30 22:33:28 +08:00
|
|
|
'/customize/languageSelector.js',
|
2016-07-06 21:14:41 +08:00
|
|
|
'/bower_components/jquery/dist/jquery.min.js',
|
2016-12-30 22:33:28 +08:00
|
|
|
], function (Messages, Config, Cryptpad, LilUri, LS) {
|
2017-02-01 00:29:32 +08:00
|
|
|
if (Cryptpad.isLoggedIn()) {
|
|
|
|
document.location.href = '/drive';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-04 21:21:23 +08:00
|
|
|
var $ = window.$;
|
2016-07-11 17:07:59 +08:00
|
|
|
|
2017-01-03 19:17:17 +08:00
|
|
|
var USE_TABLE = Config.USE_HOMEPAGE_TABLE;
|
|
|
|
var USE_FS_STORE = Config.USE_FS_STORE;
|
|
|
|
|
2016-08-31 00:15:43 +08:00
|
|
|
var APP = window.APP = {
|
|
|
|
Cryptpad: Cryptpad,
|
|
|
|
};
|
|
|
|
|
2017-01-31 19:43:28 +08:00
|
|
|
// main block is hidden in case javascript is disabled
|
|
|
|
$('#mainBlock').removeClass('hidden');
|
|
|
|
|
2016-07-04 21:21:23 +08:00
|
|
|
var padTypes = {
|
2016-09-16 00:35:09 +08:00
|
|
|
'/pad/': Messages.type.pad,
|
|
|
|
'/code/': Messages.type.code,
|
|
|
|
'/poll/': Messages.type.poll,
|
|
|
|
'/slide/': Messages.type.slide,
|
2016-07-04 21:21:23 +08:00
|
|
|
};
|
|
|
|
|
2016-08-31 00:15:43 +08:00
|
|
|
var now = new Date();
|
|
|
|
var hasRecent = false;
|
2016-07-04 21:21:23 +08:00
|
|
|
|
2016-09-13 17:01:10 +08:00
|
|
|
var displayCreateButtons = function () {
|
2016-11-07 18:43:49 +08:00
|
|
|
var $parent = $('#buttons');
|
2016-09-13 17:01:10 +08:00
|
|
|
Config.availablePadTypes.forEach(function (el) {
|
2017-02-01 00:29:32 +08:00
|
|
|
$('#create-' + el).attr('target', '_blank').show();
|
2016-09-13 17:01:10 +08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-01-11 17:46:22 +08:00
|
|
|
// Language selector
|
2016-12-30 22:33:28 +08:00
|
|
|
var $sel = $('#language-selector');
|
2017-01-13 01:28:38 +08:00
|
|
|
Cryptpad.createLanguageSelector(undefined, $sel);
|
2017-01-18 01:19:45 +08:00
|
|
|
$sel.find('button').addClass('btn').addClass('btn-secondary');
|
2016-12-30 22:33:28 +08:00
|
|
|
$sel.show();
|
2017-01-13 01:28:38 +08:00
|
|
|
|
2017-01-11 17:46:22 +08:00
|
|
|
$(window).click(function () {
|
2017-01-13 01:28:38 +08:00
|
|
|
$sel.find('.cryptpad-dropdown').hide();
|
2017-01-11 17:46:22 +08:00
|
|
|
});
|
2016-12-30 22:33:28 +08:00
|
|
|
|
2017-01-17 18:52:44 +08:00
|
|
|
var addButtonHandlers = function () {
|
|
|
|
$('button.login').click(function (e) {
|
|
|
|
var username = $('#name').val();
|
|
|
|
var passwd = $('#password').val();
|
|
|
|
var remember = $('#rememberme').is(':checked');
|
|
|
|
sessionStorage.login_user = username;
|
|
|
|
sessionStorage.login_pass = passwd;
|
|
|
|
sessionStorage.login_rmb = remember;
|
|
|
|
sessionStorage.login = 1;
|
|
|
|
document.location.href = '/user';
|
|
|
|
});
|
|
|
|
$('button.register').click(function (e) {
|
|
|
|
var username = $('#name').val();
|
|
|
|
var passwd = $('#password').val();
|
|
|
|
var remember = $('#rememberme').is(':checked');
|
|
|
|
sessionStorage.login_user = username;
|
|
|
|
sessionStorage.login_pass = passwd;
|
|
|
|
sessionStorage.login_rmb = remember;
|
|
|
|
sessionStorage.register = 1;
|
|
|
|
document.location.href = '/user';
|
|
|
|
});
|
|
|
|
$('button.nologin').click(function (e) {
|
|
|
|
document.location.href = '/drive';
|
|
|
|
});
|
2017-01-19 01:02:32 +08:00
|
|
|
$('button.knowmore').click(function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
$('html, body').animate({
|
|
|
|
scrollTop: $('#knowmore').offset().top
|
|
|
|
}, 500);
|
|
|
|
});
|
|
|
|
$('button.tryit').click(function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
$('html, body').animate({
|
|
|
|
scrollTop: $('#tryit').offset().top
|
|
|
|
}, 500);
|
|
|
|
});
|
2017-02-01 00:29:32 +08:00
|
|
|
|
|
|
|
var $passwd = $('#password');
|
|
|
|
$passwd.on('keyup', function (e) {
|
|
|
|
if (e.which !== 13) { return; } // enter
|
|
|
|
$('button.login').click();
|
|
|
|
});
|
2017-01-17 18:52:44 +08:00
|
|
|
};
|
|
|
|
|
2016-12-22 18:02:12 +08:00
|
|
|
displayCreateButtons();
|
2016-08-31 00:15:43 +08:00
|
|
|
|
2017-02-01 00:29:32 +08:00
|
|
|
addButtonHandlers();
|
|
|
|
console.log("ready");
|
2016-07-04 21:21:23 +08:00
|
|
|
});
|
|
|
|
|