mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2026-04-19 21:58:08 -04:00
refactor: remove more jQuery stuff
This commit is contained in:
+2
-2
@@ -12,8 +12,8 @@ global.WebCrypto = require('@peculiar/webcrypto').Crypto;
|
|||||||
global.$ = global.jQuery = require('./jquery-3.7.1');
|
global.$ = global.jQuery = require('./jquery-3.7.1');
|
||||||
global.zlib = require('./zlib-1.3.1-2').zlib;
|
global.zlib = require('./zlib-1.3.1-2').zlib;
|
||||||
require('./prettify');
|
require('./prettify');
|
||||||
global.prettyPrint = window.PR.prettyPrint;
|
global.prettyPrint = window.PR ? window.PR.prettyPrint : function() {};
|
||||||
global.prettyPrintOne = window.PR.prettyPrintOne;
|
global.prettyPrintOne = window.PR ? window.PR.prettyPrintOne : function() {};
|
||||||
global.showdown = require('./showdown-2.1.0');
|
global.showdown = require('./showdown-2.1.0');
|
||||||
global.DOMPurify = require('./purify-3.3.0');
|
global.DOMPurify = require('./purify-3.3.0');
|
||||||
global.baseX = require('./base-x-5.0.1').baseX;
|
global.baseX = require('./base-x-5.0.1').baseX;
|
||||||
|
|||||||
+26
-38
@@ -1744,7 +1744,7 @@ window.PrivateBin = (function() {
|
|||||||
if (typeof state === 'undefined') {
|
if (typeof state === 'undefined') {
|
||||||
state = null;
|
state = null;
|
||||||
}
|
}
|
||||||
historyChange($.Event('popstate', {originalEvent: new PopStateEvent('popstate', {state: state}), target: window}));
|
historyChange({originalEvent: new PopStateEvent('popstate', {state: state}), target: window});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1945,7 +1945,7 @@ window.PrivateBin = (function() {
|
|||||||
message = 'Loading…';
|
message = 'Loading…';
|
||||||
}
|
}
|
||||||
|
|
||||||
handleNotification(0, $loadingIndicator, message, icon);
|
handleNotification(0, loadingIndicator, message, icon);
|
||||||
|
|
||||||
// show loading status (cursor)
|
// show loading status (cursor)
|
||||||
document.body.classList.add('loading');
|
document.body.classList.add('loading');
|
||||||
@@ -1959,7 +1959,7 @@ window.PrivateBin = (function() {
|
|||||||
*/
|
*/
|
||||||
me.hideLoading = function()
|
me.hideLoading = function()
|
||||||
{
|
{
|
||||||
$loadingIndicator.addClass('hidden');
|
loadingIndicator.classList.add('hidden');
|
||||||
|
|
||||||
// hide loading cursor
|
// hide loading cursor
|
||||||
document.body.classList.remove('loading');
|
document.body.classList.remove('loading');
|
||||||
@@ -2082,18 +2082,6 @@ window.PrivateBin = (function() {
|
|||||||
'noopener, noreferrer'
|
'noopener, noreferrer'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
})
|
|
||||||
.fail(function(data, textStatus, errorThrown) {
|
|
||||||
console.error(textStatus, errorThrown);
|
|
||||||
// we don't know why it failed, could be CORS of the external
|
|
||||||
// server not setup properly, in which case we follow old
|
|
||||||
// behavior to open it in new tab
|
|
||||||
window.open(
|
|
||||||
`${$shortenButton.data('shortener')}${encodeURIComponent($pasteUrl.attr('href'))}`,
|
|
||||||
'_blank',
|
|
||||||
'noopener, noreferrer'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2125,7 +2113,7 @@ window.PrivateBin = (function() {
|
|||||||
me.createPasteNotification = function(url, deleteUrl)
|
me.createPasteNotification = function(url, deleteUrl)
|
||||||
{
|
{
|
||||||
I18n._(
|
I18n._(
|
||||||
$('#pastelink'),
|
document.getElementById('pastelink'),
|
||||||
'Your document is <a id="pasteurl" href="%s">%s</a> <span id="copyhint">(Hit <kbd>Ctrl</kbd>+<kbd>c</kbd> to copy)</span>',
|
'Your document is <a id="pasteurl" href="%s">%s</a> <span id="copyhint">(Hit <kbd>Ctrl</kbd>+<kbd>c</kbd> to copy)</span>',
|
||||||
url, url
|
url, url
|
||||||
);
|
);
|
||||||
@@ -2155,7 +2143,7 @@ window.PrivateBin = (function() {
|
|||||||
*/
|
*/
|
||||||
me.checkAutoShorten = function() {
|
me.checkAutoShorten = function() {
|
||||||
// check if auto-shortening is enabled
|
// check if auto-shortening is enabled
|
||||||
if ($shortenButton.data('autoshorten') === true) {
|
if (shortenButton.dataset.autoshorten === 'true') {
|
||||||
// if so, we send the link to the shortener
|
// if so, we send the link to the shortener
|
||||||
// we do not remove the button, in case shortener fails
|
// we do not remove the button, in case shortener fails
|
||||||
sendToShortener();
|
sendToShortener();
|
||||||
@@ -2286,8 +2274,8 @@ window.PrivateBin = (function() {
|
|||||||
const Prompt = (function () {
|
const Prompt = (function () {
|
||||||
const me = {};
|
const me = {};
|
||||||
|
|
||||||
let $passwordDecrypt,
|
let passwordDecrypt,
|
||||||
$passwordModal,
|
passwordModal,
|
||||||
bootstrap5PasswordModal = null,
|
bootstrap5PasswordModal = null,
|
||||||
password = '';
|
password = '';
|
||||||
|
|
||||||
@@ -2304,7 +2292,7 @@ window.PrivateBin = (function() {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
// get input
|
// get input
|
||||||
password = $passwordDecrypt.val();
|
password = passwordDecrypt.value;
|
||||||
|
|
||||||
// hide modal
|
// hide modal
|
||||||
if (bootstrap5PasswordModal) {
|
if (bootstrap5PasswordModal) {
|
||||||
@@ -2324,20 +2312,20 @@ window.PrivateBin = (function() {
|
|||||||
*/
|
*/
|
||||||
me.requestLoadConfirmation = function()
|
me.requestLoadConfirmation = function()
|
||||||
{
|
{
|
||||||
const $loadconfirmmodal = $('#loadconfirmmodal');
|
const loadconfirmmodal = document.getElementById('loadconfirmmodal');
|
||||||
|
|
||||||
const $loadconfirmOpenNow = $loadconfirmmodal.find('#loadconfirm-open-now');
|
const loadconfirmOpenNow = loadconfirmmodal.querySelector('#loadconfirm-open-now');
|
||||||
$loadconfirmOpenNow.off('click.loadPaste');
|
loadconfirmOpenNow.removeEventListener('click', PasteDecrypter.run);
|
||||||
$loadconfirmOpenNow.on('click.loadPaste', PasteDecrypter.run);
|
loadconfirmOpenNow.addEventListener('click', PasteDecrypter.run);
|
||||||
|
|
||||||
const $loadconfirmClose = $loadconfirmmodal.find('.close');
|
const loadconfirmClose = loadconfirmmodal.querySelector('.close');
|
||||||
$loadconfirmClose.off('click.close');
|
loadconfirmClose.removeEventListener('click', Controller.newPaste);
|
||||||
$loadconfirmClose.on('click.close', Controller.newPaste);
|
loadconfirmClose.addEventListener('click', Controller.newPaste);
|
||||||
|
|
||||||
if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip.VERSION) {
|
if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip.VERSION) {
|
||||||
(new bootstrap.Modal($loadconfirmmodal[0])).show();
|
(new bootstrap.Modal(loadconfirmmodal)).show();
|
||||||
} else {
|
} else {
|
||||||
$loadconfirmmodal.modal('show');
|
$(loadconfirmmodal).modal('show');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2402,12 +2390,12 @@ window.PrivateBin = (function() {
|
|||||||
*/
|
*/
|
||||||
me.init = function()
|
me.init = function()
|
||||||
{
|
{
|
||||||
$passwordDecrypt = $('#passworddecrypt');
|
passwordDecrypt = document.getElementById('passworddecrypt');
|
||||||
$passwordModal = $('#passwordmodal');
|
passwordModal = $('#passwordmodal');
|
||||||
|
|
||||||
// bind events - handle Model password submission
|
// bind events - handle Model password submission
|
||||||
if ($passwordModal.length !== 0) {
|
if (passwordModal.length !== 0) {
|
||||||
$('#passwordform').submit(submitPasswordModal);
|
document.getElementById('passwordform').addEventListener('submit', submitPasswordModal);
|
||||||
|
|
||||||
const disableClosingConfig = {
|
const disableClosingConfig = {
|
||||||
backdrop: 'static',
|
backdrop: 'static',
|
||||||
@@ -2415,12 +2403,12 @@ window.PrivateBin = (function() {
|
|||||||
show: false
|
show: false
|
||||||
};
|
};
|
||||||
if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip.VERSION) {
|
if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip.VERSION) {
|
||||||
bootstrap5PasswordModal = new bootstrap.Modal($passwordModal[0], disableClosingConfig);
|
bootstrap5PasswordModal = new bootstrap.Modal(passwordModal[0], disableClosingConfig);
|
||||||
} else {
|
} else {
|
||||||
$passwordModal.modal(disableClosingConfig);
|
passwordModal.modal(disableClosingConfig);
|
||||||
}
|
}
|
||||||
$passwordModal.on('shown.bs.modal', () => {
|
passwordModal.on('shown.bs.modal', () => {
|
||||||
$passwordDecrypt.focus();
|
passwordDecrypt.focus();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -2446,7 +2434,7 @@ window.PrivateBin = (function() {
|
|||||||
$messagePreviewParent,
|
$messagePreviewParent,
|
||||||
$messageTab,
|
$messageTab,
|
||||||
$messageTabParent,
|
$messageTabParent,
|
||||||
$message,
|
message,
|
||||||
isPreview = false,
|
isPreview = false,
|
||||||
isTabSupported = true;
|
isTabSupported = true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user