// FILE ARCHIVED ON Dez 29, 2009
var g_summaries = {};
// required for json parse
var dO = function(a){
function b() {}
b.prototype = a;
return new b
};
function Summary(c) {
cO(this, c);
if (this.id) {
var b = this.id;
if (this.parent) {
var g = ce("div");
g.id = b;
ae($(this.parent), g);
this.container = g
} else {
this.container = ge(b)
}
} else {
return
}
if (this.template) {
this.templateName = this.template;
this.template = Summary.templates[this.template]
} else {
return
}
g_summaries[this.id] = this;
if (this.editable == null) {
if (this.template.editable != null) {
this.editable = this.template.editable
} else {
this.editable = 1
}
}
if (this.draggable == null) {
if (this.template.draggable != null) {
this.draggable = this.template.draggable
} else {
this.draggable = this.editable
}
}
if (this.searchable == null) {
if (this.template.searchable != null) {
this.searchable = this.template.searchable
} else {
this.searchable = (this.editable && this.draggable)
}
}
if (this.weightable == null) {
if (this.template.weightable != null) {
this.weightable = this.template.weightable
} else {
this.weightable = this.editable
}
}
if (this.textable == null) {
if (this.template.textable != null) {
this.textable = this.template.textable
} else {
this.textable = 0
}
}
if (this.enhanceable == null) {
if (this.template.enhanceable != null) {
this.enhanceable = this.template.enhanceable
} else {
this.enhanceable = this.editable
}
}
if (this.level == null) {
if (this.template.level != null) {
this.level = this.template.level
} else {
this.level = 80
}
}
var a = g_getGets();
this.autoSave = 1;
if (a.compare) {
this.autoSave = 0
}
if (a.l && !isNaN(a.l)) {
this.level = parseInt(a.l)
}
else
{
var l = gc('compare_level');
if (l)
this.level = l;
}
if (this.groups == null) {
this.groups = [];
if (a.compare) {
this.readGroups(a.compare)
} else {
this.readGroups(gc("compare_groups"))
}
}
if (this.weights == null) {
this.weights = [];
if (this.weightable) {
if (a.compare) {
this.readWeights(a.weights)
} else {
this.readWeights(gc("compare_weights"))
}
}
}
this.showTotal = 0;
if (this.template.total != null) {
this.total = this.template.total;
this.showTotal = this.template.columns[this.total].hidden
}
if (this.template.clone != null) {
this.clone = {};
cO(this.clone, this.template.columns[this.template.clone]);
this.clone.i = this.template.clone
}
if (a.compare && a.focus != null) {
var e = parseInt(a.focus) | 0;
if (e >= 0 && e < this.groups.length) {
this.selected = this.clone.i + e
}
}
this.initialize()
}
Summary.prototype = {
initialize: function () {
// todo: move to announcements
/* if (this.templateName == "compare" && !gc("compare_first")) {
var e = ce("div"),
b = ce("span");
e.onclick = function (d) {
d = $E(d);
if (d._target.nodeName == "A") {
de(this);
// sc("compare_first", 20, 1, "/", ".wowhead.com")
sc("compare_first", 20, 1, "/", location.hostname)
}
};
e.className = "summary-notice";
b.innerHTML = LANG.su_notice;
ae(e, b);
ae(this.container, e)
} */
this.controls = ce("div");
this.controls.style.display = "none";
this.controls.className = "summary-controls";
this.textNames = ce("div");
this.textNames.style.display = "none";
this.textNames.className = "summary-textnames";
var c;
if (this.onBeforeCreate != null) {
c = this.onBeforeCreate()
}
this.updateGroups();
this.updateTraits();
this.updateColumns();
this.updateVisibility();
if (this.traits.length == 0) {
this.visibility.shift();
this.visibility.shift()
}
this.noData = ce("div");
this.noData.className = "listview-nodata text";
this.table = ce("table");
this.thead = ce("thead");
this.tbody = ce("tbody");
this.table.id = "su_table";
this.table.className = "grid";
this.refreshHeader();
ae(this.table, this.thead);
ae(this.table, this.tbody);
this.refreshRows();
ae(this.container, this.controls);
ae(this.container, this.textNames);
ae(this.container, this.table);
this.itemTip = ce("div");
this.itemTip.className = "summary-tip";
this.itemTip.style.display = "none";
var a = ce("span");
a.innerHTML = LANG.su_itemtip;
ae(this.itemTip, a);
ae(this.container, this.itemTip);
this.refreshLink();
if (this.onAfterCreate != null) {
this.onAfterCreate(c)
}
if (this.templateName == "compare") {
ModelViewer.addExtraPound(this.viewIn3dFromPound.bind(this))
}
},
updateGroups: function () {
for (var d = 0, a = this.groups.length; d < a; ++d) {
for (var c = 0, b = this.groups[d].length; c < b; ++c) {
if (this.groups[d][c][0] == 0 || (b > 1 && this.groups[d][c][0] == -1)) {
this.groups[d].splice(c, 1); --c; --b
}
}
if (b == 0) {
if (this.selected != null) {
if (this.__selected.i == d) {
this.selected = null
}
}
this.groups.splice(d, 1); --d; --a
}
}
if (this.editable) {
this.updateControls()
}
},
updateTraits: function () {
this.traits = [];
var b, p = false,
a = [];
for (var g = 0, h = this.groups.length; g < h; ++g) {
for (var f = 0, e = this.groups[g].length; f < e; ++f) {
var n = this.groups[g][f];
if (g_items[n[0]]) {
a.push(g_items[n[0]].jsonequip);
if (!this.enhanceable) {
continue
}
if (g_items[n[0]].jsonequip.subitems && g_items[n[0]].jsonequip.subitems[n[1]]) {
a.push(g_items[n[0]].jsonequip.subitems[n[1]].jsonequip)
}
if (g_enchants[n[2]]) {
a.push(g_enchants[n[2]].jsonequip)
}
if (g_enchants[n[3]]) {
a.push(g_enchants[n[3]].jsonequip)
}
for (var d = 4; d < 8; ++d) {
if (g_gems[n[d]]) {
a.push(g_gems[n[d]].jsonequip)
}
}
if (this.hasExtraSocket(n)) {
a.push({
nsockets: 1
})
}
if (this.hasSocketBonus(n)) {
a.push(g_items[n[0]].jsonequip.socketbonusstat)
}
}
}
if (b = this.getSetBonuses(this.groups[g])) {
a.push(b)
}
}
for (var g = 0, h = this.template.traits.length; g < h; ++g) {
var l = this.template.traits[g];
if (l.type == "sep") {
p = true;
continue
}
var m = [l.id];
if (l.json) {
var m = l.json
}
var o = false;
for (var f = 0, e = a.length; f < e; ++f) {
for (var d = 0, c = m.length; d < c; ++d) {
if (a[f][m[d]] && (l.id != "gains" || (this.editable && this.groups.length > 1)) && (l.id != "score" || this.weights.length)) {
if (p) {
this.traits.push({})
}
p = false;
this.traits.push(l);
o = true;
break
}
}
if (o) {
break
}
}
}
},
updateColumns: function () {
this.columns = this.template.columns.slice(0);
if (this.template.newgroup != null) {
this.newgroup = this.template.newgroup
}
if (this.total != null) {
this.__total = this.columns[this.total]
} else {
this.__total = {}
}
this.__total.total = {};
this.minValue = {};
this.maxValue = {};
this.ratings = {};
if (this.clone != null) {
this.columns.splice(this.clone.i, 1);
var b = 0;
for (var d = 0, a = this.groups.length; d < a; ++d) {
if (this.groups[d].length < 1) {
continue
}
if (b > 0 && this.newgroup != null) {
this.newgroup++
}
var c = {};
cO(c, this.clone);
c.id = "group" + d;
c.group = this.groups[d];
c.i = d;
this.columns.splice(this.clone.i + d, 0, c);
b++
}
for (var d = 0, a = this.columns.length; d < a; ++d) {
this.calcTraitTotals(this.columns[d], this.__total, this.level)
}
if (this.selected != null) {
this.__selected = this.columns[this.selected];
for (var d = 0, a = this.groups.length; d < a; ++d) {
if (this.clone.i + d == this.selected) {
continue
}
this.calcTraitDifference(this.columns[this.clone.i + d], this.__selected)
}
} else {
this.__selected = {}
}
if (this.total != null && (b == 1 || this.selected != null)) {
this.__total.hidden = 1
} else {
this.__total.hidden = this.showTotal
}
}
},
updateVisibility: function () {
this.visibility = [];
var e = [],
d = [];
if (this.visibleCols != null) {
array_walk(this.visibleCols, function (f) {
e[f] = 1
})
}
if (this.hiddenCols != null) {
array_walk(this.hiddenCols, function (f) {
d[f] = 1
})
}
for (var c = 0, a = this.columns.length; c < a; ++c) {
var b = this.columns[c];
if (e[b.id] != null || (!b.hidden && d[b.id] == null)) {
this.visibility.push(c)
}
}
if (this.groups.length > 1 && this.textable) {
this.showTextNames()
} else {
this.textNames.style.display = "none"
}
},
updateDraggable: function () {
for (var c = 0, len = this.dragHeaders.length; c < len; ++c) {
var _ = this.dragHeaders[c];
_._targets = this.dragTargets;
Draggable.init(_, {
container: this.table,
onDrag: Summary.dragGroup.bind(this),
onDrop: Summary.moveGroup.bind(this)
});
// alert(_.onmousedown);
}
for (var c = 0, len = this.dragIcons.length; c < len; ++c) {
var _ = this.dragIcons[c];
_._targets = this.dragTargets;
Draggable.init(_, {
container: this.table,
onDrop: Summary.moveGroupItem.bind(this)
});
}
},
updateWeights: function (g) {
var e = ge("su_weight");
var k = e.childNodes[0].childNodes[0];
var f = 0;
for (var b in g) {
if (!LANG.traits[b]) {
continue
}
if (f++>0) {
k = this.addWeight()
}
var h = k.getElementsByTagName("option");
for (var d = 0, a = h.length; d < a; ++d) {
if (h[d].value == b) {
h[d].selected = true;
break
}
}
this.refreshWeights(k, g[b])
}
},
addWeight: function (g) {
var f = ge("su_weight");
var b = ge("su_addweight");
if (f.childNodes.length >= 14) {
b.style.display = "none"
}
b = f.childNodes[0].lastChild;
if (b.nodeName != "A") {
ae(f.childNodes[0], ct(String.fromCharCode(160, 160)));
ae(f.childNodes[0], this.createControl(LANG.firemove, "", "", this.deleteWeight.bind(this, f.childNodes[0].firstChild)))
} else {
b.firstChild.nodeValue = LANG.firemove;
b.onmouseup = this.deleteWeight.bind(this, f.childNodes[0].firstChild)
}
var h = ce("div"),
i = f.childNodes[0].childNodes[0].cloneNode(true);
ae(f, h);
i.onchange = i.onkeyup = this.refreshWeights.bind(this, i);
ae(h, i);
ae(h, ct(String.fromCharCode(160, 160)));
ae(h, this.createControl(LANG.firemove, "", "", this.deleteWeight.bind(this, i)));
if (g) {
sp($E(g))
}
return i
},
deleteWeight: function (g, h) {
var i = g.parentNode,
j = i.parentNode;
de(i);
if (j.childNodes.length == 1) {
var f = j.firstChild;
if (f.firstChild.selectedIndex > 0) {
var b = f.lastChild;
b.firstChild.nodeValue = LANG.ficlear;
b.onmouseup = this.resetWeights.bind(this)
} else {
while (f.childNodes.length > 1) {
de(f.childNodes[1])
}
}
}
var b = ge("su_addweight");
if (j.childNodes.length < 15) {
b.style.display = ""
}
if (h) {
sp($E(h))
}
},
showDetails: function (b) {
var c = ge("su_weight");
g_toggleDisplay(c);
c = c.nextSibling;
b.firstChild.nodeValue = g_toggleDisplay(c) ? LANG.fihidedetails: LANG.fishowdetails
},
calcTraitTotals: function (d, o, level) {
if (!d.group) {
return
}
d.total = {};
d.difference = {};
var q = {
sum: function (c, f) {
return (!isNaN(c) ? c: 0) + f
},
min: function (c, f) {
return Math.min((!isNaN(c) ? c: f), f)
},
max: function (c, f) {
return Math.max((!isNaN(c) ? c: 0), f)
},
avg: function (c, i, f) {
return (!isNaN(c) ? c: 0) + (i / f)
},
text: function (c, B, A, z, k, i, j) {
if (k) {
k = k.bind(this);
B = k(B, i, z, j)
}
return (in_array(c, B) < 0 ? B: null)
},
custom: function (c, B, A, z, k, i, j) {
if (k) {
k = k.bind(this);
k(B, c, i, z, j)
}
return c
}
};
var e = function (C, i, y, j, k, z, t, E) {
var x = {};
cO(x, C);
if(x.scadist && x.scaflags)
$WH.g_setJsonItemLevel(x, level);
var A = (y.type == "text" || y.type == "custom" ? x: (x[i] && typeof x[i] != "object" ? x[i] : 0));
if (i == "nsockets" && E) {
A += E
}
if (!A) {
return
}
var B = k(j.total[y.id], A, j.group.length, t, z, 0, E),
D = k(o.total[y.id], A, j.group.length, t, z, 1, E);
if (y.type == "text") {
if (B) {
j.total[y.id].push(B)
}
if (D) {
o.total[y.id].push(D)
}
} else {
j.total[y.id] = B;
o.total[y.id] = D
}
};
for (var r in this.traits) {
r = this.traits[r];
if (r.id && r.type) {
var b, p = q[r.type].bind(this),
u = r.calcTotal;
var v = [r.id];
if (r.json) {
v = r.json
}
if (d.total[r.id] == null) {
if (r.type == "text") {
d.total[r.id] = []
} else {
if (r.type == "custom") {
d.total[r.id] = {}
}
}
}
if (o.total[r.id] == null) {
if (r.type == "text") {
o.total[r.id] = []
} else {
if (r.type == "custom") {
o.total[r.id] = {}
}
}
}
for (var m = 0, n = d.group.length; m < n; ++m) {
var a = this.hasExtraSocket(d.group[m]);
for (var l = 0, h = v.length; l < h; ++l) {
if (g_items[d.group[m][0]]) {
if (g_items[d.group[m][0]]) {
e(g_items[d.group[m][0]].jsonequip, v[l], r, d, p, u, d.group[m], a);
if (!this.enhanceable || r.itemonly) {
continue
}
if (g_items[d.group[m][0]].jsonequip.subitems && g_items[d.group[m][0]].jsonequip.subitems[d.group[m][1]]) {
e(g_items[d.group[m][0]].jsonequip.subitems[d.group[m][1]].jsonequip, v[l], r, d, p, u, d.group[m])
}
if (g_enchants[d.group[m][2]]) {
e(g_enchants[d.group[m][2]].jsonequip, v[l], r, d, p, u, d.group[m])
}
if (g_enchants[d.group[m][3]]) {
e(g_enchants[d.group[m][3]].jsonequip, v[l], r, d, p, u, d.group[m])
}
for (var g = 4; g < 8; ++g) {
if (g_gems[d.group[m][g]]) {
e(g_gems[d.group[m][g]].jsonequip, v[l], r, d, p, u, d.group[m])
}
}
if (this.hasSocketBonus(d.group[m])) {
e(g_items[d.group[m][0]].jsonequip.socketbonusstat, v[l], r, d, p, u, d.group[m])
}
}
}
}
}
if (b = this.getSetBonuses(d.group)) {
for (var l = 0, h = v.length; l < h; ++l) {
e(b, v[l], r, d, p, u, [])
}
}
if (r.rating) {
this.ratings[r.id] = r.rating
}
if (r.type == "sum") {
if (d.total[r.id] == null) {
this.minValue[r.id] = 0
} else {
if (this.minValue[r.id] == null || this.minValue[r.id] > d.total[r.id]) {
this.minValue[r.id] = d.total[r.id]
}
}
if (this.maxValue[r.id] == null || this.maxValue[r.id] < d.total[r.id]) {
this.maxValue[r.id] = d.total[r.id]
}
} else {
if (r.type == "custom") {
if (this.minValue[r.id] == null) {
this.minValue[r.id] = {}
}
if (this.maxValue[r.id] == null) {
this.maxValue[r.id] = {}
}
for (var w in d.total[r.id]) {
if (this.minValue[r.id][w] == null || this.minValue[r.id][w] > d.total[r.id][w]) {
this.minValue[r.id][w] = d.total[r.id][w]
}
if (this.maxValue[r.id][w] == null || this.maxValue[r.id][w] < d.total[r.id][w]) {
this.maxValue[r.id][w] = d.total[r.id][w]
}
}
}
}
}
}
},
calcTraitDifference: function (b, g) {
b.difference = {};
var a = {
sum: function (c, f) {
return (!isNaN(f) ? f: 0) - (!isNaN(c) ? c: 0)
},
min: function (c, f) {
return (!isNaN(f) ? f: 0) - (!isNaN(c) ? c: 0)
},
max: function (c, f) {
return (!isNaN(f) ? f: 0) - (!isNaN(c) ? c: 0)
},
avg: function (c, f) {
return (!isNaN(f) ? f: 0) - (!isNaN(c) ? c: 0)
},
text: function (f, m) {
var j = [];
for (var l = 0, c = m.length; l < c; ++l) {
if (in_array(f, m[l]) == -1) {
var k = ce("span");
k.className = "q2";
ae(k, ct("+" + m[l]));
j.push(k)
}
}
for (var l = 0, c = f.length; l < c; ++l) {
if (in_array(m, f[l]) == -1) {
var k = ce("span");
k.className = "q10";
ae(k, ct("-" + f[l]));
j.push(k)
}
}
return j
},
custom: function (c, j, i) {
if (i) {
i = i.bind(this);
return i(j, c)
}
return {}
}
};
for (var d in this.traits) {
d = this.traits[d];
if (d.id && d.type) {
var e = a[d.type].bind(this),
h = d.calcDifference;
b.difference[d.id] = e(g.total[d.id], b.total[d.id], h)
}
}
},
resetAll: function () {
this.groups = [];
this.weights = [];
this.refreshAll()
},
refreshAll: function () {
this.updateGroups();
this.updateTraits();
this.updateColumns();
this.updateVisibility();
this.refreshHeader();
this.refreshRows();
this.refreshLink();
if (this.autoSave) {
this.saveComparison(0)
}
},
refreshHeader: function () {
if (this.groups.length && this.thead.nodeName.toLowerCase() != "thead") {
this.thead = ce("thead");
ae(this.table, this.thead)
}
while (this.thead.firstChild) {
this.thead.removeChild(this.thead.firstChild)
}
this.dragHeaders = [];
this.dragIcons = [];
this.dragTargets = [];
this.selectLevel = ce("div");
this.selectLevel.style.display = "none";
var d = ce("tr");
if (!this.groups.length) {
var f = ce("th");
ae(d, f);
ae(this.thead, d);
this.showNoData(f);
return
}
var l = 0;
for (var u = 0, v = this.visibility.length; u < v; ++u) {
var p = this.visibility[u];
var e = this.columns[p];
var f = ce("th");
if (e.id == "total") {
f.style.verticalAlign = "middle"
} else {
if (e.id == "name") {
f.style.verticalAlign = "bottom"
} else {
f.style.verticalAlign = "top"
}
}
e.__th = f;
f.__col = e;
if (e.width != null) {
f.style.width = e.width
}
if (e.align != null) {
f.style.textAlign = e.align
}
if (e.span != null) {
f.colSpan = e.span
}
if (this.selected != null && this.__selected.id == e.id) {
f.className = "checked"
}
if (e.id == "name") {
ae(f, this.selectLevel);
if (this.editable) {
var n = ce("select");
n.onchange = (function (a) {
this.level = a.options[a.selectedIndex].value;
this.refreshAll()
}).bind(this, n);
for (var u = 80; u > 0; --u) {
var q = ce("option");
if (u == this.level) {
q.selected = true
}
st(q, u);
ae(n, q)
}
ae(this.selectLevel, ct(LANG.pr_dialog_level + " "));
ae(this.selectLevel, n)
}
}
if (e.group) {
this.dragTargets.push(f);
if (this.editable) {
var A = ce("div");
A.className = "summary-group";
m = ce("div");
m.className = "summary-group-controls";
var z = ce("a");
z.href = "javascript:;";
z.className = "summary-group-dropdown";
ae(z, ce("span"));
z.menu = [[0, LANG.su_export, "?compare=" + this.getGroupData(l)]];
z.menu[0].newWindow = 1;
if (this.viewableIn3d(e)) {
z.menu.push([0, LANG.su_viewin3d, this.viewIn3d.bind(this, e)])
}
if (e.group.length > 1) {
z.menu.push([0, LANG.su_split, this.splitColumn.bind(this, e)])
}
if (this.enhanceable && this.hasEnhancements(e.group)) {
z.menu.push([0, LANG.pr_menu_clearenh, this.clearEnhancements.bind(this, e)])
}
z.onclick = Menu.showAtCursor;
ae(m, z);
if (this.groups.length > 1) {
z = ce("a");
z.href = "javascript:;";
z.className = "summary-group-focus";
var n = ce("span");
z.onclick = this.selectColumn.bind(this, e);
if (this.selected && this.__selected.id == e.id) {
z.onmouseover = function () {
Tooltip.show(this, LANG.tooltip_removefocus, 0, 0, "q")
};
n.className = "selected"
} else {
z.onmouseover = function () {
Tooltip.show(this, LANG.tooltip_setfocus, 0, 0, "q")
}
}
z.onmousemove = Tooltip.cursorUpdate;
z.onmouseout = Tooltip.hide;
ae(z, n);
ae(m, z)
}
z = ce("a");
z.href = "javascript:;";
z.className = "summary-group-delete";
z.onclick = this.deleteColumn.bind(this, e);
ae(z, ce("span"));
ae(m, z);
if (this.draggable) {
z = ce("a");
z.href = "javascript:;";
z.className = "summary-group-drag";
ae(z, ce("span"));
ae(m, z);
A.__col = e;
A._handle = z;
this.dragHeaders.push(A)
}
ae(A, m);
ae(f, A);
if (this.draggable && this.groups.length > 1) {
if (Browser.ie) {
var x = ce("div");
x.style.width = "80px";
x.style.fontSize = "1px";
x.style.height = "0";
x.style.background = "transparent";
ae(f, x)
} else {
A.style.minWidth = "80px"
}
}
}
var g = e.group.length,
r = 1,
c = 3,
h = 44;
if (g > 3) {
r = 0;
c = 5;
h = 26
}
var A = ce("div");
A.style.margin = "0 auto";
A.style.clear = "both";
var k = ce("div"),
m = A.cloneNode(true);
if (this.editable) {
k.className = "summary-group-bottom"
}
for (var t = 0; t < g; ++t) {
if (t % c == 0) {
m.style.width = (h * c) + "px";
m = A.cloneNode(true);
ae(k, m)
}
var w = g_items.createIcon(e.group[t][0], r);
w.__col = e;
w.i = t;
if (this.enhanceable) {
this.refreshItem(e, t, Icon.getLink(w))
}
this.dragIcons.push(w);
ae(m, w)
}
if (e.group.length) {
m.style.width = (h * (g % c == 0 ? c: (g % c))) + "px"
}
ae(k, m);
if (this.editable) {
f.style.padding = "0";
m = ce("div");
m.className = "clear";
ae(k, m);
m = ce("div");
m.className = "clear";
ae(f.firstChild, m);
ae(f.firstChild, k)
} else {
ae(f, k)
}
l++
} else {
if (e.name) {
var y = ce("b");
ae(y, ct(e.name));
ae(f, y)
}
}
if (this.editable && p == this.newgroup) {
this.dragTargets.push(f)
}
ae(d, f)
}
ae(this.thead, d);
if (this.draggable) {
this.updateDraggable()
}
},
refreshItem: function (e, h, m) {
var o = e.group[h],
p = o[0],
b = [],
d = this.hasExtraSocket(o);
m.rel = this.getItemRel(o, e);
if (!this.enhanceable) {
return
}
m.oncontextmenu = rf;
if (g_items[p].jsonequip.subitems != null) {
b.push([0, (o[1] ? LANG.pr_menu_repsubitem: LANG.pr_menu_addsubitem), this.openSubitemPicker.bind(this, e, h)])
}
if (this.canBeEnchanted(g_items[p].jsonequip.slotbak)) {
var n = [0, (o[2] ? LANG.pr_menu_repenchant: LANG.pr_menu_addenchant), this.openEnchantPicker.bind(this, e, h)];
if (o[2] && g_enchants[o[2]]) {
n.tinyIcon = g_enchants[o[2]].icon
}
b.push(n)
}
if (g_items[p].jsonequip.nsockets || d) {
for (var g = 0, f = (g_items[p].jsonequip.nsockets | 0) + d; g < f; ++g) {
var j = (o[g + 4] > 0 ? o[g + 4] : 0),
l = (d && g == f - 1 ? 14 : g_items[p].jsonequip["socket" + (g + 1)]),
n = [0, (j ? LANG.pr_menu_repgem: LANG.pr_menu_addgem), this.openGemPicker.bind(this, e, h, 4 + g, l)];
if (j) {
n.tinyIcon = g_gems[j].icon
} else {
n.socketColor = l
}
b.push(n)
}
}
if (this.canBeSocketed(g_items[p].jsonequip.slotbak)) {
var n = [0, LANG.pr_menu_extrasock, Summary.toggleExtraSocket.bind(this, e, h, m)];
n.checked = d;
b.push(n)
}
if (this.hasEnhancements([o])) {
b.push([0, LANG.pr_menu_clearenh, this.clearEnhancements.bind(this, e, h)])
}
if (b.length) {
m.oncontextmenu = rf;
m.onclick = this.onMouseClick.bind(0, m);
m.onmouseup = this.onMouseUp.bind(0, m);
m.menu = b
}
},
refreshRows: function () {
if (this.groups.length) {
ae(this.table, this.tbody)
}
while (this.tbody.firstChild) {
this.tbody.removeChild(this.tbody.firstChild)
}
this.selectLevel.style.display = "none";
/* start experimental */
for (var itr = 0, len = this.visibility.length; itr < len; ++itr)
{
var reali = this.visibility[itr];
var col = this.columns[reali];
if(!col.group)
continue;
for(var jtr = 0, len2 = col.group.length; jtr < len2; ++jtr)
{
var itemId = col.group[jtr][0];
if(g_items[itemId].jsonequip.scadist && g_items[itemId].jsonequip.scaflags)
{
this.selectLevel.style.display = '';
break;
}
}
}
/* end experimental */
var a = 0;
for (trait in this.traits) {
if (this.traits[trait].id) {
this.traits[trait].i = ++a
}
ae(this.tbody, this.getRow(trait, a))
}
if (!a) {
if (!this.groups.length && this.tbody.parentNode) {
de(this.tbody)
}
var c = ce("tr");
var d = ce("td");
var b = ce("span");
if(this.visibility && this.visibility.length)
d.colSpan = this.visibility.length;
d.style.textAlign = "center";
ae(b, ct("The items in this set don't have any comparable stats."));
ae(d, b);
ae(c, d);
ae(this.tbody, c)
}
},
refreshLink: function () {
var b = ge("su_link"),
e = this.getGroupData(),
f = this.getWeightData();
if (e) {
this.itemTip.style.display = ""
} else {
this.itemTip.style.display = "none"
}
if (b) {
sc("compare_level", 20, this.level, "/", location.hostname); // custom
var d = "?compare" + (e ? "=" + e: "") + (this.level != 80 ? "&l=" + this.level: "");
if (f[1].length && f[2].length) {
d += "&weights=" + f.join(";")
}
if (this.selected) {
d += "&focus=" + this.__selected.i
}
b.href = d
}
},
refreshClasses: function (e) {
var i = e.options[e.selectedIndex],
a = ge("su_presets");
while (a.firstChild) {
de(a.firstChild)
}
ae(a, ce("option"));
if (e.selectedIndex > 0) {
for (var b in i._presets) {
var d = i._presets[b];
var g = ce("optgroup");
g.label = LANG.presets[b];
for (var f in d) {
var h = ce("option");
h._weights = d[f];
ae(h, ct(LANG.presets[f]));
ae(g, h)
}
if (g && g.childNodes.length > 0) {
ae(a, g)
}
}
if (a.childNodes.length > 1) {
a.parentNode.style.display = ""
}
} else {
a.parentNode.style.display = "none"
}
this.resetWeights()
},
refreshPresets: function (b) {
this.resetWeights();
var a = ge("su_classes");
var c = b.options[b.selectedIndex];
if (b.selectedIndex > 0) {
this.updateWeights(c._weights);
ge("su_scale").value = a.options[a.selectedIndex].text + LANG.hyphen + c.text
}
},
resetWeights: function () {
var c = ge("su_weight");
ge("su_scale").value = "";
while (c.childNodes.length >= 2) {
c.removeChild(c.childNodes[1])
}
var e = c.childNodes[0];
while (e.childNodes.length > 1) {
e.removeChild(e.childNodes[1])
}
e.firstChild.selectedIndex = 0;
var b = ge("su_addweight");
if (c.childNodes.length < 15) {
b.style.display = ""
}
},
refreshWeights: function (c, b) {
var e = c.parentNode;
while (e.childNodes.length > 1) {
de(e.childNodes[1])
}
if (c.selectedIndex > 0) {
ae(e, ct(" "));
var a = ce("input");
a.type = "text";
a.value = (b | 0);
a.maxLength = 7;
a.style.textAlign = "center";
a.style.width = "4.5em";
a.setAttribute("autocomplete", "off");
a.onchange = this.sortWeights.bind(this, a);
ae(e, a);
this.sortWeights(a)
}
if (e.parentNode.childNodes.length == 1) {
if (c.selectedIndex > 0) {
ae(e, ct(String.fromCharCode(160, 160)));
ae(e, this.createControl(LANG.ficlear, "", "", this.resetWeights.bind(this)))
}
} else {
if (e.parentNode.childNodes.length > 1) {
ae(e, ct(String.fromCharCode(160, 160)));
ae(e, this.createControl(LANG.firemove, "", "", this.deleteWeight.bind(this, c)))
}
}
},
sortWeights: function (e) {
var f = ge("su_weight"),
b = Number(e.value),
k = e.parentNode;
var j = 0;
for (var g = 0, a = f.childNodes.length; g < a; ++g) {
var h = f.childNodes[g];
if (h.childNodes.length == 5) {
if (h.childNodes[0].tagName == "SELECT" && h.childNodes[2].tagName == "INPUT") {
if (b > Number(h.childNodes[2].value)) {
f.insertBefore(k, h);
return
}++j
}
}
}
if (j < a) {
f.insertBefore(k, f.childNodes[j])
} else {
ae(f, k)
}
},
saveComparison: function (refresh) {
// sc("compare_groups", 20, this.getGroupData(), "/", ".wowhead.com");
sc("compare_groups", 20, this.getGroupData(), "/", location.hostname);
// sc("compare_weights", 20, rtrim(this.getWeightData(1).join(";"), ";"), "/", wowhead.com);
sc("compare_weights", 20, rtrim(this.getWeightData(1).join(";"), ";"), "/", location.hostname);
sc("compare_level", 20, this.level, "/", location.hostname);
if (refresh) {
document.location.href = "?compare"
}
},
getGroupData: function (g) {
var f = 0,
a = this.groups.length;
if (!isNaN(g)) {
f = g;
a = g + 1
}
var d = "",
c = 0;
for (var e = f; e < a; ++e) {
if (this.groups[e].length < 1) {
continue
}
if (c++>0) {
d += ";"
}
for (var c = 0, b = this.groups[e].length; c < b; ++c) {
if (c > 0) {
d += ":"
}
d += this.writeItem(this.groups[e][c])
}
}
return d
},
getWeightData: function (k) {
var a = "",
f = "",
b = "",
g;
for (var d = 0, e = this.weights.length; d < e; ++d) {
if (d > 0) {
f += ";";
b += ";";
a += ";"
}
a += (k ? this.weights[d].name: urlencode(this.weights[d].name));
var c = 0;
for (var h in this.weights[d]) {
if (!LANG.traits[h]) {
continue
}
g = fi_Lookup(h, "items");
if (!g) {
continue
}
if (c++>0) {
f += ":";
b += ":"
}
f += g.id;
b += this.weights[d][h]
}
}
return [a, f, b]
},
showNoData: function (a) {
var c = this.textNames;
while (c.firstChild) {
de(c.firstChild)
}
c.style.display = "none";
c = this.noData;
while (c.firstChild) {
de(c.firstChild)
}
ae(a, c);
var b = -1;
if (this.template.onNoData) {
b = (this.template.onNoData.bind(this, c))()
}
if (b == -1) {
ae(c, ct(LANG.su_additems || LANG.lvnodata))
}
},
showTextNames: function () {
var b = this.textNames;
b.style.display = "";
b.style.paddingTop = "10px";
while (b.firstChild) {
de(b.firstChild)
}
ae(b, ct(LANG.su_comparing));
var e = 0;
for (var f = 0, g = this.visibility.length; f < g; ++f) {
var h = this.visibility[f];
var d = this.columns[h];
if (!d.group || !d.group.length) {
continue
}
if (e++>0) {
ae(b, ct(LANG.su_comparewith))
}
if (d.group.length == 1) {
var k = g_items[d.group[0][0]].jsonequip;
var j = ce("a");
j.className = "q" + (7 - parseInt(k.name.charAt(0)));
j.href = "?item=" + k.id;
j.rel = this.getItemRel(d.group[0], d);
ae(j, ct("[" + this.getItemName(d.group[0]) + "]"));
ae(b, j)
} else {
var c = ce("span");
c.onmouseover = Summary.groupOver.bind(j, d.group);
c.onmousemove = Tooltip.cursorUpdate;
c.onmouseout = Tooltip.hide;
c.className = "tip";
ae(c, ct("[" + d.group.length + " " + LANG.types[3][3] + "]"));
ae(b, c)
}
}
},
updateControls: function () {
if (this.__lastCtrlUpdate != null && (this.__lastCtrlUpdate == this.groups.length || this.groups.length > 1)) {
return
}
this.__lastCtrlUpdate = this.groups.length;
var k = this.controls,
y;
k.style.display = "";
while (k.firstChild) {
de(k.firstChild)
}
var f = ce("div");
f.className = "summary-controls-right";
ae(k, f);
y = this.createControl(LANG.su_help, null, "help-icon", null, "?help=item-comparison");
ae(f, y);
if (this.searchable) {
var l = ce("span");
//l.className = "icon-additem";
y = this.createControl(LANG.su_addset, "su_addset", "additem-icon", this.openItemPicker.bind(this, 4));
ae(l, y);
ae(f, l);
l = ce("span");
//l.className = "icon-additem";
y = this.createControl(LANG.su_additem, "su_additem", null, this.openItemPicker.bind(this, 3));
y.className = "additem-icon";
ae(l, y);
ae(f, l)
}
if (this.groups.length) {
if (this.weightable) {
var l = ce("span");
//l.className = "icon-additem";
y = this.createControl(LANG.su_addscale, "su_addscale", "additem-icon", this.toggleOptions.bind(this, "su_weights", "su_addscale"));
ae(l, y);
ae(f, l)
}
}
aE(document, "click", this.toggleOptions.bind(this, null, null));
var A = ce("div");
A.className = "clear";
ae(f, A);
if (this.weightable) {
var z = ce("div"),
u = ce("div");
z.style.display = "none";
z.id = "su_weights";
u.className = "summary-weights-inner";
ae(z, u);
ae(f, z);
var j = ce("table"),
b = ce("tbody"),
e = ce("tr"),
g = ce("td");
ae(j, b);
ae(b, e);
ae(e, g);
ae(g, ct(LANG.su_preset));
g = ce("td");
ae(e, g);
var l = ce("select");
l.id = "su_classes";
l.onchange = l.onkeyup = this.refreshClasses.bind(this, l);
ae(l, ce("option"));
ae(g, l);
var v = [];
for (var x in wt_presets) {
v.push(x)
}
v.sort(function (d, c) {
return strcmp(g_chr_classes[d], g_chr_classes[c])
});
for (var q = 0, r = v.length; q < r; ++q) {
var x = v[q],
n = ce("option");
n.value = x;
n._presets = wt_presets[x];
ae(n, ct(g_chr_classes[x]));
ae(l, n)
}
A = ce("span");
A.style.display = "none";
ae(A, ct(" "));
ae(g, A);
l = ce("select");
l.id = "su_presets";
l.onchange = l.onkeyup = this.refreshPresets.bind(this, l);
ae(l, ce("option"));
ae(A, l);
ae(g, ct(" "));
y = ce("a");
y.href = "javascript:;";
ae(y, ct(LANG.fishowdetails));
y.onclick = this.showDetails.bind(this, y);
ae(g, y);
e = ce("tr");
g = ce("td");
ae(b, e);
ae(e, g);
ae(g, ct(LANG.su_name));
g = ce("td");
ae(e, g);
var q = ce("input");
q.type = "text";
q.id = "su_scale";
ae(g, q);
ae(g, ct(" "));
ae(u, j);
var h = ce("div");
h.style.display = "none";
h.id = "su_weight";
ae(u, h);
A = ce("div");
ae(h, A);
l = ce("select");
l.onchange = l.onkeyup = this.refreshWeights.bind(this, l);
ae(l, ce("option"));
ae(A, l);
A = false;
for (var q = 0, r = this.template.traits.length; q < r; ++q) {
var m = this.template.traits[q];
if (m.type == "sep") {
if (A && A.childNodes.length > 0) {
ae(l, A)
}
A = ce("optgroup");
A.label = (LANG.traits[m.id] ? LANG.traits[m.id] : m.name)
} else {
if (m.type != "custom") {
var n = ce("option");
n.value = m.id;
ae(n, ct((m.indent ? "- ": "") + LANG.traits[m.id] ? LANG.traits[m.id][0] : m.name));
ae(A, n)
}
}
}
if (A && A.childNodes.length > 0) {
ae(l, A)
}
A = ce("div");
A.style.display = "none";
y = this.createControl(LANG.su_addweight, "su_addweight", "", this.addWeight.bind(this));
ae(A, y);
ae(u, A);
A = ce("div");
A.className = "summary-weights-buttons";
y = ce("a");
y.className = "help-icon";
y.href = "?help=stat-weighting";
y.target = "_blank";
y.style.border = "none";
y.style.cssFloat = y.style.styleFloat = "right";
ae(y, ct(LANG.su_help));
ae(A, y);
q = ce("input");
q.type = "button";
q.value = LANG.su_applyweight;
q.onclick = Summary.addWeightScale.bind(this);
ae(A, q);
ae(A, ct(" "));
q = ce("input");
q.type = "button";
q.value = LANG.su_resetweight;
q.onclick = Summary.resetScale.bind(this);
ae(A, q);
ae(u, A)
}
if (this.autoSave) {
y = this.createControl(LANG.su_autosaving, null, "autosave-icon selected")
} else {
y = this.createControl(LANG.su_savecompare, "su_save", "save-icon", this.saveComparison.bind(this, 1))
}
ae(k, y);
if (this.groups.length) {
y = this.createControl(LANG.su_linkcompare, "su_link", "link-icon");
ae(k, y);
y = this.createControl(LANG.su_clear, null, "clear-icon", this.resetAll.bind(this));
ae(k, y)
}
},
getRow: function (a) {
var b = this.traits[a];
this.createRow(b);
return b.__tr
},
createRow: function (r) {
var m = ce("tr");
r.__tr = m;
for (var h = 0, k = this.visibility.length; h < k; ++h) {
var l = this.visibility[h];
var d = this.columns[l];
var e = ce("td"),
q = e;
if (d.align != null) {
e.style.textAlign = d.align
}
if (this.total != null && this.__total.id == d.id || this.selected != null && this.__selected.id == d.id) {
if (r.id != "gains") {
e.style.fontWeight = "bold";
e.className += "q1";
if (this.selected != null && this.__selected.id == d.id) {
e.className += " checked"
}
}
}
if (!r.type) {
q.colSpan = k;
q.style.borderBottomWidth = (Browser.ie6 ? "3px": "2px");
q.style.padding = "0";
ae(m, e);
break
}
var o = null;
if (d.compute) {
o = (d.compute.bind(this, r, q, m, l))()
} else {
if (r.compute) {
o = (r.compute.bind(this, d, q, m, l))()
} else {
if (d.total) {
if (this.selected != null && this.__selected.id != d.id && d.difference) {
o = d.difference[r.id];
if (o > 0) {
q.className += " q2"
} else {
if (o < 0) {
q.className += " q10"
} else {
if (o == 0) {
o = null
}
}
}
} else {
o = d.total[r.id]
}
if (o != null) {
if (o.join) {
for (var g = 0, f = o.length; g < f; ++g) {
if (g > 0) {
ae(q, ct(", "))
}
if (o[g].appendChild) {
ae(q, o[g])
} else {
ae(q, ct(o[g]))
}
}
o = null
} else {
if (!isNaN(o)) {
var c = Math.pow(10, (r.digits != null ? r.digits: 4));
o = Math.round(c * o) / c;
if (!r.rating) {
o = (o < 0 ? "-": "") + number_format(Math.abs(o))
} else {
this.selectLevel.style.display = ""
}
if (o > 0 && this.selected != null && this.__selected.id != d.id) {
o = "+" + o
}
}
}
}
}
}
}
if (this.groups.length > 1 && !this.selected && d.total && d.total[r.id] == this.maxValue[r.id] && this.maxValue[r.id] != this.minValue[r.id] && d.id != "total") {
q.style.fontWeight = "bold";
q.className += " q2"
}
if (o != null) {
if (r.rating && !isNaN(o)) {
var b = (o < 0 ? -1 : 1) * g_convertRatingToPercent(this.level, r.rating, Math.abs(o));
b = number_format((Math.round(b * 100) / 100));
if (r.rating != 12 && r.rating != 37) {
b += "%"
}
var p = ce("a");
p.className = (q.className ? q.className: "q1");
p.style.borderBottom = "1px dotted #808080";
p.onmouseover = (function (i, a, n, j) {
Tooltip.show(this, i + " " + j + " (" + sprintf(LANG.tooltip_combatrating, a, n) + ')
' + LANG.su_toggle + "", 0, 0, "q")
}).bind(p, o, b, this.level, LANG.traits[r.id][0]);
p.onmousemove = Tooltip.cursorUpdate;
p.onmouseout = Tooltip.hide;
p.onclick = this.toggleRatings.bind(this);
ae(p, ct(this.ratingMode ? b: o));
aef(q, p)
} else {
aef(q, ct(o))
}
}
if (!r.hidden) {
ae(m, e)
}
}
},
toggleOptions: function (g, h, f) {
f = $E(f);
if (f && f._button >= 2) {
return false
}
var j = [ge("su_weights")],
k = [ge("su_addscale")],
a = null;
if (Browser.ie && f && !g && in_array(k, f._target) != -1) {
return
}
if (h) {
h = ge(h)
}
if (g && h) {
if (h.className.indexOf("selected") != -1) {
h = null
} else {
a = ge(g)
}
} else {
if (f) {
var b = f._target;
if (!b.parentNode) {
return
}
while (b.parentNode) {
if (in_array(j, b) != -1) {
return false
}
b = b.parentNode
}
}
}
for (var c = 0, d = j.length; c < d; ++c) {
if (j[c] && j[c] != a) {
j[c].style.display = "none"
}
}
for (var c = 0, d = k.length; c < d; ++c) {
if (k[c] && k[c] != h) {
k[c].className = k[c].className.replace("selected", "")
}
}
if (h) {
h.className += " selected";
if (a) {
a.style.display = ""
}
}
if (f && g && h) {
sp(f)
}
},
toggleWeights: function () {
if (++this.scoreMode > 2) {
this.scoreMode = 0
}
this.refreshAll()
},
toggleRatings: function () {
this.ratingMode = !this.ratingMode;
this.refreshAll()
},
createControl: function (f, g, e, d, c) {
var b = ce("a");
if (c) {
b.href = c;
b.target = "_blank"
} else {
b.href = "javascript:;"
}
if (g) {
b.id = g
}
if (e) {
b.className = e
}
if (d) {
if (Browser.ie) {
b.onmouseup = d
} else {
b.onclick = d
}
}
ae(b, ct(f));
return b
},
createColumn: function () {
this.groups.push([this.readItem( - 1)]);
this.refreshAll()
},
selectColumn: function (a) {
Tooltip.hide();
this.selected = (this.__selected.id == a.id ? null: this.clone.i + a.i);
this.refreshAll()
},
deleteColumn: function (a, b) {
Tooltip.hide();
b = $E(b);
if (!b.shiftKey) {
this.groups.splice(a.i, 1)
} else {
this.groups = [this.groups[a.i]]
}
if (!this.editable || this.groups.length <= 1 || this.__selected.id == a.id) {
this.selected = null
} else {
if (this.selected) {
this.selected += (this.clone.i + a.i > this.selected ? 0 : -1)
}
}
this.refreshAll();
return false
},
createWeightScale: function () {
var b = ge("su_weight"),
d = ge("su_scale"),
f = {},
e = false;
f.name = d.value;
f.name = trim(f.name);
f.name = f.name.replace(/'/g, "");
for (var c = 0, a = b.childNodes.length; c < a; ++c) {
if (b.childNodes[c].childNodes.length == 5) {
if (b.childNodes[c].childNodes[0].tagName == "SELECT" && b.childNodes[c].childNodes[2].tagName == "INPUT") {
f[b.childNodes[c].childNodes[0].options[b.childNodes[c].childNodes[0].selectedIndex].value] = Number(b.childNodes[c].childNodes[2].value);
e = true
}
}
}
if (e) {
return f
}
return null
},
deleteWeightScale: function (a) {
Tooltip.hide();
this.weights.splice(a, 1);
this.refreshAll()
},
openItemPicker: function (a) {
this.searchType = a;
Lightbox.show("compare", {
onShow: this.onItemPickerShow.bind(this)
})
},
createItemPickerNote: function (e) {
var d = ce("small"),
c = ce("span"),
b;
this.currentSearch = "";
this.searchTimer = 0;
ae(d, ct(LANG.su_note_name));
this.searchName = ce("input");
this.searchName.type = "text";
aE(this.searchName, "keyup", this.onSearchKeyUp.bind(this));
aE(this.searchName, "keydown", this.onSearchKeyDown.bind(this));
ae(d, this.searchName);
this.searchMsg = ce("span");
this.searchMsg.style.fontWeight = "bold";
ae(d, this.searchMsg);
ae(e, d)
},
getSetBonuses: function (l) {
var b = {},
e = {};
for (var g = 0, k = l.length; g < k; ++g) {
var c = l[g][0];
if (g_items[c]) {
var m = g_items[c].jsonequip.itemset;
if (g_itemsets[m]) {
if (e[m] == null) {
e[m] = {}
}
e[m][c] = 1
}
}
}
for (var m in e) {
var a = g_itemsets[m],
h = 0;
if (!a.setbonus) {
continue
}
for (var c in e[m]) {
h++
}
for (var d in a.setbonus) {
if (d > h) {
break
}
for (var f in a.setbonus[d]) {
if (b[f] == null) {
b[f] = 0
}
b[f] += a.setbonus[d][f]
}
}
}
return b
},
onItemPickerShow: function (j, f, b) {
Lightbox.setSize(800, 564);
var c;
if (f) {
j.className = "summary-picker listview";
var h = ce("div"),
i = ce("a"),
e = ce("div");
h.className = "listview";
ae(j, h);
i = ce("a");
i.className = "screenshotviewer-close";
i.href = "javascript:;";
i.onclick = Lightbox.hide;
ae(i, ce("span"));
ae(j, i);
e.className = "clear";
ae(j, e);
c = new Listview({
template: "compare",
id: "items",
parent: h,
data: [],
clip: {
w: 780,
h: 478
},
createNote: this.createItemPickerNote.bind(this)
});
if (Browser.firefox) {
aE(c.getClipDiv(), "DOMMouseScroll", this.onPickerWheel)
} else {
c.getClipDiv().onmousewheel = this.onPickerWheel
}
} else {
c = g_listviews.items
}
var k = this.searchItems.bind(this),
g = this.searchName;
setTimeout(function () {
k("", this.searchType);
g.value = "";
g.focus()
},
1)
},
openSubitemPicker: function (a, b) {
this.currentItem = {
col: a,
i: b,
item: a.group[b]
};
Lightbox.show("subitempicker", {
onShow: this.onSubitemPickerShow.bind(this)
})
},
onSubitemPickerShow: function (k, g, b) {
Lightbox.setSize(800, 564);
var e, c = [],
m = this.currentItem.item[0];
for (var i in g_items[m].jsonequip.subitems) {
var l = g_items[m].jsonequip.subitems[i];
l.id = i;
l.item = m;
l._summary = this;
c.push(l)
}
if (g) {
k.className = "summary-picker listview";
var h = ce("div"),
j = ce("a"),
f = ce("div");
h.className = "listview";
ae(k, h);
j = ce("a");
j.className = "screenshotviewer-close";
j.href = "javascript:;";
j.onclick = Lightbox.hide;
ae(j, ce("span"));
ae(k, j);
f.className = "clear";
ae(k, f);
e = new Listview({
template: "subitempicker",
id: "subitems",
parent: h,
data: c
});
if (Browser.firefox) {
aE(e.getClipDiv(), "DOMMouseScroll", this.onPickerWheel)
} else {
e.getClipDiv().onmousewheel = this.onPickerWheel
}
} else {
e = g_listviews.subitems;
e.setData(c);
e.clearSearch();
e.updateFilters(true)
}
setTimeout(function () {
e.focusSearch()
},
1)
},
openEnchantPicker: function (a, b) {
this.currentItem = {
col: a,
i: b,
item: a.group[b]
};
Lightbox.show("enchantpicker", {
onShow: this.onEnchantPickerShow.bind(this)
})
},
createEnchantPickerNote: function (d) {
var c = ce("small"),
b;
ae(c, ct(LANG.pr_note_source));
b = ce("a");
b.href = "javascript:;";
b.onclick = this.filterEnchants.bind(this, b, 0, null);
ae(b, ct(LANG.pr_note_all));
g_setSelectedLink(b, "enchants0");
ae(c, b);
ae(c, ct(LANG.comma));
b = ce("a");
b.href = "javascript:;";
b.onclick = this.filterEnchants.bind(this, b, 0, 1);
ae(b, ct(LANG.pr_note_items));
ae(c, b);
ae(c, ct(LANG.comma));
b = ce("a");
b.href = "javascript:;";
b.onclick = this.filterEnchants.bind(this, b, 0, 2);
ae(b, ct(LANG.pr_note_profs));
ae(c, b);
ae(d, c)
},
canBeEnchanted: function(slot) {
return (slot == 1 || slot == 3 || slot == 16 || slot == 5 || slot == 20 || // Head, Shoulder, Back, Chest, Robe
slot == 9 || slot == 10 || slot == 6 || slot == 7 || slot == 8 || // Wrists, Hands, Waist, Legs, Feet
slot == 11 || slot == 21 || slot == 13 || slot == 17 || slot == 22 || // Finger, Main Hand, One Hand, Two Hand, Off Hand
slot == 14 || slot == 15 || slot == 26 || slot == 23) // Shield, Ranged, Held in Off Hand
},
isValidEnchant: function (b) {
if (b.none) {
return true
}
var a = 1 << (g_items[this.currentItem.item[0]].jsonequip.slot - 1);
return ((b.slots & a) && (this.enchantSource == null || (this.enchantSource == 1 && b.source < 0) || (this.enchantSource == 2 && b.source > 0)))
},
filterEnchants: function (b, c, d) {
switch (c) {
case 0:
this.enchantSource = d;
break;
default:
return
}
if (b && b.nodeName == "A") {
g_setSelectedLink(b, "enchants" + c)
}
g_listviews.enchants.updateFilters(true);
return false
},
onEnchantPickerShow: function (n, j, c) {
Lightbox.setSize(800, 564);
var f;
if (j) {
n.className = "summary-picker listview";
var e = [],
l = ce("div"),
m = ce("a"),
h = ce("div");
e.push({
none: 1,
__alwaysvisible: 1,
_summary: this
});
for (var o in g_enchants) {
var b = {
id: o,
_summary: this
};
cO(b, g_enchants[o]);
if (typeof b.name == "string") {
e.push(b)
} else {
for (var g = 0, k = g_enchants[o].name.length; g < k; ++g) {
var p = {};
cO(p, b);
p.name = b.name[g];
p.source = b.source[g];
p.slots = b.slots[g];
e.push(p)
}
}
}
l.className = "listview";
ae(n, l);
m = ce("a");
m.className = "screenshotviewer-close";
m.href = "javascript:;";
m.onclick = Lightbox.hide;
ae(m, ce("span"));
ae(n, m);
h.className = "clear";
ae(n, h);
f = new Listview({
template: "enchantpicker",
id: "enchants",
parent: l,
data: e,
createNote: this.createEnchantPickerNote.bind(this),
customFilter: this.isValidEnchant.bind(this)
});
if (Browser.firefox) {
aE(f.getClipDiv(), "DOMMouseScroll", this.onPickerWheel)
} else {
f.getClipDiv().onmousewheel = this.onPickerWheel
}
} else {
f = g_listviews.enchants;
f.clearSearch();
f.updateFilters(true)
}
setTimeout(function () {
f.focusSearch()
},
1)
},
openGemPicker: function (b, c, d, a) {
this.currentItem = {
col: b,
i: c,
item: b.group[c],
socket: d,
color: a
};
Lightbox.show("gempicker", {
onShow: this.onGemPickerShow.bind(this)
})
},
createGemPickerNote: function (e) {
var d = ce("small"),
b;
ae(d, ct(LANG.pr_note_source));
b = ce("a");
b.href = "javascript:;";
b.onclick = this.filterGems.bind(this, b, 0, null);
ae(b, ct(LANG.pr_note_all));
ae(d, b);
ae(d, ct(LANG.comma));
b = ce("a");
b.href = "javascript:;";
b.onclick = this.filterGems.bind(this, b, 0, 1);
ae(b, ct(LANG.pr_note_bc));
ae(d, b);
ae(d, ct(LANG.comma));
b = ce("a");
b.href = "javascript:;";
b.onclick = this.filterGems.bind(this, b, 0, 2);
ae(b, ct(LANG.pr_note_wotlk));
this.gemSource = 2;
g_setSelectedLink(b, "gems0");
ae(d, b);
ae(e, d);
d = ce("small");
var c = ce("span");
c.style.padding = "0 8px";
c.style.color = "white";
ae(c, ct("|"));
ae(d, c);
ae(d, ct(LANG.pr_note_color));
b = ce("a");
b.href = "javascript:;";
b.onclick = this.filterGems.bind(this, b, 1, null);
ae(b, ct(LANG.pr_note_all));
ae(d, b);
ae(d, ct(LANG.comma));
b = ce("a");
b.href = "javascript:;";
b.onclick = this.filterGems.bind(this, b, 1, 1);
ae(b, ct(LANG.pr_note_match));
this.gemColor = 1;
g_setSelectedLink(b, "gems1");
ae(d, b);
ae(e, d)
},
matchGemSocket: function (b, c) {
for (var a = 1; a <= 8; a *= 2) {
if ((c & a) && (b & a)) {
return true
}
}
return false
},
canBeSocketed: function (a) {
return (a == 9 || a == 10 || a == 6)
},
hasExtraSocket: function (a) {
return this.enhanceable && (a[this.getExtraSocketPos(a[0])] ? 1 : 0)
},
getExtraSocketPos: function (a) {
if (!a || !g_items[a]) {
return 4
}
return 4 + (g_items[a].jsonequip.nsockets | 0)
},
hasSocketBonus: function (b) {
var c = 0;
if (!g_items[b[0]] || !g_items[b[0]].jsonequip.nsockets) {
return false
}
for (var a = 0; a < 3; ++a) {
if (b[a + 4] && g_gems[b[a + 4]]) {
if (this.matchGemSocket(g_gems[b[a + 4]].colors, g_items[b[0]].jsonequip["socket" + (a + 1)])) {++c
}
}
}
return (c == g_items[b[0]].jsonequip.nsockets)
},
isValidGem: function (a) {
if (a.none) {
return true
}
return ((this.gemSource == null || a.expansion == this.gemSource) && ((this.gemColor == null && this.currentItem.color != 1 && a.colors != 1) || this.matchGemSocket(a.colors, this.currentItem.color)))
},
filterGems: function (b, c, d) {
switch (c) {
case 0:
this.gemSource = d;
break;
case 1:
this.gemColor = d;
break;
default:
return
}
if (b && b.nodeName == "A") {
g_setSelectedLink(b, "gems" + c)
}
g_listviews.gems.updateFilters(true);
return false
},
onGemPickerShow: function (o, j, e) {
Lightbox.setSize(800, 564);
var h;
if (j) {
o.className = "summary-picker listview";
var f = [],
m = ce("div"),
n = ce("a"),
i = ce("div");
f.push({
none: 1,
__alwaysvisible: 1,
_summary: this
});
for (var l in g_gems) {
var k = {
id: l,
_summary: this
};
cO(k, g_gems[l]);
f.push(k)
}
m.className = "listview";
ae(o, m);
n = ce("a");
n.className = "screenshotviewer-close";
n.href = "javascript:;";
n.onclick = Lightbox.hide;
ae(n, ce("span"));
ae(o, n);
i.className = "clear";
ae(o, i);
h = new Listview({
template: "gempicker",
id: "gems",
parent: m,
data: f,
createNote: this.createGemPickerNote.bind(this),
customFilter: this.isValidGem.bind(this)
});
if (Browser.firefox) {
aE(h.getClipDiv(), "DOMMouseScroll", this.onPickerWheel)
} else {
h.getClipDiv().onmousewheel = this.onPickerWheel
}
} else {
h = g_listviews.gems;
h.clearSearch();
h.updateFilters(true)
}
var c = h.getNoteTopDiv(),
b = gE(c, "small"),
g = gE(c, "a");
if (this.currentItem.color == 1 || this.currentItem.color == 14) {
b[1].style.display = "none"
} else {
b[1].style.display = ""
}
setTimeout(function () {
h.focusSearch()
},
1)
},
onPickerWheel: function (a) {
a = $E(a);
if (a._wheelDelta < 0) {
this.scrollTop += 27
} else {
this.scrollTop -= 27
}
},
onMouseClick: function (b, c) {
c = $E(c);
if (c._button == 3 || c.shiftKey || c.ctrlKey) {
return false
}
},
onMouseUp: function (b, c) {
c = $E(c);
if (c._button == 3 || c.shiftKey || c.ctrlKey) {
var f = Menu.getDiv(0, b.menu);
_cursorPos = g_getCursorPos(c);
if (Browser.ie6) {
_cursorPos.x -= 2;
_cursorPos.y -= 2
}
var g = g_getCursorPos(c);
setTimeout(Menu.showAtCursor.bind(b, null, g.x, g.y), 1);
Tooltip.hide()
}
return false
},
onSearchKeyUp: function (b) {
var a = trim(this.searchName.value.replace(/\s+/g, " "));
if (a == this.currentSearch) {
return
}
this.currentSearch = a;
this.prepareSearch(a)
},
onSearchKeyDown: function (a) {
a = $E(a);
switch (a.keyCode) {
case 13:
g_listviews.items.submitSearch(a);
break;
case 27:
hide();
break;
case 38:
cycle(0);
break;
case 40:
cycle(1);
break
}
},
prepareSearch: function (a) {
if (this.searchTimer > 0) {
clearTimeout(this.searchTimer);
this.searchTimer = 0
}
if (a) {
st(this.searchMsg, sprintf(LANG["su_searching" + this.searchType], a))
}
this.searchMsg.className = "";
this.searchTimer = setTimeout(this.searchItems.bind(this, a, this.searchType), 333)
},
searchItems: function (search, type) {
var lv = g_listviews.items,
_this = this,
searchResults = [{
none: 1
}];
lv.searchable = false;
lv.setData(searchResults);
lv.clearSearch();
lv.updateFilters(true);
this.searchMsg.className = "";
if (!search) {
st(this.searchMsg, LANG["su_specifyitem" + this.searchType]);
return
}
st(this.searchMsg, sprintf(LANG["su_searching" + this.searchType], search));
// todo: find propper format
new Ajax("?search=" + urlencode(search) + "&json&type=" + type, {
method: "POST",
search: search,
onSuccess: function (xhr, opt) {
var text = xhr.responseText;
if (text.charAt(0) != "[" || text.charAt(text.length - 1) != "]") {
return
}
var a = eval(text);
if (search == opt.search && a.length == 3) {
for (var i = 0, len = a[1].length; i < len; ++i) {
var row = {};
row.id = a[1][i].id;
row.name = row["name_" + g_locale.name] = a[1][i].name.substring(1);
row.quality = 7 - a[1][i].name.charAt(0);
row.icon = a[1][i].icon;
row.level = a[1][i].level;
row.classs = a[1][i].classs;
row.subclass = a[1][i].subclass;
row.jsonequip = dO(a[1][i]);
row._type = 3;
row._summary = _this;
g_items.add(a[1][i].id, row);
if (_this.searchType == row._type) {
searchResults.push(row)
}
/* dropped in favour of code block from 2.5.2012 (see above)
var _ = {};
cO(_, a[1][i]);
_._type = _this.searchType;
_._summary = _this;
searchResults.push(_)
*/
}
for (var i = 0, len = a[2].length; i < len; ++i) {
var row = {};
row.id = a[2][i].id;
row.name = row["name_" + g_locale.name] = a[2][i].name.substring(1);
row.quality = 7 - a[2][i].name.charAt(0);
row.minlevel = a[2][i].minlevel;
row.maxlevel = a[2][i].maxlevel;
row.type = a[2][i].type;
row.pieces = a[2][i].pieces;
row.jsonequip = {};
for (var j = 0, len2 = row.pieces.length; j < len2; ++j) {
if (g_items[row.pieces[j]]) {
var item = g_items[row.pieces[j]];
for (var k in item.jsonequip) {
if (LANG.traits[k] == null) {
continue
}
if (!row.jsonequip[k]) {
row.jsonequip[k] = 0
}
row.jsonequip[k] += item.jsonequip[k]
}
}
}
row._type = 4;
row._summary = _this;
if (_this.searchType == row._type) {
searchResults.push(row)
}
/* dropped in favour of code block from 2.5.2012 (see above)
var _ = {};
_["name_" + g_locale.name] = a[2][i].name.substring(1);
cO(_, {
quality: 7 - parseInt(a[2][i].name.charAt(0)),
icon: a[2][i].icon,
jsonequip: {}
});
cO(_.jsonequip, a[2][i]);
g_items.add(a[2][i].id, _)
*/
}
lv.searchable = true;
ee(_this.searchMsg)
} else {
st(_this.searchMsg, sprintf(LANG.su_noresults, opt.search));
_this.searchMsg.className = "q10"
}
lv.setData(searchResults);
lv.clearSearch();
lv.updateFilters(true)
}
})
},
ignoredSlots: {
2 : 1,
11 : 1,
12 : 1,
18 : 1,
24 : 1,
28 : 1
},
viewableIn3d: function (b) {
for (var c = 0, a = b.group.length; c < a; ++c) {
var e = g_items[b.group[c][0]].jsonequip;
if (e.slotbak > 0 && e.displayid > 0 && !this.ignoredSlots[e.slotbak]) {
return true
}
}
return false
},
viewIn3dFromPound: function (a) {
var b = parseInt(a) | 0;
if (b >= 0 && b < this.groups.length) {
this.viewIn3d(this.columns[this.clone.i + b])
}
},
viewIn3d: function (b) {
var e = [];
for (var c = 0, a = b.group.length; c < a; ++c) {
var f = g_items[b.group[c][0]].jsonequip;
if (f.slotbak > 0 && f.displayid > 0 && !this.ignoredSlots[f.slotbak]) {
e.push(f.slotbak);
e.push(f.displayid)
}
}
ModelViewer.show({
type: 4,
typeId: 9999,
equipList: e,
extraPound: b.i,
noPound: (this.autoSave ? 1 : null)
})
},
splitColumn: function (b) {
this.groups.splice(b.i, 1);
for (var c = 0, a = b.group.length; c < a; ++c) {
this.groups.splice(b.i, 0, [b.group[c]])
}
this.refreshAll()
},
hasEnhancements: function (d) {
for (var c = 0, a = d.length; c < a; ++c) {
for (var b = 1; b < 8; ++b) {
if (d[c][b] != 0) {
return true
}
}
}
return false
},
clearEnhancements: function (b, e) {
var d = 0,
a = b.group.length;
if (!isNaN(e)) {
d = e;
a = e + 1
}
for (var c = d; c < a; ++c) {
b.group[c] = this.readItem(b.group[c][0])
}
this.refreshAll()
},
readGroups: function (e) {
if (!e) {
return
}
var d = e.split(";");
for (var f = 0, g = d.length; f < g; ++f) {
var h = [],
a = d[f].split(":");
for (var c = 0, b = a.length; c < b; ++c) {
var k = this.readItem(a[c]);
if (g_items[k[0]]) {
h.push(k)
}
}
if (h.length) {
this.groups.push(h)
}
}
},
readItem: function (a) {
a += "";
var c = a.split(".", 8);
while (c.length < 8) {
c.push(0)
}
for (var b = 0; b < 8; ++b) {
c[b] = parseInt(c[b])
}
return c
},
writeItem: function (a) {
return a[0] ? a.join(".").replace(/(\.0)+$/, "") : ""
},
getItemName: function (b) {
if (!g_items[b[0]]) {
return
}
var a = g_items[b[0]].jsonequip.name.substr(1);
if (g_items[b[0]].jsonequip.subitems && g_items[b[0]].jsonequip.subitems[b[1]]) {
a += " " + g_items[b[0]].jsonequip.subitems[b[1]].name
}
return a
},
getItemRel: function (k, d) {
if (!g_items[k[0]]) {
return
}
var c = this.hasExtraSocket(k),
j = [],
b = [],
h = [];
if (k[1]) {
j.push("rand=" + k[1])
}
if (k[2]) {
j.push("ench=" + k[2])
}
for (var e = 0, f = (g_items[k[0]].jsonequip.nsockets | 0) + c; e < f; ++e) {
b.push(k[4 + e] > 0 ? k[4 + e] : 0)
}
if (b.length) {
j.push("gems=" + b.join(":"))
}
if (c) {
j.push("sock")
}
if (g_items[k[0]].jsonequip.itemset) {
for (var e = 0, f = d.group.length; e < f; ++e) {
var a = d.group[e][0];
if (g_items[a] && g_items[a].jsonequip.itemset) {
h.push(a)
}
}
j.push("pcs=" + h.join(":"))
}
var g = j.join("&");
if (g) {
g = "&" + g
}
return g
},
readWeights: function (f) {
if (!f) {
return
}
var e = f.split(";"),
h = parseInt(e.length / 3);
if (h > 0) {
for (var g = 0; g < h; ++g) {
var b = e[g],
a = e[g + h].split(":"),
m = e[g + h * 2].split(":");
if (a.length > 0 && a.length == m.length) {
var c = {
name: b
},
n = false;
for (var d = 0, k = a.length; d < k; ++d) {
var l = fi_Lookup(a[d], "items");
if (l && l.type == "num") {
c[l.name] = parseInt(m[d]);
n = true
}
}
if (n) {
this.weights.push(c)
}
}
}
}
}
};
Summary.dragGroup = function (b, a, c) {
a.style.width = c.offsetWidth + "px"
};
Summary.moveGroup = function (d, c, a, f) {
if (!c.__col.group.length) {
return
}
var b = [],
g;
cO(b, this.groups[c.__col.i]);
if (!a) {
if (confirm(LANG.message_deletegroup)) {
this.deleteColumn(c.__col, d)
}
return
} else {
if (f && this.newgroup != null && a.__col.id == this.columns[this.newgroup].id) {
g = this.groups.length - 1
} else {
if (f && a.__col.id != c.__col.id) {
g = a.__col.i
} else {
return
}
}
}
if (!d.shiftKey) {
if (this.selected != null && this.clone.i + c.__col.i <= this.selected) {
this.selected--
}
this.groups.splice(c.__col.i, 1)
}
if (this.__selected.id == c.__col.id) {
this.selected = this.clone.i + g
} else {
if (this.selected != null && this.clone.i + g <= this.selected) {
this.selected++
}
}
this.groups.splice(g, 0, b);
this.refreshAll()
};
Summary.moveGroupItem = function (d, c, a) {
if (!c.__col.group.length) {
return
}
var b = [];
cO(b, c.__col.group[c.i]);
if (!a || (a.__col.group && !a.__col.group.length)) {
if (confirm(sprintf(LANG.message_deleteitem, g_items[c.__col.group[c.i][0]].jsonequip.name.substring(1)))) {
c.__col.group.splice(c.i, 1);
this.refreshAll()
}
return
} else {
if (this.newgroup != null && a.__col.id == this.columns[this.newgroup].id) {
this.groups.push([b])
} else {
if (a.__col.id != c.__col.id) {
a.__col.group.push(b)
} else {
if (d.shiftKey) {
c.__col.group.push(b)
} else {
return
}
}
}
}
if (!d.shiftKey) {
c.__col.group.splice(c.i, 1)
}
this.refreshAll()
};
Summary.addGroupItem = function (g, h) {
if (g == 3) {
this.groups.push([this.readItem(h)])
} else {
if (g == 4) {
var c = [];
for (var f in g_items) {
if (g_items[f].jsonequip && g_items[f].jsonequip.itemset == h) {
c.push(this.readItem(f))
}
}
this.groups.push(c)
}
}
this.refreshAll();
Lightbox.hide();
if (g == 3 && g_items[h].jsonequip.subitems) {
var e;
for (var f = 0, a = this.visibility.length; f < a; ++f) {
var d = this.visibility[f];
var b = this.columns[d];
if (b.group && b.group[0][0] == h) {
e = b
}
}
if (e) {
this.openSubitemPicker(e, 0)
}
}
return false
};
Summary.groupOver = function (f, d) {
var h = "",
c = {};
for (var b = 0, a = f.length; b < a; ++b) {
c[f[b][0]] = (c[f[b][0]] | 0) + 1
}
for (var b = 0, a = f.length; b < a; ++b) {
var g = f[b][0];
if (g_items[g]) {
h += "
| ' + c + ' | ' + g + ' |