diff --git a/app/assets/images/icons/envocab.png b/app/assets/images/icons/envocab.png new file mode 100644 index 000000000..325160596 Binary files /dev/null and b/app/assets/images/icons/envocab.png differ diff --git a/app/assets/images/icons/wikibooks.png b/app/assets/images/icons/wikibooks.png new file mode 100644 index 000000000..70d560262 Binary files /dev/null and b/app/assets/images/icons/wikibooks.png differ diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 75273d61f..f56314834 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -37,6 +37,71 @@ var sortAscending = function(a, b) { var sortDescending = function(a, b) { return $(a).find("h1").text() < $(b).find("h1").text() ? 1 : -1; }; +jQuery.ajax = (function(_ajax){ + + var protocol = location.protocol, + hostname = location.hostname, + exRegex = RegExp(protocol + '//' + hostname), + YQL = 'http' + (/^https/.test(protocol)?'s':'') + '://query.yahooapis.com/v1/public/yql?callback=?', + query = 'select * from html where url="{URL}" and xpath="*"'; + + function isExternal(url) { + return !exRegex.test(url) && /:\/\//.test(url); + } + + return function(o) { + + var url = o.url; + + if ( /get/i.test(o.type) && !/json/i.test(o.dataType) && isExternal(url) ) { + + // Manipulate options so that JSONP-x request is made to YQL + + o.url = YQL; + o.dataType = 'json'; + + o.data = { + q: query.replace( + '{URL}', + url + (o.data ? + (/\?/.test(url) ? '&' : '?') + jQuery.param(o.data) + : '') + ), + format: 'xml' + }; + + // Since it's a JSONP request + // complete === success + if (!o.success && o.complete) { + o.success = o.complete; + delete o.complete; + } + + o.success = (function(_success){ + return function(data) { + + if (_success) { + // Fake XHR callback. + _success.call(this, { + responseText: (data.results[0] || '') + // YQL screws with