2023-10-20 22:35:26 +08:00
|
|
|
|
// SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
|
|
|
|
|
//
|
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
|
2017-12-01 02:17:59 +08:00
|
|
|
|
define([
|
2018-01-23 22:53:00 +08:00
|
|
|
|
'jquery',
|
2017-12-01 18:51:04 +08:00
|
|
|
|
'/api/config',
|
2017-12-01 02:17:59 +08:00
|
|
|
|
'/common/hyperscript.js',
|
2017-12-01 18:51:04 +08:00
|
|
|
|
'/common/outer/local-store.js',
|
|
|
|
|
'/customize/messages.js',
|
2017-12-01 02:17:59 +08:00
|
|
|
|
|
|
|
|
|
'less!/customize/src/less2/pages/page-404.less',
|
2018-01-23 22:53:00 +08:00
|
|
|
|
], function ($, Config, h, LocalStore, Messages) {
|
2017-12-01 18:51:04 +08:00
|
|
|
|
var urlArgs = Config.requireConf.urlArgs;
|
|
|
|
|
var img = h('img#cp-logo', {
|
2020-10-28 19:16:59 +08:00
|
|
|
|
src: '/customize/CryptPad_logo_grey.svg?' + urlArgs
|
2017-12-01 18:51:04 +08:00
|
|
|
|
});
|
|
|
|
|
|
2022-03-22 19:08:42 +08:00
|
|
|
|
var is500 = Boolean(document.querySelector('#five-hundred'));
|
2017-12-01 18:51:04 +08:00
|
|
|
|
var brand = h('h1#cp-brand', 'CryptPad');
|
2022-03-25 19:23:10 +08:00
|
|
|
|
// Msg.fivehundred_internalServerError.four04_pageNotFound
|
2022-03-22 19:08:42 +08:00
|
|
|
|
var message = h('h2#cp-scramble', Messages[is500? 'fivehundred_internalServerError':'four04_pageNotFound']);
|
|
|
|
|
var title = h('h2#cp-title', is500? "500":"404");
|
2017-12-01 18:51:04 +08:00
|
|
|
|
|
|
|
|
|
var loggedIn = LocalStore.isLoggedIn();
|
|
|
|
|
var link = h('a#cp-link', {
|
|
|
|
|
href: loggedIn? '/drive/': '/',
|
2017-12-05 01:31:07 +08:00
|
|
|
|
}, loggedIn? Messages.header_logoTitle: Messages.header_homeTitle);
|
2017-12-01 18:51:04 +08:00
|
|
|
|
|
2018-01-23 22:53:00 +08:00
|
|
|
|
if (Config.httpUnsafeOrigin && Config.httpUnsafeOrigin !== window.location.origin
|
|
|
|
|
&& window.parent) {
|
|
|
|
|
$(link).click(function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
window.parent.location = Config.httpUnsafeOrigin + $(link).attr('href').slice(1);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-01 02:17:59 +08:00
|
|
|
|
var content = h('div#cp-main', [
|
2017-12-01 18:51:04 +08:00
|
|
|
|
img,
|
|
|
|
|
brand,
|
2017-12-01 02:17:59 +08:00
|
|
|
|
title,
|
2017-12-01 18:51:04 +08:00
|
|
|
|
message,
|
|
|
|
|
link,
|
2017-12-01 02:17:59 +08:00
|
|
|
|
]);
|
|
|
|
|
document.body.appendChild(content);
|
|
|
|
|
|
|
|
|
|
var die = function (n) { return Math.floor(Math.random() * n); };
|
|
|
|
|
var randomChar = function () {
|
|
|
|
|
return String.fromCharCode(die(94) + 34);
|
|
|
|
|
};
|
|
|
|
|
var mutate = function (S, i, c) {
|
|
|
|
|
var A = S.split("");
|
|
|
|
|
A[i] = c;
|
|
|
|
|
return A.join("");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var take = function (A) {
|
|
|
|
|
var n = die(A.length);
|
|
|
|
|
var choice = A[n];
|
|
|
|
|
A.splice(n, 1);
|
|
|
|
|
return choice;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var makeDecryptor = function (el, t, difficulty, cb) {
|
|
|
|
|
var Orig = el.innerText;
|
|
|
|
|
var options = [];
|
|
|
|
|
el.innerText = el.innerText.split("").map(function (c, i) {
|
|
|
|
|
Orig[i] = c;
|
|
|
|
|
options.push(i);
|
|
|
|
|
return randomChar();
|
|
|
|
|
}).join("");
|
|
|
|
|
|
|
|
|
|
return function f () {
|
|
|
|
|
if (die(difficulty) === 0) {
|
|
|
|
|
var choice = take(options);
|
|
|
|
|
el.innerText = mutate(el.innerText, choice, Orig.charAt(choice));
|
|
|
|
|
} else { // make a superficial change
|
|
|
|
|
el.innerText = mutate(el.innerText,
|
|
|
|
|
options[die(options.length)],
|
|
|
|
|
randomChar());
|
|
|
|
|
}
|
|
|
|
|
setTimeout(options.length > 0? f: cb, t);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-05 00:33:06 +08:00
|
|
|
|
makeDecryptor(brand, 70, 2, function () { })();
|
2017-12-01 21:03:13 +08:00
|
|
|
|
makeDecryptor(title, 50, 14, function () { })();
|
2017-12-05 00:33:06 +08:00
|
|
|
|
makeDecryptor(link, 20, 4, function () {})();
|
|
|
|
|
makeDecryptor(message, 12, 3, function () {
|
2017-12-01 02:17:59 +08:00
|
|
|
|
console.log('done');
|
|
|
|
|
})();
|
|
|
|
|
});
|
|
|
|
|
|