#41 itemextendedcosts and all templates for tooltips

This commit is contained in:
Ulf Gebhardt 2016-04-13 22:22:31 +02:00
parent fc8d79fcab
commit e6b8199e2a
3 changed files with 314 additions and 149 deletions

View File

@ -0,0 +1,107 @@
<script id="wow-item-template" type="text/x-handlebars-template">
<aside class="wow-item hidden" data-quality="{{ quality }}">
<header class="wow-item__header">
<p class="header__title">{{ name }}</p>
{{#if ItemLevel}}
<p class="info__item-level">Item Level {{ ItemLevel }}</p>
{{/if}}
{{#if binds}}<p class="header__binds">{{ binds }}</p>{{/if}}
{{#if unique}}
<p class="header__unique">Unique</p>
{{/if}}
</header>
<section class="wow-item__type">
<p class="type__slot">{{slot}}</p>
<p class="type__item">{{type}}</p>
</section>
<section class="wow-item__stats">
{{#if damage}}
<p class="stats__damage-armor"><span class="value">{{ damage.min }} - {{damage.max}}</span> Damage</p>
<p class="stats__speed">Speed <span class="value">{{ speed damage.speed }}</span></p>
<p class="stats__dps">(<span class="value">{{ dps damage }}</span> damage per second)</p>
{{/if}}
{{#if armor}}
<p class="stats__armor">{{ armor }} Armor</p>
{{/if}}
<div class="stats__list">
{{#each stats}}
<p class="stats__{{ type }} stats__list-item">+{{ value }} {{ stat }}</p>
{{/each}}
</div>
</section>
{{#if enchantments}}
<section class="wow-item__enchantments">
{{#each enchantments.enchants}}
<p class="enchantments__enchant">{{ description }}</p>
{{/each}}
<div class="enchantments__sockets">
{{#each enchantments.sockets }}
<p class="enchantments__socket socket--{{ color }}">{{ color }} socket</p>
{{/each}}
{{#if enchantments.socketBonus}}
<p class="enchantments__socket-bonus">Socket Bonus: {{ enchantments.socketBonus }}</p>
{{/if}}
</div>
</section>
{{/if}}
<section class="wow-item__info">
{{#if MaxDurability}}
<p class="info__durability">Durability: {{ MaxDurability }} / {{ MaxDurability }}</p>
{{/if}}
{{#each chanceOnHit}}
<p class="info__chance-on-hit">Chance on hit: {{ description }}</p>
{{/each}}
{{#if classes}}
<p class="info__class-requirement">Classes: <span class="value">{{ classes classes }}</span></p>
{{/if}}
{{#if RequiredLevel}}
<p class="info__level-requirement">Requires Level {{ RequiredLevel }}</p>
{{/if}}
</section>
{{#if bonuses}}
<section class="wow-item__bonuses">
{{#each bonuses}}
<p class="bonuses__bonus">{{ description }}</p>
{{/each}}
</section>
{{/if}}
<section class="wow-item__info">
{{#if tradelevel }}
<p class="info__trade-level">Requires {{ tradelevel.trade }} ({{ tradelevel.level }})</p>
{{/if}}
{{#if description }}
<p class="info__flavour-text">"{{ description }}"</p>
{{/if}}
</section>
<section class="wow-item__price">
{{#if price_gold }}
<p class="price__gold">Sell Price: {{ price_gold }}</p>
{{/if}}
{{#if price_silver }}
<p class="price__silver">{{ price_silver }}</p>
{{/if}}
{{#if price_copper }}
<p class="price__copper">{{ price_copper }}</p>
{{/if}}
</section>
</aside>
</script>

View File

@ -0,0 +1,27 @@
<script id="wow-itemextendedcost-template" type="text/x-handlebars-template">
<aside class="wow-item hidden">
<header class="wow-item__header">
<p class="header__title">Item Extended Cost {{ 1 }}</p>
</header>
<section class="wow-item__stats">
{{#if 2}}
<p>Required Honor Points {{ 2 }}</p>
{{/if}}
{{#if 3}}
<p>Required Arena Points {{ 3 }}</p>
{{/if}}
{{#if 4}}
<p>Required Item {{ 9 }}x{{ 4 }} </p>
{{/if}}
{{#if 5}}
<p>Required Item {{ 10 }}x{{ 5 }}</p>
{{/if}}
{{#if 6}}
<p>Required Item {{11 }}x{{ 6 }}</p>
{{/if}}
{{#if 14}}
<p>Required Personal Arena Rating {{ 14 }}</p>
{{/if}}
</section>
</aside>
</script>

View File

@ -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("<span class='stack'>"+json.result.stack+"</span>");}
});
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("<span class='stack'>"+json.result.stack+"</span>");}
});
}
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("<span class='stack'>"+json.result.stack+"</span>");}
});
}
/*var example = {
@ -671,5 +703,4 @@ function wow_tooltips(){
}
};*/
}
};*/