mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Javascript:
- reviewed and used objects PageTemplate and Locale - removed associated workarounds - replaced ~12k tabs with ~48k spaces - fixed some localization errors - whoops, forgot to update some Util::$pageTemplate calls to $this
This commit is contained in:
@@ -1,99 +1,99 @@
|
||||
function Book(opt) {
|
||||
if (!opt.parent || !opt.pages || opt.pages.length == 0) {
|
||||
return;
|
||||
}
|
||||
if (!opt.parent || !opt.pages || opt.pages.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
opt.parent = $WH.ge(opt.parent);
|
||||
opt.parent = $WH.ge(opt.parent);
|
||||
|
||||
var
|
||||
var
|
||||
d,
|
||||
a,
|
||||
_;
|
||||
|
||||
this.nPages = opt.pages.length;
|
||||
this.nPages = opt.pages.length;
|
||||
|
||||
this.parent = $WH.ge(opt.parent);
|
||||
this.parent.className += ' book';
|
||||
this.parent = $WH.ge(opt.parent);
|
||||
this.parent.className += ' book';
|
||||
|
||||
d = $WH.ce('div');
|
||||
d.className = 'paging';
|
||||
if (this.nPages == 1) {
|
||||
d.style.display = 'none';
|
||||
}
|
||||
$WH.ns(d);
|
||||
d = $WH.ce('div');
|
||||
d.className = 'paging';
|
||||
if (this.nPages == 1) {
|
||||
d.style.display = 'none';
|
||||
}
|
||||
$WH.ns(d);
|
||||
|
||||
_ = $WH.ce('div');
|
||||
_.style.visibility = 'hidden';
|
||||
_.className = 'previous';
|
||||
a = $WH.ce('a');
|
||||
a.appendChild($WH.ct(String.fromCharCode(8249) + LANG.lvpage_previous));
|
||||
a.href = 'javascript:;';
|
||||
a.onclick = this.previous.bind(this);
|
||||
_.appendChild(a);
|
||||
d.appendChild(_);
|
||||
_ = $WH.ce('div');
|
||||
_.style.visibility = 'hidden';
|
||||
_.className = 'previous';
|
||||
a = $WH.ce('a');
|
||||
a.appendChild($WH.ct(String.fromCharCode(8249) + LANG.lvpage_previous));
|
||||
a.href = 'javascript:;';
|
||||
a.onclick = this.previous.bind(this);
|
||||
_.appendChild(a);
|
||||
d.appendChild(_);
|
||||
|
||||
_ = $WH.ce('div');
|
||||
_.style.visibility = 'hidden';
|
||||
_.className = 'next';
|
||||
a = $WH.ce('a');
|
||||
a.appendChild($WH.ct(LANG.lvpage_next + String.fromCharCode(8250)));
|
||||
a.href = 'javascript:;';
|
||||
a.onclick = this.next.bind(this);
|
||||
_.appendChild(a);
|
||||
d.appendChild(_);
|
||||
_ = $WH.ce('div');
|
||||
_.style.visibility = 'hidden';
|
||||
_.className = 'next';
|
||||
a = $WH.ce('a');
|
||||
a.appendChild($WH.ct(LANG.lvpage_next + String.fromCharCode(8250)));
|
||||
a.href = 'javascript:;';
|
||||
a.onclick = this.next.bind(this);
|
||||
_.appendChild(a);
|
||||
d.appendChild(_);
|
||||
|
||||
_ = $WH.ce('b');
|
||||
_.appendChild($WH.ct('1'));
|
||||
d.appendChild(_);
|
||||
_ = $WH.ce('b');
|
||||
_.appendChild($WH.ct('1'));
|
||||
d.appendChild(_);
|
||||
|
||||
d.appendChild($WH.ct(LANG.lvpage_of));
|
||||
d.appendChild($WH.ct(LANG.lvpage_of));
|
||||
|
||||
_ = $WH.ce('b');
|
||||
_.appendChild($WH.ct(this.nPages));
|
||||
d.appendChild(_);
|
||||
_ = $WH.ce('b');
|
||||
_.appendChild($WH.ct(this.nPages));
|
||||
d.appendChild(_);
|
||||
|
||||
opt.parent.appendChild(d);
|
||||
opt.parent.appendChild(d);
|
||||
|
||||
for (var i = 0; i < this.nPages; ++i) {
|
||||
d = $WH.ce('div');
|
||||
d.className = 'page';
|
||||
d.style.display = 'none';
|
||||
for (var i = 0; i < this.nPages; ++i) {
|
||||
d = $WH.ce('div');
|
||||
d.className = 'page';
|
||||
d.style.display = 'none';
|
||||
|
||||
d.innerHTML = opt.pages[i];
|
||||
d.innerHTML = opt.pages[i];
|
||||
|
||||
opt.parent.appendChild(d);
|
||||
}
|
||||
opt.parent.appendChild(d);
|
||||
}
|
||||
|
||||
this.page = 1;
|
||||
this.changePage(opt.page || 1);
|
||||
this.page = 1;
|
||||
this.changePage(opt.page || 1);
|
||||
}
|
||||
|
||||
Book.prototype = {
|
||||
changePage: function(page) {
|
||||
if (page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
changePage: function(page) {
|
||||
if (page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
else if (page > this.nPages) {
|
||||
page = this.nPages;
|
||||
}
|
||||
}
|
||||
|
||||
var _ = this.parent.childNodes;
|
||||
_[this.page].style.display = 'none';
|
||||
_[page].style.display = '';
|
||||
this.page = page;
|
||||
var _ = this.parent.childNodes;
|
||||
_[this.page].style.display = 'none';
|
||||
_[page].style.display = '';
|
||||
this.page = page;
|
||||
|
||||
_ = _[0].childNodes;
|
||||
_[0].style.visibility = (page == 1) ? 'hidden': 'visible';
|
||||
_[1].style.visibility = (page == this.nPages) ? 'hidden': 'visible';
|
||||
_ = _[0].childNodes;
|
||||
_[0].style.visibility = (page == 1) ? 'hidden': 'visible';
|
||||
_[1].style.visibility = (page == this.nPages) ? 'hidden': 'visible';
|
||||
|
||||
_[2].innerHTML = page;
|
||||
},
|
||||
_[2].innerHTML = page;
|
||||
},
|
||||
|
||||
next: function() {
|
||||
this.changePage(this.page + 1);
|
||||
},
|
||||
next: function() {
|
||||
this.changePage(this.page + 1);
|
||||
},
|
||||
|
||||
previous: function() {
|
||||
this.changePage(this.page - 1);
|
||||
}
|
||||
previous: function() {
|
||||
this.changePage(this.page - 1);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -346,7 +346,7 @@ Mapper.prototype = {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
var type = g_locale.name;
|
||||
var type = Locale.getName();
|
||||
|
||||
if($WH.isset('g_ptr') && g_ptr)
|
||||
type = 'ptr';
|
||||
|
||||
8112
static/js/Markup.js
8112
static/js/Markup.js
File diff suppressed because it is too large
Load Diff
@@ -981,12 +981,10 @@ function Profiler() {
|
||||
// Breadcrumb
|
||||
|
||||
if (_isArmoryProfile(_profile.genuine)) {
|
||||
// PageTemplate.set({ breadcrumb: [1, 5, 0, _profile.region[0], _profile.battlegroup[0], _profile.realm[0]] });
|
||||
g_initPath([1, 5, 0, _profile.region[0], _profile.battlegroup[0], _profile.realm[0]]);
|
||||
PageTemplate.set({ breadcrumb: [1, 5, 0, _profile.region[0], _profile.battlegroup[0], _profile.realm[0]] });
|
||||
}
|
||||
else {
|
||||
// PageTemplate.set({ breadcrumb: [1, 5, 1] });
|
||||
g_initPath([1, 5, 1]);
|
||||
PageTemplate.set({ breadcrumb: [1, 5, 1] });
|
||||
}
|
||||
|
||||
// ************************
|
||||
@@ -7455,7 +7453,7 @@ function ProfilerCompletion(_parent) {
|
||||
}
|
||||
|
||||
if (_opt.onDemand && !_loading && !_loaded) {
|
||||
$WH.g_ajaxIshRequest(g_host + '?data=' + _opt.onDemand + (_opt.dataArgs ? _opt.dataArgs(_profile) : '') + '&locale=' + g_locale.id + '&t=' + g_dataKey + '&callback=$WowheadProfiler.loadOnDemand&' + (new Date().getTime()));
|
||||
$WH.g_ajaxIshRequest(g_host + '?data=' + _opt.onDemand + (_opt.dataArgs ? _opt.dataArgs(_profile) : '') + '&locale=' + Locale.getId() + '&t=' + g_dataKey + '&callback=$WowheadProfiler.loadOnDemand&' + (new Date().getTime()));
|
||||
_imgLoading.style.display = 'block';
|
||||
_divTipQuests.style.display = 'none';
|
||||
_loading = this;
|
||||
@@ -8382,7 +8380,7 @@ function ProfilerCompletion(_parent) {
|
||||
|
||||
if (_category !== null) {
|
||||
if (_opt.onDemand && _opt.partial && !_loaded[_category] && !_loading) {
|
||||
$WH.g_ajaxIshRequest(g_host + '?data=' + _opt.onDemand + '&locale=' + g_locale.id + '&catg=' + _category + '&t=' + g_dataKey + '&callback=$WowheadProfiler.loadOnDemand&' + (new Date().getTime()));
|
||||
$WH.g_ajaxIshRequest(g_host + '?data=' + _opt.onDemand + '&locale=' + Locale.getId() + '&catg=' + _category + '&t=' + g_dataKey + '&callback=$WowheadProfiler.loadOnDemand&' + (new Date().getTime()));
|
||||
_imgLoading.style.display = 'block';
|
||||
_divTipQuests.style.display = 'none';
|
||||
_loading = this;
|
||||
|
||||
@@ -3245,7 +3245,7 @@ Summary.prototype = {
|
||||
for (var i = 0, len = a[1].length; i < len; ++i) {
|
||||
var row = {};
|
||||
row.id = a[1][i].id;
|
||||
row.name = row['name_' + g_locale.name] = a[1][i].name.substring(1);
|
||||
row.name = row['name_' + Locale.getName()] = a[1][i].name.substring(1);
|
||||
row.quality = 7 - a[1][i].name.charAt(0);
|
||||
row.icon = a[1][i].icon;
|
||||
row.level = a[1][i].level;
|
||||
@@ -3266,7 +3266,7 @@ Summary.prototype = {
|
||||
for (var i = 0, len = a[2].length; i < len; ++i) {
|
||||
var row = {};
|
||||
row.id = a[2][i].id;
|
||||
row.name = row['name_' + g_locale.name] = a[2][i].name.substring(1);
|
||||
row.name = row['name_' + Locale.getName()] = a[2][i].name.substring(1);
|
||||
row.quality = 7 - a[2][i].name.charAt(0);
|
||||
row.minlevel = a[2][i].minlevel;
|
||||
row.maxlevel = a[2][i].maxlevel;
|
||||
@@ -3687,7 +3687,7 @@ Summary.groupOver = function(group, e) {
|
||||
buff += '<tr>';
|
||||
buff += '<td style="text-align: right">x' + count[itemId] + '</td>';
|
||||
buff += '<td><div class="indent q' + g_items[itemId].quality + '">';
|
||||
buff += '<span class="icontiny" style="background: url(' + g_staticUrl + '/images/wow/icons/tiny/' + g_items[itemId].icon.toLowerCase() + '.gif) left center no-repeat">' + g_items[itemId]['name_' + g_locale.name] + '</span>';
|
||||
buff += '<span class="icontiny" style="background: url(' + g_staticUrl + '/images/wow/icons/tiny/' + g_items[itemId].icon.toLowerCase() + '.gif) left center no-repeat">' + g_items[itemId]['name_' + Locale.getName()] + '</span>';
|
||||
buff += '</div></td>';
|
||||
buff += '<td><div class="indent q1"><small><em>' + LANG.level + ' ' + g_items[itemId].jsonequip.level + '</em></small></div></td>';
|
||||
buff += '</tr>';
|
||||
@@ -4660,7 +4660,7 @@ Listview.templates.subitempicker = {
|
||||
a.href = url;
|
||||
a.rel = 'rand=' + subitem.id;
|
||||
|
||||
$WH.ae(a, $WH.ct(item['name_' + g_locale.name] + ' ' + subitem.name));
|
||||
$WH.ae(a, $WH.ct(item['name_' + Locale.getName()] + ' ' + subitem.name));
|
||||
|
||||
$WH.nw(td);
|
||||
$WH.ae(td, a);
|
||||
|
||||
@@ -2243,7 +2243,7 @@ function TalentCalc() {
|
||||
c.div.style.display = "";
|
||||
}
|
||||
else {
|
||||
$WH.g_ajaxIshRequest('?data=talents&class=' + classId + '&locale=' + g_locale.id + '&t=' + g_dataKey + '&' + _versionBuild);
|
||||
$WH.g_ajaxIshRequest('?data=talents&class=' + classId + '&locale=' + Locale.getId() + '&t=' + g_dataKey + '&' + _versionBuild);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2529,7 +2529,7 @@ function TalentCalc() {
|
||||
function _simplifyGlyphName(name) {
|
||||
var str;
|
||||
|
||||
switch (g_locale.id) {
|
||||
switch (Locale.getId()) {
|
||||
case 0:
|
||||
str = name.replace(/^Glyph of (the )?/i, '');
|
||||
break;
|
||||
|
||||
@@ -1328,8 +1328,8 @@ $WH.g_setTooltipLevel = function(tooltip, level) {
|
||||
|
||||
if (_ == 'number') {
|
||||
var arr = $WH.g_getDataSource();
|
||||
if (arr[tooltip] && arr[tooltip][(buff ? 'buff_' : 'tooltip_') + g_locale.name]) {
|
||||
tooltip = arr[tooltip][(buff ? 'buff_' : 'tooltip_') + g_locale.name];
|
||||
if (arr[tooltip] && arr[tooltip][(buff ? 'buff_' : 'tooltip_') + Locale.getName()]) {
|
||||
tooltip = arr[tooltip][(buff ? 'buff_' : 'tooltip_') + Locale.getName()];
|
||||
}
|
||||
else {
|
||||
return tooltip; // Error
|
||||
@@ -1528,9 +1528,9 @@ $WH.g_enhanceTooltip = function(tooltip, isStatic, useGets, showSlider, buff, kn
|
||||
arr = $WH.g_getDataSource(),
|
||||
id = tooltip;
|
||||
|
||||
if (arr[id] && arr[id][(buff ? 'buff_' : 'tooltip_') + g_locale.name]) {
|
||||
tooltip = arr[id][(buff ? 'buff_' : 'tooltip_') + g_locale.name];
|
||||
spellJson = arr[id][(buff ? 'buff' : '') + 'spells_' + g_locale.name];
|
||||
if (arr[id] && arr[id][(buff ? 'buff_' : 'tooltip_') + Locale.getName()]) {
|
||||
tooltip = arr[id][(buff ? 'buff_' : 'tooltip_') + Locale.getName()];
|
||||
spellJson = arr[id][(buff ? 'buff' : '') + 'spells_' + Locale.getName()];
|
||||
|
||||
if (spellJson) {
|
||||
tooltip = $WH.g_setTooltipSpells(tooltip, knownSpells, spellJson);
|
||||
@@ -1595,7 +1595,7 @@ $WH.g_enhanceTooltip = function(tooltip, isStatic, useGets, showSlider, buff, kn
|
||||
|
||||
$(chooseSpells)
|
||||
.append('<input type="checkbox" id="known-' + i + '" />')
|
||||
.append('<label for="known-' + i + '"><a rel="spell=' + i + '&know=' + i + '">' + g_spells[i]['name_' + g_locale.name] + (g_spells[i]['rank_' + g_locale.name] ? ' (' + g_spells[i]['rank_' + g_locale.name] + ')' : '') + '</a></label>')
|
||||
.append('<label for="known-' + i + '"><a rel="spell=' + i + '&know=' + i + '">' + g_spells[i]['name_' + Locale.getName()] + (g_spells[i]['rank_' + Locale.getName()] ? ' (' + g_spells[i]['rank_' + Locale.getName()] + ')' : '') + '</a></label>')
|
||||
.append('<br />');
|
||||
|
||||
$('#known-' + i).change($WH.g_tooltipSpellsChange.bind(this));
|
||||
@@ -1646,7 +1646,7 @@ $WH.g_staticTooltipLevelClick = function (div, level, noSlider, buff) {
|
||||
}
|
||||
|
||||
var arr = $WH.g_getDataSource();
|
||||
_ = $WH.g_setTooltipLevel(arr[itemId][(buff ? 'buff_' : 'tooltip_') + g_locale.name], level, buff);
|
||||
_ = $WH.g_setTooltipLevel(arr[itemId][(buff ? 'buff_' : 'tooltip_') + Locale.getName()], level, buff);
|
||||
_ = $WH.g_enhanceTooltip(_, true);
|
||||
|
||||
div.innerHTML = '<table><tr><td>' + _ + '</td><th style="background-position: top right"></th></tr><tr><th style="background-position: bottom left"></th><th style="background-position: bottom right"></th></tr></table>';
|
||||
|
||||
@@ -522,6 +522,12 @@ function fi_reset(_this) {
|
||||
fi_resetCriterion($WH.ge('fi_criteria'));
|
||||
fi_resetCriterion($WH.ge('fi_weight'));
|
||||
|
||||
// custom start (originally a click on reset would reload the page with empty filters)
|
||||
var bc = PageTemplate.get('breadcrumb');
|
||||
if (typeof bc[1] !== 'undefined')
|
||||
Menu.modifyUrl(Menu.findItem(mn_database, [bc[1]]), {}, {});
|
||||
// custom end
|
||||
|
||||
var _ = $WH.ge('sdkgnsdkn436');
|
||||
if (_) {
|
||||
_.parentNode.style.display = 'none';
|
||||
@@ -1467,11 +1473,12 @@ function fi_dropdownSync(_this) {
|
||||
function fi_init(type) {
|
||||
fi_type = type;
|
||||
|
||||
var s = $WH.ge('fi_subcat');
|
||||
if (g_initPath.lastIt && g_initPath.lastIt[3]) {
|
||||
if (s) {
|
||||
Menu.add(s, g_initPath.lastIt[3]);
|
||||
}
|
||||
var
|
||||
s = $WH.ge('fi_subcat'),
|
||||
m = Menu.findItem(mn_path, PageTemplate.get('breadcrumb'));
|
||||
|
||||
if (s && m[3]) {
|
||||
Menu.add(s, m[3]);
|
||||
}
|
||||
else if (s) {
|
||||
$WH.de(s.parentNode);
|
||||
@@ -1846,7 +1853,7 @@ function fi_filterParamToJson(filters) {
|
||||
if(filters) {
|
||||
var parts = filters.split(';');
|
||||
|
||||
$WH.array_walk(parts, function(part){
|
||||
$.each(parts, function(idx, part) {
|
||||
$WH.g_splitQueryParam(part, result);
|
||||
});
|
||||
}
|
||||
@@ -1859,7 +1866,7 @@ function fi_filterJsonToParam(json) {
|
||||
|
||||
var i = 0;
|
||||
|
||||
$WH.array_walk(json, function(value, _, __, name) {
|
||||
$.each(json, function(name, value) {
|
||||
if (value !== '') {
|
||||
if (i++ > 0) {
|
||||
result += ';';
|
||||
|
||||
2837
static/js/global.js
2837
static/js/global.js
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@ function pc_init() {
|
||||
_,
|
||||
clear;
|
||||
|
||||
g_initPath([1, 2]);
|
||||
// PageTemplate.set({ breadcrumb: [1, 2] });
|
||||
|
||||
$WH.ge('pc-classes').className = 'choose';
|
||||
|
||||
@@ -97,7 +97,7 @@ function pc_onChange(tc, info, data) {
|
||||
_ = pc_classIcons[pc_classId];
|
||||
_.className += ' iconmedium-gold-selected';
|
||||
|
||||
g_initPath([1, 2, pc_classId]);
|
||||
PageTemplate.set({ breadcrumb: [1, 2, pc_classId] });
|
||||
}
|
||||
|
||||
pc_build = tc.getWhBuild();
|
||||
|
||||
@@ -582,20 +582,13 @@ function pr_addEquipButton(id, itemId)
|
||||
|
||||
function pr_onBreadcrumbUpdate() // Add character lookup textbox to the breadcrumb
|
||||
{
|
||||
// var breadcrumb = PageTemplate.get('breadcrumb');
|
||||
var breadcrumb = temp_path;
|
||||
// end
|
||||
|
||||
var breadcrumb = PageTemplate.get('breadcrumb');
|
||||
if(!breadcrumb || breadcrumb.length != 6) // Realm is required
|
||||
return;
|
||||
|
||||
var path = Menu.getFullPath(mn_path, breadcrumb);
|
||||
var menuItem = path[path.length - 1];
|
||||
|
||||
// var span = PageTemplate.expandBreadcrumb()[0];
|
||||
$('.path').children('span:last').addClass('breadcrumb-arrow');
|
||||
var span = ($('<span/>').appendTo($('.path')))[0];
|
||||
// end
|
||||
var span = PageTemplate.expandBreadcrumb()[0];
|
||||
|
||||
var f = $WH.ce('form'),
|
||||
i = $WH.ce('input'),
|
||||
@@ -797,10 +790,5 @@ if($WH.isset('mn_profiles'))
|
||||
Menu.findItem(mn_path, [1,5,2])[MENU_IDX_SUB] = mn_guilds;
|
||||
Menu.findItem(mn_path, [1,5,3])[MENU_IDX_SUB] = mn_arenateams;
|
||||
|
||||
|
||||
// todo (low): understand and use pageTemplate
|
||||
// PageTemplate.getBreadcrumb().bind('update', pr_onBreadcrumbUpdate);
|
||||
DomContentLoaded.addEvent(function() {
|
||||
pr_onBreadcrumbUpdate();
|
||||
});
|
||||
PageTemplate.getBreadcrumb().bind('update', pr_onBreadcrumbUpdate);
|
||||
}
|
||||
@@ -11,7 +11,7 @@ function tc_init() {
|
||||
_,
|
||||
clear;
|
||||
|
||||
g_initPath([1, 0]);
|
||||
// PageTemplate.set({ breadcrumb: [1, 0] });
|
||||
|
||||
$WH.ge('tc-classes').className = 'choose';
|
||||
|
||||
@@ -88,7 +88,7 @@ function tc_onChange(tc, info, data) {
|
||||
_ = tc_classIcons[tc_classId];
|
||||
_.className += ' iconmedium-gold-selected';
|
||||
|
||||
g_initPath([1, 0, tc_classId]);
|
||||
PageTemplate.set({ breadcrumb: [1, 0, tc_classId] });
|
||||
}
|
||||
|
||||
tc_build = tc.getWhBuild();
|
||||
|
||||
1046
static/js/user.js
1046
static/js/user.js
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user