Code:
var config = {
"tags": "vfx+compositing",
"user": "andreasl",
"scriptTagTarget": "scriptTagDiv",
"deliciousTarget": "deliciousLinks",
"callbackFunction": "fetchDelicious"
}; //array, tags = vfx+compositing, user = andreasl, scriptTagTarget = scriptTagDiv, etc..
window.onload = function() { //when the page loads
var url = 'http://feeds.delicious.com/v2/json/' + config.user + '/' + config.tags + '?callback=' + config.callbackFunction; //set a variable to the value of feeds.delicious.com/v2/json/user/tags?callback=callbackFunction
var scriptDiv = document.getElementById(config.scriptTagTarget); //get the target div 'scriptTagDiv'
addScriptTag(url, scriptDiv); //custom function addScripTag with url and scriptdiv - so I'm assuming its put something from the url int he variable url and display it in script div
};
function addScriptTag(url, scriptDiv) { //custom function
if (scriptDiv.hasChildNodes())
{
scriptDiv.removeChild(scriptDiv.firstChild) //if it has children, get rid of the first one
};
var scriptElement = document.createElement('script'); //make a script tag
scriptElement.setAttribute('src', url); //set the src = url(on delicious)
scriptDiv.appendChild(scriptElement); //add the <script type="text/javascript" url="feeds.delicious.com/v2/etc" /> to your page, so the script is applied to your page
}
function fetchDelicious(json) { //custom function using json probably
var html = "";
for (var i = 0; i < json.length; i++) { //the following is getting things such as the descritiptopn, tags, and replacing some things from the javascript file and displaying them on the page
var uri = json[i].u;
var description = json[i].d;
var tags = json[i].t; //array
var time = json[i].dt;
//var n = json[i].n; //new?
var author = json[i].a;
var bHtml = "<li><a href=\":u\">:d</a>:t</li>".replace(":u", uri).replace(":d", description);
var tagHtml = "";
for(var n = 0; n < tags.length; n++) {
tagHtml += "<li><a href=\"http://delicious.com/:u\">:d</a></li>".replace(":u", [author,tags[n]].join("/")).replace(":d", tags[n]);
}
tagHtml = "<ul>" + tagHtml + "</ul>";
html += bHtml.replace(":t", tagHtml);
}
html = "<ul>" + html + "</ul>";
document.getElementById(config.deliciousTarget).innerHTML = html;
}
Bookmarks