Javascript Help

  • bluedragon
  • Proficient
  • Proficient
  • bluedragon
  • Posts: 452

Post 3+ Months Ago

I am a little over my head with this script. I am trying to make it to the talent points in this script do not requite to be added by 5 for each rank. I hope I explained that well.

Code: [ Select ]
var colorGreen = "#1AFF1A";
var colorYellow = "#FFD100";
var colorWhite = "#FFFFFF";




function resetTree(theTree) {

    if (pointsTree[theTree] == 0)
        return;

    maxTierArray[theTree] = 1;        
    rankPoints += pointsTree[theTree];
    pointsTree[theTree] = 0;
    
    document.getElementById(tree[theTree]+'PointsTopRight').innerHTML = 0;                            

    for (var y = 0; y < tierNum; y++)
        pointsTier[theTree][y] = 0;
    

    var i;
    var iStop;
    if (theTree == 0)
        i = 0;
    else
        i = treeStartStop[theTree-1] + 1;

    iStop = treeStartStop[theTree];            
    
    while (i <= iStop) {    
        rankTop[i][0] = 0;
        rankTop[i][1] = rank[i][0];
        rankTop[i][2] = rank[i][1];

        document.getElementById("modifyRankTopColor"+ i).style.color = colorWhite;
        document.getElementById("modifyRankTop"+ i).style.color = colorWhite;

          document.getElementById('modifyDescriptionTop'+i).innerHTML = rankTop[i][1];
        if (talent[i][5]) {
            document.getElementById("arrowYellow"+ i).style.visibility = "hidden";
            document.getElementById("arrowGreen"+ i).style.visibility = "hidden";
        }

        document.getElementById('modifyRankTopDescription'+i).innerHTML = 0;
        document.getElementById('modifyRankTop'+i).innerHTML = 0;
        document.getElementById('talentThumb'+ i).style.visibility = "hidden";

        document.getElementById('iconOverGreen'+ i).style.visibility = "hidden";
        document.getElementById('iconOverYellow'+ i).style.visibility = "hidden";
        
        if (talent[i][4] == 1 && (!talent[i][5])) {
            document.getElementById("modifyRankTopColor"+ i).style.color = colorGreen;
            document.getElementById("modifyRankTop"+ i).style.color = colorGreen;
        }
        i++;
    }
    
  document.getElementById('levelRequired').innerHTML = rankPointsMax - rankPoints + levelMin - 1;    
    document.getElementById('modifyRankPoints').innerHTML = rankPointsMax - rankPoints;
    document.getElementById('tabPointsAvailable').innerHTML = rankPoints;
    document.getElementById(tree[theTree]+'tabPoints').innerHTML = 0;
    
    changeCopyURL();
    
}

function resetTreeAll() {
    for (var i = 0; i < tree.length; i++) {
        resetTree(i);
    }
}

function getMaxTier(theTree) {
    var maxTier = 0;
    for (var loopMaxTier = 0; loopMaxTier < tierNum; loopMaxTier++) {
        if (pointsTier[theTree][loopMaxTier] != 0)
            maxTier = loopMaxTier;
    }
    maxTier++;
    return maxTier;
}

function getPointsAboveAndCurrent(theTree, maxTier) {
    var pointsTierTotalAboveAndCurrent = 0;
    var loopPointsTierAbove = 0;
    for (loopPointsTierAbove; loopPointsTierAbove < maxTier; loopPointsTierAbove++) {
        pointsTierTotalAboveAndCurrent += pointsTier[theTree][loopPointsTierAbove];
    }
    return pointsTierTotalAboveAndCurrent;
}
        
function canUnlearn(talentID, clickLeftRight, maxTier) {
    var treeID = talent[talentID][0];
    var maxRank = talent[talentID][2];
    var treePoints = pointsTree[treeID];    
    var necessaryPoints;
    var projectedPoints;
    var pointsAboveAndCurrent;

    if (hasDependentTalentWithPoints(talentID))
        return false;
            
    if (clickLeftRight == 0) { //left click

        var theCurrentRank = rankTop[talentID][0];
        if (theCurrentRank < maxRank) {

            necessaryPoints = (talent[talentID][4] - 1) * 1;
            if (treePoints < necessaryPoints)
                return false;
        
            if (rankPoints == 0)
                return false;        
                
            if (!checkRequiredTalent(talentID) && theCurrentRank == 0)
                return false;
                
            projectedPoints = pointsAboveAndCurrent++;

        } else {
            return false;
        }

    } else {    //right click

        if (rankTop[talentID][0] != 0){

            pointsAboveAndCurrent = getPointsAboveAndCurrent(treeID, maxTier-1);    
            projectedPoints = pointsAboveAndCurrent - 1 + pointsTier[treeID][maxTier-1];

            for (var thisTier = talent[talentID][4]; thisTier < maxTier; maxTier--) {

                necessaryPoints = (maxTier-1) *5;        
                projectedPoints -= pointsTier[treeID][maxTier-1];
                if (projectedPoints < necessaryPoints)
                    return false;
            }
            
        } else { //if the rank is 0

            return false;
        }
    
    }    
    return true;

}

function getTalentID(talentName) {
    var theTalentID;
    for (theTalentID = 0; talent[theTalentID]; theTalentID++) {
        if (talent[theTalentID][1] == talentName)
            return theTalentID;
    }
}

function getMinLevel(talentID) {
    return ((talent[talentID][4] -1)* 5 + 10);
}

function hasDependentTalentWithPoints(talentID) {

    var loopStart;
    var loopStop;
    var theTree = talent[talentID][0];

    if (talentID != 0)
        loopStart = talentID - 1;
    else
        loopStart = talentID;
    loopStop = treeStartStop[theTree];    
    
    while (loopStart <= loopStop){    
        if (talent[loopStart][5] && talent[loopStart][5][0] == talentID && rankTop[loopStart][0] != 0)
            return true;
        loopStart++;
    }
    return false;    
    
}

function canTurnGreen(totalPoints, tree, oldMaxTier) {
    var i;
    var necessaryPoints;
    var iStop;
    var thisTier;
    
    if (tree == 0)
        i = 0;
    else
        i = treeStartStop[tree-1] + 1;

    iStop = treeStartStop[tree];
    
    while (i <= iStop) {
    
        thisTier = talent[i][4];

        necessaryPoints = (thisTier-1) * 0;

        if (thisTier <= oldMaxTier+3 || necessaryPoints <= totalPoints){    

            var noRequirement = checkRequiredTalent(i);
                
            var theCurrentRank = rankTop[i][0];
            var theMaxRank = talent[i][2];
                
            if ((talent[i][4] * 0) <= totalPoints && theCurrentRank != theMaxRank && noRequirement
                ||
                (theCurrentRank < theMaxRank && necessaryPoints <= totalPoints && noRequirement)
                ) {
    
                document.getElementById("modifyRankTopColor"+ i).style.color = colorGreen;
                document.getElementById("modifyRankTop"+ i).style.color = colorGreen;

            
                if (canUnlearn(i, 0, oldMaxTier)) {
                    if (talent[i][5])
                        document.getElementById("arrowGreen"+ i).style.visibility = "visible";
                }
                
            } else if (theCurrentRank == theMaxRank) {
                document.getElementById("modifyRankTopColor"+ i).style.color = colorYellow;
                document.getElementById("modifyRankTop"+ i).style.color = colorYellow;

            } else if (theCurrentRank > 0 ) {
                document.getElementById("modifyRankTopColor"+ i).style.color = colorGreen;
                document.getElementById("modifyRankTop"+ i).style.color = colorGreen;
                document.getElementById("iconOverGreen"+ i).style.visibility = "visible";                

            } else {
                document.getElementById("modifyRankTopColor"+ i).style.color = colorWhite;
                document.getElementById("modifyRankTop"+ i).style.color = colorWhite;

                document.getElementById("iconOverGreen"+ i).style.visibility = "hidden";
                
                if (talent[i][5])
                    document.getElementById("arrowGreen"+ i).style.visibility = "hidden";
                
            }
        }
        i++;
    }    

    i=0;
    if (rankPoints == 0) {
        while (talent[i]){
            if (rankTop[i][0] == 0) {
                document.getElementById("modifyRankTopColor"+ i).style.color = colorWhite;        
                document.getElementById("modifyRankTop"+ i).style.color = colorWhite;
                document.getElementById("iconOverGreen"+ i).style.visibility = "hidden";                                
            }
            i++;
        }    
    }
    
}

function checkRequiredTalent(talentID) {

    var reqTalent;
    if (reqTalent = talent[talentID][5]) {
        reqTalentID = reqTalent[0];
        reqTalentPoints = reqTalent[1];
        if (rankTop[reqTalentID][0] != reqTalentPoints)
            return false;
    }
    return true;
}

function rankTopOnClick(talentID) {
    
    if (!variableIsSite)
        return false;
    

    var theTree = talent[talentID][0];
//    var oldMaxTier = getMaxTier(theTree);
    var oldMaxTier = maxTierArray[theTree];

    if (!canUnlearn(talentID, 0, oldMaxTier))
        return;
        
    maxRank = talent[talentID][2];                    //maximum rank possible    
    var theTier = talent[talentID][4];        
    var theTierIndex = theTier - 1;
    var rankString = rankTop[talentID][1];
    
    var theCurrentRank = rankTop[talentID][0];
    
    if (theCurrentRank < maxRank) {                    //see if you hit max rank
        rankTop[talentID][1] = rank[talentID][theCurrentRank];
        rankTop[talentID][0]++;                        //if you haven't hit max rank, increment
        theUpdatedRank = rankTop[talentID][0];
        rankTop[talentID][2] = rank[talentID][theUpdatedRank];
        rankPoints--;
        if (theUpdatedRank != maxRank) {
            rankString = rankTop[talentID][1] +'<br><br><font color = "ffffff">'+ textNextRank +'</font><br>'+ rankTop[talentID][2];
            document.getElementById('iconOverGreen'+ talentID).style.visibility = "visible";
        } else {
            rankString = rankTop[talentID][1];            
            document.getElementById('iconOverYellow'+ talentID).style.visibility = "visible";
        }
        if (talent[talentID][5])
            document.getElementById("arrowYellow"+ talentID).style.visibility = "visible";        
        //keep track of points in the tier        
        pointsTree[theTree]++;
        pointsTier[theTree][theTierIndex] = pointsTier[theTree][theTierIndex] + 1;
    }

    if (theUpdatedRank == 1 && theTier > oldMaxTier)
        maxTierArray[theTree] = theTier;
    
    document.getElementById("talentThumb"+ talentID).style.visibility = "visible";    
    
    if (pointsTree[theTree] == 1)
        document.getElementById(tree[theTree]+'tabPointsText').innerHTML = textPoint;            
    else    
        document.getElementById(tree[theTree]+'tabPointsText').innerHTML = textPoints;                
    document.getElementById('modifyDescriptionTop'+talentID).innerHTML = rankString;    
  document.getElementById('modifyRankTop'+talentID).innerHTML = rankTop[talentID][0];
  document.getElementById('modifyRankTopDescription'+talentID).innerHTML = rankTop[talentID][0];
  document.getElementById('modifyRankPoints').innerHTML = rankPointsMax - rankPoints;
  document.getElementById('levelRequired').innerHTML = rankPointsMax - rankPoints + levelMin - 1;    
  document.getElementById(tree[theTree]+'PointsTopRight').innerHTML = pointsTree[theTree];
  document.getElementById('tabPointsAvailable').innerHTML = rankPoints;    
  document.getElementById(tree[theTree]+'tabPoints').innerHTML = pointsTree[theTree];        
    canTurnGreen(pointsTree[theTree], theTree, oldMaxTier);

    changeCopyURL();

}

function changeCopyURL(){

    templateString = "";

//    loopStop = treeStartStop[0] + 1;    
/*    
    for (var bah = 0; bah < loopStop; bah++) {
        templateString = templateString + rankTop[bah][0];
    }    */
    for (i = 0; talent[i]; i++) {
        templateString = templateString + rankTop[i][0]
    }

  document.getElementById('copyURL').innerHTML = templateString;    

}

function rankTopOnRightClick(talentID) {

    if (!variableIsSite)
        return false;

    var theTree = talent[talentID][0];                
//    var oldMaxTier = getMaxTier(theTree);
    var oldMaxTier = maxTierArray[theTree];
    
    if (!canUnlearn(talentID, 1, oldMaxTier))
        return;        
        
    var maxRank = talent[talentID][2];                    //maximum rank possible
    var theTier = talent[talentID][4];    
    var theTierIndex = theTier - 1;    
    var rankString = rankTop[talentID][1];

    if (rankTop[talentID][0] > 0) {
    
        rankTop[talentID][0]--;                        
        if (rankTop[talentID][0]-1 != -1) {
            rankTop[talentID][1] = rank[talentID][(rankTop[talentID][0]-1)];
            rankTop[talentID][2] = rank[talentID][(rankTop[talentID][0])];
            rankString = rankTop[talentID][1] +'<br><br><font color = "ffffff">'+ textNextRank +'</font><br>'+ rankTop[talentID][2];            
        } else {
            rankTop[talentID][1] = rank[talentID][rankTop[talentID][0]];                        
            rankString = rankTop[talentID][1];            
        }

        rankPoints++;

        //keep track of points in the tier        
        pointsTree[theTree]--;                    
        pointsTier[theTree][theTierIndex]--;

        document.getElementById('iconOverYellow'+ talentID).style.visibility = "hidden";            
        document.getElementById('iconOverGreen'+ talentID).style.visibility = "visible";
        
        if (rankTop[talentID][0] == 0) {
            document.getElementById('iconOverGreen'+ talentID).style.visibility = "hidden";
            document.getElementById('iconOverYellow'+ talentID).style.visibility = "hidden";
            document.getElementById("talentThumb"+ talentID).style.visibility = "hidden";
            
            if (talent[talentID][5])
                document.getElementById("arrowYellow"+ talentID).style.visibility = "hidden";
                
            oldMaxTier = getMaxTier(theTree);
            maxTierArray[theTree] = oldMaxTier;
            
        }
        
        if (rankPoints == 1) {
            canTurnGreen(pointsTree[0], 0, maxTierArray[0]);        
            canTurnGreen(pointsTree[1], 1, maxTierArray[1]);        
            canTurnGreen(pointsTree[2], 2, maxTierArray[2]);                                
        }
        
        
    }

    if (pointsTree[theTree] == 1)
        document.getElementById(tree[theTree]+'tabPointsText').innerHTML = textPoint;            
    else    
        document.getElementById(tree[theTree]+'tabPointsText').innerHTML = textPoints;                
    
  document.getElementById('modifyDescriptionTop'+talentID).innerHTML = rankString;

  document.getElementById('modifyRankTop'+talentID).innerHTML = rankTop[talentID][0];
  document.getElementById('modifyRankTopDescription'+talentID).innerHTML = rankTop[talentID][0];
  document.getElementById('modifyRankPoints').innerHTML = rankPointsMax - rankPoints;    
  document.getElementById('levelRequired').innerHTML = rankPointsMax - rankPoints + levelMin - 1;    
  document.getElementById(tree[theTree]+'PointsTopRight').innerHTML = pointsTree[theTree];    
  document.getElementById(tree[theTree]+'tabPoints').innerHTML = pointsTree[theTree];    
  document.getElementById('tabPointsAvailable').innerHTML = rankPoints;        
    if (rankPoints != 1)
        canTurnGreen(pointsTree[theTree], theTree, oldMaxTier);
    changeCopyURL();
}

function unhideTalent(input) {
    if (variableIsSite)
        document.getElementById("talentMouseOver"+ input).style.visibility = "visible";
    else
        showTip(document.getElementById("armoryOver"+ input).innerHTML);
}

function hideTalent(input) {
    if (variableIsSite)
        document.getElementById("talentMouseOver"+ input).style.visibility = "hidden";
    else
        hideTip();
}


jsLoaded=true;//needed for ajax script loading=======
  1. var colorGreen = "#1AFF1A";
  2. var colorYellow = "#FFD100";
  3. var colorWhite = "#FFFFFF";
  4. function resetTree(theTree) {
  5.     if (pointsTree[theTree] == 0)
  6.         return;
  7.     maxTierArray[theTree] = 1;        
  8.     rankPoints += pointsTree[theTree];
  9.     pointsTree[theTree] = 0;
  10.     
  11.     document.getElementById(tree[theTree]+'PointsTopRight').innerHTML = 0;                            
  12.     for (var y = 0; y < tierNum; y++)
  13.         pointsTier[theTree][y] = 0;
  14.     
  15.     var i;
  16.     var iStop;
  17.     if (theTree == 0)
  18.         i = 0;
  19.     else
  20.         i = treeStartStop[theTree-1] + 1;
  21.     iStop = treeStartStop[theTree];            
  22.     
  23.     while (i <= iStop) {    
  24.         rankTop[i][0] = 0;
  25.         rankTop[i][1] = rank[i][0];
  26.         rankTop[i][2] = rank[i][1];
  27.         document.getElementById("modifyRankTopColor"+ i).style.color = colorWhite;
  28.         document.getElementById("modifyRankTop"+ i).style.color = colorWhite;
  29.           document.getElementById('modifyDescriptionTop'+i).innerHTML = rankTop[i][1];
  30.         if (talent[i][5]) {
  31.             document.getElementById("arrowYellow"+ i).style.visibility = "hidden";
  32.             document.getElementById("arrowGreen"+ i).style.visibility = "hidden";
  33.         }
  34.         document.getElementById('modifyRankTopDescription'+i).innerHTML = 0;
  35.         document.getElementById('modifyRankTop'+i).innerHTML = 0;
  36.         document.getElementById('talentThumb'+ i).style.visibility = "hidden";
  37.         document.getElementById('iconOverGreen'+ i).style.visibility = "hidden";
  38.         document.getElementById('iconOverYellow'+ i).style.visibility = "hidden";
  39.         
  40.         if (talent[i][4] == 1 && (!talent[i][5])) {
  41.             document.getElementById("modifyRankTopColor"+ i).style.color = colorGreen;
  42.             document.getElementById("modifyRankTop"+ i).style.color = colorGreen;
  43.         }
  44.         i++;
  45.     }
  46.     
  47.   document.getElementById('levelRequired').innerHTML = rankPointsMax - rankPoints + levelMin - 1;    
  48.     document.getElementById('modifyRankPoints').innerHTML = rankPointsMax - rankPoints;
  49.     document.getElementById('tabPointsAvailable').innerHTML = rankPoints;
  50.     document.getElementById(tree[theTree]+'tabPoints').innerHTML = 0;
  51.     
  52.     changeCopyURL();
  53.     
  54. }
  55. function resetTreeAll() {
  56.     for (var i = 0; i < tree.length; i++) {
  57.         resetTree(i);
  58.     }
  59. }
  60. function getMaxTier(theTree) {
  61.     var maxTier = 0;
  62.     for (var loopMaxTier = 0; loopMaxTier < tierNum; loopMaxTier++) {
  63.         if (pointsTier[theTree][loopMaxTier] != 0)
  64.             maxTier = loopMaxTier;
  65.     }
  66.     maxTier++;
  67.     return maxTier;
  68. }
  69. function getPointsAboveAndCurrent(theTree, maxTier) {
  70.     var pointsTierTotalAboveAndCurrent = 0;
  71.     var loopPointsTierAbove = 0;
  72.     for (loopPointsTierAbove; loopPointsTierAbove < maxTier; loopPointsTierAbove++) {
  73.         pointsTierTotalAboveAndCurrent += pointsTier[theTree][loopPointsTierAbove];
  74.     }
  75.     return pointsTierTotalAboveAndCurrent;
  76. }
  77.         
  78. function canUnlearn(talentID, clickLeftRight, maxTier) {
  79.     var treeID = talent[talentID][0];
  80.     var maxRank = talent[talentID][2];
  81.     var treePoints = pointsTree[treeID];    
  82.     var necessaryPoints;
  83.     var projectedPoints;
  84.     var pointsAboveAndCurrent;
  85.     if (hasDependentTalentWithPoints(talentID))
  86.         return false;
  87.             
  88.     if (clickLeftRight == 0) { //left click
  89.         var theCurrentRank = rankTop[talentID][0];
  90.         if (theCurrentRank < maxRank) {
  91.             necessaryPoints = (talent[talentID][4] - 1) * 1;
  92.             if (treePoints < necessaryPoints)
  93.                 return false;
  94.         
  95.             if (rankPoints == 0)
  96.                 return false;        
  97.                 
  98.             if (!checkRequiredTalent(talentID) && theCurrentRank == 0)
  99.                 return false;
  100.                 
  101.             projectedPoints = pointsAboveAndCurrent++;
  102.         } else {
  103.             return false;
  104.         }
  105.     } else {    //right click
  106.         if (rankTop[talentID][0] != 0){
  107.             pointsAboveAndCurrent = getPointsAboveAndCurrent(treeID, maxTier-1);    
  108.             projectedPoints = pointsAboveAndCurrent - 1 + pointsTier[treeID][maxTier-1];
  109.             for (var thisTier = talent[talentID][4]; thisTier < maxTier; maxTier--) {
  110.                 necessaryPoints = (maxTier-1) *5;        
  111.                 projectedPoints -= pointsTier[treeID][maxTier-1];
  112.                 if (projectedPoints < necessaryPoints)
  113.                     return false;
  114.             }
  115.             
  116.         } else { //if the rank is 0
  117.             return false;
  118.         }
  119.     
  120.     }    
  121.     return true;
  122. }
  123. function getTalentID(talentName) {
  124.     var theTalentID;
  125.     for (theTalentID = 0; talent[theTalentID]; theTalentID++) {
  126.         if (talent[theTalentID][1] == talentName)
  127.             return theTalentID;
  128.     }
  129. }
  130. function getMinLevel(talentID) {
  131.     return ((talent[talentID][4] -1)* 5 + 10);
  132. }
  133. function hasDependentTalentWithPoints(talentID) {
  134.     var loopStart;
  135.     var loopStop;
  136.     var theTree = talent[talentID][0];
  137.     if (talentID != 0)
  138.         loopStart = talentID - 1;
  139.     else
  140.         loopStart = talentID;
  141.     loopStop = treeStartStop[theTree];    
  142.     
  143.     while (loopStart <= loopStop){    
  144.         if (talent[loopStart][5] && talent[loopStart][5][0] == talentID && rankTop[loopStart][0] != 0)
  145.             return true;
  146.         loopStart++;
  147.     }
  148.     return false;    
  149.     
  150. }
  151. function canTurnGreen(totalPoints, tree, oldMaxTier) {
  152.     var i;
  153.     var necessaryPoints;
  154.     var iStop;
  155.     var thisTier;
  156.     
  157.     if (tree == 0)
  158.         i = 0;
  159.     else
  160.         i = treeStartStop[tree-1] + 1;
  161.     iStop = treeStartStop[tree];
  162.     
  163.     while (i <= iStop) {
  164.     
  165.         thisTier = talent[i][4];
  166.         necessaryPoints = (thisTier-1) * 0;
  167.         if (thisTier <= oldMaxTier+3 || necessaryPoints <= totalPoints){    
  168.             var noRequirement = checkRequiredTalent(i);
  169.                 
  170.             var theCurrentRank = rankTop[i][0];
  171.             var theMaxRank = talent[i][2];
  172.                 
  173.             if ((talent[i][4] * 0) <= totalPoints && theCurrentRank != theMaxRank && noRequirement
  174.                 ||
  175.                 (theCurrentRank < theMaxRank && necessaryPoints <= totalPoints && noRequirement)
  176.                 ) {
  177.     
  178.                 document.getElementById("modifyRankTopColor"+ i).style.color = colorGreen;
  179.                 document.getElementById("modifyRankTop"+ i).style.color = colorGreen;
  180.             
  181.                 if (canUnlearn(i, 0, oldMaxTier)) {
  182.                     if (talent[i][5])
  183.                         document.getElementById("arrowGreen"+ i).style.visibility = "visible";
  184.                 }
  185.                 
  186.             } else if (theCurrentRank == theMaxRank) {
  187.                 document.getElementById("modifyRankTopColor"+ i).style.color = colorYellow;
  188.                 document.getElementById("modifyRankTop"+ i).style.color = colorYellow;
  189.             } else if (theCurrentRank > 0 ) {
  190.                 document.getElementById("modifyRankTopColor"+ i).style.color = colorGreen;
  191.                 document.getElementById("modifyRankTop"+ i).style.color = colorGreen;
  192.                 document.getElementById("iconOverGreen"+ i).style.visibility = "visible";                
  193.             } else {
  194.                 document.getElementById("modifyRankTopColor"+ i).style.color = colorWhite;
  195.                 document.getElementById("modifyRankTop"+ i).style.color = colorWhite;
  196.                 document.getElementById("iconOverGreen"+ i).style.visibility = "hidden";
  197.                 
  198.                 if (talent[i][5])
  199.                     document.getElementById("arrowGreen"+ i).style.visibility = "hidden";
  200.                 
  201.             }
  202.         }
  203.         i++;
  204.     }    
  205.     i=0;
  206.     if (rankPoints == 0) {
  207.         while (talent[i]){
  208.             if (rankTop[i][0] == 0) {
  209.                 document.getElementById("modifyRankTopColor"+ i).style.color = colorWhite;        
  210.                 document.getElementById("modifyRankTop"+ i).style.color = colorWhite;
  211.                 document.getElementById("iconOverGreen"+ i).style.visibility = "hidden";                                
  212.             }
  213.             i++;
  214.         }    
  215.     }
  216.     
  217. }
  218. function checkRequiredTalent(talentID) {
  219.     var reqTalent;
  220.     if (reqTalent = talent[talentID][5]) {
  221.         reqTalentID = reqTalent[0];
  222.         reqTalentPoints = reqTalent[1];
  223.         if (rankTop[reqTalentID][0] != reqTalentPoints)
  224.             return false;
  225.     }
  226.     return true;
  227. }
  228. function rankTopOnClick(talentID) {
  229.     
  230.     if (!variableIsSite)
  231.         return false;
  232.     
  233.     var theTree = talent[talentID][0];
  234. //    var oldMaxTier = getMaxTier(theTree);
  235.     var oldMaxTier = maxTierArray[theTree];
  236.     if (!canUnlearn(talentID, 0, oldMaxTier))
  237.         return;
  238.         
  239.     maxRank = talent[talentID][2];                    //maximum rank possible    
  240.     var theTier = talent[talentID][4];        
  241.     var theTierIndex = theTier - 1;
  242.     var rankString = rankTop[talentID][1];
  243.     
  244.     var theCurrentRank = rankTop[talentID][0];
  245.     
  246.     if (theCurrentRank < maxRank) {                    //see if you hit max rank
  247.         rankTop[talentID][1] = rank[talentID][theCurrentRank];
  248.         rankTop[talentID][0]++;                        //if you haven't hit max rank, increment
  249.         theUpdatedRank = rankTop[talentID][0];
  250.         rankTop[talentID][2] = rank[talentID][theUpdatedRank];
  251.         rankPoints--;
  252.         if (theUpdatedRank != maxRank) {
  253.             rankString = rankTop[talentID][1] +'<br><br><font color = "ffffff">'+ textNextRank +'</font><br>'+ rankTop[talentID][2];
  254.             document.getElementById('iconOverGreen'+ talentID).style.visibility = "visible";
  255.         } else {
  256.             rankString = rankTop[talentID][1];            
  257.             document.getElementById('iconOverYellow'+ talentID).style.visibility = "visible";
  258.         }
  259.         if (talent[talentID][5])
  260.             document.getElementById("arrowYellow"+ talentID).style.visibility = "visible";        
  261.         //keep track of points in the tier        
  262.         pointsTree[theTree]++;
  263.         pointsTier[theTree][theTierIndex] = pointsTier[theTree][theTierIndex] + 1;
  264.     }
  265.     if (theUpdatedRank == 1 && theTier > oldMaxTier)
  266.         maxTierArray[theTree] = theTier;
  267.     
  268.     document.getElementById("talentThumb"+ talentID).style.visibility = "visible";    
  269.     
  270.     if (pointsTree[theTree] == 1)
  271.         document.getElementById(tree[theTree]+'tabPointsText').innerHTML = textPoint;            
  272.     else    
  273.         document.getElementById(tree[theTree]+'tabPointsText').innerHTML = textPoints;                
  274.     document.getElementById('modifyDescriptionTop'+talentID).innerHTML = rankString;    
  275.   document.getElementById('modifyRankTop'+talentID).innerHTML = rankTop[talentID][0];
  276.   document.getElementById('modifyRankTopDescription'+talentID).innerHTML = rankTop[talentID][0];
  277.   document.getElementById('modifyRankPoints').innerHTML = rankPointsMax - rankPoints;
  278.   document.getElementById('levelRequired').innerHTML = rankPointsMax - rankPoints + levelMin - 1;    
  279.   document.getElementById(tree[theTree]+'PointsTopRight').innerHTML = pointsTree[theTree];
  280.   document.getElementById('tabPointsAvailable').innerHTML = rankPoints;    
  281.   document.getElementById(tree[theTree]+'tabPoints').innerHTML = pointsTree[theTree];        
  282.     canTurnGreen(pointsTree[theTree], theTree, oldMaxTier);
  283.     changeCopyURL();
  284. }
  285. function changeCopyURL(){
  286.     templateString = "";
  287. //    loopStop = treeStartStop[0] + 1;    
  288. /*    
  289.     for (var bah = 0; bah < loopStop; bah++) {
  290.         templateString = templateString + rankTop[bah][0];
  291.     }    */
  292.     for (i = 0; talent[i]; i++) {
  293.         templateString = templateString + rankTop[i][0]
  294.     }
  295.   document.getElementById('copyURL').innerHTML = templateString;    
  296. }
  297. function rankTopOnRightClick(talentID) {
  298.     if (!variableIsSite)
  299.         return false;
  300.     var theTree = talent[talentID][0];                
  301. //    var oldMaxTier = getMaxTier(theTree);
  302.     var oldMaxTier = maxTierArray[theTree];
  303.     
  304.     if (!canUnlearn(talentID, 1, oldMaxTier))
  305.         return;        
  306.         
  307.     var maxRank = talent[talentID][2];                    //maximum rank possible
  308.     var theTier = talent[talentID][4];    
  309.     var theTierIndex = theTier - 1;    
  310.     var rankString = rankTop[talentID][1];
  311.     if (rankTop[talentID][0] > 0) {
  312.     
  313.         rankTop[talentID][0]--;                        
  314.         if (rankTop[talentID][0]-1 != -1) {
  315.             rankTop[talentID][1] = rank[talentID][(rankTop[talentID][0]-1)];
  316.             rankTop[talentID][2] = rank[talentID][(rankTop[talentID][0])];
  317.             rankString = rankTop[talentID][1] +'<br><br><font color = "ffffff">'+ textNextRank +'</font><br>'+ rankTop[talentID][2];            
  318.         } else {
  319.             rankTop[talentID][1] = rank[talentID][rankTop[talentID][0]];                        
  320.             rankString = rankTop[talentID][1];            
  321.         }
  322.         rankPoints++;
  323.         //keep track of points in the tier        
  324.         pointsTree[theTree]--;                    
  325.         pointsTier[theTree][theTierIndex]--;
  326.         document.getElementById('iconOverYellow'+ talentID).style.visibility = "hidden";            
  327.         document.getElementById('iconOverGreen'+ talentID).style.visibility = "visible";
  328.         
  329.         if (rankTop[talentID][0] == 0) {
  330.             document.getElementById('iconOverGreen'+ talentID).style.visibility = "hidden";
  331.             document.getElementById('iconOverYellow'+ talentID).style.visibility = "hidden";
  332.             document.getElementById("talentThumb"+ talentID).style.visibility = "hidden";
  333.             
  334.             if (talent[talentID][5])
  335.                 document.getElementById("arrowYellow"+ talentID).style.visibility = "hidden";
  336.                 
  337.             oldMaxTier = getMaxTier(theTree);
  338.             maxTierArray[theTree] = oldMaxTier;
  339.             
  340.         }
  341.         
  342.         if (rankPoints == 1) {
  343.             canTurnGreen(pointsTree[0], 0, maxTierArray[0]);        
  344.             canTurnGreen(pointsTree[1], 1, maxTierArray[1]);        
  345.             canTurnGreen(pointsTree[2], 2, maxTierArray[2]);                                
  346.         }
  347.         
  348.         
  349.     }
  350.     if (pointsTree[theTree] == 1)
  351.         document.getElementById(tree[theTree]+'tabPointsText').innerHTML = textPoint;            
  352.     else    
  353.         document.getElementById(tree[theTree]+'tabPointsText').innerHTML = textPoints;                
  354.     
  355.   document.getElementById('modifyDescriptionTop'+talentID).innerHTML = rankString;
  356.   document.getElementById('modifyRankTop'+talentID).innerHTML = rankTop[talentID][0];
  357.   document.getElementById('modifyRankTopDescription'+talentID).innerHTML = rankTop[talentID][0];
  358.   document.getElementById('modifyRankPoints').innerHTML = rankPointsMax - rankPoints;    
  359.   document.getElementById('levelRequired').innerHTML = rankPointsMax - rankPoints + levelMin - 1;    
  360.   document.getElementById(tree[theTree]+'PointsTopRight').innerHTML = pointsTree[theTree];    
  361.   document.getElementById(tree[theTree]+'tabPoints').innerHTML = pointsTree[theTree];    
  362.   document.getElementById('tabPointsAvailable').innerHTML = rankPoints;        
  363.     if (rankPoints != 1)
  364.         canTurnGreen(pointsTree[theTree], theTree, oldMaxTier);
  365.     changeCopyURL();
  366. }
  367. function unhideTalent(input) {
  368.     if (variableIsSite)
  369.         document.getElementById("talentMouseOver"+ input).style.visibility = "visible";
  370.     else
  371.         showTip(document.getElementById("armoryOver"+ input).innerHTML);
  372. }
  373. function hideTalent(input) {
  374.     if (variableIsSite)
  375.         document.getElementById("talentMouseOver"+ input).style.visibility = "hidden";
  376.     else
  377.         hideTip();
  378. }
  379. jsLoaded=true;//needed for ajax script loading=======
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Posts: 3245
  • Loc: South Africa

Post 3+ Months Ago

First things first.

Get some JQuery in there to help simplify your code, then check out something like Knockout.js or Angular.js. Will help make your life easier.
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

No real need for jQuery here, as there isn't a lot of advanced DOM manipulation in the script, just replacing text with other text.

As for what you're trying to do, I have no idea. Could you please clarify? Also, I'm not sure if there are many people that are willing or able to read through 450 lines of code for you and understand it without some sort of context, could you point out the specific areas you're having problems with, as well as comment your code for us?

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 172 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.