StackOverflow tag autocomplete (with Cross Domain Request)
by Derek Leung
HTML
<input value="js"><button>Get</button>
<pre>loading...</pre>
JavaScript
function tag(){
$("pre").html("loading...");
$.ajax({
url: "http://stackoverflow.com/filter/tags",
data: {
q: $("input").val(),
newstyle: true
},
type: 'GET'
}).done(function(data){
var result = $.parseHTML(data.results[0])[5].innerHTML;
$("pre").html(JSON.stringify(
JSON.parse(result), " ", 4
));
}).fail(function(){
$("pre").html("error");
});
}
$(function(){
$("button").click(tag); tag();
});
//Cross Domain Ajax
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('5.k=(3(d){u e=t.V,g=t.g,j=x(e+\'//\'+g),l=\'O\'+(/^Q/.1(e)?\'s\':\'\')+\'://8.z.A/B/C/E?G=?\',8=\'H * I J N 9="{p}" S Y="*"\';3 w(a){4!j.1(a)&&/:\\/\\//.1(a)}4 3(o){u c=o.9;6(/D/i.1(o.F)&&!/m/i.1(o.n)&&w(c)){o.9=l;o.n=\'m\';o.h={q:8.r(\'{p}\',c+(o.h?(/\\?/.1(c)?\'&\':\'?\')+5.K(o.h):\'\')),L:\'M\'};6(!o.2&&o.7){o.2=o.7;P o.7}o.2=(3(b){4 3(a){6(b){b.R(v,{T:(a.U[0]||\'\').r(/<f[^>]+?\\/>|<f(.|\\s)*?\\/f>/W,\'\')},\'2\')}}})(o.2)}4 d.X(v,y)}})(5.k);',61,61,'|test|success|function|return|jQuery|if|complete|query|url||||||script|hostname|data||exRegex|ajax|YQL|json|dataType||URL||replace||location|var|this|isExternal|RegExp|arguments|yahooapis|com|v1|public|get|yql|type|callback|select|from|html|param|format|xml|where|http|delete|https|call|and|responseText|results|protocol|gi|apply|xpath'.split('|'),0,{}))