$(function(){ var placeholder = $("#short_url").attr("placeholder"); if (!('placeholder' in document.createElement('input'))) { $("#short_url").val(placeholder).focus(function(){ if ($(this).val() == placeholder) { $(this).val(''); } }).blur(function(){ if ($(this).val() == '') { $(this).val(placeholder); } }) } $("#url-form").submit(function(){ var short_url = $.trim($("#short_url").val()), reg = /(http(s)?|ftp):\/\/([\w]+\.)+[\w-]+(\/[\w.\/?%&=-]*)?/i; if (short_url.length === 0 || short_url === placeholder) { $("p.error").html("鸟人,要缩短的网址都没填!").removeClass('none').slideDown().delay(3000).slideUp(200); return false; } else if(!reg.test(short_url)) { $("p.error").html("拜托,您填的是网址吗?").removeClass('none').slideDown().delay(3000).slideUp(200); return false; } else { var parameter = $(this).serialize(), action = $(this).attr("action"), submitVal = $("#submit").val(); $("#submit").attr("disabled","disabled").val("").addClass("active"); $.post(action,parameter,function(e){ if(e.state === 'success'){ var //_click = e.msg.clicks, _url_long = e.msg.url_long, //_locations = e.msg.locations, _share_counts = e.msg.share_counts, _tmpl = $('#J_Tmpl').clone(); $('#J_Result').html(_tmpl.html()); /*var _tmpl_locations = $('#locations dd:first'); if(_locations.length === 0){ _tmpl_locations.html('暂无数据!'); }else{ $.each(_locations, function(i, v){ var _tmp = _tmpl_locations.clone().html().replace('{{locations}}', v.location).replace('{{locationsClicks}}', v.clicks); $('#locations').append('