/, function(match)
{
match = match.substring(4, match.length - 1);
match = match.charAt(0).toUpperCase() + match.slice(1);
return "";
});
desc = desc.replace(/<\/c>/, "");
return (desc !== "" ? desc + "
" : desc);
};
/**
* Returns the description for the tooltip if the item is a consumable, or
* "" otherwise.
*
* @method getConsumableDescription
* @return {string} the description for the tooltip if the item is a
* consumable, or "" otherwise.
*/
var getConsumableDescription = function()
{
if(_item.type !== "Consumable")
return "";
var desc = _item.description;
if(desc === undefined || desc === "")
if(_item.details.description !== undefined &&
_item.details.description !== "")
desc = _item.details.description;
else
desc = "";
switch(_item.details.type)
{
case "Booze":
return "Double-click to consume.
" +
"Excessive alcohol consumption will result in" +
"intoxication.
";
case "Food":
case "Utility":
return "Double-click to consume.
" +
"" +
"Nourishment(" + _item.details.duration_ms / 60000 +
"m): " +
desc.replace(/(?:\r\n|\r|\n)/g,
"
") + "
";
case "Generic":
return "Double-click to consume.
" +
desc.replace(/(?:\r\n|\r|\n)/g,
"
") + "
";
default:
return "Double-click to consume.
" +
getDescription();
}
};
/**
* Returns the level of the item for the tooltip.
*
* @method getLevel
* @return {string} the level of the item for the tooltip.
*/
var getLevel = function()
{
return (
_item.level > 0 ?
"Required Level: " + _item.level + "
" :
""
);
};
/**
* Returns the flags of the item for the tooltip.
*
* @method getFlags
* @return {string} the flags of the item for the tooltip.
*/
var getFlags = function()
{
var part = "",
flags = _item.flags;
// Unique
if(Polyfill.indexOf(flags, "Unique") >= 0)
part += "Unique
";
// Account bound
if(Polyfill.indexOf(flags, "AccountBound") >= 0)
if(Polyfill.indexOf(flags, "AccountBindOnUse") >= 0)
part += "Account Bound on Acquire or Use
";
else
part += "Account Bound on Acquire
";
else if(Polyfill.indexOf(flags, "AccountBindOnUse") >= 0)
part += "Account Bound on Use
";
// Soul bound
if(Polyfill.indexOf(flags, "SoulbindOnAcquire") >= 0)
if(Polyfill.indexOf(flags, "SoulbindOnUse") >= 0)
part += "Soulbound on Acquire or Use
";
else
part += "Soulbound on Acquire
";
else if(Polyfill.indexOf(flags, "SoulbindOnUse") >= 0)
part += "Soulbound on Use
";
/* Not actually used in-game
// Sold or salvaged
if(Polyfill.indexOf(flags, "NoSalvage") >= 0)
if(Polyfill.indexOf(flags, "NoSell") >= 0)
part += "Can\'t be sold or salvaged
";
else
part += "Can\'t be salvaged
";
else
part += "Can\'t be sold
";*/
return part;
};
/**
* Returns the rarity of the item for the tooltip.
*
* @method getRarity
* @return {string} the rarity of the item for the tooltip.
*/
var getRarity = function()
{
return (
_item.rarity == "Basic" ?
"" :
_item.rarity + "
"
);
};
/**
* Returns the value of the item for the tooltip.
*
* @method getValue
* @return {string} the value of the item for the tooltip.
*/
var getValue = function()
{
if(Polyfill.indexOf(_item.flags, "NoSell") > -1)
return "";
var part = "",
value = item.vendor_value,
multiplier;
if(value >= 10000)
{
multiplier = Math.floor(value / 10000);
value -= multiplier * 10000;
part += "" +
"" +
multiplier +
" " +
" ";
}
if(value >= 100 || part.length > 0)
{
multiplier = Math.floor(value / 100);
value -= multiplier * 100;
part += "" +
"" +
multiplier +
" " +
" ";
}
if(value >= 1 || part.length > 0)
{
part += "" +
"" +
value +
" " +
"";
}
return part;
};
/**
* List of tooltip generators for subtypes.
*
* @type {Object}
*/
var tooltipString =
{
/**
* Returns the tooltip string for an armor piece.
*
* @method
* @return {string} the tooltip string for an armor piece.
*/
Armor : function()
{
return "" +
getHeader() +
"Defense: " + _item.details.defense + "
" +
getAttributes(true) +
getInfusionSlots(true) +
getRarity() +
_item.details.weight_class + "
" +
getArmorType() + " Armor
" +
getLevel() +
getDescription() +
getFlags() +
getValue();
},
/**
* Returns the tooltip string for a back item.
*
* @method
* @return {string} the tooltip string for a back item.
*/
Back : function()
{
return "" +
getHeader() +
"
" +
getRarity() +
"Back Item
" +
getDescription() +
getLevel() +
getFlags() +
getValue();
},
/**
* Returns the tooltip string for a bag.
*
* @method
* @return {string} the tooltip string for a bag.
*/
Bag : function()
{
return "" +
getHeader() +
"
" +
getDescription() +
getLevel() +
getValue();
},
/**
* Returns the tooltip string for a consumable.
*
* @method
* @return {string} the tooltip string for a consumable.
*/
Consumable : function()
{
return "" +
getHeader() +
getConsumableDescription() +
"
" +
"Consumable
" +
getLevel() +
getFlags() +
getValue();
},
/**
* Returns the tooltip string for a container.
*
* @method
* @return {string} the tooltip string for a container.
*/
Container : function()
{
return "" +
getHeader() +
getDescription() +
"
" +
"Consumable
" +
getFlags() +
getValue();
},
/**
* Returns the tooltip string for a gathering tool.
*
* @method
* @return {string} the tooltip string for a gathering tool.
*/
Gathering : function()
{
return "" +
getHeader() +
getDescription() +
(_item.level > 0 ? "
" : "") +
getLevel() +
getFlags();
},
/**
* Returns the tooltip string for a gizmo.
*
* @method
* @return {string} the tooltip string for a gizmo.
*/
Gizmo : function()
{
return "" +
getHeader() +
getDescription() +
getFlags() +
getValue();
},
/**
* Returns the tooltip string for a miniature.
*
* @method
* @return {string} the tooltip string for a miniature.
*/
MiniPet : function()
{
return "" +
getHeader() +
getDescription() +
"
" +
"Miniature
" +
getFlags();
},
/**
* Returns the tooltip string for a salvage kit.
*
* @method
* @return {string} the tooltip string for a salvage kit.
*/
Tool : function()
{
return "" +
getHeader() + "
" +
getRarity() +
"Consumable
" +
getDescription() +
getFlags();
},
/**
* Returns the tooltip string for a trinket.
*
* @method
* @return {string} the tooltip string for a trinket.
*/
Trinket : function()
{
return "" +
getHeader() +
getAttributes(true) +
getInfusionSlots(true) +
getRarity() +
_item.details.type + "
" +
getLevel() +
getDescription() +
getFlags() +
getValue();
},
/**
* Returns the tooltip string for a trophy.
*
* @method
* @return {string} the tooltip string for a trophy.
*/
Trophy : function()
{
return "" +
getHeader() +
getDescription() +
"
" +
"Trophy
" +
getFlags() +
getValue();
},
/**
* Returns the tooltip string for an upgrade component.
*
* @method
* @return {string} the tooltip string for an upgrade component.
*/
UpgradeComponent : function()
{
return "" +
getHeader() +
"
" +
getBuffs() +
getDescription() +
getLevel() +
(_item.details.type === "Gem" ? "
" : "") +
getValue();
},
/**
* Returns the tooltip string for a weapon.
*
* @method
* @return {string} the tooltip string for a weapon.
*/
Weapon : function()
{
return "" +
getHeader() +
"Weapon Strength: " +
Polyfill.commaSeparate(_item.details.min_power) + " - " +
Polyfill.commaSeparate(_item.details.max_power) + "
" +
getAttributes(true) +
getInfusionSlots(true) +
getRarity() +
_item.details.type + "
" +
"(" + getWeaponType() + ")
" +
getLevel() +
getDescription() +
getFlags() +
getValue();
},
/**
* Returns the tooltip string for a generic item. Used for crafting
* materials( and traits).
*
* @method
* @return {string} the tooltip string for a generic item.
*/
Generic : function()
{
return "" +
getHeader() +
getDescription() +
getFlags() +
"
" +
getValue();
}
};
/**
* Returns the tooltip string appropriate for the item.
*
* @method getTooltip
* @return {string} the tooltip string appropriate for the item.
*/
this.getTooltip = function()
{
var tooltip = "";
return tooltip;
};
}
ItemTooltip.type = "items";
ItemTooltip.attr = "itemid";