|
|
@ -1,5 +1,5 @@
|
|
|
|
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
|
|
|
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
|
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
|
|
|
<%@ include file="/WEB-INF/jsp/framework/taglibs.jsp" %>
|
|
|
|
|
|
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<html>
|
|
|
@ -11,6 +11,7 @@
|
|
|
|
<script type="text/javascript" src="/resources/3rd-party/paintweb/html2canvas.min.js"></script>
|
|
|
|
<script type="text/javascript" src="/resources/3rd-party/paintweb/html2canvas.min.js"></script>
|
|
|
|
<script type="text/javascript" src="/resources/3rd-party/paintweb/es6-promise.min.js"></script>
|
|
|
|
<script type="text/javascript" src="/resources/3rd-party/paintweb/es6-promise.min.js"></script>
|
|
|
|
<script type="text/javascript" src="/resources/3rd-party/paintweb/es6-promise.auto.min.js"></script>
|
|
|
|
<script type="text/javascript" src="/resources/3rd-party/paintweb/es6-promise.auto.min.js"></script>
|
|
|
|
|
|
|
|
<script type="text/javascript" src="/resources/framework/js/cmm/cmmUtil.js"></script>
|
|
|
|
</head>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<body>
|
|
|
|
<img id="editableImage"/>
|
|
|
|
<img id="editableImage"/>
|
|
|
@ -19,6 +20,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
<script type="text/javascript">
|
|
|
|
//TODO: srcImg 변수명 변경시 paintweb.js의 imageSaveTo() 내의 2669 line var url = srcImg.src; 변경 필요
|
|
|
|
//TODO: srcImg 변수명 변경시 paintweb.js의 imageSaveTo() 내의 2669 line var url = srcImg.src; 변경 필요
|
|
|
|
|
|
|
|
var pw;
|
|
|
|
var srcImg;
|
|
|
|
var srcImg;
|
|
|
|
let editImg =null;
|
|
|
|
let editImg =null;
|
|
|
|
|
|
|
|
|
|
|
@ -27,18 +29,137 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const initEditor = () => {
|
|
|
|
const initEditor = () => {
|
|
|
|
const pw = new PaintWeb();
|
|
|
|
pw = new PaintWeb();
|
|
|
|
pw.config.guiPlaceholder = document.getElementById('PaintWebTarget');
|
|
|
|
pw.config.guiPlaceholder = document.getElementById('PaintWebTarget');
|
|
|
|
pw.config.configFile = 'paintweb-config.json';
|
|
|
|
pw.config.configFile = 'paintweb-config.json';
|
|
|
|
pw.config.imageLoad = editImg;
|
|
|
|
pw.config.imageLoad = editImg;
|
|
|
|
|
|
|
|
|
|
|
|
pw.config.imageSaveURL = "/saveImage.do"; // imageSave == image upload
|
|
|
|
//pw.config.imageSaveURL = "/saveImage.do"; // imageSave == image upload
|
|
|
|
|
|
|
|
pw.config.imageSaveURL = "/saveImage"; // imageSave == image upload
|
|
|
|
pw.config.imageDownloadURL = "/fileDownload.do";
|
|
|
|
pw.config.imageDownloadURL = "/fileDownload.do";
|
|
|
|
pw.config.afterImageSave = afterImageSave;
|
|
|
|
//pw.config.afterImageSave = afterImageSave;
|
|
|
|
|
|
|
|
pw.config.imageSave = imageSaveTo;
|
|
|
|
|
|
|
|
pw.config.afterImageSave = () => window.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var evId = pw.config.saveH('imageSave', saveHandler);
|
|
|
|
|
|
|
|
// Later you can remove the event handler
|
|
|
|
|
|
|
|
//pw.events.remove('imageSave', evId);
|
|
|
|
|
|
|
|
|
|
|
|
pw.init();
|
|
|
|
pw.init();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function imageSaveTo(file, doc, _self){
|
|
|
|
|
|
|
|
//downloadImage(idata, 'lllll');
|
|
|
|
|
|
|
|
console.log(file)
|
|
|
|
|
|
|
|
this.image = {
|
|
|
|
|
|
|
|
filename: file.name,
|
|
|
|
|
|
|
|
size: file.size,
|
|
|
|
|
|
|
|
type: file.type,
|
|
|
|
|
|
|
|
lastModified: file.lastModified
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//let formData = new FormData();
|
|
|
|
|
|
|
|
//formData.append('file', file);
|
|
|
|
|
|
|
|
const {interfaceSeqN, ctznSttemntDetailSn, fileMastrId, fileId} = srcImg.dataset;
|
|
|
|
|
|
|
|
const param = {
|
|
|
|
|
|
|
|
interfaceSeqN,
|
|
|
|
|
|
|
|
ctznSttemntDetailSn,
|
|
|
|
|
|
|
|
fileMastrId,
|
|
|
|
|
|
|
|
fileId: 'kdkdkdk',
|
|
|
|
|
|
|
|
orginlFileNm: srcImg.orginlFileNm,
|
|
|
|
|
|
|
|
file: file
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmmAjax({
|
|
|
|
|
|
|
|
url: '<c:out value="/framework/biz/cmm/file/uploadPaintweb.do"/>',
|
|
|
|
|
|
|
|
data: $.param(JSON.stringify(param)),
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function imageSaveTo2(idata, width, height, doc, _self){
|
|
|
|
|
|
|
|
debugger
|
|
|
|
|
|
|
|
alert('~~~~imageSaveTo~~~');
|
|
|
|
|
|
|
|
console.log(idata)
|
|
|
|
|
|
|
|
var ex = /\?filename=([a-z0-9\-]+)\&?/i;
|
|
|
|
|
|
|
|
var dashdash = '--';
|
|
|
|
|
|
|
|
var crlf = '\r\n';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
|
|
|
|
|
|
var progressBar = doc.createElement("div");
|
|
|
|
|
|
|
|
progressBar.style.left = ((w-200)/2) + "px";
|
|
|
|
|
|
|
|
progressBar.className = "progressBar";
|
|
|
|
|
|
|
|
document.body.appendChild(progressBar);
|
|
|
|
|
|
|
|
var progressRate = doc.createElement("div");
|
|
|
|
|
|
|
|
progressRate.innerText = "Saving";
|
|
|
|
|
|
|
|
progressRate.className = "progressRate";
|
|
|
|
|
|
|
|
progressBar.appendChild(progressRate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var url = srcImg.src;
|
|
|
|
|
|
|
|
var filename = url.match(ex)[1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var boundary = 'multipartformboundary' + (new Date).getTime();
|
|
|
|
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
|
|
|
|
xhr.open("POST", _self.config.imageSaveURL);
|
|
|
|
|
|
|
|
xhr.setRequestHeader('content-type', 'multipart/form-data; boundary='+ boundary);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var builder = dashdash + boundary + crlf + 'Content-Disposition: form-data; name="imageFile"' +
|
|
|
|
|
|
|
|
'; filename="' + filename + '";' + crlf + ' Content-Type: application/octet-stream' + crlf + crlf;
|
|
|
|
|
|
|
|
builder += idata;
|
|
|
|
|
|
|
|
builder += crlf + dashdash + boundary + crlf + 'Content-Disposition: form-data; name="filename"' + crlf + crlf + filename;
|
|
|
|
|
|
|
|
builder += crlf + dashdash + boundary + dashdash + crlf;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onload = function () {
|
|
|
|
|
|
|
|
var newImg = document.createElement("IMG");
|
|
|
|
|
|
|
|
newImg.onload = function () {
|
|
|
|
|
|
|
|
srcImg.src = newImg.src + "#img" + (new Date()).getTime();
|
|
|
|
|
|
|
|
if (_self.config.afterImageSave) _self.config.afterImageSave();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
newImg.src = _self.config.imageDownloadURL + "?filename=" + filename+ "#img" + (new Date()).getTime();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
xhr.upload.addEventListener("progress", function(evt){
|
|
|
|
|
|
|
|
if (evt.lengthComputable) {
|
|
|
|
|
|
|
|
var p = evt.loaded / evt.total * 100;
|
|
|
|
|
|
|
|
progressRate.style.width = p + "%";
|
|
|
|
|
|
|
|
progressRate.innerText = progressRate.style.width;
|
|
|
|
|
|
|
|
if (p==100) {
|
|
|
|
|
|
|
|
progressRate.innerText = "Saved";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
xhr.send(builder);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function saveHandler (ev) {
|
|
|
|
|
|
|
|
// Cancel the default action of the event.
|
|
|
|
|
|
|
|
ev.preventDefault();
|
|
|
|
|
|
|
|
alert('saveHandler~~~')
|
|
|
|
|
|
|
|
var handlerURL = 'image_save_script.php', send = 'dataURL=' + encodeURIComponent(ev.dataURL), headers = {'Content-Type': 'application/x-www-form-urlencoded'};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 이미지를 저장하는 서버 측 스크립트로 데이터 URL을 보냅니다.
|
|
|
|
|
|
|
|
pwlib.xhrLoad ( handlerURL, saveReady, 'POST', send, header );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The XMLHttpRequest onreadystatechange event handler.
|
|
|
|
|
|
|
|
function saveReady (xhr) {
|
|
|
|
|
|
|
|
alert('saveReady~~~')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!xhr || xhr.readyState !== 4) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((xhr.status !== 304 && xhr.status !== 200) || !xhr.responseText || xhr.responseText !== 'OK') {
|
|
|
|
|
|
|
|
// Image save failed.
|
|
|
|
|
|
|
|
pw.events.dispatch(new appEvent.imageSaveResult(false));
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Image save was successful.
|
|
|
|
|
|
|
|
pw.events.dispatch(new appEvent.imageSaveResult(true));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(document).ready(function () {
|
|
|
|