|
|
|
// bg #e7e7e7
|
|
|
|
// blue #0087FF
|
|
|
|
// text #3F4141
|
|
|
|
define(['/customize/messages.js'], function (Messages) {
|
|
|
|
var loadingStyle = (function(){/*
|
|
|
|
@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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#cp-loading {
|
|
|
|
visibility: visible;
|
|
|
|
position: fixed;
|
|
|
|
z-index: 10000000;
|
|
|
|
top: 0px;
|
|
|
|
bottom: 0px;
|
|
|
|
left: 0px;
|
|
|
|
right: 0px;
|
|
|
|
background-color: #e7e7e7;
|
|
|
|
color: #3F4141;
|
|
|
|
font-size: 1.3em;
|
|
|
|
line-height: 120%;
|
|
|
|
opacity: 1;
|
|
|
|
display: flex;
|
|
|
|
flex-flow: column;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
font: 20px 'Open Sans', 'Helvetica Neue', sans-serif !important;
|
|
|
|
}
|
|
|
|
#cp-loading.cp-loading-transparent {
|
|
|
|
background-color: rgba(231, 231, 231, 0.7);
|
|
|
|
}
|
|
|
|
#cp-loading.cp-loading-hidden {
|
|
|
|
opacity: 0;
|
|
|
|
visibility: hidden;
|
|
|
|
transition: opacity 0.75s, visibility 0s 0.75s;
|
|
|
|
}
|
|
|
|
#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: 236px;
|
|
|
|
max-height: calc(100vh - 20px);
|
|
|
|
margin: 50px;
|
|
|
|
flex-shrink: 0;
|
|
|
|
display: flex;
|
|
|
|
flex-flow: column;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
#cp-loading .cp-loading-cryptofist {
|
|
|
|
margin-left: auto;
|
|
|
|
margin-right: auto;
|
|
|
|
max-width: 90vw;
|
|
|
|
max-height: 300px;
|
|
|
|
width: auto;
|
|
|
|
height: auto;
|
|
|
|
margin-bottom: 2em;
|
|
|
|
}
|
|
|
|
@media screen and (max-width: 500px) {
|
|
|
|
#cp-loading {
|
|
|
|
font-size: 16px !important;
|
|
|
|
}
|
|
|
|
#cp-loading .cp-loading-container {
|
|
|
|
height: 206px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@media screen and (max-height: 700px) {
|
|
|
|
#cp-loading {
|
|
|
|
font-size: 16px !important;
|
|
|
|
}
|
|
|
|
#cp-loading .cp-loading-container {
|
|
|
|
height: 206px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@media screen and (max-height: 500px) {
|
|
|
|
#cp-loading .cp-loading-logo {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#cp-loading-message {
|
|
|
|
background: #FFF;
|
|
|
|
padding: 20px;
|
|
|
|
width: 100%;
|
|
|
|
color: #3F4141;
|
|
|
|
text-align: left;
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
#cp-loading-password-prompt p.cp-password-error {
|
|
|
|
color: white;
|
|
|
|
background: #9e0000;
|
|
|
|
padding: 5px;
|
|
|
|
margin-bottom: 15px;
|
|
|
|
}
|
|
|
|
#cp-loading-password-prompt .cp-password-info {
|
|
|
|
text-align: left;
|
|
|
|
margin-bottom: 15px;
|
|
|
|
}
|
|
|
|
#cp-loading-burn-after-reading .cp-password-info {
|
|
|
|
margin-bottom: 15px;
|
|
|
|
}
|
|
|
|
|
|
|
|
p.cp-password-info{
|
|
|
|
text-align: left;
|
|
|
|
}
|
|
|
|
#cp-loading-password-prompt .cp-password-form {
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
}
|
|
|
|
#cp-loading-password-prompt .cp-password-form button{
|
|
|
|
background-color: #4591c4;
|
|
|
|
color: white;
|
|
|
|
border: 1px solid #4591c4;
|
|
|
|
}
|
|
|
|
|
|
|
|
.cp-password-input{
|
|
|
|
font-size:16px;
|
|
|
|
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%;
|
|
|
|
}
|
|
|
|
|
|
|
|
#cp-loading-password-prompt .cp-password-form .cp-password-container {
|
|
|
|
flex-shrink: 1;
|
|
|
|
min-width: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#cp-loading-password-prompt .cp-password-form .cp-password-container .cp-password-reveal{
|
|
|
|
color: #4591c4;
|
|
|
|
padding: 0px 24px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#cp-loading-password-prompt .cp-password-form input {
|
|
|
|
flex: 1;
|
|
|
|
padding: 12px;
|
|
|
|
min-width: 0;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
#cp-loading-password-prompt .cp-password-form button:hover {
|
|
|
|
background-color: #326599;
|
|
|
|
}
|
|
|
|
#cp-loading-password-prompt ::placeholder {
|
|
|
|
color: #999999;
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
#cp-loading-password-prompt :-ms-input-placeholder {
|
|
|
|
color: #d9d9d9;
|
|
|
|
}
|
|
|
|
#cp-loading-password-prompt ::-ms-input-placeholder {
|
|
|
|
color: #d9d9d9;
|
|
|
|
}
|
|
|
|
#cp-loading .cp-loading-spinner-container {
|
|
|
|
position: relative;
|
|
|
|
height: 80px;
|
|
|
|
margin-bottom: 50px;
|
|
|
|
}
|
|
|
|
.cp-loading-progress {
|
|
|
|
width: 100%;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
.cp-loading-progress p {
|
|
|
|
margin: 5px;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
.cp-loading-progress-list {
|
|
|
|
text-align: left;
|
|
|
|
display: inline-block;
|
|
|
|
margin-bottom: 50px;
|
|
|
|
max-width: 100%;
|
|
|
|
}
|
|
|
|
.cp-loading-progress-list ul {
|
|
|
|
list-style: none;
|
|
|
|
padding-left: 0;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
.cp-loading-progress-list li {
|
|
|
|
padding: 0px 5px;
|
|
|
|
-webkit-user-select: none;
|
|
|
|
-moz-user-select: none;
|
|
|
|
-ms-user-select: none;
|
|
|
|
user-select: none;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
.cp-loading-progress-list li i {
|
|
|
|
width: 22px;
|
|
|
|
}
|
|
|
|
.cp-loading-progress-list li span{
|
|
|
|
margin-left: 10px;
|
|
|
|
}
|
|
|
|
.cp-loading-progress-list li span.percent {
|
|
|
|
position: absolute;
|
|
|
|
}
|
|
|
|
|
|
|
|
.cp-loading-progress-bar {
|
|
|
|
height: 24px;
|
|
|
|
background: white;
|
|
|
|
border: 1px solid #0087FF;
|
|
|
|
}
|
|
|
|
.cp-loading-progress-bar-value {
|
|
|
|
height: 100%;
|
|
|
|
background: #0087FF;
|
|
|
|
}
|
|
|
|
|
|
|
|
@keyframes spin {
|
|
|
|
from {
|
|
|
|
transform: rotate(0deg);
|
|
|
|
}
|
|
|
|
to {
|
|
|
|
transform: rotate(1800deg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.cp-spinner {
|
|
|
|
display: inline-block;
|
|
|
|
box-sizing: border-box;
|
|
|
|
width: 80px;
|
|
|
|
height: 80px;
|
|
|
|
border: 11px solid #999999;
|
|
|
|
border-radius: 50%;
|
|
|
|
border-top-color: transparent;
|
|
|
|
animation: spin infinite 3s;
|
|
|
|
animation-timing-function: cubic-bezier(.6,0.15,0.4,0.85);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
*/}).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/CryptPad_logo_grey.svg?' + urlArgs + '">',
|
|
|
|
'</div>',
|
|
|
|
'<div class="cp-loading-container">',
|
|
|
|
'<div class="cp-loading-spinner-container">',
|
|
|
|
'<span class="cp-spinner"></span>',
|
|
|
|
'</div>',
|
|
|
|
'<div class="cp-loading-progress">',
|
|
|
|
'<div class="cp-loading-progress-list"></div>',
|
|
|
|
'<div class="cp-loading-progress-container"></div>',
|
|
|
|
'</div>',
|
|
|
|
'<p id="cp-loading-message"></p>',
|
|
|
|
'</div>'
|
|
|
|
].join('');
|
|
|
|
var built = false;
|
|
|
|
|
|
|
|
// XXX
|
|
|
|
var types = ['less', 'drive', 'migrate', 'sf', 'team', 'pad', 'end'];
|
|
|
|
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';
|
|
|
|
var percentStr = '';
|
|
|
|
if (i === c) {
|
|
|
|
var p = Math.min(Math.floor(data.progress), 100);
|
|
|
|
percentStr = '<span class="percent">('+p+'%)</span>';
|
|
|
|
}
|
|
|
|
return '<li><i class="fa '+check+'"></i><span>'+Messages['loading_state_'+i]+'</span>' + percentStr;
|
|
|
|
};
|
|
|
|
var list = '<ul>';
|
|
|
|
types.forEach(function (el, i) {
|
|
|
|
if (i >= 6) { return; }
|
|
|
|
list += getLi(i);
|
|
|
|
});
|
|
|
|
list += '</ul>';
|
|
|
|
return list;
|
|
|
|
};
|
|
|
|
var makeBar = function (data) {
|
|
|
|
var c = types.indexOf(data.type);
|
|
|
|
var l = types.length;
|
|
|
|
var progress = Math.min(data.progress, 100);
|
|
|
|
var p = (progress / l) + (100 * c / l);
|
|
|
|
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) {
|
|
|
|
if (!built) { return; }
|
|
|
|
var c = types.indexOf(data.type);
|
|
|
|
if (c < current) { return console.error(data); }
|
|
|
|
try {
|
|
|
|
document.querySelector('.cp-loading-spinner-container').style.display = 'none';
|
|
|
|
document.querySelector('.cp-loading-progress-list').innerHTML = makeList(data);
|
|
|
|
document.querySelector('.cp-loading-progress-container').innerHTML = makeBar(data);
|
|
|
|
} catch (e) { console.error(e); }
|
|
|
|
};
|
|
|
|
window.CryptPad_updateLoadingProgress = updateLoadingProgress;
|
|
|
|
window.CryptPad_loadingError = function (err) {
|
|
|
|
if (!built) { return; }
|
|
|
|
try {
|
|
|
|
var node = document.querySelector('.cp-loading-progress');
|
|
|
|
if (node.parentNode) { node.parentNode.removeChild(node); }
|
|
|
|
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;
|
|
|
|
} catch (e) { console.error(e); }
|
|
|
|
};
|
|
|
|
return function () {
|
|
|
|
built = true;
|
|
|
|
var intr;
|
|
|
|
var append = function () {
|
|
|
|
if (!document.body) { return; }
|
|
|
|
clearInterval(intr);
|
|
|
|
document.body.appendChild(elem);
|
|
|
|
};
|
|
|
|
intr = setInterval(append, 100);
|
|
|
|
append();
|
|
|
|
};
|
|
|
|
});
|