Skip to content

Commit

Permalink
Removed the old javascript code for accessing the pod from search.cpa…
Browse files Browse the repository at this point in the history
…n.org -- may re-add this later if we want to allow for comparisons
  • Loading branch information
ioncache committed Nov 25, 2010
1 parent 3513e1b commit 06e7990
Showing 1 changed file with 0 additions and 90 deletions.
90 changes: 0 additions & 90 deletions htdocs/js/main.js
Expand Up @@ -6,44 +6,6 @@ function debug(data) {
}
}

// Accepts a url and a callback function to run.
function requestCrossDomain( site, callback ) {

// If no url was passed, exit.
if ( !site ) {
alert('No site was passed.');
return false;
}

// Take the provided url, and add it to a YQL query. Make sure you encode it!
var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from html where url="' + site + '"') + '&format=xml&callback=?';

function cbFunc(data) {
// If we have something to work with...
if ( data.results[0] ) {
// Strip out all script tags, for security reasons.
// BE VERY CAREFUL. This helps, but we should do more.
data = data.results[0].replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '');

// If the user passed a callback, and it
// is a function, call it, and send through the data var.
if ( typeof callback === 'function') {
callback(data);
}
}
// Else, Maybe we requested a site that doesn't exist, and nothing returned.
else {
debug('Error: Nothing returned from getJSON.');
callback('');
}
}

// Request that YSQL string, and run a callback function.
// Pass a defined function to prevent cache-busting.
$.getJSON( yql, cbFunc );

}

// does a search on module name through ElasticSearch
function metaSearch(value) {
if ( value !== '') {
Expand Down Expand Up @@ -165,55 +127,3 @@ function showPod(module) {
}
});
}

function remotePod(module, dist, author) {
var modulePath = module.replace(/::/g, '/');
var url = 'http://search.cpan.org/~' + escape(author) + '/' + escape(dist) + '/lib/' + escape(modulePath) + '.pm';
debug('Remote pod URL: ' + url);
$("#pod_contents, #source_contents").html('');
requestCrossDomain( url, function(resp) {
if ( resp !== '' ) {
var html = resp;
html = html.replace(/\n/gm, 'metacpan_newline');
html = html.replace(/^.*<div class="pod">/m, '<div class="pod">');
html = html.replace(/<div class="footer">.*$/m, '');
html = html.replace(/metacpan_newline/g, '\n');
html = html.replace('<div class="pod">', '<a name="___top" /><div class="pod">');
$("#pod_contents").html(html);
if ( $("#pod_contents").html() !== '' ) {
$("#pod_contents pre").each(function() {
$(this).replaceWith('<code class="highlight" style="padding: 10px;">' + $(this).html() + '</code>');
});
$("#pod_contents").syntaxHighlight();
var srcUrl = 'http://cpansearch.perl.org/src/' + escape(author) + '/' + escape(dist) + '/lib/' + escape(modulePath) + '.pm';
var srcFunc = (function(srcResp) {
if ( srcResp !== '' ) {
debug('Remote source URL: ' + srcUrl);
var src = srcResp.query.results.body.p;
if ( typeof(src) == 'object') {
console.log( src );
src = src.join('');
}
src = src.replace(/^\n/gm, 'meta_newline');
//src = src.replace(/\n/gm, ' ');
src = src.replace(/;/gm, ';\n');
//src = src.replace(/{/gm, '{\n');
//src = src.replace(/}/gm, '}\n');
src = src.replace(/meta_newline/gm, '\n');
$("#source_contents").html(src);
$("#source_contents").wrapInner('<code class="highlight" style="padding: 10px; white-space: pre;" />').syntaxHighlight();
}
});
var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from html where url="' + srcUrl + '"') + '&format=json&callback=?';
$.getJSON( yql, srcFunc );
}
$("#pod_loader").fadeOut(200, function() {
$("#pod_container").fadeIn(200);
});
} else {
$("#pod_loader").fadeOut(200, function() {
$("#no_pod").fadeIn(200);
});
}
});
}

0 comments on commit 06e7990

Please sign in to comment.