2018-04-19 20:21:26 +08:00
|
|
|
// dark #326599
|
|
|
|
// light #4591c4
|
2020-10-14 21:20:56 +08:00
|
|
|
define(['/customize/messages.js'], function (Messages) {
|
2018-04-19 20:21:26 +08:00
|
|
|
var loadingStyle = (function(){/*
|
2020-10-14 23:32:15 +08:00
|
|
|
@font-face {
|
|
|
|
font-family: 'Open Sans';
|
|
|
|
src: url('/bower_components/open-sans-fontface/fonts/Regular/OpenSans-Regular.eot');
|
|
|
|
src: url('/bower_components/open-sans-fontface/fonts/Regular/OpenSans-Regular.eot?#iefix') format('embedded-opentype'),
|
|
|
|
url('/bower_components/open-sans-fontface/fonts/Regular/OpenSans-Regular.woff') format('woff'),
|
|
|
|
url('/bower_components/open-sans-fontface/fonts/Regular/OpenSans-Regular.ttf') format('truetype'),
|
|
|
|
url('/bower_components/open-sans-fontface/fonts/Regular/OpenSans-Regular.svg#OpenSansRegular') format('svg');
|
|
|
|
font-weight: normal;
|
|
|
|
font-style: normal;
|
|
|
|
}
|
|
|
|
|
2018-04-19 20:21:26 +08:00
|
|
|
#cp-loading {
|
|
|
|
visibility: visible;
|
|
|
|
position: fixed;
|
|
|
|
z-index: 10000000;
|
|
|
|
top: 0px;
|
|
|
|
bottom: 0px;
|
|
|
|
left: 0px;
|
|
|
|
right: 0px;
|
|
|
|
background: linear-gradient(to right, #326599 0%, #326599 50%, #4591c4 50%, #4591c4 100%);
|
|
|
|
color: #fafafa;
|
2020-01-13 18:53:48 +08:00
|
|
|
font-size: 1.3em;
|
|
|
|
line-height: 120%;
|
2018-04-19 20:21:26 +08:00
|
|
|
opacity: 1;
|
|
|
|
display: flex;
|
|
|
|
flex-flow: column;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
2020-10-14 23:32:15 +08:00
|
|
|
font: 20px 'Open Sans', 'Helvetica Neue', sans-serif !important;
|
2018-04-19 20:21:26 +08:00
|
|
|
}
|
|
|
|
#cp-loading.cp-loading-hidden {
|
|
|
|
opacity: 0;
|
|
|
|
visibility: hidden;
|
2020-02-11 21:03:06 +08:00
|
|
|
transition: opacity 0.75s, visibility 0s 0.75s;
|
2018-04-19 20:21:26 +08:00
|
|
|
}
|
|
|
|
#cp-loading .cp-loading-logo {
|
|
|
|
height: 300px;
|
|
|
|
width: 300px;
|
|
|
|
margin-top: 50px;
|
|
|
|
flex: 0 1 auto;
|
|
|
|
min-height: 0;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
#cp-loading .cp-loading-logo img {
|
|
|
|
max-width: 100%;
|
|
|
|
max-height: 100%;
|
|
|
|
}
|
|
|
|
#cp-loading .cp-loading-container {
|
|
|
|
width: 700px;
|
|
|
|
max-width: 90vw;
|
|
|
|
height: 500px;
|
|
|
|
max-height: calc(100vh - 20px);
|
|
|
|
margin: 50px;
|
|
|
|
flex-shrink: 0;
|
|
|
|
display: flex;
|
|
|
|
flex-flow: column;
|
2018-05-24 22:09:33 +08:00
|
|
|
justify-content: space-around;
|
2018-04-19 20:21:26 +08:00
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
@media screen and (max-height: 800px) {
|
|
|
|
#cp-loading .cp-loading-container {
|
|
|
|
height: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@media screen and (max-width: 600px) {
|
|
|
|
#cp-loading .cp-loading-container {
|
|
|
|
height: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#cp-loading .cp-loading-cryptofist {
|
|
|
|
margin-left: auto;
|
|
|
|
margin-right: auto;
|
|
|
|
//height: 300px;
|
|
|
|
max-width: 90vw;
|
|
|
|
max-height: 300px;
|
|
|
|
width: auto;
|
|
|
|
height: auto;
|
|
|
|
margin-bottom: 2em;
|
|
|
|
}
|
2018-05-14 20:02:46 +08:00
|
|
|
@media screen and (max-height: 500px) {
|
|
|
|
#cp-loading .cp-loading-logo {
|
|
|
|
display: none;
|
2018-04-19 20:21:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#cp-loading-message {
|
|
|
|
background: #FFF;
|
|
|
|
padding: 20px;
|
|
|
|
width: 100%;
|
2020-01-10 21:07:52 +08:00
|
|
|
color: #3F4141;
|
2020-01-13 18:53:48 +08:00
|
|
|
text-align: left;
|
2018-04-19 20:21:26 +08:00
|
|
|
display: none;
|
|
|
|
}
|
2020-01-13 18:53:48 +08:00
|
|
|
|
2020-01-14 00:29:09 +08:00
|
|
|
#cp-loading-password-prompt p.cp-password-error {
|
2018-04-26 01:03:58 +08:00
|
|
|
color: white;
|
|
|
|
background: #9e0000;
|
|
|
|
padding: 5px;
|
|
|
|
margin-bottom: 15px;
|
|
|
|
}
|
|
|
|
#cp-loading-password-prompt .cp-password-info {
|
|
|
|
text-align: left;
|
|
|
|
margin-bottom: 15px;
|
|
|
|
}
|
2020-01-14 00:29:09 +08:00
|
|
|
#cp-loading-burn-after-reading .cp-password-info {
|
|
|
|
margin-bottom: 15px;
|
|
|
|
}
|
|
|
|
|
2020-01-10 21:07:52 +08:00
|
|
|
p.cp-password-info{
|
|
|
|
text-align: left;
|
|
|
|
}
|
2018-04-26 01:03:58 +08:00
|
|
|
#cp-loading-password-prompt .cp-password-form {
|
|
|
|
display: flex;
|
2018-05-04 21:42:29 +08:00
|
|
|
flex-wrap: wrap;
|
2018-04-26 01:03:58 +08:00
|
|
|
}
|
2020-01-13 18:53:48 +08:00
|
|
|
#cp-loading-password-prompt .cp-password-form button{
|
2018-04-26 01:03:58 +08:00
|
|
|
background-color: #4591c4;
|
|
|
|
color: white;
|
|
|
|
border: 1px solid #4591c4;
|
|
|
|
}
|
2020-01-13 18:53:48 +08:00
|
|
|
|
|
|
|
.cp-password-input{
|
2020-01-13 20:05:41 +08:00
|
|
|
font-size:16px;
|
2020-01-13 18:53:48 +08:00
|
|
|
border: 1px solid #4591c4;
|
|
|
|
background-color: white;
|
|
|
|
border-radius 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.cp-password-form button{
|
|
|
|
padding: 8px 12px;
|
|
|
|
font-weight: bold;
|
|
|
|
text-transform: uppercase;
|
|
|
|
}
|
|
|
|
|
|
|
|
#cp-loading-password-prompt .cp-password-form{
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
2018-05-04 21:42:29 +08:00
|
|
|
#cp-loading-password-prompt .cp-password-form .cp-password-container {
|
|
|
|
flex-shrink: 1;
|
|
|
|
min-width: 0;
|
|
|
|
}
|
2020-01-13 18:53:48 +08:00
|
|
|
|
|
|
|
#cp-loading-password-prompt .cp-password-form .cp-password-container .cp-password-reveal{
|
|
|
|
color: #4591c4;
|
|
|
|
padding: 0px 24px;
|
|
|
|
}
|
|
|
|
|
2018-04-26 01:03:58 +08:00
|
|
|
#cp-loading-password-prompt .cp-password-form input {
|
|
|
|
flex: 1;
|
2020-01-13 18:53:48 +08:00
|
|
|
padding: 12px;
|
2018-04-26 01:03:58 +08:00
|
|
|
min-width: 0;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
#cp-loading-password-prompt .cp-password-form button:hover {
|
|
|
|
background-color: #326599;
|
|
|
|
}
|
2019-10-21 23:12:36 +08:00
|
|
|
#cp-loading-password-prompt ::placeholder {
|
2020-01-13 18:53:48 +08:00
|
|
|
color: #999999;
|
2019-10-21 23:12:36 +08:00
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
#cp-loading-password-prompt :-ms-input-placeholder {
|
|
|
|
color: #d9d9d9;
|
|
|
|
}
|
|
|
|
#cp-loading-password-prompt ::-ms-input-placeholder {
|
|
|
|
color: #d9d9d9;
|
|
|
|
}
|
2018-04-19 20:21:26 +08:00
|
|
|
#cp-loading .cp-loading-spinner-container {
|
|
|
|
position: relative;
|
|
|
|
height: 100px;
|
|
|
|
}
|
|
|
|
#cp-loading .cp-loading-spinner-container > div {
|
|
|
|
height: 100px;
|
|
|
|
}
|
|
|
|
#cp-loading-tip {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 10000000;
|
|
|
|
top: 80%;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
text-align: center;
|
|
|
|
transition: opacity 750ms;
|
|
|
|
transition-delay: 3000ms;
|
|
|
|
}
|
|
|
|
@media screen and (max-height: 600px) {
|
|
|
|
#cp-loading-tip {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#cp-loading-tip span {
|
|
|
|
background: #222;
|
|
|
|
color: #fafafa;
|
|
|
|
text-align: center;
|
2020-01-13 18:53:48 +08:00
|
|
|
font-size: 1.3em;
|
2018-04-19 20:21:26 +08:00
|
|
|
opacity: 0.7;
|
|
|
|
font-family: 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
|
|
padding: 15px;
|
|
|
|
max-width: 60%;
|
|
|
|
display: inline-block;
|
|
|
|
}
|
2018-05-05 00:41:54 +08:00
|
|
|
.cp-loading-progress {
|
|
|
|
width: 100%;
|
|
|
|
margin: 20px;
|
|
|
|
}
|
|
|
|
.cp-loading-progress p {
|
|
|
|
margin: 5px;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
2020-10-14 23:32:15 +08:00
|
|
|
.cp-loading-progress-list ul {
|
|
|
|
list-style: none;
|
|
|
|
padding-left: 0;
|
|
|
|
}
|
|
|
|
.cp-loading-progress-list li {
|
|
|
|
padding: 0px 5px;
|
|
|
|
-webkit-user-select: none;
|
|
|
|
-moz-user-select: none;
|
|
|
|
-ms-user-select: none;
|
|
|
|
user-select: none;
|
|
|
|
}
|
2020-10-14 21:20:56 +08:00
|
|
|
.cp-loading-progress-list li i {
|
|
|
|
width: 22px;
|
|
|
|
}
|
|
|
|
.cp-loading-progress-list li span{
|
|
|
|
margin-left: 20px;
|
|
|
|
}
|
|
|
|
|
2018-05-05 00:41:54 +08:00
|
|
|
.cp-loading-progress-bar {
|
2018-05-14 20:02:46 +08:00
|
|
|
height: 24px;
|
2018-05-05 00:41:54 +08:00
|
|
|
background: white;
|
|
|
|
}
|
|
|
|
.cp-loading-progress-bar-value {
|
|
|
|
height: 100%;
|
2018-05-14 20:02:46 +08:00
|
|
|
background: #5cb85c;
|
2018-05-05 00:41:54 +08:00
|
|
|
}
|
2019-07-25 21:55:20 +08:00
|
|
|
|
|
|
|
@keyframes spin {
|
|
|
|
from {
|
|
|
|
transform: rotate(0deg);
|
|
|
|
}
|
|
|
|
to {
|
|
|
|
transform: rotate(1800deg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.cp-spinner {
|
|
|
|
display: inline-block;
|
|
|
|
box-sizing: border-box;
|
|
|
|
width: 80px;
|
|
|
|
height: 80px;
|
2019-08-19 23:32:37 +08:00
|
|
|
border: 11px solid white;
|
2019-07-25 21:55:20 +08:00
|
|
|
border-radius: 50%;
|
|
|
|
border-top-color: transparent;
|
|
|
|
animation: spin infinite 3s;
|
|
|
|
animation-timing-function: cubic-bezier(.6,0.15,0.4,0.85);
|
|
|
|
}
|
|
|
|
|
2020-01-10 21:07:52 +08:00
|
|
|
button.primary{
|
|
|
|
border: 1px solid #4591c4;
|
|
|
|
padding: 8px 12px;
|
|
|
|
text-transform: uppercase;
|
|
|
|
background-color: #4591c4;
|
|
|
|
color: white;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
button.primary:hover{
|
|
|
|
background-color: rgb(52, 118, 162);
|
|
|
|
}
|
|
|
|
|
2018-04-19 20:21:26 +08:00
|
|
|
*/}).toString().slice(14, -3);
|
|
|
|
var urlArgs = window.location.href.replace(/^.*\?([^\?]*)$/, function (all, x) { return x; });
|
|
|
|
var elem = document.createElement('div');
|
|
|
|
elem.setAttribute('id', 'cp-loading');
|
|
|
|
elem.innerHTML = [
|
|
|
|
'<style>',
|
|
|
|
loadingStyle,
|
|
|
|
'</style>',
|
|
|
|
'<div class="cp-loading-logo">',
|
|
|
|
'<img class="cp-loading-cryptofist" src="/customize/loading-logo.png?' + urlArgs + '">',
|
|
|
|
'</div>',
|
|
|
|
'<div class="cp-loading-container">',
|
|
|
|
'<div class="cp-loading-spinner-container">',
|
2019-07-25 21:55:20 +08:00
|
|
|
'<span class="cp-spinner"></span>',
|
2018-04-19 20:21:26 +08:00
|
|
|
'</div>',
|
2020-10-14 21:20:56 +08:00
|
|
|
'<div class="cp-loading-progress">',
|
|
|
|
'<div class="cp-loading-progress-list"></div>',
|
|
|
|
'<div class="cp-loading-progress-container"></div>',
|
|
|
|
'</div>',
|
2018-04-19 20:21:26 +08:00
|
|
|
'<p id="cp-loading-message"></p>',
|
|
|
|
'</div>'
|
|
|
|
].join('');
|
2020-10-14 21:20:56 +08:00
|
|
|
|
|
|
|
// XXX
|
|
|
|
var types = ['less', 'drive', 'migrate', 'sf', 'team', 'pad'];
|
|
|
|
Messages.loading_state_0 = "Less";
|
|
|
|
Messages.loading_state_1 = "Drive";
|
|
|
|
Messages.loading_state_2 = "Migrate";
|
|
|
|
Messages.loading_state_3 = "SF";
|
|
|
|
Messages.loading_state_4 = "Team";
|
|
|
|
Messages.loading_state_5 = "Pad";
|
|
|
|
var current;
|
|
|
|
var makeList = function (data) {
|
|
|
|
var c = types.indexOf(data.type);
|
|
|
|
current = c;
|
|
|
|
var getLi = function (i) {
|
|
|
|
var check = (i < c || (i === c && data.progress === 100)) ? 'fa-check-square-o'
|
|
|
|
: 'fa-square-o';
|
2020-10-14 23:53:13 +08:00
|
|
|
var p = Math.min(Math.floor(data.progress), 100);
|
|
|
|
var percent = i < c ? '(100%)' : (i === c ? '('+p+'%)' : '(0%)');
|
2020-10-14 21:20:56 +08:00
|
|
|
return '<li><i class="fa '+check+'"></i><span>'+Messages['loading_state_'+i]+'</span>' +
|
|
|
|
'<span>'+percent+'</span>';
|
|
|
|
};
|
|
|
|
var list = '<ul>';
|
|
|
|
types.forEach(function (el, i) {
|
|
|
|
list += getLi(i);
|
|
|
|
});
|
|
|
|
list += '</ul>';
|
|
|
|
return list;
|
|
|
|
};
|
|
|
|
var makeBar = function (data) {
|
|
|
|
var c = types.indexOf(data.type);
|
|
|
|
var l = types.length;
|
2020-10-14 23:53:13 +08:00
|
|
|
var progress = Math.min(data.progress, 100);
|
|
|
|
var p = (progress / l) + (100 * c / l);
|
2020-10-14 21:20:56 +08:00
|
|
|
var bar = '<div class="cp-loading-progress-bar">'+
|
|
|
|
'<div class="cp-loading-progress-bar-value" style="width:'+p+'%"></div>'+
|
|
|
|
'</div>';
|
|
|
|
return bar;
|
|
|
|
};
|
|
|
|
|
|
|
|
var updateLoadingProgress = function (data) {
|
|
|
|
var c = types.indexOf(data.type);
|
|
|
|
if (c < current) { return console.error(data); }
|
|
|
|
document.querySelector('.cp-loading-progress-list').innerHTML = makeList(data);
|
|
|
|
document.querySelector('.cp-loading-progress-container').innerHTML = makeBar(data);
|
|
|
|
};
|
|
|
|
window.CryptPad_updateLoadingProgress = updateLoadingProgress;
|
2020-10-09 22:10:39 +08:00
|
|
|
window.CryptPad_loadingError = function (err) {
|
|
|
|
document.querySelector('.cp-loading-spinner-container').setAttribute('style', 'display:none;');
|
|
|
|
document.querySelector('#cp-loading-message').setAttribute('style', 'display:block;');
|
|
|
|
document.querySelector('#cp-loading-message').innerText = err;
|
|
|
|
};
|
2018-04-19 20:21:26 +08:00
|
|
|
return function () {
|
|
|
|
var intr;
|
|
|
|
var append = function () {
|
|
|
|
if (!document.body) { return; }
|
|
|
|
clearInterval(intr);
|
|
|
|
document.body.appendChild(elem);
|
|
|
|
};
|
|
|
|
intr = setInterval(append, 100);
|
|
|
|
append();
|
|
|
|
};
|
|
|
|
});
|