//移动时文字的显隐
  this.showCaption = function() {
    moveMe(this.caption, this.x() - (getWidth(this.caption)/2) + (this.w()/2), (this.y() + this.h()));
    show(this.caption);
  }
  this.hideCaption = function() {
    hide(this.caption);
  }
  this.setCaption = function(c) { getObjectRef(this.caption).innerHTML = c;}
 
  this.addItem = function(c,action,r) {
    getObjectRef(this.ref).className = "dot";
    if(!r) r = this.radius/2;
    var sub = new menuObject(this.name + ".subMenus[" + this.subMenus.length + "]",0,0,c,r,this);
    sub.parent = this;
    sub.action = action;
    sub.moveMe(0,0);
    this.subMenus[this.subMenus.length] = sub;
    return sub;
  }
  
  this.expand = function() {
    if(this.subMenus.length > 0) {
      var p = true;
      if(this.parent) {
        p = !this.parent.moving;
        for(var i=0; i<this.parent.subMenus.length;i++)
          p = p && ((this.parent.subMenus[i].state==0) || (this.parent.subMenus[i].state==this.parent.subMenus[i].subMenus.length)) && (this.parent.subMenus[i].moving==false);
      } else var o = false;
            if((!this.parent || this.parent.state == this.parent.subMenus.length) && p) {
        if(this.parent) this.collapseAll(this.name);
        
        var diff = 360 / this.subMenus.length;
        for(var i=0;i<this.subMenus.length;i++){
          this.subMenus[i].moveMe(0,0);
          this.subMenus[i].show();
          this.moving = true;
          this.subMenus[i].slide(this.subMenus[i].radius * cos(degToRad((diff*i)+this.startAngle)), this.subMenus[i].radius * sin(degToRad((diff*i)+this.startAngle)), this.name + ".subMenus[" + i + "].showCaption();" + this.name + ".moving=false;" + this.name + ".state+=1;");
        }
        if(this.parent){
          getObjectRef(this.parent.ref).style.filter = "alpha (opacity=33)";
          getObjectRef(this.parent.ref).style.MozOpacity = "33%";
          getObjectRef(this.parent.ref).className = "dotoff";
          getObjectRef(this.parent.caption).style.filter = "alpha (opacity=33)";
          getObjectRef(this.parent.caption).style.MozOpacity = "33%";
          for(i=0;i<this.parent.subMenus.length;i++) {
              getObjectRef(this.parent.subMenus[i].ref).style.filter = "alpha (opacity=66)";
              getObjectRef(this.parent.subMenus[i].ref).style.MozOpacity = "66%";
              getObjectRef(this.parent.subMenus[i].caption).style.filter = "alpha (opacity=66)";
              getObjectRef(this.parent.subMenus[i].caption).style.MozOpacity = "66%";     
          }
          if(this.parent.parent) {
            for(i=0;i<this.parent.parent.subMenus.length;i++) {
              getObjectRef(this.parent.parent.subMenus[i].ref).style.filter = "alpha (opacity=33)";
              getObjectRef(this.parent.parent.subMenus[i].ref).style.MozOpacity = "33%";
              getObjectRef(this.parent.parent.subMenus[i].ref).className = "dotoff";
  getObjectRef(this.parent.parent.subMenus[i].ref).style.visibility = "hidden";//点击第四级二级消失
  getObjectRef(this.parent.parent.subMenus[i].caption).style.visibility = "hidden";//点击第四级二级消失
              getObjectRef(this.parent.parent.subMenus[i].caption).style.filter = "alpha (opacity=33)";        
              getObjectRef(this.parent.parent.subMenus[i].caption).style.MozOpacity = "33%";
            }
            getObjectRef(this.parent.parent.ref).style.MozOpacity = "33%";
            getObjectRef(this.parent.parent.ref).style.MozOpacity = "33%";
            getObjectRef(this.parent.parent.ref).className = "dotoff";

          }
        }
        getObjectRef(this.ref).style.filter = "alpha (opacity=66)";
        getObjectRef(this.caption).style.filter = "alpha (opacity=66)";  
        getObjectRef(this.ref).style.MozOpacity = "66%";
        getObjectRef(this.caption).style.MozOpacity = "66%"; 
getObjectRef(this.ref).style.visibility = "hidden";//第一次点击父节点消失
getObjectRef(this.caption).style.visibility = "hidden";//第一次点击父节点消失
      }
    }  
  }  this.collapse = function() {
    var p = true;
    p = !this.moving;
    for(var i=0; i<this.subMenus.length;i++)
      p = p && (this.subMenus[i].state==0)  && (this.subMenus[i].moving==false);
    
    if(p && this.subMenus.length > 0) {
      for(var i=0;i<this.subMenus.length;i++){
        this.subMenus[i].hideCaption();
        this.moving = true;
        this.subMenus[i].slide(0, 0, this.name + ".subMenus[" + i + "].hide();" + this.name + ".moving=false;" + this.name + ".state-=1;");
      }
      if(this.parent){
        getObjectRef(this.parent.ref).style.filter = "alpha (opacity=66)";
        getObjectRef(this.parent.ref).style.MozOpacity = "66%";
        if(this.parent.subMenus.length != 0)
          getObjectRef(this.parent.ref).className = "dot";
        else
          getObjectRef(this.parent.ref).className = "dotempty";
        getObjectRef(this.parent.caption).style.filter = "alpha (opacity=66)";
        getObjectRef(this.parent.caption).style.MozOpacity = "66%";
        for(i=0;i<this.parent.subMenus.length;i++) {
          getObjectRef(this.parent.subMenus[i].ref).style.filter = "alpha (opacity=100)";
          getObjectRef(this.parent.subMenus[i].ref).style.MozOpacity = "100%";
          if(this.parent.subMenus[i].subMenus.length != 0) 
            getObjectRef(this.parent.subMenus[i].ref).className = "dot";
          else
            getObjectRef(this.parent.subMenus[i].ref).className = "dotempty";
          getObjectRef(this.parent.subMenus[i].caption).style.filter = "alpha (opacity=100)";        
          getObjectRef(this.parent.subMenus[i].caption).style.MozOpacity = "100%";
        }
        if(this.parent.parent) {
          for(i=0;i<this.parent.parent.subMenus.length;i++) {
            getObjectRef(this.parent.parent.subMenus[i].ref).style.filter = "alpha (opacity=66)";
            getObjectRef(this.parent.parent.subMenus[i].ref).style.MozOpacity = "66%";
            if(this.parent.parent.subMenus[i].subMenus.length != 0)
              getObjectRef(this.parent.parent.subMenus[i].ref).className = "dot";
            else
              getObjectRef(this.parent.parent.subMenus[i].ref).className = "dotempty";
            getObjectRef(this.parent.parent.subMenus[i].caption).style.filter = "alpha (opacity=66)";        
            getObjectRef(this.parent.parent.subMenus[i].caption).style.MozOpacity = "66%";
          }
        }
      }
      getObjectRef(this.ref).style.filter = "alpha (opacity=100)";
      getObjectRef(this.caption).style.filter = "alpha (opacity=100)";       
      getObjectRef(this.ref).style.MozOpacity = "100%";
      getObjectRef(this.caption).style.MozOpacity = "100%";
    }
  }  this.collapseAll = function(except) {
    for(var i=0;i<this.parent.subMenus.length;i++) {
      if(this.parent.subMenus[i].name!=except && this.parent.subMenus[i].state==this.parent.subMenus[i].subMenus.length) {
        this.parent.subMenus[i].collapse();
      }    
    }
  }
  
  this.toggle = function(e) {
    if(document.all) id = window.event.srcElement;
    else id = e.target;
    var dot = eval(id.objRef);
    
    if(dot.state==0 && !dot.moving) dot.expand();
    else if(dot.state==dot.subMenus.length && !dot.moving) dot.collapse()
  }
  
  this.doAction = function(e) {
    if(document.all) id = window.event.srcElement;
    else id = e.target;
    var dot = eval(id.objRef);
    
    if(dot.action == "toggle") dot.toggle(e);
    else eval(dot.action);
  }

解决方案 »

  1.   


     //change these if you want to change the events that trigger the actions
      //========================================================================
      //getObjectRef(this.ref).onmousemove = this.toggle;
      getObjectRef(this.ref).onmouseup = this.doAction;
      
      this.slide = function(xx,yy,func) {
        if(!func) func = "";
        var px = this.parent.x();
        var py = this.parent.y();
        
        var x = xx - this.x() + px;
        var y = yy - this.y() + py;
        
        var d = sqrt(square(xx-this.x() + px) + square(yy-this.y() + py));
        
        var v = d/8;
        if(v<1) v = 1;
            
        if( (Math.abs(x) < v) && (Math.abs(y) < v) ) {
          moveMe(this.ref,xx + px,yy + py);      
          if(func != "") eval(func);
        } else {    
          var a = round(atan(x,y));
          dx = round(v * cos(degToRad(a)));
          dy = round(v * sin(degToRad(a)));
       
          this.moveBy(dx,dy);
          setTimeout(this.name + ".slide(" + xx + "," + yy + ", '" + func + "');",10);    
        }
      }
      // Preoading the windows filters.
      if (menuCount==0 && document.all) document.all[this.ref].style.filter = "alpha (opacity=100)";
      menuCount++;
      return this;
    }
    // Math functions
    //================
    var pi = Math.PI;
    function square(x) { return (x*x); }
    function sqrt(x) { return Math.sqrt(x); }
    function round(x) { return Math.round(x); }
    function rand(x,y) { return (round(Math.random()*(y-x)) + x); }function cos(x) { return Math.cos(x) }
    function sin(x) { return Math.sin(x) }

    function degToRad(x) { return ( x/(360/(2*pi)) ); }
    function radToDeg(x) { return ( x*(360/(2*pi)) ); }
    function atan(s,t) {
      if( s == 0.0 && t > 0.0)
        angle = 90.0;
      else if(s == 0.0 && t < 0.0) 
        angle = 270.0;
      else if (s < 0.0 ) 
        angle = 180.0 + radToDeg(Math.atan(t/s));
      else if (s > 0.0 && t < 0.0)
        angle = 360.0 + radToDeg(Math.atan(t/s));
      else {
        if(s==0.0) s=0.00001;
        angle = radToDeg(Math.atan(t/s));
      }
      if(angle < 0.0) angle += 360.0;
      return angle;
    }
    //get dimentions of the page
    if(document.all) pageWidth = document.body.offsetWidth-20;
    else pageWidth = innerWidth;
    if(document.all) pageHeight = document.body.offsetHeight-4;
    else pageHeight = innerHeight;//Create main menu
    var menu = new menuObject("menu",pageWidth/2,pageHeight/2,"noah知识点地图",pageHeight/2);
    menu.startAngle = -90;//show menu and caption
    menu.show();
    menu.showCaption();//Add submenus
    menu.addItem("新加知识点","window.open('/news')");
    menu.addItem("数学","toggle");
    menu.addItem("语文","toggle");
    menu.addItem("物理","toggle");
    menu.addItem("化学","toggle");
    menu.addItem("英语","toggle");menu.subMenus[1].addItem("数学1","window.open('/script/script22.asp')");
    menu.subMenus[1].addItem("数学2","window.open('/script/script17.asp')");
    menu.subMenus[1].addItem("数学3","window.open('/script/script16.asp')");
    menu.subMenus[1].addItem("数学4","window.open('/script/script15.asp')");
    menu.subMenus[1].addItem("数学5","window.open('/script/script14.asp')");
    menu.subMenus[1].addItem("数学6","window.open('/script/script9.asp')");
    menu.subMenus[1].addItem("数学7","window.open('/script/script10.asp')");
    menu.subMenus[1].addItem("数学8","window.open('/script/')");
    menu.subMenus[2].addItem("语文1","window.open('/tutorials/tutorial5.asp')");
    menu.subMenus[2].addItem("语文2","window.open('/tutorials/tutorial6.asp')");
    menu.subMenus[2].addItem("语文3","window.open('/tutorials/tutorial4.asp')");
    menu.subMenus[2].addItem("语文4","window.open('/tutorials/tutorial3.asp')");
    menu.subMenus[2].addItem("语文5","window.open('/tutorials/tutorial2.asp')");
    menu.subMenus[2].addItem("语文6","window.open('/tutorials/tutorial1.asp')");
    menu.subMenus[2].addItem("语文7","window.open('/tutorials/tutorial1.asp')");
    menu.subMenus[3].addItem("物理1","window.open('/forums')");
    menu.subMenus[3].addItem("物理2","window.open('/forums/forum.asp?FORUM_ID=1&CAT_ID=1&Forum_Title=Cool+sites')");
    menu.subMenus[3].addItem("物理3","window.open('/forums/forum.asp?FORUM_ID=2&CAT_ID=1&Forum_Title=CoolMenus')");
    menu.subMenus[3].addItem("物理4","window.open('/forums/forum.asp?FORUM_ID=3&CAT_ID=1&Forum_Title=Crossbrowser+DHTML')");
    menu.subMenus[3].addItem("物理5","window.open('/forums/forum.asp?FORUM_ID=4&CAT_ID=1&Forum_Title=DHTML+Scripts')");
    menu.subMenus[3].addItem("物理6","window.open('/forums/forum.asp?FORUM_ID=6&CAT_ID=1&Forum_Title=General+DHTML+issues')");
    menu.subMenus[3].addItem("物理7","window.open('/forums/forum.asp?FORUM_ID=9&CAT_ID=1&Forum_Title=Off%2Dtopic')");
    c = menu.subMenus[4].addItem("实验室","toggle");
    c.startAngle = 15;
    menu.subMenus[4].addItem("实验室1","window.open('/resources/default.asp?catid=7&cattitle=Portals')");
    menu.subMenus[4].addItem("实验室2","window.open('/resources/default.asp?catid=1&cattitle=Script+sites')");menu.subMenus[4].addItem("初中化学","toggle");menu.subMenus[4].subMenus[0].addItem("实验室a","window.open('/resources/default.asp?catid=5&cattitle=Commercial+sites')")
    menu.subMenus[4].subMenus[0].addItem("实验室b","window.open('/resources/default.asp?catid=6&cattitle=Personal+sites')");
    menu.subMenus[4].subMenus[0].addItem("实验室c","toggle");menu.subMenus[4].subMenus[0].subMenus[2].addItem("实验室c-1","");
    menu.subMenus[4].subMenus[0].subMenus[2].addItem("实验室c-2","");menu.subMenus[4].subMenus[3].addItem("初一化学","window.open('/resources/default.asp?catid=8&cattitle=References')");
    menu.subMenus[4].subMenus[3].addItem("初二化学","window.open('/resources/default.asp?catid=9&cattitle=Tutorials+and+Articles')");menu.subMenus[5].addItem("初中英语","");
    menu.subMenus[5].addItem("高中英语","");
    menu.subMenus[5].addItem("大学英语","toggle");menu.subMenus[5].subMenus[2].addItem("大学英语一","window.open('http://www.sina.com.cn')");
    menu.subMenus[5].subMenus[2].addItem("大学英语二","");
    menu.subMenus[5].subMenus[2].addItem("大学英语三","");
    //--></script>
    </body>
      

  2.   

    function degToRad(x) { return ( x/(360/(2*pi)) ); }
    function radToDeg(x) { return ( x*(360/(2*pi)) ); }
    function atan(s,t) {
      if( s == 0.0 && t > 0.0)
        angle = 90.0;
      else if(s == 0.0 && t < 0.0) 
        angle = 270.0;
      else if (s < 0.0 ) 
        angle = 180.0 + radToDeg(Math.atan(t/s));
      else if (s > 0.0 && t < 0.0)
        angle = 360.0 + radToDeg(Math.atan(t/s));
      else {
        if(s==0.0) s=0.00001;
        angle = radToDeg(Math.atan(t/s));
      }
      if(angle < 0.0) angle += 360.0;
      return angle;
    这里处理度数没看明白