/ Published in: JavaScript
                    
                                        
This is a website specific script... pops up the source of an OPML file with 145+ podcasts.
http://www.productivity501.com/2006/11/free_academic_p.html
Note: The 'bookmarklet' format is included as a comment at the bottom... (write in a webpage an anchor element with the escaped javascript format in the href attribute).
                http://www.productivity501.com/2006/11/free_academic_p.html
Note: The 'bookmarklet' format is included as a comment at the bottom... (write in a webpage an anchor element with the escaped javascript format in the href attribute).
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
/* 'Get Podcasts'
* if isOPML is false, it pops up an escaped version in HTML.
* if isOPML is true, it pops up an OPML version.
* Either way, you need to copy and save the results as a file with an .opml extension
* You can then add it to your Aggregator of choice:
*/
var isOPML=false;
var entry=document.getElementById('entry-14040355');
var ul=entry.getElementsByTagName('ul')[1];
var links=ul.getElementsByTagName('a');
var smalls=entry.getElementsByTagName('small');
var names=[];var cond=false;var text=url=title="";
for(var i=0;i<smalls.length;++i){
cond=false;text=smalls[i].childNodes[0].nodeValue;
for(var j=0;j<names.length;++j){
if(text==names[j]){
cond=true;
}
}
if(!cond){
names.push(text);
}
}
//So far, names=["Purdue University","Southwest Tech","Berkeley","College of St. Scholastica","John Hopkins University","UCLA","Western Kentucky University","College of DuPage","NC State University","City University of New York","Ohio State University"];
function filter(name){
var t=output="";
for(var k=0;k<links.length;++k){
t=smalls[k].childNodes[0].nodeValue;
if(t==name){
url=links[k].href;
title=links[k].childNodes[0].nodeValue;
output=output+' <outline text="'+title+'" title="'+title+'" type="rss" xmlUrl="'+url+'" htmlUrl="'+url+'"/>'+"\n";
}
}
return output;
}
var header='<opml version="1.0">'+"\n"+' <head>'+"\n"+' <title>Free Academic Podcasts</title>'+"\n"+' </head>'+"\n"+' <body>'+"\n";
var body='';
names.sort();
var p='Choose from which university you would like to get the podcasts from:\n 0. All';
for(var l=0;l<names.length;++l){
p=p+'\n '+(l+1)+'. '+names[l];
}
var reply=prompt(p,"");
var choice=parseInt(reply)-1;
if(choice<0||choice>names.length-1||isNaN(choice)){
for(var l=0;l<names.length;++l){
body=body+' <outline title="'+names[l]+'" text="'+names[l]+'">'+"\n"+filter(names[l])+' </outline>'+"\n";
}
}else{
body=' <outline title="'+names[choice]+'" text="'+names[choice]+'">'+"\n"+filter(names[choice])+' </outline>'+"\n";
}
body=body.replace(/="\s/g,'="');
body=body.replace(/&/g,'&');
var footer=' </body>'+"\n"+'</opml>';
var htmlHeader='<html><head><title>Free Academic Podcasts</title></head><body>';
var htmlFooter='</body></html>';
var opml=(isOPML)?header+body+footer:htmlHeader+(((((header+body+footer).replace(/&/g,'&')).replace(/>/g,'>')).replace(/</g,'<')).replace(/\n/g,'<br>\n'))+htmlFooter;
function popOPML(code){
var gOPML=window.open('','Free Academic Podcasts','top=300,left=200,height=480,width=640');
var tmp=gOPML.document;
tmp.open();
tmp.write(code);
tmp.close();
}
popOPML(opml);
/*Resulting Bookmarklet:*/
/*javascript:(function(){var%20isOPML=false;var%20entry=document.getElementById('entry-14040355');var%20ul=entry.getElementsByTagName('ul')[1];var%20links=ul.getElementsByTagName('a');var%20smalls=entry.getElementsByTagName('small');var%20names=[];var%20cond=false;var%20text=url=title='';for(var%20i=0;i<smalls.length;++i){cond=false;text=smalls[i].childNodes[0].nodeValue;for(var%20j=0;j<names.length;++j){if(text==names[j]){cond=true}}if(!cond){names.push(text)}}function%20filter(name){var%20t=output='';for(var%20k=0;k<links.length;++k){t=smalls[k].childNodes[0].nodeValue;if(t==name){url=links[k].href;title=links[k].childNodes[0].nodeValue;output=output+' <outline%20text=%22'+title+'%22%20title=%22'+title+'%22%20type=%22rss%22%20xmlUrl=%22'+url+'%22%20htmlUrl=%22'+url+'%22/>'+%22\n%22}}return%20output}var%20header='<opml%20version=%221.0%22>'+%22\n%22+' <head>'+%22\n%22+' <title>Free%20Academic%20Podcasts</title>'+%22\n%22+' </head>'+%22\n%22+' <body>'+%22\n%22;var%20body='';names.sort();var%20p='Choose%20from%20which%20university%20you%20would%20like%20to%20get%20the%20podcasts%20from:\n%200.%20All';for(var%20l=0;l<names.length;++l){p=p+'\n%20'+(l+1)+'.%20'+names[l];}var%20reply=prompt(p,%22%22);var%20choice=parseInt(reply)-1;if(choice<0||choice>names.length-1||isNaN(choice)){for(var%20l=0;l<names.length;++l){body=body+' <outline%20title=%22'+names[l]+'%22%20text=%22'+names[l]+'%22>'+%22\n%22+filter(names[l])+' </outline>'+%22\n%22;}}else{body=' <outline%20title=%22'+names[choice]+'%22%20text=%22'+names[choice]+'%22>'+%22\n%22+filter(names[choice])+' </outline>'+%22\n%22;}var%20tx='='+'%22';body=body.replace(/=%22\s/g,tx);body=body.replace(/&/g,'&amp;');var%20footer=' </body>'+%22\n%22+'</opml>';var%20htmlHeader='<html><head><title>Free%20Academic%20Podcasts</title></head><body>';var%20htmlFooter='</body></html>';var%20opml=(isOPML)?header+body+footer:htmlHeader+(((((header+body+footer).replace(/&/g,'&amp;')).replace(/>/g,'&gt;')).replace(/</g,'&lt;')).replace(/\n/g,'<br>\n'))+htmlFooter;function%20popOPML(code){var%20gOPML=window.open('','Free%20Academic%20Podcasts','top=300,left=200,height=480,width=640');var%20tmp=gOPML.document;tmp.open();tmp.write(code);tmp.close()}popOPML(opml);})()*/
URL: http://www.productivity501.com/2006/11/free_academic_p.html
Comments
 Subscribe to comments
                    Subscribe to comments
                
                