diff --git a/lib/tpl/wow-item-template.tpl b/lib/tpl/wow-item-template.tpl
new file mode 100644
index 0000000..389a110
--- /dev/null
+++ b/lib/tpl/wow-item-template.tpl
@@ -0,0 +1,107 @@
+
\ No newline at end of file
diff --git a/lib/tpl/wow-itemextendedcost-template.tpl b/lib/tpl/wow-itemextendedcost-template.tpl
new file mode 100644
index 0000000..d281cd1
--- /dev/null
+++ b/lib/tpl/wow-itemextendedcost-template.tpl
@@ -0,0 +1,27 @@
+
\ No newline at end of file
diff --git a/lib/wow_tooltips.js b/lib/wow_tooltips.js
index a324963..532aabc 100644
--- a/lib/wow_tooltips.js
+++ b/lib/wow_tooltips.js
@@ -1,3 +1,6 @@
+var items = {};
+var itemextendedcosts = {};
+
var wow_quality = {
0: "trash",
1: "common",
@@ -176,8 +179,6 @@ var wow_socketbonus = {
3313: "+8 Agility",
3305: "+12 Stamina",
3353: "+8 Intellect",
- 2872: "+9 Healing",
- 3877: "+16 Attack Power",
2900: "+4 Spell Power",
2872: "+5 Spell Power",
@@ -192,17 +193,15 @@ var wow_socketbonus = {
440: "+9 Spell Power",
2314: "+9 Spell Power",
3753: "+9 Spell Power",
-/*
-3114": stats.AttackPower += 4; break;
-2936": stats.AttackPower += 8; break;
-1587":
-3356":
-3764": stats.AttackPower += 12; break;
-3877":
-1589": stats.AttackPower += 16; break;
-1597": stats.AttackPower += 32; break;
- #endregion
- #region Stamina
+ 3114: "+4 Attack Power",
+ 2936: "+8 Attack Power",
+ 1587: "+8 Attack Power",
+ 3356: "+8 Attack Power",
+ 3764: "+12 Attack Power",
+ 3877: "+12 Attack Power",
+ 1589: "+16 Attack Power",
+ 1597: "+32 Attack Power",
+ /*
2895": stats.Stamina += 4; break;
2868":
2882": stats.Stamina += 6; break;
@@ -395,8 +394,6 @@ var wow_spelltrigger = {
}
function wow_tooltips(){
- //item hover
- var items = {}
Handlebars.registerHelper("speed", function( speed ) {
return speed.toFixed(2);
});
@@ -419,137 +416,23 @@ function wow_tooltips(){
return new Handlebars.SafeString( classes );
});
+ //item hover
var source = $("#wow-item-template").html();
- var template = Handlebars.compile(source);
+ var template_item = Handlebars.compile(source);
+ var source = $("#wow-itemextendedcost-template").html();
+ var template_itemextendedcost = Handlebars.compile(source);
var $body = $("body");
var $wowIcons = $(".wow-icon");
var lastHovered;
$wowIcons.each(function(k,v) {
var $this = $(this);
- var id = $this.data("item-id");
- $.getJSON('./api.php?call=tbc&action=item&id='+id,function(json){
- if(!json || json.status !== true || !json.result){
- return;}
-
- //Quality strings
- json.result.quality = wow_quality[json.result.Quality];
-
- //bonding
- json.result.binds = wow_bonding[json.result.bonding];
-
- //Inventory Type
- json.result.slot = wow_inventorytype[json.result.InventoryType];
-
- //class & subclass
- json.result.type = wow_class_subclass[json.result.class][json.result.subclass];
-
- //flags
- json.result.unique = json.result.flags % 524288 === 0 ? 'true' : 'false';
-
- //dmg
- if(json.result.dmg_min1 > 0 || json.result.dmg_max1 > 0){
- json.result.damage = { min: json.result.dmg_min1,
- max: json.result.dmg_max1,
- speed: json.result.delay / 1000}
- }
-
- //stats
- json.result.stats = {};
- if(json.result.stat_type1 !== 0){
- json.result.stats[0] = {stat: wow_statstype[json.result.stat_type1], value: json.result.stat_value1, type: json.result.stat_type1 <= 7 ? "primary" : "secondary" };}
- if(json.result.stat_type2 !== 0){
- json.result.stats[1] = {stat: wow_statstype[json.result.stat_type2], value: json.result.stat_value2, type: json.result.stat_type2 <= 7 ? "primary" : "secondary" };}
- if(json.result.stat_type3 !== 0){
- json.result.stats[2] = {stat: wow_statstype[json.result.stat_type3], value: json.result.stat_value3, type: json.result.stat_type3 <= 7 ? "primary" : "secondary" };}
- if(json.result.stat_type4 !== 0){
- json.result.stats[3] = {stat: wow_statstype[json.result.stat_type4], value: json.result.stat_value4, type: json.result.stat_type4 <= 7 ? "primary" : "secondary" };}
- if(json.result.stat_type5 !== 0){
- json.result.stats[4] = {stat: wow_statstype[json.result.stat_type5], value: json.result.stat_value5, type: json.result.stat_type5 <= 7 ? "primary" : "secondary" };}
- if(json.result.stat_type6 !== 0){
- json.result.stats[5] = {stat: wow_statstype[json.result.stat_type6], value: json.result.stat_value6, type: json.result.stat_type6 <= 7 ? "primary" : "secondary" };}
- if(json.result.stat_type7 !== 0){
- json.result.stats[6] = {stat: wow_statstype[json.result.stat_type7], value: json.result.stat_value7, type: json.result.stat_type7 <= 7 ? "primary" : "secondary" };}
- if(json.result.stat_type8 !== 0){
- json.result.stats[7] = {stat: wow_statstype[json.result.stat_type8], value: json.result.stat_value8, type: json.result.stat_type8 <= 7 ? "primary" : "secondary" };}
- if(json.result.stat_type9 !== 0){
- json.result.stats[8] = {stat: wow_statstype[json.result.stat_type9], value: json.result.stat_value9, type: json.result.stat_type9 <= 7 ? "primary" : "secondary" };}
- if(json.result.stat_type10 !== 0){
- json.result.stats[9] = {stat: wow_statstype[json.result.stat_type10], value: json.result.stat_value10, type: json.result.stat_type10 <= 7 ? "primary" : "secondary" };}
-
- json.result.enchantments = {};
- //socket
- json.result.enchantments.sockets = {};
- if(json.result.socketColor_1 !== 0){
- json.result.enchantments.sockets[0] = {color: wow_socketcolor[json.result.socketColor_1]};}
- if(json.result.socketColor_2 !== 0){
- json.result.enchantments.sockets[1] = {color: wow_socketcolor[json.result.socketColor_2]};}
- if(json.result.socketColor_3 !== 0){
- json.result.enchantments.sockets[2] = {color: wow_socketcolor[json.result.socketColor_3]};}
-
- json.result.enchantments.socketBonus = wow_socketbonus[json.result.socketBonus];
-
- //Classes
- json.result.classes = [];
- if(json.result.AllowableClass !== -1){
- if(json.result.AllowableClass % 1 === 0){
- json.result.classes.push("Warrior");}
- if(json.result.AllowableClass % 2 === 0){
- json.result.classes.push("Paladin");}
- if(json.result.AllowableClass % 4 === 0){
- json.result.classes.push("Hunter");}
- if(json.result.AllowableClass % 8 === 0){
- json.result.classes.push("Rogue");}
- if(json.result.AllowableClass % 16 === 0){
- json.result.classes.push("Priest");}
- if(json.result.AllowableClass % 32 === 0){
- json.result.classes.push("Death Knight");}
- if(json.result.AllowableClass % 64 === 0){
- json.result.classes.push("Shaman");}
- if(json.result.AllowableClass % 128 === 0){
- json.result.classes.push("Mage");}
- if(json.result.AllowableClass % 256 === 0){
- json.result.classes.push("Warlock");}
- if(json.result.AllowableClass % 512 === 0){
- json.result.classes.push("Monk");}
- if(json.result.AllowableClass % 1024 === 0){
- json.result.classes.push("Druid");}
- }
-
- //Set
-
- //spells
- json.result.bonuses = [];
- if(json.result.spellid_1 !== 0){
- json.result.bonuses[0] = {description: wow_spelltrigger[json.result.spelltrigger_1]+': '+json.result.spelltext_1};}
- if(json.result.spellid_2 !== 0){
- json.result.bonuses[1] = {description: wow_spelltrigger[json.result.spelltrigger_2]+': '+json.result.spelltext_2};}
- if(json.result.spellid_3 !== 0){
- json.result.bonuses[2] = {description: wow_spelltrigger[json.result.spelltrigger_3]+': '+json.result.spelltext_3};}
- if(json.result.spellid_4 !== 0){
- json.result.bonuses[3] = {description: wow_spelltrigger[json.result.spelltrigger_4]+': '+json.result.spelltext_4};}
- if(json.result.spellid_5 !== 0){
- json.result.bonuses[4] = {description: wow_spelltrigger[json.result.spelltrigger_5]+': '+json.result.spelltext_5};}
-
- //Price
- var sp = json.result.SellPrice;
- if(sp / 10000 >= 1){
- json.result.price_gold = Math.floor(sp / 10000);
- sp = sp % 10000;}
- if(sp / 100 >= 1){
- json.result.price_silver = Math.floor(sp / 100);
- sp = sp % 100;}
- if(sp => 1){
- json.result.price_copper = sp;}
-
- items[json.result.entry] = json.result;
- if( json.result.icon ) {
- $this.css({"background-image": "url(http://wow.zamimg.com/images/wow/icons/medium/"+ json.result.icon +".jpg)"});
- }
- if( json.result.stack ) {
- $this.append(""+json.result.stack+"");}
- });
-
+ var item_id = $this.data("item-id");
+ var itemextendedcost_id = $this.data("itemextendedcost-id");
+ if (typeof item_id !== "undefined") {
+ wow_tooltips_item(item_id,$this);
+ } else if(typeof itemextendedcost_id !== "undefined"){
+ wow_tooltips_itemextendedcost(itemextendedcost_id,$this);}
});
$wowIcons.on("mouseover.wow", function(e) {
@@ -558,15 +441,19 @@ function wow_tooltips(){
if( !lastHovered || !lastHovered.is( $this ) ) {
- var id = $this.data("item-id");
- $html = $( template(items[id]) );
+ var item_id = $this.data("item-id");
+ var itemextendedcost_id = $this.data("itemextendedcost-id");
+ if (typeof item_id !== "undefined") {
+ $html = $( template_item(items[item_id]) );
+ } else if(typeof itemextendedcost_id !== "undefined"){
+ $html = $( template_itemextendedcost(itemextendedcosts[itemextendedcost_id]) );}
$body.find(".wow-item").remove();
$body.append( $html );
$html.css({
- left: e.clientX + 20,
- top: e.clientY - 10
+ left: e.pageX + 20,
+ top: e.pageY - 10 - $(window).scrollTop()
});
lastHovered = $this;
@@ -581,8 +468,8 @@ function wow_tooltips(){
$this.on("mousemove.wow", function(e) {
$html.css({
- left: e.clientX + 20,
- top: e.clientY - 30
+ left: e.pageX + 20,
+ top: e.pageY - 30 - $(window).scrollTop()
});
});
@@ -593,13 +480,158 @@ function wow_tooltips(){
$(this).off("mousemove.wow");
});
- $body.on("mouseover.wow", ".wow-item" , function(e) {
+ //$body.on("mouseover.wow", ".wow-item" , function(e) {
//$(this).removeClass("hidden");
- });
+ //});
$body.on("mouseout.wow", ".wow-item" , function(e) {
$(this).addClass("hidden");
});
+}
+
+function wow_tooltips_itemextendedcost(id,$this){
+ if(id <= 0){
+ return;}
+ $.getJSON('./api.php?call=tbc&action=itemextendedcost&id='+id,function(json){
+ if(!json || json.status !== true || !json.result){
+ return;}
+
+ itemextendedcosts[json.result.entry] = json.result;
+ if( json.result.icon ) {
+ $this.css({"background-image": "url(http://wow.zamimg.com/images/wow/icons/medium/"+ json.result.icon +".jpg)"});
+ }
+ if( json.result.stack ) {
+ $this.append(""+json.result.stack+"");}
+ });
+}
+
+function wow_tooltips_item(id,$this){
+ if(id <= 0){
+ return;}
+ $.getJSON('./api.php?call=tbc&action=item&id='+id,function(json){
+ if(!json || json.status !== true || !json.result){
+ return;}
+
+ //Quality strings
+ json.result.quality = wow_quality[json.result.Quality];
+
+ //bonding
+ json.result.binds = wow_bonding[json.result.bonding];
+
+ //Inventory Type
+ json.result.slot = wow_inventorytype[json.result.InventoryType];
+
+ //class & subclass
+ json.result.type = wow_class_subclass[json.result.class][json.result.subclass];
+
+ //flags
+ json.result.unique = json.result.flags % 524288 === 0 ? 'true' : 'false';
+
+ //dmg
+ if(json.result.dmg_min1 > 0 || json.result.dmg_max1 > 0){
+ json.result.damage = { min: json.result.dmg_min1,
+ max: json.result.dmg_max1,
+ speed: json.result.delay / 1000}
+ }
+
+ //stats
+ json.result.stats = {};
+ if(json.result.stat_type1 !== 0){
+ json.result.stats[0] = {stat: wow_statstype[json.result.stat_type1], value: json.result.stat_value1, type: json.result.stat_type1 <= 7 ? "primary" : "secondary" };}
+ if(json.result.stat_type2 !== 0){
+ json.result.stats[1] = {stat: wow_statstype[json.result.stat_type2], value: json.result.stat_value2, type: json.result.stat_type2 <= 7 ? "primary" : "secondary" };}
+ if(json.result.stat_type3 !== 0){
+ json.result.stats[2] = {stat: wow_statstype[json.result.stat_type3], value: json.result.stat_value3, type: json.result.stat_type3 <= 7 ? "primary" : "secondary" };}
+ if(json.result.stat_type4 !== 0){
+ json.result.stats[3] = {stat: wow_statstype[json.result.stat_type4], value: json.result.stat_value4, type: json.result.stat_type4 <= 7 ? "primary" : "secondary" };}
+ if(json.result.stat_type5 !== 0){
+ json.result.stats[4] = {stat: wow_statstype[json.result.stat_type5], value: json.result.stat_value5, type: json.result.stat_type5 <= 7 ? "primary" : "secondary" };}
+ if(json.result.stat_type6 !== 0){
+ json.result.stats[5] = {stat: wow_statstype[json.result.stat_type6], value: json.result.stat_value6, type: json.result.stat_type6 <= 7 ? "primary" : "secondary" };}
+ if(json.result.stat_type7 !== 0){
+ json.result.stats[6] = {stat: wow_statstype[json.result.stat_type7], value: json.result.stat_value7, type: json.result.stat_type7 <= 7 ? "primary" : "secondary" };}
+ if(json.result.stat_type8 !== 0){
+ json.result.stats[7] = {stat: wow_statstype[json.result.stat_type8], value: json.result.stat_value8, type: json.result.stat_type8 <= 7 ? "primary" : "secondary" };}
+ if(json.result.stat_type9 !== 0){
+ json.result.stats[8] = {stat: wow_statstype[json.result.stat_type9], value: json.result.stat_value9, type: json.result.stat_type9 <= 7 ? "primary" : "secondary" };}
+ if(json.result.stat_type10 !== 0){
+ json.result.stats[9] = {stat: wow_statstype[json.result.stat_type10], value: json.result.stat_value10, type: json.result.stat_type10 <= 7 ? "primary" : "secondary" };}
+
+ json.result.enchantments = {};
+ //socket
+ json.result.enchantments.sockets = {};
+ if(json.result.socketColor_1 !== 0){
+ json.result.enchantments.sockets[0] = {color: wow_socketcolor[json.result.socketColor_1]};}
+ if(json.result.socketColor_2 !== 0){
+ json.result.enchantments.sockets[1] = {color: wow_socketcolor[json.result.socketColor_2]};}
+ if(json.result.socketColor_3 !== 0){
+ json.result.enchantments.sockets[2] = {color: wow_socketcolor[json.result.socketColor_3]};}
+
+ json.result.enchantments.socketBonus = wow_socketbonus[json.result.socketBonus];
+
+ //Classes
+ json.result.classes = [];
+ if(json.result.AllowableClass !== -1){
+ if(json.result.AllowableClass % 1 === 0){
+ json.result.classes.push("Warrior");}
+ if(json.result.AllowableClass % 2 === 0){
+ json.result.classes.push("Paladin");}
+ if(json.result.AllowableClass % 4 === 0){
+ json.result.classes.push("Hunter");}
+ if(json.result.AllowableClass % 8 === 0){
+ json.result.classes.push("Rogue");}
+ if(json.result.AllowableClass % 16 === 0){
+ json.result.classes.push("Priest");}
+ if(json.result.AllowableClass % 32 === 0){
+ json.result.classes.push("Death Knight");}
+ if(json.result.AllowableClass % 64 === 0){
+ json.result.classes.push("Shaman");}
+ if(json.result.AllowableClass % 128 === 0){
+ json.result.classes.push("Mage");}
+ if(json.result.AllowableClass % 256 === 0){
+ json.result.classes.push("Warlock");}
+ if(json.result.AllowableClass % 512 === 0){
+ json.result.classes.push("Monk");}
+ if(json.result.AllowableClass % 1024 === 0){
+ json.result.classes.push("Druid");}
+ }
+
+ //Set
+
+ //spells
+ json.result.bonuses = [];
+ if(json.result.spellid_1 !== 0){
+ json.result.bonuses[0] = {description: wow_spelltrigger[json.result.spelltrigger_1]+': '+json.result.spelltext_1};}
+ if(json.result.spellid_2 !== 0){
+ json.result.bonuses[1] = {description: wow_spelltrigger[json.result.spelltrigger_2]+': '+json.result.spelltext_2};}
+ if(json.result.spellid_3 !== 0){
+ json.result.bonuses[2] = {description: wow_spelltrigger[json.result.spelltrigger_3]+': '+json.result.spelltext_3};}
+ if(json.result.spellid_4 !== 0){
+ json.result.bonuses[3] = {description: wow_spelltrigger[json.result.spelltrigger_4]+': '+json.result.spelltext_4};}
+ if(json.result.spellid_5 !== 0){
+ json.result.bonuses[4] = {description: wow_spelltrigger[json.result.spelltrigger_5]+': '+json.result.spelltext_5};}
+
+ //Price
+ var sp = json.result.SellPrice;
+ if(sp / 10000 >= 1){
+ json.result.price_gold = Math.floor(sp / 10000);
+ sp = sp % 10000;}
+ if(sp / 100 >= 1){
+ json.result.price_silver = Math.floor(sp / 100);
+ sp = sp % 100;}
+ if(sp => 1){
+ json.result.price_copper = sp;}
+
+ items[json.result.entry] = json.result;
+ if( json.result.icon ) {
+ $this.css({"background-image": "url(http://wow.zamimg.com/images/wow/icons/medium/"+ json.result.icon +".jpg)"});
+ }
+ if( json.result.stack ) {
+ $this.append(""+json.result.stack+"");}
+ });
+}
+
+
/*var example = {
@@ -671,5 +703,4 @@ function wow_tooltips(){
}
-};*/
-}
\ No newline at end of file
+};*/
\ No newline at end of file