Skip to content

Instantly share code, notes, and snippets.

@AstroCB
Created November 1, 2014 18:32
Show Gist options
  • Save AstroCB/855574d22e74b357ca80 to your computer and use it in GitHub Desktop.
Save AstroCB/855574d22e74b357ca80 to your computer and use it in GitHub Desktop.
Puts links in the format "-hyperlinked_title (source)" and outputs HTML source
var title = "empty";
var url = "empty";
var source = "";
var i = 0;
var j = 0;
var webData = {};
var sources = [];
var finalData = "";
while(title !== ""){
title = prompt("Enter title");
url = prompt("Enter URL");
source = prompt("Enter source");
webData[title] = url;
sources[i] = source;
i++;
}
for(var i in webData){
if((webData[i]) === ""){
delete webData[i];
}
}
var dataLength = Object.keys(webData).length;
for(var i in webData){
if(sources[j] !== undefined && sources[j] !== ""){
if(webData[i] === webData[dataLength - 2] && j === dataLength - 2){
finalData += ("-<a href=\"" + webData[i] + "\">" + i + "</a> (" + sources[j] + ")");
}else{
finalData += ("-<a href=\"" + webData[i] + "\">" + i + "</a> (" + sources[j] + ")\n");
}
}
j++;
}
console.log(finalData);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment