/* ============== | XMLTREE.JS | @author: Mitya (acroxall@espresso.co.uk) | @Docs & demo: http://www.mitya.co.uk/scripts/XML-Tree---visualise-and-traverse-your-XML-186 ============== */ (function($) { XMLTree = function(jdo, subTreeRequest) { /* ------------------- | PREP & VALIDATION ------------------- */ //ensure was instantiated, not merely called if (!(this instanceof XMLTree)) { if (window.console && console.log) console.log("XMLTree was called but not instantiated"); return; } //validate some params var error; if (!jdo.fpath && !jdo.xml) error = "neither XML nor path to XML file passed"; else if ((!jdo.container || !$(jdo.container).length) && !jdo.justReturn) error = "No container selector passed or does not match element in DOM"; if (error) { alert('XMLTree error - '+error); return; } //some vars var li, appendTo, attrLI, container = $(jdo.container), rand = Math.floor(Math.random() * 10000000), thiss = this; //establish tree container - if making the outer tree, create a new UL. If this is a sub-tree request, i.e. called by self, //merge new tree into existing UL of caller LI this.tree = !subTreeRequest ? $('