|
|
|
@ -8,8 +8,6 @@ var nextUrl = ''
|
|
|
|
|
htmlText = '' |
|
|
|
|
var dataUri = [] |
|
|
|
|
|
|
|
|
|
console.log('Welcome to Web STDB') |
|
|
|
|
|
|
|
|
|
function getStartPage(){ |
|
|
|
|
sesToken = sessionStorage.getItem('token'); |
|
|
|
|
if( sesToken === null){ |
|
|
|
@ -87,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 |
|
|
|
@ -96,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,
|
|
|
|
@ -122,7 +120,7 @@ function getUser(status){
|
|
|
|
|
function getDataStat(respone){ |
|
|
|
|
getUser('first'); |
|
|
|
|
// 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("accountActive").innerHTML = respone.users.active |
|
|
|
|
document.getElementById("numAll").innerHTML = respone.items.all |
|
|
|
@ -131,28 +129,35 @@ function getDataStat(respone){
|
|
|
|
|
|
|
|
|
|
function getData(respone) { |
|
|
|
|
// console.log(dataInstrument)
|
|
|
|
|
// console.log(respone)
|
|
|
|
|
// console.log("---------------- Next")
|
|
|
|
|
// console.log(respone.next)
|
|
|
|
|
console.log(respone) |
|
|
|
|
console.log("---------------- Next") |
|
|
|
|
console.log(respone.next)
|
|
|
|
|
// console.log(respone.results)
|
|
|
|
|
// console.log(dataInstrument)
|
|
|
|
|
console.log(dataInstrument)
|
|
|
|
|
dataInstrument = dataInstrument.concat(respone.results) |
|
|
|
|
// console.log('*******ฬฬฬฬฬฬฬฬฬ*********')
|
|
|
|
|
// console.log(respone.results)
|
|
|
|
|
console.log('*******ฬฬฬฬฬฬฬฬฬ*********')
|
|
|
|
|
console.log(respone.results)
|
|
|
|
|
var htmlText = '' |
|
|
|
|
var modalText = '' |
|
|
|
|
|
|
|
|
|
for (i=start;i<dataInstrument.length;i++ ){ |
|
|
|
|
// console.log('========='+i+'==========')
|
|
|
|
|
console.log('========='+i+'==========') |
|
|
|
|
// console.log(dataInstrument[i].name)
|
|
|
|
|
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="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>' |
|
|
|
|
+'</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">' |
|
|
|
@ -178,7 +183,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){ |
|
|
|
@ -202,7 +207,7 @@ function getData(respone) {
|
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
// console.log('*********** < 2 ***********')
|
|
|
|
|
console.log('*********** < 2 ***********') |
|
|
|
|
var tagMiniImage = '' |
|
|
|
|
for(j=1;j<4;j++){ |
|
|
|
|
if (j==3){ |
|
|
|
@ -318,11 +323,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'){ |
|
|
|
@ -334,22 +339,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]);
|
|
|
|
@ -375,9 +380,9 @@ function addData(){
|
|
|
|
|
if(dataUri.length != 0){ |
|
|
|
|
data.clips = dataUri |
|
|
|
|
} |
|
|
|
|
// console.log(data)
|
|
|
|
|
console.log(data) |
|
|
|
|
data = JSON.stringify(data) |
|
|
|
|
// console.log(data)
|
|
|
|
|
console.log(data) |
|
|
|
|
token = sessionStorage.getItem('token') |
|
|
|
|
$.ajax({ |
|
|
|
|
type: "POST", |
|
|
|
@ -389,7 +394,7 @@ function addData(){
|
|
|
|
|
'Authorization': 'Bearer ' + token, |
|
|
|
|
}, |
|
|
|
|
success: function(respone){ |
|
|
|
|
// console.log(respone)
|
|
|
|
|
console.log(respone) |
|
|
|
|
window.location.reload(true); |
|
|
|
|
}, |
|
|
|
|
dataType: 'json' |
|
|
|
@ -397,10 +402,10 @@ function addData(){
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function updateData(idData){ |
|
|
|
|
// console.log(document.getElementById("name"+idData))
|
|
|
|
|
// console.log(document.getElementById("note"+idData))
|
|
|
|
|
// console.log(document.getElementById("id"+idData))
|
|
|
|
|
// console.log(document.getElementById("cr"+idData))
|
|
|
|
|
console.log(document.getElementById("name"+idData)) |
|
|
|
|
console.log(document.getElementById("note"+idData)) |
|
|
|
|
console.log(document.getElementById("id"+idData)) |
|
|
|
|
console.log(document.getElementById("cr"+idData)) |
|
|
|
|
dataUpdate = { |
|
|
|
|
'name':document.getElementById("name"+idData).value, |
|
|
|
|
'note':document.getElementById("note"+idData).value, |
|
|
|
@ -421,7 +426,7 @@ function updateData(idData){
|
|
|
|
|
'Authorization': 'Bearer ' + token, |
|
|
|
|
}, |
|
|
|
|
success: function(respone){ |
|
|
|
|
// console.log(respone)
|
|
|
|
|
console.log(respone) |
|
|
|
|
window.location.reload(true); |
|
|
|
|
}, |
|
|
|
|
dataType: 'json' |
|
|
|
@ -442,7 +447,7 @@ function deleteData(idData){
|
|
|
|
|
'Authorization': 'Bearer ' + token, |
|
|
|
|
}, |
|
|
|
|
success: function(respone){ |
|
|
|
|
// console.log(respone)
|
|
|
|
|
console.log(respone) |
|
|
|
|
window.location.reload(true); |
|
|
|
|
}, |
|
|
|
|
dataType: 'json' |
|
|
|
@ -465,12 +470,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)) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}
|
|
|
|
|