Skip to content

Instantly share code, notes, and snippets.

@chrisforbes
Created October 2, 2009 04:39
Show Gist options
  • Save chrisforbes/199470 to your computer and use it in GitHub Desktop.
Save chrisforbes/199470 to your computer and use it in GitHub Desktop.
function farmnet_init()
{
jQuery.tag = function(e) { return $(document.createElement(e)); }
}
function do_expand()
{
$(this).toggleClass('toggle_expanded');
$(this).parent().next().toggleClass('details_expanded');
}
function farmnet_spawn(desc)
{
var itemSummary = $.tag("div").addClass("item").attr("id", desc.id)
.append($.tag("div").addClass("item_name").html(desc.name))
.append($.tag("div").addClass("summary")
.append($.tag("div").addClass("light_" + desc.light))
.append($.tag("div").html(desc.summary)))
.append($.tag("div").addClass("toggle").click(do_expand));
var itemDetail = $.tag("div").addClass("details").attr("id", desc.id)
.html(desc.details);
if (desc.light == "red")
itemSummary.addClass("item_broken");
$("#main").append(itemSummary);
$("#main").append(itemDetail);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment