1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-09-29 16:10:11 +02:00
* Fix: #746

* formatting
This commit is contained in:
Ludy 2024-02-18 08:40:30 +01:00 committed by GitHub
parent 673f005fe6
commit 51ad741744
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 265 additions and 283 deletions

View File

@ -29,13 +29,12 @@ $(document).ready(function () {
// Set a timeout to show the game button if operation takes more than 5 seconds // Set a timeout to show the game button if operation takes more than 5 seconds
const timeoutId = setTimeout(() => { const timeoutId = setTimeout(() => {
var boredWaiting = localStorage.getItem("boredWaiting") || "disabled"; var boredWaiting = localStorage.getItem("boredWaiting") || "disabled";
const showGameBtn = document.getElementById('show-game-btn'); const showGameBtn = document.getElementById("show-game-btn");
if (boredWaiting === "enabled" && showGameBtn) { if (boredWaiting === "enabled" && showGameBtn) {
showGameBtn.style.display = 'block'; showGameBtn.style.display = "block";
} }
}, 5000); }, 5000);
try { try {
if (remoteCall === true) { if (remoteCall === true) {
if (override === "multi" || (!multiple && files.length > 1 && override !== "single")) { if (override === "multi" || (!multiple && files.length > 1 && override !== "single")) {
@ -46,7 +45,6 @@ $(document).ready(function () {
} }
clearTimeout(timeoutId); clearTimeout(timeoutId);
$("#submitBtn").text(originalButtonText); $("#submitBtn").text(originalButtonText);
} catch (error) { } catch (error) {
clearTimeout(timeoutId); clearTimeout(timeoutId);
handleDownloadError(error); handleDownloadError(error);

View File

@ -3323,13 +3323,13 @@
kind: OptionKind.WORKER kind: OptionKind.WORKER
}, },
workerSrc: { workerSrc: {
value: "/pdfjs/pdf.worker.js", value: "./pdfjs/pdf.worker.js",
kind: OptionKind.WORKER kind: OptionKind.WORKER
} }
}; };
{ {
defaultOptions.defaultUrl = { defaultOptions.defaultUrl = {
value: "/pdfjs/example/Welcome.pdf", value: "./pdfjs/example/Welcome.pdf",
kind: OptionKind.VIEWER kind: OptionKind.VIEWER
}; };
defaultOptions.disablePreferences = { defaultOptions.disablePreferences = {

View File

@ -34,7 +34,7 @@
<link rel="stylesheet" href="css/bootstrap-icons.min.css"> <link rel="stylesheet" href="css/bootstrap-icons.min.css">
<!-- PDF.js --> <!-- PDF.js -->
<script src="pdfjs/pdf.js"></script> <script th:src="@{pdfjs/pdf.js}"></script>
<!-- PDF-Lib --> <!-- PDF-Lib -->
<script src="js/thirdParty/pdf-lib.min.js"></script> <script src="js/thirdParty/pdf-lib.min.js"></script>
@ -71,7 +71,6 @@
console.log("loaded game"); console.log("loaded game");
$(document).ready(function() { $(document).ready(function() {
// Find the file input within the form // Find the file input within the form
var fileInput = $('input[type="file"]'); var fileInput = $('input[type="file"]');
@ -87,7 +86,6 @@
// Insert the 'show-game-btn' just above the submit button // Insert the 'show-game-btn' just above the submit button
submitButton.before(gameButton); submitButton.before(gameButton);
function loadGameScript(callback) { function loadGameScript(callback) {
console.log('loadGameScript called'); console.log('loadGameScript called');
const script = document.createElement('script'); const script = document.createElement('script');
@ -122,8 +120,6 @@
gameDialog.close(); gameDialog.close();
} }
}) })
}) })
</script> </script>
<div id="game-container"> <div id="game-container">

View File

@ -15,19 +15,13 @@
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-md-3"> <div class="col-md-3">
<div id="sliders-container" style="display:none;"> <div id="sliders-container" style="display:none;">
<h4> <h4><span th:text="#{adjustContrast.contrast}"></span> <span id="contrast-val">100</span>%</h4>
<span th:text="#{adjustContrast.contrast}"></span> <span id="contrast-val">100</span>%
</h4>
<input type="range" min="0" max="200" value="100" id="contrast-slider" /> <input type="range" min="0" max="200" value="100" id="contrast-slider" />
<h4> <h4><span th:text="#{adjustContrast.brightness}"></span> <span id="brightness-val">100</span>%</h4>
<span th:text="#{adjustContrast.brightness}"></span> <span id="brightness-val">100</span>%
</h4>
<input type="range" min="0" max="200" value="100" id="brightness-slider" /> <input type="range" min="0" max="200" value="100" id="brightness-slider" />
<h4> <h4><span th:text="#{adjustContrast.saturation}"></span> <span id="saturation-val">100</span>%</h4>
<span th:text="#{adjustContrast.saturation}"></span> <span id="saturation-val">100</span>%
</h4>
<input type="range" min="0" max="200" value="100" id="saturation-slider" /> <input type="range" min="0" max="200" value="100" id="saturation-slider" />
</div> </div>
</div> </div>
@ -36,7 +30,7 @@
<div class="col-md-8"> <div class="col-md-8">
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multiple=false, accept='application/pdf', remoteCall='false')}"></div> <div th:replace="~{fragments/common :: fileSelector(name='fileInput', multiple=false, accept='application/pdf', remoteCall='false')}"></div>
</div> </div>
<br> <br />
<canvas id="contrast-pdf-canvas"></canvas> <canvas id="contrast-pdf-canvas"></canvas>
<button id="download-button" class="btn btn-primary" th:text="#{adjustContrast.download}"></button> <button id="download-button" class="btn btn-primary" th:text="#{adjustContrast.download}"></button>
</div> </div>
@ -51,8 +45,6 @@
} }
</style> </style>
<script src="pdfjs/pdf.js"></script>
<script> <script>
var canvas = document.getElementById('contrast-pdf-canvas'); var canvas = document.getElementById('contrast-pdf-canvas');
var context = canvas.getContext('2d'); var context = canvas.getContext('2d');
@ -107,7 +99,6 @@
}); });
} }
function adjustImageProperties() { function adjustImageProperties() {
var contrast = parseFloat(document.getElementById('contrast-slider').value); var contrast = parseFloat(document.getElementById('contrast-slider').value);
var brightness = parseFloat(document.getElementById('brightness-slider').value); var brightness = parseFloat(document.getElementById('brightness-slider').value);
@ -121,8 +112,7 @@
var newImageData = context.createImageData(originalImageData.width, originalImageData.height); var newImageData = context.createImageData(originalImageData.width, originalImageData.height);
newImageData.data.set(originalImageData.data); newImageData.data.set(originalImageData.data);
for(var i=0; i<newImageData.data.length; i+=4) for(var i=0; i<newImageData.data.length; i+=4) {
{
var r = newImageData.data[i]; var r = newImageData.data[i];
var g = newImageData.data[i+1]; var g = newImageData.data[i+1];
var b = newImageData.data[i+2]; var b = newImageData.data[i+2];
@ -205,6 +195,7 @@
// Denormalize back to [0, 255] // Denormalize back to [0, 255]
return (normalized + 0.5) * 255; return (normalized + 0.5) * 255;
} }
function clamp(value, min, max) { function clamp(value, min, max) {
return Math.min(Math.max(value, min), max); return Math.min(Math.max(value, min), max);
} }
@ -268,9 +259,6 @@
} }
// Event listeners // Event listeners
document.getElementById('fileInput-input').addEventListener('change', function(e) { document.getElementById('fileInput-input').addEventListener('change', function(e) {
if (e.target.files.length > 0) { if (e.target.files.length > 0) {

View File

@ -32,11 +32,11 @@ See https://github.com/adobe-type-tools/cmap-resources
<script src="js/thirdParty/bootstrap.min.js"></script> <script src="js/thirdParty/bootstrap.min.js"></script>
<!-- This snippet is used in production (included from view-pdf.html) --> <!-- This snippet is used in production (included from view-pdf.html) -->
<link rel="resource" type="application/l10n" href="pdfjs/locale/locale.properties"> <link rel="resource" type="application/l10n" th:href="@{pdfjs/locale/locale.properties}">
<script src="pdfjs/pdf.js"></script> <script th:src="@{pdfjs/pdf.js}" type="module"></script>
<link rel="stylesheet" href="pdfjs/css/viewer.css"> <link rel="stylesheet" th:href="@{/pdfjs/css/viewer.css}">
<script src="pdfjs/js/viewer.js"></script> <script th:src="@{pdfjs/js/viewer.js}" type="module"></script>
</head> </head>
<body tabindex="1"> <body tabindex="1">