Browse Source

0.0.2.22.6

master
racha.non 9 years ago
parent
commit
be97eba104
  1. 149
      js/stdb.js

149
js/stdb.js

@ -146,63 +146,68 @@ function getData(respone) {
+'<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>'; +'</div>';
console.log(dataInstrument[i].clips.length)
if(dataInstrument[i].clips.length === 0){ if(dataInstrument[i].clips.length === 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">'
+'<img id="myImg0'+i+'" src="" alt=""/>' +'<img id="myImg0'+i+'" src="" alt=""/>'
+'<div class="bgImage flexCenter"><h2>ไมปภาพ</h2></div>' +'<div class="bgImage flexCenter"><h2>ไมปภาพ</h2></div>'
+'</div>' +'</div>'
+'<div class="column bgMiniImage" style="margin-left:10px">' +'<div class="column bgMiniImage" style="margin-left:10px">'
+'<img id="myImg1'+i+'" class="miniImage" src="" alt=""/>' +'<img id="myImg1'+i+'" class="miniImage" src="" alt=""/>'
+'<h6 class="miniImage flexCenter" >ไมปภาพ</h6>' +'<h6 class="miniImage flexCenter" >ไมปภาพ</h6>'
+'<img id="myImg2'+i+'" class="miniImage" src="" alt=""/>' +'<img id="myImg2'+i+'" class="miniImage" src="" alt=""/>'
+'<h6 class="miniImage flexCenter" >ไมปภาพ</h6>' +'<h6 class="miniImage flexCenter" >ไมปภาพ</h6>'
+'<img id="myImg3'+i+'" class="miniImage" style="margin-top:5px" src="" alt=""/>' +'<img id="myImg3'+i+'" class="miniImage" style="margin-top:5px" src="" alt=""/>'
+'<h6 class="miniImage flexCenter" style="margin-top:5px">ไมปภาพ</h6>' +'<h6 class="miniImage flexCenter" style="margin-top:5px">ไมปภาพ</h6>'
+'</div>' +'</div>'
+'</div>' +'</div>'
+'</div>' +'</div>'
+'<div class="flexCenter" style="margin-top:5px;">' +'<div class="flexCenter" style="margin-top:5px;">'
+'<div class="upload flexCenter">' +'<div class="upload flexCenter">'
+'<a style="font-size:18px">Upload</a></div>' +'<a style="font-size:18px">Upload</a></div>'
+'<input type="file" name="upload" onclick="uploadImage('+i.toString()+')"/>' +'<input type="file" name="upload" onclick="uploadImage('+i.toString()+')"/>'
+'</div>' +'</div>'
} }
else{ else{
if(dataInstrument[i].clips.length > 1){ var style4 = ''
if(dataInstrument[i].clips.length >= 2){
console.log('*********** >= 2 ***********')
var tagMiniImage = '' var tagMiniImage = ''
var loopImage = dataInstrument[i].clips.length var loopImage = dataInstrument[i].clips.length1
var style4 = '' for(j=1;j<loopImage;j++){
for(j=1;j<loopImage-1;j++){
if (j==3){ if (j==3){
style4 = 'style="margin-top:5px"' style4 = 'margin-top:5px'
} }
tagMiniImage = tagMiniImage tagMiniImage = tagMiniImage
+'<img id="myImg'+j+''+i+'" class="miniImage" '+style4+' src="'+dataInstrument[i].clips[j].photo+'" alt=""/>' +'<img id="myImg'+j+''+i+'" class="miniImage" style="'+style4+'" src="'+dataInstrument[i].clips[j].photo+'" alt=""/>'
+'<h6 class="miniImage flexCenter" ></h6>'; +'<h6 class="miniImage flexCenter" ></h6>';
} }
for(j=loopImage-1;j<3;j++){ for(j=loopImage+1;j<3;j++){
if (j==3){ if (j==3){
style4 = 'style="margin-top:5px"' style4 = 'margin-top:5px'
} }
tagMiniImage = tagMiniImage tagMiniImage = tagMiniImage
+'<img id="myImg'+j+''+i+'" class="miniImage" '+style4+' src="" alt=""/>' +'<img id="myImg'+j+''+i+'" class="miniImage" style="'+style4+'" src="" alt=""/>'
+'<h6 class="miniImage flexCenter" >ไมปภาพ</h6>'; +'<h6 class="miniImage flexCenter" >ไมปภาพ</h6>';
} }
} }
else{ else{
console.log('*********** < 2 ***********')
var tagMiniImage = ''
for(j=1;j<4;j++){ for(j=1;j<4;j++){
if (j==3){ if (j==3){
style4 = 'style="margin-top:5px"' style4 = 'margin-top:5px'
} }
tagMiniImage = tagMiniImage tagMiniImage = tagMiniImage
+'<img id="myImg'+j+''+i+'" class="miniImage" '+style4+' src="" alt=""/>' +'<img id="myImg'+j+''+i+'" class="miniImage" style="'+style4+'" src="" alt=""/>'
+'<h6 class="miniImage flexCenter" >ไมปภาพ</h6>'; +'<h6 class="miniImage flexCenter" >ไมปภาพ</h6>';
} }
} }
console.log(dataInstrument)
imageTag = '<div class="flexCenter">' imageTag = '<div class="flexCenter">'
+'<div class="flexCenter bgImage">' +'<div class="flexCenter bgImage">'
+'<div class="flexCenter">' +'<div class="flexCenter">'
@ -219,33 +224,33 @@ function getData(respone) {
+'<a style="font-size:18px">Upload</a></div>' +'<a style="font-size:18px">Upload</a></div>'
+'<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;padding-top:10px;">' 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>'
+'<div style="font-size:20px;margin-top:20px">ชอครณฑทยาศาสตร</div>' +'<div style="font-size:20px;margin-top:20px">ชอครณฑทยาศาสตร</div>'
+'<div style="font-size:16px;margin-top:5px;margin-left:5px"><input type="text" id="name'+i+'" name="name'+i+'" placeholder="เลขครณฑ" value="'+dataInstrument[i].name+'"></div>' +'<div style="font-size:16px;margin-top:5px;margin-left:5px"><input type="text" id="name'+i+'" name="name'+i+'" placeholder="เลขครณฑ" value="'+dataInstrument[i].name+'"></div>'
+'</div>' +'</div>'
+'<div>' +'<div>'
+'<div style="font-size:20px;margin-top:20px">จดประสงคการใชงาน</div>' +'<div style="font-size:20px;margin-top:20px">จดประสงคการใชงาน</div>'
+'<div style="font-size:16px;margin-top:5px;margin-left:5px"><input type="text" id="note'+i+'" name="note'+i+'" placeholder="เลขครณฑ" value="'+dataInstrument[i].note+'"></div>' +'<div style="font-size:16px;margin-top:5px;margin-left:5px"><input type="text" id="note'+i+'" name="note'+i+'" placeholder="เลขครณฑ" value="'+dataInstrument[i].note+'"></div>'
+'</div>'
+'<div>'
+'<div style="font-size:20px;margin-top:20px">เลขครณฑ</div>'
+'<div style="font-size:16px;margin-top:5px;margin-left:5px"><input type="text" id="id'+i+'" name="id'+i+'" placeholder="เลขครณฑ" value="'+dataInstrument[i].custom_id+'"></div>'
+'</div>'
+'<div>'
+'<div style="font-size:20px;margin-top:20px">ผแล</div>'
+'<div style="font-size:16px;margin-top:5px;margin-left:5px"><input type="text" id="cr'+i+'" name="cr'+i+'" placeholder="เลขครณฑ" value="'+dataInstrument[i].caretaker+'"></div>'
+'</div>'
+'<div class="flexCenterSpace" style="margin-top:20px">'
+'<input type="button" onclick="updateData('+i+')" class="buttonUpdate" value="Update">'
+'<input type="button" onclick="deleteData('+i+')" class="buttonDelete "value="Delete">'
+'<input type="button" onclick="backData('+i+')" class="buttonBack" value="Back">'
+'</div>'
+'</div>' +'</div>'
+'</div>'; +'<div>'
+'<div style="font-size:20px;margin-top:20px">เลขครณฑ</div>'
+'<div style="font-size:16px;margin-top:5px;margin-left:5px"><input type="text" id="id'+i+'" name="id'+i+'" placeholder="เลขครณฑ" value="'+dataInstrument[i].custom_id+'"></div>'
+'</div>'
+'<div>'
+'<div style="font-size:20px;margin-top:20px">ผแล</div>'
+'<div style="font-size:16px;margin-top:5px;margin-left:5px"><input type="text" id="cr'+i+'" name="cr'+i+'" placeholder="เลขครณฑ" value="'+dataInstrument[i].caretaker+'"></div>'
+'</div>'
+'<div class="flexCenterSpace" style="margin-top:20px">'
+'<input type="button" onclick="updateData('+i+')" class="buttonUpdate" value="Update">'
+'<input type="button" onclick="deleteData('+i+')" class="buttonDelete "value="Delete">'
+'<input type="button" onclick="backData('+i+')" class="buttonBack" value="Back">'
+'</div>'
+'</div>'
+'</div>';
} }
if(respone.next != null){ if(respone.next != null){
moreText = "<div class='cardStyle flexCenter' style='margin-bottom:10px;height:60px;background-color: #E0E0E0;' onClick='getNextUrl()'>" moreText = "<div class='cardStyle flexCenter' style='margin-bottom:10px;height:60px;background-color: #E0E0E0;' onClick='getNextUrl()'>"
@ -302,6 +307,8 @@ function uploadImage(idImage) {
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('-------------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'){
@ -310,7 +317,7 @@ function uploadImage(idImage) {
else{ else{
var loopImage = instrument.clips.length var loopImage = instrument.clips.length
for(idImg=0;idImg<loopImage;idImg++){ for(idImg=0;idImg<loopImage;idImg++){
$('#myImg'+idImg+''+idImage).attr('src', dataInstrument[idData].clips[idImg].photo); $('#myImg'+idImg+''+idImage).attr('src', dataInstrument[idImage].clips[idImg].photo);
} }
} }
console.log(idImage) console.log(idImage)
@ -321,8 +328,10 @@ function uploadImage(idImage) {
idloopImage = 0 idloopImage = 0
} }
var idUri = 0 var idUri = 0
console.log(dataUri)
console.log(loopImage-1) console.log(loopImage-1)
for(idImg=loopImage-1;idImg<idloopImage+dataUri.length;idImg++){ console.log(idloopImage+dataUri.length)
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
} }
@ -441,12 +450,18 @@ function removeImage(idData){
loopImage = 1 loopImage = 1
} }
else{ else{
var time = new Date()
var loopImage = dataInstrument[idData].clips.length var loopImage = dataInstrument[idData].clips.length
console.log(dataInstrument[idData])
for(j=0;j<loopImage;j++){ for(j=0;j<loopImage;j++){
$('#myImg'+j+''+idData).attr('src', loopImage[j]); 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))
} }
} }
for(j=loopImage-1;j<4;j++){ for(j=loopImage;j<4;j++){
$('#myImg'+j+''+idData).attr('src',''); $('#myImg'+j+''+idData).attr('src','');
} }
} }

Loading…
Cancel
Save