Commit c93b03e4 by Daniel Bawag

WG-227 - Modified PDF viewer to accept blob

parent 1f0a7291
......@@ -11,11 +11,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.payara.tools.lib.system">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
......@@ -29,5 +24,10 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.payara.tools.lib.system">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Payara Server 5 (5.2022.1)"/>
<runtime name="Payara Server 5 (5.2021.1)"/>
<fixed facet="jst.web"/>
<fixed facet="java"/>
<fixed facet="wst.jsdt.web"/>
......
......@@ -121,18 +121,26 @@ function createRejectWindow(){
setRadioHandler('MssgBox');
okButton.onclick = function () {
saveExceptionToXml();//save xml
rejectElement();//reject on bpo
screenMain.style.display = 'none';
rejectButton.disabled = false;
popUpDisplay.remove();
var fileName = sessionStorage.getItem("file_Name");
if(fileName !== null && fileName !== undefined){
document.getElementById("controlsContainer").outerHTML="";
}else{
document.getElementById("TiffViewer_ButtonContainer").outerHTML="";
}
okButton.onclick = function () {
if (document.querySelector('input[name="rejectRadio"]:checked').value != null) {
if (document.querySelector('input[name="rejectRadio"]:checked').value.trim().length != 0) {
saveExceptionToXml();//save xml
rejectElement();//reject on bpo
screenMain.style.display = 'none';
rejectButton.disabled = false;
popUpDisplay.remove();
var fileName = sessionStorage.getItem("file_Name");
if(fileName !== null && fileName !== undefined){
document.getElementById("controlsContainer").outerHTML="";
}else{
document.getElementById("TiffViewer_ButtonContainer").outerHTML="";
}
return;
}
}
document.getElementById('MssgBox').value = "";
document.getElementById('rejectSubmit').click();
}
cancelButton.onclick = function () {
......@@ -304,19 +312,28 @@ function saveExceptionToXml(){
}
function createMessageBox(id){
let form = document.createElement('form');
var mssgBox = document.createElement('textarea');
mssgBox.id = id;
mssgBox.name = "rejectRadio";
mssgBox.maxLength = "1000";
mssgBox.cols = "20";
mssgBox.rows = "5";
mssgBox.rows = "5";
mssgBox.required = true;
mssgBox.disabled = true;
mssgBox.onkeyup = function () {
let radioFive = document.getElementById('check5');
radioFive.value = mssgBox.value;
}
return mssgBox;
let submit = document.createElement('input');
submit.id = 'rejectSubmit';
submit.type = 'submit';
submit.style.visibility = 'hidden';
form.appendChild(mssgBox);
form.appendChild(submit);
return form;
}
......
......@@ -71,7 +71,8 @@ async function accessFile() {
TiffViewer_filedetail.textContent = "Filename: " + idQuery.result.name;
TiffViewer_filedetail.title = "Filename: " + idQuery.result.name;
TiffViewer_Header.append(TiffViewer_filedetail);
displayPdf(idQuery.result.path);
// displayPdf(idQuery.result.path);
displayPdf(url);
} else {
console.log("This is not a pdf file");
window.addEventListener("load", loadDoc(url, TIFFViewer, idQuery.result.name), false);
......@@ -90,7 +91,8 @@ async function accessFile() {
TiffViewer_filedetail.textContent = "Filename: " + idQuery.result.name;
TiffViewer_filedetail.title = "Filename: " + idQuery.result.name;
TiffViewer_Header.append(TiffViewer_filedetail);
displayPdf(idQuery.result.path);
// displayPdf(idQuery.result.path);
displayPdf(url);
} else {
console.log("This is not a pdf file");
window.addEventListener("load", loadDoc(url, TIFFViewer, idQuery.result.name), false);
......@@ -182,7 +184,8 @@ async function accessFile() {
TiffViewer_filedetail.textContent = "Filename: " + filename;
TiffViewer_filedetail.title = "Filename: " + filename;
TiffViewer_Header.append(TiffViewer_filedetail);
displayPdf(img);
// displayPdf(img);
displayPdf(url);
} else {
window.addEventListener("load", loadDoc(url, TIFFViewer,filename), false);
}
......@@ -550,7 +553,8 @@ function refreshImage() {
TiffViewer_filedetail.textContent = "Filename: " + idQuery.result.name;
TiffViewer_filedetail.title = "Filename: " + idQuery.result.name;
TiffViewer_Header.append(TiffViewer_filedetail);
displayPdf(idQuery.result.path);
// displayPdf(idQuery.result.path);
displayPdf(url);
} else {
console.log("This is not a pdf file");
window.addEventListener("load", loadDoc(url, TIFFViewer,idQuery.result.name), false);
......
......@@ -188,24 +188,24 @@ var displayPdf = function(doc) {
fitContentButton.addEventListener('click', function() {
if (currentScale != fitScale) {
/*if (currentScale != fitScale) {
currentScale = fitScale;
renderPage(currentPage);
} else {
} else {*/
currentScale = 1.3;
renderPage(currentPage);
}
//}
});
document.addEventListener("keydown", function(e) {
if (e.shiftKey && e.key == 'F') {
if (currentScale != fitScale) {
currentScale = fitScale;
renderPage(currentPage);
} else {
// if (currentScale != fitScale) {
// currentScale = fitScale;
// renderPage(currentPage);
// } else {
currentScale = 1.3;
renderPage(currentPage);
}
// }
}
});
......
.tiffViewerContainer {
margin: auto;
height: calc(100% - 60px);
/* height: calc(100% - 60px); */
width: 70%;
position: relative;
display: block;
......
......@@ -107,6 +107,9 @@ function TIFFViewer(xhr, TiffViewerImageName) {
var editedwidth = 0,
editedheight = 0; //checker of width and height change
var initWidth = 100;
var widthHolder;
var hpercent = 0,
wpercent = 0; //set of percent increase or decrease per zoom
var hzoom = new Array(),
......@@ -351,7 +354,7 @@ let fileName = document.getElementById("TiffViewerImageName");
//setting the style per page
for (var j = 1; j <= TiffViewer_pages; j++) {
var img = document.getElementById(filenameWithoutExt + j);
getMeta(canvas, function(width, height) {
getMeta(canvas, function(width, height, img) {
wzoom[TiffViewer_current - 1] = changedwidth; /*ADDED: to fit large TIFF files*/
hzoom[TiffViewer_current - 1] = changedheight;
Edited();
......@@ -361,26 +364,29 @@ let fileName = document.getElementById("TiffViewerImageName");
setheight = height;
//to only display single page
if (setheight > 800 && setwidth > 1000) {
if (setheight > setwidth) {
// img.style = "width: 870px; height: 1160px";
img.style = "width: 900; height: 1200";
} else {
// img.style = "width: 800; height: 600";
//img.style = "width: 600; height: 800";
img.style = "width: 800; height: 600";
}
changed = true;
} else if (setwidth > 1000 && setheight <= 800) {
img.style = "width: 1000;";
changed = true;
} else if (setheight > 800 && setwidth <= 1000) {
img.style = "width: 800;";
changed = true;
} else {
img.style = `width: {setwidth}; height: {setheight}`;
changed = true;
}
// if (setheight > 800 && setwidth > 1000) {
// if (setheight > setwidth) {
// // img.style = "width: 870px; height: 1160px";
// img.style = "width: 900; height: 1200";
// } else {
// // img.style = "width: 800; height: 600";
// //img.style = "width: 600; height: 800";
// img.style = "width: 800; height: 600";
// }
// changed = true;
// } else if (setwidth > 1000 && setheight <= 800) {
// img.style = "width: 1000;";
// changed = true;
// } else if (setheight > 800 && setwidth <= 1000) {
// img.style = "width: 800;";
// changed = true;
// } else {
// img.style = `width: {setwidth}; height: {setheight}`;
// changed = true;
// }
img.style = `width: ${initWidth}%;`;
changed = true;
if (changed) {
if (TiffViewer_pages > 1) {
......@@ -396,15 +402,22 @@ let fileName = document.getElementById("TiffViewerImageName");
changedheight = setheight;
changedwidth = setwidth;
hpercent = (parseInt(setheight, 10) * (10 / 100));
wpercent = (parseInt(setwidth, 10) * (10 / 100));
// hpercent = (parseInt(setheight, 10) * (10 / 100));
// wpercent = (parseInt(setwidth, 10) * (10 / 100));
wpercent = 10;
hzoom.push(parseInt(setheight, 10));
wzoom.push(parseInt(setwidth, 10));
TiffViewer_scrn.style = `width: ${setwidth}; height: ${setheight};`;
document.getElementById("TiffViewer_FileContainer").style = `width: ${setwidth}; height: ${setheight};`;
TiffViewer_ImageContainer.style = `width: ${setwidth}; height: ${setheight};`;
// TiffViewer_scrn.style = `width: ${setwidth}; height: ${setheight};`;
// document.getElementById("TiffViewer_FileContainer").style = `width: ${setwidth}; height: ${setheight};`;
// TiffViewer_ImageContainer.style = `width: ${setwidth}; height: ${setheight};`;
TiffViewer_scrn.style = `width: ${initWidth}%;`;
document.getElementById("TiffViewer_FileContainer").style = `width: calc(${initWidth}% - 10px);`;
TiffViewer_ImageContainer.style = `width: ${initWidth}%;`;
});
checker.push(0);
flippedX.push(1);
......@@ -428,7 +441,7 @@ let fileName = document.getElementById("TiffViewerImageName");
var img = new Image();
img.src = url;
img.onload = function() {
callback(this.width, this.height);
callback(this.width, this.height, img);
}
}
......@@ -538,8 +551,10 @@ let fileName = document.getElementById("TiffViewerImageName");
})
function zoomIn() {
hzoom[TiffViewer_current - 1] += hpercent;
wzoom[TiffViewer_current - 1] += wpercent;
// hzoom[TiffViewer_current - 1] += hpercent;
// wzoom[TiffViewer_current - 1] += wpercent;
initWidth += wpercent;
document.getElementById("TiffViewer_FileContainer").style = `width: calc(${initWidth}% - 10px);`;
Edited();
};
......@@ -554,12 +569,15 @@ let fileName = document.getElementById("TiffViewerImageName");
})
function zoomOut() {
hzoom[TiffViewer_current - 1] -= hpercent;
wzoom[TiffViewer_current - 1] -= wpercent;
if ((setwidth + wzoom[TiffViewer_current - 1]) < wpercent && (setheight + hzoom[TiffViewer_current - 1]) < hpercent) {
hzoom[TiffViewer_current - 1] = hpercent - setheight;
wzoom[TiffViewer_current - 1] = wpercent - setwidth;
}
// hzoom[TiffViewer_current - 1] -= hpercent;
// wzoom[TiffViewer_current - 1] -= wpercent;
// if ((setwidth + wzoom[TiffViewer_current - 1]) < wpercent && (setheight + hzoom[TiffViewer_current - 1]) < hpercent) {
// hzoom[TiffViewer_current - 1] = hpercent - setheight;
// wzoom[TiffViewer_current - 1] = wpercent - setwidth;
// }
initWidth -= wpercent;
initWidth < 20 ? initWidth = 20 : initWidth;
document.getElementById("TiffViewer_FileContainer").style = `width: calc(${initWidth}% - 10px);`;
Edited();
};
......@@ -627,7 +645,8 @@ let fileName = document.getElementById("TiffViewerImageName");
function fitResize() {
var FitText = this.textContent || this.innerHTML;
document.getElementById("TiffViewer_ImageContainer").classList.remove("active");
if (FitText === "fc") {
/*if (FitText === "fc") {
setheight = origheight;
setwidth = origwidth;
wzoom[TiffViewer_current - 1] = origwidth;
......@@ -639,7 +658,10 @@ let fileName = document.getElementById("TiffViewerImageName");
wzoom[TiffViewer_current - 1] = changedwidth;
hzoom[TiffViewer_current - 1] = changedheight;
}
}*/
widthHolder = initWidth;
initWidth = 100;
document.getElementById("TiffViewer_FileContainer").style = `width: calc(${initWidth}% - 10px);`;
Edited();
}
......@@ -654,82 +676,76 @@ let fileName = document.getElementById("TiffViewerImageName");
if (rot[TiffViewer_current - 1] == 90 || rot[TiffViewer_current - 1] == 270 || rot[TiffViewer_current - 1] == -90 || rot[TiffViewer_current - 1] == -270) {
image.style = `
width: ${setwidth + wzoom[TiffViewer_current - 1]};
height: ${setheight + hzoom[TiffViewer_current - 1]};
width: 100%;
border: 0px groove white;
transform: rotate(${rot[TiffViewer_current - 1]}deg) scaleX(${flippedX[TiffViewer_current - 1]}) scaleY(${flippedY[TiffViewer_current - 1]});`;
image.style = `
width: ${setwidth + wzoom[TiffViewer_current - 1]};
height: ${setheight + hzoom[TiffViewer_current - 1]};
width: 100%;
border: 0px groove white;
-ms-transform: rotate(${rot[TiffViewer_current - 1]}deg) scaleX(${flippedX[TiffViewer_current - 1]}) scaleY(${flippedY[TiffViewer_current - 1]});`; // IE
image.style = `
width: ${setwidth + wzoom[TiffViewer_current - 1]};
height: ${setheight + hzoom[TiffViewer_current - 1]};
width: 100%;
border: 0px groove white;
-webkit-transform: rotate(${rot[TiffViewer_current - 1]}deg) scaleX(${flippedX[TiffViewer_current - 1]}) scaleY(${flippedY[TiffViewer_current - 1]});`; //Safari
TiffViewer_ImageContainer.style = `display: flex;
width: ${setheight};
height: ${setwidth};
position: relative;
justify-content: center;
align-items: center;`;
TiffViewer_Screen.style = `display: flex;
width: ${setheight};
height: ${setwidth};
position: relative;
justify-content: center;
align-items: center;`;
TiffViewer_imgclass.style = `display: flex;
width: ${(setheight + hzoom[TiffViewer_current - 1]) < setheight ? setheight : setheight + hzoom[TiffViewer_current - 1]};
height: ${(setwidth + wzoom[TiffViewer_current - 1]) < setwidth ? setwidth : setwidth + wzoom[TiffViewer_current - 1]};
position: relative;
justify-content: center;
align-items: center;`;
// TiffViewer_ImageContainer.style = `display: flex;
// width: ${setheight};
// height: ${setwidth};
// position: relative;
// justify-content: center;
// align-items: center;`;
// TiffViewer_Screen.style = `display: flex;
// width: ${setheight};
// height: ${setwidth};
// position: relative;
// justify-content: center;
// align-items: center;`;
// TiffViewer_imgclass.style = `display: flex;
// width: ${(setheight + hzoom[TiffViewer_current - 1]) < setheight ? setheight : setheight + hzoom[TiffViewer_current - 1]};
// height: ${(setwidth + wzoom[TiffViewer_current - 1]) < setwidth ? setwidth : setwidth + wzoom[TiffViewer_current - 1]};
// position: relative;
// justify-content: center;
// align-items: center;`;
width = TiffViewer_Screen.clientHeight;
height = TiffViewer_Screen.clientWidth;
} else {
image.style = `
width: ${setwidth + wzoom[TiffViewer_current - 1]};
height: ${setheight + hzoom[TiffViewer_current - 1]};
width: 100%;
border: 0px groove white;
transform: rotate(${rot[TiffViewer_current - 1]}deg) scaleX(${flippedX[TiffViewer_current - 1]}) scaleY(${flippedY[TiffViewer_current - 1]});`;
image.style = `
width: ${setwidth + wzoom[TiffViewer_current - 1]};
height: ${setheight + hzoom[TiffViewer_current - 1]};
width: 100%;
border: 0px groove white;
-ms-transform: rotate(${rot[TiffViewer_current - 1]}deg) scaleX(${flippedX[TiffViewer_current - 1]}) scaleY(${flippedY[TiffViewer_current - 1]});`; // IE
image.style = `
width: ${setwidth + wzoom[TiffViewer_current - 1]};
height: ${setheight + hzoom[TiffViewer_current - 1]};
width: 100%;
border: 0px groove white;
-webkit-transform: rotate(${rot[TiffViewer_current - 1]}deg) scaleX(${flippedX[TiffViewer_current - 1]}) scaleY(${flippedY[TiffViewer_current - 1]});`; //Safari
TiffViewer_ImageContainer.style = `display: flex;
width: ${setwidth};
height: ${setheight};
position: relative;
justify-content: center;
align-items: center;`;
TiffViewer_Screen.style = `display: flex;
width: ${setwidth};
height: ${setheight};
position: relative;
justify-content: center;
align-items: center;`;
TiffViewer_imgclass.style = `display: flex;
width: ${(setwidth + wzoom[TiffViewer_current - 1]) < setwidth ? setwidth : setwidth + wzoom[TiffViewer_current - 1]};
height: ${(setheight + hzoom[TiffViewer_current - 1]) < setheight ? setheight : setheight + hzoom[TiffViewer_current - 1]};
position: relative;
justify-content: center;
align-items: center;`;
// TiffViewer_ImageContainer.style = `display: flex;
// width: ${setwidth};
// height: ${setheight};
// position: relative;
// justify-content: center;
// align-items: center;`;
// TiffViewer_Screen.style = `display: flex;
// width: ${setwidth};
// height: ${setheight};
// position: relative;
// justify-content: center;
// align-items: center;`;
// TiffViewer_imgclass.style = `display: flex;
// width: ${(setwidth + wzoom[TiffViewer_current - 1]) < setwidth ? setwidth : setwidth + wzoom[TiffViewer_current - 1]};
// height: ${(setheight + hzoom[TiffViewer_current - 1]) < setheight ? setheight : setheight + hzoom[TiffViewer_current - 1]};
// position: relative;
// justify-content: center;
// align-items: center;`;
width = TiffViewer_Screen.clientWidth;
height = TiffViewer_Screen.clientHeight;
}
editedwidth = image.clientWidth;
editedheight = image.clientHeight;
let zoomPercentage = Math.round(100 + (hzoom[TiffViewer_current - 1] / setheight * 100));
zoom.innerHTML = zoomPercentage == 100 || isNaN(zoomPercentage) ? "" : zoomPercentage + "%";
// let zoomPercentage = Math.round(100 + (hzoom[TiffViewer_current - 1] / setheight * 100));
zoom.innerHTML = initWidth == 100 || isNaN(initWidth) ? "" : initWidth + "%";
// document.getElementById(`IMG${TiffViewer_current + 1}`).style.display = 'none';
// document.getElementById("IMG2").style.display = 'none';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment