|
|
@ -64,7 +64,7 @@ function getStat(){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getUser(){ |
|
|
|
function getUser(status){ |
|
|
|
token = sessionStorage.getItem("token") |
|
|
|
token = sessionStorage.getItem("token") |
|
|
|
// console.log(token)
|
|
|
|
// console.log(token)
|
|
|
|
// console.log('======== 2 ======')
|
|
|
|
// console.log('======== 2 ======')
|
|
|
@ -80,11 +80,29 @@ function getUser(){ |
|
|
|
// console.log(respone)
|
|
|
|
// console.log(respone)
|
|
|
|
userData = respone |
|
|
|
userData = respone |
|
|
|
organ = '<div>'+respone.organizations[0].name+'</div>' |
|
|
|
organ = '<div>'+respone.organizations[0].name+'</div>' |
|
|
|
|
|
|
|
|
|
|
|
document.getElementById("nameOrgan").innerHTML = organ |
|
|
|
document.getElementById("nameOrgan").innerHTML = organ |
|
|
|
token = sessionStorage.getItem("token") |
|
|
|
token = sessionStorage.getItem("token") |
|
|
|
|
|
|
|
var searchText = '' |
|
|
|
|
|
|
|
if (status === 'search'){ |
|
|
|
|
|
|
|
console.log("search") |
|
|
|
|
|
|
|
dataInstrument = [] |
|
|
|
|
|
|
|
searchText = '&search='+document.getElementById("searchId").value |
|
|
|
|
|
|
|
start = 0 |
|
|
|
|
|
|
|
$('#modalAll').html(''); |
|
|
|
|
|
|
|
$('#card').html(""); |
|
|
|
|
|
|
|
htmlText = ''; |
|
|
|
|
|
|
|
modalText = ''; |
|
|
|
|
|
|
|
dataInstrument = []; |
|
|
|
|
|
|
|
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) |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
type: "GET", |
|
|
|
type: "GET", |
|
|
|
url: 'http://www.serv.stdb.most.go.th/api/v2/instrument/?organization='+respone.organizations[0].id, |
|
|
|
url: url,
|
|
|
|
headers :{ |
|
|
|
headers :{ |
|
|
|
Authorization: 'Bearer '+ token, |
|
|
|
Authorization: 'Bearer '+ token, |
|
|
|
Accept: 'application/json, text/javascript', |
|
|
|
Accept: 'application/json, text/javascript', |
|
|
@ -100,7 +118,7 @@ function getUser(){ |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getDataStat(respone){ |
|
|
|
function getDataStat(respone){ |
|
|
|
getUser(); |
|
|
|
getUser('first'); |
|
|
|
// console.log(respone)
|
|
|
|
// console.log(respone)
|
|
|
|
document.getElementById("like").innerHTML = '0' |
|
|
|
document.getElementById("like").innerHTML = '0' |
|
|
|
document.getElementById("status").innerHTML = '+'+respone.items.recent_update
|
|
|
|
document.getElementById("status").innerHTML = '+'+respone.items.recent_update
|
|
|
@ -113,17 +131,20 @@ function getData(respone) { |
|
|
|
// console.log(dataInstrument)
|
|
|
|
// console.log(dataInstrument)
|
|
|
|
// console.log(respone)
|
|
|
|
// console.log(respone)
|
|
|
|
// console.log(respone.results)
|
|
|
|
// console.log(respone.results)
|
|
|
|
dataInstrument = dataInstrument.concat(respone.results) |
|
|
|
|
|
|
|
// console.log('****************')
|
|
|
|
|
|
|
|
console.log(dataInstrument)
|
|
|
|
console.log(dataInstrument)
|
|
|
|
var cardText = '' |
|
|
|
dataInstrument = dataInstrument.concat(respone.results) |
|
|
|
|
|
|
|
console.log('*******ฬฬฬฬฬฬฬฬฬ*********')
|
|
|
|
|
|
|
|
console.log(respone.results)
|
|
|
|
|
|
|
|
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(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()+")'>" |
|
|
|
+'<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].location+'</h3>' |
|
|
|
+'<h3 style="color:#9E9E9E;font-size:22px;margin-left:20px " >@'+dataInstrument[i].caretaker+'</h3>' |
|
|
|
+'</div>'; |
|
|
|
+'</div>'; |
|
|
|
|
|
|
|
|
|
|
|
if(dataInstrument[i].clips.length === 0){ |
|
|
|
if(dataInstrument[i].clips.length === 0){ |
|
|
@ -199,7 +220,7 @@ function getData(respone) { |
|
|
|
+'<input type="file" name="upload" onclick="uploadImage('+i.toString()+')"/>' |
|
|
|
+'<input type="file" name="upload" onclick="uploadImage('+i.toString()+')"/>' |
|
|
|
+'</div>'
|
|
|
|
+'</div>'
|
|
|
|
} |
|
|
|
} |
|
|
|
modalText = modalText+'<div id="modal'+i.toString()+'" class="modal" style="max-height: 100%;display: none;">' |
|
|
|
modalText = modalText+'<div id="modal'+i.toString()+'" class="modal" style="max-height: 100%;display: none;padding-top:10px;">' |
|
|
|
+'<div class="modal-content cardStyle" >' |
|
|
|
+'<div class="modal-content cardStyle" >' |
|
|
|
+imageTag |
|
|
|
+imageTag |
|
|
|
+'<div>' |
|
|
|
+'<div>' |
|
|
@ -234,9 +255,10 @@ function getData(respone) { |
|
|
|
document.getElementById("more").innerHTML = moreText; |
|
|
|
document.getElementById("more").innerHTML = moreText; |
|
|
|
}
|
|
|
|
}
|
|
|
|
start = dataInstrument.length |
|
|
|
start = dataInstrument.length |
|
|
|
// console.log(start)
|
|
|
|
|
|
|
|
document.getElementById("modalAll").innerHTML = document.getElementById("modalAll").innerHTML+modalText |
|
|
|
document.getElementById("modalAll").innerHTML = document.getElementById("modalAll").innerHTML+modalText |
|
|
|
document.getElementById("card").innerHTML = document.getElementById("card").innerHTML+htmlText |
|
|
|
document.getElementById("card").innerHTML = document.getElementById("card").innerHTML+htmlText |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getNextUrl(){ |
|
|
|
function getNextUrl(){ |
|
|
@ -264,7 +286,9 @@ function modalItem(idCard){ |
|
|
|
window.onclick = function(event) { |
|
|
|
window.onclick = function(event) { |
|
|
|
if (event.target == modal) { |
|
|
|
if (event.target == modal) { |
|
|
|
modal.style.display = "none"; |
|
|
|
modal.style.display = "none"; |
|
|
|
|
|
|
|
if(idCard != 'search'){ |
|
|
|
removeImage(idCard) |
|
|
|
removeImage(idCard) |
|
|
|
|
|
|
|
} |
|
|
|
dataUri = [] |
|
|
|
dataUri = [] |
|
|
|
} |
|
|
|
} |
|
|
|
}
|
|
|
|
}
|
|
|
@ -315,11 +339,17 @@ function addData(){ |
|
|
|
|
|
|
|
|
|
|
|
data = { |
|
|
|
data = { |
|
|
|
'name':document.getElementById("nameI").value, |
|
|
|
'name':document.getElementById("nameI").value, |
|
|
|
'note':document.getElementById("noteI").value, |
|
|
|
|
|
|
|
'caretaker':document.getElementById("idI").value, |
|
|
|
|
|
|
|
'instrument_id':document.getElementById("CrI").value, |
|
|
|
|
|
|
|
'organization': userData.organizations[0].id, |
|
|
|
'organization': userData.organizations[0].id, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(document.getElementById("noteI").value != ''){ |
|
|
|
|
|
|
|
data.caretaker = document.getElementById("idI").value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(document.getElementById("noteI").value != ''){ |
|
|
|
|
|
|
|
data.instrument_id = document.getElementById("CrI").value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(document.getElementById("noteI").value != ''){ |
|
|
|
|
|
|
|
data.note = document.getElementById("noteI").value |
|
|
|
|
|
|
|
} |
|
|
|
if(dataUri.length != 0){ |
|
|
|
if(dataUri.length != 0){ |
|
|
|
data.clips = dataUri |
|
|
|
data.clips = dataUri |
|
|
|
} |
|
|
|
} |
|
|
|