/*############################################################################## # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ############################################################################## */ //Here's the code that will set up our Left Nav instance. var tree, currentIconMode; (function(){ function changeIconMode() { var newVal = parseInt(this.value); if (newVal != currentIconMode) { currentIconMode = newVal; } buildTree(); } tree = new YAHOO.widget.TreeView("espNavTree"); tree.setDynamicLoad(loadNodeData, currentIconMode); var root = tree.getRoot(); var attributeServersNode = new YAHOO.widget.TextNode({label: "Attribute Servers", expanded:true, dynamicLoadComplete:true}, root); var tmpNode2 = new YAHOO.widget.TextNode({label: "dataland"}, attributeServersNode); tmpNode2.labelStyle = "icon-doc"; var tmpNode3 = new YAHOO.widget.TextNode({label: "prod"}, attributeServersNode); tmpNode3.labelStyle = "icon-doc"; var tmpNode4 = new YAHOO.widget.TextNode({label: "qa", expanded: false}, attributeServersNode); tmpNode4.labelStyle = "icon-doc"; var roxieClustersNode = new YAHOO.widget.TextNode({label: "Roxie Clusters", expanded:true, dynamicLoadComplete:true}, root); var tmpNode5 = new YAHOO.widget.TextNode({label: "QA-Roxie"}, roxieClustersNode); tmpNode5.labelStyle = "icon-doc"; var tmpNode6 = new YAHOO.widget.TextNode({label: "Staging", expanded: false}, roxieClustersNode); tmpNode6.labelStyle = "icon-doc"; var tmpNode7 = new YAHOO.widget.TextNode({label: "40-Way"}, roxieClustersNode); tmpNode7.labelStyle = "icon-doc"; tree.render(); })(); function loadNodeData(node, fnLoadComplete) { //We'll load node data based on what we get back when we //use Connection Manager topass the text label of the //expanding node to the Yahoo! //Search "related suggestions" API. Here, we're at the //first part of the request -- we'll make the request to the //server. In our success handler, we'll build our new children //and then return fnLoadComplete back to the tree. //Get the node's label and urlencode it; this is the word/s //on which we'll search for related words: var nodeLabel = encodeURI(node.label); //prepare URL for XHR request: var sUrl = "assets/ysuggest_proxy.php?query=" + nodeLabel; //prepare our callback object var callback = { //if our XHR call is successful, we want to make use //of the returned data and create child nodes. success: function(oResponse) { YAHOO.log("XHR transaction was successful.", "info", "example"); //YAHOO.log(oResponse.responseText); var oResults = eval("(" + oResponse.responseText + ")"); if((oResults.ResultSet.Result) && (oResults.ResultSet.Result.length)) { //Result is an array if more than one result, string otherwise if(YAHOO.lang.isArray(oResults.ResultSet.Result)) { for (var i=0, j=oResults.ResultSet.Result.length; i