Skip to content

Instantly share code, notes, and snippets.

@azcoov
Created January 23, 2011 02:15
Show Gist options
  • Save azcoov/791741 to your computer and use it in GitHub Desktop.
Save azcoov/791741 to your computer and use it in GitHub Desktop.
Javascript for Flash tag cloud
<script type="text/javascript" src="/Content/swfobject.js"></script>
<script type="text/javascript">
var divRecentTags = document.getElementById("recent-tags");
if (divRecentTags) {
var cloud = new SWFObject("/Content/tagcloud.swf", "tagcloudflash", "275", "200", "9", "#ffffff");
cloud.addParam("allowScriptAccess", "always");
cloud.addVariable("tcolor", "0x6290B8");
cloud.addVariable("tcolor2", "0x000000");
cloud.addVariable("hicolor", "0xFE5655");
cloud.addVariable("tspeed", "100");
cloud.addVariable("distr", "true");
cloud.addVariable("mode", "tags");
var aTags = divRecentTags.getElementsByTagName("a");
var tagHtml = "";
for(var i = 0; i < aTags.length; i++) {
var hrefText = aTags[i].getAttribute("href");
var cssText = aTags[i].className;
var tagName = $(aTags[i]).text();
var styleText = "style=\'font-size: 8pt;\'";
if (cssText == "post-tag pop1") { var styleText = "style=\'font-size: 15pt;\'"; }
else if (cssText == "post-tag pop2") { var styleText = "style=\'font-size: 22pt;\'";}
var newLinkText = "<a href=\'" + hrefText + "\' " + styleText + ">" + tagName + "</a>";
tagHtml = tagHtml + newLinkText;
}
cloud.addVariable("tagcloud", escape("<tags>" + tagHtml + "</tags>"));
cloud.write("recent-tags");
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment