var numAll = '' var numPhoto = '' var token = '' var userData var dataInstrument = [] var start = 0 var nextUrl = '' htmlText = '' var dataUri = [] function getStartPage(){ sesToken = sessionStorage.getItem('token'); if( sesToken === null){ token = localStorage.getItem("token") // console.log(token) // console.log('==================') if( token != null ){ $.ajax({ type: "POST", url: 'http://www.serv.stdb.most.go.th/api-token-verify/', data: { "token" : token }, header: { Authorization: 'Bearer '+ token, }, success: function(respone){ sessionStorage.setItem("token",respone.token) getStat(); }, dataType: 'json' }); } else{ window.location.href = 'login.html' } } else{ getStat(); } } function LogoutPage(){ localStorage.removeItem('token'); sessionStorage.removeItem('token'); window.location.href = 'index.html' } function getStat(){ token = sessionStorage.getItem("token") // console.log(token) // console.log('======== 2 ======') dataUser = jwt_decode(token) userId = dataUser.user_id if( token != null ){ $.ajax({ type: "GET", url: 'http://www.serv.stdb.most.go.th/api/v2/instrument/stats/', headers :{ Authorization: 'Bearer '+ token, }, success: getDataStat, dataType: 'json', }); } } function getUser(status){ token = sessionStorage.getItem("token") // console.log(token) // console.log('======== 2 ======') dataUser = jwt_decode(token) userId = dataUser.user_id.toString() $.ajax({ type: "GET", url: 'http://www.serv.stdb.most.go.th/api/v2/user/'+userId+'/', headers :{ Authorization: 'Bearer '+ token, }, success: function(respone){ // console.log(respone) userData = respone organ = '