added design front and back shirt and save file to phone(android)
This commit is contained in:
@ -91,13 +91,13 @@ for (var i = 0; i < list_desain.length; i++) {
|
||||
// console.log(list_desain[i].id);
|
||||
if (list_desain[i].id == id_desain) {
|
||||
baju_color = list_desain[i].canvas
|
||||
detail_desain = list_desain[i].isi;
|
||||
console.log(detail_desain)
|
||||
detail_desain = list_desain[i].isi_depan;
|
||||
// console.log(detail_desain)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$("#sini_div_baju_color").attr("style","background-image: url(assets/img/"+baju_color+".PNG); height: 350px; width: 100%;background-size: 100% 100%;");
|
||||
$("#sini_div_baju_color").attr("style","background-image: url(assets/img/"+baju_color+"1.JPG); height: 350px; width: 100%;background-size: 100% 100%;");
|
||||
|
||||
function toastnya(id,mesej){
|
||||
toastr.options = {
|
||||
@ -300,7 +300,10 @@ resizeCanvas();
|
||||
|
||||
|
||||
|
||||
|
||||
function desain_belakang(){
|
||||
console.log(id_desain)
|
||||
window.location.href ="desain_complete_belakang.html?id="+id_desain;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -329,4 +332,108 @@ resizeCanvas();
|
||||
$('#ini_untuk_share').trigger('click');
|
||||
}, 200);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function DownloadToDevice() {
|
||||
$.blockUI({
|
||||
message: "Sedang Diproses",
|
||||
css: {
|
||||
border: 'none',
|
||||
padding: '15px',
|
||||
backgroundColor: '#000',
|
||||
'-webkit-border-radius': '10px',
|
||||
'-moz-border-radius': '10px',
|
||||
opacity: .5,
|
||||
color: '#fff'
|
||||
} });
|
||||
var div = document.getElementById('sini_div_baju_color');
|
||||
await html2canvas(div).then(
|
||||
function (canvas) {
|
||||
document
|
||||
.getElementById('output')
|
||||
.appendChild(canvas);
|
||||
var base64URL = canvas.toDataURL('image/png');
|
||||
$.ajax({
|
||||
url: "http://irwan.kuwakuwi.com/",
|
||||
type: 'post',
|
||||
data: {proses : "ambil_gambar" , base64 : base64URL, id : "desain_depan"+id_desain},
|
||||
beforeSend: function(res) {
|
||||
|
||||
},
|
||||
success: function (response) {
|
||||
console.log(response);
|
||||
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
console.log(errorThrown)
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
await sleep(3000);
|
||||
ambil_foto();
|
||||
|
||||
}
|
||||
|
||||
function ambil_foto(){
|
||||
var blob = null;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "http://irwan.kuwakuwi.com/"+"desain_depan"+id_desain+".png");
|
||||
xhr.responseType = "blob";//force the HTTP response, response-type header to be blob
|
||||
xhr.onload = function()
|
||||
{
|
||||
blob = xhr.response;//xhr.response is now a blob object
|
||||
console.log(blob);
|
||||
var storageLocation = "";
|
||||
// switch (device.platform) {
|
||||
// case "Android":
|
||||
storageLocation = 'file:///storage/emulated/0/';
|
||||
// break;
|
||||
// case "iOS":
|
||||
// storageLocation = cordova.file.documentsDirectory;
|
||||
// break;
|
||||
// }
|
||||
var folderpath = storageLocation + "Download";
|
||||
var filename = "desain_depan"+id_desain+".png";
|
||||
var DataBlob = blob;
|
||||
window.resolveLocalFileSystemURL(folderpath, function(dir) {
|
||||
dir.getFile(filename, {create:true}, function(file) {
|
||||
file.createWriter(function(fileWriter) {
|
||||
fileWriter.write(DataBlob);
|
||||
toastr.options = {
|
||||
"closeButton": true,
|
||||
"debug": false,
|
||||
"progressBar": true,
|
||||
"positionClass": "toast-top-right",
|
||||
"showDuration": "300",
|
||||
"hideDuration": "1000",
|
||||
"timeOut": "5000",
|
||||
"extendedTimeOut": "1000",
|
||||
"showEasing": "swing",
|
||||
"hideEasing": "linear",
|
||||
"showMethod": "fadeIn",
|
||||
"hideMethod": "fadeOut"
|
||||
};
|
||||
|
||||
toastr.success("<center>Desain Baju Berhasil Disimpan di Folder <b><i>Download</i></b></center>");
|
||||
//Download was succesfull
|
||||
}, function(err){
|
||||
// failed
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
xhr.send();
|
||||
$.unblockUI();
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
Reference in New Issue
Block a user