', {class: 'small'})
.css('fontStyle', 'italic')
.css('position', 'absolute')
.css('right', '3px')
.css('bottom', '3px')
.html(buff)
);
}
$WH.ae(td, wrapper);
},
getVisibleText: function(spell) {
var buff = spell.name;
if (spell.rank) {
buff += ' ' + spell.rank;
}
if (spell.reqclass) {
var classes = Listview.funcBox.assocBinFlags(spell.reqclass, g_chr_classes);
for (var i = 0, len = classes.length; i < len; ++i) {
if (i > 0) {
buff += LANG.comma;
}
buff += g_chr_classes[classes[i]];
}
}
if (spell.reqrace) {
buff += ' ' + Listview.funcBox.arrayText(Listview.funcBox.assocBinFlags(spell.reqrace, g_chr_races), g_chr_races);
}
return buff;
}
},
{
id: 'tier',
name: LANG.tier,
width: '10%',
value: 'level',
compute: function(spell, td) {
if (spell.level > 0) {
var
baseLevel = (!this._petTalents ? 10 : 20),
tierPoints = (!this._petTalents ? 5 : 12);
return Math.floor((spell.level - baseLevel) / tierPoints) + 1; // + 3 ?
}
else {
return 1;
}
},
hidden: true
},
{
id: 'level',
name: LANG.level,
width: '10%',
value: 'level',
compute: function(spell, td) {
if (spell.level > 0) {
return spell.level;
}
},
hidden: true
},
{
id: 'trainingcost',
name: LANG.cost,
width: '10%',
hidden: true,
getValue: function(row) {
if (row.trainingcost) {
return row.trainingcost;
}
},
compute: function(row, td) {
if (row.trainingcost) {
Listview.funcBox.appendMoney(td, row.trainingcost);
}
},
sortFunc: function(a, b, col) {
if (a.trainingcost == null) {
return -1;
}
else if (b.trainingcost == null) {
return 1;
}
if (a.trainingcost < b.trainingcost) {
return -1;
}
else if (a.trainingcost > b.trainingcost) {
return 1;
}
return 0;
}
},
{
id: 'classes',
name: LANG.classes,
type: 'text',
hidden: true,
width: '20%',
getVisibleText: function(spell) {
var str = '';
if (spell.reqclass) {
var classes = Listview.funcBox.assocBinFlags(spell.reqclass, g_chr_classes);
for (var i = 0, len = classes.length; i < len; ++i) {
if (i > 0) {
str += LANG.comma;
}
str += g_chr_classes[classes[i]];
}
}
return str;
},
compute: function(spell, td) {
if (spell.reqclass) {
var classes = Listview.funcBox.assocBinFlags(spell.reqclass, g_chr_classes);
var d = $WH.ce('div');
d.style.width = (26 * classes.length) + 'px';
d.style.margin = '0 auto';
for (var i = 0, len = classes.length; i < len; ++i) {
var icon = Icon.create('class_' + g_file_classes[classes[i]], 0, null, '?class=' + classes[i]);
icon.style.cssFloat = icon.style.styleFloat = 'left';
g_addTooltip(icon, g_chr_classes[classes[i]], 'c' + classes[i]);
$WH.ae(d, icon);
}
$WH.ae(td, d);
}
},
sortFunc: function(a, b, col) {
return Listview.funcBox.assocArrCmp(Listview.funcBox.assocBinFlags(a.reqclass, g_chr_classes), Listview.funcBox.assocBinFlags(b.reqclass, g_chr_classes), g_chr_classes);
}
},
{
/* NOTE: To be used only if one single class is to be displayed */
id: 'singleclass',
name: LANG.classs,
type: 'text',
hidden: true,
width: '15%',
compute: function(spell, td) {
if (spell.reqclass) {
var classes = Listview.funcBox.assocBinFlags(spell.reqclass, g_chr_classes);
var classId = classes[0];
var text = $WH.ce('a');
text.style.backgroundImage = 'url("' + g_staticUrl + '/images/wow/icons/tiny/class_' + g_file_classes[classId] + '.gif")';
text.className = 'icontiny tinyspecial c' + classId;
text.href = '?class=' + classId;
$WH.ae(text, $WH.ct(g_chr_classes[classId]));
$WH.ae(td, text);
}
},
sortFunc: function(a, b, col) {
return Listview.funcBox.assocArrCmp(Listview.funcBox.assocBinFlags(a.reqclass, g_chr_classes), Listview.funcBox.assocBinFlags(b.reqclass, g_chr_classes), g_chr_classes);
}
},
{
id: 'glyphtype',
name: LANG.glyphtype,
type: 'text',
hidden: true,
width: '10%',
compute: function(spell, td) {
if (spell.glyphtype) {
return g_item_glyphs[spell.glyphtype];
}
}
},
{
id: 'schools',
name: LANG.school,
type: 'text',
width: '10%',
hidden: true,
compute: function(spell, td) {
var text = '';
var schools = spell.schools ? spell.schools : spell.school;
for (var i = 0; i < 32; ++i) {
if (!(schools & (1 << i))) {
continue;
}
if (text != '') {
text += ', ';
}
text += g_spell_resistances[i];
}
return text;
},
sortFunc: function(a, b, col) {
return $WH.strcmp(this.compute(a), this.compute(b));
}
},
{
id: 'type',
name: LANG.type,
type: 'text',
width: '14%',
hidden: true,
compute: function (spell, td) {
var d = $WH.ce('div');
d.className = 'small';
if ($WH.in_array([7, -2, -7, -12, -11, -13], spell.cat) != -1) {
var a1 = $WH.ce('a');
a1.className = 'q0';
a1.href = '?spells=' + spell.cat;
$WH.ae(a1, $WH.ct(g_spell_categories[spell.cat]));
$WH.ae(d, a1);
$WH.ae(d, $WH.ce('br'));
if (spell.talentspec) {
for (var i = 0, len = spell.talentspec.length; i< len; ++i) {
if (i > 0) {
$WH.ae(d, $WH.ct(LANG.comma));
}
var a2 = $WH.ce('a');
a2.className = 'q1';
a2.href = '?spells=' + spell.cat + '.' + (1 + Math.log(spell.reqclass) / Math.LN2) + '.' + spell.talentspec[i];
$WH.ae(a2, $WH.ct(g_chr_specs[spell.talentspec[i]]));
$WH.ae(d, a2);
}
}
else if (g_spell_types[spell.cat]) {
if (spell.cat == -11 && (spell.type == 1 || spell.type == 2)) {
var a2 = $WH.ce('a');
a2.className = 'q1';
// a2.href = '?spells=' + spell.cat + '&filter=cr=22;crs=' + spell.type + ';crv=0';
a2.href = '?spells=' + spell.cat + '.' + (spell.type == 2 ? '8' : '6');
$WH.ae(a2, $WH.ct(g_spell_types[spell.cat][spell.type]));
$WH.ae(d, a2);
}
else {
$WH.ae(d, $WH.ct(g_spell_types[spell.cat][spell.type]));
}
}
else if (spell.reqclass) {
var a2 = $WH.ce('a');
a2.className = 'q1';
a2.href = '?spells=' + spell.cat + '.' + (1 + Math.log(spell.reqclass) / Math.LN2) + (g_item_glyphs[spell.glyphtype] ? '&filter=gl=' + spell.glyphtype : '');
$WH.ae(a2, $WH.ct((g_item_glyphs[spell.glyphtype] ? g_item_glyphs[spell.glyphtype] + ' ' : '') + g_chr_classes[(1 + Math.log(spell.reqclass) / Math.LN2)]));
$WH.ae(d, a2);
}
}
else if (g_spell_categories[spell.cat]) {
var a1 = $WH.ce('a');
a1.className = 'q1';
a1.href = '?spells=' + spell.cat;
$WH.ae(a1, $WH.ct(g_spell_categories[spell.cat]));
$WH.ae(d, a1)
}
$WH.ae(td, d);
},
getVisibleText: function (spell) {
var buff = g_spell_categories[spell.cat];
if ($WH.in_array([7, -2, -12, -11, -13], spell.cat) != -1) {
if (spell.talentspec) {
buff += ' ' + Listview.funcBox.arrayText(spell.talentspec, g_chr_specs);
}
else if (g_spell_types[spell.cat]) {
buff += ' ' + g_spell_types[spell.cat][spell.type];
}
else {
if (g_item_glyphs[spell.glyphtype]) {
buff += ' ' + g_item_glyphs[spell.glyphtype];
}
buff += ' ' + g_chr_classes[(1 + Math.log(spell.reqclass) / Math.LN2)];
}
}
return buff;
},
sortFunc: function(a, b, col) {
var
typeA = (g_spell_types[a.cat] ? g_spell_types[a.cat][a.type] : a.type),
typeB = (g_spell_types[b.cat] ? g_spell_types[b.cat][b.type] : a.type);
return $WH.strcmp(a.cat, b.cat) || $WH.strcmp(typeA, typeB);
}
},
{
id: 'reagents',
name: LANG.reagents,
width: '9%',
hidden: true,
getValue: function(spell) {
return (spell.reagents ? spell.reagents.length : 0);
},
compute: function(spell, td) {
var hasIcons = (spell.reagents != null);
if (hasIcons) {
td.style.padding = '0';
var d = $WH.ce('div');
var items = spell.reagents;
d.style.width = (44 * items.length) + 'px';
d.style.margin = '0 auto';
for (var i = 0, len = items.length; i < len; ++i) {
var id = items[i][0];
var num = items[i][1];
var icon = g_items.createIcon(id, 1, num);
icon.style.cssFloat = icon.style.styleFloat = 'left';
$WH.ae(d, icon);
}
$WH.ae(td, d);
}
},
sortFunc: function(a, b) {
var lena = (a.reagents != null ? a.reagents.length : 0);
var lenb = (b.reagents != null ? b.reagents.length : 0);
if (lena > 0 && lena == lenb) {
return $WH.strcmp(a.reagents.toString(), b.reagents.toString());
}
else {
return $WH.strcmp(lena, lenb);
}
}
},
{
id: 'tp', // essentially unused, but if someone wants to backport classic
name: LANG.tp,
tooltip: LANG.tooltip_trainingpoints,
width: '7%',
hidden: true,
value: 'tp',
compute: function (spell, col) {
if (spell.tp > 0) {
return spell.tp;
}
}
},
{
id: 'source',
name: LANG.source,
type: 'text',
width: '12%',
hidden: true,
compute: function(spell, td) {
if (spell.source != null) {
if (spell.source.length == 1) {
$WH.nw(td);
var sm = (spell.sourcemore ? spell.sourcemore[0] : {});
var type = 0;
if (sm.t) {
type = sm.t;
var a = $WH.ce('a');
if (sm.q != null) {
a.className = 'q' + sm.q;
}
else {
a.className = 'q1';
}
a.href = '?' + g_types[sm.t] + '=' + sm.ti;
a.style.whiteSpace = 'nowrap';
if (sm.icon) {
a.className += ' icontiny tinyspecial';
a.style.backgroundImage = 'url("' + g_staticUrl + '/images/wow/icons/tiny/' + sm.icon.toLowerCase() + '.gif")';
}
$WH.ae(a, $WH.ct(sm.n));
$WH.ae(td, a);
}
else {
$WH.ae(td, $WH.ct(Listview.funcBox.getUpperSource(spell.source[0], sm)));
}
var ls = Listview.funcBox.getLowerSource(spell.source[0], sm, type);
if (this.iconSize != 0 && ls != null) {
var div = $WH.ce('div');
div.className = 'small2';
if (ls.pretext) {
$WH.ae(div, $WH.ct(ls.pretext));
}
if (ls.url) {
var a = $WH.ce('a');
a.className = 'q1';
a.href = ls.url;
$WH.ae(a, $WH.ct(ls.text));
$WH.ae(div, a);
}
else {
$WH.ae(div, $WH.ct(ls.text));
}
if (ls.posttext) {
$WH.ae(div, $WH.ct(ls.posttext));
}
$WH.ae(td, div);
}
}
else {
var buff = '';
for (var i = 0, len = spell.source.length; i < len; ++i) {
if (i > 0) {
buff += LANG.comma;
}
buff += g_sources[spell.source[i]];
}
}
return buff;
}
},
getVisibleText: function(spell) {
if (spell.source != null) {
if (spell.source.length == 1) {
var buff = '';
var sm = (spell.sourcemore ? spell.sourcemore[0] : {});
var type = 0;
if (sm.t) {
type = sm.t;
buff += ' ' + sm.n;
}
else {
buff += ' ' + Listview.funcBox.getUpperSource(spell.source[0], sm);
}
var ls = Listview.funcBox.getLowerSource(spell.source[0], sm, type);
if (ls != null) {
if (ls.pretext) {
buff += ' ' + ls.pretext;
}
buff += ' ' + ls.text;
if (ls.posttext) {
buff += ' ' + ls.posttext;
}
}
return buff;
}
else {
return Listview.funcBox.arrayText(spell.source, g_sources);
}
}
},
sortFunc: function(a, b, col) {
return Listview.funcBox.assocArrCmp(a.source, b.source, g_sources);
}
},
{
id: 'skill',
name: LANG.skill,
type: 'text',
width: '16%',
getValue: function(spell) {
return spell.learnedat;
},
compute: function(spell, td, tr, colNo) {
if (spell.skill != null) {
this.skillsColumn = colNo;
var div = $WH.ce('div');
div.className = 'small';
if (spell.cat == -7 && spell.pettype != null) {
spell.skill = [];
var petTalents = {
0: 410,
1: 409,
2: 411
};
for (var i = 0, len = spell.pettype.length; i < len; ++i) {
spell.skill.push(petTalents[spell.pettype[i]]);
}
}
for (var i = 0, len = spell.skill.length; i < len; ++i) {
if (i > 0) {
$WH.ae(div, $WH.ct(LANG.comma));
}
if (spell.skill[i] == -1) {
$WH.ae(div, $WH.ct(LANG.ellipsis));
}
else {
if ($WH.in_array([7, -2, -3, -5, -6, -7, 11, 9], spell.cat) != -1) {
var a = $WH.ce('a');
a.className = 'q1';
if ($WH.in_array([-5, -6], spell.cat) != -1) {
a.href = '?spells=' + spell.cat;
}
else {
a.href = '?spells=' + spell.cat + '.' + ((spell.reqclass && (spell.cat == 7 || spell.cat == -2)) ? (1 + Math.log(spell.reqclass) / Math.LN2) + '.' : '') + spell.skill[i];
}
var get = $WH.g_getGets();
var spellCat = (get.spells ? get.spells.split('.') : [false, false]);
if (spell.reqclass && (spell.cat == 7 || spell.cat == -2)) {
if (i < 1 && ((1 + Math.log(spell.reqclass) / Math.LN2) != spellCat[1])) {
var a2 = $WH.ce('a');
a2.className = 'q0';
a2.href = '?spells=' + spell.cat + '.' + (1 + Math.log(spell.reqclass) / Math.LN2);
$WH.ae(a2, $WH.ct(g_chr_classes[(1 + Math.log(spell.reqclass) / Math.LN2)]));
$WH.ae(div, a2);
$WH.ae(div, $WH.ce('br'));
}
}
$WH.ae(a, $WH.ct(spell.cat == -7 && spell.pettype != null ? g_pet_types[spell.pettype[i]] : g_spell_skills[spell.skill[i]]));
$WH.ae(div, a);
}
else {
$WH.ae(div, $WH.ct(g_spell_skills[spell.skill[i]]));
}
}
}
if (spell.learnedat > 0) {
$WH.ae(div, $WH.ct(' ('));
var spLearnedAt = $WH.ce('span');
if (spell.learnedat == 9999) {
spLearnedAt.className = 'q0';
$WH.ae(spLearnedAt, $WH.ct('??'));
}
else if (spell.learnedat > 0) {
$WH.ae(spLearnedAt, $WH.ct(spell.learnedat));
spLearnedAt.style.fontWeight = 'bold';
}
$WH.ae(div, spLearnedAt);
$WH.ae(div, $WH.ct(')'));
}
$WH.ae(td, div);
if (spell.colors != null) {
this.template.columns[colNo].type = null;
var
colors = spell.colors,
nColors = 0;
for (var i = 0; i < colors.length; ++i) {
if (colors[i] > 0) {
++nColors;
break;
}
}
if (nColors > 0) {
nColors = 0;
div = $WH.ce('div');
div.className = 'small';
div.style.fontWeight = 'bold';
for (var i = 0; i < colors.length; ++i) {
if (colors[i] > 0) {
if (nColors++ > 0) {
$WH.ae(div, $WH.ct(' '));
}
var spColor = $WH.ce('span');
spColor.className = 'r' + (i + 1);
$WH.ae(spColor, $WH.ct(colors[i]));
$WH.ae(div, spColor);
}
}
$WH.ae(td, div);
}
}
}
},
getVisibleText: function(spell) {
var buff = Listview.funcBox.arrayText(spell.skill, g_spell_skills);
if (spell.learnedat > 0) {
buff += ' ' + (spell.learnedat == 9999 ? '??' : spell.learnedat);
}
return buff;
},
sortFunc: function(a, b) {
/* aowow: behaves unpredictable if reqclass not set or 0
if (a.reqclass && b.reqclass) {
var reqClass = $WH.strcmp(g_chr_classes[(1 + Math.log(a.reqclass) / Math.LN2)], g_chr_classes[(1 + Math.log(b.reqclass) / Math.LN2)]);
if (reqClass) {
return reqClass;
}
}
*/
var skill = [a.learnedat, b.learnedat];
for (var s = 0; s < 2; ++s) {
var sp = (s == 0 ? a : b);
if (skill[s] == 9999 && sp.colors != null) {
var i = 0;
while (sp.colors[i] == 0 && i < sp.colors.length) {
i++;
}
if (i < sp.colors.length) {
skill[s] = sp.colors[i];
}
}
}
var foo = $WH.strcmp(skill[0], skill[1]);
if (foo != 0) {
return foo;
}
if (a.colors != null && b.colors != null) {
for (var i = 0; i < 4; ++i) {
foo = $WH.strcmp(a.colors[i], b.colors[i]);
if (foo != 0) {
return foo;
}
}
}
if (a.pettype != null & b.pettype != null) {
return Listview.funcBox.assocArrCmp(a.pettype, b.pettype, g_pet_types);
}
return Listview.funcBox.assocArrCmp(a.skill, b.skill, g_spell_skills);
}
},
/* AoWoW: custom start */
{
id: 'stackRules',
name: LANG.asr_behaviour,
type: 'text',
width: '20%',
hidden: true,
compute: function(spell, td) {
if (!spell.stackRule) {
return;
}
var
buff = '',
buff2 = '';
switch (spell.stackRule) {
case 3:
buff2 = LANG.asr_strongest_effect;
case 0:
buff = LANG.asr_coexist; // without condition
break;
case 2:
case 4:
buff2 = spell.stackRule == 2 ? LANG.asr_same_owner : LANG.asr_strongest_effect;
case 1:
buff = LANG.asr_exclusive; // without condition
break;
}
td.className = 'small';
td.style.lineHeight = '18px';
var span = $WH.ce('span');
span.className = !spell.stackRule || spell.stackRule == 3 ? 'q2' : 'q10';
$WH.ae(span, $WH.ct(buff));
$WH.ae(td, span);
if (buff2) {
var sp2 = $WH.ce('span');
sp2.style.whiteSpace = 'nowrap';
sp2.className = 'q0';
$WH.ae(td, $WH.ce('br'));
$WH.st(sp2, buff2);
$WH.ae(td, sp2);
}
},
getVisibleText: function (spell) {
if (!spell.stackRule) {
return;
}
var buff = '';
switch (spell.stackRule) {
case 3:
buff += LANG.asr_strongest_effect;
case 0:
buff += ' ' + LANG.asr_coexist;
break;
case 2:
buff += LANG.asr_same_owner;
case 1:
buff += ' ' + LANG.asr_exclusive;
break;
}
return buff;
},
sortFunc: function(a, b, col) {
return $WH.strcmp(a.stackRule, b.stackRule);
}
},
{
id: 'linkedTrigger',
name: LANG.ls_trigger,
type: 'text',
width: '50%',
hidden: true,
compute: function(spell, td) {
if (!spell.linked) {
return;
}
var
trigger = spell.linked[0],
buff = '';
switch (spell.linked[2]) {
case 0:
buff = trigger > 0 ? LANG.ls_onCast : LANG.ls_onAuraRemove;
break;
case 1:
buff = LANG.ls_onSpellHit;
break;
case 2:
buff = LANG.ls_onAuraApply;
break;
}
td.className = 'small';
td.style.lineHeight = '18px';
var a = $WH.ce('a');
a.style.whiteSpace = 'nowrap';
a.href = '?spell=' + Math.abs(trigger);
if (g_pageInfo.typeId == Math.abs(trigger)) { // ponts to self
a.className = 'q1';
$WH.st(a, LANG.ls_self);
}
else {
var item = g_spells[Math.abs(trigger)];
a.className = 'icontiny tinyspecial';
a.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/tiny/' + item['icon'] + '.gif)';
$WH.st(a, item['name_' + Locale.getName()]);
}
$WH.ae(td, a);
var span = $WH.ce('span');
span.className = 'q0';
$WH.st(span, buff);
$WH.ae(td, $WH.ce('br'));
$WH.ae(td, span);
},
getVisibleText: function (spell) {
if (!spell.linked) {
return;
}
var
trigger = spell.linked[0],
buff = '';
if (g_pageInfo.typeId == Math.abs(trigger)) {
buff += LANG.ls_self;
}
else {
buff += g_spells[Math.abs(trigger)]['name_' + Locale.getName()];
}
switch (spell.linked[2]) {
case 0:
buff += trigger > 0 ? ' ' + LANG.ls_onCast : ' ' + LANG.ls_onAuraRemove;
break;
case 1:
buff += ' ' + LANG.ls_onSpellHit;
break;
case 2:
buff += ' ' + LANG.ls_onAuraApply;
break;
}
return buff;
},
sortFunc: function(a, b, col) {
var
trA = a.linked[0],
trB = b.linked[0];
if (trA > 0 && trB < 0) {
return -1;
}
else if (trA < 0 && trB > 0) {
return 1;
}
if (g_pageInfo.typeId == Math.abs(trA)) {
return 1;
}
else if (g_pageInfo.typeId == Math.abs(trB)) {
return -1;
}
else if (trA != trB) {
return $WH.strcmp(g_spells[Math.abs(trA)]['name_' + Locale.getName()], g_spells[Math.abs(trB)]['name_' + Locale.getName()]);
}
return 0;
}
},
{
id: 'linkedEffect',
name: LANG.ls_effects,
type: 'text',
width: '50%',
hidden: true,
compute: function(spell, td) {
if (!spell.linked) {
return;
}
var
effect = spell.linked[1],
buff = '';
switch (spell.linked[2]) {
case 0:
case 1:
buff = effect > 0 ? LANG.ls_onTrigger : LANG.ls_onAuraRemove;
break;
case 2:
buff = effect > 0 ? LANG.ls_onAuraApply : LANG.ls_onImmune;
break;
}
td.className = 'small';
td.style.lineHeight = '18px';
var a = $WH.ce('a');
a.style.whiteSpace = 'nowrap';
a.href = '?spell=' + Math.abs(effect);
if (g_pageInfo.typeId == Math.abs(effect)) { // points to self
a.className = 'q1';
$WH.st(a, LANG.ls_self);
}
else {
var item = g_spells[Math.abs(effect)];
a.className = 'icontiny tinyspecial';
a.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/tiny/' + item['icon'] + '.gif)';
$WH.st(a, item['name_' + Locale.getName()]);
}
$WH.ae(td, a);
var span = $WH.ce('span');
span.className = 'q0';
$WH.st(span, buff);
$WH.ae(td, $WH.ce('br'));
$WH.ae(td, span);
},
getVisibleText: function (spell) {
if (!spell.linked) {
return;
}
var
effect = spell.linked[1],
buff = '';
if (g_pageInfo.typeId == Math.abs(effect)) {
buff += LANG.ls_self;
}
else {
buff += g_spells[Math.abs(effect)]['name_' + Locale.getName()];
}
switch (spell.linked[2]) {
case 0:
case 1:
buff += effect > 0 ? ' ' + LANG.ls_onTrigger : ' ' + LANG.ls_onAuraRemove;
break;
case 2:
buff += effect > 0 ? ' ' + LANG.ls_onAuraApply : ' ' + LANG.ls_onImmune;
break;
}
return buff;
},
sortFunc: function(a, b, col) {
var
effA = a.linked[1],
effB = b.linked[1];
if (effA > 0 && effB < 0) {
return -1;
}
else if (effA < 0 && effB > 0) {
return 1;
}
if (g_pageInfo.typeId == Math.abs(effA)) {
return 1;
}
else if (g_pageInfo.typeId == Math.abs(effB)) {
return -1;
}
else if (effA != effB) {
return $WH.strcmp(g_spells[Math.abs(effA)]['name_' + Locale.getName()], g_spells[Math.abs(effB)]['name_' + Locale.getName()]);
}
return 0;
}
},
/* AoWoW: custom end */
{
id: 'completed', // Listview.COLUMN_ID_COMPLETION
name: LANG.completion, // WH.TERMS.completion
hidden: true,
compute: function (spell, td)
{
if (!spell.hasOwnProperty('cat') || !Listview.templates.spell._validCompletionCategory(spell.cat))
return;
$WH.addCompletionIcons(td, 6, spell.id)
},
sortFunc: function (a, b)
{
// return $WH.stringCompare(
return $WH.strcmp(
$WH.getCompletionFlags(6, a.id),
$WH.getCompletionFlags(6, b.id)
);
},
getValue: function (spell) {
var value = 0;
var completionData = g_user.completion?.hasOwnProperty(6) ? g_user.completion[6] : {};
if (!spell.hasOwnProperty('cat') || !Listview.templates.spell._validCompletionCategory(spell.cat))
return -1;
for (var i in g_user.characters)
{
var profile = g_user.characters[i];
if (!(profile.id in completionData))
continue;
if ($WH.in_array(completionData[profile.id], spell.id) != -1)
value++;
}
return value;
}
}
],
getItemLink: function(spell) {
return '?spell=' + spell.id;
},
_validCompletionCategory: function (category) {
return $WH.in_array(g_completion_categories[6], category) != -1;
},
onBeforeCreate: function () {
for (var i in this.columns)
{
if (this.columns[i].id == 'completed' && this.columns[i].hidden)
{
if ($WH.isset('g_user') && 'characters' in g_user && $WH.in_array(this.hiddenCols, this.columns[i].id) == -1)
{
var n = 0;
for (var j in this.data)
if (this.data[j].hasOwnProperty('cat') && Listview.templates.spell._validCompletionCategory(this.data[j].cat))
n++;
if (n > this.data.length * 0.1)
this.visibility.push(parseInt(i));
}
}
}
}
},
zone: {
sort: [1],
nItemsPerPage: -1,
searchable: 1,
filtrable: 1,
columns: [
{
id: 'name',
name: LANG.name,
type: 'text',
align: 'left',
value: 'name',
compute: function(zone, td) {
var
wrapper = $WH.ce('div'),
a = $WH.ce('a');
a.style.fontFamily = 'Verdana, sans-serif';
a.href = this.getItemLink(zone);
$WH.ae(a, $WH.ct(zone.name));
if (zone.expansion) {
var sp = $WH.ce('span');
sp.className = g_GetExpansionClassName(zone.expansion);
$WH.ae(sp, a);
$WH.ae(wrapper, sp);
}
else {
$WH.ae(wrapper, a);
}
$WH.ae(td, wrapper);
if (zone.subzones) {
if (zone.subzones.length == 1 && zone.subzones[0] == zone.id)
return;
var nRows = parseInt(zone.subzones.length / 3);
if (nRows != (zone.subzones.length / 3))
nRows++;
wrapper.style.position = 'relative';
wrapper.style.minHeight = ((nRows * 12) + 19) + 'px';
var d = $WH.ce('div');
d.className = 'small';
d.style.fontStyle = 'italic';
d.style.position = 'absolute';
d.style.right = '2px';
d.style.bottom = '2px';
d.style.textAlign = 'right';
for (i in zone.subzones) {
if (!g_gatheredzones[zone.subzones[i]]) {
continue;
}
if (i > 0) {
$WH.ae(d, $WH.ct(LANG.comma));
}
var a = $WH.ce('a');
a.className = zone.subzones[i] == zone.id ? 'q1' : 'q0';
a.style.whiteSpace = 'nowrap';
a.href = '?zone=' + zone.subzones[i];
$WH.st(a, g_gatheredzones[zone.subzones[i]]['name_' + Locale.getName()]);
$WH.ae(d, a);
}
$WH.ae(wrapper, d);
}
},
getVisibleText: function(zone) {
var buff = zone.name + Listview.funcBox.getExpansionText(zone);
if (zone.instance == 5 || zone.instance == 8) {
buff += ' heroic';
}
return buff;
}
},
{
id: 'level',
name: LANG.level,
type: 'range',
width: '10%',
getMinValue: function(zone) {
return zone.minlevel;
},
getMaxValue: function(zone) {
return zone.maxlevel;
},
compute: function(zone, td) {
if (zone.minlevel > 0 && zone.maxlevel > 0) {
if (zone.minlevel != zone.maxlevel) {
return zone.minlevel + LANG.hyphen + zone.maxlevel;
}
else {
return zone.minlevel;
}
}
},
sortFunc: function(a, b, col) {
if (col > 0) {
return $WH.strcmp(a.minlevel, b.minlevel) || $WH.strcmp(a.maxlevel, b.maxlevel);
}
else {
return $WH.strcmp(a.maxlevel, b.maxlevel) || $WH.strcmp(a.minlevel, b.minlevel);
}
}
},
{
id: 'players',
name: LANG.players,
type: 'text',
hidden: true,
compute: function(zone, td) {
if (zone.instance > 0) {
var sp = $WH.ce('span');
if (zone.nplayers == -2) {
zone.nplayers = '10/25';
}
var buff = '';
if (zone.nplayers) {
if (zone.instance == 4) {
buff += $WH.sprintf(LANG.lvzone_xvx, zone.nplayers, zone.nplayers);
}
else {
buff += $WH.sprintf(LANG.lvzone_xman, zone.nplayers);
}
}
$WH.ae(sp, $WH.ct(buff));
$WH.ae(td, sp);
}
},
getVisibleText: function(zone) {
if (zone.instance > 0) {
if (zone.nplayers == -2) {
zone.nplayers = '10/25';
}
var buff = '';
if (zone.nplayers && ((zone.instance != 2 && zone.instance != 5) || zone.nplayers > 5)) {
if (zone.instance == 4) {
buff += $WH.sprintf(LANG.lvzone_xvx, zone.nplayers, zone.nplayers);
}
else {
buff += $WH.sprintf(LANG.lvzone_xman, zone.nplayers);
}
}
return buff;
}
},
sortFunc: function(a, b, col) {
return $WH.strcmp(a.nplayers, b.nplayers);
}
},
{
id: 'territory',
name: LANG.territory,
type: 'text',
width: '13%',
compute: function(zone, td) {
var sp = $WH.ce('span');
switch (zone.territory) {
case 0:
sp.className = 'icon-alliance';
break;
case 1:
sp.className = 'icon-horde';
break;
case 4:
sp.className = 'icon-ffa';
break;
}
$WH.ae(sp, $WH.ct(g_zone_territories[zone.territory]));
$WH.ae(td, sp);
},
getVisibleText: function(zone) {
return g_zone_territories[zone.territory];
},
sortFunc: function(a, b, col) {
return $WH.strcmp(g_zone_territories[a.territory], g_zone_territories[b.territory]);
}
},
{
id: 'instancetype',
name: LANG.instancetype,
type: 'text',
compute: function(zone, td) {
if (zone.instance > 0) {
var sp = $WH.ce('span');
if ((zone.instance >= 1 && zone.instance <= 5) || zone.instance == 7 || zone.instance == 8) {
sp.className = 'icon-instance' + zone.instance;
}
var buff = g_zone_instancetypes[zone.instance];
if (zone.heroicLevel) {
var skull = $WH.ce('span');
skull.className = 'icon-heroic';
g_addTooltip(skull, LANG.tooltip_heroicmodeavailable + LANG.qty.replace('$1', zone.heroicLevel));
$WH.ae(td, skull);
}
$WH.ae(sp, $WH.ct(buff));
$WH.ae(td, sp);
}
},
getVisibleText: function(zone) {
if (zone.instance > 0) {
var buff = g_zone_instancetypes[zone.instance];
if (zone.nplayers && ((zone.instance != 2 && zone.instance != 5) || zone.nplayers > 5)) {
if (zone.instance == 4) {
buff += ' ' + $WH.sprintf(LANG.lvzone_xvx, zone.nplayers, zone.nplayers);
}
else {
buff += ' ' + $WH.sprintf(LANG.lvzone_xman, zone.nplayers);
}
}
if (zone.instance == 5 || zone.instance == 8) {
buff += ' heroic';
}
return buff;
}
},
sortFunc: function(a, b, col) {
return $WH.strcmp(g_zone_instancetypes[a.instance], g_zone_instancetypes[b.instance]) || $WH.strcmp(a.instance, b.instance) || $WH.strcmp(a.nplayers, b.nplayers);
}
},
{
id: 'category',
name: LANG.category,
type: 'text',
width: '15%',
compute: function(zone, td) {
td.className = 'small q1';
var a = $WH.ce('a');
a.href = '?zones=' + zone.category;
$WH.ae(a, $WH.ct(g_zone_categories[zone.category]));
$WH.ae(td, a);
},
getVisibleText: function(zone) {
return g_zone_categories[zone.category];
},
sortFunc: function(a, b, col) {
return $WH.strcmp(g_zone_categories[a.category], g_zone_categories[b.category]);
}
}
],
getItemLink: function(zone) {
return '?zone=' + zone.id;
}
},
holiday: {
sort: [2, 1],
nItemsPerPage: -1,
searchable: 1,
filtrable: 1,
columns: [
{
id: 'name',
name: LANG.name,
type: 'text',
align: 'left',
value: 'name',
span: 2,
compute: function(holiday, td, tr) {
var i = $WH.ce('td');
i.style.width = '1px';
i.style.padding = '0';
i.style.borderRight = 'none';
$WH.ae(i, g_holidays.createIcon(holiday.id, 0));
$WH.ae(tr, i);
td.style.borderLeft = 'none';
var a = $WH.ce('a');
a.style.fontFamily = 'Verdana, sans-serif';
a.href = this.getItemLink(holiday);
$WH.ae(a, $WH.ct(holiday.name));
$WH.ae(td, a);
},
getVisibleText: function(holiday) {
return holiday.name;
}
},
{
id: 'date',
name: LANG.date,
type: 'text',
width: '16%',
allText: true,
compute: function(holiday, td, tr) {
if (holiday.startDate && holiday.endDate) {
var dates = Listview.funcBox.getEventNextDates(holiday.startDate, holiday.endDate, holiday.rec || 0);
if (dates[0] && dates[1]) {
var
start = g_formatDateSimple(dates[0]),
end = g_formatDateSimple(dates[1]),
sp = $WH.ce('span');
if (start != end) {
$WH.st(sp, start + LANG.hyphen + end);
}
else {
$WH.st(sp, start);
}
$WH.ae(td, sp);
if (dates[0] <= g_serverTime && dates[1] >= g_serverTime) {
tr.className = 'checked';
sp.className = 'q2 tip';
g_addTooltip(sp, LANG.tooltip_activeholiday, 'q');
}
}
}
},
getVisibleText: function(holiday) {
if (holiday.startDate && holiday.endDate) {
var dates = Listview.funcBox.getEventNextDates(holiday.startDate, holiday.endDate, holiday.rec || 0);
if (dates[0] && dates[1]) {
var
start = g_formatDateSimple(dates[0]),
end = g_formatDateSimple(dates[1]);
if (start != end) {
return start + LANG.hyphen + end;
}
else {
return start;
}
}
}
return'';
},
sortFunc: function(a, b, col) {
if (a.startDate && b.startDate) {
var datesA = Listview.funcBox.getEventNextDates(a.startDate, a.endDate, a.rec || 0);
var datesB = Listview.funcBox.getEventNextDates(b.startDate, b.endDate, b.rec || 0);
if (datesA[0] && datesB[0]) {
return datesA[0] - datesB[0];
}
}
else if (a.startDate) {
return -1;
}
else if (b.startDate) {
return 1;
}
return 0;
}
},
{
id: 'category',
name: LANG.category,
type: 'text',
width: '16%',
compute: function(holiday, td) {
td.className = 'small q1';
var
a = $WH.ce('a'),
href = '?events=' + holiday.category;
a.href = href;
$WH.ae(a, $WH.ct(g_holiday_categories[holiday.category]));
$WH.ae(td, a);
},
getVisibleText: function(holiday) {
return g_holiday_categories[holiday.category];
},
sortFunc: function(a, b, col) {
return $WH.strcmp(g_holiday_categories[a.category], g_holiday_categories[b.category]);
}
}
],
getItemLink: function(holiday) {
return '?event=' + holiday.id;
}
},
holidaycal: {
sort: [1],
mode: 4, // Calendar
startOnMonth: new Date(g_serverTime.getFullYear(), 0, 1),
nMonthsToDisplay: 12,
rowOffset: g_serverTime.getMonth(),
poundable: 2, // Yes but w/o sort
columns: [],
compute: function(holiday, div, i) {
if (!holiday.events || !holiday.events.length) {
return;
}
for (var i = 0; i < holiday.events.length; ++i) {
var icon = g_holidays.createIcon(holiday.events[i].id, 1);
icon.onmouseover = Listview.funcBox.dateEventOver.bind(icon, holiday.date, holiday.events[i]);
icon.onmousemove = $WH.Tooltip.cursorUpdate;
icon.onmouseout = $WH.Tooltip.hide;
icon.style.cssFloat = icon.style.styleFloat = 'left';
$WH.ae(div, icon);
}
},
sortFunc: function(a, b) {
if (a.startDate && b.startDate) {
var datesA = Listview.funcBox.getEventNextDates(a.startDate, a.endDate, a.rec || 0);
var datesB = Listview.funcBox.getEventNextDates(b.startDate, b.endDate, b.rec || 0);
for (var i = 0; i < 2; ++i) {
var
dA = datesA[i],
dB = datesB[i];
if (dA.getFullYear() == dB.getFullYear() && dA.getMonth() == dB.getMonth() && dA.getDate() == dB.getDate()) {
return dA - dB;
}
}
}
return $WH.strcmp(a.name, b.name);
}
},
comment: { // todo: reformat
sort: [-5, 4, 6, -3, 2], // this is the default for coSortHighestRating so that a double-sort doesn't happen
mode: 2, // Div mode
nItemsPerPage: 40,
poundable: 2, // Yes, but w/o sort
columns: [
{ value: 'number' },
{ value: 'id' },
{ value: 'rating' },
{ value: 'deleted' },
{ value: 'sticky' },
{ value: 'outofdate' }
],
compute: function(comment, div, i)
{
/** Variables **/
var container = $('
');
var hidden = (comment.__minPatch && g_getPatchVersion.T[comment.__minPatch] > new Date(comment.date));
comment.locale = (this.id == 'english-comments' ? 'en' : '');
/** Initialization.. Create base HTML skeleton */
container.append('
| ' +
/* VOTE */ ' + - ' +
' | ' +
/* HEADER */ '' +
/* BODY */ '' +
/* REPLIES */ '' +
/* REPLIES CONTROL */ '' +
' |
');
comment.colorClass = 'comment' + (i % 2);
container.addClass('comment').addClass(comment.colorClass);
if (comment.rating < -4) {
container.addClass('comment-lowrated');
}
if (comment.deleted)
container.addClass('comment-deleted');
if (comment.outofdate)
container.addClass('comment-outofdate');
comment.container = container;
comment.voteCell = container.find('.vote-column');
comment.commentCell = container.find('.main-body');
comment.repliesCell = container.find('.comment-replies');
comment.repliesControl = container.find('.comment-replies-control');
comment.headerCell = container.find('.comment-header');
comment.commentBody = container.find('.comment-body');
comment.commentAuthor = container.find('.comment-author');
comment.commentControls = container.find('.comment-controls');
this.template.updateVoteCell(comment, true);
this.template.updateCommentCell(comment);
this.template.updateStickyStatus(comment);
this.template.updateReplies(comment);
// headers for hidden comments
if (comment.deleted || comment.rating < -4) {
comment.headerCell.css('cursor', 'pointer');
comment.headerCell.bind('click', function(e) {
if ($WH.$E(e)._target.nodeName == 'A') {
return; // aowow - custom: prevent toggle if using function buttons
}
comment.voteCell.toggle();
comment.repliesCell.toggle();
comment.commentBody.toggle();
});
}
$(div).addClass('comment-wrapper').html(container);
if (hidden)
$(div).hide();
else
$(div).show();
},
applyAuthorTitle: function (container, title)
{
if (!title.label)
return;
let cssClass = ['comment-reply-author-label'].concat(title.classes);
$WH.ae(container, $WH.ct(' ')); // aowow - LANG.wordspace_punct
if (title.url)
$WH.ae(container, $WH.ce('a', { className: cssClass.join(' '), href: title.url }, $WH.ct(`<${ title.label }>`)));
else
$WH.ae(container, $WH.ce('span', { className: cssClass.join(' ') }, $WH.ct(`<${ title.label }>`)));
},
getAuthorTitle: function (author)
{
let title = {
classes: [],
label: undefined,
url: undefined
};
if (g_pageInfo.author === author) {
title.label = LANG.guideAuthor;
return title;
}
let user = g_users[author];
if (user) {
// aowow - let roleColor = WH.User.getCommentTitleClass(_.roles, _.tierClass, user);
let roleColor = g_GetStaffColorFromRoles(user.roles);
if (roleColor) {
title.classes.push(roleColor);
}
// aowow - title.label = WH.User.getCommentRoleLabel(user.roles, user.title, user.tierTitle);
title.label = g_GetCommentRoleLabel(user.roles, user.title);
title.url = /* user.tierTitle && !user.title ? '/?premium' : */ ''; // aowow - tierTitle being the premium tier ("Rare|Epic|Legendary Premium User")
}
return title;
},
updateReplies: function(comment)
{
this.updateRepliesCell(comment);
this.updateRepliesControl(comment);
SetupReplies(comment.container, comment);
/* Let's see if the user wants to see a specific reply; only if it's the first time loading the page. */
if (!comment.alreadyLoadedBefore)
{
comment.alreadyLoadedBefore = true;
var matches = location.hash.match('#comments:id=([0-9]+):reply=([0-9]+)');
if (matches)
{
var commentId = matches[1];
var replyId = matches[2];
if (comment.id == commentId)
this.highlightReply(comment, replyId);
}
}
},
highlightReply: function(comment, replyId, fetchedMoreReplies)
{
var reply = null;
/* First let's try to find it */
for (var idx in comment.replies)
{
if (comment.replies[idx].id == replyId)
{
reply = comment.replies[idx];
break;
}
}
if (!reply)
{
if (fetchedMoreReplies)
return; /* Doesn't exist */
$.ajax({
type: 'GET',
url: '?comment=show-replies',
data: { id: comment.id },
success: function (replies) { comment.replies = replies; Listview.templates.comment.updateReplies(comment); Listview.templates.comment.highlightReply(comment, replyId, true); },
dataType: 'json'
});
return;
}
/* Ok, we have found the reply to highlight. */
var replyRow = comment.repliesCell.find('.comment-reply-row[data-replyid=' + replyId + ']');
var normalColor = '#292929';
if (comment.deleted) {
normalColor = '#402424';
} else if (comment.outofdate) {
normalColor = '#322C1C';
} else if (comment.colorClass == 'comment0') {
normalColor = '#242424';
}
replyRow.css('background-color', '#581111');
setTimeout(function() { replyRow.animate({ backgroundColor: normalColor }, 1500) }, 1500);
},
updateStickyStatus: function(comment)
{
if (comment.sticky)
comment.voteCell.find('.comment-sticky').show();
else
comment.voteCell.find('.comment-sticky').hide();
},
updateRepliesCell: function(comment)
{
var container = comment.repliesCell;
var table = $('
');
container.html('');
if (!comment.replies.length)
{
container.append(table).hide();
return;
}
for (var i = 0; i < comment.replies.length; ++i)
{
var reply = comment.replies[i];
let owner = g_pageInfo.author === reply.username;
var row = $('');
var replyBy = $('');
var replyByUserLink = $('
');
var creationDate = new Date(reply.creationdate);
var elapsed = (g_serverTime - creationDate) / 1000;
var upvoteControl = row.find('.reply-upvote');
var downvoteControl = row.find('.reply-downvote');
var canDelete = (g_user.name == reply.username) || (g_user.roles & U_GROUP_COMMENTS_MODERATOR) != 0;
var canEdit = canDelete;
row.attr('data-replyid', reply.id);
row.attr('data-idx', i);
// aowow - let cssClass = WH.User.getCommentRoleClass(reply.roles, reply.username);
let cssClass = g_GetStaffColorFromRoles(reply.roles);
if (!['comment-blue', 'comment-green'].includes(cssClass) && owner) {
cssClass = 'comment-green'; // comment-guide-author
}
row.find('.reply-text').addClass(cssClass);
var replyWhen = $('
');
replyWhen.text(g_formatDate(null, elapsed, creationDate));
replyWhen.attr('href', '#comments:id=' + comment.id + ':reply=' + reply.id);
replyWhen.attr('id', 'comments:id=' + comment.id + ':reply=' + reply.id);
replyWhen.addClass('when');
replyByUserLink.attr('href', '?user=' + reply.username);
replyByUserLink.text(reply.username);
replyBy.append(replyByUserLink);
this.applyAuthorTitle(replyBy[0], this.getAuthorTitle(reply.username))
replyBy.append(' ').append(replyWhen).append(' ').append($WH.sprintf(LANG.lvcomment_patch, g_getPatchVersion(creationDate)));
var replyHtml = Markup.toHtml(reply.body, {allow: Markup.CLASS_USER, mode: Markup.MODE_REPLY, roles: 0, locale: comment.locale});
replyHtml = replyHtml.replace(/[^\s<>]{81,}/, function(text) {
if (text.substring(0, 4) == 'href' || text.substring(0, 3) == 'src')
return text;
var ret = '';
for (j = 0; j < text.length; j += 80)
ret += (text.substring(j, 80 + j) + " ");
return ret;
});
/* Flag */
if (g_user.canUpvote && g_user.name != reply.username && !reply.reportedByUser)
replyHtml += '
report';
if (canEdit)
replyHtml += '
edit';
if (g_user.roles & U_GROUP_COMMENTS_MODERATOR)
replyHtml += '
detach';
if (canDelete)
replyHtml += '
delete';
row.find('.reply-text').html(replyBy).append(replyHtml);
row.find('.reply-rating').text(reply.rating);
/* Upvote */
if (reply.votedByUser)
upvoteControl.attr('data-hasvoted', 'true');
if (g_user.canUpvote && g_user.name != reply.username && !reply.votedByUser && !reply.downvotedByUser)
upvoteControl.attr('data-canvote', 'true');
/* Downvote */
if (reply.downvotedByUser)
downvoteControl.attr('data-hasvoted', 'true');
if (g_user.canDownvote && g_user.name != reply.username && !reply.votedByUser && !reply.downvotedByUser)
downvoteControl.attr('data-canvote', 'true');
table.append(row);
}
container.html(table);
if (comment.deleted || comment.rating < -4) {
comment.repliesCell.hide();
}
},
updateRepliesControl: function(comment)
{
var control = comment.repliesControl;
control.html('').hide().unbind().attr('class', 'comment-replies-control');
var extraReplies = Math.max(comment.nreplies - comment.replies.length, 0);
if ((comment.deleted || comment.outofdate || comment.rating < -4) || (!g_user.canPostReplies && !extraReplies))
return;
if (g_user.canPostReplies)
{
if (!extraReplies)
control.text(LANG.addreply_stc).addClass('add-reply');
else
control.text($WH.sprintf(extraReplies == 1 ? LANG.addshow1morereply_stc : LANG.addshowmorereplies_format, extraReplies)).addClass('show-more-replies');
}
else
control.text($WH.sprintf(extraReplies == 1 ? LANG.show1morereply_stc : LANG.showmorereplies_format, extraReplies)).addClass('show-more-replies');
control.show();
},
updateCommentCell: function(comment)
{
comment.commentCell.find('.comment-edit').remove();
this.updateCommentBody(comment, comment.commentBody);
this.updateCommentAuthor(comment, comment.commentAuthor);
this.updateCommentControls(comment, comment.commentControls);
},
updateCommentAuthor: function(comment, container)
{
var user = g_users[comment.user];
var postedOn = new Date(comment.date);
var elapsed = (g_serverTime - postedOn) / 1000;
container.html('');
container.append(LANG.lvcomment_by);
container.append($WH.sprintf('
$2', comment.user, comment.user));
// aowow - avatar recovered and transplanted from commentsv1 version
if (user != null && user.avatar) {
var icon = Icon.createUser(user.avatar, user.avatarmore, 0, null, (user.roles & U_GROUP_PREMIUM) ? user.border : Icon.STANDARD_BORDER, 0, Icon.getPrivilegeBorder(user.reputation));
icon.style.marginRight = '3px';
icon.style.cssFloat = 'left';
container.css('lineHeight', '25px');
container.append(icon);
}
// aowow - end recover
container.append(g_getReputationPlusAchievementText(user.gold, user.silver, user.copper, user.reputation));
this.applyAuthorTitle(container[0], this.getAuthorTitle(comment.user));
container.append($WH.sprintf(' ', comment.id, comment.id, g_formatDate(null, elapsed, postedOn)));
container.append(' ');
container.append($WH.sprintf(LANG.lvcomment_patch, g_getPatchVersion(postedOn)));
},
updateCommentControls: function(comment, container)
{
/** VARIABLES **/
var controls = []; // List of objects: .name and .func
var canEdit = (g_user.roles & U_GROUP_COMMENTS_MODERATOR) != 0 || (comment.user.toLowerCase() == g_user.name.toLowerCase() && !g_user.commentban);
var canDelete = (g_user.roles & U_GROUP_COMMENTS_MODERATOR) != 0 || (comment.user.toLowerCase() == g_user.name.toLowerCase() && !g_user.commentban);
var isAdmin = (g_user.roles & U_GROUP_COMMENTS_MODERATOR) != 0;
/** PUT THE CONTROLS IN `controls` **/
if (canEdit) {
if (!comment.outofdate && !comment.deleted) {
controls.push({name: LANG.lvcomment_edit, func: Listview.funcBox.coEdit.bind(this, comment, 0, false)});
}
}
if (canDelete && !comment.deleted) {
controls.push({name: LANG.lvcomment_delete, func: Listview.funcBox.coDelete.bind(this, comment)});
}
if (isAdmin && comment.deleted) {
controls.push({name: LANG.lvcomment_undelete, func: Listview.funcBox.coUndelete.bind(this, comment)});
}
if (isAdmin && comment.outofdate) {
controls.push({name: LANG.lvcomment_uptodate, func: Listview.funcBox.coFlagUpOfDate.bind(this, comment)});
}
/** SpiffyJr, add Flag as out of date **/
if (g_user.id != 0 && !comment.outofdate && !comment.deleted) {
controls.push({name: LANG.lvcomment_outofdate, func: Listview.funcBox.coFlagOutOfDate.bind(this, comment)});
}
if (isAdmin && !comment.sticky && !comment.outofdate && !comment.deleted)
controls.push({name: 'Sticky', func: this.sticky.bind(this, comment)});
if (isAdmin && comment.sticky && !comment.outofdate && !comment.deleted)
controls.push({name: 'Unsticky', func: this.sticky.bind(this, comment)});
if (!comment.outofdate && !comment.deleted) {
controls.push({extraClass: 'icon-report', tooltip: LANG.report_tooltip, name: LANG.lvcomment_report, func: ContactTool.show.bind(ContactTool, {mode: 1, comment: comment})});
}
/** WRITE THE CONTROLS **/
container.html('');
for (var idx in controls)
{
var data = controls[idx];
var control = $('
');
var insideContainer = $('
');
if (idx != 0)
insideContainer.append(' | ');
control.click(data.func);
control.text(data.name);
if (data.extraClass)
control.addClass(data.extraClass);
if (data.tooltip)
control.mouseover(function(event) {$WH.Tooltip.showAtCursor(event, data.tooltip, 0, 0, 'q2');}).mousemove(function(event) {$WH.Tooltip.cursorUpdate(event)}).mouseout(function() {$WH.Tooltip.hide()});
insideContainer.append(control);
container.append(insideContainer);
}
},
updateCommentBody: function(comment, commentBody)
{
var allowed = Markup.rolesToClass(comment.roles);
/** BODY **/
commentBody.removeClass('comment-green');
commentBody.addClass(Listview.funcBox.coGetColor(comment));
commentBody.html(Markup.toHtml(comment.body, {allow: allowed, mode: Markup.MODE_COMMENT, roles: comment.roles, locale: comment.locale}));
/** ADMIN RESPONSE **/
if (comment.response)
{
var adminResponse = $('
');
adminResponse.addClass('text comment-body');
adminResponse.html(Markup.toHtml('[div][/div][wowheadresponse=' + comment.responseuser + ' roles=' + comment.responseroles + ']' + comment.response + '[/wowheadresponse]', { allow: Markup.CLASS_STAFF, roles: comment.responseroles, uid: 'resp-' + comment.id }));
commentBody.append(adminResponse);
}
/** LAST EDIT **/
if (comment.lastEdit)
this.addEditedByOrDeletedByText(commentBody, LANG.lvcomment_lastedit, comment.lastEdit[2], comment.lastEdit[0], comment.lastEdit[1]);
/** DELETION **/
if (comment.deletedInfo)
this.addEditedByOrDeletedByText(commentBody, LANG.lvcomment_deletedby, comment.deletedInfo[1], comment.deletedInfo[0], null);
/** THIS IS USED FOR OBSOLETE CODE **/
comment.divBody = commentBody[0];
if (comment.deleted || comment.rating < -4) {
commentBody.hide();
}
},
/* Used for both last edit and deleted by messages since the only thing that changes is the `text`, given as argument.. */
addEditedByOrDeletedByText: function(commentBody, text, username, when, count)
{
var editedOn = new Date(when);
var elapsed = (g_serverTime - editedOn) / 1000;
count = count > 1 ? LANG.dash + $WH.sprintf(LANG.lvcomment_nedits, count) : '';
var lastEdit = $('
');
lastEdit.addClass('comment-lastedit');
lastEdit.html($WH.sprintf('$1
$2 $3$4', text, g_formatDate(null, elapsed, editedOn), $WH.sprintf(LANG.lvcomment_patch, g_getPatchVersion(editedOn)), count));
/* Fix up last editor name */
lastEdit.find('a').text(username).attr('href', '?user=' + username);
commentBody.append(lastEdit);
},
updateVoteCell: function(comment, onInit)
{
var upvoteControl = comment.voteCell.find('.upvote');
var downvoteControl = comment.voteCell.find('.downvote');
var ratingContainer = comment.voteCell.find('.rating-container');
var ratingText = $('
');
var template = this;
ratingContainer.html(ratingText);
/* Set up the vote cell */
if (comment.userRating > 0)
upvoteControl.attr('data-hasvoted', 'true').attr('title', LANG.upvoted_tip);
else
upvoteControl.attr('data-hasvoted', 'false').attr('title', LANG.upvote_tip);
if (comment.userRating < 0)
downvoteControl.attr('data-hasvoted', 'true').attr('title', LANG.downvoted_tip);
else
downvoteControl.attr('data-hasvoted', 'false').attr('title', LANG.downvote_tip);
g_addTooltip(upvoteControl[0], LANG.tooltip_uprate, 'q2');
g_addTooltip(downvoteControl[0], LANG.tooltip_downrate, 'q10');
/* Clean up (unbind click events; this function can be called several times) */
ratingText.unbind();
upvoteControl.unbind();
downvoteControl.unbind();
/* Bind events */
ratingText.text(comment.rating);
ratingText.click(function() { template.showVoteBreakdown(comment, ratingContainer); });
upvoteControl.click(function() { template.vote(comment, 1); });
downvoteControl.click(function() { template.vote(comment, -1); });
if ((comment.deleted || comment.rating < -4) && onInit) {
comment.voteCell.hide();
}
},
vote: function(comment, rating)
{
/****************************/
/*** BASIC ERROR CHECKING ***/
/****************************/
if (!rating)
return;
if (!g_user.id)
{
this.voteError(comment, LANG.votelogin_tip);
return;
}
if (comment.deleted)
{
this.voteError(comment, LANG.votedeleted_tip);
return;
}
if (g_user.name == comment.user)
{
this.voteError(comment, LANG.voteself_tip);
return;
}
if (!g_user.canUpvote && rating > 0)
{
this.voteError(comment, $WH.sprintf(LANG.upvotenorep_tip, g_user.upvoteRep));
return;
}
if (!g_user.canDownvote && rating < 0)
{
this.voteError(comment, $WH.sprintf(LANG.downvotenorep_tip, g_user.downvoteRep));
return;
}
/**********************/
/*** VARIABLE SETUP ***/
/**********************/
if (rating > 0)
rating = g_user.superCommentVotes ? 2 : 1;
else if (rating < 0)
rating = g_user.superCommentVotes ? -2 : -1;
else
return;
/*************************/
/*** CHANGE RATING NOW ***/
/*************************/
var backupCommentRating = comment.rating;
var backupUserRating = comment.userRating;
var template = this;
/* Case: Rescinding previous vote */
if ((comment.userRating > 0 && rating > 0) || (comment.userRating < 0 && rating < 0))
{
comment.rating -= comment.userRating;
comment.userRating = 0;
}
/* Case: "Inverting" vote (from downvote to upvote, from upvote to downvote) or simply casting a vote when there was none before */
else
{
comment.rating -= comment.userRating;
comment.rating += rating;
comment.userRating = rating;
}
this.updateVoteCell(comment);
/**********************/
/*** SERVER REQUEST ***/
/**********************/
$.get('?comment=vote', { id: comment.id, rating: rating }, function(response) {
if (response.error)
{
/* We have to undo the change we have done above */
comment.rating = backupCommentRating;
comment.userRating = backupUserRating;
template.updateVoteCell(comment);
}
if (response.message)
template.voteError(comment, response.message);
}, 'json');
},
voteError: function(comment, error)
{
MessageBox(comment.voteCell, error);
},
showVoteBreakdown: function(comment, ratingText)
{
/* Show ajax icon */
ratingText.find('p').html('

');
$.get('?comment=rating&id=' + comment.id, null, function(data) {
if (data.success)
ratingText.html($WH.sprintf('
$1
$2
', (data.up ? ('+' + data.up) : 0), -data.down));
else
MessageBox(ratingText, 'An error has occurred while fetching vote counts. Try refreshing the page.');
}, 'json');
},
sticky: function(comment)
{
var notificationDiv = comment.commentCell.find('.comment-notification');
comment.sticky = !comment.sticky;
this.updateStickyStatus(comment);
this.updateCommentCell(comment);
if (comment.sticky)
MessageBox(notificationDiv, 'This comment is now sticky.');
else
MessageBox(notificationDiv, 'This comment is no longer sticky.');
$.post('?comment=sticky', { id: comment.id, sticky: comment.sticky ? 1 : 0 });
},
createNote: function(div) {
var sm = $WH.ce('small');
if (!g_user.commentban) {
var a = $WH.ce('a');
if (g_user.id > 0) {
a.href = 'javascript:;';
a.onclick = co_addYourComment;
}
else {
a.href = '?account=signin';
}
$WH.ae(a, $WH.ct(LANG.lvcomment_add));
$WH.ae(sm, a);
var sp = $WH.ce('span');
sp.style.padding = '0 5px';
sp.style.color = 'white';
$WH.ae(sp, $WH.ct('|'));
$WH.ae(sm, sp);
}
$WH.ae(sm, $WH.ct(LANG.sort + LANG.colon));
var aSort1 = $WH.ce('a');
aSort1.href = 'javascript:;';
$WH.ae(aSort1, $WH.ct(LANG.newestfirst_stc));
aSort1.onclick = Listview.funcBox.coSortNewestFirst.bind(this, aSort1);
$WH.ae(sm, aSort1);
$WH.ae(sm, $WH.ct(LANG.comma));
var aSort2 = $WH.ce('a');
aSort2.href = 'javascript:;';
$WH.ae(aSort2, $WH.ct(LANG.oldestfirst_stc));
aSort2.onclick = Listview.funcBox.coSortOldestFirst.bind(this, aSort2);
$WH.ae(sm, aSort2);
$WH.ae(sm, $WH.ct(LANG.comma));
var aSort3 = $WH.ce('a');
aSort3.href = 'javascript:;';
$WH.ae(aSort3, $WH.ct(LANG.highestrated_stc));
aSort3.onclick = Listview.funcBox.coSortHighestRatedFirst.bind(this, aSort3);
$WH.ae(sm, aSort3)
var sort = $WH.gc()['comments_sort'];
switch (sort) {
case '1':
aSort1.onclick();
break;
case '2':
aSort2.onclick();
break;
default:
case '3':
aSort3.onclick();
break;
}
var sp = $WH.ce('span');
sp.style.padding = '0 5px';
sp.style.color = 'white';
$WH.ae(sp, $WH.ct('|'));
$WH.ae(sm, sp);
var select = $WH.ce('select');
var option = $WH.ce('option');
option.value = 0;
option.selected = 'selected';
$WH.ae(select, option);
var patchesSeen = {};
for (var d = 0; d < this.data.length; ++d) {
var postedOn = new Date(this.data[d].date).getTime();
patchesSeen[g_getPatchVersionIndex(postedOn)] = true;
}
var patches = [];
for (var p in patchesSeen) {
patches.push(p);
}
patches.sort(function(a, b) {
return b - a;
});
for (var p = 0; p < patches.length; ++p) {
var option = $WH.ce('option');
option.value = patches[p];
$WH.ae(option, $WH.ct(g_getPatchVersion.V[patches[p]]));
$WH.ae(select, option);
}
select.onchange = Listview.funcBox.coFilterByPatchVersion.bind(this, select);
$WH.ae(sm, $WH.ct(LANG.lvcomment_patchfilter));
$WH.ae(sm, select);
$WH.ae(div, sm);
if (this.tabClick) {
$('a, select', sm).click(this.tabClick);
}
},
onNoData: function(div) {
var s = '
' + LANG.lvnodata_co1 + '';
if (g_user.id > 0) {
var foo = LANG.lvnodata_co2;
foo = foo.replace('
', '');
s += foo;
}
else {
var foo = LANG.lvnodata_co3;
foo = foo.replace('', '');
foo = foo.replace('', '');
s += foo;
}
div.style.padding = '1.5em 0';
div.innerHTML = s;
},
onBeforeCreate: function() {
if (location.hash && location.hash.match(/:id=([0-9]+)/) != null) {
var sort = $WH.gc()['comments_sort'];
switch (sort) {
case '1':
this.setSort([-5, 4, -1, -2], false, false);
break;
case '2':
this.setSort([-5, 4, 1, 2], false, false);
break;
default:
case '3':
this.setSort([-5, 4, -3, 2], false, false);
break;
}
var rowNo = $WH.in_array(this.data, parseInt(RegExp.$1), function(x) {
return x.id;
});
this.rowOffset = this.getRowOffset(rowNo);
return this.data[rowNo];
}
},
onAfterCreate: function(result) {
if (result != null) {
var div = result.__div;
this.tabs.__st = div;
}
}
},
commentpreview: {
sort: [4],
nItemsPerPage: 75,
columns: [
{
id: 'subject',
name: LANG.subject,
align: 'left',
value: 'subject',
compute: function(comment, td) {
var a = $WH.ce('a');
a.style.fontFamily = 'Verdana, sans-serif';
a.href = this.getItemLink(comment);
$WH.ae(a, $WH.ct(comment.subject));
$WH.ae(td, a);
if (LANG.types[comment.type]) {
var d = $WH.ce('div');
d.className = 'small';
$WH.ae(d, $WH.ct(LANG.types[comment.type][0]));
$WH.ae(td, d);
}
}
},
{
id: 'preview',
name: LANG.preview,
align: 'left',
width: '50%',
value: 'preview',
compute: function(comment, td, tr) {
var d = $WH.ce('div');
d.className = 'crop';
if (comment.rating >= 10) {
d.className += ' comment-green';
}
$WH.ae(d, $WH.ct(
Markup.removeTags(comment.preview, {mode: Markup.MODE_ARTICLE})
));
$WH.ae(td, d);
if (comment.rating !== null || comment.deleted) {
d = $WH.ce('div');
d.className = 'small3';
if (comment.rating) {
$WH.ae(d, $WH.ct(LANG.lvcomment_rating + (comment.rating > 0 ? '+' : '') + comment.rating));
}
var
s = $WH.ce('span'),
foo = '';
s.className = 'q10';
if (comment.deleted) {
foo = LANG.lvcomment_deleted;
}
$WH.ae(s, $WH.ct(foo));
$WH.ae(d, s);
tr.__status = s;
$WH.ae(td, d);
}
}
},
{
id: 'author',
name: LANG.author,
value: 'user',
compute: function(comment, td) {
td.className = 'q1';
var a = $WH.ce('a');
a.href = '?user=' + comment.user;
$WH.ae(a, $WH.ct(comment.user));
$WH.ae(td, a);
}
},
{
id: 'posted',
name: LANG.posted,
width: '16%',
value: 'elapsed',
compute: function(comment, td) {
var
postedOn = new Date(comment.date),
elapsed = (g_serverTime - postedOn) / 1000;
var s = $WH.ce('span');
g_formatDate(s, elapsed, postedOn, 0, 1);
$WH.ae(td, s);
}
}
],
getItemLink: function(comment) {
return '?' + g_types[comment.type] + '=' + comment.typeId + (comment.id != null ? '#comments:id=' + comment.id : '')
}
},
replypreview: {
sort: [4],
nItemsPerPage: 75,
columns: [
{
id: 'subject',
name: LANG.subject,
align: 'left',
value: 'subject',
compute: function(reply, td)
{
var a = $WH.ce('a');
a.style.fontFamily = 'Verdana, sans-serif';
a.href = this.getItemLink(reply);
$WH.ae(a, $WH.ct(reply.subject));
$WH.ae(td, a);
if (LANG.types[reply.type])
{
var d = $WH.ce('div');
d.className = 'small';
$WH.ae(d, $WH.ct(LANG.types[reply.type][0]));
$WH.ae(td, d);
}
}
},
{
id: 'preview',
name: LANG.preview,
align: 'left',
width: '50%',
value: 'preview',
compute: function(reply, td, tr)
{
var d = $WH.ce('div');
d.className = 'crop';
if (reply.rating >= 10)
d.className += ' comment-green';
$WH.ae(d, $WH.ct( Markup.removeTags(reply.preview, {mode: Markup.MODE_ARTICLE}) ));
$WH.ae(td, d);
if (reply.rating)
{
d = $WH.ce('div');
d.className = 'small3';
$WH.ae(d, $WH.ct(LANG.lvcomment_rating + (reply.rating > 0 ? '+' : '') + reply.rating));
var s = $WH.ce('span'), foo = '';
s.className = 'q10';
$WH.ae(s, $WH.ct(foo));
$WH.ae(d, s);
tr.__status = s;
$WH.ae(td, d);
}
}
},
{
id: 'author',
name: LANG.author,
value: 'user',
compute: function(reply, td)
{
td.className = 'q1';
var a = $WH.ce('a');
a.href = '?user=' + reply.user;
$WH.ae(a, $WH.ct(reply.user))
$WH.ae(td, a);
}
},
{
id: 'posted',
name: LANG.posted,
width: '16%',
value: 'elapsed',
compute: function(reply, td)
{
var postedOn = new Date(reply.date),
elapsed = (g_serverTime - postedOn) / 1000;
var s = $WH.ce('span');
g_formatDate(s, elapsed, postedOn, 0, 1);
$WH.ae(td, s);
}
}
],
getItemLink: function(reply)
{
if (reply.url)
return '?' + reply.url;
if (!g_types[reply.type])
return '?go-to-reply&id=' + reply.id;
return $WH.sprintf('?$1=$2#comments:id=$3:reply=$4', g_types[reply.type], reply.typeId, reply.commentid, reply.id);
}
},
screenshot: {
sort: [],
mode: 3, // Grid mode
nItemsPerPage: 40,
nItemsPerRow: 4,
poundable: 2, // Yes but w/o sort
columns: [],
compute: function(screenshot, td, i) {
var
_,
postedOn = new Date(screenshot.date),
elapsed = (g_serverTime - postedOn) / 1000;
td.className = 'screenshot-cell';
td.vAlign = 'bottom';
var a = $WH.ce('a');
a.href = '#screenshots:id=' + screenshot.id;
a.onclick = $WH.rf2;
var
img = $WH.ce('img'),
scale = Math.min(150 / screenshot.width, 150 / screenshot.height);
img.src = g_staticUrl + '/uploads/screenshots/thumb/' + screenshot.id + '.jpg';
//img.width = Math.round(scale * screenshot.width);
//img.height = Math.round(scale * screenshot.height);
$WH.ae(a, img);
$WH.ae(td, a);
var d = $WH.ce('div');
d.className = 'screenshot-cell-user';
var hasUser = (screenshot.user != null && screenshot.user.length);
if (hasUser) {
a = $WH.ce('a');
a.href = '?user=' + screenshot.user;
$WH.ae(a, $WH.ct(screenshot.user));
$WH.ae(d, $WH.ct(LANG.lvscreenshot_from));
$WH.ae(d, a);
$WH.ae(d, $WH.ct(' '));
}
var s = $WH.ce('span');
if (hasUser) {
g_formatDate(s, elapsed, postedOn);
}
else {
g_formatDate(s, elapsed, postedOn, 0, 1);
}
$WH.ae(d, s);
$WH.ae(d, $WH.ct(' ' + LANG.dash + ' '));
var a = $WH.ce('a');
a.href = 'javascript:;';
a.onclick = ContactTool.show.bind(ContactTool, {
mode: 3,
screenshot: screenshot
});
a.className = 'icon-report';
g_addTooltip(a, LANG.report_tooltip, 'q2');
$WH.ae(a, $WH.ct(LANG.report));
$WH.ae(d, a);
$WH.ae(td, d);
d = $WH.ce('div');
d.style.position = 'relative';
d.style.height = '1em';
var hasCaption = (screenshot.caption != null && screenshot.caption.length);
var hasSubject = (screenshot.subject != null && screenshot.subject.length);
if (hasCaption || hasSubject) {
var d2 = $WH.ce('div');
d2.className = 'screenshot-caption';
if (hasSubject) {
var foo1 = $WH.ce('small');
$WH.ae(foo1, $WH.ct(LANG.types[screenshot.type][0] + LANG.colon));
var foo2 = $WH.ce('a');
$WH.ae(foo2, $WH.ct(screenshot.subject));
foo2.href = '?' + g_types[screenshot.type] + '=' + screenshot.typeId;
$WH.ae(foo1, foo2);
$WH.ae(d2, foo1);
if (hasCaption && screenshot.caption.length) {
$WH.ae(foo1, $WH.ct(' (...)'));
}
$WH.ae(foo1, $WH.ce('br'));
}
if (hasCaption) {
$WH.aE(td, 'mouseover', Listview.funcBox.ssCellOver.bind(d2));
$WH.aE(td, 'mouseout', Listview.funcBox.ssCellOut.bind(d2));
var foo = $WH.ce('span');
foo.innerHTML = Markup.toHtml(screenshot.caption, {
mode: Markup.MODE_SIGNATURE
});
$WH.ae(d2, foo);
}
$WH.ae(d, d2);
}
$WH.aE(td, 'click', Listview.funcBox.ssCellClick.bind(this, i));
$WH.ae(td, d);
},
createNote: function(div) {
if (typeof g_pageInfo == 'object' && g_pageInfo.type > 0) {
var sm = $WH.ce('small');
var a = $WH.ce('a');
if (g_user.id > 0) {
a.href = 'javascript:;';
a.onclick = ss_submitAScreenshot;
}
else {
a.href = '?account=signin';
}
$WH.ae(a, $WH.ct(LANG.lvscreenshot_submit));
$WH.ae(sm, a);
$WH.ae(div, sm);
}
},
onNoData: function(div) {
if (typeof g_pageInfo == 'object' && g_pageInfo.type > 0) {
var s = '' + LANG.lvnodata_ss1 + '';
if (g_user.id > 0) {
var foo = LANG.lvnodata_ss2;
foo = foo.replace('', '');
s += foo;
}
else {
var foo = LANG.lvnodata_ss3;
foo = foo.replace('', '');
foo = foo.replace('', '');
s += foo;
}
div.style.padding = '1.5em 0';
div.innerHTML = s;
}
else {
return -1;
}
},
onBeforeCreate: function() {
if (location.hash && location.hash.match(/:id=([0-9]+)/) != null) {
var rowNo = $WH.in_array(this.data, parseInt(RegExp.$1), function(x) {
return x.id;
});
this.rowOffset = this.getRowOffset(rowNo);
return rowNo;
}
},
onAfterCreate: function(rowNo) {
if (rowNo != null) {
setTimeout((function() {
ScreenshotViewer.show({
screenshots: this.data,
pos: rowNo
})
}).bind(this), 1);
}
}
},
sound: {
searchable: 1,
filtrable: 1,
columns: [
{
id: 'name',
name: LANG.name,
type: 'text',
align: 'left',
value: 'name',
compute: function (sound, td) {
var a = $WH.ce('a');
a.className = 'listview-cleartext';
a.href = '?sound=' + sound.id;
$WH.st(a, sound.name);
$WH.ae(td, a);
}
},
{
id: 'type',
name: LANG.type,
type: 'text',
compute: function (sound, td) {
var type = '';
if (!this.hasOwnProperty('soundtypecache')) {
var cache = {};
for (var i in mn_sounds)
if (mn_sounds[i][0] < 1000)
cache[mn_sounds[i][0]] = mn_sounds[i][1];
this.soundtypecache = cache;
}
if (this.soundtypecache.hasOwnProperty(sound.type))
type = this.soundtypecache[sound.type];
$WH.st(td, type);
},
sortFunc: function (a, b) {
if (!this.hasOwnProperty('soundtypecache')) {
var cache = {};
for (var i in mn_sounds)
if (mn_sounds[i][0] < 1000)
cache[mn_sounds[i][0]] = mn_sounds[i][1];
this.soundtypecache = cache;
}
var aType = (this.soundtypecache.hasOwnProperty(a.type)) ? this.soundtypecache[a.type] : '';
var bType = (this.soundtypecache.hasOwnProperty(b.type)) ? this.soundtypecache[b.type] : '';
return $WH.strcmp(aType, bType) || $WH.strcmp(a.name, b.name);
}
},
{
id: 'activity',
name: LANG.activity,
hidden: true,
type: 'text',
compute: function (sound, td) {
if (!sound.hasOwnProperty('activity'))
return '';
if (LANG.sound_activities.hasOwnProperty(sound.activity))
return LANG.sound_activities[sound.activity];
else
return sound.activity;
},
sortFunc: function (a, b) {
return $WH.strcmp(this.compute(a), this.compute(b));
}
},
{
id: 'sound',
name: LANG.types[19][2],
span: 2,
compute: function (sound, td, tr) {
var td2 = $WH.ce('td');
td2.className = 'nowrap';
$WH.ae(tr, td2);
td2.style.borderRight = 'none';
td.className = 'nowrap';
td.style.borderLeft = 'none';
var div = $WH.ce('div');
$WH.ae(td2, div);
(new AudioControls()).init(sound.files, div, { listview: this, trackdisplay: td });
}
}
],
getItemLink: function (sound) {
return '?sound=' + sound.id;
}
},
video: {
sort: [],
mode: 3, // Grid mode
nItemsPerPage: 40,
nItemsPerRow: 4,
poundable: 2, // Yes but w/o sort
columns: [],
compute: function(video, td, i) {
var
_,
postedOn = new Date(video.date),
elapsed = (g_serverTime - postedOn) / 1000;
td.className = 'screenshot-cell';
td.vAlign = 'bottom';
var a = $WH.ce('a');
a.href = '#videos:id=' + video.id;
a.onclick = $WH.rf2;
var img = $WH.ce('img');
img.src = $WH.sprintf(vi_thumbnails[video.videoType], video.videoId);
$WH.ae(a, img);
$WH.ae(td, a);
var d = $WH.ce('div');
d.className = 'screenshot-cell-user';
var hasUser = (video.user != null && video.user.length);
if (hasUser) {
a = $WH.ce('a');
a.href = '?user=' + video.user;
$WH.ae(a, $WH.ct(video.user));
$WH.ae(d, $WH.ct(LANG.lvvideo_from));
$WH.ae(d, a);
$WH.ae(d, $WH.ct(' '));
}
var s = $WH.ce('span');
if (hasUser) {
g_formatDate(s, elapsed, postedOn);
}
else {
g_formatDate(s, elapsed, postedOn, 0, 1);
}
$WH.ae(d, s);
$WH.ae(d, $WH.ct(' ' + LANG.dash + ' '));
var a = $WH.ce('a');
a.href = 'javascript:;';
a.onclick = ContactTool.show.bind(ContactTool, {mode: 5, video: video});
a.className = 'icon-report';
g_addTooltip(a, LANG.report_tooltip, 'q2');
$WH.ae(a, $WH.ct(LANG.report));
$WH.ae(d, a);
$WH.ae(td, d);
d = $WH.ce('div');
d.style.position = 'relative';
d.style.height = '1em';
var hasCaption = (video.caption != null && video.caption.length);
var hasSubject = (video.subject != null && video.subject.length);
if (hasCaption || hasSubject) {
var d2 = $WH.ce('div');
d2.className = 'screenshot-caption';
if (hasSubject) {
var foo1 = $WH.ce('small');
$WH.ae(foo1, $WH.ct(LANG.types[video.type][0] + LANG.colon));
var foo2 = $WH.ce('a');
$WH.ae(foo2, $WH.ct(video.subject));
foo2.href = '?' + g_types[video.type] + '=' + video.typeId;
$WH.ae(foo1, foo2);
$WH.ae(d2, foo1);
if (hasCaption && video.caption.length) {
$WH.ae(foo1, $WH.ct(' (...)'));
}
$WH.ae(foo1, $WH.ce('br'));
}
if (hasCaption) {
$WH.aE(td, 'mouseover', Listview.funcBox.ssCellOver.bind(d2));
$WH.aE(td, 'mouseout', Listview.funcBox.ssCellOut.bind(d2));
var foo = $WH.ce('span');
foo.innerHTML = Markup.toHtml(video.caption, {
mode: Markup.MODE_SIGNATURE
});
$WH.ae(d2, foo);
}
$WH.ae(d, d2);
}
$WH.aE(td, 'click', Listview.funcBox.viCellClick.bind(this, i));
$WH.ae(td, d);
},
createNote: function(div) {
if (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO)) {
if (typeof g_pageInfo == 'object' && g_pageInfo.type > 0) {
var sm = $WH.ce('small');
var a = $WH.ce('a');
if (g_user.id > 0) {
a.href = 'javascript:;';
a.onclick = vi_submitAVideo;
}
else {
a.href = '?account=signin';
}
$WH.ae(a, $WH.ct(LANG.lvvideo_suggest));
$WH.ae(sm, a);
$WH.ae(div, sm);
}
}
},
onNoData: function(div) {
if (typeof g_pageInfo == 'object' && g_pageInfo.type > 0) {
var s = '' + LANG.lvnodata_vi1 + '';
if (g_user.id > 0) {
var foo = LANG.lvnodata_vi2;
foo = foo.replace('', '');
s += foo;
}
else {
var foo = LANG.lvnodata_vi3;
foo = foo.replace('', '');
foo = foo.replace('', '');
s += foo;
}
div.style.padding = '1.5em 0';
div.innerHTML = s;
}
else {
return -1;
}
},
onBeforeCreate: function() {
if (location.hash && location.hash.match(/:id=([0-9]+)/) != null) {
var rowNo = $WH.in_array(this.data, parseInt(RegExp.$1), function(x) {
return x.id;
});
this.rowOffset = this.getRowOffset(rowNo);
return rowNo;
}
},
onAfterCreate: function(rowNo) {
if (rowNo != null) {
setTimeout((function() {
VideoViewer.show({
videos: this.data,
pos: rowNo
})
}).bind(this), 1);
}
}
},
pet: {
sort: [1],
nItemsPerPage: -1,
searchable: 1,
filtrable: 1,
columns: [
{
id: 'name',
name: LANG.name,
type: 'text',
align: 'left',
value: 'name',
span: 2,
compute: function(pet, td, tr) {
var i = $WH.ce('td');
i.style.width = '1px';
i.style.padding = '0';
i.style.borderRight = 'none';
$WH.ae(i, Icon.create(pet.icon, 0));
$WH.ae(tr, i);
td.style.borderLeft = 'none';
var wrapper = $WH.ce('div');
var a = $WH.ce('a');
a.style.fontFamily = 'Verdana, sans-serif';
a.href = this.getItemLink(pet);
$WH.ae(a, $WH.ct(pet.name));
if (pet.expansion) {
var sp = $WH.ce('span');
sp.className = g_GetExpansionClassName(pet.expansion);
$WH.ae(sp, a);
$WH.ae(wrapper, sp);
}
else {
$WH.ae(wrapper, a);
}
if (pet.exotic) {
wrapper.style.position = 'relative';
var d = $WH.ce('div');
d.className = 'small q1';
d.style.fontStyle = 'italic';
d.style.position = 'absolute';
d.style.right = '3px';
d.style.bottom = '0px';
var a = $WH.ce('a');
a.href = '?spell=53270';
$WH.ae(a, $WH.ct(LANG.lvpet_exotic));
$WH.ae(d, a);
$WH.ae(wrapper, d);
}
$WH.ae(td, wrapper);
},
getVisibleText: function(pet) {
var buff = pet.name + Listview.funcBox.getExpansionText(pet);
if (pet.exotic) {
buff += ' ' + LANG.lvpet_exotic;
}
return buff;
}
},
{
id: 'level',
name: LANG.level,
type: 'range',
getMinValue: function(pet) {
return pet.minlevel;
},
getMaxValue: function(pet) {
return pet.maxlevel;
},
compute: function(pet, td) {
if (pet.minlevel > 0 && pet.maxlevel > 0) {
if (pet.minlevel != pet.maxlevel) {
return pet.minlevel + LANG.hyphen + pet.maxlevel;
}
else {
return pet.minlevel;
}
}
else {
return -1;
}
},
sortFunc: function(a, b, col) {
if (col > 0) {
return $WH.strcmp(a.minlevel, b.minlevel) || $WH.strcmp(a.maxlevel, b.maxlevel);
}
else {
return $WH.strcmp(a.maxlevel, b.maxlevel) || $WH.strcmp(a.minlevel, b.minlevel);
}
}
},
{
id: 'damage', // essentially unused, but if someone wants to backport classic
name: LANG.damage,
value: 'damage',
hidden: 1,
compute: function (pet, col) {
$WH.ae(col, this.template.getStatPct(pet.damage))
}
},
{
id: 'armor', // essentially unused, but if someone wants to backport classic
name: LANG.armor,
value: 'armor',
hidden: 1,
compute: function (pet, col) {
$WH.ae(col, this.template.getStatPct(pet.armor))
}
},
{
id: 'health', // essentially unused, but if someone wants to backport classic
name: LANG.health,
value: 'health',
hidden: 1,
compute: function (pet, col) {
$WH.ae(col, this.template.getStatPct(pet.health))
}
},
{
id: 'abilities',
name: LANG.abilities,
type: 'text',
getValue: function(pet) {
if (!pet.spells) {
return '';
}
if (pet.spells.length > 0) {
var spells = '';
for (var i = 0, len = pet.spells.length; i < len; ++i) {
if (pet.spells[i]) {
spells += g_spells[pet.spells[i]]['name_' + Locale.getName()];
}
}
return spells;
}
},
compute: function(pet, td) {
if (!pet.spells) {
return '';
}
if (pet.spells.length > 0) {
td.style.padding = '0';
Listview.funcBox.createCenteredIcons(pet.spells, td, '', 1);
}
},
sortFunc: function(a, b) {
if (!a.spells || !b.spells) {
return 0;
}
return $WH.strcmp(a.spellCount, b.spellCount) || $WH.strcmp(a.spells, b.spells);
},
hidden: true
},
{
id: 'diet',
name: LANG.diet,
type: 'text',
compute: function(pet, td) {
if (td) {
td.className = 'small';
}
var
i = 0,
foods = '';
for (var food in g_pet_foods) {
if (pet.diet & food) {
if (i++ > 0) {
foods += LANG.comma;
}
foods += g_pet_foods[food];
}
}
return foods;
},
sortFunc: function(a, b) {
return $WH.strcmp(b.foodCount, a.foodCount) || Listview.funcBox.assocArrCmp(a.diet, b.diet, g_pet_foods);
}
},
{
id: 'type',
name: LANG.type,
type: 'text',
compute: function(pet, td) {
if (pet.type != null) {
td.className = 'small q1';
var a = $WH.ce('a');
a.href = '?pets=' + pet.type;
$WH.ae(a, $WH.ct(g_pet_types[pet.type]));
$WH.ae(td, a);
}
},
getVisibleText: function(pet) {
if (pet.type != null) {
return g_pet_types[pet.type];
}
},
sortFunc: function(a, b, col) {
return $WH.strcmp(g_pet_types[a.type], g_pet_types[b.type]);
}
}
],
getItemLink: function(pet) {
return '?pet=' + pet.id;
},
getStatPct: function(modifier) {
var _ = $WH.ce('span');
if (!isNaN(modifier) && modifier > 0) {
_.className = 'q2';
$WH.ae(_, $WH.ct('+' + modifier + '%'));
}
else if (!isNaN(modifier) && modifier < 0) {
_.className = 'q10';
$WH.ae(_, $WH.ct(modifier + '%'));
}
return _;
}
},
achievement: {
sort: [1, 2],
nItemsPerPage: 100,
searchable: 1,
filtrable: 1,
columns: [
{
id: 'name',
name: LANG.name,
type: 'text',
align: 'left',
value: 'name',
span: 2,
compute: function(achievement, td, tr) {
var rel = null;
if (achievement.who && achievement.completed) {
rel = 'who=' + achievement.who + '&when=' + achievement.completed.getTime();
}
var i = $WH.ce('td');
i.style.width = '1px';
i.style.padding = '0';
i.style.borderRight = 'none';
$WH.ae(i, g_achievements.createIcon(achievement.id, 1));
Icon.getLink(i.firstChild).href = this.getItemLink(achievement);
Icon.getLink(i.firstChild).rel = rel;
$WH.ae(tr, i);
td.style.borderLeft = 'none';
var a = $WH.ce('a');
a.style.fontFamily = 'Verdana, sans-serif';
a.href = this.getItemLink(achievement);
a.rel = rel;
$WH.ae(a, $WH.ct(achievement.name));
$WH.ae(td, a);
if (achievement.description != null) {
var d = $WH.ce('div');
d.className = 'small';
$WH.ae(d, $WH.ct(achievement.description));
$WH.ae(td, d);
}
},
getVisibleText: function(achievement) {
var buff = achievement.name;
if (achievement.description) {
buff += ' ' + achievement.description;
}
return buff;
}
},
{
id: 'location',
name: LANG.location,
type: 'text',
width: '15%',
hidden: 1,
compute: function (achievement, td) {
if (achievement.zone) {
var a = $WH.ce('a');
a.className = 'q1';
a.href = '?zones=' + achievement.zone;
$WH.ae(a, $WH.ct(g_zones[achievement.zone]));
$WH.ae(td, a);
}
},
getVisibleText: function (achievement) {
return Listview.funcBox.arrayText(achievement.zone, g_zones);
},
sortFunc: function (a, b, col) {
return Listview.funcBox.assocArrCmp(a.zone, b.zone, g_zones);
}
},
{
id: 'side',
name: LANG.side,
type: 'text',
compute: function(achievement, td) {
if (achievement.side && achievement.side != 3) {
var sp = $WH.ce('span');
sp.className = (achievement.side == 1 ? 'icon-alliance' : 'icon-horde');
g_addTooltip(sp, g_sides[achievement.side]);
$WH.ae(td, sp);
}
},
getVisibleText: function(achievement) {
if (achievement.side) {
return g_sides[achievement.side];
}
},
sortFunc: function(a, b, col) {
return $WH.strcmp(g_sides[a.side], g_sides[b.side]);
}
},
{
id: 'points',
name: LANG.points,
type: 'number',
width: '10%',
value: 'points',
compute: function(achievement, td) {
if (achievement.points) {
Listview.funcBox.appendMoney(td, 0, null, 0, 0, achievement.points);
}
}
},
{
id: 'rewards',
name: LANG.rewards,
type: 'text',
width: '20%',
compute: function(achievement, td) {
if (achievement.rewards) {
var itemrewards = [];
var spellrewards = []; // not used in 3.3.5
var titlerewards = [];
for (var i = 0; i < achievement.rewards.length; i++) {
if (achievement.rewards[i][0] == 11) {
titlerewards.push(achievement.rewards[i][1]);
}
else if (achievement.rewards[i][0] == 3) {
itemrewards.push(achievement.rewards[i][1]);
}
else if (achievement.rewards[i][0] == 6) {
spellrewards.push(achievement.rewards[i][1]);
}
}
if (itemrewards.length > 0) {
for (var i = 0; i < itemrewards.length; i++) {
if (!g_items[itemrewards[i]]) {
return;
}
var item = g_items[itemrewards[i]];
var a = $WH.ce('a');
a.href = '?item=' + itemrewards[i];
a.className = 'q' + item.quality + ' icontiny tinyspecial';
a.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/tiny/' + item.icon.toLowerCase() + '.gif)';
$WH.ae(a, $WH.ct(item['name_' + Locale.getName()]));
var span = $WH.ce('span');
$WH.ae(span, a);
$WH.ae(td, span);
$WH.ae(td, $WH.ce('br'));
}
}
if (spellrewards.length > 0) {
for (var i = 0; i < spellrewards.length; i++) {
if (!g_spells[spellrewards[i]]) {
return;
}
var item = g_spells[spellrewards[i]];
var a = $WH.ce('a');
a.href = '?spell=' + spellrewards[i];
a.className = 'q8 icontiny tinyspecial';
a.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/tiny/' + item.icon.toLowerCase() + '.gif)';
$WH.ae(a, $WH.ct(item['name_' + Locale.getName()]));
var span = $WH.ce('span');
$WH.ae(span, a);
$WH.ae(td, span);
$WH.ae(td, $WH.ce('br'));
}
}
if (titlerewards.length > 0) {
for (var i = 0; i < titlerewards.length; i++) {
if (!g_titles[titlerewards[i]]) {
return;
}
var title = g_titles[titlerewards[i]]['name_' + Locale.getName()];
title = title.replace('%s', '<' + LANG.name + '>');
var span = $WH.ce('a');
span.className = 'q1';
span.href = '?title=' + titlerewards[i];
span.innerHTML = title;
$WH.ae(td, span);
$WH.ae(td, $WH.ce('br'));
}
}
}
else if (achievement.reward) {
var span = $WH.ce('span');
span.className = 'q1';
$WH.ae(span, $WH.ct(achievement.reward));
$WH.ae(td, span);
}
},
getVisibleText: function(achievement) {
var buff = '';
if (achievement.rewards) {
for (var i = 0; i < achievement.rewards.length; i++) {
if (achievement.rewards[i][0] == 11) {
buff += ' ' + g_titles[achievement.rewards[i][1]]['name_' + Locale.getName()].replace('%s', '<' + LANG.name + '>');
}
else if (achievement.rewards[i][0] == 3) {
buff += ' ' + g_items[achievement.rewards[i][1]]['name_' + Locale.getName()];
}
else if (achievement.rewards[i][0] == 6) {
buff += ' ' + g_spells[achievement.rewards[i][1]]['name_' + Locale.getName()];
}
}
}
else if (achievement.reward) {
buff += ' ' + achievement.reward;
}
return buff;
},
sortFunc: function(a, b, col) {
var text1 = this.getVisibleText(a);
var text2 = this.getVisibleText(b);
if (text1 != '' && text2 == '') {
return -1;
}
if (text2 != '' && text1 == '') {
return 1;
}
return $WH.strcmp(text1, text2);
}
},
{
id: 'category',
name: LANG.category,
type: 'text',
width: '15%',
compute: function(achievement, td) {
statistic = achievement.type ? achievement.type + '.' : '';
td.className = 'small';
path = '?achievements=' + statistic;
if (achievement.category != -1 && achievement.parentcat != -1) {
var a2 = $WH.ce('a');
a2.className = 'q0';
a2.href = '?achievements=' + statistic + achievement.parentcat;
$WH.ae(a2, $WH.ct(g_achievement_categories[achievement.parentcat]));
$WH.ae(td, a2);
$WH.ae(td, $WH.ce('br'));
path = a2.href + '.';
}
var a = $WH.ce('a');
a.className = 'q1';
a.href = path + achievement.category;
$WH.ae(a, $WH.ct(g_achievement_categories[achievement.category]));
$WH.ae(td, a);
},
getVisibleText: function(achievement) {
return g_achievement_categories[achievement.category];
},
sortFunc: function(a, b, col) {
return $WH.strcmp(g_achievement_categories[a.category], g_achievement_categories[b.category]);
},
hidden: true
},
{
id: 'completed', // Listview.COLUMN_ID_COMPLETION
name: LANG.completion, // WH.TERMS.completion
hidden: true,
compute: function (achievement, td)
{
if (achievement.type)
return;
$WH.addCompletionIcons(td, 10, achievement.id)
},
sortFunc: function (a, b)
{
// return $WH.stringCompare(
return $WH.strcmp(
$WH.getCompletionFlags(10, a.id),
$WH.getCompletionFlags(10, b.id)
);
},
getValue: function (achievement) {
var value = 0;
var completionData = g_user.completion?.hasOwnProperty(10) ? g_user.completion[10] : {};
if (achievement.type)
return -1;
for (var i in g_user.characters)
{
var profile = g_user.characters[i];
if (!(profile.id in completionData))
continue;
if ($WH.in_array(completionData[profile.id], achievement.id) != -1)
value++;
}
return value;
}
}
],
getItemLink: function(achievement) {
return '?achievement=' + achievement.id;
},
onBeforeCreate: function () {
for (var i in this.columns)
{
if (this.columns[i].id == 'completed' && this.columns[i].hidden)
{
if ($WH.isset('g_user') && 'characters' in g_user && $WH.in_array(this.hiddenCols, this.columns[i].id) == -1)
{
var n = 0;
for (var j in this.data)
if (!this.data[j].type)
n++;
if (n > this.data.length * 0.1)
this.visibility.push(parseInt(i));
}
}
}
}
},
title: {
sort: [1],
nItemsPerPage: -1,
searchable: 1,
filtrable: 1,
columns: [
{
id: 'name',
name: LANG.name,
type: 'text',
align: 'left',
value: 'name',
compute: function(title, td, tr) {
var
sp = $WH.ce('a'),
n = $WH.ce('span'),
t = $WH.ct($WH.str_replace(title.name, '%s', ''));
td.style.fontFamily = 'Verdana, sans-serif';
// $WH.nw(td)
sp.href = this.getItemLink(title);
if (title.who) {
$WH.ae(n, $WH.ct(title.who));
}
else {
$WH.ae(n, $WH.ct('<' + LANG.name + '>'));
n.className = 'q0';
}
if (title.name.indexOf('%s') > 0) { // Prefix title
$WH.ae(sp, t);
$WH.ae(sp, n);
}
else if (title.name.indexOf('%s') == 0) { // Suffix title
$WH.ae(sp, n);
$WH.ae(sp, t);
}
if (title.expansion) {
var i = $WH.ce('span');
i.className = g_GetExpansionClassName(title.expansion);
$WH.ae(i, sp);
$WH.ae(td, i);
}
else {
$WH.ae(td, sp);
}
},
sortFunc: function(a, b, col) {
var
aName = $WH.trim(a.name.replace('%s', '').replace(/^[\s,]*(,|the |of the |of )/i, ''));
bName = $WH.trim(b.name.replace('%s', '').replace(/^[\s,]*(,|the |of the |of )/i, ''));
return $WH.strcmp(aName, bName);
},
getVisibleText: function(title) {
var buff = title.name + Listview.funcBox.getExpansionText(title);
return buff;
}
},
{
id: 'gender',
name: LANG.gender,
type: 'text',
value: 'gender',
compute: function(title, td) {
if (title.gender && title.gender != 3) {
var gender = g_file_genders[title.gender - 1];
var sp = $WH.ce('span');
sp.className = 'icon-' + gender;
g_addTooltip(sp, LANG[gender]);
$WH.ae(td, sp);
}
},
getVisibleText: function(title) {
if (title.gender && title.gender != 3) {
return LANG[g_file_genders[title.gender - 1]];
}
},
sortFunc: function(a, b, col) {
return $WH.strcmp(a.gender, b.gender);
}
},
{
id: 'side',
name: LANG.side,
type: 'text',
compute: function(title, td) {
if (title.side && title.side != 3) {
var sp = $WH.ce('span');
sp.className = (title.side == 1 ? 'icon-alliance' : 'icon-horde');
g_addTooltip(sp, g_sides[title.side]);
$WH.ae(td, sp);
}
},
getVisibleText: function(title) {
if (title.side) {
return g_sides[title.side];
}
},
sortFunc: function(a, b, col) {
return $WH.strcmp(g_sides[a.side], g_sides[b.side]);
}
},
{
id: 'source',
name: LANG.source,
type: 'text',
compute: function(title, td) {
if (title.source) {
$WH.nw(td);
td.className = 'small';
td.style.lineHeight = '18px';
var n = 0;
for (var s in title.source) {
title.source[s].sort(function(a, b) {
return b.s - a.s;
});
for (var i = 0, len = title.source[s].length; i < len; ++i) {
var sm = title.source[s][i];
var type = 0;
if (title.faction && typeof sm != 'string' && sm.s !== undefined && sm.s != -1 && sm.s != 2 - title.faction) {
continue;
}
if (n++ > 0) {
$WH.ae(td, $WH.ce('br'));
}
if (typeof sm == 'string') {
$WH.ae(td, $WH.ct(sm));
}
else if (sm.t) {
type = sm.t;
var a = $WH.ce('a');
// o.style.fontFamily = 'Verdana, sans-serif';
a.href = '?' + g_types[sm.t] + '=' + sm.ti;
a.className = 'q1';
if (sm.s == 1) {
a.className += ' icon-alliance'
}
if (sm.s == 0) {
a.className += ' icon-horde'
}
if (sm.t == 5) { // Quests
a.className += ' icontiny tinyspecial';
a.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/tiny/quest_start.gif)';
}
$WH.ae(a, $WH.ct(sm.n));
$WH.ae(td, a);
}
}
}
}
},
getVisibleText: function(title) {
var buff = '';
if (title.source) {
for (var s in title.source) {
for (var i = 0, len = title.source[s].length; i < len; ++i) {
var sm = title.source[s][i];
if (typeof sm == 'string') {
buff += ' ' + sm;
}
else if (sm.t){
buff += ' ' + sm.n;
}
}
}
}
return buff;
},
sortFunc: function(a, b, col) {
return $WH.strcmp(this.getVisibleText(a), this.getVisibleText(b));
}
},
{
id: 'category',
name: LANG.category,
type: 'text',
width: '15%',
compute: function(title, td) {
$WH.nw(td);
td.className = 'small q1';
var a = $WH.ce('a');
a.href = '?titles=' + title.category;
$WH.ae(a, $WH.ct(g_title_categories[title.category]));
$WH.ae(td, a);
},
getVisibleText: function(title) {
return g_title_categories[title.category];
},
sortFunc: function(a, b, col) {
return $WH.strcmp(g_title_categories[a.category], g_title_categories[b.category]);
},
hidden: true
},
{
id: 'completed', // Listview.COLUMN_ID_COMPLETION
name: LANG.completion, // WH.TERMS.completion
hidden: true,
compute: function (title, td)
{
$WH.addCompletionIcons(td, 11, title.id)
},
sortFunc: function (a, b)
{
// return $WH.stringCompare(
return $WH.strcmp(
$WH.getCompletionFlags(11, a.id),
$WH.getCompletionFlags(11, b.id)
);
},
getValue: function (title) {
var value = 0;
var completionData = g_user.completion?.hasOwnProperty(11) ? g_user.completion[11] : {};
for (var i in g_user.characters)
{
var profile = g_user.characters[i];
if (!(profile.id in completionData))
continue;
if ($WH.in_array(completionData[profile.id], title.id) != -1)
value++;
}
return value;
}
}
],
getItemLink: function(title) {
return '?title=' + title.id;
},
onBeforeCreate: function () {
for (var i in this.columns)
{
if (this.columns[i].id == 'completed' && this.columns[i].hidden)
{
if ($WH.isset('g_user') && 'characters' in g_user && $WH.in_array(this.hiddenCols, this.columns[i].id) == -1)
this.visibility.push(parseInt(i));
}
}
}
},
profile: {
sort: [],
nItemsPerPage: 50,
searchable: 1,
filtrable: 1,
columns: [
{
id: 'name',
name: LANG.name,
value: 'name',
type: 'text',
align: 'left',
span: 2,
compute: function(profile, td, tr) {
if (profile.level) {
var i = $WH.ce('td');
i.style.width = '1px';
i.style.padding = '0';
i.style.borderRight = 'none';
// $WH.ae(i, Icon.create($WH.g_getProfileIcon(profile.race, profile.classs, profile.gender, profile.level, profile.icon ? profile.icon : profile.id, 'medium'), 1, null, this.getItemLink(profile)));
// aowow - see profile=avatar endpoint for explanation
var ic = Icon.create($WH.g_getProfileIcon(profile.race, profile.classs, profile.gender, profile.level, profile.icon ? profile.icon : 0, 'medium'), 1, null, this.getItemLink(profile));
// aowow - custom
if (profile.captain) {
tr.className = 'mergerow';
ic.className += ' ' + ic.className + '-gold';
}
$WH.ae(i, ic);
$WH.ae(tr, i);
td.style.borderLeft = 'none';
}
else {
td.colSpan = 2;
}
var wrapper = $WH.ce('div');
wrapper.style.position = 'relative';
var a = $WH.ce('a');
a.style.fontFamily = 'Verdana, sans-serif';
a.href = this.getItemLink(profile);
if (profile.pinned) {
a.className = 'icon-star-right';
}
$WH.ae(a, $WH.ct(profile.name));
$WH.ae(wrapper, a);
var d = $WH.ce('div');
d.className = 'small';
d.style.marginRight = '20px';
if (profile.guild && typeof(profile.guild) != 'number') {
var a = $WH.ce('a');
a.className = 'q1';
a.href = '?guild=' + profile.region + '.' + profile.realm + '.' + g_urlize(profile.guild, true);
$WH.ae(a, $WH.ct(profile.guild));
$WH.ae(d, $WH.ct('<'));
$WH.ae(d, a);
$WH.ae(d, $WH.ct('>'));
}
else if (profile.description) {
$WH.ae(d, $WH.ct(profile.description));
}
var
s = $WH.ce('span'),
foo = '';
s.className = 'q10';
if (profile.deleted) {
foo = LANG.lvcomment_deleted;
}
$WH.ae(s, $WH.ct(foo));
$WH.ae(d, s);
$WH.ae(wrapper, d);
var d = $WH.ce('div');
d.className = 'small';
d.style.fontStyle = 'italic';
d.style.position = 'absolute';
d.style.right = '3px';
d.style.bottom = '0px';
tr.__status = d;
if (profile.published === 0) {
$WH.ae(d, $WH.ct(LANG.privateprofile));
}
// aowow custom
if (profile.renameItr) {
$WH.ae(d, $WH.ce('span', { className: 'q0'}, $WH.ct(LANG.pr_note_pendingrename)));
}
// end aowow custom
$WH.ae(wrapper, d);
$WH.ae(td, wrapper);
},
getVisibleText: function(profile) {
var buff = profile.name;
if (profile.guild && typeof(profile.guild) != 'number') {
buff += ' ' + profile.guild;
}
return buff;
}
},
{
id: 'faction',
name: LANG.faction,
type: 'text',
compute: function(profile, td) {
if (!profile.size && profile.members === undefined && !profile.level) {
return;
}
var
d = $WH.ce('div'),
d2 = $WH.ce('div'),
icon;
icon = Icon.create('faction_' + g_file_factions[parseInt(profile.faction) + 1], 0);
icon.style.cssFloat = icon.style.syleFloat = 'left';
g_addTooltip(icon, g_sides[parseInt(profile.faction) + 1]);
d.style.margin = '0 auto';
d.style.textAlign = 'left';
d.style.width = '26px';
d2.className = 'clear';
$WH.ae(d, icon);
$WH.ae(td, d);
$WH.ae(td, d2);
},
getVisibleText: function(profile) {
return g_sides[profile.faction + 1];
},
sortFunc: function(a, b, col) {
return $WH.strcmp(this.getVisibleText(a), this.getVisibleText(b));
}
},
{
id: 'members',
name: LANG.members,
value: 'members',
hidden: 1
},
{
id: 'size',
name: 'Size',
value: 'size',
hidden: 1
},
{
id: 'rank',
name: 'Rank',
value: 'rank',
hidden: 1
},
{
id: 'race',
name: LANG.race,
type: 'text',
compute: function(profile, td) {
if (profile.race) {
var
d = $WH.ce('div'),
d2 = $WH.ce('div'),
icon;
icon = Icon.create('race_' + g_file_races[profile.race] + '_' + g_file_genders[profile.gender], 0, null, '?race=' + profile.race);
icon.style.cssFloat = icon.style.syleFloat = 'left';
g_addTooltip(icon, g_chr_races[profile.race]);
d.style.margin = '0 auto';
d.style.textAlign = 'left';
d.style.width = '26px';
d2.className = 'clear';
$WH.ae(d, icon);
$WH.ae(td, d);
$WH.ae(td, d2);
}
},
getVisibleText: function(profile) {
return g_file_genders[profile.gender] + ' ' + g_chr_races[profile.race];
},
sortFunc: function(a, b, col) {
return $WH.strcmp(g_chr_races[a.race], g_chr_races[b.race]);
},
hidden: 1
},
{
id: 'classs',
name: LANG.classs,
type: 'text',
compute: function(profile, td) {
if (profile.classs) {
var
d = $WH.ce('div'),
d2 = $WH.ce('div'),
icon;
icon = Icon.create('class_' + g_file_classes[profile.classs], 0, null, '?class=' + profile.classs);
icon.style.cssFloat = icon.style.syleFloat = 'left';
g_addTooltip(icon, g_chr_classes[profile.classs], 'c' + profile.classs);
d.style.margin = '0 auto';
d.style.textAlign = 'left';
d.style.width = '26px';
d2.className = 'clear';
$WH.ae(d, icon);
$WH.ae(td, d);
$WH.ae(td, d2);
}
else {
return -1;
}
},
getVisibleText: function(profile) {
if (profile.classs) {
return g_chr_classes[profile.classs];
}
},
sortFunc: function(a, b, col) {
return $WH.strcmp(this.getVisibleText(a), this.getVisibleText(b));
},
hidden: 1
},
{
id: 'level',
name: LANG.level,
value: 'level',
hidden: 1
},
{
id: 'talents',
name: LANG.talents,
type: 'text',
compute: function(profile, td) {
if (!profile.level) {
return;
}
var spent = [profile.talenttree1, profile.talenttree2, profile.talenttree3];
var specData = pr_getSpecFromTalents(profile.classs, spent);
var a = $WH.ce('a');
a.className = 'icontiny tinyspecial tip q1';
// aowow - a.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/tiny/' + specData.icon.toLowerCase() + '.gif)';
a.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/tiny/' + (g_file_specs[profile.classs][specData.id - 1] ?? g_file_specs[specData.id]) + '.gif)';
a.rel = 'np';
a.href = this.getItemLink(profile) + '#talents';
g_addTooltip(a, specData.name);
$WH.ae(a, $WH.ct(profile.talenttree1 + ' / ' + profile.talenttree2 + ' / ' + profile.talenttree3));
$WH.ae(td, a);
},
getVisibleText: function(profile) {
if (profile.talenttree1 || profile.talenttree2 || profile.talenttree3) {
if (profile.talentspec > 0) {
return g_chr_specs[profile.classs][profile.talentspec - 1];
}
else {
return g_chr_specs[0];
}
}
else {
return g_chr_specs['-1'];
}
},
sortFunc: function(a, b, col) {
return $WH.strcmp(this.getVisibleText(a), this.getVisibleText(b));
},
hidden: 1
},
{
id: 'gearscore',
name: LANG.gearscore,
tooltip: LANG.gearscore_real,
value: 'gearscore',
compute: function(profile, td)
{
var level = (profile.level ? profile.level : (profile.members !== undefined ? 80 : 0));
if (isNaN(profile.gearscore) || !level)
return;
td.className = 'q' + pr_getGearScoreQuality(level, profile.gearscore, ($WH.in_array([2, 6, 7, 11], profile.classs) != -1));
return (profile.gearscore ? $WH.number_format(profile.gearscore) : 0);
},
hidden: 1
},
{
id: 'achievementpoints',
name: LANG.points,
value: 'achievementpoints',
tooltip: LANG.tooltip_achievementpoints,
compute: function(profile, td) {
if (profile.achievementpoints) {
Listview.funcBox.appendMoney(td, 0, null, 0, 0, profile.achievementpoints);
}
},
hidden: 1
},
{
id: 'wins',
name: LANG.wins,
value: 'wins',
hidden: 1
},
{
id: 'losses',
name: LANG.losses,
compute: function(profile, td) {
return profile.games - profile.wins;
},
sortFunc: function(a, b, col) {
var
lossA = a.games - a.wins,
lossB = b.games - b.wins;
if (lossA > lossB)
return 1;
if (lossA < lossB)
return -1;
return 0;
},
hidden: 1
},
{
id: 'guildrank',
name: LANG.guildrank,
value: 'guildrank',
compute: function(profile, td) {
// >>> aowow - real rank names >>>
if (typeof guild_ranks !== "undefined" && guild_ranks[profile.guildrank]) {
var sp = $WH.ce('span', null, $WH.ct(guild_ranks[profile.guildrank]));
g_addTooltip(sp, $WH.sprintf(LANG.rankno, profile.guildrank));
$WH.ae(td, sp);
}
// if (profile.guildrank > 0) {
// <<< aowow - real rank names <<<
else if (profile.guildrank > 0) {
return $WH.sprintf(LANG.rankno, profile.guildrank);
}
else if (profile.guildrank == 0) {
var b = $WH.ce('b');
$WH.ae(b, $WH.ct(LANG.guildleader));
$WH.ae(td, b);
}
},
getVisibleText: function(profile) {
if (profile.guildrank > 0) {
return $WH.sprintf(LANG.rankno, profile.guildrank);
}
else if (profile.guildrank == 0) {
return LANG.guildleader;
}
},
sortFunc: function(a, b, col) {
return $WH.strcmp((a.guildrank >= 0 ? a.guildrank : 11), (b.guildrank >= 0 ? b.guildrank : 11));
},
hidden: 1
},
{
id: 'rating',
name: LANG.rating,
value: 'rating',
hidden: 1
},
{
id: 'location',
name: LANG.location,
type: 'text',
compute: function(profile, td) {
var a;
if (profile.region) {
if (profile.realm) {
a = $WH.ce('a');
a.className = 'q1';
a.href = '?profiles=' + profile.region + '.' + profile.realm;
$WH.ae(a, $WH.ct(profile.realmname));
$WH.ae(td, a);
$WH.ae(td, $WH.ce('br'));
}
var s = $WH.ce('small');
a = $WH.ce('a');
a.className = 'q1';
a.href = '?profiles=' + profile.region;
$WH.ae(a, $WH.ct(profile.region.toUpperCase()));
$WH.ae(s, a);
if (profile.battlegroup) {
$WH.ae(s, $WH.ct(LANG.hyphen));
a = $WH.ce('a');
a.className = 'q1';
a.href = '?profiles=' + profile.region + '.' + profile.battlegroup;
$WH.ae(a, $WH.ct(profile.battlegroupname));
$WH.ae(s, a);
}
$WH.ae(td, s);
}
},
getVisibleText: function(profile) {
var buff = '';
if (profile.region) {
buff += ' ' + profile.region;
}
if (profile.battlegroup) {
buff += ' ' + profile.battlegroup;
}
if (profile.realm) {
buff += ' ' + profile.realm;
}
return $WH.trim(buff);
},
sortFunc: function(a, b, col) {
if (a.region != b.region) {
return $WH.strcmp(a.region, b.region);
}
if (a.battlegroup != b.battlegroup) {
return $WH.strcmp(a.battlegroup, b.battlegroup);
}
return $WH.strcmp(a.realm, b.realm);
}
},
{
id: 'guild',
name: LANG.guild,
value: 'guild',
type: 'text',
compute: function(profile, td) {
if (!profile.region || !profile.realm || !profile.guild || typeof(profile.guild) == 'number') {
return;
}
var a = $WH.ce('a');
a.className = 'q1';
a.href = '?guild=' + profile.region + '.' + profile.realm + '.' + g_urlize(profile.guild, true);
$WH.ae(a, $WH.ct(profile.guild));
$WH.ae(td, a);
},
sortFunc: function(a, b, col) {
return $WH.strcmp(a.guild, b.guild);
}
}
],
getItemLink: function(profile) {
if (profile.size !== undefined) {
return '?arena-team=' + profile.region + '.' + profile.realm + '.' + g_urlize(profile.name, true);
}
else if (profile.members !== undefined) {
return '?guild=' + profile.region + '.' + profile.realm + '.' + g_urlize(profile.name, true);
}
else {
return g_getProfileUrl(profile);
}
}
},
model: {
sort: [],
mode: 3, // Grid mode
nItemsPerPage: 40,
nItemsPerRow: 4,
poundable: 2, // Yes but w/o sort
columns: [],
compute: function(model, td, i) {
td.className = 'screenshot-cell';
td.vAlign = 'bottom';
var a = $WH.ce('a');
a.href = 'javascript:;';
// a.className = 'pet-zoom'; // aowow: keep as reference only
a.onclick = this.template.modelShow.bind(this.template, model.npcId, model.displayId, false);
var img = $WH.ce('img');
img.src = g_staticUrl + '/modelviewer/thumbs/npc/' + model.displayId + '.png';
$WH.ae(a, img);
$WH.ae(td, a);
var d = $WH.ce('div');
d.className = 'screenshot-cell-user';
a = $WH.ce('a');
a.href = '?npcs=1&filter=' + (model.family ? 'fa=' + model.family + ';' : '') + 'minle=1;cr=35;crs=0;crv=' + model.skin;
$WH.ae(a, $WH.ct(model.skin));
$WH.ae(d, a);
$WH.ae(d, $WH.ct(' (' + model.count + ')'));
$WH.ae(td, d);
d = $WH.ce('div');
d.style.position = 'relative';
d.style.height = '1em';
var d2 = $WH.ce('div');
d2.className = 'screenshot-caption';
var s = $WH.ce('small');
$WH.ae(s, $WH.ct(LANG.level + ': '));
$WH.ae(s, $WH.ct((model.minLevel == 9999 ? '??' : model.minLevel) + (model.minLevel == model.maxLevel ? '' : LANG.hyphen + (model.maxLevel == 9999 ? '??' : model.maxLevel))));
$WH.ae(s, $WH.ce('br'));
$WH.ae(d2, s);
$WH.ae(d, d2);
$WH.ae(td, d);
$WH.aE(td, 'click', this.template.modelShow.bind(this.template, model.npcId, model.displayId, true));
},
modelShow: function(npcId, displayId, sp, e) {
if (sp) {
e = $WH.$E(e);
if (e.shiftKey || e.ctrlKey) {
return;
}
var
j = 0,
el = e._target;
while (el && j < 3) {
if (el.nodeName == 'A') {
return;
}
if (el.nodeName == 'IMG') {
break;
}
el = el.parentNode;
}
}
ModelViewer.show({type: 1, typeId: npcId, displayId: displayId, noPound: 1});
}
},
genericmodel: {
sort: [],
mode: 3, // Grid mode
nItemsPerPage: 40,
nItemsPerRow: 4,
poundable: 2, // Yes but w/o sort
columns: [
{
value: "name",
sortFunc: function (a, b) {
return Listview.templates.genericmodel.sortFunc(a, b);
}
}
],
compute: function (model, td, i) {
td.className = 'screenshot-cell';
td.vAlign = 'bottom';
var
displayId,
type,
linkType,
slot,
typeId;
if ('modelviewer' in model) {
displayId = model.modelviewer.displayid;
typeId = model.modelviewer.typeid;
type = model.modelviewer.type;
slot = model.slot;
}
else if ('npcmodel' in model) {
displayId = model.npcmodel;
typeId = model.id;
type = 1;
}
else if ('displayid' in model) {
displayId = model.displayid;
typeId = model.id;
type = 3;
slot = model.slotbak || model.slot;
}
switch (type) {
case 1:
linkType = 'npc';
break;
case 3:
linkType = 'item';
break;
default:
linkType = 'item';
break;
}
if (displayId) {
var a = $WH.ce('a');
a.href = 'javascript:;';
a.rel = this.genericlinktype + '=' + model.id + ' domain=' + Locale.get().domain ;
a.onclick = this.template.modelShow.bind(this.template, type, typeId, displayId, slot, false);
var img = $WH.ce('img');
img.src = g_staticUrl + '/modelviewer/thumbs/' + linkType + '/' + displayId + '.png';
$WH.ae(a, img);
$WH.ae(td, a);
}
d = $WH.ce('div');
d.style.position = 'relative';
d.style.height = '1em';
var d2 = $WH.ce('div');
d2.className = 'screenshot-caption';
var a = $WH.ce('a');
a.className = 'q' + ((this.genericlinktype == 'item') ? g_items[model.id].quality : '');
a.style.fontFamily = 'Verdana,sans-serif';
a.href = g_host + '?' + this.genericlinktype + '=' + model.id;
$WH.ae(a, $WH.ct(model.name.substr(1)));
$WH.ae(d2, a);
$WH.ae(d, d2);
$WH.ae(td, d);
if (displayId) {
$WH.aE(td, 'click', this.template.modelShow.bind(this.template, type, typeId, displayId, slot, true));
}
},
modelShow: function (type, typeId, displayId, slot, sp, e) {
if (sp) {
e = $WH.$E(e);
if (e.shiftKey || e.ctrlKey) {
return;
}
var
j = 0,
el = e._target;
while (el && j < 3) {
if (el.nodeName == 'A') {
return;
}
if (el.nodeName == 'IMG') {
break;
}
el = el.parentNode;
}
}
var opt = {
type: type,
typeId: typeId,
displayId: displayId,
noPound: 1
};
if (typeof slot != "undefined") {
opt.slot = slot;
}
ModelViewer.show(opt);
},
sortFunc: function (a, b, col) {
return ($WH.strcmp(a.displayid, b.displayid) || $WH.strcmp(a.name, b.name) || -$WH.strcmp(a.level, b.level));
}
},
currency: {
sort: [1],
searchable: 1,
filtrable: 1,
columns: [
{
id: 'name',
name: LANG.name,
type: 'text',
align: 'left',
span: 2,
value: 'name',
compute: function(currency, td, tr) {
var i = $WH.ce('td');
i.style.width = '1px';
i.style.padding = '0';
i.style.borderRight = 'none';
$WH.ae(i, Icon.create(currency.icon, 0, null, this.getItemLink(currency)));
$WH.ae(tr, i);
td.style.borderLeft = 'none';
var wrapper = $WH.ce('div');
var a = $WH.ce('a');
a.style.fontFamily = 'Verdana, sans-serif';
a.href = this.getItemLink(currency);
$WH.ae(a, $WH.ct(currency.name));
$WH.ae(wrapper, a);
$WH.ae(td, wrapper);
}
},
{
id: 'category',
name: LANG.category,
type: 'text',
width: '15%',
compute: function(currency, td) {
td.className = 'small';
var a = $WH.ce('a');
a.className = 'q1';
a.href = '?currencies=' + currency.category;
$WH.ae(a, $WH.ct(g_currency_categories[currency.category]));
$WH.ae(td, a);
},
getVisibleText: function(currency) {
return g_currency_categories[currency.category];
},
sortFunc: function(a, b, col) {
return $WH.strcmp(g_currency_categories[a.category], g_currency_categories[b.category]);
}
}
],
getItemLink: function(currency) {
return '?currency=' + currency.id;
}
},
classs: {
sort: [1],
searchable: 1,
filtrable: 1,
columns: [
{
id: 'name',
name: LANG.name,
type: 'text',
align: 'left',
span: 2,
value: 'name',
compute: function(classs, td, tr) {
var i = $WH.ce('td');
i.style.width = '1px';
i.style.padding = '0';
i.style.borderRight = 'none';
$WH.ae(i, Icon.create('class_' + g_file_classes[classs.id], 0, null, this.getItemLink(classs)));
$WH.ae(tr, i);
td.style.borderLeft = 'none';
// force minimum width to fix overlap display bug
td.style.width = '270px';
var wrapper = $WH.ce('div');
var a = $WH.ce('a');
a.className = 'c' + classs.id;
a.style.fontFamily = 'Verdana, sans-serif';
a.href = this.getItemLink(classs);
$WH.ae(a, $WH.ct(classs.name));
if (classs.expansion) {
var sp = $WH.ce('span');
sp.className = g_GetExpansionClassName(classs.expansion);
$WH.ae(sp, a);
$WH.ae(wrapper, sp);
}
else {
$WH.ae(wrapper, a);
}
if (classs.hero) {
wrapper.style.position = 'relative';
var d = $WH.ce('div');
d.className = 'small';
d.style.fontStyle = 'italic';
d.style.position = 'absolute';
d.style.right = '3px';
d.style.bottom = '0px';
$WH.ae(d, $WH.ct(LANG.lvclass_hero));
$WH.ae(wrapper, d);
}
$WH.ae(td, wrapper);
}
},
{
id: 'races',
name: LANG.races,
type: 'text',
compute: function(classs, td) {
if (classs.races) {
var races = Listview.funcBox.assocBinFlags(classs.races, g_chr_races);
td.className = 'q1';
for (var i = 0, len = races.length; i < len; ++i) {
if (i > 0) {
$WH.ae(td, $WH.ct(LANG.comma));
}
var a = $WH.ce('a');
a.href = '?race=' + races[i];
$WH.ae(a, $WH.ct(g_chr_races[races[i]]));
$WH.ae(td, a);
}
}
},
getVisibleText: function(classs) {
if (classs.races) {
return Listview.funcBox.arrayText(Listview.funcBox.assocBinFlags(classs.races, g_chr_races), g_chr_races);
}
},
sortFunc: function(a, b, col) {
return Listview.funcBox.assocArrCmp(Listview.funcBox.assocBinFlags(a.races, g_chr_races), Listview.funcBox.assocBinFlags(b.races, g_chr_races), g_chr_races);
}
}
],
getItemLink: function(classs) {
return '?class=' + classs.id;
}
},
race: {
sort: [1],
searchable: 1,
filtrable: 1,
columns: [
{
id: 'name',
name: LANG.name,
type: 'text',
align: 'left',
span: 2,
value: 'name',
compute: function(race, td, tr) {
var
d = $WH.ce('div'),
icon;
d.style.margin = '0 auto';
d.style.textAlign = 'left';
d.style.width = '52px';
icon = Icon.create('race_' + g_file_races[race.id] + '_' + g_file_genders[0], 0, null, this.getItemLink(race));
icon.style.cssFloat = icon.style.styleFloat = 'left';
$WH.ae(d, icon);
icon = Icon.create('race_' + g_file_races[race.id] + '_' + g_file_genders[1], 0, null, this.getItemLink(race));
icon.style.cssFloat = icon.style.styleFloat = 'left';
$WH.ae(d, icon);
var i = $WH.ce('td');
i.style.width = '1px';
i.style.padding = '0';
i.style.borderRight = 'none';
$WH.ae(i, d);
$WH.ae(tr, i);
td.style.borderLeft = 'none';
var wrapper = $WH.ce('div');
var a = $WH.ce('a');
a.style.fontFamily = 'Verdana, sans-serif';
a.href = this.getItemLink(race);
$WH.ae(a, $WH.ct(race.name));
if (race.expansion) {
var sp = $WH.ce('span');
sp.className = g_GetExpansionClassName(race.expansion);
$WH.ae(sp, a);
$WH.ae(wrapper, sp);
}
else {
$WH.ae(wrapper, a);
}
$WH.ae(td, wrapper);
}
},
{
id: 'side',
name: LANG.side,
type: 'text',
compute: function(race, td) {
if (race.side && race.side != 3) {
var sp = $WH.ce('span');
sp.className = (race.side == 1 ? 'icon-alliance' : 'icon-horde');
g_addTooltip(sp, g_sides[race.side]);
$WH.ae(td, sp);
}
},
getVisibleText: function(race) {
if (race.side) {
return g_sides[race.side];
}
},
sortFunc: function(a, b, col) {
return $WH.strcmp(g_sides[a.side], g_sides[b.side]);
}
},
{
id: 'classes',
name: LANG.classes,
type: 'text',
compute: function(race, td) {
if (race.classes) {
var classes = Listview.funcBox.assocBinFlags(race.classes, g_chr_classes);
var d = $WH.ce('div');
d.style.width = (26 * classes.length) + 'px';
d.style.margin = '0 auto';
for (var i = 0, len = classes.length; i < len; ++i) {
var icon = Icon.create('class_' + g_file_classes[classes[i]], 0, null, '?class=' + classes[i]);
g_addTooltip(icon, g_chr_classes[classes[i]], 'c' + classes[i]);
icon.style.cssFloat = icon.style.styleFloat = 'left';
$WH.ae(d, icon);
}
$WH.ae(td, d);
}
},
getVisibleText: function(race) {
if (race.classes) {
return Listview.funcBox.arrayText(Listview.funcBox.assocBinFlags(race.classes, g_chr_classes), g_chr_classes);
}
},
sortFunc: function(a, b, col) {
return Listview.funcBox.assocArrCmp(Listview.funcBox.assocBinFlags(a.classes, g_chr_classes), Listview.funcBox.assocBinFlags(b.classes, g_chr_classes), g_chr_classes);
}
}
],
getItemLink: function(race) {
return '?race=' + race.id;
}
},
changelog: {
nItemsPerPage: 100,
sortable: false,
columns: [
{
id: "name",
name: "Name",
compute: function (changelog, td) {
var c = $(changelog.tooltip).find("b").first().text();
$(td).html(c);
td.className += " listview-cleartext";
},
},
{
id: "version",
name: "Version (mouseover to see tooltip)",
compute: function (changelog, td) {
var tt = changelog.tooltip;
$(td).mouseover(function (event, menu) { $WH.Tooltip.showAtCursor(menu, event, 0, 0); }.bind(td, tt));
$(td).mousemove(function (event) { $WH.Tooltip.cursorUpdate(event); })
.mouseout(function () { $WH.Tooltip.hide(); });
/* aowow - we dont do patches
var g = typeof g_hearthhead != "undefined" && g_hearthhead ? "hearthstone" : "wow";
if (!g_getPatchVersionObject.hasOwnProperty("parsed") || !g_getPatchVersionObject.parsed[g]) {
g_getPatchVersionObject();
}
var j = (changelog.build > 0 ? "" : "Before ") + "Build " + Math.abs(changelog.build);
if (changelog.version > 0) {
var f = parseInt(changelog.version / 10000) + "." + (parseInt(changelog.version / 100) % 100) + "." + (changelog.version % 100);
j = f + " " + j;
var c = false;
for (var b in g_gameversions[g]) {
if (g_gameversions[g][b].versionnum >= changelog.version && (!c || c.build > g_gameversions[g][b].build)) {
c = g_gameversions[g][b];
}
}
if (c) {
j = j.replace(f, f + " (" + new Date(c.timestamp).toDateString() + ")");
}
}
*/
let j = changelog.version; // aowow - tmp
$(td).html(j);
},
},
],
}
};