+ $(this).attr("href", $(this).attr("href") + "&query_desc=[% query_desc | uri %]");
+ });
+ [% END %]
+
+ [% IF ( IDreamBooksResults ) %]
+ $('.idbresult').each(function() {
+ var isbn = $(this).children('a').text().replace(/\s*/,'');
+ var element = this;
+
+ if ($.browser.msie && parseInt($.browser.version, 10) >= 8 && window.XDomainRequest) {
+ // Use Microsoft XDR for IE version 8 or above
+ var xdr = new XDomainRequest();
+ xdr.open("get", "http://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e");
+ xdr.onload = function() {
+ json = 'json = '+xdr.responseText; // the string now looks like.. json = { ... };
+ eval(json); // json is now a regular JSON object
+ if(json.total_results > 0 && json.book.rating > 0){
+ $(element).children('a').html("<img src='"+json.book.to_read_or_not_small+"' alt='"+json.book.title+" by "+json.book.author+"' title='Rating based on reviews of "+json.book.title+"'>"+json.book.rating+"%");
+ $(element).show();
+ } else {
+ $(element).remove();
+ }
+ }
+ xdr.send();
+ } else {
+ $.getJSON("http://idreambooks.com/newbooks/api.json?q="+encodeURIComponent(isbn)+"&key=8bf66516232d1b72f3e47df939653e1e", function(json){
+ if(json.total_results > 0 && json.book.rating > 0){
+ $(element).children('a').html("<img src='"+json.book.to_read_or_not_small+"' alt='"+json.book.title+" by "+json.book.author+"' title='Rating based on reviews of "+json.book.title+"'>"+json.book.rating+"%");
+ $(element).show();
+ } else {
+ $(element).remove();
+ }
+ });
+ }