JHunz's KOL Consumption Management

By JHunz Last update Apr 21, 2008 — Installed 652,500 times.

Fix due to layout changes

in
Subscribe to Fix due to layout changes 1 post, 1 voice

Phaque Scriptwright

It seems like the inventory code is a little different now, which affected the sorting of the inventory items. Here's a quick fix for the SortInv function:

Basically, I just adjusted the foodParents and drinkParents xpath to be more specific and tweaked the re-adding of item nodes.

function SortInv(foodNodeArray,drinkNodeArray) {
//Remove the inventory nodes from their parents
for (i=0;i<foodnodearray>
foodNodeArray[i].node.parentNode.removeChild(foodNodeArray[i].node);
foodNodeArray[i].imgNode.parentNode.removeChild(foodNodeArray[i].imgNode);
}
for (i=0;i<drinknodearray>
drinkNodeArray[i].node.parentNode.removeChild(drinkNodeArray[i].node);
drinkNodeArray[i].imgNode.parentNode.removeChild(drinkNodeArray[i].imgNode);
}

if (invSortOrder == 'totalAdv') {
foodNodeArray.sort(TotalAdvSort);
drinkNodeArray.sort(TotalAdvSort);
}
else if (invSortOrder == 'perAdv') {
foodNodeArray.sort(PerAdvSort);
drinkNodeArray.sort(PerAdvSort);
}
else if (invSortOrder == 'alpha') {
foodNodeArray.sort(AlphaSort);
drinkNodeArray.sort(AlphaSort);
}

//Re-sort the arrays
var foodParents = document.evaluate('//div[@id="section1"]//table[@class="item"]//tr',document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
var drinkParents = document.evaluate('//div[@id="section2"]//table[@class="item"]//tr',document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);

//Re-add the food in the new order
for (i=0;i<foodparents>
curParent = foodParents.snapshotItem(i);
curParent.appendChild(foodNodeArray[i].imgNode);
curParent.appendChild(foodNodeArray[i].node);
}

//Re-add the booze in the new order
for (i=0;i<drinkparents>
curParent = drinkParents.snapshotItem(i);
curParent.appendChild(drinkNodeArray[i].imgNode);
curParent.appendChild(drinkNodeArray[i].node);
}
}