|
|
|
@ -85,7 +85,7 @@ function getUser(status){
|
|
|
|
|
token = sessionStorage.getItem("token") |
|
|
|
|
var searchText = '' |
|
|
|
|
if (status === 'search'){ |
|
|
|
|
console.log("search") |
|
|
|
|
// console.log("search")
|
|
|
|
|
dataInstrument = [] |
|
|
|
|
searchText = '&search='+document.getElementById("searchId").value |
|
|
|
|
start = 0 |
|
|
|
@ -94,12 +94,12 @@ function getUser(status){
|
|
|
|
|
htmlText = ''; |
|
|
|
|
modalText = ''; |
|
|
|
|
dataInstrument = []; |
|
|
|
|
console.log(' >> end of search button'); |
|
|
|
|
console.log(dataInstrument) |
|
|
|
|
console.log($('#card').html()); |
|
|
|
|
// console.log(' >> end of search button');
|
|
|
|
|
// console.log(dataInstrument)
|
|
|
|
|
// console.log($('#card').html());
|
|
|
|
|
} |
|
|
|
|
var url = 'http://www.serv.stdb.most.go.th/api/v2/instrument/?organization='+respone.organizations[0].id+searchText; |
|
|
|
|
console.log('url = ' + url) |
|
|
|
|
// console.log('url = ' + url)
|
|
|
|
|
$.ajax({ |
|
|
|
|
type: "GET", |
|
|
|
|
url: url,
|
|
|
|
@ -141,7 +141,7 @@ function getData(respone) {
|
|
|
|
|
var modalText = '' |
|
|
|
|
|
|
|
|
|
for (i=start;i<dataInstrument.length;i++ ){ |
|
|
|
|
console.log('========='+i+'==========') |
|
|
|
|
// console.log('========='+i+'==========')
|
|
|
|
|
// console.log(dataInstrument[i].name)
|
|
|
|
|
var imageInstrument = '' |
|
|
|
|
if (dataInstrument[i].clips.length != 0) { |
|
|
|
@ -160,9 +160,9 @@ function getData(respone) {
|
|
|
|
|
+'</div>'// end of right
|
|
|
|
|
// End
|
|
|
|
|
+'</div>'; |
|
|
|
|
console.log(dataInstrument[i].clips.length) |
|
|
|
|
// console.log(dataInstrument[i].clips.length)
|
|
|
|
|
if(dataInstrument[i].clips.length === 0){ |
|
|
|
|
console.log('========= = 0 =========') |
|
|
|
|
// console.log('========= = 0 =========')
|
|
|
|
|
imageTag = '<div class="flexCenter">' |
|
|
|
|
+'<div class="flexCenter bgImage">' |
|
|
|
|
+'<div class="flexCenter">' |
|
|
|
@ -188,7 +188,7 @@ function getData(respone) {
|
|
|
|
|
else{ |
|
|
|
|
var style4 = '' |
|
|
|
|
if(dataInstrument[i].clips.length >= 2){ |
|
|
|
|
console.log('*********** >= 2 ***********') |
|
|
|
|
// console.log('*********** >= 2 ***********')
|
|
|
|
|
var tagMiniImage = '' |
|
|
|
|
var loopImage = dataInstrument[i].clips.length |
|
|
|
|
if (loopImage > 4){ |
|
|
|
@ -212,7 +212,7 @@ function getData(respone) {
|
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
console.log('*********** < 2 ***********') |
|
|
|
|
// console.log('*********** < 2 ***********')
|
|
|
|
|
var tagMiniImage = '' |
|
|
|
|
for(j=1;j<4;j++){ |
|
|
|
|
if (j==3){ |
|
|
|
@ -328,11 +328,11 @@ function uploadImage(idImage) {
|
|
|
|
|
$(":file").change(function () { |
|
|
|
|
if (this.files && this.files[0] && check===0) { |
|
|
|
|
var reader = new FileReader(); |
|
|
|
|
console.log(reader) |
|
|
|
|
// console.log(reader)
|
|
|
|
|
reader.onload = function(e) { |
|
|
|
|
instrument = dataInstrument[parseInt(idImage)] |
|
|
|
|
console.log(instrument) |
|
|
|
|
console.log('-------------xxxx-------------') |
|
|
|
|
// console.log(instrument)
|
|
|
|
|
// console.log('-------------xxxx-------------')
|
|
|
|
|
var uriAdd = [{'uri':e.target.result}]; |
|
|
|
|
dataUri = dataUri.concat(uriAdd); |
|
|
|
|
if(idImage == 'add'){ |
|
|
|
@ -344,22 +344,22 @@ function uploadImage(idImage) {
|
|
|
|
|
$('#myImg'+idImg+''+idImage).attr('src', dataInstrument[idImage].clips[idImg].photo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
console.log(idImage) |
|
|
|
|
// console.log(idImage)
|
|
|
|
|
var dataUriSort = dataUri |
|
|
|
|
idloopImage = loopImage |
|
|
|
|
if(loopImage==0){ |
|
|
|
|
idloopImage = 0 |
|
|
|
|
} |
|
|
|
|
var idUri = 0 |
|
|
|
|
console.log(dataUri) |
|
|
|
|
console.log(loopImage-1) |
|
|
|
|
console.log(idloopImage+dataUri.length) |
|
|
|
|
// console.log(dataUri)
|
|
|
|
|
// console.log(loopImage-1)
|
|
|
|
|
// console.log(idloopImage+dataUri.length)
|
|
|
|
|
for(idImg=loopImage;idImg<idloopImage+dataUri.length;idImg++){ |
|
|
|
|
$('#myImg'+idImg+''+idImage).attr('src', dataUri[idUri].uri); |
|
|
|
|
idUri += 1 |
|
|
|
|
} |
|
|
|
|
console.log('---------------------------') |
|
|
|
|
console.log(dataUri) |
|
|
|
|
// console.log('---------------------------')
|
|
|
|
|
// console.log(dataUri)
|
|
|
|
|
check += 1 |
|
|
|
|
}; |
|
|
|
|
reader.readAsDataURL(this.files[0]);
|
|
|
|
@ -399,7 +399,7 @@ function addData(){
|
|
|
|
|
'Authorization': 'Bearer ' + token, |
|
|
|
|
}, |
|
|
|
|
success: function(respone){ |
|
|
|
|
console.log(respone) |
|
|
|
|
// console.log(respone)
|
|
|
|
|
window.location.reload(true); |
|
|
|
|
}, |
|
|
|
|
dataType: 'json' |
|
|
|
@ -431,7 +431,7 @@ function updateData(idData){
|
|
|
|
|
'Authorization': 'Bearer ' + token, |
|
|
|
|
}, |
|
|
|
|
success: function(respone){ |
|
|
|
|
console.log(respone) |
|
|
|
|
// console.log(respone)
|
|
|
|
|
window.location.reload(true); |
|
|
|
|
}, |
|
|
|
|
dataType: 'json' |
|
|
|
@ -452,7 +452,7 @@ function deleteData(idData){
|
|
|
|
|
'Authorization': 'Bearer ' + token, |
|
|
|
|
}, |
|
|
|
|
success: function(respone){ |
|
|
|
|
console.log(respone) |
|
|
|
|
// console.log(respone)
|
|
|
|
|
window.location.reload(true); |
|
|
|
|
}, |
|
|
|
|
dataType: 'json' |
|
|
|
@ -475,12 +475,12 @@ function removeImage(idData){
|
|
|
|
|
else{ |
|
|
|
|
var time = new Date() |
|
|
|
|
var loopImage = dataInstrument[idData].clips.length |
|
|
|
|
console.log(dataInstrument[idData]) |
|
|
|
|
// console.log(dataInstrument[idData])
|
|
|
|
|
for(j=0;j<loopImage;j++){ |
|
|
|
|
console.log('#myImg'+j+''+idData) |
|
|
|
|
// console.log('#myImg'+j+''+idData)
|
|
|
|
|
document.getElementById("myImg"+j+''+idData).src = dataInstrument[idData].clips[j].photo+'?'+time; |
|
|
|
|
console.log(document.getElementById("myImg"+j+''+idData).src) |
|
|
|
|
console.log(document.getElementById("myImg"+j+''+idData)) |
|
|
|
|
// console.log(document.getElementById("myImg"+j+''+idData).src)
|
|
|
|
|
// console.log(document.getElementById("myImg"+j+''+idData))
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}
|
|
|
|
|