|
|
@ -8,8 +8,6 @@ var nextUrl = '' |
|
|
|
htmlText = '' |
|
|
|
htmlText = '' |
|
|
|
var dataUri = [] |
|
|
|
var dataUri = [] |
|
|
|
|
|
|
|
|
|
|
|
console.log('Welcome to Web STDB') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getStartPage(){ |
|
|
|
function getStartPage(){ |
|
|
|
sesToken = sessionStorage.getItem('token'); |
|
|
|
sesToken = sessionStorage.getItem('token'); |
|
|
|
if( sesToken === null){ |
|
|
|
if( sesToken === null){ |
|
|
@ -87,7 +85,7 @@ function getUser(status){ |
|
|
|
token = sessionStorage.getItem("token") |
|
|
|
token = sessionStorage.getItem("token") |
|
|
|
var searchText = '' |
|
|
|
var searchText = '' |
|
|
|
if (status === 'search'){ |
|
|
|
if (status === 'search'){ |
|
|
|
// console.log("search")
|
|
|
|
console.log("search") |
|
|
|
dataInstrument = [] |
|
|
|
dataInstrument = [] |
|
|
|
searchText = '&search='+document.getElementById("searchId").value |
|
|
|
searchText = '&search='+document.getElementById("searchId").value |
|
|
|
start = 0 |
|
|
|
start = 0 |
|
|
@ -96,12 +94,12 @@ function getUser(status){ |
|
|
|
htmlText = ''; |
|
|
|
htmlText = ''; |
|
|
|
modalText = ''; |
|
|
|
modalText = ''; |
|
|
|
dataInstrument = []; |
|
|
|
dataInstrument = []; |
|
|
|
// console.log(' >> end of search button');
|
|
|
|
console.log(' >> end of search button'); |
|
|
|
// console.log(dataInstrument)
|
|
|
|
console.log(dataInstrument) |
|
|
|
// console.log($('#card').html());
|
|
|
|
console.log($('#card').html()); |
|
|
|
} |
|
|
|
} |
|
|
|
var url = 'http://www.serv.stdb.most.go.th/api/v2/instrument/?organization='+respone.organizations[0].id+searchText; |
|
|
|
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({ |
|
|
|
$.ajax({ |
|
|
|
type: "GET", |
|
|
|
type: "GET", |
|
|
|
url: url,
|
|
|
|
url: url,
|
|
|
@ -122,7 +120,7 @@ function getUser(status){ |
|
|
|
function getDataStat(respone){ |
|
|
|
function getDataStat(respone){ |
|
|
|
getUser('first'); |
|
|
|
getUser('first'); |
|
|
|
// console.log(respone)
|
|
|
|
// console.log(respone)
|
|
|
|
document.getElementById("like").innerHTML = respone.items.completed |
|
|
|
document.getElementById("like").innerHTML = '0' |
|
|
|
document.getElementById("status").innerHTML = '+'+respone.items.recent_update
|
|
|
|
document.getElementById("status").innerHTML = '+'+respone.items.recent_update
|
|
|
|
document.getElementById("accountActive").innerHTML = respone.users.active |
|
|
|
document.getElementById("accountActive").innerHTML = respone.users.active |
|
|
|
document.getElementById("numAll").innerHTML = respone.items.all |
|
|
|
document.getElementById("numAll").innerHTML = respone.items.all |
|
|
@ -131,28 +129,35 @@ function getDataStat(respone){ |
|
|
|
|
|
|
|
|
|
|
|
function getData(respone) { |
|
|
|
function getData(respone) { |
|
|
|
// console.log(dataInstrument)
|
|
|
|
// console.log(dataInstrument)
|
|
|
|
// console.log(respone)
|
|
|
|
console.log(respone) |
|
|
|
// console.log("---------------- Next")
|
|
|
|
console.log("---------------- Next") |
|
|
|
// console.log(respone.next)
|
|
|
|
console.log(respone.next)
|
|
|
|
// console.log(respone.results)
|
|
|
|
// console.log(respone.results)
|
|
|
|
// console.log(dataInstrument)
|
|
|
|
console.log(dataInstrument)
|
|
|
|
dataInstrument = dataInstrument.concat(respone.results) |
|
|
|
dataInstrument = dataInstrument.concat(respone.results) |
|
|
|
// console.log('*******ฬฬฬฬฬฬฬฬฬ*********')
|
|
|
|
console.log('*******ฬฬฬฬฬฬฬฬฬ*********')
|
|
|
|
// console.log(respone.results)
|
|
|
|
console.log(respone.results)
|
|
|
|
var htmlText = '' |
|
|
|
var htmlText = '' |
|
|
|
var modalText = '' |
|
|
|
var modalText = '' |
|
|
|
|
|
|
|
|
|
|
|
for (i=start;i<dataInstrument.length;i++ ){ |
|
|
|
for (i=start;i<dataInstrument.length;i++ ){ |
|
|
|
// console.log('========='+i+'==========')
|
|
|
|
console.log('========='+i+'==========') |
|
|
|
// console.log(dataInstrument[i].name)
|
|
|
|
// console.log(dataInstrument[i].name)
|
|
|
|
htmlText = htmlText+"<div id='"+i.toString()+"'' class='cardStyle' onclick='modalItem("+i.toString()+")'>" |
|
|
|
htmlText = htmlText+"<div id='"+i.toString()+"'' class='cardStyle' onclick='modalItem("+i.toString()+")'>" |
|
|
|
|
|
|
|
// Author :: Apirak
|
|
|
|
|
|
|
|
+'<div class="box-left">' |
|
|
|
|
|
|
|
+'<img src="'+dataInstrument[i].clips[0].photo+'" class="cover-img">' |
|
|
|
|
|
|
|
+'</div>'// end of left
|
|
|
|
|
|
|
|
+'<div class="box-right">' |
|
|
|
+'<h3 style="font-size:26px;margin-left:20px " >'+dataInstrument[i].name+'</h3>' |
|
|
|
+'<h3 style="font-size:26px;margin-left:20px " >'+dataInstrument[i].name+'</h3>' |
|
|
|
+'<h3 style="color:#9E9E9E;font-size:22px;margin-left:20px " >#'+dataInstrument[i].custom_id+'</h3>' |
|
|
|
+'<h3 style="color:#9E9E9E;font-size:22px;margin-left:20px " >#'+dataInstrument[i].custom_id+'</h3>' |
|
|
|
+'<h3 style="color:#9E9E9E;font-size:22px;margin-left:20px " >@'+dataInstrument[i].caretaker+'</h3>' |
|
|
|
+'<h3 style="color:#9E9E9E;font-size:22px;margin-left:20px " >@'+dataInstrument[i].caretaker+'</h3>' |
|
|
|
|
|
|
|
+'</div>'// end of right
|
|
|
|
|
|
|
|
// End
|
|
|
|
+'</div>'; |
|
|
|
+'</div>'; |
|
|
|
// console.log(dataInstrument[i].clips.length)
|
|
|
|
console.log(dataInstrument[i].clips.length) |
|
|
|
if(dataInstrument[i].clips.length === 0){ |
|
|
|
if(dataInstrument[i].clips.length === 0){ |
|
|
|
// console.log('========= = 0 =========')
|
|
|
|
console.log('========= = 0 =========') |
|
|
|
imageTag = '<div class="flexCenter">' |
|
|
|
imageTag = '<div class="flexCenter">' |
|
|
|
+'<div class="flexCenter bgImage">' |
|
|
|
+'<div class="flexCenter bgImage">' |
|
|
|
+'<div class="flexCenter">' |
|
|
|
+'<div class="flexCenter">' |
|
|
@ -178,7 +183,7 @@ function getData(respone) { |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
var style4 = '' |
|
|
|
var style4 = '' |
|
|
|
if(dataInstrument[i].clips.length >= 2){ |
|
|
|
if(dataInstrument[i].clips.length >= 2){ |
|
|
|
// console.log('*********** >= 2 ***********')
|
|
|
|
console.log('*********** >= 2 ***********') |
|
|
|
var tagMiniImage = '' |
|
|
|
var tagMiniImage = '' |
|
|
|
var loopImage = dataInstrument[i].clips.length |
|
|
|
var loopImage = dataInstrument[i].clips.length |
|
|
|
if (loopImage > 4){ |
|
|
|
if (loopImage > 4){ |
|
|
@ -202,7 +207,7 @@ function getData(respone) { |
|
|
|
}
|
|
|
|
}
|
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
// console.log('*********** < 2 ***********')
|
|
|
|
console.log('*********** < 2 ***********') |
|
|
|
var tagMiniImage = '' |
|
|
|
var tagMiniImage = '' |
|
|
|
for(j=1;j<4;j++){ |
|
|
|
for(j=1;j<4;j++){ |
|
|
|
if (j==3){ |
|
|
|
if (j==3){ |
|
|
@ -318,11 +323,11 @@ function uploadImage(idImage) { |
|
|
|
$(":file").change(function () { |
|
|
|
$(":file").change(function () { |
|
|
|
if (this.files && this.files[0] && check===0) { |
|
|
|
if (this.files && this.files[0] && check===0) { |
|
|
|
var reader = new FileReader(); |
|
|
|
var reader = new FileReader(); |
|
|
|
// console.log(reader)
|
|
|
|
console.log(reader) |
|
|
|
reader.onload = function(e) { |
|
|
|
reader.onload = function(e) { |
|
|
|
instrument = dataInstrument[parseInt(idImage)] |
|
|
|
instrument = dataInstrument[parseInt(idImage)] |
|
|
|
// console.log(instrument)
|
|
|
|
console.log(instrument) |
|
|
|
// console.log('-------------xxxx-------------')
|
|
|
|
console.log('-------------xxxx-------------') |
|
|
|
var uriAdd = [{'uri':e.target.result}]; |
|
|
|
var uriAdd = [{'uri':e.target.result}]; |
|
|
|
dataUri = dataUri.concat(uriAdd); |
|
|
|
dataUri = dataUri.concat(uriAdd); |
|
|
|
if(idImage == 'add'){ |
|
|
|
if(idImage == 'add'){ |
|
|
@ -334,22 +339,22 @@ function uploadImage(idImage) { |
|
|
|
$('#myImg'+idImg+''+idImage).attr('src', dataInstrument[idImage].clips[idImg].photo); |
|
|
|
$('#myImg'+idImg+''+idImage).attr('src', dataInstrument[idImage].clips[idImg].photo); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// console.log(idImage)
|
|
|
|
console.log(idImage) |
|
|
|
var dataUriSort = dataUri |
|
|
|
var dataUriSort = dataUri |
|
|
|
idloopImage = loopImage |
|
|
|
idloopImage = loopImage |
|
|
|
if(loopImage==0){ |
|
|
|
if(loopImage==0){ |
|
|
|
idloopImage = 0 |
|
|
|
idloopImage = 0 |
|
|
|
} |
|
|
|
} |
|
|
|
var idUri = 0 |
|
|
|
var idUri = 0 |
|
|
|
// console.log(dataUri)
|
|
|
|
console.log(dataUri) |
|
|
|
// console.log(loopImage-1)
|
|
|
|
console.log(loopImage-1) |
|
|
|
// console.log(idloopImage+dataUri.length)
|
|
|
|
console.log(idloopImage+dataUri.length) |
|
|
|
for(idImg=loopImage;idImg<idloopImage+dataUri.length;idImg++){ |
|
|
|
for(idImg=loopImage;idImg<idloopImage+dataUri.length;idImg++){ |
|
|
|
$('#myImg'+idImg+''+idImage).attr('src', dataUri[idUri].uri); |
|
|
|
$('#myImg'+idImg+''+idImage).attr('src', dataUri[idUri].uri); |
|
|
|
idUri += 1 |
|
|
|
idUri += 1 |
|
|
|
} |
|
|
|
} |
|
|
|
// console.log('---------------------------')
|
|
|
|
console.log('---------------------------') |
|
|
|
// console.log(dataUri)
|
|
|
|
console.log(dataUri) |
|
|
|
check += 1 |
|
|
|
check += 1 |
|
|
|
}; |
|
|
|
}; |
|
|
|
reader.readAsDataURL(this.files[0]);
|
|
|
|
reader.readAsDataURL(this.files[0]);
|
|
|
@ -375,9 +380,9 @@ function addData(){ |
|
|
|
if(dataUri.length != 0){ |
|
|
|
if(dataUri.length != 0){ |
|
|
|
data.clips = dataUri |
|
|
|
data.clips = dataUri |
|
|
|
} |
|
|
|
} |
|
|
|
// console.log(data)
|
|
|
|
console.log(data) |
|
|
|
data = JSON.stringify(data) |
|
|
|
data = JSON.stringify(data) |
|
|
|
// console.log(data)
|
|
|
|
console.log(data) |
|
|
|
token = sessionStorage.getItem('token') |
|
|
|
token = sessionStorage.getItem('token') |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
type: "POST", |
|
|
|
type: "POST", |
|
|
@ -389,7 +394,7 @@ function addData(){ |
|
|
|
'Authorization': 'Bearer ' + token, |
|
|
|
'Authorization': 'Bearer ' + token, |
|
|
|
}, |
|
|
|
}, |
|
|
|
success: function(respone){ |
|
|
|
success: function(respone){ |
|
|
|
// console.log(respone)
|
|
|
|
console.log(respone) |
|
|
|
window.location.reload(true); |
|
|
|
window.location.reload(true); |
|
|
|
}, |
|
|
|
}, |
|
|
|
dataType: 'json' |
|
|
|
dataType: 'json' |
|
|
@ -397,10 +402,10 @@ function addData(){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function updateData(idData){ |
|
|
|
function updateData(idData){ |
|
|
|
// console.log(document.getElementById("name"+idData))
|
|
|
|
console.log(document.getElementById("name"+idData)) |
|
|
|
// console.log(document.getElementById("note"+idData))
|
|
|
|
console.log(document.getElementById("note"+idData)) |
|
|
|
// console.log(document.getElementById("id"+idData))
|
|
|
|
console.log(document.getElementById("id"+idData)) |
|
|
|
// console.log(document.getElementById("cr"+idData))
|
|
|
|
console.log(document.getElementById("cr"+idData)) |
|
|
|
dataUpdate = { |
|
|
|
dataUpdate = { |
|
|
|
'name':document.getElementById("name"+idData).value, |
|
|
|
'name':document.getElementById("name"+idData).value, |
|
|
|
'note':document.getElementById("note"+idData).value, |
|
|
|
'note':document.getElementById("note"+idData).value, |
|
|
@ -421,7 +426,7 @@ function updateData(idData){ |
|
|
|
'Authorization': 'Bearer ' + token, |
|
|
|
'Authorization': 'Bearer ' + token, |
|
|
|
}, |
|
|
|
}, |
|
|
|
success: function(respone){ |
|
|
|
success: function(respone){ |
|
|
|
// console.log(respone)
|
|
|
|
console.log(respone) |
|
|
|
window.location.reload(true); |
|
|
|
window.location.reload(true); |
|
|
|
}, |
|
|
|
}, |
|
|
|
dataType: 'json' |
|
|
|
dataType: 'json' |
|
|
@ -442,7 +447,7 @@ function deleteData(idData){ |
|
|
|
'Authorization': 'Bearer ' + token, |
|
|
|
'Authorization': 'Bearer ' + token, |
|
|
|
}, |
|
|
|
}, |
|
|
|
success: function(respone){ |
|
|
|
success: function(respone){ |
|
|
|
// console.log(respone)
|
|
|
|
console.log(respone) |
|
|
|
window.location.reload(true); |
|
|
|
window.location.reload(true); |
|
|
|
}, |
|
|
|
}, |
|
|
|
dataType: 'json' |
|
|
|
dataType: 'json' |
|
|
@ -465,12 +470,12 @@ function removeImage(idData){ |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
var time = new Date() |
|
|
|
var time = new Date() |
|
|
|
var loopImage = dataInstrument[idData].clips.length |
|
|
|
var loopImage = dataInstrument[idData].clips.length |
|
|
|
// console.log(dataInstrument[idData])
|
|
|
|
console.log(dataInstrument[idData]) |
|
|
|
for(j=0;j<loopImage;j++){ |
|
|
|
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; |
|
|
|
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).src) |
|
|
|
// console.log(document.getElementById("myImg"+j+''+idData))
|
|
|
|
console.log(document.getElementById("myImg"+j+''+idData)) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}
|
|
|
|
}
|
|
|
|