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

View File

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