You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.0 KiB
JavaScript

ajaxing = false;
var looprouter = function(){
if(ajaxing){return;}
var expresstype = $('[name=expresstype]:checked').val();
var keySN = $('#epresssn').val();
if(expresstype.length<1){return;}
var Eurl = '/api/api.php?method=express.'+expresstype+'&sn='+keySN+'&'+Math.random();
if(keySN.length != 12){return;}
if(expresstype == 'sf'){
$.ajax({
url:Eurl,
dataType:'json',
beforeSend:function(){ $('#sfRouter').find("ul").html('Loading.....').end().show();ajaxing = true;},
complete:function(){ajaxing = false; },
success:function(results){
if(results.length>0){
result = results[0];
$('#sfRouter>ul').html('');
if(result.id){
for(var i=0;i< result.routes.length;i++){
time = result.routes[i].scanDateTime;
time = time.replace("T","&nbsp;");
time = time.replace("+0800","&nbsp;");
string = "<li><div><i "+((i===(result.routes.length-1))?' style="background-position: 0 0;" ':'')+"></i></div>"+ time +result.routes[i].remark+"</li>";
$('#sfRouter>ul').prepend(string);
}
}else{
$('#sfRouter>ul').html('Sorry! There aren\'t any result!');
}
}else{
$('#sfRouter>ul').html('Sorry! There aren\'t any result!');
}
}
});
}else if(expresstype == 'sto'){
$.ajax({
url:Eurl,
dataType:'json',
beforeSend:function(){ $('#sfRouter').find("ul").html('Loading.....').end().show();ajaxing = true;},
complete:function(){ajaxing = false; },
success:function(result){
if(result.length>0){
$('#sfRouter>ul').html('');
for(var i=0;i< result.length;i++){
time = result[i].time;
string = "<li><div><i "+((i===0)?' style="background-position: 0 0;" ':'')+"></i></div>"+
time +'<br/>'+result[i].EnContext+'<br/>'+result[i].context+"</li>";
$('#sfRouter>ul').append(string);
}
}else{
$('#sfRouter>ul').html('Sorry! There aren\'t any result!');
}
}
});
}else{
}
}
$(function(){$('#epresssn').keyup(looprouter);});