javascript Javascript片段

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Javascript片段相关的知识,希望对你有一定的参考价值。

bindings.js ------------------------

//Functions that will be used as bindings
function expandEvent (params) { // Expand a node (with event handler)
  if (params.nodes.length) { //Did the click occur on a node?
    var page = params.nodes[0]; //The id of the node clicked
    expandNode(page);
  }
}

expandNode("shrek");

//

var testData = []; //keep track over every node that has been clicked on

//Functions that will be used as bindings
function expandEvent (params) { // Expand a node (with event handler)
  if (params.nodes.length) { //Did the click occur on a node?
    var page = params.nodes[0]; //The id of the node clicked
    expandNode(page);
    testData.push(page);
  }
}

//

//Reset the color of all nodes, and width of all edges.
function resetProperties() {
  if (!isReset) {
    selectedNode = null;
    //Reset node color
    var modnodes = tracenodes.map(function(i){return nodes.get(i);});
    colorNodes(modnodes, 0);
    //Reset edge width and color
    var modedges = traceedges.map(function(i){
      var e=edges.get(i);
      e.color=getEdgeColor(nodes.get(e.to).level);
      return e;
    });
    edgesWidth(modedges, 1);
    tracenodes = [];
    traceedges = [];
    tracenodes = ['aldi','argo','lidl']; //testData;
    traceedges = [];
    //traceedges = [];
    //Color nodes yellow
    var modnodes = tracenodes.map(function(i){return nodes.get(i);});
    colorNodes(modnodes, 1);
    //Widen edges
    var modedges = traceedges.map(function(i){
      var e=edges.get(i);
      e.color={inherit:"to"};
      return e;
    });
    edgesWidth(modedges, 5);
  }
}

//Highlight the path from a given node back to the central node.
function traceBack(node) {
  if (node != selectedNode) {
    selectedNode = node;
    resetProperties();
    tracenodes = getTraceBackNodes(node);
    traceedges = getTraceBackEdges(tracenodes);
    tracenodes = ['aldi','argo','lidl']; //testData;
    traceedges = [];
    //traceedges = [];
    //Color nodes yellow
    var modnodes = tracenodes.map(function(i){return nodes.get(i);});
    colorNodes(modnodes, 1);
    //Widen edges
    var modedges = traceedges.map(function(i){
      var e=edges.get(i);
      e.color={inherit:"to"};
      return e;
    });
    edgesWidth(modedges, 5);
  }
}

以上是关于javascript Javascript片段的主要内容,如果未能解决你的问题,请参考以下文章

javascript JavaScript重要的片段/方法

javascript Javascript片段

javascript Nexternal的Javascript片段集合

VSCode自定义代码片段12——JavaScript的Promise对象

VSCode自定义代码片段12——JavaScript的Promise对象

thymeleaf 片段渲染后重新加载 javascript