further unpacking of talent.js and petcalc.js

no change in funcitoinality (hopefully)
This commit is contained in:
Sarjuuk
2012-12-24 19:45:15 +01:00
parent 31ac4dfcdc
commit 94621c0687
2 changed files with 259 additions and 186 deletions

View File

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

View File

@@ -1,113 +1,150 @@
var tc_loaded = false,
tc_object, tc_classId = -1,
tc_classIcons = {},
tc_build = "",
tc_glyphs = "";
var
tc_loaded = false,
tc_object,
tc_classId = -1,
tc_classIcons = {},
tc_build = '',
tc_glyphs = '';
function tc_init() {
var c;
g_initPath([1, 0]);
ge("tc-classes").className = "choose";
var e = g_sortJsonArray(g_chr_classes, g_chr_classes);
c = ge("tc-classes-inner");
for (var d = 0, b = e.length; d < b; ++d) {
var h = e[d],
f = Icon.create("class_" + g_file_classes[h], 1, null, "javascript:;"),
g = Icon.getLink(f);
tc_classIcons[h] = f;
if (Browser.ie6) {
g.onfocus = tb
}
g.onclick = tc_classClick.bind(g, h);
g.onmouseover = tc_classOver.bind(g, h);
g.onmouseout = Tooltip.hide;
ae(c, f)
}
var a = ce("div");
a.className = "clear";
ae(c, a);
tc_object = new TalentCalc();
tc_object.initialize("tc-itself", {
onChange: tc_onChange
});
tc_readPound();
setInterval(tc_readPound, 1000)
var
_,
clear;
g_initPath([1, 0]);
ge('tc-classes').className = 'choose';
var classes = g_sortJsonArray(g_chr_classes, g_chr_classes);
_ = ge('tc-classes-inner');
for (var i = 0, len = classes.length; i < len; ++i) {
var
classId = classes[i],
icon = Icon.create('class_' + g_file_classes[classId], 1, null, 'javascript:;'),
link = Icon.getLink(icon);
tc_classIcons[classId] = icon;
if (Browser.ie6) {
link.onfocus = tb;
}
link.onclick = tc_classClick.bind(link, classId);
link.onmouseover = tc_classOver.bind(link, classId);
link.onmouseout = Tooltip.hide;
ae(_, icon);
}
clear = ce('div');
clear.className = 'clear';
ae(_, clear);
tc_object = new TalentCalc();
tc_object.initialize('tc-itself', {
onChange: tc_onChange,
mode: TalentCalc.MODE_DEFAULT
});
ge('tc-itself').className += ' choose';
tc_readPound();
setInterval(tc_readPound, 1000);
}
function tc_classClick(a) {
if (tc_object.setClass(a)) {
Tooltip.hide()
}
return false
function tc_classClick(classId) {
if (tc_object.setClass(classId)) {
Tooltip.hide();
}
return false;
}
function tc_classOver(a) {
Tooltip.show(this, "<b>" + g_chr_classes[a] + "</b>", 0, 0, "c" + a)
function tc_classOver(classId) {
Tooltip.show(this, '<b>' + g_chr_classes[classId] + '</b>', 0, 0, 'c' + classId);
}
function tc_onChange(a, e, d) {
var c;
if (e.classId != tc_classId) {
if (!tc_loaded) {
var c = ge("tc-classes");
de(gE(c, "p")[0]);
c.className = "";
tc_loaded = true
}
if (tc_classId != -1) {
c = tc_classIcons[tc_classId];
c.className = tc_classIcons[tc_classId].className.replace("iconmedium-gold", "")
}
tc_classId = e.classId;
c = tc_classIcons[tc_classId];
c.className += " iconmedium-gold";
g_initPath([1, 0, tc_classId])
}
tc_build = a.getWhBuild();
tc_glyphs = a.getWhGlyphs();
var b = "#" + tc_build;
if (tc_glyphs != "") {
b += ":" + tc_glyphs
}
location.replace(b);
var g = document.title;
if (g.indexOf("/") != -1) {
var f = g.indexOf("- ");
if (f != -1) {
g = g.substring(f + 2)
}
}
document.title = g_chr_classes[tc_classId] + " (" + d[0].k + "/" + d[1].k + "/" + d[2].k + ") - " + g
function tc_onChange(tc, info, data) {
var _;
if (info.classId != tc_classId) { // Class change
if (!tc_loaded) {
_ = ge('tc-itself');
_.className = _.className.replace('choose', '');
_ = ge('tc-classes');
de(gE(_, 'p')[0]); // Removes 'Choose a class:'
_.className = '';
tc_loaded = true;
}
if (tc_classId != -1) {
_ = tc_classIcons[tc_classId];
_.className = tc_classIcons[tc_classId].className.replace('iconmedium-gold-selected', '');
}
tc_classId = info.classId;
_ = tc_classIcons[tc_classId];
_.className += ' iconmedium-gold-selected';
g_initPath([1, 0, tc_classId]);
}
tc_build = tc.getWhBuild();
tc_glyphs = tc.getWhGlyphs();
var url = '#' + tc_build;
if (tc_glyphs != '') {
url += ':' + tc_glyphs
}
location.replace(url);
var buff = document.title;
if (buff.indexOf('/') != -1) {
var pos = buff.indexOf('- ');
if (pos != -1) {
buff = buff.substring(pos + 2);
}
}
document.title = g_chr_classes[tc_classId] + ' (' + data[0].k + '/' + data[1].k + '/' + data[2].k + ') - ' + buff;
}
function tc_readPound() {
if (location.hash) {
if (location.hash.indexOf("-") != -1) {
var d = location.hash.substr(1).split("-"),
a = d[0] || "",
f = d[1] || "",
c = -1;
for (var g in g_file_classes) {
if (g_file_classes[g] == a) {
c = g;
break
}
}
if (c != -1) {
tc_object.setBlizzBuild(c, f)
}
} else {
var d = location.hash.substr(1).split(":"),
e = d[0] || "",
b = d[1] || "";
if (tc_build != e) {
tc_build = e;
tc_object.setWhBuild(tc_build)
}
if (tc_glyphs != b) {
tc_glyphs = b;
tc_object.setWhGlyphs(tc_glyphs)
}
}
}
if (location.hash) {
if (location.hash.indexOf('-') != -1) { // Blizz-Build
var
pounds = location.hash.substr(1).split('-'),
classs = pounds[0] || '',
build = pounds[1] || '',
classId = -1;
for (var i in g_file_classes) {
if (g_file_classes[i] == classs) {
classId = i;
break;
}
}
if (classId != -1) {
tc_object.setBlizzBuild(classId, build);
}
}
else { // WH-Build
var
pounds = location.hash.substr(1).split(':'),
build = pounds[0] || '',
glyphs = pounds[1] || '';
if (tc_build != build) {
tc_build = build;
tc_object.setWhBuild(tc_build);
}
if (tc_glyphs != glyphs) {
tc_glyphs = glyphs;
tc_object.setWhGlyphs(tc_glyphs);
}
}
}
};