tracking number, seguimiento de envios desde china 
Tuesday, November 27, 2012, 05:29 AM - General
script para saber que esta pasando con los paquetes que nos envian desdde china, algunas veces la pagina del correo chino tiene problemas y no aparece la informacion, tengan paciencia y esperen a que se restablesca la pagina
El texto informativo se muestra en el idioma de donde se encuenta el paquete en ese momento, para eso tenemos a google que nos permitira traducir de chino a español, para ir a la herramienta de seguimiento de envios, click en el enlace de abajo





Para los que quieran imlplementarlo en su pagina web, mas abajo pongo el codigo



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>International Parcel Tracking</title>
<script src="http://www.sao.cn/js/jquery/jquery-1.5.1.min.js" type="text/javascript"></script>
<style type="text/css">
body {
text-align:center;
background-color:#FFFFFF;
}
body,td,th,table,.style0 {
font-size: 14px;
color: #1167A5;
}
.maintable{
border-collapse:collapse;
background-color:#FFFFFF;
width:62%;
}
.maintable tbody tr td{
padding:3px;
border:1px solid #1167A5;
height:23px;
valign:top;
}
.detailtable{
background-color:#FFFFFF;
border-collapse:collapse;
width:100%;
}
.detailtable tbody tr td{
padding:3px;
border:1px solid #1167A5;
}

.barpanel {
background-color:#3FAEE6;
}
.bartitle {
color: #FFFFFF;
font-weight: bold;
}
.mailstatus {
color: #1CA93E
}
</style>
</head>


<body>
<b><font color="#1167A5" size="3">Parcel Tracking</font></b>

<table class="maintable" align="center">
<tbody>
<tr>
<td colspan="2" class="barpanel">
<span class="bartitle">Shipment Summary</span>
</td>
</tr>
<tr>
<td width="13%" align="right">Shipment Number:</td>
<td id="mailNo" width="60%" align="left">&nbsp;</td>
</tr>
<tr>
<td nowrap="nowrap" align="right">Origin:</td>
<td id="srcName" nowrap="nowrap" align="left">&nbsp;</td>
</tr>
<tr>
<td nowrap="nowrap" align="right">Destination:</td>
<td id="dstName" nowrap="nowrap" align="left">&nbsp;</td>
</tr>
<tr>
<td nowrap="nowrap" align="right">Parcel Status:</td>
<td nowrap="nowrap" align="left">
<div align="left"><span class="mailstatus" id="mailStatus">&nbsp;</span></div>
</td>
</tr>
<tr>
<td nowrap="nowrap" align="right">Query Status:</td>
<td nowrap="nowrap" align="left">
<div align="left"><span id="queryStatus">&nbsp;</span></div>
</td>
</tr>
<tr>
<td nowrap="nowrap" align="right">Query Time:</td>
<td nowrap="nowrap" align="left"><span id="waittime">0</span> seconds</td>
</tr>
<tr>
<td colspan="2" class="barpanel" valign="middle" align="center" >
<p><span class="bartitle">Shipment Details</span></p>
</td>
</tr>
<tr>
<td colspan="2" align="right">

<table class="detailtable">
<tbody>
<tr>
<td width="131" align="center"><p>Date</p></td>
<td width="281" align="center">Activity</td>
<td width="150" align="center">Location</td>
</tr>
</tbody>
<tbody id="row-record" style="display:none">
<tr>
<td width="131" align="center">{datetime}</td>
<td width="281" align="center">{content}<br></td>
<td width="150" align="center">{location}</td>
</tr>
</tbody>
<tbody id="msg-record" style="display:none">
<tr>
<td colspan="3" align="center">{content}<br></td>
</tr>
</tbody>
<tbody id="track-info">
</tbody>
</table>

</td>
</tr>

</tbody></table>

<br/>
<input type="text" value="Shipment Number" class="style0" onfocus="if(this.value='Shipment Number') this.value=''" id="itemid" class="input_track" name="itemid"/>&nbsp;
<input type="button" value="track" id="trackbtn" class="style0" onclick="track($('#itemid').val())" disabled/>

<p style="height:30px"></p>
<hr size="1">

<span style="display:none;">
<!-- don't delete current segment codes -->
<a href="http://www.alexa.com/siteinfo/www.sao.cn">
<script type="text/javascript" language='JavaScript' src='http://xslt.alexa.com/site_stats/js/t/a?url=www.sao.cn'></script>
</a>
</span>

<script>
var script_segment = null;
String.prototype.replaceAll = function(s1,s2)
{
return this.replace(new RegExp(s1, "gm"), s2);
}
String.prototype.trim=function()
{
return this.replace(/(^\s*)(\s*$)/g, "");
}

function callback_render(result){
$("#track-info").empty();
$("#trackbtn").removeAttr("disabled");

if(result.length<=0){
newMsg("<font color=red>Sorry, Not found. </font>");
return;
}

var json = result;
$(json).each(function(z, data){

$("#mailNo").text(data["mailNo"]);
$("#mailStatus").text(data["mailStatus"]);
$("#queryStatus").text(data["queryStatus"]);
$("#dstName").text(data["dstName"]);
$("#srcName").text(data["srcName"]);
$("#waittime").text(data["waittime"]/1000);

if(data["srcName"]!=null && data["srcName"]!=""){
newMsg(data["srcName"]);
}
var srcEvent = data["srcEvent"];
if(srcEvent!=null && srcEvent.length>0){
for(var i=0; i<srcEvent.length; i++){
var itemEvent = srcEvent;
newRow(itemEvent["datetime"],itemEvent["content"],itemEvent["location"]);
}
}

if(data["dstName"]!=null && data["dstName"]!=""){
newMsg(data["dstName"]);
}
var dstEvent = data["dstEvent"];
if(dstEvent!=null && dstEvent.length>0){
for(var i=0; i<dstEvent.length; i++){
var itemEvent = dstEvent;
newRow(itemEvent["datetime"],itemEvent["content"],itemEvent["location"]);
}
}
});
}

function track(itemid,lang){
clearTxt();
if(itemid==null || itemid.length<=0 || itemid=="Shipment Number") return;
lang = lang==null ? defaultLang : lang;
$("#trackbtn").attr("disabled","true");

var senddata = {"id":itemid.trim(),"timeout":timeout*1000,"lang":lang,"from":company,"type":"callback_render"}; //invoke callback_render method
$("#itemid").val(itemid.trim());
$("#mailNo").text(itemid.trim());

function tourl(data){
var s = "";
for(var key in data){
s += s.length>0?"&":"?";
s += key+"="+data[key];
}
return s;
}

$("#track-info").empty();
newMsg("<span style='font-weight:bold'>We are tracking, please wait a moment </span><img src='http://www.sao.cn/images/loading.gif' border=0/> ");

var url = "http://api.sao.cn/track" + tourl(senddata) ; //Outer JS URL
var script = document.createElement('script');
script.setAttribute('src', url);

//load javascript
document.getElementsByTagName('head')[0].appendChild(script);
script_segment = script;
}

function clearTxt(){
$("#mailNo").text(" ");
$("#mailStatus").text(" ");
$("#queryStatus").text(" ");
$("#dstName").text(" ");
$("#srcName").text(" ");
$("#waittime").text(0);
$("#track-info").empty();
try{ $(script_segment).remove(); }catch(e){}
}

function newRow(datetime,content,location){
var rowHTML = $("#row-record").html();
rowHTML = rowHTML.replaceAll("{datetime}",datetime);
rowHTML = rowHTML.replaceAll("{content}",content);
rowHTML = rowHTML.replaceAll("{location}",location);
$("#track-info").append($(rowHTML));
}
function newMsg(content){
var rowHTML = $("#msg-record").html();
rowHTML = rowHTML.replaceAll("{content}",content);
$("#track-info").append($(rowHTML));
}
function getParameter(url,name,defval){
try{
if(name.indexOf("=")<0) name=name+"=";
var start = url.indexOf(name);
if(start<0) return defval;
var end = url.indexOf("&",start);
if(end<0) end = url.length;
return url.substring(start+name.length,end);
}catch(e){
return defval;
}
}
</script>


<script>
var timeout = 100; //timeout seconds
var defaultLang = "CN"; // default language (CN,EN)
var company = window.location.hostname;//your commany name

$(document).ready(function(){
$("#trackbtn").removeAttr("disabled");
var url = window.location.href;
var itemid = getParameter(url,"itemid","");
var lang = getParameter(url,"lang",defaultLang);
track(itemid, lang);
});
</script></body>





Comentarios

Agregar comentario

Rellene los campos de abajo para dejar su comentario.









Extras (Negrita / Cursiva / URL / Imagen):








En este blog está activada la moderación. Tu comentario requiere que los administradores lo aprueben antes de hacerse visible.