';
+ }
+ else {
+ str += '';
+ }
+ str += label[i][1] + '';
+ }
+ }
+ this._legendLabel.innerHTML = str;
};
ShowOnMap.combinePins = function(pins, dailyOnly, hasPaths) {
- var combined = {};
- var coord = null, tmpCoord = null;
- var x, y;
- var nPins = 0;
+ var combined = {};
+ var coord = null, tmpCoord = null;
+ var x, y;
+ var nPins = 0;
- var getCoord = function(coord, tight) {
- var x = Math.floor(coord[0]);
- var y = Math.floor(coord[1]);
- if (!tight) {
- if (x % 2 == 1) {
- x += 1;
- }
- if (y % 2 == 1) {
- y += 1;
- }
- }
+ var getCoord = function(coord, tight) {
+ var x = Math.floor(coord[0]);
+ var y = Math.floor(coord[1]);
+ if (!tight) {
+ if (x % 2 == 1) {
+ x += 1;
+ }
+ if (y % 2 == 1) {
+ y += 1;
+ }
+ }
- if (combined[x] === undefined) {
- combined[x] = {};
- }
- if (combined[x][y] === undefined) {
- combined[x][y] = [];
- }
+ if (combined[x] === undefined) {
+ combined[x] = {};
+ }
+ if (combined[x][y] === undefined) {
+ combined[x][y] = [];
+ }
- return [x, y];
- }
+ return [x, y];
+ }
- for (var p = 0; p < pins.length; ++p) {
- var pin = pins[p];
- if (dailyOnly) {
- if (!pin.quests) {
- continue;
- }
- var noDaily = true;
- for (var n = 0; n < pin.quests.length; ++n) {
- if (pin.quests[n].daily) {
- noDaily = false;
- break;
- }
- }
- if (noDaily) {
- continue;
- }
- }
- else if (hasPaths) {
- // Don't combine pins that have paths
- coord = getCoord([pin.id, 0], true);
- x = coord[0]; y = coord[1];
- var newPin = dO(pin);
- newPin.coord = pin.coords[0];
+ for (var p = 0; p < pins.length; ++p) {
+ var pin = pins[p];
+ if (dailyOnly) {
+ if (!pin.quests) {
+ continue;
+ }
+ var noDaily = true;
+ for (var n = 0; n < pin.quests.length; ++n) {
+ if (pin.quests[n].daily) {
+ noDaily = false;
+ break;
+ }
+ }
+ if (noDaily) {
+ continue;
+ }
+ }
+ else if (hasPaths) {
+ // Don't combine pins that have paths
+ coord = getCoord([pin.id, 0], true);
+ x = coord[0]; y = coord[1];
+ var newPin = dO(pin);
+ newPin.coord = pin.coords[0];
- combined[x][y].push(newPin);
- nPins++;
+ combined[x][y].push(newPin);
+ nPins++;
- continue;
- }
+ continue;
+ }
- if (pin.point == 'start' || pin.point == 'end') {
- coord = getCoord(pin.coord);
- x = coord[0]; y = coord[1];
- if (combined[x][y].length > 3) {
- var temp = combined[x][y];
- combined[x][y] = [];
- for (var i = 0; i < temp.length; ++i) {
- tmpCoord = getCoord(temp[i].coord, true);
- combined[tmpCoord[0]][tmpCoord[1]].push(temp[i]);
- }
- }
+ if (pin.point == 'start' || pin.point == 'end') {
+ coord = getCoord(pin.coord);
+ x = coord[0]; y = coord[1];
+ if (combined[x][y].length > 3) {
+ var temp = combined[x][y];
+ combined[x][y] = [];
+ for (var i = 0; i < temp.length; ++i) {
+ tmpCoord = getCoord(temp[i].coord, true);
+ combined[tmpCoord[0]][tmpCoord[1]].push(temp[i]);
+ }
+ }
- combined[x][y].push(pin);
- nPins++;
- }
- else {
- for (var c = 0; c < pin.coords.length; ++c) {
- coord = getCoord(pin.coords[c]);
- x = coord[0]; y = coord[1];
- var newPin = dO(pin);
- newPin.coord = pin.coords[c];
+ combined[x][y].push(pin);
+ nPins++;
+ }
+ else {
+ for (var c = 0; c < pin.coords.length; ++c) {
+ coord = getCoord(pin.coords[c]);
+ x = coord[0]; y = coord[1];
+ var newPin = dO(pin);
+ newPin.coord = pin.coords[c];
- if (combined[x][y].length > 3) {
- var temp = combined[x][y];
- combined[x][y] = [];
- for (var i = 0; i < temp.length; ++i) {
- tmpCoord = getCoord(temp[i].coord, true);
- combined[tmpCoord[0]][tmpCoord[1]].push(temp[i]);
- }
- }
+ if (combined[x][y].length > 3) {
+ var temp = combined[x][y];
+ combined[x][y] = [];
+ for (var i = 0; i < temp.length; ++i) {
+ tmpCoord = getCoord(temp[i].coord, true);
+ combined[tmpCoord[0]][tmpCoord[1]].push(temp[i]);
+ }
+ }
- combined[x][y].push(newPin);
- nPins++;
- }
- }
- }
+ combined[x][y].push(newPin);
+ nPins++;
+ }
+ }
+ }
- var complete = [];
- for (x in combined) {
- for (y in combined[x]) {
- complete.push({
+ var complete = [];
+ for (x in combined) {
+ for (y in combined[x]) {
+ complete.push({
coord: [combined[x][y][0].coord[0], combined[x][y][0].coord[1]],
level: combined[x][y][0].level,
list: combined[x][y]
});
- }
- }
+ }
+ }
- return [complete, nPins];
+ return [complete, nPins];
};
ShowOnMap.buildTooltip = function(list, dailyOnly) {
- var str = '';
- var url = '';
- var menu = [];
- var pinType = -1;
- var uniques = {};
- var nUniques = 0;
- var pointTypes = {};
- var objType = 1;
+ var str = '';
+ var url = '';
+ var menu = [];
+ var pinType = -1;
+ var uniques = {};
+ var nUniques = 0;
+ var pointTypes = {};
+ var objType = 1;
- for (var n = 0; n < list.length; ++n) {
- var obj = list[n];
- url = (g_types[obj.type] && obj.id ? '?' + g_types[obj.type] + '=' + obj.id : '');
- var key = url + obj.item;
- var pointKey = url + obj.point;
- if (!uniques[key]) {
- uniques[key] = {
+ for (var n = 0; n < list.length; ++n) {
+ var obj = list[n];
+ url = (g_types[obj.type] && obj.id ? '?' + g_types[obj.type] + '=' + obj.id : '');
+ var key = url + obj.item;
+ var pointKey = url + obj.point;
+ if (!uniques[key]) {
+ uniques[key] = {
url: url,
obj: obj,
coords: [obj.coord],
all: [obj]
};
- nUniques++;
- }
- else {
- if (!pointTypes[pointKey]) {
- uniques[key].all.push(obj);
- }
- uniques[key].coords.push(obj.coord);
- }
- pointTypes[pointKey] = 1;
- }
+ nUniques++;
+ }
+ else {
+ if (!pointTypes[pointKey]) {
+ uniques[key].all.push(obj);
+ }
+ uniques[key].coords.push(obj.coord);
+ }
+ pointTypes[pointKey] = 1;
+ }
- var n = 0;
- for (var key in uniques) {
- var url = uniques[key].url;
- var all = uniques[key].all;
- var obj = uniques[key].obj;
- var coords = uniques[key].coords;
- if (n > 0) {
+ var n = 0;
+ for (var key in uniques) {
+ var url = uniques[key].url;
+ var all = uniques[key].all;
+ var obj = uniques[key].obj;
+ var coords = uniques[key].coords;
+ if (n > 0) {
str += '
';
- }
- menu.push([n++, obj.name, url]);
- objType = obj.type;
+ }
+ menu.push([n++, obj.name, url]);
+ objType = obj.type;
- if (!obj.point) {
- if ((obj.reacthorde == 1 && obj.reactalliance < 1) || obj.side == 2) {
- if (pinType == 2 || pinType == -1) {
- pinType = 2;
- }
- else {
- pinType = 0;
- }
- }
- else if ((obj.reactalliance == 1 && obj.reacthorde < 1) || obj.side == 1) {
- if (pinType == 3 || pinType == -1) {
- pinType = 3;
- }
- else {
- pinType = 0;
- }
- }
- else {
- pinType = 0;
- }
- }
+ if (!obj.point) {
+ if ((obj.reacthorde == 1 && obj.reactalliance < 1) || obj.side == 2) {
+ if (pinType == 2 || pinType == -1) {
+ pinType = 2;
+ }
+ else {
+ pinType = 0;
+ }
+ }
+ else if ((obj.reactalliance == 1 && obj.reacthorde < 1) || obj.side == 1) {
+ if (pinType == 3 || pinType == -1) {
+ pinType = 3;
+ }
+ else {
+ pinType = 0;
+ }
+ }
+ else {
+ pinType = 0;
+ }
+ }
- str += '' + obj.name + '';
- if (coords.length > 0) {
- str += ' (' + coords[0][0] + ', ' + coords[0][1] + ')
';
- }
+ str += '' + obj.name + '';
+ if (coords.length > 0) {
+ str += ' (' + coords[0][0] + ', ' + coords[0][1] + ')
';
+ }
- if (obj.quests) {
- if (obj.quests.length > 1) {
- str += LANG.som_startsquestpl;
- }
- else {
- str += LANG.som_startsquest;
- }
- str += '';
- for (var q = 0; q < obj.quests.length; ++q) {
- var quest = obj.quests[q];
- if (dailyOnly && !quest.daily) {
- continue;
- }
- str += '[' + quest.level + '] ' + quest.name + ((quest.series && !quest.first) ? '(*)' : '') + ((quest.category < 0 && g_quest_sorts[quest.category]) ? ' ' + g_quest_sorts[quest.category] + '' : '') + '
';
- }
- str += '
';
- }
- else if (obj.description) {
- str += obj.description + '
';
- }
- else if (obj.point) {
- for (var n = 0; n < all.length; ++n) {
- var o = all[n];
- switch (o.point) {
- case 'start':
- str += LANG.mapper_startsquest + '
';
- if (pinType == 'end') {
- pinType = 'startend';
- }
- else if (pinType != 'startend') {
- pinType = 'start';
- }
- break;
- case 'end':
- str += LANG.mapper_endsquest + '
';
- if (pinType == 'start') {
- pinType = 'startend';
- }
- else if (pinType != 'startend') {
- pinType = 'end';
- }
- break;
- case 'sourcestart':
- str += LANG.mapper_sourcestart + '
';
- str += '' + o.item + '
';
- if (pinType == 'end') {
- pinType = 'startend';
- }
- else if (pinType != 'startend') {
- pinType = 'start';
- }
- break;
- case 'sourceend':
- str += LANG.mapper_sourceend + '
';
- str += '' + o.item + '
';
- if (pinType == 'start') {
- pinType = 'startend';
- }
- else if (pinType != 'startend') {
- pinType = 'end';
- }
- break;
- case 'requirement':
- str += LANG.mapper_requiredquest + '
';
- if (pinType == -1) {
- pinType = o.objective;
- }
- break;
- case 'sourcerequirement':
- str += LANG.mapper_sourcereq + '
';
- str += '' + o.item + '
';
- if (pinType == -1) {
- pinType = o.objective;
- }
- break;
- }
- }
- }
- }
+ if (obj.quests) {
+ if (obj.quests.length > 1) {
+ str += LANG.som_startsquestpl;
+ }
+ else {
+ str += LANG.som_startsquest;
+ }
+ str += '';
+ for (var q = 0; q < obj.quests.length; ++q) {
+ var quest = obj.quests[q];
+ if (dailyOnly && !quest.daily) {
+ continue;
+ }
+ str += '[' + quest.level + '] ' + quest.name + ((quest.series && !quest.first) ? '(*)' : '') + ((quest.category < 0 && g_quest_sorts[quest.category]) ? ' ' + g_quest_sorts[quest.category] + '' : '') + '
';
+ }
+ str += '
';
+ }
+ else if (obj.description) {
+ str += obj.description + '
';
+ }
+ else if (obj.point) {
+ for (var n = 0; n < all.length; ++n) {
+ var o = all[n];
+ switch (o.point) {
+ case 'start':
+ str += LANG.mapper_startsquest + '
';
+ if (pinType == 'end') {
+ pinType = 'startend';
+ }
+ else if (pinType != 'startend') {
+ pinType = 'start';
+ }
+ break;
+ case 'end':
+ str += LANG.mapper_endsquest + '
';
+ if (pinType == 'start') {
+ pinType = 'startend';
+ }
+ else if (pinType != 'startend') {
+ pinType = 'end';
+ }
+ break;
+ case 'sourcestart':
+ str += LANG.mapper_sourcestart + '
';
+ str += '' + o.item + '
';
+ if (pinType == 'end') {
+ pinType = 'startend';
+ }
+ else if (pinType != 'startend') {
+ pinType = 'start';
+ }
+ break;
+ case 'sourceend':
+ str += LANG.mapper_sourceend + '
';
+ str += '' + o.item + '
';
+ if (pinType == 'start') {
+ pinType = 'startend';
+ }
+ else if (pinType != 'startend') {
+ pinType = 'end';
+ }
+ break;
+ case 'requirement':
+ str += LANG.mapper_requiredquest + '
';
+ if (pinType == -1) {
+ pinType = o.objective;
+ }
+ break;
+ case 'sourcerequirement':
+ str += LANG.mapper_sourcereq + '
';
+ str += '' + o.item + '
';
+ if (pinType == -1) {
+ pinType = o.objective;
+ }
+ break;
+ }
+ }
+ }
+ }
- str += '';
- if (list.length == 1) {
- str += (list[0].type == 1 ? LANG.som_viewnpc : (list[0].type == 2 ? LANG.som_viewobj : ''));
- }
- else if (nUniques == 1) {
- str += (objType == 1 ? LANG.som_viewnpc : (objType == 2 ? LANG.som_viewobj : ''));
- }
- else {
- str += '
' + LANG.som_view;
- }
- str += '
';
+ str += '';
+ if (list.length == 1) {
+ str += (list[0].type == 1 ? LANG.som_viewnpc : (list[0].type == 2 ? LANG.som_viewobj : ''));
+ }
+ else if (nUniques == 1) {
+ str += (objType == 1 ? LANG.som_viewnpc : (objType == 2 ? LANG.som_viewobj : ''));
+ }
+ else {
+ str += '
' + LANG.som_view;
+ }
+ str += '
';
- var ret = [];
- ret.push(str);
- ret.push(pinType);
- if (list.length == 1 || nUniques == 1) {
- ret.push(url);
- ret.push(null);
- }
- else {
- ret.push('javascript:;');
- ret.push(menu);
- }
+ var ret = [];
+ ret.push(str);
+ ret.push(pinType);
+ if (list.length == 1 || nUniques == 1) {
+ ret.push(url);
+ ret.push(null);
+ }
+ else {
+ ret.push('javascript:;');
+ ret.push(menu);
+ }
- return ret;
+ return ret;
};
// !sarjuuk: tempfix!
-Markup._fixUrl = function(url)
-{
- if(!url) return '';
+Markup._fixUrl = function(url) {
+ if(!url) {
+ return '';
+ }
// Make local URLs absolute
var firstChar = url.charAt(0);
if(firstChar == '/' || firstChar == '?')
- {
- url = url.replace(/^[\/\?]+/, '');
-
- url = '?' + url;
- }
+ url = '?' + url.replace(/^[\/\?]+/, '');
return url;
}
diff --git a/template/js/Summary.js b/template/js/Summary.js
index 2889fa1f..1d22384e 100644
--- a/template/js/Summary.js
+++ b/template/js/Summary.js
@@ -1,3675 +1,5047 @@
-// FILE ARCHIVED ON Dez 29, 2009
var g_summaries = {};
+var fi_type = 'items';
-// required for json parse
-var dO = function(a){
- function b() {}
- b.prototype = a;
- return new b
-};
+function Summary(opt) {
+ cO(this, opt);
-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()
+ if (this.id) {
+ var divId = this.id;
+ if (this.parent) {
+ var d = ce('div');
+ d.id = divId;
+ ae($(this.parent), d);
+ this.container = d;
+ }
+ else {
+ this.container = ge(divId);
+ }
+ }
+ 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 GET = g_getGets();
+ /* sarjuuk: GET.compare => GET.items, when using flat urls */
+
+ this.autoSave = 1;
+ if (GET.compare) {
+ this.autoSave = 0;
+ }
+
+ if (GET.l && !isNaN(GET.l)) {
+ this.level = parseInt(GET.l);
+ }
+ else {
+ var l = gc('compare_level');
+ if (l) {
+ this.level = l;
+ }
+ }
+
+ if (this.groups == null) {
+ this.groups = [];
+
+ if (GET.compare) {
+ this.readGroups(GET.compare);
+ }
+ else {
+ this.readGroups(gc('compare_groups'));
+ }
+ }
+
+ if (this.weights == null) {
+ this.weights = [];
+
+ if (this.weightable) {
+ if (GET.compare) {
+ this.readWeights(GET.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 (GET.compare && GET.focus != null) {
+ var f = parseInt(GET.focus) | 0;
+ if (f >= 0 && f < this.groups.length) {
+ this.selected = this.clone.i + f;
+ }
+ }
+
+ 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"
- }
- },
+ initialize: function() {
+ this.controls = ce('div');
+ this.controls.style.display = 'none';
+ this.controls.className = 'summary-controls';
- updateDraggable: function () {
- for (var c = 0, len = this.dragHeaders.length; c < len; ++c) {
- var _ = this.dragHeaders[c];
+ this.textNames = ce('div');
+ this.textNames.style.display = 'none';
+ this.textNames.className = 'summary-textnames';
- _._targets = this.dragTargets;
- Draggable.init(_, {
- container: this.table,
- onDrag: Summary.dragGroup.bind(this),
- onDrop: Summary.moveGroup.bind(this)
- });
- // alert(_.onmousedown);
+ var result;
+ if (this.onBeforeCreate != null) {
+ result = this.onBeforeCreate();
+ }
- }
- for (var c = 0, len = this.dragIcons.length; c < len; ++c) {
- var _ = this.dragIcons[c];
+ this.updateGroups();
+ this.updateTraits();
+ this.updateColumns();
+ this.updateVisibility();
- _._targets = this.dragTargets;
- Draggable.init(_, {
- container: this.table,
- onDrop: Summary.moveGroupItem.bind(this)
- });
- }
- },
+ if (this.traits.length == 0) {
+ this.visibility.shift();
+ this.visibility.shift();
+ }
- 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);
+ this.noData = ce('div');
+ this.noData.className = 'listview-nodata text';
- if(x.scadist && x.scaflags)
- $WH.g_setJsonItemLevel(x, level);
+ this.table = ce('table');
+ this.thead = ce('thead');
+ this.tbody = ce('tbody');
- 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);
+ this.table.id = 'su_table';
+ this.table.className = 'grid';
- 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 += "";
- h += '| x' + c[g] + " | ";
- h += '';
- h += '' + g_items[g]["name_" + g_locale.name] + "";
- h += " | ";
- h += '' + LANG.level + " " + g_items[g].jsonequip.level + " | ";
- h += "
"
- }
- }
- if (h) {
- Tooltip.showAtCursor(d, '")
- }
-};
-Summary.addWeightScale = function (a) {
- a = this.createWeightScale();
- if (a) {
- this.weights.push(a)
- }
- this.toggleOptions();
- this.refreshAll()
-};
-Summary.resetScale = function () {
- var a = ge("su_classes");
- a.selectedIndex = 0;
- a.onchange()
-};
-Summary.weightOver = function (a, h) {
- var j = '' + a.name + "",
- c = "",
- g = "",
- d, f = false;
- d = 0;
- for (var b in a) {
- if (LANG.traits[b] == null) {
- continue
- }
- if (d++>0) {
- c += "
"
- }
- c += a[b];
- f = true
- }
- if (f) {
- d = 0;
- for (var b in a) {
- if (LANG.traits[b] == null) {
- continue
- }
- if (d++>0) {
- g += "
"
- }
- g += LANG.traits[b][1]
- }
- j += '' + LANG.su_toggle + ""
- }
- Tooltip.showAtCursor(h, j)
-};
-Summary.socketOver = function (c, d) {
- var f = "",
- a = {
- 1 : "#9D9D9D",
- 2 : "#e60c0b",
- 4 : "#ffff35",
- 6 : "#f48905",
- 8 : "#295df1",
- 10 : "#b957fc",
- 12 : "#22c516",
- 14 : "#FFFFFF"
- };
- for (var b in c) {
- if (g_gems[b]) {
- f += "";
- f += 'x' + c[b] + " | ";
- f += '';
- f += '' + g_gems[b].name + "";
- f += " | ";
- f += '' + g_gems[b].enchantment + " | ";
- f += "
"
- }
- }
- if (f) {
- Tooltip.showAtCursor(d, '")
- }
-};
-Summary.addItemSubitem = function (c) {
- var a = this.currentItem.col,
- b = this.currentItem.i;
- a.group[b][1] = c;
- this.refreshAll();
- Lightbox.hide()
-};
-Summary.addItemEnchant = function (c) {
- var a = this.currentItem.col,
- b = this.currentItem.i;
- a.group[b][2] = c;
- this.refreshAll();
- Lightbox.hide()
-};
-Summary.addItemGem = function (a) {
- var b = this.currentItem.col,
- c = this.currentItem.i,
- d = this.currentItem.socket;
- b.group[c][d] = a;
- this.refreshAll();
- Lightbox.hide()
-};
-Summary.toggleExtraSocket = function (c, d, b) {
- var f = c.group[d],
- e = this.getExtraSocketPos(f[0]);
- f[e] = (this.hasExtraSocket(f) ? 0 : -1);
- this.refreshAll()
-};
-Summary.funcBox = {
- createSockets: function (c, e, h, m, k, d) {
- if (!c) {
- return
- }
- var p = {
- 1 : "meta",
- 2 : "red",
- 4 : "yellow",
- 8 : "blue",
- 14 : "prismatic"
- };
- var f, g = 0;
- for (f in p) {
- if (c[f] != null && c[f] != 0) {++g
- }
- }
- if (g == 0) {
- return
- }
- var b = ce("div");
- b.style.paddingBottom = "3px";
- ae(e, b);
- var l = 0,
- g = 0;
- for (f in p) {
- if (c[f] != null && c[f] != 0) {
- if (g > 0) {
- if (g % 2 == 0) {
- var b = ce("div");
- b.style.paddingBottom = "3px";
- ae(e, b)
- } else {
- ae(b, ct(String.fromCharCode(160, 160)))
- }
- }
- var o = ce("a");
- o.href = "?items=3&filter=" + (f == 14 ? "gb=1;cr=81:81:81;crs=2:3:4;crv=0:0:0;ma=1": "cr=81;crs=" + (l + 1) + ";crv=0");
- o.className = "moneysocket" + p[f];
- if (d && d[f]) {
- for (var n in d[f]) {
- if (g_gems[n]) {
- o.className += " tip";
- o.style.borderBottom = "1px dotted #808080";
- break
- }
- }
- o.onmouseover = Summary.socketOver.bind(o, d[f]);
- o.onmousemove = Tooltip.cursorUpdate;
- o.onmouseout = Tooltip.hide
- }
- if (h) {
- o.className += " " + (c[f] > 0 ? "q2": "q10");
- if (c[f] > 0) {
- ae(o, ct("+"))
- }
- } else {
- if (m && k && m[f] != k[f] && c[f] == k[f]) {
- o.style.fontWeight = "bold";
- o.className += " q2"
- }
- }
- ae(o, ct(c[f]));
- ae(b, o); ++g
- }++l
- }
- }
-};
-Summary.templates = {
- compare: {
- total: 1,
- clone: 2,
- newgroup: 3,
- textable: 1,
- enhanceable: 1,
- columns: [
- {
- id: "name",
- align: "left",
- compute: function (c, f, e, b) {
- if (!this.__total.total[c.id]) {
- e.style.display = "none"
+ 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 span = ce('span');
+ span.innerHTML = LANG.su_itemtip;
+ ae(this.itemTip, span);
+ ae(this.container, this.itemTip);
+
+ this.refreshLink();
+
+ if (this.onAfterCreate != null) {
+ this.onAfterCreate(result);
+ }
+
+ if (this.templateName == 'compare') {
+ ModelViewer.addExtraPound(this.viewIn3dFromPound.bind(this));
+ }
+ },
+
+ updateGroups: function() {
+ for (var i = 0, len = this.groups.length; i < len; ++i) {
+ for (var j = 0, len2 = this.groups[i].length; j < len2; ++j) {
+ if (this.groups[i][j][0] == 0 || (len2 > 1 && this.groups[i][j][0] == -1) || !g_items[this.groups[i][j][0]]) {
+ this.groups[i].splice(j, 1);
+ --j;
+ --len2;
+ }
+ }
+
+ if (len2 == 0) { // Remove empty group
+ if (this.selected != null) { // Deselect if selected
+ if (this.__selected.i == i) {
+ this.selected = null;
}
- f.style.whiteSpace = "nowrap";
- f.style.paddingLeft = "4px";
- f.style.paddingRight = "20px";
- var a = (LANG.traits[c.id] ? LANG.traits[c.id][0] : c.name);
- if (c.id == "gains") {
- var d = ce("span");
- d.className = "tip";
- d.onmouseover = function () {
- Tooltip.show(this, LANG.tooltip_gains, 0, 0, "q")
+ }
+
+ this.groups.splice(i, 1);
+ --i;
+ --len;
+ }
+ }
+
+ if (this.editable) {
+ this.updateControls();
+ }
+ },
+
+ updateTraits: function() {
+ this.traits = [];
+
+ var
+ setBonus,
+ sep = false,
+ dataz = [];
+
+ // Get the items, enchants, and gems used by the summary
+ for (var i = 0, len = this.groups.length; i < len; ++i) {
+ for (var j = 0, len2 = this.groups[i].length; j < len2; ++j) {
+ var item = this.groups[i][j];
+
+ if (g_items[item[0]]) {
+ dataz.push(g_items[item[0]].jsonequip);
+
+ if (!this.enhanceable) {
+ continue;
+ }
+
+ // Subitems
+ if (g_items[item[0]].jsonequip.subitems && g_items[item[0]].jsonequip.subitems[item[1]]) {
+ dataz.push(g_items[item[0]].jsonequip.subitems[item[1]].jsonequip);
+ }
+
+ // Perm Enchant
+ if (g_enchants[item[2]]) {
+ dataz.push(g_enchants[item[2]].jsonequip);
+ }
+
+ // Temp Enchant
+ if (g_enchants[item[3]]) {
+ dataz.push(g_enchants[item[3]].jsonequip);
+ }
+
+ // Gems
+ for (var k = 4; k < 8; ++k) {
+ if (g_gems[item[k]]) {
+ dataz.push(g_gems[item[k]].jsonequip);
+ }
+ }
+
+ // Extra sockets
+ if (this.hasExtraSocket(item)) {
+ dataz.push({ nsockets: 1 });
+ }
+
+ // Socket bonuses
+ if (this.hasSocketBonus(item)) {
+ dataz.push(g_items[item[0]].jsonequip.socketbonusstat);
+ }
+ }
+ }
+
+ if (setBonus = this.getSetBonuses(this.groups[i])) {
+ dataz.push(setBonus);
+ }
+ }
+
+ // Find the traits used by those items
+ for (var i = 0, len = this.template.traits.length; i < len; ++i) {
+ var trait = this.template.traits[i];
+
+ if (trait.type == 'sep') {
+ sep = true;
+ continue;
+ }
+
+ var _ = [trait.id];
+ if (trait.json) {
+ var _ = trait.json;
+ }
+
+ var found = false;
+
+ for (var j = 0, len2 = dataz.length; j < len2; ++j) {
+ for (var k = 0, len3 = _.length; k < len3; ++k) {
+ if (dataz[j] && dataz[j][_[k]]
+ && (trait.id != 'gains' || (this.editable && this.groups.length > 1)) // Special case for 'Gains'
+ && (trait.id != 'score' || this.weights.length)) { // Special case for 'Score'
+ if (sep) {
+ this.traits.push({});
+ }
+ sep = false;
+
+ this.traits.push(trait);
+ found = true;
+ break;
+ }
+ }
+
+ if (found) {
+ 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 k = 0;
+ for (var i = 0, len = this.groups.length; i < len; ++i) {
+ if (this.groups[i].length < 1) {
+ continue;
+ }
+
+ if (k > 0 && this.newgroup != null) {
+ this.newgroup++;
+ }
+
+ var _ = dO(this.clone);
+
+ _.id = 'group' + i;
+ _.group = this.groups[i];
+ _.i = i;
+
+ this.columns.splice(this.clone.i + i, 0, _);
+
+ k++;
+ }
+
+ for (var i = 0, len = this.columns.length; i < len; ++i) {
+ this.calcTraitTotals(this.columns[i], this.__total, this.level);
+ }
+
+ if (this.selected != null) {
+ this.__selected = this.columns[this.selected];
+ for (var i = 0, len = this.groups.length; i < len; ++i) {
+ if (this.clone.i + i == this.selected) {
+ continue;
+ }
+
+ this.calcTraitDifference(this.columns[this.clone.i + i], this.__selected);
+ }
+ }
+ else {
+ this.__selected = {};
+ }
+
+ if (this.total != null && (k == 1 || this.selected != null)) {
+ this.__total.hidden = 1;
+ }
+ else {
+ this.__total.hidden = this.showTotal;
+ }
+ }
+ },
+
+ updateVisibility: function() {
+ this.visibility = [];
+
+ var
+ visibleCols = [],
+ hiddenCols = [];
+
+ if (this.visibleCols != null) {
+ array_walk(this.visibleCols, function(x) { visibleCols[x] = 1; });
+ }
+
+ if (this.hiddenCols != null) {
+ array_walk(this.hiddenCols, function(x) { hiddenCols[x] = 1; });
+ }
+
+ for (var i = 0, len = this.columns.length; i < len; ++i) {
+ var col = this.columns[i];
+ if (visibleCols[col.id] != null || (!col.hidden && hiddenCols[col.id] == null)) {
+ this.visibility.push(i);
+ }
+ }
+
+ if (this.groups.length > 1 && this.textable) {
+ this.showTextNames();
+ }
+ else {
+ this.textNames.style.display = 'none';
+ }
+ },
+
+ updateDraggable: function() {
+ for (var i = 0, len = this.dragHeaders.length; i < len; ++i) {
+ var _ = this.dragHeaders[i];
+
+ _._targets = this.dragTargets;
+ Draggable.init(_, {
+ container: this.table,
+ onDrag: Summary.dragGroup.bind(this),
+ onDrop: Summary.moveGroup.bind(this)
+ });
+ }
+
+ for (var i = 0, len = this.dragIcons.length; i < len; ++i) {
+ var _ = this.dragIcons[i];
+
+ _._targets = this.dragTargets;
+ Draggable.init(_, {
+ container: this.table,
+ onDrop: Summary.moveGroupItem.bind(this)
+ });
+ }
+ },
+
+ updateWeights: function(weights) {
+ var _ = ge('su_weight');
+ var c = _.childNodes[0].childNodes[0];
+ var i = 0;
+
+ for (var w in weights) {
+ if (!LANG.traits[w]) {
+ continue;
+ }
+
+ if (i++ > 0) {
+ c = this.addWeight();
+ }
+
+ var opts = c.getElementsByTagName('option');
+
+ for (var j = 0, len = opts.length; j < len; ++j) {
+ if (opts[j].value == w) {
+ opts[j].selected = true;
+ break;
+ }
+ }
+
+ this.refreshWeights(c, weights[w]);
+ }
+ },
+
+ addWeight: function(e) {
+ var _ = ge('su_weight');
+ var a = ge('su_addweight');
+
+ if (_.childNodes.length >= 14) {
+ a.style.display = 'none';
+ }
+
+ a = _.childNodes[0].lastChild;
+ if (a.nodeName != 'A') {
+ ae(_.childNodes[0], ct(String.fromCharCode(160, 160)));
+ ae(_.childNodes[0], this.createControl(LANG.firemove, '', '', this.deleteWeight.bind(this, _.childNodes[0].firstChild)));
+ }
+ else {
+ a.firstChild.nodeValue = LANG.firemove;
+ a.onmouseup = this.deleteWeight.bind(this, _.childNodes[0].firstChild);
+ }
+
+ var
+ d = ce('div'),
+ c = _.childNodes[0].childNodes[0].cloneNode(true);
+
+ ae(_, d);
+
+ c.onchange = c.onkeyup = this.refreshWeights.bind(this, c);
+ ae(d, c);
+
+ ae(d, ct(String.fromCharCode(160, 160)));
+ ae(d, this.createControl(LANG.firemove, '', '', this.deleteWeight.bind(this, c)));
+
+ if (e) {
+ sp($E(e));
+ }
+
+ return c;
+ },
+
+ deleteWeight: function(sel, e) {
+ var
+ d = sel.parentNode,
+ c = d.parentNode;
+
+ de(d);
+
+ if (c.childNodes.length == 1) {
+ var _ = c.firstChild;
+ if (_.firstChild.selectedIndex > 0) {
+ var a = _.lastChild;
+ a.firstChild.nodeValue = LANG.ficlear;
+ a.onmouseup = this.resetWeights.bind(this);
+ }
+ else {
+ while (_.childNodes.length > 1) {
+ de(_.childNodes[1]);
+ }
+ }
+ }
+
+ var a = ge('su_addweight');
+ if (c.childNodes.length < 15) {
+ a.style.display = '';
+ }
+
+ if (e) {
+ sp($E(e));
+ }
+ },
+
+ showDetails: function(a) {
+ var foo = ge('su_weight');
+
+ g_toggleDisplay(foo);
+
+ foo = foo.nextSibling;
+
+ a.firstChild.nodeValue = g_toggleDisplay(foo) ? LANG.fihidedetails : LANG.fishowdetails;
+ },
+
+ saveScale: function() {
+ if (!g_user.id) {
+ return;
+ }
+
+ var
+ opts = gE(ge('su_presets'), 'option'),
+ o;
+
+ for (i in opts) {
+ if (opts[i].selected) {
+ o = opts[i];
+ break;
+ }
+ }
+
+ var
+ name = ge('su_scale').value,
+ id = ((o._weights ? o._weights.id : 0) | 0),
+ scale = { id: id, name: name },
+ _ = ge('su_weight'),
+ n = 0;
+
+ for (i = 0; i < _.childNodes.length; ++i) {
+ var
+ w = fi_Lookup(gE(_.childNodes[i], 'select')[0].value),
+ inps = gE(_.childNodes[i], 'input'),
+ v;
+
+ for (j in inps) {
+ if (inps[j]) {
+ v = inps[j].value;
+ break;
+ }
+ }
+
+ if (w && v && v != 0) {
+ scale[w.name] = v;
+ ++n;
+ }
+ }
+
+ if (!name || n < 1 || (!(o._weights && o._weights.id) && g_user.weightscales && g_user.weightscales.length >= 5)) {
+ return alert(LANG.message_weightscalesaveerror);
+ }
+
+ var data = [ 'save=1', 'name=' + urlencode(name) ];
+
+ if (id) {
+ data.push('id=' + id);
+ }
+
+ scale.name = name;
+ n = 0;
+
+ var scaStr = ''
+ for (var w in scale) {
+ if (!LANG.traits[w]) {
+ continue;
+ }
+
+ if (n++ > 0) {
+ scaStr += ',';
+ }
+
+ scaStr += w + ':' + scale[w];
+ }
+ data.push('scale=' + scaStr);
+
+ new Ajax('?account=weightscales', {
+ method: 'post',
+ params: data.join('&'),
+ onSuccess: function(xhr, opt) {
+ var response = parseInt(xhr.responseText);
+
+ if (response > 0) {
+ if (g_user.weightscales == null) {
+ g_user.weightscales = [];
+ }
+
+ if (scale.id) {
+ g_user.weightscales = array_filter(g_user.weightscales, function(x) {
+ return x.id != scale.id;
+ });
+ }
+
+ scale.id = response;
+ g_user.weightscales.push(scale);
+
+ var
+ s = ge('su_classes'),
+ opts = gE(s, 'option'),
+ c;
+
+ for (i in opts) {
+ if (opts[i].value == -1) {
+ c = opts[i];
+ break;
+ }
+ }
+
+ if (!c) {
+ c = ce('option');
+ c.value = -1;
+ ae(c, ct(LANG.ficustom));
+ aef(s, c);
+ aef(s, gE(s, 'option')[1]);
+ }
+
+ c._presets = { custom: {} };
+ for (var i = 0, len = g_user.weightscales.length; i < len; ++i) {
+ c._presets.custom[g_user.weightscales[i].id] = g_user.weightscales[i];
+ }
+
+ c.selected = true;
+ c.parentNode.onchange();
+
+ var
+ opts = gE(ge('su_presets'), 'option'),
+ o;
+
+ for (i in opts) {
+ if (opts[i].value == scale.id) {
+ o = opts[i];
+ break;
+ }
+ }
+
+ if (o) {
+ o.text = scale.name;
+ o.selected = true;
+ o.parentNode.onchange();
+ }
+
+ alert(LANG.message_saveok);
+ }
+ else {
+ alert(LANG.message_weightscalesaveerror);
+ }
+ }
+ });
+ },
+
+ deleteScale: function() {
+ if (!g_user.id) {
+ return;
+ }
+
+ var
+ s = ge('su_classes'),
+ opts = gE(s, 'option'),
+ c;
+
+ for (i in opts) {
+ if (opts[i].selected) {
+ c = opts[i];
+ break;
+ }
+ }
+
+ if (c.value == -1) {
+ var
+ opts = gE(ge('su_presets'), 'option'),
+ o;
+
+ for (i in opts) {
+ if (opts[i].selected) {
+ o = opts[i];
+ break;
+ }
+ }
+
+ if (o.value && confirm(LANG.confirm_deleteweightscale)) {
+ new Ajax('?account=weightscales', {
+ method: 'post',
+ params: 'delete=1&id=' + o.value
+ });
+
+ g_user.weightscales = array_filter(g_user.weightscales, function(x) {
+ return x.id != o.value;
+ });
+
+ if (g_user.weightscales.length) {
+ c._presets = { custom: {} };
+ for (var i = 0, len = g_user.weightscales.length; i < len; ++i) {
+ c._presets.custom[g_user.weightscales[i].id] = g_user.weightscales[i];
+ }
+ }
+ else {
+ de(c);
+ }
+
+ de(o);
+
+ // $('#su_classes, #su_presets').change();
+ ge('su_classes').onchange();
+ ge('su_presets').onchange();
+ }
+ }
+ },
+
+ calcTraitTotals: function(col, tot, level) {
+ if (!col.group) {
+ return;
+ }
+
+ col.total = {};
+ col.difference = {};
+
+ var traitFuncs = {
+ sum: function(x, y) { return (!isNaN(x) ? x : 0) + y; },
+ min: function(x, y) { return Math.min((!isNaN(x) ? x : y), y); },
+ max: function(x, y) { return Math.max((!isNaN(x) ? x : 0), y); },
+ avg: function(x, y, n) { return (!isNaN(x) ? x : 0) + (y / n); },
+ text: function(x, y, n, e, f, t, s) {
+ if (f) {
+ f = f.bind(this);
+ y = f(y, t, e, s);
+ }
+
+ return (in_array(x, y) < 0 ? y : null);
+ },
+ custom: function(x, y, n, e, f, t, s) {
+ if (f) {
+ f = f.bind(this);
+ f(y, x, t, e, s);
+ }
+
+ return x;
+ }
+ };
+
+ var checkTrait = function(json, tj, trait, col, f, c, e, s) {
+ var _json = dO(json);
+ if (_json.scadist && _json.scaflags) {
+ g_setJsonItemLevel(_json, level);
+ }
+
+ var
+ v = (trait.type == 'text' || trait.type == 'custom' ? _json : (_json[tj] && typeof _json[tj] != 'object' ? _json[tj] : 0));
+
+ if (tj == 'nsockets' && s) {
+ v += s;
+ }
+
+ if (!v) {
+ return;
+ }
+
+ var
+ cT = f(col.total[trait.id], v, col.group.length, e, c, 0, s),
+ tT = f(tot.total[trait.id], v, col.group.length, e, c, 1, s);
+
+ if (trait.type == 'text') {
+ if (cT) {
+ col.total[trait.id].push(cT);
+ }
+ if (tT) {
+ tot.total[trait.id].push(tT);
+ }
+ }
+ else {
+ col.total[trait.id] = cT;
+ tot.total[trait.id] = tT;
+ }
+ };
+
+ for (var trait in this.traits) {
+ trait = this.traits[trait];
+
+ if (trait.id && trait.type) {
+ var
+ setBonus,
+ f = traitFuncs[trait.type].bind(this),
+ c = trait.calcTotal;
+
+ var _ = [trait.id];
+ if (trait.json) {
+ _ = trait.json;
+ }
+
+ if (col.total[trait.id] == null) {
+ if (trait.type == 'text') {
+ col.total[trait.id] = [];
+ }
+ else if (trait.type == 'custom') {
+ col.total[trait.id] = {};
+ }
+ }
+
+ if (tot.total[trait.id] == null) {
+ if (trait.type == 'text') {
+ tot.total[trait.id] = [];
+ }
+ else if (trait.type == 'custom') {
+ tot.total[trait.id] = {};
+ }
+ }
+
+ for (var i = 0, len = col.group.length; i < len; ++i) {
+ var extraSocket = this.hasExtraSocket(col.group[i]);
+
+ for (var j = 0, len2 = _.length; j < len2; ++j) {
+ if (g_items[col.group[i][0]]) {
+ if (g_items[col.group[i][0]]) {
+ checkTrait(g_items[col.group[i][0]].jsonequip, _[j], trait, col, f, c, col.group[i], extraSocket);
+
+ if (!this.enhanceable || trait.itemonly) {
+ continue;
+ }
+
+ if (g_items[col.group[i][0]].jsonequip.subitems && g_items[col.group[i][0]].jsonequip.subitems[col.group[i][1]]) {
+ checkTrait(g_items[col.group[i][0]].jsonequip.subitems[col.group[i][1]].jsonequip, _[j], trait, col, f, c, col.group[i]);
+ }
+
+ if (g_enchants[col.group[i][2]]) {
+ checkTrait(g_enchants[col.group[i][2]].jsonequip, _[j], trait, col, f, c, col.group[i]);
+ }
+
+ if (g_enchants[col.group[i][3]]) {
+ checkTrait(g_enchants[col.group[i][3]].jsonequip, _[j], trait, col, f, c, col.group[i]);
+ }
+
+ for (var k = 4; k < 8; ++k) {
+ if (g_gems[col.group[i][k]]) {
+ checkTrait(g_gems[col.group[i][k]].jsonequip, _[j], trait, col, f, c, col.group[i]);
+ }
+ }
+
+ if (this.hasSocketBonus(col.group[i])) {
+ checkTrait(g_items[col.group[i][0]].jsonequip.socketbonusstat, _[j], trait, col, f, c, col.group[i]);
+ }
+ }
+ }
+ }
+ }
+
+ if (setBonus = this.getSetBonuses(col.group)) {
+ for (var j = 0, len2 = _.length; j < len2; ++j) {
+ checkTrait(setBonus, _[j], trait, col, f, c, []);
+ }
+ }
+
+ if (trait.rating) {
+ this.ratings[trait.id] = trait.rating;
+ }
+
+ if (trait.type == 'sum') {
+ if (col.total[trait.id] == null) {
+ this.minValue[trait.id] = 0;
+ }
+ else if (this.minValue[trait.id] == null || this.minValue[trait.id] > col.total[trait.id]) {
+ this.minValue[trait.id] = col.total[trait.id];
+ }
+ if (this.maxValue[trait.id] == null || this.maxValue[trait.id] < col.total[trait.id]) {
+ this.maxValue[trait.id] = col.total[trait.id];
+ }
+ }
+ else if (trait.type == 'custom') {
+ if (this.minValue[trait.id] == null) {
+ this.minValue[trait.id] = {};
+ }
+ if (this.maxValue[trait.id] == null) {
+ this.maxValue[trait.id] = {};
+ }
+
+ for (var t in col.total[trait.id]) {
+ if (this.minValue[trait.id][t] == null || this.minValue[trait.id][t] > col.total[trait.id][t]) {
+ this.minValue[trait.id][t] = col.total[trait.id][t];
+ }
+ if (this.maxValue[trait.id][t] == null || this.maxValue[trait.id][t] < col.total[trait.id][t]) {
+ this.maxValue[trait.id][t] = col.total[trait.id][t];
+ }
+ }
+ }
+ }
+ }
+ },
+
+ calcTraitDifference: function(col, sel) {
+ col.difference = {};
+
+ var traitFuncs = {
+ sum: function(x, y) { return (!isNaN(y) ? y : 0) - (!isNaN(x) ? x : 0); },
+ min: function(x, y) { return (!isNaN(y) ? y : 0) - (!isNaN(x) ? x : 0); },
+ max: function(x, y) { return (!isNaN(y) ? y : 0) - (!isNaN(x) ? x : 0); },
+ avg: function(x, y) { return (!isNaN(y) ? y : 0) - (!isNaN(x) ? x : 0); },
+ text: function(x, y) {
+ var a = [];
+ for (var i = 0, len = y.length; i < len; ++i) {
+ if (in_array(x, y[i]) == -1) {
+ var _ = ce('span');
+ _.className = 'q2';
+ ae(_, ct('+' + y[i]));
+ a.push(_);
+ }
+ }
+ for (var i = 0, len = x.length; i < len; ++i) {
+ if (in_array(y, x[i]) == -1) {
+ var _ = ce('span');
+
+ _.className = 'q10';
+ ae(_, ct('-' + x[i]));
+ a.push(_);
+ }
+ }
+ return a;
+ },
+ custom: function(x, y, f) {
+ if (f) {
+ f = f.bind(this);
+ return f(y, x);
+ }
+
+ return {};
+ }
+ };
+
+ for (var trait in this.traits) {
+ trait = this.traits[trait];
+
+ if (trait.id && trait.type) {
+ var
+ f = traitFuncs[trait.type].bind(this),
+ c = trait.calcDifference;
+
+ col.difference[trait.id] = f(sel.total[trait.id], col.total[trait.id], c);
+ }
+ }
+ },
+
+ resetAll: function() {
+ this.groups = [];
+ this.weights = [];
+ this.refreshAll();
+ },
+
+ refreshAll: function() {
+ this.updateGroups();
+ this.updateTraits();
+ this.updateColumns();
+ this.updateVisibility();
+ this.refreshHeader();
+ this.refreshRows();
+ this.refreshLink();
+ this.refreshSort();
+
+ if (this.autoSave) {
+ this.saveComparison(0);
+ }
+ else if (this.editable && !Browser.ie) {
+ window.onbeforeunload = function(e) { return LANG.message_savebeforeexit };
+ }
+ },
+
+ 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 tr = ce('tr');
+
+ if (!this.groups.length) {
+ var th = ce('th');
+ ae(tr, th);
+ ae(this.thead, tr);
+ this.showNoData(th);
+ return;
+ }
+
+ var groupi = 0;
+ for (var i = 0, len = this.visibility.length; i < len; ++i) {
+ var reali = this.visibility[i];
+ var col = this.columns[reali];
+
+ var th = ce('th');
+ if (col.id == 'total') {
+ th.style.verticalAlign = 'middle';
+ }
+ else if (col.id == 'name') {
+ th.style.verticalAlign = 'bottom';
+ }
+ else {
+ th.style.verticalAlign = 'top';
+ }
+
+ col.__th = th;
+ th.__col = col;
+
+ if (col.width != null) {
+ th.style.width = col.width;
+ }
+ if (col.align != null) {
+ th.style.textAlign = col.align;
+ }
+ if (col.span != null) {
+ th.colSpan = col.span;
+ }
+
+ if (this.selected != null && this.__selected.id == col.id) {
+ th.className = 'checked';
+ }
+
+ if (col.id == 'name') {
+ ae(th, this.selectLevel);
+ if (this.editable) {
+
+ var s = ce('select');
+ s.onchange = (function(s) {
+ this.level = s.options[s.selectedIndex].value;
+ this.refreshAll();
+ }).bind(this, s);
+
+ for (var i = 80; i > 0; --i) {
+ var o = ce('option');
+ if (i == this.level) {
+ o.selected = true;
+ }
+ st(o, i);
+ ae(s, o);
+ }
+
+ ae(this.selectLevel, ct(LANG.su_level + ' '));
+ ae(this.selectLevel, s);
+ }
+ }
+
+ if (col.group) {
+ this.dragTargets.push(th);
+
+ if (this.editable) {
+ var _ = ce('div');
+ _.className = 'summary-group';
+
+ div = ce('div');
+ div.className = 'summary-group-controls';
+
+ var a = ce('a');
+ a.href = 'javascript:;';
+ a.className = 'summary-group-dropdown';
+ ae(a, ce('span'));
+ a.menu = [
+ [0, LANG.su_export, '?compare=' + this.getGroupData(groupi)]
+ ];
+ a.menu[0].newWindow = 1;
+
+ if (this.viewableIn3d(col)) {
+ a.menu.push([0, LANG.su_viewin3d, this.viewIn3d.bind(this, col)]);
+ }
+
+ if (col.group.length > 1) {
+ a.menu.push([0, LANG.su_split, this.splitColumn.bind(this, col)]);
+ }
+
+ if (this.enhanceable && this.hasEnhancements(col.group)) {
+ a.menu.push([0, LANG.pr_menu_clearenh, this.clearEnhancements.bind(this, col)]);
+ }
+
+ a.onclick = Menu.showAtCursor;
+ ae(div, a);
+
+ if (this.groups.length > 1) {
+ a = ce('a');
+ a.href = 'javascript:;';
+ a.className = 'summary-group-focus';
+ var s = ce('span');
+ a.onclick = this.selectColumn.bind(this, col);
+ if (this.selected && this.__selected.id == col.id) {
+ a.onmouseover = function() {
+ Tooltip.show(this, LANG.tooltip_removefocus, 0, 0, 'q');
+ };
+ s.className = 'selected';
+ }
+ else {
+ a.onmouseover = function() {
+ Tooltip.show(this, LANG.tooltip_setfocus, 0, 0, 'q');
+ };
+ }
+ a.onmousemove = Tooltip.cursorUpdate;
+ a.onmouseout = Tooltip.hide;
+ ae(a, s);
+ ae(div, a);
+ }
+
+ a = ce('a');
+ a.href = 'javascript:;';
+ a.className = 'summary-group-delete';
+ a.onclick = this.deleteColumn.bind(this, col);
+ ae(a, ce('span'));
+ ae(div, a);
+
+ if (this.draggable) {
+ a = ce('a');
+ a.href = 'javascript:;';
+ a.className = 'summary-group-drag';
+ ae(a, ce('span'));
+ ae(div, a);
+
+ _.__col = col;
+ _._handle = a;
+ this.dragHeaders.push(_);
+ }
+
+ ae(_, div);
+ ae(th, _);
+
+ if (this.draggable && this.groups.length > 1) {
+ // Spacer needed to fix the wrapping issues in the bar
+ _.style.minWidth = '80px';
+ }
+ }
+
+ var
+ len2 = col.group.length,
+ iconSize = 1,
+ iconPerRow = 3,
+ iconWidth = 44;
+
+ if (len2 > 3) {
+ iconSize = 0;
+ iconPerRow = 5;
+ iconWidth = 26;
+ }
+
+ var _ = ce('div');
+ _.style.margin = '0 auto';
+ _.style.clear = 'both';
+
+ var
+ btm = ce('div'),
+ div = _.cloneNode(true);
+
+ if (this.editable) {
+ btm.className = 'summary-group-bottom';
+ }
+
+ for (var j = 0; j < len2; ++j) {
+ if (j % iconPerRow == 0) {
+ div.style.width = (iconWidth * iconPerRow) + 'px';
+ div = _.cloneNode(true);
+ ae(btm, div);
+ }
+
+ var icon = g_items.createIcon(col.group[j][0], iconSize);
+
+ icon.__col = col;
+ icon.i = j;
+
+ if (this.enhanceable) {
+ this.refreshItem(col, j, Icon.getLink(icon));
+ }
+
+ this.dragIcons.push(icon);
+
+ ae(div, icon);
+ }
+
+ if (col.group.length) {
+ div.style.width = (iconWidth * (len2 % iconPerRow == 0 ? iconPerRow : (len2 % iconPerRow))) + 'px';
+ }
+ ae(btm, div);
+
+ if (this.editable) {
+ th.style.padding = '0';
+
+ div = ce('div');
+ div.className = 'clear';
+ ae(btm, div);
+
+ div = ce('div');
+ div.className = 'clear';
+ ae(th.firstChild, div);
+
+ ae(th.firstChild, btm);
+ }
+ else {
+ ae(th, btm);
+ }
+
+ groupi++;
+ }
+ else if (col.name) {
+ var b = ce('b');
+ ae(b, ct(col.name));
+ ae(th, b);
+ }
+
+ if (this.editable && reali == this.newgroup) {
+ this.dragTargets.push(th);
+ }
+
+ ae(tr, th);
+ }
+ ae(this.thead, tr);
+
+ if (this.draggable) {
+ this.updateDraggable();
+ }
+ },
+
+ refreshItem: function(col, i, a) {
+ var
+ item = col.group[i],
+ itemId = item[0],
+ menu = [],
+
+ extraSocket = this.hasExtraSocket(item);
+
+ // Random Enchant
+ if (g_items[itemId].jsonequip.subitems != null) {
+ menu.push([0, (item[1] ? LANG.pr_menu_repsubitem : LANG.pr_menu_addsubitem), this.openSubitemPicker.bind(this, col, i)]);
+ }
+
+ // Enchant
+ if (this.canBeEnchanted(g_items[itemId].jsonequip.slotbak, g_items[itemId].jsonequip.subclass)) {
+ var _ = [0, (item[2] ? LANG.pr_menu_repenchant : LANG.pr_menu_addenchant), this.openEnchantPicker.bind(this, col, i)];
+
+ if (item[2] && g_enchants[item[2]]) {
+ _.tinyIcon = g_enchants[item[2]].icon;
+ }
+
+ menu.push(_);
+ }
+
+ // Gems
+ if (g_items[itemId].jsonequip.nsockets || extraSocket) {
+ for (var k = 0, len3 = (g_items[itemId].jsonequip.nsockets | 0) + extraSocket; k < len3; ++k) {
+ var
+ gemId = (item[k + 4] > 0 ? item[k + 4] : 0),
+ c = (extraSocket && k == len3 - 1 ? 14 : g_items[itemId].jsonequip['socket' + (k + 1)]),
+ _ = [0, (gemId ? LANG.pr_menu_repgem : LANG.pr_menu_addgem), this.openGemPicker.bind(this, col, i, 4 + k, c)];
+
+ if (gemId) {
+ _.tinyIcon = g_gems[gemId].icon;
+ }
+ else {
+ _.socketColor = c;
+ }
+
+ menu.push(_);
+ }
+ }
+
+ // Extra Socket
+ if (this.canBeSocketed(g_items[itemId].jsonequip.slotbak)) {
+ var _ = [0, LANG.pr_menu_extrasock, Summary.toggleExtraSocket.bind(this, col, i, a)];
+ _.checked = extraSocket;
+
+ menu.push(_);
+ }
+
+ if (this.hasEnhancements([item])) {
+ menu.push([0, LANG.pr_menu_clearenh, this.clearEnhancements.bind(this, col, i)]);
+ }
+
+ // Remove item
+ menu.push([0, LANG.pr_menu_remove, this.removeItem.bind(this, col.group, i)]);
+
+ a.rel = this.getItemRel(item, col);
+ a.oncontextmenu = rf;
+ a.onclick = this.onMouseClick.bind(0, a);
+ a.onmouseup = this.onMouseUp.bind(0, a);
+ a.menu = menu;
+ },
+
+ removeItem: function(group, i) {
+ group.splice(i, 1);
+ this.refreshAll();
+ },
+
+ 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';
+
+ for (var i = 0, len = this.visibility.length; i < len; ++i) {
+ var reali = this.visibility[i];
+ var col = this.columns[reali];
+
+ if (!col.group)
+ continue;
+
+ for (var j = 0, len2 = col.group.length; j < len2; ++j)
+ {
+ var itemId = col.group[j][0];
+
+ if (g_items[itemId].jsonequip.scadist && g_items[itemId].jsonequip.scaflags)
+ {
+ this.selectLevel.style.display = '';
+ break;
+ }
+ }
+ }
+
+ var i = 0;
+ for (trait in this.traits) {
+ if (this.traits[trait].id) {
+ this.traits[trait].i = ++i;
+ }
+ ae(this.tbody, this.getRow(trait, i));
+ }
+
+ if (!i) {
+ if (!this.groups.length && this.tbody.parentNode) {
+ de(this.tbody);
+ }
+ var tr = ce('tr');
+ var td = ce('td');
+ var span = ce('span');
+ if (this.visibility && this.visibility.length) {
+ td.colSpan = this.visibility.length;
+ }
+ td.style.textAlign = 'center';
+ ae(span, ct('The items in this set don\'t have any comparable stats.'));
+ ae(td, span);
+ ae(tr, td);
+ ae(this.tbody, tr);
+ }
+ },
+
+ getLink: function(groups, weights, level, focus) {
+ var href ='?compare';
+
+ if (groups) {
+ href += '=' + groups; // sarjuuk - with fixed urls: href += '?items=' + groups;
+
+ if (level != 80) {
+ href += '&l=' + level;
+ }
+
+ if (weights[1].length && weights[2].length) {
+ href += '&weights=' + weights.join(';');
+ }
+
+ if (focus !== undefined) {
+ href += '&focus=' + focus;
+ }
+ }
+
+ return href;
+ },
+
+ refreshLink: function() {
+ var
+ a = ge('su_link'),
+ _ = this.getGroupData(),
+ c = this.getWeightData();
+
+ if (this.editable && _) {
+ this.itemTip.style.display = '';
+ }
+ else {
+ this.itemTip.style.display = 'none';
+ }
+
+ if (a) {
+ var href = this.getLink(_, c, this.level, (this.selected ? this.__selected.i : undefined));
+
+ a.href = href;
+ a.target = '_blank';
+ }
+ },
+
+ refreshSort: function(lv) {
+ if (!this.sortWeighted) {
+ var sm = ce('small');
+ sm.style.display = 'none';
+
+ var sp = ce('span');
+ sp.style.padding = '0 8px';
+ sp.style.color = 'white';
+ ae(sp, ct('|'));
+ ae(sm, sp);
+
+ ae(sm, ct(LANG.pr_note_sort + ' '));
+
+ var s = ce('select');
+ ae(sm, s);
+
+ this.sortWeighted = sm;
+ }
+
+ var
+ s = gE(this.sortWeighted, 'select')[0],
+ o = ce('option');
+
+ ee(s);
+ ae(s, o);
+
+ if (this.weights && this.weights.length) {
+ for (var i = 0, len = this.weights.length; i < len; ++i) {
+ o = ce('option');
+ o.scale = this.weights[i];
+ o.selected = (o.scale == this.currentScale);
+ st(o, this.weights[i].name);
+ ae(s, o);
+ }
+ }
+
+ this.sortWeighted.style.display = s.childNodes.length > 1 ? '' : 'none';
+
+ if (lv) {
+ ae(ce('div'), this.sortWeighted); // Remove from current parent
+ gE(this.sortWeighted, 'span')[0].style.display = (gE(lv.getNoteTopDiv(), 'small').length ? '' : 'none');
+
+ ae(lv.getNoteTopDiv(), this.sortWeighted);
+ s.onchange = this.sortPickerWindow.bind(this, lv, 1);
+ s.onchange();
+ }
+ },
+
+ refreshClasses: function(sel) {
+ var
+ c = sel.options[sel.selectedIndex],
+ _ = ge('su_presets');
+
+ while (_.firstChild) {
+ de(_.firstChild);
+ }
+ ae(_, ce('option'));
+
+ if (sel.selectedIndex > 0) {
+ for (var _group in c._presets) {
+ var weights = c._presets[_group];
+
+ if (LANG.presets[_group] != null) {
+ var group = ce('optgroup');
+ group.label = LANG.presets[_group];
+ }
+ else {
+ group = _;
+ }
+
+ for (var p in weights) {
+ var o = ce('option');
+ o.value = p;
+ o._weights = weights[p];
+ ae(o, ct(weights[p].name ? weights[p].name :LANG.presets[p]));
+ ae(group, o);
+ }
+
+ if (LANG.presets[_group] != null && group && group.childNodes.length > 0) {
+ ae(_, group);
+ }
+ }
+
+ if (_.childNodes.length > 1) {
+ _.parentNode.style.display = '';
+ }
+ }
+ else {
+ _.parentNode.style.display = 'none';
+ }
+
+ this.resetWeights();
+ },
+
+ refreshPresets: function(sel) {
+ this.resetWeights();
+
+ var _ = ge('su_classes');
+
+ var o = sel.options[sel.selectedIndex];
+ if (sel.selectedIndex > 0) {
+ this.updateWeights(o._weights);
+ ge('su_scale').value = (_.options[_.selectedIndex].value != -1 ? _.options[_.selectedIndex].text + LANG.hyphen : '') + o.text;
+ }
+
+ if (g_user.id > 0) {
+ var a = ge('su_remscale');
+ a.style.display = (o._weights && o._weights.name ? '' : 'none');
+ }
+ },
+
+ resetWeights: function() {
+ var _ = ge('su_weight');
+
+ ge('su_scale').value = '';
+
+ while (_.childNodes.length >= 2) {
+ _.removeChild(_.childNodes[1]);
+ }
+
+ var d = _.childNodes[0];
+ while (d.childNodes.length > 1) {
+ d.removeChild(d.childNodes[1]);
+ }
+ d.firstChild.selectedIndex = 0;
+
+ var a = ge('su_addweight');
+ if (_.childNodes.length < 15) {
+ a.style.display = '';
+ }
+ },
+
+ refreshWeights: function(sel, value) {
+ var d = sel.parentNode;
+
+ while (d.childNodes.length > 1) {
+ de(d.childNodes[1]);
+ }
+
+ if (sel.selectedIndex > 0) {
+ ae(d, ct(' '));
+ var _ = ce('input');
+ _.type = 'text';
+ _.value = (value | 0);
+ _.maxLength = 7;
+ _.style.textAlign = 'center';
+ _.style.width = '4.5em';
+ _.setAttribute('autocomplete', 'off');
+ _.onchange = this.sortWeights.bind(this, _);
+ ae(d, _);
+ this.sortWeights(_);
+ }
+
+ if (d.parentNode.childNodes.length == 1) {
+ if (sel.selectedIndex > 0) {
+ ae(d, ct(String.fromCharCode(160, 160)));
+ ae(d, this.createControl(LANG.ficlear, '', '', this.resetWeights.bind(this)));
+ }
+ }
+ else if (d.parentNode.childNodes.length > 1) {
+ ae(d, ct(String.fromCharCode(160, 160)));
+ ae(d, this.createControl(LANG.firemove, '', '', this.deleteWeight.bind(this, sel)));
+ }
+ },
+
+ sortWeights: function(input) {
+ var
+ _ = ge('su_weight'),
+ v = Number(input.value),
+ c = input.parentNode;
+
+ var n = 0;
+ for (var i = 0, len = _.childNodes.length; i < len; ++i) {
+ var d = _.childNodes[i];
+ if (d.childNodes.length == 5) {
+ if (d.childNodes[0].tagName == 'SELECT' && d.childNodes[2].tagName == 'INPUT') {
+ if (v > Number(d.childNodes[2].value)) {
+ _.insertBefore(c, d);
+ return;
+ }
+ ++n;
+ }
+ }
+ }
+
+ if (n < len) {
+ _.insertBefore(c, _.childNodes[n]);
+ }
+ else {
+ ae(_, c);
+ }
+ },
+
+ saveComparison: function(refresh) {
+ window.onbeforeunload = null;
+
+ // g_setWowheadCookie('compare_groups', this.getGroupData(), true);
+ sc('compare_groups', 20, this.getGroupData(), '/', location.hostname);
+ // g_setWowheadCookie('compare_weights', rtrim(this.getWeightData(1).join(';'), ';'), true);
+ sc('compare_weights', 20, rtrim(this.getWeightData(1).join(';'), ';'), '/', location.hostname);
+ // g_setWowheadCookie('compare_level', this.level, true);
+ sc('compare_level', 20, this.level, '/', location.hostname);
+
+ if (refresh) {
+ document.location.href = '?compare'
+ }
+ },
+
+ viewSavedComparison: function(refresh) {
+ window.onbeforeunload = null;
+
+ document.location.href = '?compare';
+ },
+
+ getGroupData: function(n) {
+ var
+ start = 0,
+ len = this.groups.length;
+
+ if (!isNaN(n)) {
+ start = n;
+ len = n + 1;
+ }
+
+ var
+ _ = '',
+ j = 0;
+
+ for (var i = start; i < len; ++i) {
+ if (this.groups[i].length < 1) {
+ continue;
+ }
+
+ if (j++ > 0) {
+ _ += ';';
+ }
+
+ for (var j = 0, len2 = this.groups[i].length; j < len2; ++j) {
+ if (j > 0) {
+ _ += ':';
+ }
+
+ _ += this.writeItem(this.groups[i][j]);
+ }
+ }
+ return _;
+ },
+
+ getWeightData: function(plain) {
+ var
+ n = '',
+ wt = '',
+ wtv = '',
+ filter;
+
+ for (var i = 0, len = this.weights.length; i < len; ++i) {
+ if (i > 0) {
+ wt += ';';
+ wtv += ';';
+ n += ';';
+ }
+ n += (plain ? this.weights[i].name : urlencode(this.weights[i].name));
+
+ var j = 0;
+ for (var w in this.weights[i]) {
+ if (!LANG.traits[w]) {
+ continue;
+ }
+
+ filter = fi_Lookup(w, 'items');
+ if (!filter) {
+ continue;
+ }
+
+ if (j++ > 0) {
+ wt += ':';
+ wtv += ':';
+ }
+
+ wt += filter.id;
+ wtv += this.weights[i][w];
+ }
+ }
+ return [n, wt, wtv];
+ },
+
+ showNoData: function(container) {
+ var div = this.textNames;
+ while (div.firstChild) {
+ de(div.firstChild);
+ }
+ div.style.display = 'none';
+
+ div = this.noData;
+ while (div.firstChild) {
+ de(div.firstChild);
+ }
+ ae(container, div);
+
+ var result = -1;
+ if (this.template.onNoData) {
+ result = (this.template.onNoData.bind(this, div))();
+ }
+ if (result == -1) {
+ ae(div, ct(LANG.su_additems || LANG.lvnodata));
+ }
+ },
+
+ showTextNames: function() {
+ var div = this.textNames;
+ div.style.display = '';
+ div.style.paddingTop = '10px';
+
+ while (div.firstChild) {
+ de(div.firstChild);
+ }
+
+ ae(div, ct(LANG.su_comparing));
+
+ var n = 0;
+ for (var i = 0, len = this.visibility.length; i < len; ++i) {
+ var reali = this.visibility[i];
+ var col = this.columns[reali];
+
+ if (!col.group || !col.group.length) {
+ continue;
+ }
+
+ if (n++ > 0) {
+ ae(div, ct(LANG.su_comparewith));
+ }
+
+ if (col.group.length == 1) {
+ var item = g_items[col.group[0][0]].jsonequip;
+
+ var a = ce('a');
+ a.className = 'q' + (7 - parseInt(item.name.charAt(0)));
+ a.href = '?item=' + item.id;
+ a.rel = this.getItemRel(col.group[0], col);
+ ae(a, ct('[' + this.getItemName(col.group[0]) + ']'));
+ ae(div, a);
+ }
+ else {
+ var sp = ce('span');
+ sp.onmouseover = Summary.groupOver.bind(a, col.group);
+ sp.onmousemove = Tooltip.cursorUpdate;
+ sp.onmouseout = Tooltip.hide;
+ sp.className = 'tip';
+ ae(sp, ct('[' + col.group.length + ' ' + LANG.types[3][3] + ']'));
+ ae(div, sp);
+ }
+ }
+ },
+
+ updateControls: function() {
+ if (this.__lastCtrlUpdate != null && (this.__lastCtrlUpdate == this.groups.length || this.groups.length > 1)) {
+ return;
+ }
+ this.__lastCtrlUpdate = this.groups.length;
+
+ var
+ div = this.controls,
+ a;
+
+ div.style.display = '';
+
+ while (div.firstChild) {
+ de(div.firstChild);
+ }
+
+ var div2 = ce('div');
+ div2.className = 'summary-controls-right';
+ ae(div, div2);
+
+ a = this.createControl(LANG.su_help, null, 'help-icon', null, '?help=item-comparison');
+ a.target = '_blank';
+ ae(div2, a);
+
+ if (this.searchable) {
+ a = this.createControl(LANG.su_addset, 'su_addset', 'additem-icon', this.openItemPicker.bind(this, 4));
+ ae(div2, a);
+
+ a = this.createControl(LANG.su_additem, 'su_additem', 'additem-icon', this.openItemPicker.bind(this, 3));
+ ae(div2, a);
+ }
+
+ if (this.groups.length) {
+ if (this.weightable) {
+ a = this.createControl(LANG.su_addscale, 'su_addscale', 'additem-icon', this.toggleOptions.bind(this, 'su_weights', 'su_addscale'));
+ ae(div2, a);
+ }
+ }
+
+ aE(document, 'click', this.toggleOptions.bind(this, null, null));
+
+ var _ = ce('div');
+ _.className = 'clear';
+ ae(div2, _);
+
+ if (this.weightable) {
+ var
+ d2 = ce('div'),
+ d = ce('div');
+
+ d2.style.display = 'none';
+ d2.id = 'su_weights';
+ d.className = 'summary-weights-inner';
+ ae(d2, d);
+ ae(div2, d2);
+
+ var
+ t = ce('table'),
+ tbody = ce('tbody'),
+ tr = ce('tr'),
+ td = ce('td');
+
+ ae(t, tbody);
+ ae(tbody, tr);
+ ae(tr, td);
+
+ ae(td, ct(LANG.su_preset));
+
+ td = ce('td');
+ ae(tr, td);
+
+ var s = ce('select');
+ s.id = 'su_classes';
+ s.onchange = s.onkeyup = this.refreshClasses.bind(this, s);
+ ae(s, ce('option'));
+ ae(td, s);
+
+ if (g_user.weightscales != null && g_user.weightscales.length) {
+ var o = ce('option');
+ o.value = -1;
+ o._presets = { custom: {} };
+ ae(o, ct(LANG.ficustom));
+ ae(s, o);
+
+ for (var i = 0, len = g_user.weightscales.length; i < len; ++i) {
+ o._presets.custom[g_user.weightscales[i].id] = g_user.weightscales[i];
+ }
+ }
+
+ var temp = [];
+ for (var c in wt_presets) {
+ temp.push(c);
+ }
+ temp.sort(function(a, b) {
+ return strcmp(g_chr_classes[a], g_chr_classes[b]);
+ });
+
+ for (var i = 0, len = temp.length; i < len; ++i) {
+ var
+ c = temp[i],
+ o = ce('option');
+
+ o.value = c;
+ o._presets = wt_presets[c];
+ ae(o, ct(g_chr_classes[c]));
+ ae(s, o);
+ }
+
+ _ = ce('span');
+ _.style.display = 'none';
+ ae(_, ct(' '));
+ ae(td, _);
+
+ s = ce('select');
+ s.id = 'su_presets';
+ s.onchange = s.onkeyup = this.refreshPresets.bind(this, s);
+ ae(s, ce('option'));
+ ae(_, s);
+
+ ae(td, ct(' '));
+ a = ce('a');
+ a.href = 'javascript:;';
+ ae(a, ct(LANG.fishowdetails));
+ a.onclick = this.showDetails.bind(this, a);
+ ae(td, a);
+
+ if (g_user.id > 0) {
+ ae(td, ct(' '));
+ a = ce('a');
+ a.href = 'javascript:;';
+ a.className = 'save-icon';
+ a.appendChild(ct(LANG.fisavescale));
+ a.onclick = this.saveScale;
+ a.onmousedown = rf;
+ ae(td, a);
+
+ ae(td, ct(' '));
+ a = ce('a');
+ a.href = 'javascript:;';
+ a.id = 'su_remscale';
+ a.className = 'clear-icon';
+ a.style.display = 'none';
+ a.appendChild(ct(LANG.fideletescale));
+ a.onclick = this.deleteScale;
+ a.onmousedown = rf;
+ ae(td, a);
+ }
+
+ tr = ce('tr');
+ td = ce('td');
+ ae(tbody, tr);
+ ae(tr, td);
+
+ ae(td, ct(LANG.su_name));
+
+ td = ce('td');
+ ae(tr, td);
+
+ var i = ce('input');
+ i.type = 'text';
+ i.id = 'su_scale';
+ ae(td, i);
+ ae(td, ct(' '));
+
+ ae(d, t);
+
+ var w = ce('div');
+ w.style.display = 'none';
+ w.id = 'su_weight';
+ ae(d, w);
+ _ = ce('div');
+ ae(w, _);
+
+ s = ce('select');
+ s.onchange = s.onkeyup = this.refreshWeights.bind(this, s);
+ ae(s, ce('option'));
+ ae(_, s);
+
+ _ = false;
+
+ for (var i = 0, len = this.template.traits.length; i < len; ++i) {
+ var p = this.template.traits[i];
+
+ if (p.type == 'sep') {
+ if (_ && _.childNodes.length > 0) {
+ ae(s, _);
+ }
+ _ = ce('optgroup');
+ _.label = (LANG.traits[p.id] ? LANG.traits[p.id] : p.name);
+ }
+ else if (p.type != 'custom') {
+ var o = ce('option');
+ o.value = p.id;
+ ae(o, ct((p.indent ? '- ' : '') + (LANG.traits[p.id] ? LANG.traits[p.id][0] : p.name)));
+ ae(_, o);
+ }
+ }
+ if (_ && _.childNodes.length > 0) {
+ ae(s, _);
+ }
+
+ _ = ce('div');
+ _.style.display = 'none';
+ a = this.createControl(LANG.su_addweight, 'su_addweight', '', this.addWeight.bind(this));
+ ae(_, a);
+ ae(d, _);
+
+ _ = ce('div');
+ _.className = 'summary-weights-buttons';
+
+ a = ce('a');
+ a.className = 'help-icon';
+ a.href = '?help=stat-weighting';
+ a.target = '_blank';
+ a.style.border = 'none';
+ a.style.cssFloat = a.style.styleFloat = 'right';
+ ae(a, ct(LANG.su_help));
+ ae(_, a);
+
+ i = ce('input');
+ i.type = 'button';
+ i.value = LANG.su_applyweight;
+ i.onclick = Summary.addWeightScale.bind(this);
+ ae(_, i);
+
+ ae(_, ct(' '));
+
+ i = ce('input');
+ i.type = 'button';
+ i.value = LANG.su_resetweight;
+ i.onclick = Summary.resetScale.bind(this);
+ ae(_, i);
+
+ ae(d, _);
+ }
+
+ if (this.autoSave) {
+ a = this.createControl(LANG.su_autosaving, null, 'autosave-icon selected');
+ }
+ else {
+ if (gc('compare_groups')) {
+ a = this.createControl(LANG.su_viewsaved, 'su_viewsaved', 'save-icon', this.viewSavedComparison.bind(this, 1));
+ ae(div, a);
+ }
+
+ a = this.createControl(LANG.su_savecompare, 'su_save', 'save-icon', this.saveComparison.bind(this, 1));
+ }
+ ae(div, a);
+
+ if (this.groups.length) {
+ a = this.createControl(LANG.su_linkcompare, 'su_link', 'link-icon');
+ ae(div, a);
+
+ a = this.createControl(LANG.su_clear, null, 'clear-icon', this.resetAll.bind(this));
+ ae(div, a);
+ }
+ },
+
+ getRow: function(trait) {
+ var row = this.traits[trait];
+ this.createRow(row);
+ return row.__tr
+ },
+
+ createRow: function(row) {
+ var tr = ce('tr');
+ row.__tr = tr;
+
+ for (var i = 0, len = this.visibility.length; i < len; ++i) {
+ var reali = this.visibility[i];
+ var col = this.columns[reali];
+
+ var
+ td = ce('td'),
+ _ = td;
+
+ if (col.align != null) {
+ td.style.textAlign = col.align;
+ }
+
+ if (this.total != null && this.__total.id == col.id || this.selected != null && this.__selected.id == col.id) {
+ if (row.id != 'gains') { // Special case for 'Gains'
+ td.style.fontWeight = 'bold';
+ td.className += 'q1';
+
+ if (this.selected != null && this.__selected.id == col.id) {
+ td.className += ' checked';
+ }
+ }
+ }
+
+ if (!row.type) {
+ _.colSpan = len;
+ _.style.borderBottomWidth = '2px';
+ _.style.padding = '0';
+ ae(tr, td);
+ break;
+ }
+
+ var
+ result = null,
+ sign = '';
+
+ if (col.compute) {
+ result = (col.compute.bind(this, row, _, tr, reali))();
+ }
+ else if (row.compute) {
+ result = (row.compute.bind(this, col, _, tr, reali))();
+ }
+ else if (col.total) {
+ if (this.selected != null && this.__selected.id != col.id && col.difference) {
+ result = col.difference[row.id];
+ if (result > 0) {
+ _.className += ' q2';
+ }
+ else if (result < 0) {
+ _.className += ' q10';
+ }
+ else if (result == 0) {
+ result = null;
+ }
+ }
+ else {
+ result = col.total[row.id];
+ }
+
+ if (result != null) {
+ if (result.join) {
+ for (var j = 0, len2 = result.length; j < len2; ++j) {
+ if (j > 0) {
+ ae(_, ct(', '));
+ }
+ if (result[j].appendChild) {
+ ae(_, result[j]);
+ }
+ else {
+ ae(_, ct(result[j]));
+ }
+ }
+ result = null;
+ }
+ else if (!isNaN(result)) {
+ var n = Math.pow(10, (row.digits != null ? row.digits : 4));
+ result = Math.round(n * result) / n;
+
+ if (result > 0 && this.selected != null && this.__selected.id != col.id) {
+ sign = '+';
+ }
+
+ if (!row.rating) {
+ result = (result < 0 ? '-' : '') + number_format(Math.abs(result));
+ }
+ else {
+ this.selectLevel.style.display = '';
+ }
+ }
+ }
+ }
+
+ // Is maximum value?
+ if (this.groups.length > 1 && !this.selected && col.total && col.total[row.id] == this.maxValue[row.id] && this.maxValue[row.id] != this.minValue[row.id] && col.id != 'total') {
+ _.style.fontWeight = 'bold';
+ _.className += ' q2';
+ }
+
+ if (result != null) {
+ if (row.rating && !isNaN(result)) {
+ var percent = (result < 0 ? -1 : 1) * g_convertRatingToPercent(this.level, row.rating, Math.abs(result));
+ percent = number_format((Math.round(percent * 100) / 100));
+
+ if (row.rating != 12 && row.rating != 37) { // Neither Defense, nor Expertise
+ percent += '%';
+ }
+
+ var a = ce('a');
+
+ a.className = (_.className ? _.className : 'q1');
+ a.style.borderBottom = '1px dotted #808080';
+ a.onmouseover = (function(rating, percent, level, text) {
+ Tooltip.show(this, rating + ' ' + text + ' (' + sprintf(LANG.tooltip_combatrating, percent, level) + ')
' + LANG.su_toggle + '', 0, 0, 'q');
+ }).bind(a, result, percent, this.level, LANG.traits[row.id][0]);
+ a.onmousemove = Tooltip.cursorUpdate;
+ a.onmouseout = Tooltip.hide;
+ a.onclick = this.toggleRatings.bind(this);
+
+ ae(a, ct(sign + (this.ratingMode ? percent : result)));
+
+ aef(_, a);
+ }
+ else {
+ aef(_, ct(sign + result));
+ }
+ }
+
+ if (!row.hidden) {
+ ae(tr, td);
+ }
+ }
+ },
+
+ toggleOptions: function(popupId, link, e) {
+ e = $E(e);
+
+ if (e && e._button >= 2) {
+ return false;
+ }
+
+ var
+ popups = [ge('su_weights')],
+ links = [ge('su_addscale')],
+ popup = null;
+
+ if (Browser.ie && e && !popupId && in_array(links, e._target) != -1) {
+ return;
+ }
+
+ if (link) {
+ link = ge(link);
+ }
+ if (popupId && link) { // Params provided -> a link was clicked
+ if (link.className.indexOf('selected') != -1) { // Already selected
+ link = null;
+ }
+ else {
+ popup = ge(popupId);
+ }
+ }
+ else if (e) {
+ var p = e._target;
+
+ if (!p.parentNode) {
+ return;
+ }
+
+ while (p.parentNode) {
+ if (in_array(popups, p) != -1) {
+ return false;
+ }
+
+ p = p.parentNode;
+ }
+ }
+
+ for (var i = 0, len = popups.length; i < len; ++i) {
+ if (popups[i] && popups[i] != popup) {
+ popups[i].style.display = 'none';
+ }
+ }
+ for (var i = 0, len = links.length; i < len; ++i) {
+ if (links[i] && links[i] != link) {
+ links[i].className = links[i].className.replace('selected', '');
+ }
+ }
+
+ if (link) {
+ link.className += ' selected';
+
+ if (popup) {
+ popup.style.display = '';
+ }
+ }
+
+ if (e && popupId && link) {
+ sp(e);
+ }
+ },
+
+ toggleWeights: function() {
+ if (++this.scoreMode > 2) {
+ this.scoreMode = 0;
+ }
+ this.refreshAll();
+ },
+
+ toggleRatings: function() {
+ this.ratingMode = !this.ratingMode;
+
+ this.refreshAll();
+ },
+
+ createControl: function(text, id, _class, onclick, href) {
+ var a = ce('a');
+
+ if (href) {
+ a.href = href;
+ a.target = '_blank';
+ }
+ else {
+ a.href = 'javascript:;';
+ }
+
+ if (id) {
+ a.id = id;
+ }
+
+ if (_class) {
+ a.className = _class;
+ }
+
+ if (onclick) {
+ a.onclick = onclick;
+ }
+
+ ae(a, ct(text));
+
+ return a;
+ },
+
+ createColumn: function() {
+ this.groups.push([this.readItem(-1)]);
+ this.refreshAll();
+ },
+
+ selectColumn: function(col) {
+ Tooltip.hide();
+
+ this.selected = (this.__selected.id == col.id ? null : this.clone.i + col.i);
+ this.refreshAll();
+ },
+
+ deleteColumn: function(col, e) {
+ Tooltip.hide();
+
+ e = $E(e);
+
+ if (!e.shiftKey) {
+ this.groups.splice(col.i, 1);
+ }
+ else {
+ this.groups = [this.groups[col.i]];
+ }
+ if (!this.editable || this.groups.length <= 1 || this.__selected.id == col.id) {
+ this.selected = null;
+ }
+ else if (this.selected) {
+ this.selected += (this.clone.i + col.i > this.selected ? 0 : -1);
+ }
+ this.refreshAll();
+
+ return false;
+ },
+
+ createWeightScale: function() {
+ var
+ _ = ge('su_weight'),
+ s = ge('su_scale'),
+ scale = {},
+ found = false;
+
+ scale.name = s.value;
+ scale.name = trim(scale.name);
+ scale.name = scale.name.replace(/'/g, '');
+
+ for (var i = 0, len = _.childNodes.length; i < len; ++i) {
+ if (_.childNodes[i].childNodes.length == 5) {
+ if (_.childNodes[i].childNodes[0].tagName == 'SELECT' && _.childNodes[i].childNodes[2].tagName == 'INPUT') {
+ scale[_.childNodes[i].childNodes[0].options[_.childNodes[i].childNodes[0].selectedIndex].value] = Number(_.childNodes[i].childNodes[2].value);
+
+ found = true;
+ }
+ }
+ }
+
+ if (found) {
+ return scale;
+ }
+
+ return null;
+ },
+
+ deleteWeightScale: function(i) {
+ Tooltip.hide();
+
+ this.weights.splice(i, 1);
+
+ if (!this.weights.length) {
+ var a = ge('enchants-default-sort');
+ if (a) {
+ a.onclick();
+ }
+ }
+
+ this.refreshAll();
+ },
+
+ calcScores: function(data, scale) {
+ for (var i = 0, len = data.length; i < len; ++i) {
+ var row = data[i];
+
+ row.__tr = null;
+ row.score = (scale ? 0 : null);
+
+ if (row.jsonequip && scale) {
+ for (var w in scale) {
+ if (!LANG.traits[w]) {
+ continue;
+ }
+
+ if (!isNaN(row.jsonequip[w])) {
+ row.score += row.jsonequip[w] * scale[w] / (!this.scoreMode ? scale.f : (this.scoreMode == 2 ? scale.m * 0.01 : 1));
+ }
+ }
+
+ if (!this.scoreMode) {
+ row.score = row.score.toFixed(2);
+ }
+ else if (this.scoreMode == 2) {
+ row.score = row.score.toFixed(1) + '%';
+ }
+ }
+ }
+
+ return data;
+ },
+
+ sortPickerWindow: function(lv, search) {
+ if (!this.sortWeighted) {
+ return;
+ }
+
+ /* original
+ if ($('option:selected', this.sortWeighted)[0])
+ this.currentScale = $('option:selected', this.sortWeighted)[0].scale;
+ * replacement */
+
+ var opts = gE(this.sortWeighted, 'option');
+ for (i in opts) {
+ if (opts[i].selected) {
+ this.currentScale = opts[i].scale;
+ break;
+ }
+ }
+ /* replace end */
+
+ lv.setSort([1], true, false);
+ lv.setData(this.calcScores(lv.data, this.currentScale));
+
+ if (this.currentScale) {
+ lv.setSort([2], true, false);
+ }
+
+ if (search && lv.id == 'items') {
+ this.onSearchKeyUp(0);
+ }
+ },
+
+ openItemPicker: function(type) {
+ this.searchType = type;
+
+ Lightbox.show('compare', { onShow: this.onItemPickerShow.bind(this) });
+ },
+
+ createItemPickerNote: function(div) {
+ var
+ sm = ce('small'),
+ sp = ce('span'),
+ a;
+
+ this.currentSearch = '';
+ this.searchTimer = 0;
+
+ ae(sm, ct(LANG.su_note_name));
+
+ this.searchName = ce('input');
+ this.searchName.type = 'text';
+
+ aE(this.searchName, 'keyup', this.onSearchKeyUp.bind(this, 333));
+ aE(this.searchName, 'keydown', this.onSearchKeyDown.bind(this));
+
+ ae(sm, this.searchName);
+ this.searchMsg = sp;
+ this.searchMsg.style.fontWeight = 'bold';
+ ae(sm, this.searchMsg);
+ ae(div, sm);
+ },
+
+ getSetBonuses: function(group) {
+ var
+ setbonuses = {},
+ itemsetpcs = {},
+ itemsetbak = {};
+
+ for (var i = 0, len = group.length; i < len; ++i) {
+ var p = group[i][0];
+ if (g_items[p]) {
+ var
+ s = g_items[p].jsonequip.itemset,
+ _ = g_itemsets[s];
+
+ if (_) {
+ // Use the real set id for set bonus tally
+ s = _.idbak;
+ if (itemsetpcs[s] == null) {
+ itemsetpcs[s] = {};
+ }
+ itemsetpcs[s][p] = 1;
+ itemsetbak[s] = _;
+ }
+ }
+ }
+
+ for (var s in itemsetpcs) {
+ var
+ itemset = itemsetbak[s],
+ nItems = 0;
+
+ if (!itemset.setbonus) {
+ continue;
+ }
+
+ for (var p in itemsetpcs[s]) {
+ nItems++;
+ }
+
+ for (var n in itemset.setbonus) {
+ if (n > nItems) {
+ break;
+ }
+
+ for (var j in itemset.setbonus[n]) {
+ if (setbonuses[j] == null) {
+ setbonuses[j] = 0;
+ }
+
+ setbonuses[j] += itemset.setbonus[n][j];
+ }
+ }
+ }
+
+ return setbonuses;
+ },
+
+ onItemPickerShow: function(dest, first, opt) {
+ Lightbox.setSize(800, 564);
+
+ var lv;
+
+ if (first) {
+ dest.className = 'summary-picker listview';
+
+ var
+ d = ce('div'),
+ a = ce('a'),
+ clear = ce('div');
+
+ d.className = 'listview';
+ ae(dest, d);
+
+ a = ce('a');
+ a.className = 'screenshotviewer-close';
+ a.href = 'javascript:;';
+ a.onclick = Lightbox.hide;
+ ae(a, ce('span'));
+ ae(dest, a);
+
+ clear.className = 'clear';
+ ae(dest, clear);
+
+ lv = new Listview({
+ template: 'compare',
+ id: 'items',
+ parent: d,
+ data: [],
+ clip: { w: 780, h: 478 },
+ createNote: this.createItemPickerNote.bind(this)
+ });
+
+ if (Browser.firefox) {
+ aE(lv.getClipDiv(), 'DOMMouseScroll', g_pickerWheel);
+ }
+ else {
+ lv.getClipDiv().onmousewheel = g_pickerWheel;
+ }
+ }
+ else {
+ lv = g_listviews.items;
+ }
+
+ var
+ searchItems = this.searchItems.bind(this),
+ searchName = this.searchName;
+
+ this.refreshSort(lv);
+
+ setTimeout(function() {
+ searchItems('', this.searchType);
+ searchName.value = '';
+ searchName.focus();
+ }, 1);
+ },
+
+ openSubitemPicker: function(col, i) {
+ this.currentItem = { col: col, i: i, item: col.group[i] };
+
+ Lightbox.show('subitempicker', { onShow: this.onSubitemPickerShow.bind(this) });
+ },
+
+ onSubitemPickerShow: function(dest, first, opt) {
+ Lightbox.setSize(800, 564);
+
+ var
+ lv,
+ dataz = [],
+ itemId = this.currentItem.item[0];
+
+ for (var subitemId in g_items[itemId].jsonequip.subitems) {
+ var subitem = g_items[itemId].jsonequip.subitems[subitemId];
+
+ subitem.id = subitemId;
+ subitem.item = itemId;
+ subitem._summary = this;
+
+ dataz.push(subitem);
+ }
+
+ if (first) {
+ dest.className = 'summary-picker listview';
+
+ var
+ d = ce('div'),
+ a = ce('a'),
+ clear = ce('div');
+
+ d.className = 'listview';
+ ae(dest, d);
+
+ a = ce('a');
+ a.className = 'screenshotviewer-close';
+ a.href = 'javascript:;';
+ a.onclick = Lightbox.hide;
+ ae(a, ce('span'));
+ ae(dest, a);
+
+ clear.className = 'clear';
+ ae(dest, clear);
+
+ lv = new Listview({
+ template: 'subitempicker',
+ id: 'subitems',
+ parent: d,
+ data: dataz
+ });
+
+ if (Browser.firefox) {
+ aE(lv.getClipDiv(), 'DOMMouseScroll', g_pickerWheel);
+ }
+ else {
+ lv.getClipDiv().onmousewheel = g_pickerWheel;
+ }
+ }
+ else {
+ lv = g_listviews.subitems;
+
+ lv.setData(dataz);
+ lv.clearSearch();
+ lv.updateFilters(true);
+ }
+
+ this.refreshSort(lv);
+
+ setTimeout(function() {
+ lv.focusSearch();
+ }, 1);
+ },
+
+ openEnchantPicker: function(col, i) {
+ this.currentItem = { col: col,i: i, item: col.group[i] };
+
+ Lightbox.show('enchantpicker', { onShow: this.onEnchantPickerShow.bind(this) });
+ },
+
+ createEnchantPickerNote: function(div) {
+ var
+ sm = ce('small'),
+ a;
+
+ ae(sm, ct(LANG.pr_note_source));
+
+ a = ce('a');
+ a.href = 'javascript:;';
+ a.onclick = this.filterEnchants.bind(this, a, 0, null);
+ ae(a, ct(LANG.pr_note_all));
+
+ g_setSelectedLink(a, 'enchants0');
+
+ ae(sm, a);
+ ae(sm, ct(LANG.comma));
+
+ a = ce('a');
+ a.href = 'javascript:;';
+ a.onclick = this.filterEnchants.bind(this, a, 0, 1);
+ ae(a, ct(LANG.pr_note_items));
+
+ ae(sm, a);
+ ae(sm, ct(LANG.comma));
+
+ a = ce('a');
+ a.href = 'javascript:;';
+ a.onclick = this.filterEnchants.bind(this, a, 0, 2);
+ ae(a, ct(LANG.pr_note_profs));
+
+ ae(sm, a);
+ ae(div, sm);
+ },
+
+ canBeEnchanted: function(slot, subclass) {
+ 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
+ (subclass != 19)) // No Wands
+ },
+
+ isValidEnchant: function(enchant) {
+ if (enchant.none) {
+ return true;
+ }
+
+ var slotMask = 1 << (g_items[this.currentItem.item[0]].jsonequip.slot - 1);
+
+ return (
+ // Slot
+ (enchant.slots & slotMask) &&
+
+ // Source
+ (
+ this.enchantSource == null ||
+ (this.enchantSource == 1 && enchant.source < 0) ||
+ (this.enchantSource == 2 && enchant.source > 0)
+ )
+ );
+ },
+
+ filterEnchants: function(a, wut, value) {
+ switch (wut) {
+ case 0:
+ this.enchantSource = value;
+ break;
+ default:
+ return;
+ }
+
+ if (a && a.nodeName == 'A') {
+ g_setSelectedLink(a, 'enchants' + wut);
+ }
+
+ g_listviews.enchants.updateFilters(true);
+
+ return false;
+ },
+
+ onEnchantPickerShow: function(dest, first, opt) {
+ Lightbox.setSize(800, 564);
+
+ var lv;
+
+ if (first) {
+ dest.className = 'summary-picker listview';
+
+ var
+ dataz = [],
+ d = ce('div'),
+ a = ce('a'),
+ clear = ce('div');
+
+ dataz.push({ none: 1, __alwaysvisible: 1, _summary: this });
+
+ for (var enchantId in g_enchants) {
+ var enchant = { id: enchantId, _summary: this };
+
+ cO(enchant, g_enchants[enchantId]);
+
+ if (typeof enchant.name == 'string') {
+ dataz.push(enchant);
+ }
+ else {
+ for (var i = 0, len = g_enchants[enchantId].name.length; i < len; ++i) {
+ var row = dO(enchant);
+
+ row.name = enchant.name[i];
+ row.source = enchant.source[i];
+ row.slots = enchant.slots[i];
+
+ dataz.push(row);
+ }
+ }
+ }
+
+ d.className = 'listview';
+ ae(dest, d);
+
+ a = ce('a');
+ a.className = 'screenshotviewer-close';
+ a.href = 'javascript:;';
+ a.onclick = Lightbox.hide;
+ ae(a, ce('span'));
+ ae(dest, a);
+
+ clear.className = 'clear';
+ ae(dest, clear);
+
+ lv = new Listview({
+ template: 'enchantpicker',
+ id: 'enchants',
+ parent: d,
+ data: dataz,
+ createNote: this.createEnchantPickerNote.bind(this),
+ customFilter: this.isValidEnchant.bind(this)
+ });
+
+ if (Browser.firefox) {
+ aE(lv.getClipDiv(), 'DOMMouseScroll', g_pickerWheel);
+ }
+ else {
+ lv.getClipDiv().onmousewheel = g_pickerWheel;
+ }
+ }
+ else {
+ lv = g_listviews.enchants;
+
+ lv.clearSearch();
+ lv.updateFilters(true);
+ }
+
+ this.refreshSort(lv);
+
+ setTimeout(function() {
+ lv.focusSearch();
+ }, 1);
+ },
+
+ openGemPicker: function(col, i, socket, color) {
+ this.currentItem = {
+ col: col,
+ i: i,
+ item: col.group[i],
+ socket: socket,
+ color: color
+ };
+
+ Lightbox.show('gempicker', { onShow: this.onGemPickerShow.bind(this) });
+ },
+
+ createGemPickerNote: function(div) {
+ var
+ sm = ce('small'),
+ a;
+
+ ae(sm, ct(LANG.pr_note_source));
+
+ a = ce('a');
+ a.href = 'javascript:;';
+ a.onclick = this.filterGems.bind(this, a, 0, null);
+ ae(a, ct(LANG.pr_note_all));
+
+ ae(sm, a);
+ ae(sm, ct(LANG.comma));
+
+ a = ce('a');
+ a.href = 'javascript:;';
+ a.onclick = this.filterGems.bind(this, a, 0, 1);
+ ae(a, ct(LANG.pr_note_bc));
+
+ ae(sm, a);
+ ae(sm, ct(LANG.comma));
+
+ a = ce('a');
+ a.href = 'javascript:;';
+ a.onclick = this.filterGems.bind(this, a, 0, 2);
+ ae(a, ct(LANG.pr_note_wotlk));
+ this.gemSource = 2;
+ g_setSelectedLink(a, 'gems0');
+
+ ae(sm, a);
+ ae(div, sm);
+
+ sm = ce('small');
+
+ var sp = ce('span');
+ sp.style.padding = '0 8px';
+ sp.style.color = 'white';
+ ae(sp, ct('|'));
+ ae(sm, sp);
+
+ ae(sm, ct(LANG.pr_note_color));
+
+ a = ce('a');
+ a.href = 'javascript:;';
+ a.onclick = this.filterGems.bind(this, a, 1, null);
+ ae(a, ct(LANG.pr_note_all));
+
+ ae(sm, a);
+ ae(sm, ct(LANG.comma));
+
+ a = ce('a');
+ a.href = 'javascript:;';
+ a.onclick = this.filterGems.bind(this, a, 1, 1);
+ ae(a, ct(LANG.pr_note_match));
+
+ this.gemColor = 1;
+ g_setSelectedLink(a, 'gems1');
+
+ ae(sm, a);
+ ae(div, sm);
+ },
+
+ matchGemSocket: function(gemColor, socketColor) {
+ for (var i = 1; i <= 8; i *= 2) {
+ if ((socketColor & i) && (gemColor & i)) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ canBeSocketed: function(slot) {
+ return (slot== 9 || slot == 10 || slot == 6); // Wrists, Hands, and Waist
+ },
+
+ hasExtraSocket: function(item) {
+ return this.enhanceable && (item[this.getExtraSocketPos(item[0])] ? 1 : 0);
+ },
+
+ getExtraSocketPos: function(itemId) {
+ if (!itemId || !g_items[itemId]) {
+ return 4;
+ }
+
+ return 4 + (g_items[itemId].jsonequip.nsockets | 0);
+ },
+
+ hasSocketBonus: function(item) {
+ var nMatches = 0;
+
+ if (!g_items[item[0]] || !g_items[item[0]].jsonequip.nsockets) {
+ return false;
+ }
+
+ for (var j = 0; j < 3; ++j) {
+ if (item[j + 4] && g_gems[item[j + 4]]) {
+ if (this.matchGemSocket(g_gems[item[j + 4]].colors, g_items[item[0]].jsonequip['socket' + (j + 1)])) {
+ ++nMatches;
+ }
+ }
+ }
+
+ return (nMatches == g_items[item[0]].jsonequip.nsockets);
+ },
+
+ isValidGem: function(gem) {
+ if (gem.none) {
+ return true;
+ }
+
+ return (
+ // Source
+ (this.gemSource == null || gem.expansion == this.gemSource) &&
+
+ // Color
+ (
+ ((this.currentItem.color != 1 && gem.colors != 1) && // Always match meta gems and sockets
+ this.gemColor == null) ||
+ this.matchGemSocket(gem.colors, this.currentItem.color)
+ )
+ );
+ },
+
+ filterGems: function(a, wut, value) {
+ switch (wut) {
+ case 0:
+ this.gemSource = value;
+ break;
+ case 1:
+ this.gemColor = value;
+ break;
+ default:
+ return;
+ }
+
+ if (a && a.nodeName == 'A') {
+ g_setSelectedLink(a, 'gems' + wut);
+ }
+
+ g_listviews.gems.updateFilters(true);
+
+ return false;
+ },
+
+ onGemPickerShow: function(dest, first, opt) {
+ Lightbox.setSize(800, 564);
+
+ var lv;
+
+ if (first) {
+ dest.className = 'summary-picker listview';
+
+ var
+ dataz = [],
+ d = ce('div'),
+ a = ce('a'),
+ clear = ce('div');
+
+ dataz.push({ none: 1, __alwaysvisible: 1, _summary: this });
+
+ for (var gemId in g_gems) {
+ var gem = { id: gemId, _summary: this };
+
+ cO(gem, g_gems[gemId]);
+
+ dataz.push(gem);
+ }
+
+ d.className = 'listview';
+ ae(dest, d);
+
+ a = ce('a');
+ a.className = 'screenshotviewer-close';
+ a.href = 'javascript:;';
+ a.onclick = Lightbox.hide;
+ ae(a, ce('span'));
+ ae(dest, a);
+
+ clear.className = 'clear';
+ ae(dest, clear);
+
+ lv = new Listview({
+ template: 'gempicker',
+ id: 'gems',
+ parent: d,
+ data: dataz,
+ createNote: this.createGemPickerNote.bind(this),
+ customFilter: this.isValidGem.bind(this)
+ });
+
+ if (Browser.firefox) {
+ aE(lv.getClipDiv(), 'DOMMouseScroll', g_pickerWheel);
+ }
+ else {
+ lv.getClipDiv().onmousewheel = g_pickerWheel;
+ }
+ }
+ else {
+ lv = g_listviews.gems;
+
+ lv.clearSearch();
+ lv.updateFilters(true);
+ }
+
+ var
+ div = lv.getNoteTopDiv(),
+ sms = gE(div, 'small'),
+ as = gE(div, 'a');
+
+ if (this.currentItem.color == 1 || this.currentItem.color == 14) { // Meta, Prismatic
+ sms[1].style.display = 'none'; // Hide 'Color' filter
+ }
+ else {
+ sms[1].style.display = ''; // Show 'Color' filter
+ }
+
+ this.refreshSort(lv);
+
+ setTimeout(function() {
+ lv.focusSearch();
+ }, 1);
+ },
+
+ onMouseClick: function(a, e) {
+ e = $E(e);
+
+ if (e._button == 3 || e.shiftKey || e.ctrlKey) {
+ return false;
+ }
+ },
+
+ onMouseUp: function(a, e) {
+ e = $E(e);
+ if (e._button == 3 || e.shiftKey || e.ctrlKey) { // Right click
+ var f = Menu.getDiv(0, a.menu);
+
+ var pos = g_getCursorPos(e);
+ setTimeout(Menu.showAtCursor.bind(a, null, pos.x, pos.y), 1); // Timeout needed for the context menu to be disabled
+ // setTimeout(Menu.showAtXY.bind(null, this.menu, pos.x, pos.y), 1); // 5.x
+
+ Tooltip.hide();
+ }
+
+ return false;
+ },
+
+ onSearchKeyUp: function(delay) {
+ var search = trim(this.searchName.value.replace(/\s+/g, ' '));
+
+ if (search == this.currentSearch && isNaN(delay)) {
+ return;
+ }
+ this.currentSearch = search;
+
+ this.prepareSearch(search, delay);
+ },
+
+ onSearchKeyDown: function(e) {
+ e = $E(e);
+
+ switch (e.keyCode) {
+ case 13: // Enter
+ g_listviews.items.submitSearch(e);
+ break;
+/* sarjuuk todo: internal misconception ... hide() and cycle(dir) are members of Livesearch and cant be reused here without further adaptation
+ case 27: // Escape
+ hide();
+ break;
+ case 38: // Up
+ cycle(0);
+ break;
+ case 40: // Down
+ cycle(1);
+ break;
+*/
+ }
+ },
+
+ prepareSearch: function(search, delay) {
+ if (isNaN(delay)) {
+ delay = 1000;
+ }
+
+ if (this.searchTimer > 0) {
+ clearTimeout(this.searchTimer);
+ this.searchTimer = 0;
+ }
+
+ if (search) {
+ st(this.searchMsg, sprintf(LANG['su_searching' + this.searchType], search));
+ }
+ this.searchMsg.className = '';
+
+ this.searchTimer = setTimeout(this.searchItems.bind(this, search, this.searchType), delay);
+ },
+
+ 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 && !this.currentScale) {
+ st(this.searchMsg, LANG['su_specifyitem' + this.searchType]);
+ return;
+ }
+ st(this.searchMsg, sprintf(LANG['su_searching' + this.searchType], search));
+
+ new Ajax('?search=' + urlencode(search) + '&json&type=' + type + pr_getScaleFilter(this.currentScale, 1), {
+ 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 && a[1].length) {
+ 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);
+ }
+ }
+
+ 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);
+ }
+ }
+ 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);
+
+ _this.sortPickerWindow(lv);
+ }
+ });
+ },
+
+ // Item slots to ignore when checking if the column can be viewed in 3D
+ ignoredSlots: {
+ 2: 1, // Neck
+ 11: 1, // Finger
+ 12: 1, // Trinket
+ 18: 1, // Bag
+ 24: 1, // Projectile
+ 28: 1 // Relic
+ },
+
+ viewableIn3d: function(col) {
+ for (var i = 0, len = col.group.length; i < len; ++i) {
+ var d = g_items[col.group[i][0]].jsonequip;
+ if (d.slotbak > 0 && d.displayid > 0 && !this.ignoredSlots[d.slotbak]) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ viewIn3dFromPound: function(pound) {
+ var p = parseInt(pound) | 0;
+ if (p >= 0 && p < this.groups.length) {
+ this.viewIn3d(this.columns[this.clone.i + p]);
+ }
+ },
+
+ viewIn3d: function(col) {
+ var stuff = [];
+
+ for (var i = 0, len = col.group.length; i < len; ++i) {
+ var d = g_items[col.group[i][0]].jsonequip;
+ if (d.slotbak > 0 && d.displayid > 0 && !this.ignoredSlots[d.slotbak]) {
+ stuff.push(d.slotbak);
+ stuff.push(d.displayid);
+ }
+ }
+
+ ModelViewer.show({
+ type: 4,
+ typeId: 9999,
+ equipList: stuff,
+ extraPound: col.i,
+ noPound: (this.autoSave ? 1 : null)
+ });
+ },
+
+ splitColumn: function(col) {
+ this.groups.splice(col.i, 1);
+
+ for (var i = 0, len = col.group.length; i < len; ++i) {
+ this.groups.splice(col.i, 0, [col.group[i]]);
+ }
+
+ this.refreshAll();
+ },
+
+ hasEnhancements: function(group) {
+ for (var i = 0, len = group.length; i < len; ++i) {
+ for (var j = 1; j < 8; ++j) {
+ if (group[i][j] != 0) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ },
+
+ clearEnhancements: function(col, n) {
+ var
+ start = 0,
+ len = col.group.length;
+
+ if (!isNaN(n)) {
+ start = n;
+ len = n + 1;
+ }
+
+ for (var i = start; i < len; ++i) {
+ col.group[i] = this.readItem(col.group[i][0] + '.' + col.group[i][1]);
+ }
+
+ this.refreshAll();
+ },
+
+ readGroups: function(txt) { // Used to read either the 'compare' GET value or the 'compare_groups' cookie.
+ if (!txt) {
+ return;
+ }
+
+ var parts = txt.split(';');
+ for (var i = 0, len = parts.length; i < len; ++i) {
+ var
+ group = [],
+ itemIds = parts[i].split(':');
+
+ for (var j = 0, len2 = itemIds.length; j < len2; ++j) {
+ var item = this.readItem(itemIds[j]);
+
+ if (g_items[item[0]]) {
+ group.push(item);
+ }
+ }
+
+ if (group.length) {
+ this.groups.push(group);
+ }
+ }
+ },
+
+ readItem: function(txt) {
+ txt += ''; // Force string type
+
+ var item = txt.split('.', 8);
+ while (item.length < 8) {
+ item.push(0);
+ }
+
+ for (var i = 0; i < 8; ++i) {
+ item[i] = parseInt(item[i]);
+ }
+
+ return item;
+ },
+
+ writeItem: function(item) {
+ return item[0] ? item.join('.').replace(/(\.0)+$/, "") : '';
+ },
+
+ getItemName: function(item) {
+ if (!g_items[item[0]]) {
+ return;
+ }
+
+ var name = g_items[item[0]].jsonequip.name.substr(1);
+
+ if (g_items[item[0]].jsonequip.subitems && g_items[item[0]].jsonequip.subitems[item[1]]) {
+ name += ' ' + g_items[item[0]].jsonequip.subitems[item[1]].name;
+ }
+
+ return name;
+ },
+
+ getItemRel: function(item, col) {
+ if (!g_items[item[0]]) {
+ return;
+ }
+
+ var
+ extraSocket = this.hasExtraSocket(item),
+ rel = [],
+ gems = [],
+ pcs = [];
+
+ if (item[1]) {
+ rel.push('rand=' + item[1]);
+ }
+
+ if (item[2]) {
+ rel.push('ench=' + item[2]);
+ }
+
+ for (var i = 0, len = (g_items[item[0]].jsonequip.nsockets | 0) + extraSocket; i < len; ++i) {
+ gems.push(item[4 + i] > 0 ? item[4 + i] : 0);
+ }
+
+ if (gems.length) {
+ rel.push('gems=' + gems.join(':'));
+ }
+
+ if (extraSocket) {
+ rel.push('sock');
+ }
+
+ if (g_items[item[0]].jsonequip.itemset) {
+ for (var i = 0, len = col.group.length; i < len; ++i) {
+ var p = col.group[i][0];
+ if (g_items[p] && g_items[p].jsonequip.itemset) {
+ pcs.push(p);
+ }
+ }
+ rel.push('pcs=' + pcs.join(':'));
+ }
+
+ if (this.level < 80)
+ rel.push('lvl=' + this.level);
+
+ var result = rel.join('&');
+
+ if (result) {
+ result = '&' + result;
+ }
+
+ return result;
+ },
+
+ readWeights: function(txt) { // Used to read either the 'weights' GET value or the 'compare_weights' cookie.
+ if (!txt) {
+ return;
+ }
+
+ var
+ parts = txt.split(';'),
+ nScales = parseInt(parts.length / 3); // Name, Ids, Values, Name, Ids, Values, ...
+
+ if (nScales > 0) {
+ for (var i = 0; i < nScales; ++i) {
+ var
+ name = parts[i],
+ ids = parts[i + nScales].split(':'),
+ values = parts[i + nScales * 2].split(':');
+
+ if (ids.length > 0 && ids.length == values.length) {
+ var
+ weight = { name: name },
+ found = false;
+
+ for (var j = 0, len = ids.length; j < len; ++j) {
+ var filter = fi_Lookup(ids[j], 'items');
+ if (filter && filter.type == 'num') {
+
+ weight[filter.name] = parseInt(values[j]);
+ found = true;
+ }
+ }
+
+ if (found) {
+ this.weights.push(weight);
+ }
+ }
+ }
+ }
+ }
+};
+
+Summary.dragGroup = function(e, obj, orig) {
+ obj.style.width = orig.offsetWidth + 'px';
+};
+
+Summary.moveGroup = function(e, obj, targ, cursor) {
+ if (!obj.__col.group.length) {
+ return;
+ }
+
+ var
+ group = [],
+ pos;
+
+ cO(group, this.groups[obj.__col.i]);
+
+ if (!targ) {
+ if (confirm(LANG.message_deletegroup)) {
+ this.deleteColumn(obj.__col, e);
+ }
+
+ return;
+ }
+ else if (cursor && this.newgroup != null && targ.__col.id == this.columns[this.newgroup].id) {
+ pos = this.groups.length - 1;
+ }
+ else if (cursor && targ.__col.id != obj.__col.id) {
+ pos = targ.__col.i;
+ }
+ else {
+ return;
+ }
+
+ if (!e.shiftKey) {
+ if (this.selected != null && this.clone.i + obj.__col.i <= this.selected) {
+ this.selected--;
+ }
+
+ this.groups.splice(obj.__col.i, 1);
+ }
+
+ if (this.__selected.id == obj.__col.id) {
+ this.selected = this.clone.i + pos;
+ }
+ else if (this.selected != null && this.clone.i + pos <= this.selected) {
+ this.selected++;
+ }
+
+ this.groups.splice(pos, 0, group);
+ this.refreshAll();
+};
+
+Summary.moveGroupItem = function(e, obj, targ) {
+ if (!obj.__col.group.length) {
+ return;
+ }
+
+ var item = [];
+ cO(item, obj.__col.group[obj.i]);
+
+ if (!targ || (targ.__col.group && !targ.__col.group.length)) {
+ if (confirm(sprintf(LANG.message_deleteitem, g_items[obj.__col.group[obj.i][0]].jsonequip.name.substring(1)))) {
+ obj.__col.group.splice(obj.i, 1);
+ this.refreshAll();
+ }
+ return;
+ }
+ else if (this.newgroup != null && targ.__col.id == this.columns[this.newgroup].id) {
+ this.groups.push([item]);
+ }
+ else if (targ.__col.id != obj.__col.id) {
+ targ.__col.group.push(item);
+ }
+ else if (e.shiftKey) {
+ obj.__col.group.push(item);
+ }
+ else {
+ return;
+ }
+
+ if (!e.shiftKey) {
+ obj.__col.group.splice(obj.i, 1);
+ }
+ this.refreshAll();
+};
+
+Summary.addGroupItem = function(type, item) {
+ if (type == 3) {
+ this.groups.push([this.readItem(item.id)]);
+ }
+ else if (type == 4) {
+ var _ = [];
+ for (var i in g_items) {
+ if (g_items[i].jsonequip && g_items[i].jsonequip.itemset == item.id) {
+ _.push(this.readItem(i));
+ }
+ }
+ this.groups.push(_);
+ }
+
+ this.refreshAll();
+ Lightbox.hide();
+ if (type == 3 && g_items[item.id].jsonequip.subitems) {
+
+ var lastGroup;
+
+ for (var i = 0, len = this.visibility.length; i < len; ++i) {
+ var reali = this.visibility[i];
+ var col = this.columns[reali];
+ if (col.group && col.group[0][0] == item.id) {
+ lastGroup = col;
+ }
+ }
+
+ if (lastGroup) {
+ this.openSubitemPicker(lastGroup, 0);
+ }
+ }
+
+ return false;
+};
+
+Summary.groupOver = function(group, e) {
+ var
+ buff = '',
+ count = {};
+
+ for (var i = 0, len = group.length; i < len; ++i) {
+ count[group[i][0]] = (count[group[i][0]] | 0) + 1;
+ }
+
+ for (var i = 0, len = group.length; i < len; ++i) {
+ var itemId = group[i][0];
+
+ if (g_items[itemId]) {
+ buff += '';
+ buff += '| x' + count[itemId] + ' | ';
+ buff += '';
+ buff += '' + g_items[itemId]['name_' + g_locale.name] + '';
+ buff += ' | ';
+ buff += '' + LANG.level + ' ' + g_items[itemId].jsonequip.level + ' | ';
+ buff += '
';
+ }
+ }
+
+ if (buff) {
+ Tooltip.showAtCursor(e, '');
+ }
+};
+
+Summary.addWeightScale = function(scale) {
+ scale = this.createWeightScale();
+
+ if (scale) {
+ this.weights.push(scale);
+ }
+
+ this.toggleOptions();
+ this.refreshAll();
+};
+
+Summary.resetScale = function() {
+ var _ = ge('su_classes');
+
+ _.selectedIndex = 0;
+ _.onchange();
+};
+
+Summary.weightOver = function(weight, e) {
+ var
+ buff = '' + weight.name + '',
+ leftTd = '',
+ rightTd = '',
+ i,
+ found = false;
+
+ i = 0;
+ for (var w in weight) {
+ if (LANG.traits[w] == null) {
+ continue;
+ }
+
+ if (i++>0) {
+ leftTd += '
';
+ }
+
+ leftTd += weight[w];
+
+ found = true;
+ }
+
+ if (found) {
+ i = 0;
+ for (var w in weight) {
+ if (LANG.traits[w] == null) {
+ continue;
+ }
+
+ if (i++>0) {
+ rightTd += '
';
+ }
+
+ rightTd += LANG.traits[w][1];
+ }
+ buff += '| ' + leftTd + ' | ' + rightTd + ' |
' + LANG.su_toggle + '';
+ }
+
+ Tooltip.showAtCursor(e, buff);
+};
+
+Summary.socketOver = function(gems, e) {
+ var buff = '';
+
+ for (var i in gems) {
+ if (g_gems[i]) {
+ buff += '';
+ buff += 'x' + gems[i] + ' | ';
+ buff += '';
+ buff += '' + g_gems[i].name + '';
+ buff += ' | ';
+ buff += '' + g_gems[i].enchantment + ' | ';
+ buff += '
';
+ }
+ }
+
+ if (buff) {
+ Tooltip.showAtCursor(e, '');
+ }
+};
+
+Summary.addItemSubitem = function(subitemId) {
+ var
+ col = this.currentItem.col,
+ i = this.currentItem.i;
+
+ col.group[i][1] = subitemId;
+
+ this.refreshAll();
+ Lightbox.hide();
+};
+
+Summary.addItemEnchant = function(enchantId) {
+ var
+ col = this.currentItem.col,
+ i = this.currentItem.i;
+
+ col.group[i][2] = enchantId;
+
+ this.refreshAll();
+ Lightbox.hide();
+};
+
+Summary.addItemGem = function(gemId) {
+ var
+ col = this.currentItem.col,
+ i = this.currentItem.i,
+ s = this.currentItem.socket;
+
+ col.group[i][s] = gemId;
+
+ this.refreshAll();
+ Lightbox.hide();
+};
+
+Summary.toggleExtraSocket = function(col, i, a) {
+ var
+ item = col.group[i],
+ socket = this.getExtraSocketPos(item[0]);
+
+ item[socket] = (this.hasExtraSocket(item) ? 0 : -1);
+
+ this.refreshAll();
+};
+
+Summary.funcBox = {
+ createSockets: function(sockets, td, selected, minSockets, maxSockets, gems) {
+ if (!sockets) {
+ return;
+ }
+
+ var gem_colors = {
+ 1 : 'meta',
+ 2 : 'red',
+ 4 : 'yellow',
+ 8 : 'blue',
+ 14 : 'prismatic'
+ };
+
+ var
+ color,
+ j = 0;
+
+ for (color in gem_colors) {
+ if (sockets[color] != null && sockets[color] != 0) {
+ ++j;
+ }
+ }
+
+ if (j == 0) {
+ return;
+ }
+
+ var div = ce('div');
+ div.style.paddingBottom = '3px';
+ ae(td, div);
+
+ var
+ i = 0,
+ j = 0;
+
+ for (color in gem_colors) {
+ if (sockets[color] != null && sockets[color] != 0) {
+ if (j > 0) {
+ if (j % 2 == 0) {
+ var div = ce('div');
+ div.style.paddingBottom = '3px';
+ ae(td, div);
+ }
+ else {
+ ae(div, ct(String.fromCharCode(160, 160)));
+ }
+ }
+
+ var a = ce('a');
+ a.href = '?items=3&filter=' + (color == 14 ? 'gb=1;cr=81:81:81;crs=2:3:4;crv=0:0:0;ma=1' : 'cr=81;crs=' + (i + 1) + ';crv=0');
+ a.className = 'moneysocket' + gem_colors[color];
+
+ if (gems && gems[color]) {
+ for (var x in gems[color]) {
+ if (g_gems[x]) {
+ a.className += ' tip';
+ a.style.borderBottom = '1px dotted #808080';
+ break;
+ }
+ }
+
+ a.onmouseover = Summary.socketOver.bind(a, gems[color]);
+ a.onmousemove = Tooltip.cursorUpdate;
+ a.onmouseout = Tooltip.hide;
+ }
+
+ if (selected) {
+ a.className += ' ' + (sockets[color] > 0 ? 'q2' : 'q10');
+ if (sockets[color] > 0) {
+ ae(a, ct('+'));
+ }
+ }
+ else if (minSockets && maxSockets && minSockets[color] != maxSockets[color] && sockets[color] == maxSockets[color]) {
+ a.style.fontWeight = 'bold';
+ a.className += ' q2';
+ }
+
+ ae(a, ct(sockets[color]));
+ ae(div, a);
+
+ ++j;
+ }
+
+ ++i;
+ }
+ }
+};
+
+Summary.templates = {
+ compare: {
+ total: 1,
+ clone: 2,
+ newgroup: 3,
+ textable: 1,
+ enhanceable: 1,
+
+ columns: [
+ {
+ id: 'name',
+ align: 'left',
+ compute: function(trait, td, tr, i) {
+ if (!this.__total.total[trait.id]) {
+ tr.style.display = 'none';
+ }
+
+ td.style.whiteSpace = 'nowrap';
+ td.style.paddingLeft = '4px';
+ td.style.paddingRight = '20px';
+
+ var res = (LANG.traits[trait.id] ? LANG.traits[trait.id][0] : trait.name);
+ if (trait.id == 'gains') {
+ var sp = ce('span');
+ sp.className = 'tip';
+ sp.onmouseover = function() {
+ Tooltip.show(this, LANG.tooltip_gains, 0, 0, 'q');
};
- d.onmousemove = Tooltip.cursorUpdate;
- d.onmouseout = Tooltip.hide;
- ae(d, ct(a));
- ae(f, d)
- } else {
- return a
+ sp.onmousemove = Tooltip.cursorUpdate;
+ sp.onmouseout = Tooltip.hide;
+ ae(sp, ct(res));
+ ae(td, sp);
+ }
+ else {
+ return res;
}
}
},
- { id: "total", name: "Total", align: "center", hidden: 1 },
- { align: "center" },
- { id: "newgroup", align: "center", width: "100%" }
+ { id: 'total', name: 'Total', align: 'center', hidden: 1 },
+ { align: 'center' },
+ { id: 'newgroup', align: 'center', width: '100%' }
],
- traits: [
- { id: "sepgeneral", type: "sep" },
+
+ traits: [
+ { id: 'sepgeneral', type: 'sep' },
{
- id: "score",
+ id: 'score',
name: LANG.score,
- type: "custom",
- json: ["id"],
- calcTotal: function (k, g, e) {
+ type: 'custom',
+ json: ['id'],
+ calcTotal: function(item, total, isTotal) {
if (this.scoreMode == null) {
- this.scoreMode = 0
+ this.scoreMode = 0;
}
- for (var b = 0, c = this.weights.length; b < c; ++b) {
- var a = 0,
- d = 0,
- h = this.weights[b];
- for (var j in h) {
- if (!LANG.traits[j]) {
- continue
+
+ for (var i = 0, len = this.weights.length; i < len; ++i) {
+ var
+ score = 0,
+ f = 0,
+
+ weights = this.weights[i];
+
+ for (var w in weights) {
+ if (!LANG.traits[w]) {
+ continue;
}
- d += h[j];
- if (!isNaN(k[j])) {
- a += k[j] * h[j]
+
+ f += weights[w];
+ if (!isNaN(item[w])) {
+ score += item[w] * weights[w];
}
}
- g[b] = (g[b] | 0) + a;
- this.weights[b].f = d;
- if (!e && (this.weights[b].m == null || g[b] > this.weights[b].m)) {
- this.weights[b].m = g[b]
+ total[i] = (total[i] | 0) + score;
+ this.weights[i].f = f;
+
+ if (!isTotal && (this.weights[i].m == null || total[i] > this.weights[i].m)) {
+ this.weights[i].m = total[i];
}
}
},
- calcDifference: function (e, d) {
- var g = {};
- for (var f = 0, c = this.weights.length; f < c; ++f) {
- g[f] = e[f] - d[f]
+ calcDifference: function(a, b) {
+ var diff = {};
+ for (var i = 0, len = this.weights.length; i < len; ++i) {
+ diff[i] = a[i] - b[i];
}
- return g
+
+ return diff;
},
- compute: function (c, h) {
- if (!c.total || !c.difference) {
- return
+ compute: function(col, td) {
+ if (!col.total || !col.difference) {
+ return;
}
- var e = 0,
- o = (this.selected != null && this.__selected.id != c.id);
- h.style.whiteSpace = "nowrap";
- h.style.padding = "4px";
- for (var j = 0, k = this.weights.length; j < k; ++j) {
- var f = this.weights[j];
- var g = (o ? c.difference.score[j] : c.total.score[j]),
- b = f.name;
- if (g != null) {
- if (!f.name) {
- f.name = sprintf(LANG.su_customscale, ++e)
+
+ var n = 0,
+ _ = (this.selected != null && this.__selected.id != col.id);
+
+ td.style.whiteSpace = 'nowrap';
+ td.style.padding = '4px';
+
+ for (var i = 0, len = this.weights.length; i < len; ++i) {
+ var weight = this.weights[i];
+ var
+ score = (_ ? col.difference.score[i] : col.total.score[i]),
+ name = weight.name;
+
+ if (score != null) {
+ if (!weight.name) {
+ weight.name = sprintf(LANG.su_customscale, ++n);
}
+
switch (this.scoreMode) {
case 0:
- g = (f.f != 0 ? g / f.f: 0).toFixed(2);
+ score = (weight.f != 0 ? score / weight.f : 0).toFixed(2);
break;
case 2:
- g = (f.m ? 100 * g / f.m: 0).toFixed(1) + "%";
- break
+ score = (weight.m ? 100 * score / weight.m : 0).toFixed(1) + '%';
+ break;
}
- var m = ce("a");
- m.className = "summary-score-remove";
- m.href = "javascript:;";
- m.onclick = this.deleteWeightScale.bind(this, j);
- ae(m, ct("x"));
- ae(h, m);
- var l = ce("div");
- l.className = "summary-score-row" + (j % 2);
- ae(h, l);
- var m = ce("a");
- m.className = (o ? (g > 0 ? "q2": "q10") : "q1");
- m.style.borderBottom = "1px dotted #808080";
- m.href = "javascript:;";
- m.onclick = this.toggleWeights.bind(this);
- m.onmouseover = Summary.weightOver.bind(m, f);
- m.onmousemove = Tooltip.cursorUpdate;
- m.onmouseout = Tooltip.hide;
- ae(m, ct(g));
- ae(l, m)
+
+ var a = ce('a');
+ a.className = 'summary-score-remove';
+ a.href = 'javascript:;';
+ a.onclick = this.deleteWeightScale.bind(this, i);
+ ae(a, ct('x'));
+ ae(td, a);
+
+ var d = ce('div');
+ d.className = 'summary-score-row' + (i % 2);
+ ae(td, d);
+
+ var a = ce('a');
+ a.className = (_ ? (score > 0 ? 'q2' : 'q10') : 'q1');
+ a.style.borderBottom = '1px dotted #808080';
+ a.href = 'javascript:;';
+ a.onclick = this.toggleWeights.bind(this);
+ a.onmouseover = Summary.weightOver.bind(a, weight);
+ a.onmousemove = Tooltip.cursorUpdate;
+ a.onmouseout = Tooltip.hide;
+ ae(a, ct(score));
+ ae(d, a);
}
}
}
},
- { id: "sepgeneral", type: "sep" },
- { id: "level", type: "avg", digits: 1, itemonly: 1 },
- { id: "reqlevel", type: "max" },
+ { id: 'sepgeneral', type: 'sep' },
+ { id: 'level', type: 'avg', digits: 1, itemonly: 1 },
+ { id: 'reqlevel', type: 'max' },
- { id: "sepbasestats", type: "sep" },
- { id: "agi", type: "sum" },
- { id: "int", type: "sum" },
- { id: "sta", type: "sum" },
- { id: "spi", type: "sum" },
- { id: "str", type: "sum" },
- { id: "health", type: "sum" },
- { id: "mana", type: "sum" },
- { id: "healthrgn", type: "sum" },
- { id: "manargn", type: "sum" },
+ { id: 'sepbasestats', type: 'sep' },
+ { id: 'agi', type: 'sum' },
+ { id: 'int', type: 'sum' },
+ { id: 'sta', type: 'sum' },
+ { id: 'spi', type: 'sum' },
+ { id: 'str', type: 'sum' },
+ { id: 'health', type: 'sum' },
+ { id: 'mana', type: 'sum' },
+ { id: 'healthrgn', type: 'sum' },
+ { id: 'manargn', type: 'sum' },
- { id: "sepdefensivestats", type: "sep" },
- { id: "armor", type: "sum" },
- { id: "blockrtng", type: "sum", rating: 15 },
- { id: "block", type: "sum" },
- { id: "defrtng", type: "sum", rating: 12 },
- { id: "dodgertng", type: "sum", rating: 13 },
- { id: "parryrtng", type: "sum", rating: 14 },
- { id: "resirtng", type: "sum", rating: 35 },
+ { id: 'sepdefensivestats', type: 'sep' },
+ { id: 'armor', type: 'sum' },
+ { id: 'blockrtng', type: 'sum', rating: 15 },
+ { id: 'block', type: 'sum' },
+ { id: 'defrtng', type: 'sum', rating: 12 },
+ { id: 'dodgertng', type: 'sum', rating: 13 },
+ { id: 'parryrtng', type: 'sum', rating: 14 },
+ { id: 'resirtng', type: 'sum', rating: 35 },
- { id: "sepoffensivestats", type: "sep" },
- { id: "atkpwr", type: "sum" },
- { id: "feratkpwr", type: "sum", indent: 1 },
- { id: "armorpenrtng", type: "sum", rating: 44 },
- { id: "critstrkrtng", type: "sum", rating: 32 },
- { id: "exprtng", type: "sum", rating: 37 },
- { id: "hastertng", type: "sum", rating: 36 },
- { id: "hitrtng", type: "sum", rating: 31 },
- { id: "splpen", type: "sum" },
- { id: "splpwr", type: "sum" },
- { id: "arcsplpwr", type: "sum", indent: 1 },
- { id: "firsplpwr", type: "sum", indent: 1 },
- { id: "frosplpwr", type: "sum", indent: 1 },
- { id: "holsplpwr", type: "sum", indent: 1 },
- { id: "natsplpwr", type: "sum", indent: 1 },
- { id: "shasplpwr", type: "sum", indent: 1 },
+ { id: 'sepoffensivestats', type: 'sep' },
+ { id: 'atkpwr', type: 'sum' },
+ { id: 'feratkpwr', type: 'sum', indent: 1 },
+ { id: 'armorpenrtng', type: 'sum', rating: 44 },
+ { id: 'critstrkrtng', type: 'sum', rating: 32 },
+ { id: 'exprtng', type: 'sum', rating: 37 },
+ { id: 'hastertng', type: 'sum', rating: 36 },
+ { id: 'hitrtng', type: 'sum', rating: 31 },
+ { id: 'splpen', type: 'sum' },
+ { id: 'splpwr', type: 'sum' },
+ { id: 'arcsplpwr', type: 'sum', indent: 1 },
+ { id: 'firsplpwr', type: 'sum', indent: 1 },
+ { id: 'frosplpwr', type: 'sum', indent: 1 },
+ { id: 'holsplpwr', type: 'sum', indent: 1 },
+ { id: 'natsplpwr', type: 'sum', indent: 1 },
+ { id: 'shasplpwr', type: 'sum', indent: 1 },
- { id: "sepweaponstats", type: "sep" },
- { id: "dmg", type: "sum" },
- { id: "mledps", type: "sum" },
- { id: "rgddps", type: "sum" },
- { id: "mledmgmin", type: "sum" },
- { id: "rgddmgmin", type: "sum" },
- { id: "mledmgmax", type: "sum" },
- { id: "rgddmgmax", type: "sum" },
- { id: "mlespeed", type: "sum" },
- { id: "rgdspeed", type: "sum" },
+ { id: 'sepweaponstats', type: 'sep' },
- { id: "sepresistances", type: "sep" },
- { id: "arcres", type: "sum" },
- { id: "firres", type: "sum" },
- { id: "frores", type: "sum" },
- { id: "holres", type: "sum" },
- { id: "natres", type: "sum" },
- { id: "shares", type: "sum" },
+ { id: 'dmg', type: 'sum' },
+ { id: 'mledps', type: 'sum' },
+ { id: 'rgddps', type: 'sum' },
- { id: "sepindividualstats", type: "sep" },
- { id: "mleatkpwr", type: "sum" },
- { id: "mlecritstrkrtng", type: "sum", rating: 19 },
- { id: "mlehastertng", type: "sum", rating: 28 },
- { id: "mlehitrtng", type: "sum", rating: 16 },
- { id: "rgdatkpwr", type: "sum" },
- { id: "rgdcritstrkrtng", type: "sum", rating: 20 },
- { id: "rgdhastertng", type: "sum", rating: 29 },
- { id: "rgdhitrtng", type: "sum", rating: 17 },
- { id: "splcritstrkrtng", type: "sum", rating: 21 },
- { id: "splhastertng", type: "sum", rating: 30 },
- { id: "splhitrtng", type: "sum", rating: 18 },
- { id: "spldmg", type: "sum" },
- { id: "splheal", type: "sum" },
+ { id: 'mledmgmin', type: 'sum' },
+ { id: 'rgddmgmin', type: 'sum' },
- { id: "", name: LANG.sockets, type: "sep" },
+ { id: 'mledmgmax', type: 'sum' },
+ { id: 'rgddmgmax', type: 'sum' },
+
+ { id: 'mlespeed', type: 'avg' },
+ { id: 'rgdspeed', type: 'avg' },
+
+ { id: 'sepresistances', type: 'sep' },
+ { id: 'arcres', type: 'sum' },
+ { id: 'firres', type: 'sum' },
+ { id: 'frores', type: 'sum' },
+ { id: 'holres', type: 'sum' },
+ { id: 'natres', type: 'sum' },
+ { id: 'shares', type: 'sum' },
+
+ { id: 'sepindividualstats', type: 'sep' },
+ { id: 'mleatkpwr', type: 'sum' },
+ { id: 'mlecritstrkrtng', type: 'sum', rating: 19 },
+ { id: 'mlehastertng', type: 'sum', rating: 28 },
+ { id: 'mlehitrtng', type: 'sum', rating: 16 },
+ { id: 'rgdatkpwr', type: 'sum' },
+ { id: 'rgdcritstrkrtng', type: 'sum', rating: 20 },
+ { id: 'rgdhastertng', type: 'sum', rating: 29 },
+ { id: 'rgdhitrtng', type: 'sum', rating: 17 },
+ { id: 'splcritstrkrtng', type: 'sum', rating: 21 },
+ { id: 'splhastertng', type: 'sum', rating: 30 },
+ { id: 'splhitrtng', type: 'sum', rating: 18 },
+ { id: 'spldmg', type: 'sum' },
+ { id: 'splheal', type: 'sum' },
+
+ { id: '', name: LANG.sockets, type: 'sep' },
{
- id: "gems",
+ id: 'gems',
name: LANG.gems,
- type: "custom",
- json: ["id"],
+ type: 'custom',
+ json: ['id'],
itemonly: 1,
- calcTotal: function (e, d, f, a, b) {
- for (var c = 1; c <= 8; c *= 2) {
- if (d[c] == null) {
- d[c] = {}
+ calcTotal: function(item, total, isTotal, equipInfo, extraSocket) {
+ for (var i = 1; i <= 8; i *= 2) {
+ if (total[i] == null) {
+ total[i] = {};
}
}
- if (d[14] == null) {
- d[14] = {}
+
+ if (total[14] == null) {
+ total[14] = {};
}
- for (var c = 1; c < 4; ++c) {
- if ((s = e["socket" + c]) && a[c + 3]) {
- d[s][a[c + 3]] = (d[s][a[c + 3]] | 0) + 1
+
+ for (var i = 1; i < 4; ++i) {
+ if ((s = item['socket' + i]) && equipInfo[i + 3]) {
+ total[s][equipInfo[i + 3]] = (total[s][equipInfo[i + 3]] | 0) + 1;
}
}
- c = (e.nsockets | 0) + 4;
- if (b && a[c]) {
- d[14][a[c]] = (d[14][c] | 0) + 1
+
+ i = (item.nsockets | 0) + 4;
+ if (extraSocket && equipInfo[i]) {
+ total[14][equipInfo[i]] = (total[14][i] | 0) + 1;
}
},
hidden: 1
},
{
- id: "sockets",
+ id: 'sockets',
name: LANG.sockets,
- type: "custom",
- json: ["socket1"],
- calcTotal: function (e, d, f, a, b) {
- for (var c = 1; c <= 8; c *= 2) {
- d[c] = (d[c] | 0)
+ type: 'custom',
+ json: ['socket1'],
+ calcTotal: function(item, total, isTotal, equipInfo, extraSocket) {
+ for (var i = 1; i <= 8; i *= 2) {
+ total[i] = (total[i] | 0);
}
- d[14] = (d[14] | 0);
- for (var c = 1; c < 4; ++c) {
- if (s = e["socket" + c]) {
- d[s]++
+
+ total[14] = (total[14] | 0);
+
+ for (var i = 1; i < 4; ++i) {
+ if (s = item['socket' + i]) {
+ total[s]++;
}
}
- if (b) {
- d[14]++
+
+ if (extraSocket) {
+ total[14]++;
}
},
- calcDifference: function (d, c) {
- var f = {};
- for (var e = 1; e <= 8; e *= 2) {
- if (d[e] != null || c[e] != null) {
- f[e] = (d[e] | 0) - (c[e] | 0)
+ calcDifference: function(a, b) {
+ var diff = {};
+ for (var i = 1; i <= 8; i *= 2) {
+ if (a[i] != null || b[i] != null) {
+ diff[i] = (a[i] | 0) - (b[i] | 0);
}
}
- return f
+ return diff;
},
- compute: function (b, d) {
- var a = (this.selected != null && this.__selected.id != b.id);
- var c = a ? b.difference: b.total;
- if (!c) {
- return
+ compute: function(col, td) {
+ var _ = (this.selected != null && this.__selected.id != col.id);
+ var total = _ ? col.difference : col.total;
+
+ if (!total) {
+ return;
}
+
if (this.groups.length > 1) {
- Summary.funcBox.createSockets(c.sockets, d, a, this.minValue.sockets, this.maxValue.sockets, c.gems)
- } else {
- Summary.funcBox.createSockets(c.sockets, d, a, null, null, c.gems)
+ Summary.funcBox.createSockets(total.sockets, td, _, this.minValue['sockets'], this.maxValue['sockets'], total.gems);
+ }
+ else {
+ Summary.funcBox.createSockets(total.sockets, td, _, null, null, total.gems);
}
}
},
- { id: "nsockets", type: "sum" },
- { id: "", type: "sep" },
+ { id: 'nsockets', type: 'sum' },
+ { id: '', type: 'sep' },
{
- id: "gains",
+ id: 'gains',
name: LANG.gains,
- type: "custom",
- json: ["id"],
- compute: function (b, g) {
- if (b.id == this.columns[this.total].id || !b.total) {
- return
+ type: 'custom',
+ json: ['id'],
+ compute: function(col, td) {
+ if (col.id == this.columns[this.total].id || !col.total) {
+ return;
}
- g.style.whiteSpace = "nowrap";
- g.style.textAlign = "left";
- var d = 0;
- for (var c in this.minValue) {
- if (b.total[c] > this.minValue[c]) {
- if (d++>0) {
- ae(g, ce("br"))
+
+ td.style.whiteSpace = 'nowrap';
+ td.style.textAlign = 'left';
+
+ var i = 0;
+ for (var trait in this.minValue) {
+ if (col.total[trait] > this.minValue[trait]) {
+ if (i++ > 0) {
+ ae(td, ce('br'));
}
- var f = (Math.round(1000 * (b.total[c] - this.minValue[c])) / 1000);
- ae(g, ct(f + " " + LANG.traits[c][1]));
- if (this.ratings[c] != null) {
- var a = g_convertRatingToPercent(this.level, this.ratings[c], f);
- a = number_format((Math.round(a * 100) / 100));
- if (this.ratings[c] != 12 && this.ratings[c] != 37) {
- a += "%"
+
+ var value = (Math.round(1000 * (col.total[trait] - this.minValue[trait])) / 1000);
+
+ ae(td, ct(value + ' ' + LANG.traits[trait][1]));
+
+ if (this.ratings[trait] != null) {
+ var percent = g_convertRatingToPercent(this.level, this.ratings[trait], value);
+
+ percent = number_format((Math.round(percent * 100) / 100));
+
+ if (this.ratings[trait] != 12 && this.ratings[trait] != 37) { // Neither Defense, nor Expertise
+ percent += '%';
}
- var e = ce("small");
- ae(e, ct(" (" + a + ")"));
- ae(g, e)
+
+ var s = ce('small');
+ ae(s, ct(' (' + percent + ')'));
+ ae(td, s);
}
}
}
}
}
]
- },
- itemset: {
- total: 1,
- clone: 2,
- editable: 0,
- columns: [{
- id: "name",
- align: "left",
- compute: function (b, d, c, a) {
- if (!this.__total.total[b.id]) {
- c.style.display = "none"
- }
- return (LANG.traits[b.id] ? LANG.traits[b.id][0] : b.name)
- }
- },
- { id: "total", name: "Total", align: "center" },
- { align: "center" }],
- traits: [
- { id: "str", type: "sum" },
- { id: "agi", type: "sum" },
- { id: "sta", type: "sum" },
- { id: "int", type: "sum" },
- { id: "spi", type: "sum" },
- { id: "health", type: "sum" },
- { id: "mana", type: "sum" },
- { id: "healthrgn", type: "sum" },
- { id: "manargn", type: "sum" },
- { id: "armor", type: "sum" },
- { id: "block", type: "sum" },
- { id: "defrtng", type: "sum", rating: 12 },
- { id: "dodgertng", type: "sum", rating: 13 },
- { id: "parryrtng", type: "sum", rating: 14 },
- { id: "resirtng", type: "sum", rating: 35 },
- { id: "blockrtng", type: "sum", rating: 15 },
- { id: "atkpwr", type: "sum" },
- { id: "feratkpwr", type: "sum" },
- { id: "armorpenrtng", type: "sum", rating: 44 },
- { id: "critstrkrtng", type: "sum", rating: 32 },
- { id: "exprtng", type: "sum", rating: 37 },
- { id: "hastertng", type: "sum", rating: 36 },
- { id: "hitrtng", type: "sum", rating: 31 },
- { id: "splpen", type: "sum" },
- { id: "splpwr", type: "sum" },
- { id: "arcsplpwr", type: "sum" },
- { id: "firsplpwr", type: "sum" },
- { id: "frosplpwr", type: "sum" },
- { id: "holsplpwr", type: "sum" },
- { id: "natsplpwr", type: "sum" },
- { id: "shasplpwr", type: "sum" },
- { id: "dps", type: "sum" },
- { id: "dmg", type: "sum" },
- { id: "arcres", type: "sum" },
- { id: "firres", type: "sum" },
- { id: "frores", type: "sum" },
- { id: "holres", type: "sum" },
- { id: "natres", type: "sum" },
- { id: "shares", type: "sum" },
- { id: "mleatkpwr", type: "sum" },
- { id: "mlecritstrkrtng", type: "sum", rating: 19 },
- { id: "mlehastertng", type: "sum", rating: 28 },
- { id: "mlehitrtng", type: "sum", rating: 16 },
- { id: "rgdatkpwr", type: "sum" },
- { id: "rgdcritstrkrtng", type: "sum", rating: 20 },
- { id: "rgdhastertng", type: "sum", rating: 29 },
- { id: "rgdhitrtng", type: "sum", rating: 17 },
- { id: "splcritstrkrtng", type: "sum", rating: 21 },
- { id: "splhastertng", type: "sum", rating: 30 },
- { id: "splhitrtng", type: "sum", rating: 18 },
- { id: "spldmg", type: "sum" },
- { id: "splheal", type: "sum" },
- { id: "sockets",
+ },
+
+ itemset: {
+ total: 1,
+ clone: 2,
+ editable: 0,
+
+ columns: [
+ {
+ id: 'name',
+ align: 'left',
+ compute: function(trait, td, tr, i) {
+ if (!this.__total.total[trait.id]) {
+ tr.style.display = 'none';
+ }
+
+ return (LANG.traits[trait.id] ? LANG.traits[trait.id][0] : trait.name);
+ }
+ },
+ { id: 'total', name: 'Total', align: 'center' },
+ { align: 'center' }
+ ],
+
+ traits: [
+ { id: 'str', type: 'sum' },
+ { id: 'agi', type: 'sum' },
+ { id: 'sta', type: 'sum' },
+ { id: 'int', type: 'sum' },
+ { id: 'spi', type: 'sum' },
+ { id: 'health', type: 'sum' },
+ { id: 'mana', type: 'sum' },
+ { id: 'healthrgn', type: 'sum' },
+ { id: 'manargn', type: 'sum' },
+
+ { id: 'armor', type: 'sum' },
+ { id: 'block', type: 'sum' },
+ { id: 'defrtng', type: 'sum', rating: 12 },
+ { id: 'dodgertng', type: 'sum', rating: 13 },
+ { id: 'parryrtng', type: 'sum', rating: 14 },
+ { id: 'resirtng', type: 'sum', rating: 35 },
+ { id: 'blockrtng', type: 'sum', rating: 15 },
+ { id: 'atkpwr', type: 'sum' },
+ { id: 'feratkpwr', type: 'sum' },
+ { id: 'armorpenrtng', type: 'sum', rating: 44 },
+ { id: 'critstrkrtng', type: 'sum', rating: 32 },
+ { id: 'exprtng', type: 'sum', rating: 37 },
+ { id: 'hastertng', type: 'sum', rating: 36 },
+ { id: 'hitrtng', type: 'sum', rating: 31 },
+ { id: 'splpen', type: 'sum' },
+ { id: 'splpwr', type: 'sum' },
+ { id: 'arcsplpwr', type: 'sum' },
+ { id: 'firsplpwr', type: 'sum' },
+ { id: 'frosplpwr', type: 'sum' },
+ { id: 'holsplpwr', type: 'sum' },
+ { id: 'natsplpwr', type: 'sum' },
+ { id: 'shasplpwr', type: 'sum' },
+
+ { id: 'dps', type: 'sum' },
+ { id: 'dmg', type: 'sum' },
+
+ { id: 'arcres', type: 'sum' },
+ { id: 'firres', type: 'sum' },
+ { id: 'frores', type: 'sum' },
+ { id: 'holres', type: 'sum' },
+ { id: 'natres', type: 'sum' },
+ { id: 'shares', type: 'sum' },
+
+ { id: 'mleatkpwr', type: 'sum' },
+ { id: 'mlecritstrkrtng', type: 'sum', rating: 19 },
+ { id: 'mlehastertng', type: 'sum', rating: 28 },
+ { id: 'mlehitrtng', type: 'sum', rating: 16 },
+ { id: 'rgdatkpwr', type: 'sum' },
+ { id: 'rgdcritstrkrtng', type: 'sum', rating: 20 },
+ { id: 'rgdhastertng', type: 'sum', rating: 29 },
+ { id: 'rgdhitrtng', type: 'sum', rating: 17 },
+ { id: 'splcritstrkrtng', type: 'sum', rating: 21 },
+ { id: 'splhastertng', type: 'sum', rating: 30 },
+ { id: 'splhitrtng', type: 'sum', rating: 18 },
+ { id: 'spldmg', type: 'sum' },
+ { id: 'splheal', type: 'sum' },
+
+ {
+ id: 'sockets',
name: LANG.sockets,
- type: "custom",
- json: ["socket1"],
- calcTotal: function (c, b) {
- for (var a = 1; a <= 8; a *= 2) {
- b[a] = (b[a] | 0)
+ type: 'custom',
+ json: ['socket1'],
+ calcTotal: function(item, total) {
+ for (var i = 1; i <= 8; i *= 2) {
+ total[i] = (total[i] | 0);
}
- for (var a = 1; a < 4; ++a) {
- if (s = c["socket" + a]) {
- b[s]++
+
+ for (var i = 1; i < 4; ++i) {
+ if (s = item['socket' + i]) {
+ total[s]++;
}
}
},
- calcDifference: function (d, c) {
- var f = {};
- for (var e = 1; e <= 8; e *= 2) {
- if (d[e] != null || c[e] != null) {
- f[e] = (d[e] | 0) - (c[e] | 0)
+ calcDifference: function(a, b) {
+ var diff = {};
+ for (var i = 1; i <= 8; i *= 2) {
+ if (a[i] != null || b[i] != null) {
+ diff[i] = (a[i] | 0) - (b[i] | 0);
}
}
- return f
+ return diff;
},
- compute: function (b, d) {
- var a = (this.selected != null && this.__selected.id != b.id);
- var c = a ? b.difference: b.total;
- if (!c) {
- return
+ compute: function(col, td) {
+ var _ = (this.selected != null && this.__selected.id != col.id);
+ var total = _ ? col.difference : col.total;
+
+ if (!total) {
+ return;
}
+
if (this.groups.length > 1) {
- Summary.funcBox.createSockets(c.sockets, d, a, this.minValue.sockets, this.maxValue.sockets)
- } else {
- Summary.funcBox.createSockets(c.sockets, d, a)
+ Summary.funcBox.createSockets(total.sockets, td, _, this.minValue['sockets'], this.maxValue['sockets']);
+ }
+ else {
+ Summary.funcBox.createSockets(total.sockets, td, _);
}
}
}
]
- }
+ }
};
+
Listview.templates.compare = {
- sort: [1],
- nItemsPerPage: -1,
- hideBands: 2,
- hideNav: 1 | 2,
- hideHeader: 1,
- searchable: 1,
- searchDelay: 100,
- poundable: 0,
- filtrable: 0,
- clip: {
- w: 780,
- h: 486
- },
- onBeforeCreate: function () {
- this.applySort()
- },
- onSearchSubmit: function (a) {
- if (this.nRowsVisible != 1) {
- return
- } (Summary.addGroupItem.bind(a._summary, a._type, a.id))()
- },
- columns: [{
- id: "item",
- type: "text",
- align: "left",
- value: "name",
- compute: function (f, h, g) {
- if (f.none) {
- g.style.display = "none";
- return
- }
- var b = ce("a");
- b.className = "q" + f.quality;
- b.style.fontFamily = "Verdana, sans-serif";
- b.onclick = rf;
- switch (f._type) {
- case 3:
- if (!Browser.ie67) {
- this.template.columns[0].span = 2;
- var c = ce("td");
- c.style.width = "1px";
- c.style.padding = "0";
- c.style.borderRight = "none";
- var d = Icon.create(f.icon, 0, null, "?item=" + f.id),
- e = Icon.getLink(d);
- ae(c, d);
- ae(g, c);
- h.style.borderLeft = "none";
- e.onclick = rf;
- b.href = "?item=" + f.id
+ sort: [1],
+ nItemsPerPage: -1,
+ hideBands: 2,
+ hideNav: 1 | 2,
+ hideHeader: 1,
+ searchable: 1,
+ searchDelay: 100,
+ poundable: 0,
+ filtrable: 0,
+ clip: {
+ w: 780,
+ h: 486
+ },
+
+ onBeforeCreate: function() {
+ this.applySort();
+ },
+
+ onSearchSubmit: function(item) {
+ if (this.nRowsVisible != 1) {
+ return;
+ }
+
+ (Summary.addGroupItem.bind(item._summary, item._type, item))();
+ },
+
+ columns: [
+ {
+ id: 'item',
+ type: 'text',
+ align: 'left',
+ value: 'name',
+ compute: function(item, td, tr) {
+ if (item.none) {
+ tr.style.display = 'none';
+ return;
+ }
+
+ var a = ce('a');
+ a.className = 'q' + item.quality;
+ a.style.fontFamily = 'Verdana, sans-serif';
+
+ switch (item._type) {
+ case 3:
+ this.template.columns[0].span = 2;
+
+ var i = ce('td');
+ i.style.width = '1px';
+ i.style.padding = '0';
+ i.style.borderRight = 'none';
+
+ var
+ icon = Icon.create(item.icon, 0, null, '?item=' + item.id),
+ link = Icon.getLink(icon);
+
+ ae(i, icon);
+ ae(tr, i);
+ td.style.borderLeft = 'none';
+
+ link.onclick = rf;
+
+ a.href = '?item=' + item.id;
+ break;
+ case 4:
+ a.href = '?itemset=' + item.id;
+ break;
+ }
+
+ ae(a, ct(item.name));
+
+ nw(td);
+ ae(td, a);
+
+ tr.onclick = function(e) {
+ e = $E(e);
+ if (e._button != 2 || e._target != a) {
+ e.preventDefault();
+ (Summary.addGroupItem.bind(item._summary, item._type, item))();
+ }
+ };
+ },
+ sortFunc: function(a, b, col) {
+ if (a.none) {
+ return -1;
+ }
+ if (b.none) {
+ return 1;
+ }
+
+ return (
+ -strcmp(a.level | a.minlevel, b.level | b.minlevel) ||
+ -strcmp(a.quality, b.quality) ||
+ strcmp(a.name, b.name)
+ );
+ }
+ },
+ {
+ id: 'level',
+ name: LANG.level,
+ type: 'range',
+ getMinValue: function(item) {
+ return item.minlevel | item.level;
+ },
+ getMaxValue: function(item) {
+ return item.maxlevel | item.level;
+ },
+ compute: function(item, td, tr) {
+ if (item.none) {
+ return;
+ }
+
+ switch (item._type) {
+ case 3:
+ return item.level;
+ break;
+ case 4:
+ if (item.minlevel > 0 && item.maxlevel > 0) {
+ if (item.minlevel != item.maxlevel) {
+ return item.minlevel + LANG.hyphen + item.maxlevel;
+ }
+ else {
+ return item.minlevel;
+ }
+ }
+ else {
+ return -1;
+ }
+ break;
+ }
+ },
+ sortFunc: function(a, b, col) {
+ if (a.none) {
+ return -1;
+ }
+ if (b.none) {
+ return 1;
+ }
+
+ return (
+ -strcmp(a.score, b.score) ||
+ strcmp(a.name, b.name)
+ );
+ }
+ },
+ {
+ id: 'pieces',
+ name: LANG.pieces,
+ getValue: function(item) {
+ return item.pieces ? item.pieces.length : null;
+ },
+ compute: function(item, td) {
+ if (item.pieces) {
+ td.style.padding = '0';
+ Listview.funcBox.createCenteredIcons(item.pieces, td);
+ }
+ else {
+ td.style.display = 'none';
+ }
+ }
+ },
+ {
+ id: 'type',
+ name: LANG.type,
+ type: 'text',
+ compute: function(item, td, tr) {
+ td.className = 'small q1';
+ nw(td);
+ var a = ce('a');
+
+ switch (item._type) {
+ case 3:
+ var it = Listview.funcBox.getItemType(item.classs, item.subclass, item.subsubclass);
+ a.href = it.url;
+ ae(a, ct(it.text));
+ break;
+ case 4:
+ ae(a, ct(g_itemset_types[item.type]));
+ break;
+ }
+
+ ae(td, a);
+ },
+ getVisibleText: function(item) {
+ return Listview.funcBox.getItemType(item.classs, item.subclass, item.subsubclass).text;
+ }
+ },
+ {
+ id: 'score',
+ align: 'center',
+ compute: function(item, td, tr) {
+ if (item.score != null) {
+ var
+ n = parseFloat(item.score),
+ s = ce('div');
+
+ s.className = 'small q' + (n ? (n > 0 ? 2 : 10) : 0);
+ st(s, (n ? (n > 0 ? '+' : '-') + item.score : 0));
+ ae(td, s);
}
- break;
- case 4:
- b.href = "?itemset=" + f.id;
- break
- }
- ae(b, ct(f.name));
- nw(h);
- ae(h, b);
- g.onclick = Summary.addGroupItem.bind(f._summary, f._type, f.id)
- },
- sortFunc: function (d, c, e) {
- if (d.none) {
- return -1
- }
- if (c.none) {
- return 1
- }
- return ( -strcmp(d.quality, c.quality) || strcmp(d.name, c.name) || -strcmp(d.level, c.level))
- }
- },
- {
- id: "level",
- name: LANG.level,
- type: "range",
- getMinValue: function (a) {
- return a.minlevel | a.level
- },
- getMaxValue: function (a) {
- return a.maxlevel | a.level
- },
- compute: function (a, c, b) {
- if (a.none) {
- return
- }
- switch (a._type) {
- case 3:
- return a.level;
- break;
- case 4:
- if (a.minlevel > 0 && a.maxlevel > 0) {
- if (a.minlevel != a.maxlevel) {
- return a.minlevel + LANG.hyphen + a.maxlevel
- } else {
- return a.minlevel
- }
- } else {
- return -1
- }
- break
+ else {
+ td.style.display = 'none';
+ }
}
}
- },
- {
- id: "pieces",
- name: LANG.pieces,
- getValue: function (a) {
- return a.pieces ? a.pieces.length: null
- },
- compute: function (a, b) {
- b.style.padding = "0";
- Listview.funcBox.createCenteredIcons(a.pieces, b)
- }
- },
- {
- id: "type",
- name: LANG.type,
- type: "text",
- compute: function (d, f, e) {
- f.className = "small q1";
- nw(f);
- var b = ce("a");
- switch (d._type) {
- case 3:
- var c = Listview.funcBox.getItemType(d.classs, d.subclass, d.subsubclass);
- b.href = c.url;
- ae(b, ct(c.text));
- break;
- case 4:
- ae(b, ct(g_itemset_types[d.type]));
- break
- }
- ae(f, b)
- },
- getVisibleText: function (a) {
- return Listview.funcBox.getItemType(a.classs, a.subclass, a.subsubclass).text
- }
- }]
+ ]
};
+
Listview.templates.subitempicker = {
- sort: [1],
- nItemsPerPage: -1,
- hideBands: 2,
- hideNav: 1 | 2,
- hideHeader: 1,
- searchable: 1,
- searchDelay: 100,
- poundable: 0,
- filtrable: 0,
- clip: {
- w: 780,
- h: 486
- },
- onBeforeCreate: function () {
- this.applySort();
- if (!Browser.ie67) {
- this.template.columns[0].span = 2
- }
- },
- onSearchSubmit: function (a) {
- if (this.nRowsVisible != 2 || !a.id) {
- return
- } (Summary.addItemSubitem.bind(a._summary, a.id))()
- },
- columns: [{
- id: "subitem",
- type: "text",
- align: "left",
- value: "name",
- compute: function (j, c, e) {
- if (j.none) {
- return
- }
- var b = "?item=" + j.item,
- k = g_items[j.item];
- if (!Browser.ie67) {
- var d = ce("td");
- d.style.width = "1px";
- d.style.padding = "0";
- d.style.borderRight = "none";
- var f = Icon.create(k.icon, 0, null, b),
- g = Icon.getLink(f);
- ae(d, f);
- ae(e, d);
- c.style.borderLeft = "none";
- g.onclick = rf;
- g.rel = "rand=" + j.id
- }
- var h = ce("a");
- if (j.quality != -1) {
- h.className = "q" + k.quality
- }
- h.style.fontFamily = "Verdana, sans-serif";
- h.onclick = rf;
- h.href = b;
- h.rel = "rand=" + j.id;
- ae(h, ct(k["name_" + g_locale.name] + " " + j.name));
- nw(c);
- ae(c, h);
- e.onclick = Summary.addItemSubitem.bind(j._summary, j.id)
- }
- },
- {
- id: "enchantment",
- type: "text",
- align: "left",
- value: "enchantment",
- compute: function (a, e, b) {
- if (a.none) {
- return
- }
- var c = ce("div");
- c.className = "small crop";
- e.title = a.enchantment;
- ae(c, ct(a.enchantment));
- ae(e, c)
- }
- }]
+ sort: [1],
+ nItemsPerPage: -1,
+ hideBands: 2,
+ hideNav: 1 | 2,
+ hideHeader: 1,
+ searchable: 1,
+ searchDelay: 100,
+ poundable: 0,
+ filtrable: 0,
+ clip: {
+ w: 780,
+ h: 486
+ },
+
+ onBeforeCreate: function() {
+ this.applySort();
+ },
+
+ onSearchSubmit: function(subitem) {
+ if (this.nRowsVisible != 2 || !subitem.id) { // None
+ return;
+ }
+
+ (Summary.addItemSubitem.bind(subitem._summary, subitem.id))();
+ },
+
+ columns: [
+ {
+ id: 'subitem',
+ type: 'text',
+ align: 'left',
+ value: 'name',
+ compute: function(subitem, td, tr) {
+ if (subitem.none) {
+ return;
+ }
+
+ var
+ url = '?item=' + subitem.item,
+ item = g_items[subitem.item];
+
+ var i = ce('td');
+ i.style.width = '1px';
+ i.style.padding = '0';
+ i.style.borderRight = 'none';
+
+ var
+ icon = Icon.create(item.icon, 0, null, url),
+ link = Icon.getLink(icon);
+
+ ae(i, icon);
+ ae(tr, i);
+ td.style.borderLeft = 'none';
+
+ link.onclick = rf;
+ link.rel = 'rand=' + subitem.id;
+
+ var a = ce('a');
+
+ if (subitem.quality != -1) {
+ a.className = 'q' + item.quality;
+ }
+
+ a.style.fontFamily = 'Verdana, sans-serif';
+ a.href = url;
+ a.rel = 'rand=' + subitem.id;
+
+ ae(a, ct(item['name_' + g_locale.name] + ' ' + subitem.name));
+
+ nw(td);
+ ae(td, a);
+
+ tr.onclick = function(e) {
+ e = $E(e);
+ if (e._button != 2 || e._target != a) {
+ e.preventDefault();
+ (Summary.addItemSubitem.bind(subitem._summary, subitem.id))();
+ }
+ };
+ }
+ },
+ {
+ id: 'enchantment',
+ type: 'text',
+ align: 'left',
+ value: 'enchantment',
+ compute: function(subitem, td, tr) {
+ if (subitem.none) {
+ return;
+ }
+
+ var d = ce('div');
+ d.className = 'small crop';
+ td.title = subitem.enchantment;
+ ae(d, ct(subitem.enchantment));
+ ae(td, d);
+ },
+ sortFunc: function(a, b, col) {
+ if (a.none) {
+ return -1;
+ }
+ if (b.none) {
+ return 1;
+ }
+
+ return (
+ -strcmp(a.score, b.score) ||
+ strcmp(a.name, b.name)
+ );
+ }
+ },
+ {
+ id: 'score',
+ align: 'center',
+ compute: function(subitem, td, tr) {
+ if (subitem.none) {
+ return;
+ }
+
+ if (subitem.score != null) {
+ var
+ n = parseFloat(subitem.score),
+ s = ce('div');
+
+ s.className = 'small q' + (n ? (n > 0 ? 2 : 10) : 0);
+ st(s, (n ? (n > 0 ? '+' : '-') + subitem.score : 0));
+ ae(td, s);
+ }
+ }
+ }
+ ]
};
+
Listview.templates.enchantpicker = {
- sort: [1],
- nItemsPerPage: -1,
- hideBands: 2,
- hideNav: 1 | 2,
- hideHeader: 1,
- searchable: 1,
- searchDelay: 100,
- poundable: 0,
- filtrable: 0,
- clip: {
- w: 780,
- h: 486
- },
- onBeforeCreate: function () {
- this.applySort();
- if (!Browser.ie67) {
- this.template.columns[0].span = 2
- }
- },
- onSearchSubmit: function (a, b) {
- if (this.nRowsVisible != 2 || !a.id) {
- return
- } (Summary.addItemEnchant.bind(a._summary, a.id))()
- },
- columns: [{
- id: "enchant",
- type: "text",
- align: "left",
- value: "name",
- compute: function (h, j, g) {
- if (h.none) {
- return
- }
- var c = (h.source > 0 ? "?spell=": "?item=") + Math.abs(h.source);
- if (!Browser.ie67) {
- var d = ce("td");
- d.style.width = "1px";
- d.style.padding = "0";
- d.style.borderRight = "none";
- var e = Icon.create(h.icon, 0, null, c),
- f = Icon.getLink(e);
- ae(d, e);
- ae(g, d);
- j.style.borderLeft = "none";
- f.onclick = rf
- }
- var b = ce("a");
- if (h.quality != -1) {
- b.className = "q" + h.quality
- }
- b.style.fontFamily = "Verdana, sans-serif";
- b.onclick = rf;
- b.href = c;
- ae(b, ct(h.name));
- nw(j);
- ae(j, b);
- g.onclick = Summary.addItemEnchant.bind(h._summary, h.id)
- },
- sortFunc: function (d, c, e) {
- if (d.none) {
- return -1
- }
- if (c.none) {
- return 1
- }
- return ( -strcmp(d.quality, c.quality) || strcmp(d.type, c.type) || strcmp(d.name, c.name))
- }
- },
- {
- id: "enchantment",
- type: "text",
- align: "left",
- value: "enchantment",
- compute: function (b, e, a) {
- if (b.none) {
- return
- }
- var c = ce("div");
- c.className = "small crop";
- e.title = b.enchantment;
- ae(c, ct(b.enchantment));
- ae(e, c)
- }
- },
- {
- id: "skill",
- type: "text",
- compute: function (b, c, a) {
- if (b.none) {
- ee(a);
- a.onclick = Summary.addItemEnchant.bind(b._summary, 0);
- c.colSpan = (Browser.ie67 ? 3 : 4);
- c.style.fontWeight = "bold";
- c.style.textAlign = "center";
- return LANG.dash + LANG.pr_noneenchant + LANG.dash
- }
- c.className = "small q0";
- nw(c);
- if (b.skill > 0) {
- return g_spell_skills[b.skill]
- } else {
- return LANG.types[3][0]
- }
- },
- getVisibleText: function (a) {
- if (a.none) {
- return
- }
- if (a.skill > 0) {
- return g_spell_skills[a.skill]
- } else {
- return LANG.types[3][0]
- }
- }
- }]
+ sort: [1],
+ nItemsPerPage: -1,
+ hideBands: 2,
+ hideNav: 1 | 2,
+ hideHeader: 1,
+ searchable: 1,
+ searchDelay: 100,
+ poundable: 0,
+ filtrable: 0,
+ clip: {
+ w: 780,
+ h: 486
+ },
+
+ onBeforeCreate: function() {
+ this.applySort();
+ },
+
+ onSearchSubmit: function(enchant, n) {
+ if (this.nRowsVisible != 2 || !enchant.id) { // None
+ return;
+ }
+
+ (Summary.addItemEnchant.bind(enchant._summary, enchant.id))();
+ },
+
+ columns: [
+ {
+ id: 'enchant',
+ type: 'text',
+ align: 'left',
+ value: 'name',
+ span: 2,
+ compute: function(enchant, td, tr) {
+ if (enchant.none) {
+ return;
+ }
+
+ var url = (enchant.source > 0 ? '?spell=' : '?item=') + Math.abs(enchant.source);
+
+ var i = ce('td');
+ i.style.width = '1px';
+ i.style.padding = '0';
+ i.style.borderRight = 'none';
+
+ var
+ icon = Icon.create(enchant.icon, 0, null, url),
+ link = Icon.getLink(icon);
+
+ ae(i, icon);
+ ae(tr, i);
+ td.style.borderLeft = 'none';
+
+ link.onclick = rf;
+
+ var a = ce('a');
+
+ if (enchant.quality != -1) {
+ a.className = 'q' + enchant.quality;
+ }
+
+ a.style.fontFamily = 'Verdana, sans-serif';
+ a.href = url;
+
+ ae(a, ct(enchant.name));
+
+ nw(td);
+ ae(td, a);
+
+ tr.onclick = function(e) {
+ e = $E(e);
+ if (e._button != 2 || e._target != a) {
+ e.preventDefault();
+ (Summary.addItemEnchant.bind(enchant._summary, enchant.id))();
+ }
+ };
+ },
+ sortFunc: function(a, b, col) {
+ if (a.none) {
+ return -1;
+ }
+ if (b.none) {
+ return 1;
+ }
+
+ return (
+ -strcmp(a.quality, b.quality) ||
+ strcmp(a.type, b.type) ||
+ strcmp(a.name, b.name)
+ );
+ }
+ },
+ {
+ id: 'enchantment',
+ type: 'text',
+ align: 'left',
+ value: 'enchantment',
+ compute: function(enchant, td, tr) {
+ if (enchant.none) {
+ return;
+ }
+
+ var d = ce('div');
+ d.className = 'small crop';
+ td.title = enchant.enchantment;
+ ae(d, ct(enchant.enchantment));
+ ae(td, d);
+ },
+ sortFunc: function(a, b, col) {
+ if (a.none) {
+ return -1;
+ }
+ if (b.none) {
+ return 1;
+ }
+
+ return (
+ -strcmp(a.score, b.score) ||
+ strcmp(a.name, b.name)
+ );
+ }
+ },
+ {
+ id: 'skill',
+ type: 'text',
+ compute: function(enchant, td, tr) {
+ if (enchant.none) {
+ return;
+ }
+
+ td.className = 'small q0';
+ nw(td);
+
+ if (enchant.skill > 0) {
+ return g_spell_skills[enchant.skill];
+ }
+ else {
+ return LANG.types[3][0];
+ }
+ },
+ getVisibleText: function(enchant) {
+ if (enchant.none) {
+ return;
+ }
+
+ if (enchant.skill > 0) {
+ return g_spell_skills[enchant.skill];
+ }
+ else {
+ return LANG.types[3][0];
+ }
+ }
+ },
+ {
+ id: 'score',
+ align: 'center',
+ compute: function(enchant, td, tr) {
+ if (enchant.none) {
+ ee(tr);
+
+ tr.onclick = Summary.addItemEnchant.bind(enchant._summary, 0);
+ td.colSpan = 5;
+ td.style.fontWeight = 'bold';
+ td.style.textAlign = 'center';
+ return LANG.dash + LANG.pr_noneenchant + LANG.dash;
+ }
+
+ if (enchant.score != null) {
+ var
+ n = parseFloat(enchant.score),
+ s = ce('div');
+
+ s.className = 'small q' + (n ? (n > 0 ? 2 : 10) : 0);
+ st(s, (n ? (n > 0 ? '+' : '-') + enchant.score : 0));
+ ae(td, s);
+ }
+ }
+ }
+ ]
};
+
Listview.templates.gempicker = {
- sort: [1],
- nItemsPerPage: -1,
- hideBands: 2,
- hideNav: 1 | 2,
- hideHeader: 1,
- searchable: 1,
- searchDelay: 100,
- poundable: 0,
- filtrable: 0,
- clip: {
- w: 780,
- h: 486
- },
- onBeforeCreate: function () {
- this.applySort();
- if (!Browser.ie67) {
- this.template.columns[0].span = 2
- }
- },
- onSearchSubmit: function (a) {
- if (this.nRowsVisible != 2 || !a.id) {
- return
- } (Summary.addItemGem.bind(a._summary, a.id))()
- },
- sexyColors: {
- 1 : "#9D9D9D",
- 2 : "#e60c0b",
- 4 : "#ffff35",
- 6 : "#f48905",
- 8 : "#295df1",
- 10 : "#b957fc",
- 12 : "#22c516",
- 14 : "#FFFFFF"
- },
- columns: [{
- id: "gem",
- type: "text",
- align: "left",
- value: "name",
- compute: function (h, g, f) {
- if (h.none) {
- return
- }
- if (!Browser.ie67) {
- var c = ce("td");
- c.style.width = "1px";
- c.style.padding = "0";
- c.style.borderRight = "none";
- var d = Icon.create(h.icon, 0, null, "?item=" + h.id),
- e = Icon.getLink(d);
- ae(c, d);
- ae(f, c);
- g.style.borderLeft = "none";
- e.onclick = rf
- }
- var b = ce("a");
- b.className = "q" + h.quality;
- b.style.fontFamily = "Verdana, sans-serif";
- b.onclick = rf;
- b.href = "?item=" + h.id;
- ae(b, ct(h.name));
- nw(g);
- ae(g, b);
- f.onclick = Summary.addItemGem.bind(h._summary, h.id)
- },
- sortFunc: function (d, c, e) {
- if (d.none) {
- return -1
- }
- if (c.none) {
- return 1
- }
- return ( -strcmp(d.gearscore, c.gearscore) || -strcmp(d.quality, c.quality) || strcmp(d.colors, c.colors) || strcmp(d.icon, c.icon) || strcmp(d.name, c.name))
- }
- },
- {
- id: "enchantment",
- type: "text",
- align: "left",
- value: "enchantment",
- compute: function (e, c, a) {
- if (e.none) {
- return
- }
- var b = ce("div");
- b.className = "small crop";
- c.title = e.enchantment;
- ae(b, ct(e.enchantment));
- ae(c, b)
- }
- },
- {
- id: "colors",
- compute: function (c, b, a) {
- if (c.none) {
- ee(a);
- a.onclick = Summary.addItemGem.bind(c._summary, 0);
- b.colSpan = (Browser.ie67 ? 3 : 4);
- b.style.fontWeight = "bold";
- b.style.textAlign = "center";
- return LANG.dash + LANG.pr_nonegem + LANG.dash
- }
- b.className = "small";
- nw(b);
- b.style.color = this.template.sexyColors[c.colors];
- return g_gem_colors[c.colors]
- },
- getVisibleText: function (a) {
- if (a.none) {
- return
- }
- return g_gem_colors[a.colors]
- }
- }]
-};
\ No newline at end of file
+ sort: [1],
+ nItemsPerPage: -1,
+ hideBands: 2,
+ hideNav: 1 | 2,
+ hideHeader: 1,
+ searchable: 1,
+ searchDelay: 100,
+ poundable: 0,
+ filtrable: 0,
+ clip: {
+ w: 780,
+ h: 486
+ },
+
+ onBeforeCreate: function() {
+ this.applySort();
+ },
+
+ onSearchSubmit: function(gem) {
+ if (this.nRowsVisible != 2 || !gem.id) { // None
+ return;
+ }
+
+ (Summary.addItemGem.bind(gem._summary, gem.id))();
+ },
+
+ columns: [
+ {
+ id: 'gem',
+ type: 'text',
+ align: 'left',
+ value: 'name',
+ span: 2,
+ compute: function(gem, td, tr) {
+ if (gem.none) {
+ return;
+ }
+
+ var i = ce('td');
+ i.style.width = '1px';
+ i.style.padding = '0';
+ i.style.borderRight = 'none';
+
+ var
+ icon = Icon.create(gem.icon, 0, null, '?item=' + gem.id),
+ link = Icon.getLink(icon);
+
+ ae(i, icon);
+ ae(tr, i);
+ td.style.borderLeft = 'none';
+
+ link.onclick = rf;
+
+ var a = ce('a');
+ a.className = 'q' + gem.quality;
+ a.style.fontFamily = 'Verdana, sans-serif';
+ a.href = '?item=' + gem.id;
+
+ ae(a, ct(gem.name));
+
+ nw(td);
+ ae(td, a);
+
+ tr.onclick = function(e) {
+ e = $E(e);
+ if (e._button != 2 || e._target != a) {
+ e.preventDefault();
+ (Summary.addItemGem.bind(gem._summary, gem.id))();
+ }
+ };
+ },
+ sortFunc: function(a, b, col) {
+ if (a.none) {
+ return -1;
+ }
+ if (b.none) {
+ return 1;
+ }
+
+ return (
+ -strcmp(a.quality, b.quality) ||
+ strcmp(a.colors, b.colors) ||
+ strcmp(a.icon, b.icon) ||
+ strcmp(a.name, b.name)
+ );
+ }
+ },
+ {
+ id: 'enchantment',
+ type: 'text',
+ align: 'left',
+ value: 'enchantment',
+ compute: function(gem, td, tr) {
+ if (gem.none) {
+ return;
+ }
+
+ var d = ce('div');
+ d.className = 'small crop';
+ td.title = gem.enchantment;
+ ae(d, ct(gem.enchantment));
+ ae(td, d);
+ },
+ sortFunc: function(a, b, col) {
+ if (a.none) {
+ return -1;
+ }
+ if (b.none) {
+ return 1;
+ }
+
+ return (
+ -strcmp(a.score, b.score) ||
+ strcmp(a.name, b.name)
+ );
+ }
+ },
+ {
+ id: 'colors',
+ compute: function(gem, td, tr) {
+ if (gem.none) {
+ return;
+ }
+
+ td.className = 'small gem' + gem.colors;
+ nw(td);
+
+ return g_gem_colors[gem.colors];
+ },
+ getVisibleText: function(gem) {
+ if (gem.none) {
+ return;
+ }
+
+ return g_gem_colors[gem.colors];
+ }
+ },
+ {
+ id: 'score',
+ align: 'center',
+ compute: function(gem, td, tr) {
+ if (gem.none) {
+ ee(tr);
+
+ tr.onclick = Summary.addItemGem.bind(gem._summary, 0);
+ td.colSpan = 5;
+ td.style.fontWeight = 'bold';
+ td.style.textAlign = 'center';
+
+ return LANG.dash + LANG.pr_nonegem + LANG.dash;
+ }
+
+ if (gem.score != null) {
+ var
+ n = parseFloat(gem.score),
+ s = ce('div');
+
+ s.className = 'small q' + (n ? (n > 0 ? 2 : 10) : 0);
+ st(s, (n ? (n > 0 ? '+' : '-') + gem.score : 0));
+ ae(td, s);
+ }
+ }
+ }
+ ]
+};
+
+/* sarjuuk: bandaid .. belongs to profile.js */
+function pr_getScaleFilter(scale, noFilter) {
+ var temp = [];
+
+ if (scale) {
+ for (var i = 0, len = fi_filters.items.length; i < len; ++i) {
+ var f = fi_filters.items[i];
+
+ if (LANG.traits[f.name] && scale[f.name]) {
+ temp.push([f.id, scale[f.name]]);
+ }
+ }
+ }
+
+ temp.sort(function(a, b) {
+ return -strcmp(a[1], b[1]);
+ });
+
+ var wt = [], wtv = [];
+ for (var i = 0, len = temp.length; i < len; ++i) {
+ wt.push(temp[i][0]);
+ wtv.push(temp[i][1]);
+ }
+
+ if (wt.length && wtv.length) {
+ return (noFilter ? '&' : ';gm=3;rf=1;') + 'wt=' + wt.join(':') + (noFilter ? '&' : ';') + 'wtv=' + wtv.join(':');
+ }
+
+ return '';
+}
+
diff --git a/template/js/TalentCalc.js b/template/js/TalentCalc.js
index 535a0331..133447c9 100644
--- a/template/js/TalentCalc.js
+++ b/template/js/TalentCalc.js
@@ -1,43 +1,41 @@
var $WowheadTalentCalculator;
function TalentCalc() {
- var
- MODE_DEFAULT = 0,
- MODE_PET = 1,
+ var
+ MODE_DEFAULT = 0,
+ MODE_PET = 1,
- MIN_LEVEL = 10,
- MAX_LEVEL = 80,
+ MIN_LEVEL = 10,
+ MAX_LEVEL = 80,
- _versionBuild = 85,
- _self = this,
+ _versionBuild = 85,
+ _self = this,
_opt,
- _data = {},
- _glyphLookup = {},
+ _data = {},
+ _glyphLookup = {},
+ _talentLookup = {},
_build,
_firstBuild,
_firstGlyphs,
_glyphs,
- _currentClass = -1,
- _oldClass = -1,
- _nClassChanges = 0,
+ _currentClass = -1,
+ _oldClass = -1,
+ _nClassChanges = 0,
_currentGlyphSlot,
- _filteredGlyphs = false,
- _locked = false,
+ _filteredGlyphs = false,
+ _locked = false,
_mode,
_nTrees,
_nTiers,
_nGlyphs,
_glyphSlots,
- _glyphOrder = [1,2],
- _glyphLevels = {
- 1: [], // Major
- 2: [] // Minor
- },
+ _glyphOrder = [1, 2],
+ _glyphLevels = { 1: [], 2: [] }, // Major, Minor
_pointsPerTier,
_basePoints,
- _bonusPoints = 0,
+ _bonusPoints = 0,
_pointsFromBonus,
- _maxLevel = MAX_LEVEL,
+ _maxLevel = MAX_LEVEL,
_pointsToSpend,
_referenceArray,
@@ -49,8 +47,8 @@ function TalentCalc() {
_lnkExport,
_lnkRestore,
_glyphDiv,
- _glyphIcons = {},
- _glyphLinks = {},
+ _glyphIcons = {},
+ _glyphLinks = {},
_divWrapper,
_divUpper,
_lblClass,
@@ -66,12 +64,12 @@ function TalentCalc() {
swfModel,
- _encoding = '0zMcmVokRsaqbdrfwihuGINALpTjnyxtgevElBCDFHJKOPQSUWXYZ123456789',
- _blizzEncoding = 'aZbYcXdWeVfUgThSiRjQkPlOmNnMoLpKqJrIsHtGuFvEwDxCyBzA0123456789_=+-.',
- _newTree = 'Z',
+ _encoding = '0zMcmVokRsaqbdrfwihuGINALpTjnyxtgevElBCDFHJKOPQSUWXYZ123456789',
+ _blizzEncoding = 'aZbYcXdWeVfUgThSiRjQkPlOmNnMoLpKqJrIsHtGuFvEwDxCyBzA0123456789_=+-.',
+ _newTree = 'Z',
_onChangeCallback,
- _info = {};
+ _info = {};
// *************************************************************
// *************************************************************
@@ -83,91 +81,91 @@ function TalentCalc() {
return _data[_currentClass];
};
- this.addGlyph = function (itemId) {
- if (itemId) {
- _addGlyph(_currentGlyphSlot, itemId);
- }
+ this.addGlyph = function (itemId) {
+ if (itemId) {
+ _addGlyph(_currentGlyphSlot, itemId);
+ }
else {
- _removeGlyph(_currentGlyphSlot);
- }
+ _removeGlyph(_currentGlyphSlot);
+ }
- Lightbox.hide()
- };
+ Lightbox.hide()
+ };
- this.getBlizzBuild = function () {
- if (_currentClass == -1) {
- return;
- }
+ this.getBlizzBuild = function () {
+ if (_currentClass == -1) {
+ return;
+ }
- var
+ var
c = _data[_currentClass],
blizz = '';
- for (var tree = 0; tree < _nTrees; ++tree) {
- for (var i = 0; i < c[tree].t.length; ++i) {
- blizz += c[tree].t[i].k;
- }
- }
+ for (var tree = 0; tree < _nTrees; ++tree) {
+ for (var i = 0; i < c[tree].t.length; ++i) {
+ blizz += c[tree].t[i].k;
+ }
+ }
- blizz = rtrim(blizz, '0');
+ blizz = rtrim(blizz, '0');
- return blizz;
- };
+ return blizz;
+ };
- this.getBlizzGlyphs = function () {
- if (_currentClass == -1) {
- return;
- }
+ this.getBlizzGlyphs = function () {
+ if (_currentClass == -1) {
+ return;
+ }
- var
+ var
c = _data[_currentClass],
blizz = '';
- for (var slot = 0; slot < _nGlyphs; ++slot) {
- if (slot > 0) {
- blizz += ':';
- }
+ for (var slot = 0; slot < _nGlyphs; ++slot) {
+ if (slot > 0) {
+ blizz += ':';
+ }
- if (c.glyphs[slot]) {
- blizz += c.glyphs[slot];
- }
+ if (c.glyphs[slot]) {
+ blizz += c.glyphs[slot];
+ }
else {
- blizz += '0';
- }
- }
+ blizz += '0';
+ }
+ }
- return blizz;
- };
+ return blizz;
+ };
- this.getGlyphs = function () {
- var res = [];
+ this.getGlyphs = function () {
+ var res = [];
- if (_currentClass != -1) {
- var c = _data[_currentClass];
+ if (_currentClass != -1) {
+ var c = _data[_currentClass];
- if (c) {
- for (var slot = 0; slot < _nGlyphs; ++slot) {
- if (c.glyphs[slot]) {
- res.push(g_glyphs[c.glyphs[slot]]);
- }
- }
- }
- }
+ if (c) {
+ for (var slot = 0; slot < _nGlyphs; ++slot) {
+ if (c.glyphs[slot]) {
+ res.push(g_glyphs[c.glyphs[slot]]);
+ }
+ }
+ }
+ }
- return res;
- };
+ return res;
+ };
- this.getSpentFromBlizzBuild = function (build, classId) {
- var
+ this.getSpentFromBlizzBuild = function (build, classId) {
+ var
c = _data[classId],
spent = [];
- for (var i = 0; i < _nTrees; ++i) {
+ for (var i = 0; i < _nTrees; ++i) {
spent.push(0);
- }
+ }
- if (c) {
- var
+ if (c) {
+ var
tree = 0,
talent = 0;
@@ -177,45 +175,45 @@ function TalentCalc() {
}
for (var i = 0; i < build.length; ++i) {
- var n = Math.min(parseInt(build.charAt(i)), c[tree].t[talent].m);
- if (isNaN(n)) {
- continue;
- }
+ var n = Math.min(parseInt(build.charAt(i)), c[tree].t[talent].m);
+ if (isNaN(n)) {
+ continue;
+ }
- for (var k = 0; k < n; ++k) {
+ for (var k = 0; k < n; ++k) {
++spent[tree];
- }
+ }
- if (++talent > c[tree].t.length - 1) {
- talent = 0;
- if (++tree > _nTrees - 1) {
- break;
- }
- }
- }
- }
+ if (++talent > c[tree].t.length - 1) {
+ talent = 0;
+ if (++tree > _nTrees - 1) {
+ break;
+ }
+ }
+ }
+ }
- return spent;
- };
+ return spent;
+ };
- this.getTalents = function () {
- var res = [];
+ this.getTalents = function () {
+ var res = [];
- if (_currentClass != -1) {
- var c = _data[_currentClass];
- if (c) {
- for (var tree = 0; tree < _nTrees; ++tree) {
- for (i = 0; i < c[tree].t.length; ++i) {
- if (c[tree].t[i].k) {
- res.push(c[tree].t[i]);
- }
- }
- }
- }
- }
+ if (_currentClass != -1) {
+ var c = _data[_currentClass];
+ if (c) {
+ for (var tree = 0; tree < _nTrees; ++tree) {
+ for (i = 0; i < c[tree].t.length; ++i) {
+ if (c[tree].t[i].k) {
+ res.push(c[tree].t[i]);
+ }
+ }
+ }
+ }
+ }
- return res;
- };
+ return res;
+ };
this.getTalentRanks = function(talentId) {
if (_currentClass == -1) {
@@ -229,70 +227,70 @@ function TalentCalc() {
return 0;
};
- this.getWhBuild = function () {
- if (_currentClass == -1) {
- return;
- }
+ this.getWhBuild = function () {
+ if (_currentClass == -1) {
+ return;
+ }
- var
+ var
c = _data[_currentClass],
wh = '',
blizz,
i;
- for (var tree = 0; tree < _nTrees; ++tree) {
- blizz = '';
- for (i = 0; i < c[tree].t.length; ++i) {
- blizz += c[tree].t[i].k;
- }
+ for (var tree = 0; tree < _nTrees; ++tree) {
+ blizz = '';
+ for (i = 0; i < c[tree].t.length; ++i) {
+ blizz += c[tree].t[i].k;
+ }
- blizz = rtrim(blizz, '0');
+ blizz = rtrim(blizz, '0');
- wh += _convertBlizzToWh(blizz);
+ wh += _convertBlizzToWh(blizz);
- i = blizz.length;
- if (i % 2 == 1) {
+ i = blizz.length;
+ if (i % 2 == 1) {
++i;
- }
+ }
- if (i < c[tree].t.length) {
- wh += _newTree;
- }
- }
+ if (i < c[tree].t.length) {
+ wh += _newTree;
+ }
+ }
- var res;
+ var res;
- if (_mode == MODE_PET) {
- res = _encoding.charAt(Math.floor(_currentClass / 10)) + _encoding.charAt((2 * (_currentClass % 10)) + (_bonusPoints ? 1 : 0));
- }
+ if (_mode == MODE_PET) {
+ res = _encoding.charAt(Math.floor(_currentClass / 10)) + _encoding.charAt((2 * (_currentClass % 10)) + (_bonusPoints ? 1 : 0));
+ }
else {
- res = _encoding.charAt(_getOldIdFromClassId(_currentClass) * 3);
- }
+ res = _encoding.charAt(_getOldIdFromClassId(_currentClass) * 3);
+ }
- res += rtrim(wh, _newTree);
+ res += rtrim(wh, _newTree);
- return res;
- };
+ return res;
+ };
- this.getWhGlyphs = function () {
- if (_currentClass == -1) {
- return;
- }
+ this.getWhGlyphs = function () {
+ if (_currentClass == -1) {
+ return;
+ }
- var
+ var
c = _data[_currentClass],
glyphs = {};
- for (var slot = 0; slot < _nGlyphs; ++slot) {
+ for (var slot = 0; slot < _nGlyphs; ++slot) {
var glyphType = _getGlyphTypeFromSlot(slot);
if (glyphs[glyphType] == null) {
glyphs[glyphType] = '';
}
- if (c.glyphs[slot]) {
- glyphs[glyphType] += _encoding.charAt(g_glyphs[c.glyphs[slot]].index);
- }
- }
+ if (c.glyphs[slot]) {
+ glyphs[glyphType] += _encoding.charAt(g_glyphs[c.glyphs[slot]].index);
+ }
+ }
var res = '', encodeLen = 0;
for (var i = 0, len = _glyphOrder.length; i < len; ++i) {
@@ -311,77 +309,77 @@ function TalentCalc() {
res = rtrim(res, _newTree);
return res;
- };
+ };
- this.initialize = function (container, opt) {
- if (_container) {
- return;
- }
+ this.initialize = function (container, opt) {
+ if (_container) {
+ return;
+ }
- container = $(container);
- if (!container) {
- return;
- }
+ container = $(container);
+ if (!container) {
+ return;
+ }
- _container = container;
- _container.className = "talentcalc";
- if (opt == null) {
- opt = {};
- }
+ _container = container;
+ _container.className = "talentcalc";
+ if (opt == null) {
+ opt = {};
+ }
- _opt = opt;
+ _opt = opt;
- if (_opt.onChange) {
- _onChangeCallback = _opt.onChange;
- }
+ if (_opt.onChange) {
+ _onChangeCallback = _opt.onChange;
+ }
- if (_opt.mode == MODE_PET) {
- _mode = MODE_PET;
- _nTrees = 1;
- _nTiers = 6;
- _pointsPerTier = 3;
- _basePoints = 16;
+ if (_opt.mode == MODE_PET) {
+ _mode = MODE_PET;
+ _nTrees = 1;
+ _nTiers = 6;
+ _pointsPerTier = 3;
+ _basePoints = 16;
_pointsFromBonus = 4
- _referenceArray = g_pet_families;
+ _referenceArray = g_pet_families;
- _container.className += " talentcalc-pet";
+ _container.className += " talentcalc-pet";
_setGlyphSlots(0);
- }
+ }
else {
- _mode = MODE_DEFAULT;
- _nTrees = 3;
- _nTiers = 11;
- _glyphLevels = {
- 1 : [15, 30, 80], // Major
- 2 : [15, 50, 70] // Minor
- };
- _pointsPerTier = 5;
- _basePoints = 71;
+ _mode = MODE_DEFAULT;
+ _nTrees = 3;
+ _nTiers = 11;
+ _glyphLevels = {
+ 1 : [15, 30, 80], // Major
+ 2 : [15, 50, 70] // Minor
+ };
+ _pointsPerTier = 5;
+ _basePoints = 71;
_pointsFromBonus = 0;
- _referenceArray = g_chr_classes;
+ _referenceArray = g_chr_classes;
- _container.className += " talentcalc-default";
+ _container.className += " talentcalc-default";
- $WowheadTalentCalculator = _self;
+ $WowheadTalentCalculator = _self;
_setGlyphSlots(MAX_LEVEL);
- _initGlyphData();
- }
+ _initGlyphData();
+ }
- _pointsToSpend = _basePoints + _bonusPoints;
+ _pointsToSpend = _basePoints + _bonusPoints;
_divWrapper = ce('div');
_divWrapper.className = 'talentcalc-wrapper';
ae(_container, _divWrapper);
- _createSidebar();
- _createUpper();
- _createMain();
- _createModel();
- _createLower();
+ _createSidebar();
+ _createUpper();
+ _createMain();
+ _createModel();
+ _createLower();
/*
- _createSidebar();
+ _createSidebar();
_createUpper();
_createTreeNames();
_createMasteries();
@@ -390,9 +388,9 @@ function TalentCalc() {
_createLower();
*/
- if (_opt.whBuild) {
- _setWhBuild(_opt.whBuild);
- }
+ if (_opt.whBuild) {
+ _setWhBuild(_opt.whBuild);
+ }
else if (_opt.classId > 0 && _referenceArray[_opt.classId]) {
if (_opt.blizzBuild) {
_setBlizzBuild(_opt.classId, _opt.blizzBuild);
@@ -400,71 +398,71 @@ function TalentCalc() {
else {
_setClass(_opt.classId);
}
- }
+ }
- if (_opt.whGlyphs) {
- _setWhGlyphs(_opt.whGlyphs);
- }
+ if (_opt.whGlyphs) {
+ _setWhGlyphs(_opt.whGlyphs);
+ }
else if (_opt.blizzGlyphs) {
_setBlizzGlyphs(_opt.blizzGlyphs);
- }
- };
+ }
+ };
- this.promptBlizzBuild = function () {
- if (_mode == MODE_PET) {
- return;
- }
+ this.promptBlizzBuild = function () {
+ if (_mode == MODE_PET) {
+ return;
+ }
- var
+ var
classId,
url = prompt(LANG.prompt_importblizz, "");
- if (!url) {
- return;
- }
+ if (!url) {
+ return;
+ }
if (url.match(/talent-calculator#([\w=+-.])c[0-9]{2}(![\w=+-.]*![\w=+-.]*![\w=+-.]*!?[\w=+-.]*)/)) { // Bnet Url
classId = _blizzEncoding.indexOf(RegExp.$1);
- _setBlizzBuild(classId, RegExp.$2, true);
+ _setBlizzBuild(classId, RegExp.$2, true);
- return;
- }
+ return;
+ }
else if (url.match(/\?cid=([0-9]+)&tal=([0-9]+)/)) { // old style
- classId = parseInt(RegExp.$1);
- _setBlizzBuild(classId, RegExp.$2);
+ classId = parseInt(RegExp.$1);
+ _setBlizzBuild(classId, RegExp.$2);
return;
}
else {
- var idx = url.indexOf("?tal=");
- if (idx != -1) {
- for (var i in g_file_classes) {
- if (url.indexOf(g_file_classes[i]) != -1) {
- classId = parseInt(i);
+ var idx = url.indexOf("?tal=");
+ if (idx != -1) {
+ for (var i in g_file_classes) {
+ if (url.indexOf(g_file_classes[i]) != -1) {
+ classId = parseInt(i);
- break;
- }
- }
- if (classId) {
- _setBlizzBuild(classId, url.substring(idx + 5));
+ break;
+ }
+ }
+ if (classId) {
+ _setBlizzBuild(classId, url.substring(idx + 5));
- return;
- }
- }
- }
+ return;
+ }
+ }
+ }
- alert(LANG.alert_invalidurl);
- };
+ alert(LANG.alert_invalidurl);
+ };
- this.promptWhBuild = function () {
- var url = prompt(LANG.prompt_importwh, '');
+ this.promptWhBuild = function () {
+ var url = prompt(LANG.prompt_importwh, '');
- if (!url) {
- return;
- }
+ if (!url) {
+ return;
+ }
- var pos = url.indexOf('=');
- if(pos != -1) {
+ var pos = url.indexOf('=');
+ if (pos != -1) {
var hash = url.substr(pos);
var
@@ -475,114 +473,114 @@ function TalentCalc() {
_setWhBuild(build);
_setWhGlyphs(glyphs);
}
- };
-
- this.registerClass = function (classId, data) {
- _registerClass(classId, data)
- };
-
- this.reset = function (tree) {
- if (_currentClass == -1) {
- return;
- }
-
- if (tree > _nTrees - 1) {
- return;
- }
-
- _locked = false;
- _resetTree(tree, _currentClass, true)
- };
-
- this.resetAll = function () {
- if (!_data[_currentClass]) {
- return;
- }
-
- _locked = false;
- _resetAll(_currentClass);
- _onChange();
- };
-
- this.resetBuild = function () {
- if (!_data[_currentClass]) {
- return;
- }
-
- _locked = false;
-
- _resetBuild(_currentClass);
- _refreshAll(_currentClass);
- _onChange();
- };
-
- this.resetGlyphs = function () {
- _resetGlyphs();
- _onChange();
- };
-
- this.restore = function () {
- _restore();
- };
-
- this.setBlizzBuild = function (classId, build) {
- _setBlizzBuild(classId, build);
- };
-
- this.setBlizzGlyphs = function (glyphs) {
- if (_currentClass == -1) {
- return;
- }
-
- _setBlizzGlyphs(glyphs);
- };
-
- this.setBonusPoints = function () {
- if (_mode != MODE_PET) {
- return;
- }
-
- _setPoints(-1, _pointsFromBonus);
- };
-
- this.setClass = function (classId) {
- return _setClass(classId);
- };
-
- this.setLevelCap = function (lvl) {
- _setLevelCap(lvl);
};
- this.setLock = function (locked) {
- if (_currentClass == -1) {
- return;
- }
+ this.registerClass = function (classId, data) {
+ _registerClass(classId, data)
+ };
- _setLock(locked);
- };
+ this.reset = function (tree) {
+ if (_currentClass == -1) {
+ return;
+ }
- this.setWhBuild = function (build) {
- return _setWhBuild(build);
- };
+ if (tree > _nTrees - 1) {
+ return;
+ }
- this.setWhGlyphs = function (glyphs) {
- if (_currentClass == -1) {
- return;
- }
+ _locked = false;
+ _resetTree(tree, _currentClass, true)
+ };
- _setWhGlyphs(glyphs);
- };
+ this.resetAll = function () {
+ if (!_data[_currentClass]) {
+ return;
+ }
+
+ _locked = false;
+ _resetAll(_currentClass);
+ _onChange();
+ };
+
+ this.resetBuild = function () {
+ if (!_data[_currentClass]) {
+ return;
+ }
+
+ _locked = false;
+
+ _resetBuild(_currentClass);
+ _refreshAll(_currentClass);
+ _onChange();
+ };
+
+ this.resetGlyphs = function () {
+ _resetGlyphs();
+ _onChange();
+ };
+
+ this.restore = function () {
+ _restore();
+ };
+
+ this.setBlizzBuild = function (classId, build) {
+ _setBlizzBuild(classId, build);
+ };
+
+ this.setBlizzGlyphs = function (glyphs) {
+ if (_currentClass == -1) {
+ return;
+ }
+
+ _setBlizzGlyphs(glyphs);
+ };
+
+ this.setBonusPoints = function () {
+ if (_mode != MODE_PET) {
+ return;
+ }
+
+ _setPoints(-1, _pointsFromBonus);
+ };
+
+ this.setClass = function (classId) {
+ return _setClass(classId);
+ };
+
+ this.setLevelCap = function (lvl) {
+ _setLevelCap(lvl);
+ };
+
+ this.setLock = function (locked) {
+ if (_currentClass == -1) {
+ return;
+ }
+
+ _setLock(locked);
+ };
+
+ this.setWhBuild = function (build) {
+ return _setWhBuild(build);
+ };
+
+ this.setWhGlyphs = function (glyphs) {
+ if (_currentClass == -1) {
+ return;
+ }
+
+ _setWhGlyphs(glyphs);
+ };
this.setPetModel = function(npcId) {
_updateModel(_currentClass, npcId); // NYI!
}
- this.showSummary = function (mode) {
- if (_currentClass == -1) {
- return;
- }
+ this.showSummary = function (mode) {
+ if (_currentClass == -1) {
+ return;
+ }
- var
+ var
c = _data[_currentClass],
bg = window.open('?talent=summary', '', 'toolbar=no,menubar=yes,status=yes,scrollbars=yes,resizable=yes'),
i,
@@ -590,112 +588,112 @@ function TalentCalc() {
k,
buffer = '' + document.title + '';
- bg.document.open();
+ bg.document.open();
- if (mode) { // Printable version
- buffer += '';
+ if (mode) { // Printable version
+ buffer += '';
- if (_mode == MODE_PET) {
- buffer += sprintf(LANG.tc_printh, _getRequiredLevel(), g_pet_families[c.n]);
- }
+ if (_mode == MODE_PET) {
+ buffer += sprintf(LANG.tc_printh, _getRequiredLevel(), g_pet_families[c.n]);
+ }
else {
- buffer += sprintf(LANG.tc_printh, _getRequiredLevel(), g_chr_classes[c.n]) + ' (' + c[0].k + '/' + c[1].k + '/' + c[2].k + ')';
- }
+ buffer += sprintf(LANG.tc_printh, _getRequiredLevel(), g_chr_classes[c.n]) + ' (' + c[0].k + '/' + c[1].k + '/' + c[2].k + ')';
+ }
- buffer += '
';
- buffer += '
';
+ buffer += '';
+ buffer += '';
- for (i = 0; i < _nTrees; ++i) {
- buffer += '' + c[i].n + ' (' + c[i].k + ' ' + LANG[c[i].k == 1 ? 'tc_point': 'tc_points'] + ')
';
- buffer += '';
- k = 0;
+ for (i = 0; i < _nTrees; ++i) {
+ buffer += '' + c[i].n + ' (' + c[i].k + ' ' + LANG[c[i].k == 1 ? 'tc_point': 'tc_points'] + ')
';
+ buffer += '';
+ k = 0;
- for (j = 0; j < c[i].t.length; ++j) {
- if (c[i].t[j].k) {
- if (k) {
- buffer += '
';
- }
+ for (j = 0; j < c[i].t.length; ++j) {
+ if (c[i].t[j].k) {
+ if (k) {
+ buffer += '
';
+ }
- buffer += '' + c[i].t[j].n + '' + LANG.hyphen + sprintf(LANG.tc_rank, c[i].t[j].k, c[i].t[j].m) + '
';
- buffer += _getTalentDescription(c[i].t[j]);
+ buffer += '' + c[i].t[j].n + '' + LANG.hyphen + sprintf(LANG.tc_rank, c[i].t[j].k, c[i].t[j].m) + '
';
+ buffer += _getTalentDescription(c[i].t[j]);
++k;
- }
- }
+ }
+ }
- if (k == 0) {
- buffer += LANG.tc_none;
- }
+ if (k == 0) {
+ buffer += LANG.tc_none;
+ }
- buffer += '
'
- }
+ buffer += '
'
+ }
- buffer += '' + LANG.tc_glyphs + '
';
- buffer += '';
- glyphCount = 0;
+ buffer += '' + LANG.tc_glyphs + '
';
+ buffer += '';
+ glyphCount = 0;
- for (i = 0; i < _nGlyphs; ++i) {
- glyph = g_glyphs[c.glyphs[i]];
- if (glyph) {
- if (glyphCount) {
- buffer += '
';
- }
+ for (i = 0; i < _nGlyphs; ++i) {
+ glyph = g_glyphs[c.glyphs[i]];
+ if (glyph) {
+ if (glyphCount) {
+ buffer += '
';
+ }
- buffer += '' + glyph.name + ' ';
- if (glyph.type == 1) {
- buffer += '(' + LANG.tc_majgly + ')
';
- }
+ buffer += '' + glyph.name + ' ';
+ if (glyph.type == 1) {
+ buffer += '(' + LANG.tc_majgly + ')
';
+ }
else {
- buffer += '(' + LANG.tc_mingly + ')
';
- }
+ buffer += '(' + LANG.tc_mingly + ')
';
+ }
- buffer += glyph.description;
+ buffer += glyph.description;
- glyphCount++
- }
- }
+ glyphCount++
+ }
+ }
- if (glyphCount == 0) {
- buffer += LANG.tc_none;
- }
+ if (glyphCount == 0) {
+ buffer += LANG.tc_none;
+ }
- buffer += '
';
- }
+ buffer += '
';
+ }
else { // Summary
- buffer += '';
- for (i = 0; i < _nTrees; ++i) {
- buffer += '' + c[i].n + ' (' + c[i].k + ' ' + LANG[c[i].k == 1 ? 'tc_point': 'tc_points'] + ')\n\n';
- k = 0;
- for (j = 0; j < c[i].t.length; ++j) {
- if (c[i].t[j].k) {
- buffer += ' ' + c[i].t[j].k + '/' + c[i].t[j].m + ' ' + c[i].t[j].n + '\n';
+ buffer += '';
+ for (i = 0; i < _nTrees; ++i) {
+ buffer += '' + c[i].n + ' (' + c[i].k + ' ' + LANG[c[i].k == 1 ? 'tc_point': 'tc_points'] + ')\n\n';
+ k = 0;
+ for (j = 0; j < c[i].t.length; ++j) {
+ if (c[i].t[j].k) {
+ buffer += ' ' + c[i].t[j].k + '/' + c[i].t[j].m + ' ' + c[i].t[j].n + '\n';
++k;
- }
- }
- if (k == 0) {
- buffer += ' ' + LANG.tc_none + '\n';
- }
- buffer += '\n';
- }
- buffer += '';
- }
+ }
+ }
+ if (k == 0) {
+ buffer += ' ' + LANG.tc_none + '\n';
+ }
+ buffer += '\n';
+ }
+ buffer += '';
+ }
- buffer += '';
+ buffer += '