Files
aowow/template/js/petcalc.js
Sarjuuk 684b2f2778 - Tooltip class from global.js to basic.js (added nessecary prefix)
- miscTools:
    * implemented random DB-Page
    * others are placeholder (at least no errors are generated)
- Articles / Infobox:
    * dropped aowow_article_items, parse nessecary globals directly from article or infobox
    * articles default back to english if no target articles is absent
    * quickinfo from db is only used if no auto-generated info is available
- CharClass:
    * implemented detail-page
    * added basic articles per class (english only)
- generic lv-page
    * now accepts multiple listviews (as required by miscTools)
    * can display text and title
- Markup.js:
    * exchanged to current version (yet to be looked over, but basic articles are displayed properly for now)
    * removed some hacks that were nessecary for the old Markup / Menu
- Listview
    * made some more code readeable, no major changes
    * calendar-template is now functional (WorldEvents use it)

...squashing bugs left and right
2013-09-01 15:37:40 +02:00

127 lines
2.9 KiB
JavaScript

var
pc_loaded = false,
pc_object,
pc_classId = -1,
pc_classIcons = {},
pc_build = '';
function pc_init() {
var
_,
clear;
g_initPath([1, 2]);
$WH.ge('pc-classes').className = 'choose';
var
families = g_sortJsonArray(g_pet_families, g_pet_families),
div = $WH.ce('div');
div.className = 'pc-classes-inner-family';
_ = $WH.ge('pc-classes-inner');
for (var i = 0, len = families.length; i < len; ++i) {
var
classId = families[i],
icon = Icon.create(g_pet_icons[classId], 1, null, 'javascript:;'),
link = Icon.getLink(icon);
pc_classIcons[classId] = icon;
if ($WH.Browser.ie6) {
link.onfocus = tb;
}
link.onclick = pc_classClick.bind(link, classId);
link.onmouseover = pc_classOver.bind(link, classId);
link.onmouseout = $WH.Tooltip.hide;
$WH.ae(div, icon);
}
$WH.ae(_, div);
clear = $WH.ce('div');
clear.className = 'clear';
$WH.ae(div, clear);
clear = $WH.ce('div');
clear.className = 'clear';
$WH.ae(_, clear);
pc_object = new TalentCalc();
pc_object.initialize('pc-itself', {
onChange: pc_onChange,
mode: TalentCalc.MODE_PET
});
$WH.ge('pc-itself').className += ' choose';
pc_readPound();
setInterval(pc_readPound, 1000);
}
function pc_classClick(classId) {
if (pc_object.setClass(classId)) {
$WH.Tooltip.hide();
}
return false;
}
function pc_classOver(classId) {
$WH.Tooltip.show(this, '<b>' + g_pet_families[classId] + '</b>');
}
function pc_onChange(tc, info, data) {
var _;
if (info.classId != pc_classId) { // Class change
if (!pc_loaded) {
_ = $WH.ge('pc-itself');
_.className = _.className.replace('choose', '');
_ = $WH.ge('pc-classes');
$WH.de($WH.gE(_, 'p')[0]); // Removes 'Choose a pet family:'
_.className = '';
pc_loaded = true;
}
if (pc_classId != -1) {
_ = pc_classIcons[pc_classId];
_.className = pc_classIcons[pc_classId].className.replace('iconmedium-gold-selected', '');
}
pc_classId = info.classId;
_ = pc_classIcons[pc_classId];
_.className += ' iconmedium-gold-selected';
g_initPath([1, 2, pc_classId]);
}
pc_build = tc.getWhBuild();
location.replace('?petcalc#' + pc_build);
var buff = document.title;
if (buff.indexOf(' (') != -1) {
var pos = buff.indexOf("- ");
if (pos != -1) {
buff = buff.substring(pos + 2);
}
}
document.title = g_pet_families[pc_classId] + ' (' + data.k + ') - ' + buff;
}
function pc_readPound() {
if (location.hash) {
var build = location.hash.substr(1);
if (pc_build != build) {
pc_build = build;
pc_object.setWhBuild(pc_build);
}
}
};