diff --git a/includes/class.user.php b/includes/class.user.php index 3f67a265..a2ee4381 100644 --- a/includes/class.user.php +++ b/includes/class.user.php @@ -166,8 +166,8 @@ class User return AUTH_WRONGPASS; // "stay logged in" unchecked; kill session in time() + 5min - if (self::$timeout > 0 && self::$timeout < time()) - return AUTH_TIMEDOUT; + // if (self::$timeout > 0 && self::$timeout < time()) + // return AUTH_TIMEDOUT; if (self::$timeout > 0) DB::Auth()->query('UPDATE ?_account SET timeout = ?d WHERE id = ?d', @@ -275,15 +275,47 @@ class User 'avatar' => self::$avatar, 'community' => self::$description, 'chars' => self::getCharacters(), - 'profiles' => self::getProfiles(), + 'profiles' => self::getProfiles() ); + if ($_ = self::getWeightScales()) + $subSet['weights'] = json_encode($_, JSON_NUMERIC_CHECK); + $smarty->assign('user', array_merge($set, $subSet)); } else $smarty->assign('user', $set); } + public static function getWeightScales() + { + $data = []; + + $res = DB::Aowow()->select('SELECT * FROM ?_account_weightscales WHERE account = ?d', self::$id); + foreach ($res as $i) + { + $set = array ( + 'name' => $i['name'], + 'id' => $i['id'] + ); + + $weights = explode(',', $i['weights']); + foreach ($weights as $weight) + { + $w = explode(':', $weight); + + if ($w[1] === 'undefined') + $w[1] = 0; + + $set[$w[0]] = $w[1]; + } + + $data[] = $set; + } + + return $data; + } + public static function getCharacters($asJSON = true) { if (empty(self::$characters)) diff --git a/includes/kernel.php b/includes/kernel.php index 9fcd0afc..398e92d2 100644 --- a/includes/kernel.php +++ b/includes/kernel.php @@ -83,14 +83,4 @@ User::assignUserToTemplate($smarty, true); @list($pageCall, $pageParam) = explode('=', $str, 2); $smarty->assign('query', [$pageCall, $pageParam]); -// init global vars for smarty -$pageData = array( - 'page' => NULL, - 'gAchievements' => NULL, - 'gCurrencies' => NULL, - 'gItems' => NULL, - 'gSpells' => NULL, - 'gTitles' => NULL, -); - ?> diff --git a/pages/account.php b/pages/account.php index 55647c1d..85cf2809 100644 --- a/pages/account.php +++ b/pages/account.php @@ -26,7 +26,7 @@ enum(array( // UserPropsLimits )); */ -if (!in_array($pageParam, array('dashboard', '', 'signin', 'signup', 'signout', 'signin_do', 'signup_do', 'forgotpassword', 'forgotusername'))) +if (!in_array($pageParam, ['dashboard', '', 'signin', 'signup', 'signout', 'signin_do', 'signup_do', 'forgotpassword', 'forgotusername', 'weightscales'])) $smarty->error(); function signin() @@ -43,7 +43,7 @@ function signin() $_SERVER['REMOTE_ADDR'] ); - if (!$ipBan) // no entry exists; set count to 1 + if (!$ipBan) // no entry exists; set count to 1 DB::Auth()->query('INSERT INTO ?_account_bannedIPs VALUES (?s, 0, 1, FROM_UNIXTIME(?))', $_SERVER['REMOTE_ADDR'], time() + $GLOBALS['AoWoWconf']['loginFailTime'] @@ -262,17 +262,42 @@ $smarty->assign('lang', array_merge(Lang::$main, Lang::$account)); if (User::$id) { - if ($pageParam == 'signout') + switch ($pageParam) { - User::destroy(); - $next = explode('?', $_SERVER['HTTP_REFERER']); - $next = !empty($next[1]) ? '?'.$next[1] : '.'; - header('Location: '.$next); - } - else - { - dashboard(); - $smarty->display('dashboard.tpl'); + case 'signout': + User::destroy(); + $next = explode('?', $_SERVER['HTTP_REFERER']); + $next = !empty($next[1]) ? '?'.$next[1] : '.'; + header('Location: '.$next); + case 'weightscales': + $post = Util::sqlEscape($_POST); + + if (isset($post['save'])) + { + if (!isset($post['id'])) + { + $res = DB::Aowow()->selectRow('SELECT max(id) as max, count(id) as num FROM ?_account_weightscales WHERE account = ?d', User::$id); + if ($res['num'] < 5) // more or less hard-defined in LANG.message_weightscalesaveerror + $post['id'] = ++$res['max']; + else + die('0'); + } + + if (DB::Aowow()->query('REPLACE INTO ?_account_weightscales VALUES (?d, ?d, ?s, ?s)', $post['id'], User::$id, $post['name'], $post['scale'])) + die((string)$post['id']); + else + die('0'); + } + else if (isset($post['delete']) && isset($post['id'])) + DB::Aowow()->query('DELETE FROM ?_account_weightscales WHERE id = ?d AND account = ?d', $post['id'], User::$id); + else + die('0'); + + break; + default; + dashboard(); + $smarty->display('dashboard.tpl'); + break; } } else diff --git a/power/aowowPower.js b/power/aowowPower.js index c1958e20..7cf29ac2 100644 --- a/power/aowowPower.js +++ b/power/aowowPower.js @@ -174,7 +174,7 @@ if (typeof $WowheadPower == "undefined") { currentParams = params; - var p = function (m, k, v) { + var p = function (url, k, v) { if (k == "buff" || k == "sock") { params[k] = true; } @@ -238,7 +238,7 @@ if (typeof $WowheadPower == "undefined") { if (parseInt(params.gems[i])) { break; } - }; + } ++i; if (i == 0) { @@ -335,7 +335,7 @@ if (typeof $WowheadPower == "undefined") { } function getTooltipField(locale) { - return (currentParams && currentParams.buff ? "buff_": "tooltip_") + LOCALES[locale]; + return (currentParams && currentParams.buff ? "buff_" : "tooltip_") + LOCALES[locale]; } function initElement(type, id, locale) { @@ -371,14 +371,12 @@ if (typeof $WowheadPower == "undefined") { if (arr[fullId].status[locale] == STATUS_OK || arr[fullId].status[locale] == STATUS_NOTFOUND) { showTooltip(arr[fullId][getTooltipField(locale)], arr[fullId].icon); } + else if (arr[fullId].status[locale] == STATUS_QUERYING) { + showTooltip(_LANG.loading); + } else { - if (arr[fullId].status[locale] == STATUS_QUERYING) { - showTooltip(_LANG.loading); - } - else { - request(type, id, locale, null, params); - } - } + request(type, id, locale, null, params); + } } function request(type, id, locale, stealth, params) { @@ -406,13 +404,11 @@ if (typeof $WowheadPower == "undefined") { if (typeof params[i] == "object") { p += "&" + i + "=" + params[i].join(":"); } + else if (i == "sock") { + p += "&sock"; + } else { - if (i == "sock") { - p += "&sock"; - } - else { - p += "&" + i + "=" + params[i]; - } + p += "&" + i + "=" + params[i]; } } @@ -438,7 +434,7 @@ if (typeof $WowheadPower == "undefined") { if (currentParams != null) { if (currentParams.pcs && currentParams.pcs.length) { var n = 0; - for (var i = 0, al = currentParams.pcs.length; i < al; ++i) { + for (var i = 0, len = currentParams.pcs.length; i < len; ++i) { var ak; if (ak = html.match(new RegExp("(.+?)'))) { html = html.replace(ak[0], '' + (($WH.isset("g_items") && g_items[currentParams.pcs[i]]) ? g_items[currentParams.pcs[i]]["name_" + LOCALES[currentLocale]] : ak[4]) + ""); diff --git a/search.php b/search.php index 232af142..b6d72b58 100644 --- a/search.php +++ b/search.php @@ -857,6 +857,15 @@ if ($searchMask & 0x1000000) */ if ($searchMask & SEARCH_TYPE_JSON) { +/* + todo (med): + &wt=21:134:20:170:77:117:119:96:103&wtv=100:96:41:41:39:32:32:31:29 + additional url-parameter 'wt':ratingId/statId; 'wtv':applyPct (dafault 0) + search for items with these stats (name becomes optional) + how the fuck should i modify item_template_addon to accomodate this search behaviour... x_X + - is it possible to use space separated integers and not cause the search to take forever to execute + - one column per mod is probably the most efficient way to search but a pain to look at .. there are at least 150 after all +*/ $outItems = ''; $outSets = ''; diff --git a/setup/aowow_weightscales.sql b/setup/aowow_weightscales.sql new file mode 100644 index 00000000..1e6ecddf --- /dev/null +++ b/setup/aowow_weightscales.sql @@ -0,0 +1,52 @@ +-- MySQL dump 10.13 Distrib 5.5.27, for Win32 (x86) +-- +-- Host: localhost Database: world +-- ------------------------------------------------------ +-- Server version 5.5.27 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `aowow_account_weightscales` +-- + +DROP TABLE IF EXISTS `aowow_account_weightscales`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `aowow_account_weightscales` ( + `id` int(32) NOT NULL, + `account` int(32) NOT NULL, + `name` varchar(32) NOT NULL, + `weights` text NOT NULL, + PRIMARY KEY (`id`,`account`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `aowow_account_weightscales` +-- + +LOCK TABLES `aowow_account_weightscales` WRITE; +/*!40000 ALTER TABLE `aowow_account_weightscales` DISABLE KEYS */; +/*!40000 ALTER TABLE `aowow_account_weightscales` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2013-06-18 23:17:52 diff --git a/template/css/Summary.css b/template/css/Summary.css index 030502b3..8f4503e0 100644 --- a/template/css/Summary.css +++ b/template/css/Summary.css @@ -52,7 +52,7 @@ a#su_addscale.selected { background-color:#404040; border:1px solid #505050; border-bottom:none; - background-position:4px center; + background-position:4px 25%; padding-left:24px!important; padding-right:9px; padding-bottom:14px; diff --git a/template/css/basic.css b/template/css/basic.css index 05447132..f9bfe389 100644 --- a/template/css/basic.css +++ b/template/css/basic.css @@ -6,412 +6,189 @@ font-size: 13px; } -.wowhead-tooltip -{ - visibility: hidden; - z-index: 100000006; -} - -.wowhead-tooltip a -{ - text-decoration: none; -} - -.wowhead-tooltip a:hover -{ - text-decoration: underline; -} - -.wowhead-tooltip table -{ - border-spacing: 0; - border-collapse: collapse; - margin: 0; - /* width: auto; */ -} - -.wowhead-tooltip table, .wowhead-tooltip td, .wowhead-tooltip th, .wowhead-tooltip tbody -{ - border: 0 !important; -} - -.wowhead-tooltip td, .wowhead-tooltip th -{ - background: url(../images/tooltip.png); - font-family: Verdana, sans-serif; - font-size: 12px; - line-height: 17px; - color: white; -} - -.wowhead-tooltip th -{ - height: auto; - padding: 3px; - vertical-align: top; -} - -.wowhead-tooltip td -{ - padding: 8px 4px 1px 9px; - text-align: left; - vertical-align: top; -} - -.wowhead-tooltip b -{ - font-size: 14px; - line-height: 19px; - font-weight: normal; -} - -.wowhead-tooltip div.indent -{ - padding-left: .6em; -} - -.wowhead-tooltip td th, .wowhead-tooltip td td -{ - background: none; -} - -.wowhead-tooltip td th -{ - padding: 0 0 0 4em; - text-align: right; - font-weight: normal; -} - -.wowhead-tooltip td td -{ - padding: 0; - text-align: left; -} - -.wowhead-tooltip p -{ - position: absolute; - left: -44px; - top: -1px; - width: 44px; - height: 44px; - background: 4px 4px no-repeat; - margin: 0; - padding: 0; -} - -.wowhead-tooltip p div -{ - width: 44px; - height: 44px; - background-image: url(../../images/icons/border_medium.png); -} - -.wowhead-tooltip table.shrink b -{ - font-size: 12px; - line-height: 15px; -} - -.wowhead-tooltip table.shrink td, .wowhead-tooltip table.shrink th -{ - font-size: 10px; - line-height: 14px; -} - -.wowhead-tooltip-powered -{ - /* background: url(../../../images/powered.png) no-repeat; */ - width: 53px; - height: 33px; - position: absolute; - right: -56px; - top: 2px; - display: none; -} - -a.moneyitem, a.moneysocketmeta, a.moneysocketred, a.moneysocketyellow, a.moneysocketblue, a.moneysocketprismatic -{ - text-decoration: none !important; - border-bottom: 1px solid transparent; -} - -a.moneyitem:hover, a.moneysocketmeta:hover, a.moneysocketred:hover, a.moneysocketyellow:hover, a.moneysocketblue:hover, a.moneysocketprismatic:hover -{ - border-bottom: 1px solid white; -} - -.moneyitem, .moneygold, .moneysilver, .moneycopper, .moneyalliance, .moneyhorde, .moneyarena, .moneyachievement, .moneysocketmeta, .moneysocketred, .moneysocketyellow, .moneysocketblue, .moneysocketprismatic -{ - color: white; - background: no-repeat right center; -} - -.moneyitem -{ - padding-right: 18px; -} - -.moneygold -{ - padding-right: 15px; - background-image: url(../../images/icons/money_gold.gif); -} - -.moneysilver -{ - padding-right: 15px; - background-image: url(../../images/icons/money_silver.gif); -} - -.moneycopper -{ - padding-right: 15px; - background-image: url(../../images/icons/money_copper.gif); -} - -.moneyalliance -{ - padding-right: 12px; - background-image: url(../../images/icons/alliance-icon.gif); -} - -.moneyhorde -{ - padding-right: 17px; - background-image: url(../../images/icons/horde-icon.gif); -} - -.moneyarena -{ - padding-right: 18px; - background-image: url(../../images/icons/money_arena.gif); -} - -.moneyachievement -{ - padding-right: 13px; - background-image: url(../../images/icons/money_achievement.gif); -} - -.moneysocketmeta -{ - padding-right: 18px; - background-image: url(../../images/sockets/socket_meta.gif); -} - -.moneysocketred -{ - padding-right: 18px; - background-image: url(../../images/sockets/socket_red.gif); -} - -.moneysocketyellow -{ - padding-right: 18px; - background-image: url(../../images/sockets/socket_yellow.gif); -} - -.moneysocketblue -{ - padding-right: 18px; - background-image: url(../../images/sockets/socket_blue.gif); -} - -.moneysocketprismatic -{ - padding-right: 18px; - background-image: url(../../images/sockets/socket_prismatic.gif); -} - -.gem1{ - color: #9D9D9D !important; -} - -.gem2{ - color: #e60c0b !important; -} - -.gem4{ - color: #ffff35 !important; -} - -.gem6{ - color: #f48905 !important; -} - -.gem8{ - color: #295df1 !important; -} - -.gem10{ - color: #b957fc !important; -} - -.gem12{ - color: #22c516 !important; -} - -.gem14{ - color: #FFF !important; -} - -.q -{ - color: #ffd100 !important; -} - -.q0, .q0 a -{ - color: #9d9d9d !important; -} - -.q1, .q1 a -{ - color: #fff !important; -} - -.q2, .q2 a -{ - color: #1eff00 !important; -} - -.q3, .q3 a -{ - color: #0070dd !important; -} - -.q4, .q4 a -{ - color: #a335ee !important; -} - -.q5, .q5 a -{ - color: #ff8000 !important; -} - -.q6, .q6 a -{ - color: #e5cc80 !important; -} - -.q7, .q7 a -{ - color: #e5cc80 !important; -} - -.q8, .q8 a -{ - color: #ffff98 !important; -} - -.q9, .q9 a -{ - color: #71d5ff !important; -} - -.q10, .q10 a -{ - color: #f00 !important; -} - -.r1 -{ - color: #FF8040 !important; -} - -.r2 -{ - color: #FF0 !important; -} - -.r3 -{ - color: #40BF40 !important; -} - -.r4 -{ - color: #808080 !important; -} - -.c1, .c1 a -{ - color: #C69B6D !important; -} - -.c2, .c2 a -{ - color: #F48CBA !important; -} - -.c3, .c3 a -{ - color: #AAD372 !important; -} - -.c4, .c4 a -{ - color: #FFF468 !important; -} - -.c5, .c5 a -{ - color: #FFF !important; -} - -.c6, .c6 a -{ - color: #C41E3B !important; -} - -.c7, .c7 a -{ - color: #2359FF !important; -} - -.c8, .c8 a -{ - color: #68CCEF !important; -} - -.c9, .c9 a -{ - color: #9382C9 !important; -} - -.c11, .c11 a -{ - color: #FF7C0A !important; -} - -.socket-meta -{ - padding-left: 26px; - background: url(../../images/sockets/socket_meta.gif) no-repeat left center; -} - -.socket-red -{ - padding-left: 26px; - background: url(../../images/sockets/socket_red.gif) no-repeat left center; -} - -.socket-yellow -{ - padding-left: 26px; - background: url(../../images/sockets/socket_yellow.gif) no-repeat left center; -} - -.socket-blue -{ - padding-left: 26px; - background: url(../../images/sockets/socket_blue.gif) no-repeat left center; -} - -.socket-prismatic -{ - padding-left: 26px; - background: url(../../images/sockets/socket_prismatic.gif) no-repeat left center; +.wowhead-tooltip { visibility: hidden; z-index: 100000006; overflow: visible !important; } +.wowhead-tooltip a { text-decoration: none; } +.wowhead-tooltip a:hover { text-decoration: underline; } + +.wowhead-tooltip table { border-spacing: 0; border-collapse: collapse; margin: 0; width: auto; } /*maybe remove width:auto*/ +.wowhead-tooltip table, .wowhead-tooltip td, .wowhead-tooltip th, .wowhead-tooltip tbody { border: 0 !important; } +.wowhead-tooltip td table td table { width: 100% } +.wowhead-tooltip td, .wowhead-tooltip th { background: url(../images/tooltip.png); font-family: Verdana, sans-serif; font-size: 12px; line-height: 17px; color: white; } + +.wowhead-tooltip th { height: auto; padding: 3px; vertical-align: top; } +.wowhead-tooltip td { padding: 8px 4px 1px 9px; text-align: left; vertical-align: top; } +.wowhead-tooltip b { font-size: 14px; line-height: 19px; font-weight: normal; } + +.wowhead-tooltip div.indent { padding-left: .6em; } +.wowhead-tooltip td th, .wowhead-tooltip td td { background: none; } +.wowhead-tooltip td th { padding: 0 0 0 4em; text-align: right; font-weight: normal; } +.wowhead-tooltip td td { padding: 0; text-align: left; } + +.wowhead-tooltip p { position: absolute; left: -44px; top: -1px; width: 44px; height: 44px; background: 4px 4px no-repeat; margin: 0; padding: 0; } +.wowhead-tooltip p div { width: 44px; height: 44px; background-image: url(../../images/icons/border_medium.png); } + +.wowhead-tooltip table.shrink b { font-size: 12px; line-height: 15px; } +.wowhead-tooltip table.shrink td, .wowhead-tooltip table.shrink th { font-size: 10px; line-height: 14px; } + +.wowhead-tooltip .mapper { margin: 2px 0 3px 1px; border: none } + +.wowhead-tooltip ins { color: #5DF644; text-decoration: none; border-bottom: 1px dotted; } +.wowhead-tooltip del { color: #FF8040; text-decoration: none; border-bottom: 1px dotted; } + +.wowhead-tooltip-powered { + /* background: url(../../../images/powered.png) no-repeat; */ + width: 53px; + height: 33px; + position: absolute; + right: -56px; + top: 2px; + display: none; +} + +.moneyitem, .moneygold, .moneysilver, .moneycopper, .moneyalliance, .moneyhorde, .moneyarena, .moneyachievement, .moneysocketmeta, .moneysocketred, .moneysocketyellow, .moneysocketblue, .moneysocketprismatic { + background: no-repeat right center; + color: white; +} + +.moneyitem { padding-right: 18px; } +.moneygold { padding-right: 15px; background-image: url(../../images/icons/money_gold.gif); } +.moneysilver { padding-right: 15px; background-image: url(../../images/icons/money_silver.gif); } +.moneycopper { padding-right: 15px; background-image: url(../../images/icons/money_copper.gif); } +.moneyalliance { padding-right: 12px; background-image: url(../../images/icons/alliance-icon.gif); } +.moneyhorde { padding-right: 17px; background-image: url(../../images/icons/horde-icon.gif); } +.moneyarena { padding-right: 18px; background-image: url(../../images/icons/money_arena.gif); } +.moneyachievement { padding-right: 13px; background-image: url(../../images/icons/money_achievement.gif); } +.moneysocketmeta { padding-right: 18px; background-image: url(../../images/sockets/socket_meta.gif); } +.moneysocketred { padding-right: 18px; background-image: url(../../images/sockets/socket_red.gif); } +.moneysocketyellow { padding-right: 18px; background-image: url(../../images/sockets/socket_yellow.gif); } +.moneysocketblue { padding-right: 18px; background-image: url(../../images/sockets/socket_blue.gif); } +.moneysocketprismatic { padding-right: 18px; background-image: url(../../images/sockets/socket_prismatic.gif); } + +a.moneyitem, a.moneysocketmeta, a.moneysocketred, a.moneysocketyellow, a.moneysocketblue, a.moneysocketprismatic, a.moneyachievement{ + text-decoration: none !important; + border-bottom: 1px solid transparent; + color: white !important; +} + +a.moneyitem:hover, a.moneysocketmeta:hover, a.moneysocketred:hover, a.moneysocketyellow:hover, a.moneysocketblue:hover, a.moneysocketprismatic:hover, a.moneyachievement:hover { + border-bottom: 1px solid white; +} + +a span.moneyitem, a span.moneysocketmeta, a span.moneysocketred, a span.moneysocketyellow, a span.moneysocketblue, a span.moneysocketprismatic, a span.moneyachievement { + color: white; +} + +.blizzard-blue { color: #00C0FF !important; } + +/***********************/ +/* ITEM QUALITY COLORS */ +/***********************/ + +.q, .q a, .color-q, .wowhead-tooltip .q a { color: #ffd100 !important; } /* Default (yellow) */ +.q0, .q0 a, .color-q0, .wowhead-tooltip .q0 a { color: #9d9d9d !important; } /* Poor */ +.q1, .q1 a, .color-q1, .wowhead-tooltip .q1 a { color: #ffffff !important; } /* Common */ +.q2, .q2 a, .color-q2, .wowhead-tooltip .q2 a { color: #1eff00 !important; } /* Uncommon */ +.q3, .q3 a, .color-q3, .wowhead-tooltip .q3 a { color: #0070dd !important; } /* Rare */ +.q4, .q4 a, .color-q4, .wowhead-tooltip .q4 a { color: #a335ee !important; } /* Epic */ +.q5, .q5 a, .color-q5, .wowhead-tooltip .q5 a { color: #ff8000 !important; } /* Legendary */ +.q6, .q6 a, .color-q6, .wowhead-tooltip .q6 a { color: #e5cc80 !important; } /* Artifact */ +.q7, .q7 a, .color-q7, .wowhead-tooltip .q7 a { color: #e5cc80 !important; } /* Heirloom */ +.q8, .q8 a, .color-q8, .wowhead-tooltip .q8 a { color: #ffff98 !important; } /* Light yellow (item set bonuses) */ +.q9, .q9 a, .color-q9, .wowhead-tooltip .q9 a { color: #71d5ff !important; } /* Light blue (glyph type) */ +.q10, .q10 a, .color-q10, .wowhead-tooltip .q10 a { color: #ff4040 !important; } /* Red (requirement not met, error) */ + +/*********************/ +/* DIFFICULTY COLORS */ +/*********************/ + +.r1 { color: #FF8040 !important } /* Hard */ +.r2 { color: #FFFF00 !important } /* Medium */ +.r3 { color: #40BF40 !important } /* Easy */ +.r4 { color: #808080 !important } /* Trivial */ + +/****************/ +/* CLASS COLORS */ +/****************/ + +.c1, .c1 a { color: #C69B6D !important } /* Warrior */ +.c2, .c2 a { color: #F48CBA !important } /* Paladin */ +.c3, .c3 a { color: #AAD372 !important } /* Hunter */ +.c4, .c4 a { color: #FFF468 !important } /* Rogue */ +.c5, .c5 a { color: #FFFFFF !important } /* Priest */ +.c6, .c6 a { color: #C41E3B !important } /* Death Knight */ +.c7, .c7 a { color: #2359FF !important } /* Shaman */ +.c8, .c8 a { color: #68CCEF !important } /* Mage */ +.c9, .c9 a { color: #9382C9 !important } /* Warlock */ +.c11, .c11 a { color: #FF7C0A !important } /* Druid */ + +/**************/ +/* GEM COLORS */ +/**************/ + +.gem1 { color: #9D9D9D !important } /* Meta */ +.gem2 { color: #e60c0b !important } /* Red */ +.gem4 { color: #ffff35 !important } /* Yellow */ +.gem6 { color: #f48905 !important } /* Orange */ +.gem8 { color: #295df1 !important } /* Blue */ +.gem10 { color: #b957fc !important } /* Purple */ +.gem12 { color: #22c516 !important } /* Green */ +.gem14 { color: #FFFFFF !important } /* Prismatic */ + +/****************/ +/* NPC MESSAGES */ +/****************/ + +.s1 { color: #ff3f40 !important } /* Yell */ +.s2 { color: #fffb9f !important } /* Say */ +.s3 { color: #ffb2eb !important } /* Whisper */ + +/*****************/ +/* SOCKETS ICONS */ +/*****************/ + +.socket-meta { padding-left: 26px; background: url(../../images/sockets/socket_meta.gif) no-repeat left center; } +.socket-red { padding-left: 26px; background: url(../../images/sockets/socket_red.gif) no-repeat left center; } +.socket-yellow { padding-left: 26px; background: url(../../images/sockets/socket_yellow.gif) no-repeat left center; } +.socket-blue { padding-left: 26px; background: url(../../images/sockets/socket_blue.gif) no-repeat left center; } +.socket-prismatic { padding-left: 26px; background: url(../../images/sockets/socket_prismatic.gif) no-repeat left center; } + +/***********/ +/* WIDGETS */ +/***********/ + +#wowhead-bluetip { + position: absolute; + z-index: 99999; + color: #fff; + font-size: 11px; + text-align: center; + padding: 6px 8px; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + background: rgba(0, 0, 0, 0.8); + text-align: left; + max-width: 300px; +} + +.message-box { + position: absolute; + z-index: 1000; + cursor: pointer; + border: 2px solid #666; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; + padding: 15px; + background:url(../images/blk.png) repeat; +} + +.message-box .close { + text-indent: -9999px; + background:url(../images/close.png) no-repeat; + width: 10px; + height: 10px; + position: absolute; + top: 5px; + right: 5px; } diff --git a/template/css/locale_dede.css b/template/css/locale_dede.css index c3a643d3..aa7736da 100644 --- a/template/css/locale_dede.css +++ b/template/css/locale_dede.css @@ -119,7 +119,9 @@ a:hover.screenshotviewer-close span left: -25px !important; } +/* #su_weights { - width: 485px !important; + width: 550px !important; } + */ diff --git a/template/css/locale_eses.css b/template/css/locale_eses.css index 99a3bf46..a1a21458 100644 --- a/template/css/locale_eses.css +++ b/template/css/locale_eses.css @@ -124,7 +124,9 @@ a:hover.screenshotviewer-close span left: -68px !important; } +/* #su_weights { width: 500px !important; } + */ \ No newline at end of file diff --git a/template/css/locale_frfr.css b/template/css/locale_frfr.css index b9e3b3ca..895cb2b1 100644 --- a/template/css/locale_frfr.css +++ b/template/css/locale_frfr.css @@ -119,7 +119,9 @@ a:hover.screenshotviewer-close span left: -49px !important; } +/* #su_weights { width: 550px !important; } + */ \ No newline at end of file diff --git a/template/css/locale_ruru.css b/template/css/locale_ruru.css index 9c1013bc..2f99e45b 100644 --- a/template/css/locale_ruru.css +++ b/template/css/locale_ruru.css @@ -119,7 +119,9 @@ a:hover.screenshotviewer-close span left: -59px !important; } +/* #su_weights { width: 625px !important; } + */ \ No newline at end of file diff --git a/template/css/talentcalc.css b/template/css/talentcalc.css index 8b12329d..2a44f64f 100644 --- a/template/css/talentcalc.css +++ b/template/css/talentcalc.css @@ -1,403 +1,400 @@ .talentcalc-sidebar-anchor { -position:relative; + position:relative; } .talentcalc-sidebar { -position:absolute; -top:0; -padding:10px; -background-color:#141414; + position:absolute; + top:0; + padding:10px; + background-color:#141414; } .talentcalc-sidebar-inner { -width:300px; + width:300px; } .talentcalc-sidebar-controls { -padding-bottom:10px; + padding-bottom:10px; } -a.talentcalc-button-help,.talentcalc-sidebar-controls a { -display:block; -padding:2px 0 2px 20px; -margin-right:10px; -background:no-repeat left center; +a.talentcalc-button-help, .talentcalc-sidebar-controls a { + display:block; + padding:2px 0 2px 20px; + margin-right:10px; + background:no-repeat left center; } a.talentcalc-button-help { -position:absolute; -right:10px; -top:10px; -margin:0; -background-image:url(../images/help.gif); + position:absolute; + right:10px; + top:10px; + margin:0; + background-image:url(../images/help.gif); } a.talentcalc-button-lock { -float:left; -background-image:url(../images/locked.gif); + float:left; + background-image:url(../images/locked.gif); } a.talentcalc-button-unlock { -float:left; -background-image:url(../images/unlocked.gif); + float:left; + background-image:url(../images/unlocked.gif); } a.talentcalc-button-reset { -float:left; -padding-left:19px; -background-image:url(../images/delete.gif); + float:left; + padding-left:19px; + background-image:url(../images/delete.gif); } .talentcalc-sidebar-controls2 a { -margin-right:10px; -float:left; -padding:2px 0; -background:no-repeat left center; + margin-right:10px; + float:left; + padding:2px 0; + background:no-repeat left center; } a.talentcalc-button-export { -padding-left:19px; -background-image:url(../images/link.gif); + padding-left:19px; + background-image:url(../images/link.gif); } a.talentcalc-button-summary { -padding-left:19px; -background-image:url(../images/print.gif); + padding-left:19px; + background-image:url(../images/print.gif); } .talentcalc-sidebar h3 { -font-size:14px; -margin:1.5em 0 .5em; -padding:0; + font-size:14px; + margin:1.5em 0 .5em; + padding:0; } .talentcalc-sidebar h3.first { -margin-top:0; + margin-top:0; } .talentcalc-sidebar h3 a { -font-size:11px; -margin-left:6px; + font-size:11px; + margin-left:6px; } -.talentcalc-sidebar-majorglyphs,.talentcalc-sidebar-minorglyphs { -float:left; -width:150px; -font-size:11px; +.talentcalc-sidebar-majorglyphs, .talentcalc-sidebar-minorglyphs { + float:left; + width:150px; + font-size:11px; } .talentcalc-sidebar .icontab td { -width:103px; + width:103px; } .talentcalc-sidebar .icontab a { -text-decoration:none; + text-decoration:none; } .talentcalc-upper { -background-color:#141414; -margin-bottom:5px; + background-color:#141414; + margin-bottom:5px; + padding:6px 8px; + font-size:14px; } -.talentcalc-upper-inner { -padding:6px 8px; -font-size:14px; +.talentcalc-upper span { + color:#DDD; } -.talentcalc-upper-inner span { -color:#DDD; -} - -.talentcalc-upper-inner b { -color:white; +.talentcalc-upper b { + color:white; } .talentcalc-upper-class { -float:left; + float:left; } .talentcalc-upper-class a { -text-decoration:none; + text-decoration:none; } .talentcalc-upper-class a:hover { -text-decoration:underline; + text-decoration:underline; } .talentcalc-upper-reqlevel { -float:right; + float:right; } .talentcalc-upper-ptsleft { -margin-left:60px; -float:right; + margin-left:60px; + float:right; } .talentcalc-upper-ptsleft a { -font-size:11px; -font-weight:bold; -margin-left:6px; + font-size:11px; + font-weight:bold; + margin-left:6px; } .talentcalc-main { -background-color:black; -border:1px solid #404040; + background-color:black; + border:1px solid #404040; } .talentcalc-default .talentcalc-main { -width:614px; -height:554px; + width:614px; + height:554px; } .talentcalc-pet .talentcalc-main { -width:244px; -height:364px; -margin-left: 370px; -/* background: url(../../../images/talent/pet-tree-glow.png); */ + width:244px; + height:364px; + margin-left: 370px; + /* background: url(../../images/talent/pet-tree-glow.png); */ } .talentcalc-main table { -border-collapse:collapse; -margin:2px; + border-collapse:collapse; + margin:2px; } .talentcalc-main table td { -padding:0; + padding:0; } .talentcalc-default table td { -width:50px; -height:50px; + width:50px; + height:50px; } .talentcalc-pet table td { -width:60px; -height:60px; + width:60px; + height:60px; } .iconmedium div.icon-border { -position:absolute; -z-index:15; -left:1px; -top:1px; -width:42px; -height:42px; -background:url(../../../images/talent/border.gif) no-repeat; + position:absolute; + z-index:15; + left:1px; + top:1px; + width:42px; + height:42px; + background:url(../../images/talent/border.gif) no-repeat; } .iconmedium div.icon-bubble { -position:absolute; -z-index:16; -width:22px; -height:23px; -left:30px; -top:29px; -background:url(../../../images/talent/bubble2.png) no-repeat; -visibility:hidden; -padding:4px 0 0; -font-family:Verdana,sans-serif; -font-size:12px; -text-align:center; -cursor:default; + position:absolute; + z-index:16; + width:22px; + height:23px; + left:30px; + top:29px; + background:url(../../images/talent/bubble2.png) no-repeat; + visibility:hidden; + padding:4px 0 0; + font-family:Verdana,sans-serif; + font-size:12px; + text-align:center; + cursor:default; } .iconmedium a.bubbly { -background-image:url(../../../images/talent/hilite_medium_talent.png); + background-image:url(../../images/talent/hilite_medium_talent.png); } .talentcalc-arrow-anchor { -position:relative; -z-index:30; + position:relative; + z-index:30; } .talentcalc-arrow { -position:absolute; -z-index:30; + position:absolute; + z-index:30; } .talentcalc-arrow table { -width:100%; -height:100%; -border-collapse:collapse; + width:100%; + height:100%; + border-collapse:collapse; } -.talentcalc-arrow table td,.talentcalc-arrow table th { -font-size:1px; -width:auto; -height:auto; +.talentcalc-arrow table td, .talentcalc-arrow table th { + font-size:1px; + width:auto; + height:auto; } .talentcalc-arrow-leftdown td { -background-image:url(../../../images/talent/arrows/leftdown.png); + background-image:url(../../images/talent/arrows/leftdown.png); } .talentcalc-arrow-leftdown2 td { -background-image:url(../../../images/talent/arrows/leftdown2.png); + background-image:url(../../images/talent/arrows/leftdown2.png); } .talentcalc-arrow-rightdown td { -background-image:url(../../../images/talent/arrows/rightdown.png); + background-image:url(../../images/talent/arrows/rightdown.png); } .talentcalc-arrow-rightdown2 td { -background-image:url(../../../images/talent/arrows/rightdown2.png); + background-image:url(../../images/talent/arrows/rightdown2.png); } .talentcalc-arrow-right td { -background-image:url(../../../images/talent/arrows/right.png); + background-image:url(../../images/talent/arrows/right.png); } .talentcalc-arrow-right2 td { -background-image:url(../../../images/talent/arrows/right2.png); + background-image:url(../../images/talent/arrows/right2.png); } .talentcalc-arrow-left td { -background-image:url(../../../images/talent/arrows/left.png); + background-image:url(../../images/talent/arrows/left.png); } .talentcalc-arrow-left2 td { -background-image:url(../../../images/talent/arrows/left2.png); + background-image:url(../../images/talent/arrows/left2.png); } .talentcalc-lower { -position:relative; -height:24px; -margin-top:5px; + position:relative; + height:24px; + margin-top:5px; } .talentcalc-pet .talentcalc-lower { -width:244px; -margin-left:185px; + width:244px; + margin-left:185px; } -.talentcalc-lower-tree1,.talentcalc-lower-tree2,.talentcalc-lower-tree3 { -position:absolute; -top:0; +.talentcalc-lower-tree1, .talentcalc-lower-tree2, .talentcalc-lower-tree3 { + position:absolute; + top:0; } -.talentcalc-default .talentcalc-lower-tree1,.talentcalc-default .talentcalc-lower-tree2,.talentcalc-default .talentcalc-lower-tree3 { -width:204px; +.talentcalc-default .talentcalc-lower-tree1, .talentcalc-default .talentcalc-lower-tree2, .talentcalc-default .talentcalc-lower-tree3 { + width:204px; } -.talentcalc-pet .talentcalc-lower-tree1,.talentcalc-pet .talentcalc-lower-tree2,.talentcalc-pet .talentcalc-lower-tree3 { -margin-left:185px; -width:244px; +.talentcalc-pet .talentcalc-lower-tree1, .talentcalc-pet .talentcalc-lower-tree2, .talentcalc-pet .talentcalc-lower-tree3 { + margin-left:185px; + width:244px; } .talentcalc-lower-tree1 { -left:1px; + left:1px; } .talentcalc-lower-tree2 { -left:206px; + left:206px; } .talentcalc-lower-tree3 { -left:411px; + left:411px; } .talentcalc-lower p { -background-color:#141414; -height:24px; -line-height:24px; -overflow:hidden; -padding:0; -margin:0 auto; -text-align:center; + background-color:#141414; + height:24px; + line-height:24px; + overflow:hidden; + padding:0; + margin:0 auto; + text-align:center; } .talentcalc-default .talentcalc-lower p { -width:200px; + width:200px; } .talentcalc-pet .talentcalc-lower p { -width:238px; + width:238px; } .talentcalc-lower b { -font-size:13px; -background:left center no-repeat; -padding:4px 0 4px 28px; + font-size:13px; + background:left center no-repeat; + padding:4px 0 4px 28px; } .talentcalc-pet .talentcalc-lower b { -padding-left:0; + padding-left:0; } .talentcalc-lower span { -font-size:11px; -color:#DDD; + font-size:11px; + color:#DDD; } .talentcalc-lower a { -display:block; -position:absolute; -right:2px; -top:2px; -width:20px; -height:20px; -opacity:.3333; -background:url(../images/delete.gif) no-repeat 2px 2px; + display:block; + position:absolute; + right:2px; + top:2px; + width:20px; + height:20px; + opacity:.3333; + background:url(../images/delete.gif) no-repeat 2px 2px; } .talentcalc-lower a:hover { -opacity:1; + opacity:1; } .talentcalc-glyphpicker { -font-size:13px; -width:780px; -height:554px; -background-color:#303030; -border:10px solid #303030; -border-bottom:0; + font-size:13px; + width:780px; + height:554px; + background-color:#303030; + border:10px solid #303030; + border-bottom:0; } .talentcalc-glyphpicker .listview { -border:0; + border:0; } .talentcalc-glyphpicker .listview-band-top { -background-color:#303030; -height:15px; + background-color:#303030; + height:15px; } -.talentcalc,.talentcalc-main table td .iconmedium { -margin:0 auto; +.talentcalc, .talentcalc-main table td .iconmedium { + margin:0 auto; } -.talentcalc-default,.talentcalc-pet { -width:946px; +.talentcalc-default, .talentcalc-pet { + width:946px; } -.talentcalc-default .talentcalc-sidebar,.talentcalc-pet .talentcalc-sidebar { -left:621px; +.talentcalc-default .talentcalc-sidebar, .talentcalc-pet .talentcalc-sidebar { + left:621px; } -.talentcalc-default .talentcalc-upper,.talentcalc-pet .talentcalc-upper,.talentcalc-default .talentcalc-lower { -width:616px; +.talentcalc-default .talentcalc-upper, .talentcalc-pet .talentcalc-upper, .talentcalc-default .talentcalc-lower { + width:600px; } -.talentcalc-arrow-down td,.talentcalc-arrow-leftdown th,.talentcalc-arrow-rightdown th { -background-image:url(../../../images/talent/arrows/down.png); +.talentcalc-arrow-down td, .talentcalc-arrow-leftdown th, .talentcalc-arrow-rightdown th { + background-image:url(../../images/talent/arrows/down.png); } -.talentcalc-arrow-down2 td,.talentcalc-arrow-leftdown2 th,.talentcalc-arrow-rightdown2 th { -background-image:url(../../../images/talent/arrows/down2.png); +.talentcalc-arrow-down2 td, .talentcalc-arrow-leftdown2 th, .talentcalc-arrow-rightdown2 th { + background-image:url(../../images/talent/arrows/down2.png); } .talentcalc-wrapper { - float: left; - width: 614px; /* fixes IE7 being dumb and moving down the glyph window */ + float: left; + width: 614px; /* fixes IE7 being dumb and moving down the glyph window */ position: relative; } .talentcalc-model { - background-color: #141414; - border: 1px solid #404040; - width: 368px; - height: 364px; - float: left; + background-color: #141414; + border: 1px solid #404040; + width: 368px; + height: 364px; + float: left; position: absolute; top: 33px; } \ No newline at end of file diff --git a/template/generic-no-filter.tpl b/template/generic-no-filter.tpl index e513eb1b..b6ed16bd 100644 --- a/template/generic-no-filter.tpl +++ b/template/generic-no-filter.tpl @@ -10,7 +10,7 @@ {include file='bricks/announcement.tpl' an=$item} {/foreach} {/if} -{if isset($lvData.map)} +{if !empty($lvData.map)} {include file='bricks/mapper.tpl' map=$lvData.map som=$lvData.som} {/if} diff --git a/template/head.tpl b/template/head.tpl index 0a2f227d..5400923d 100644 --- a/template/head.tpl +++ b/template/head.tpl @@ -40,5 +40,6 @@ permissions:{$user.perms} {if isset($user.chars)}, characters: {$user.chars} {/if} {if isset($user.profiles)}, profiles: {$user.profiles}{/if} + {if isset($user.weights)}, weightscales: {$user.weights}{/if} {/strip} {rdelim}; diff --git a/template/images/blk.png b/template/images/blk.png new file mode 100644 index 00000000..83606591 Binary files /dev/null and b/template/images/blk.png differ diff --git a/template/images/close.png b/template/images/close.png new file mode 100644 index 00000000..cad22a0c Binary files /dev/null and b/template/images/close.png differ diff --git a/template/js/Draggable.js b/template/js/Draggable.js index 418ee31a..f59d11de 100644 --- a/template/js/Draggable.js +++ b/template/js/Draggable.js @@ -1,62 +1,62 @@ var Draggable = new function () { - var + var start = {}, mouse = {}, clickObj, dragObj; function onMouseDown(e) { - e = $E(e); + e = $E(e); - if (this._handle) { - var _ = e._target, - found = false, - i = 0; + if (this._handle) { + var _ = e._target, + found = false, + i = 0; - while (_ && i <= 3) { - if (_ == this._handle) { - found = true; - break; - } + while (_ && i <= 3) { + if (_ == this._handle) { + found = true; + break; + } - _ = _.parentNode; + _ = _.parentNode; ++i; - } + } - if (!found) { - return false; - } - } + if (!found) { + return false; + } + } - clickObj = this; + clickObj = this; - start = g_getCursorPos(e); + start = g_getCursorPos(e); - aE(document, 'mousemove', onMouseMove); - aE(document, 'mouseup', onMouseUp); + aE(document, 'mousemove', onMouseMove); + aE(document, 'mouseup', onMouseUp); - if (clickObj.onClick) { - clickObj.onClick(e, clickObj); - } + if (clickObj.onClick) { + clickObj.onClick(e, clickObj); + } - return false; - } + return false; + } - function onMouseMove(e) { - e = $E(e); + function onMouseMove(e) { + e = $E(e); - var pos = g_getCursorPos(e); + var pos = g_getCursorPos(e); - if (clickObj) { - if (Math.abs(pos.x - start.x) > 5 || Math.abs(pos.y - start.y) > 5) { - onDragStart(e, clickObj); - clickObj = null; - } - } + if (clickObj) { + if (Math.abs(pos.x - start.x) > 5 || Math.abs(pos.y - start.y) > 5) { + onDragStart(e, clickObj); + clickObj = null; + } + } if (!dragObj || !dragObj._bounds) { - return false; - } + return false; + } var bounds = getBounds(dragObj), @@ -64,166 +64,166 @@ var Draggable = new function () { dY = pos.y - start.y; dX = Math.max(dragObj._bounds.x1 - mouse.x, Math.min(dragObj._bounds.x2 - mouse.x - (bounds.x2 - bounds.x1), dX)); - dY = Math.max(dragObj._bounds.y1 - mouse.y, Math.min(dragObj._bounds.y2 - mouse.y - (bounds.y2 - bounds.y1), dY)); + dY = Math.max(dragObj._bounds.y1 - mouse.y, Math.min(dragObj._bounds.y2 - mouse.y - (bounds.y2 - bounds.y1), dY)); - setPosition(dX, dY); + setPosition(dX, dY); - return false; - } + return false; + } - function onMouseUp(e) { - e = $E(e); + function onMouseUp(e) { + e = $E(e); - clickObj = null; + clickObj = null; - if (dragObj) { - onDragEnd(e); - } - } + if (dragObj) { + onDragEnd(e); + } + } - function onDragStart(e, obj) { - if (dragObj) { - onDragEnd(e); - } + function onDragStart(e, obj) { + if (dragObj) { + onDragEnd(e); + } - var foo = ac(obj); - mouse.x = foo[0]; - mouse.y = foo[1]; + var foo = ac(obj); + mouse.x = foo[0]; + mouse.y = foo[1]; - if (obj._targets.length) { - dragObj = obj.cloneNode(true); - dragObj._orig = obj; + if (obj._targets.length) { + dragObj = obj.cloneNode(true); + dragObj._orig = obj; - ae(ge('layers'), dragObj); - // ae(document.body, dragObj); // 5.0.. why does it do that? - setPosition(-2323, -2323); - } + ae(ge('layers'), dragObj); + // ae(document.body, dragObj); // 5.0.. why does it do that? + setPosition(-2323, -2323); + } else { - dragObj = obj; - } + dragObj = obj; + } - Tooltip.disabled = true; - Tooltip.hide(); + Tooltip.disabled = true; + Tooltip.hide(); - if (obj.onDrag) { - obj.onDrag(e, dragObj, obj); - } + if (obj.onDrag) { + obj.onDrag(e, dragObj, obj); + } - dragObj._bounds = getBounds(obj._container); - dragObj.className += ' dragged'; - } + dragObj._bounds = getBounds(obj._container); + dragObj.className += ' dragged'; + } - function onDragEnd(e) { - var + function onDragEnd(e) { + var found = false, cursor = g_getCursorPos(e); if (dragObj._orig && dragObj._orig._targets.length) { - clearPosition(); + clearPosition(); - var pos = { - x1: dragObj._x, - x2: dragObj._x + parseInt(dragObj.offsetWidth), - y1: dragObj._y, - y2: dragObj._y + parseInt(dragObj.offsetHeight) - }; + var pos = { + x1: dragObj._x, + x2: dragObj._x + parseInt(dragObj.offsetWidth), + y1: dragObj._y, + y2: dragObj._y + parseInt(dragObj.offsetHeight) + }; - de(dragObj); - dragObj = dragObj._orig; + de(dragObj); + dragObj = dragObj._orig; - for (var i = 0, len = dragObj._targets.length; i < len; ++i) { - var targObj = dragObj._targets[i], - bounds = getBounds(targObj); + for (var i = 0, len = dragObj._targets.length; i < len; ++i) { + var targObj = dragObj._targets[i], + bounds = getBounds(targObj); - if (pos.x2 >= bounds.x1 && pos.x1 < bounds.x2 && pos.y2 >= bounds.y1 && pos.y1 < bounds.y2) { - found = true; - if (dragObj.onDrop) { - dragObj.onDrop(e, dragObj, targObj, (cursor.x >= bounds.x1 && cursor.x <= bounds.x2 && cursor.y >= bounds.y1 && cursor.y <= bounds.y2)); - } + if (pos.x2 >= bounds.x1 && pos.x1 < bounds.x2 && pos.y2 >= bounds.y1 && pos.y1 < bounds.y2) { + found = true; + if (dragObj.onDrop) { + dragObj.onDrop(e, dragObj, targObj, (cursor.x >= bounds.x1 && cursor.x <= bounds.x2 && cursor.y >= bounds.y1 && cursor.y <= bounds.y2)); + } else { - ae(targObj, dragObj); - } - } - } - } + ae(targObj, dragObj); + } + } + } + } - if (!found && dragObj.onDrop) { - dragObj.onDrop(e, dragObj, null); - } + if (!found && dragObj.onDrop) { + dragObj.onDrop(e, dragObj, null); + } - dE(document, 'mousemove', onMouseMove); - dE(document, 'mouseup', onMouseUp); + dE(document, 'mousemove', onMouseMove); + dE(document, 'mouseup', onMouseUp); - Tooltip.disabled = false; + Tooltip.disabled = false; - dragObj.className = dragObj.className.replace(/dragged/, ''); - dragObj = null; - } + dragObj.className = dragObj.className.replace(/dragged/, ''); + dragObj = null; + } - function setPosition(dX, dY) { - dragObj.style.position = 'absolute'; - dragObj.style.left = mouse.x + dX + 'px'; - dragObj.style.top = mouse.y + dY + 'px'; + function setPosition(dX, dY) { + dragObj.style.position = 'absolute'; + dragObj.style.left = mouse.x + dX + 'px'; + dragObj.style.top = mouse.y + dY + 'px'; - dragObj._x = mouse.x + dX; - dragObj._y = mouse.y + dY; - } + dragObj._x = mouse.x + dX; + dragObj._y = mouse.y + dY; + } - function clearPosition() { - dragObj.style.left = '-2323px'; - dragObj.style.top = '-2323px'; - } + function clearPosition() { + dragObj.style.left = '-2323px'; + dragObj.style.top = '-2323px'; + } - function getBounds(obj) { - var pos = ac(obj); + function getBounds(obj) { + var pos = ac(obj); - return { - x1: pos[0], - x2: pos[0] + parseInt(obj.offsetWidth), - y1: pos[1], - y2: pos[1] + parseInt(obj.offsetHeight) - }; - } + return { + x1: pos[0], + x2: pos[0] + parseInt(obj.offsetWidth), + y1: pos[1], + y2: pos[1] + parseInt(obj.offsetHeight) + }; + } - this.init = function (obj, opt) { - obj.onmousedown = onMouseDown; + this.init = function (obj, opt) { + obj.onmousedown = onMouseDown; - var a = obj.getElementsByTagName('a'); - for (var i = 0, len = a.length; i < len; ++i) { - ns(a[i]); - } + var a = obj.getElementsByTagName('a'); + for (var i = 0, len = a.length; i < len; ++i) { + ns(a[i]); + } - if (!obj._targets) { - obj._targets = []; - } + if (!obj._targets) { + obj._targets = []; + } - if (!obj._container) { - obj._container = document.body; - } + if (!obj._container) { + obj._container = document.body; + } - if (opt != null) { - if (opt.targets) { - for (var i = 0, len = opt.targets.length; i < len; ++i) { - obj._targets.push(ge(opt.targets[i])); - } - } + if (opt != null) { + if (opt.targets) { + for (var i = 0, len = opt.targets.length; i < len; ++i) { + obj._targets.push(ge(opt.targets[i])); + } + } - if (opt.container) { - obj._container = $(opt.container); - } + if (opt.container) { + obj._container = $(opt.container); + } - // Functions - if (opt.onClick) { - obj.onClick = opt.onClick; - } + // Functions + if (opt.onClick) { + obj.onClick = opt.onClick; + } - if (opt.onDrop) { - obj.onDrop = opt.onDrop; - } + if (opt.onDrop) { + obj.onDrop = opt.onDrop; + } - if (opt.onDrag) { - obj.onDrag = opt.onDrag; - } - } - } + if (opt.onDrag) { + obj.onDrag = opt.onDrag; + } + } + } }; diff --git a/template/js/ShowOnMap.js b/template/js/ShowOnMap.js index 0bc0ef62..d732ce33 100644 --- a/template/js/ShowOnMap.js +++ b/template/js/ShowOnMap.js @@ -1,98 +1,98 @@ var ShowOnMap = function(data, mapper) { - var self = this; - self.data = data; + var self = this; + self.data = data; - if (mapper == null) { - mapper = myMapper; - } + if (mapper == null) { + mapper = myMapper; + } - self.mapper = mapper; + self.mapper = mapper; - self._legend = null; - self._legendLabel = null; - self._legendContents = null; - self._legendHorde = null; - self._legendAlliance = null; - self._menu = []; + self._legend = null; + self._legendLabel = null; + self._legendContents = null; + self._legendHorde = null; + self._legendAlliance = null; + self._menu = []; - self.construct(); + self.construct(); }; ShowOnMap.prototype.onExpand = function() { - this.expanded = true; - location.replace(this.pound + '.map'); + this.expanded = true; + location.replace(this.pound + '.map'); }; ShowOnMap.prototype.onCollapse = function() { - this.expanded = false; - var hash = g_getHash(); - if (hash.indexOf('#show') == 0 && hash.indexOf('.map') > 0) { - this.pound = hash.substr(0, hash.indexOf('.map')); - location.replace(this.pound); - } + this.expanded = false; + var hash = g_getHash(); + if (hash.indexOf('#show') == 0 && hash.indexOf('.map') > 0) { + this.pound = hash.substr(0, hash.indexOf('.map')); + location.replace(this.pound); + } } ShowOnMap.prototype.construct = function() { - if (!this.data) { - return; - } + if (!this.data) { + return; + } - var d = ge('som-generic'); + var d = ge('som-generic'); - var cmpFunc = function(a, b) { - return strcmp(a[1], b[1]); - }; + var cmpFunc = function(a, b) { + return strcmp(a[1], b[1]); + }; - var allianceMenu = []; - var hordeMenu = []; - for (var i in this.data) { - if (this.data[i].length === undefined) { - var submenu = []; - var allCoords = []; - var allLegend = {}; - var group = this.data[i]; - for (var p in group) { - var hasPaths = false; - for (var n = 0, len = group[p].length; n < len; ++n) { - if (group[p][n].paths) { - hasPaths = true; - break; - } - } + var allianceMenu = []; + var hordeMenu = []; + for (var i in this.data) { + if (this.data[i].length === undefined) { + var submenu = []; + var allCoords = []; + var allLegend = {}; + var group = this.data[i]; + for (var p in group) { + var hasPaths = false; + for (var n = 0, len = group[p].length; n < len; ++n) { + if (group[p][n].paths) { + hasPaths = true; + break; + } + } - var i2 = g_urlize(p); - if (group[p][0].name_enus !== undefined) { - i2 = g_urlize(group[p][0].name_enus); - } + var i2 = g_urlize(p); + if (group[p][0].name_enus !== undefined) { + i2 = g_urlize(group[p][0].name_enus); + } - var coords = {}; - var legend = {}; - var entry = [i2]; - //pin.list.key = i; - var combined = ShowOnMap.combinePins(group[p], false, hasPaths); - var pins = combined[0]; - var nPins = combined[1]; - var nCoords = 0; - for (var n = 0; n < pins.length; ++n) { - var pin = pins[n]; - var tooltip = ShowOnMap.buildTooltip(pin.list); - var url = tooltip[2]; - var m = null; - if (url == 'javascript:;') { - m = tooltip[3]; - } + var coords = {}; + var legend = {}; + var entry = [i2]; + //pin.list.key = i; + var combined = ShowOnMap.combinePins(group[p], false, hasPaths); + var pins = combined[0]; + var nPins = combined[1]; + var nCoords = 0; + for (var n = 0; n < pins.length; ++n) { + var pin = pins[n]; + var tooltip = ShowOnMap.buildTooltip(pin.list); + var url = tooltip[2]; + var m = null; + if (url == 'javascript:;') { + m = tooltip[3]; + } - if (pin.list.length == 1) { - url = (g_types[pin.list[0].type] && pin.list[0].id ? '?' + g_types[pin.list[0].type] + '=' + pin.list[0].id : ''); - } - if (i == 'rare' || i == 'herb' || i == 'vein') { - tooltip[1] = submenu.length + 1; - } - if (coords[pin.level] == undefined) { - coords[pin.level] = []; - } - coords[pin.level].push([ + if (pin.list.length == 1) { + url = (g_types[pin.list[0].type] && pin.list[0].id ? '?' + g_types[pin.list[0].type] + '=' + pin.list[0].id : ''); + } + if (i == 'rare' || i == 'herb' || i == 'vein') { + tooltip[1] = submenu.length + 1; + } + if (coords[pin.level] == undefined) { + coords[pin.level] = []; + } + coords[pin.level].push([ pin.coord[0], pin.coord[1], { @@ -103,71 +103,71 @@ ShowOnMap.prototype.construct = function() { lines: pin.list[0].paths } ]); - nCoords++; - } - if (nCoords > 0) { - var url = (g_types[group[p][0].type] && group[p][0].id ? '?' + g_types[group[p][0].type] + '=' + group[p][0].id : ''); - legend[submenu.length+1] = [p, url]; - entry.push(p + sprintf(LANG.qty, nPins)); - entry.push(this.showStuff.bind(this, coords, [i, i2], legend)); - submenu.push(entry); - for (var l in coords) { - if (allCoords[l]) { - allCoords[l] = allCoords[l].concat(coords[l]); - } - else { - allCoords[l] = coords[l]; - } - } - allLegend[submenu.length] = [p, url]; - } - } - if (submenu.length > 0) { - submenu.sort(cmpFunc); - var entry = [i, LANG.som[i], this.showStuff.bind(this, allCoords, [i], allLegend), submenu]; - this._menu.push(entry); - } - } - else { - if (this.data[i].length == 0) { - continue; - } + nCoords++; + } + if (nCoords > 0) { + var url = (g_types[group[p][0].type] && group[p][0].id ? '?' + g_types[group[p][0].type] + '=' + group[p][0].id : ''); + legend[submenu.length+1] = [p, url]; + entry.push(p + sprintf(LANG.qty, nPins)); + entry.push(this.showStuff.bind(this, coords, [i, i2], legend)); + submenu.push(entry); + for (var l in coords) { + if (allCoords[l]) { + allCoords[l] = allCoords[l].concat(coords[l]); + } + else { + allCoords[l] = coords[l]; + } + } + allLegend[submenu.length] = [p, url]; + } + } + if (submenu.length > 0) { + submenu.sort(cmpFunc); + var entry = [i, LANG.som[i], this.showStuff.bind(this, allCoords, [i], allLegend), submenu]; + this._menu.push(entry); + } + } + else { + if (this.data[i].length == 0) { + continue; + } - var hasPaths = false; - for (var n = 0, len = this.data[i].length; n < len; ++n) { - if (this.data[i][n].paths) { - hasPaths = true; - break; - } - } + var hasPaths = false; + for (var n = 0, len = this.data[i].length; n < len; ++n) { + if (this.data[i][n].paths) { + hasPaths = true; + break; + } + } - var entry = [i]; - var coords = {}; - var hordeCoords = {}, hordeDailyCoords = {}; - var allianceCoords = {}, allianceDailyCoords = {}; - var legend = {}; - var hordeLegend = {}; - var allianceLegend = {}; - var combined = ShowOnMap.combinePins(this.data[i], false, hasPaths); - var nPins = combined[1]; - var nCoords = 0, nHordeCoords = 0, nHordeDailyCoords = 0, nAllianceCoords = 0, nAllianceDailyCoords = 0; + var entry = [i]; + var coords = {}; + var hordeCoords = {}, hordeDailyCoords = {}; + var allianceCoords = {}, allianceDailyCoords = {}; + var legend = {}; + var hordeLegend = {}; + var allianceLegend = {}; + var combined = ShowOnMap.combinePins(this.data[i], false, hasPaths); + var nPins = combined[1]; + var nCoords = 0, nHordeCoords = 0, nHordeDailyCoords = 0, nAllianceCoords = 0, nAllianceDailyCoords = 0; - var processPins = function(id, pins) { - for (var n = 0; n < pins.length; ++n) { - var pin = pins[n]; - var idx = id; - pin.list.key = i; - var tooltip = ShowOnMap.buildTooltip(pin.list, (id == 'hordedailyquests' || id == 'alliancedailyquests') ? true : false); - var url = tooltip[2]; - var m = null; - if (url == 'javascript:;') { - m = tooltip[3]; - } + var processPins = function(id, pins) { + for (var n = 0; n < pins.length; ++n) { + var pin = pins[n]; + var idx = id; + pin.list.key = i; + var tooltip = ShowOnMap.buildTooltip(pin.list, (id == 'hordedailyquests' || id == 'alliancedailyquests') ? true : false); + var url = tooltip[2]; + var m = null; + if (url == 'javascript:;') { + m = tooltip[3]; + } - if (pin.list.length == 1) { - url = (g_types[pin.list[0].type] && pin.list[0].id ? '?' + g_types[pin.list[0].type] + '=' + pin.list[0].id : ''); - } - var coord = [ + if (pin.list.length == 1) { + url = (g_types[pin.list[0].type] && pin.list[0].id ? '?' + g_types[pin.list[0].type] + '=' + pin.list[0].id : ''); + } + var coord = [ pin.coord[0], pin.coord[1], { @@ -178,157 +178,157 @@ ShowOnMap.prototype.construct = function() { lines: pin.list[0].paths } ]; - if (coords[pin.level] == undefined) { - coords[pin.level] = []; - hordeCoords[pin.level] = []; - hordeDailyCoords[pin.level] = []; - allianceCoords[pin.level] = []; - allianceDailyCoords[pin.level] = []; - } + if (coords[pin.level] == undefined) { + coords[pin.level] = []; + hordeCoords[pin.level] = []; + hordeDailyCoords[pin.level] = []; + allianceCoords[pin.level] = []; + allianceDailyCoords[pin.level] = []; + } - if (idx != 'rare' && idx != 'spirithealer' && idx != 'book' && idx != 'forge' && idx != 'anvil' && idx != 'hordequests' && idx != 'alliancequests' && idx != 'hordedailyquests' && idx != 'alliancedailyquests' && idx != 'boss') { - if (tooltip[1] == 2 || tooltip[1] == 0) { - if (tooltip[1] == 2) { - hordeLegend[2] = [LANG.som_legend_horde, null]; - } - else { - hordeLegend[0] = [LANG.som_legend_neutral, null]; - } - hordeCoords[pin.level].push(coord); - nHordeCoords++; - } - if (tooltip[1] == 3 || tooltip[1] == 0) { - if (tooltip[1] == 3) { - allianceLegend[3] = [LANG.som_legend_alliance, null]; - } - else { - allianceLegend[0] = [LANG.som_legend_neutral, null]; - } - allianceCoords[pin.level].push(coord); - nAllianceCoords++; - } - } - else if (idx == 'hordequests') { - idx = 'quest'; - if (tooltip[1] == 2) { - hordeLegend[2] = [LANG.som_legend_horde, null]; - } - else { - hordeLegend[0] = [LANG.som_legend_neutral, null]; - } - hordeCoords[pin.level].push(coord); - nHordeCoords++; - } - else if (idx == 'hordedailyquests') { - idx = 'daily'; - if (tooltip[1] == 2) { - hordeLegend[2] = [LANG.som_legend_horde, null]; - } - else { - hordeLegend[0] = [LANG.som_legend_neutral, null]; - } - hordeDailyCoords[pin.level].push(coord); - nHordeDailyCoords++; - } - else if (idx == 'alliancequests') { - idx = 'quest'; - if (tooltip[1] == 3) { - allianceLegend[3] = [LANG.som_legend_alliance, null]; - } - else { - allianceLegend[0] = [LANG.som_legend_neutral, null]; - } - allianceCoords[pin.level].push(coord); - nAllianceCoords++; - } - else if (idx == 'alliancedailyquests') { - idx = 'daily'; - if (tooltip[1] == 3) { - allianceLegend[3] = [LANG.som_legend_alliance, null]; - } - else { - allianceLegend[0] = [LANG.som_legend_neutral, null]; - } - allianceDailyCoords[pin.level].push(coord); - nAllianceDailyCoords++; - } - else { - coords[pin.level].push(coord); - nCoords++; - } - } - return idx; - }; - var idx = processPins(i, combined[0]); - if (i == 'alliancequests') { - var allianceDailyPins = ShowOnMap.combinePins(this.data[i], true); - if (allianceDailyPins[1] > 0) { - processPins('alliancedailyquests', allianceDailyPins[0]); - } - } - else if (i == 'hordequests') { - var hordeDailyPins = ShowOnMap.combinePins(this.data[i], true); - if (hordeDailyPins[1] > 0) { - processPins('hordedailyquests', hordeDailyPins[0]); - } - } + if (idx != 'rare' && idx != 'spirithealer' && idx != 'book' && idx != 'forge' && idx != 'anvil' && idx != 'hordequests' && idx != 'alliancequests' && idx != 'hordedailyquests' && idx != 'alliancedailyquests' && idx != 'boss') { + if (tooltip[1] == 2 || tooltip[1] == 0) { + if (tooltip[1] == 2) { + hordeLegend[2] = [LANG.som_legend_horde, null]; + } + else { + hordeLegend[0] = [LANG.som_legend_neutral, null]; + } + hordeCoords[pin.level].push(coord); + nHordeCoords++; + } + if (tooltip[1] == 3 || tooltip[1] == 0) { + if (tooltip[1] == 3) { + allianceLegend[3] = [LANG.som_legend_alliance, null]; + } + else { + allianceLegend[0] = [LANG.som_legend_neutral, null]; + } + allianceCoords[pin.level].push(coord); + nAllianceCoords++; + } + } + else if (idx == 'hordequests') { + idx = 'quest'; + if (tooltip[1] == 2) { + hordeLegend[2] = [LANG.som_legend_horde, null]; + } + else { + hordeLegend[0] = [LANG.som_legend_neutral, null]; + } + hordeCoords[pin.level].push(coord); + nHordeCoords++; + } + else if (idx == 'hordedailyquests') { + idx = 'daily'; + if (tooltip[1] == 2) { + hordeLegend[2] = [LANG.som_legend_horde, null]; + } + else { + hordeLegend[0] = [LANG.som_legend_neutral, null]; + } + hordeDailyCoords[pin.level].push(coord); + nHordeDailyCoords++; + } + else if (idx == 'alliancequests') { + idx = 'quest'; + if (tooltip[1] == 3) { + allianceLegend[3] = [LANG.som_legend_alliance, null]; + } + else { + allianceLegend[0] = [LANG.som_legend_neutral, null]; + } + allianceCoords[pin.level].push(coord); + nAllianceCoords++; + } + else if (idx == 'alliancedailyquests') { + idx = 'daily'; + if (tooltip[1] == 3) { + allianceLegend[3] = [LANG.som_legend_alliance, null]; + } + else { + allianceLegend[0] = [LANG.som_legend_neutral, null]; + } + allianceDailyCoords[pin.level].push(coord); + nAllianceDailyCoords++; + } + else { + coords[pin.level].push(coord); + nCoords++; + } + } + return idx; + }; + var idx = processPins(i, combined[0]); + if (i == 'alliancequests') { + var allianceDailyPins = ShowOnMap.combinePins(this.data[i], true); + if (allianceDailyPins[1] > 0) { + processPins('alliancedailyquests', allianceDailyPins[0]); + } + } + else if (i == 'hordequests') { + var hordeDailyPins = ShowOnMap.combinePins(this.data[i], true); + if (hordeDailyPins[1] > 0) { + processPins('hordedailyquests', hordeDailyPins[0]); + } + } - if (idx == 'rare') { - nPins = this.data[idx].length; - } - else if (idx == 'forge' || idx == 'anvil') { - nPins = combined[0].length; - } + if (idx == 'rare') { + nPins = this.data[idx].length; + } + else if (idx == 'forge' || idx == 'anvil') { + nPins = combined[0].length; + } - if (nCoords > 0) { - var entry = [idx, LANG.som[idx] + sprintf(LANG.qty, nPins), this.showStuff.bind(this, coords, [idx], legend)]; - this._menu.push(entry); - } - if (nHordeCoords > 0) { - var entry = [idx, LANG.som[idx] + sprintf(LANG.qty, nHordeCoords), this.showStuff.bind(this, hordeCoords, ['horde', idx], hordeLegend), null]; - if (idx == 'quest') { - entry.push({ tinyIcon: 'quest_start' }); + if (nCoords > 0) { + var entry = [idx, LANG.som[idx] + sprintf(LANG.qty, nPins), this.showStuff.bind(this, coords, [idx], legend)]; + this._menu.push(entry); + } + if (nHordeCoords > 0) { + var entry = [idx, LANG.som[idx] + sprintf(LANG.qty, nHordeCoords), this.showStuff.bind(this, hordeCoords, ['horde', idx], hordeLegend), null]; + if (idx == 'quest') { + entry.push({ tinyIcon: 'quest_start' }); - if (nHordeDailyCoords > 0) { - hordeMenu.push(entry); - entry = ['daily', LANG.som.daily + sprintf(LANG.qty, nHordeDailyCoords), this.showStuff.bind(this, hordeDailyCoords, ['horde', 'daily'], hordeLegend), null, { tinyIcon: 'quest_start_daily' }]; - } - } - hordeMenu.push(entry); - } - if (nAllianceCoords > 0) { - var entry = [idx, LANG.som[idx] + sprintf(LANG.qty, nAllianceCoords), this.showStuff.bind(this, allianceCoords, ['alliance', idx], allianceLegend), null]; - if (idx == 'quest') { - entry.push({ tinyIcon: 'quest_start' }); + if (nHordeDailyCoords > 0) { + hordeMenu.push(entry); + entry = ['daily', LANG.som.daily + sprintf(LANG.qty, nHordeDailyCoords), this.showStuff.bind(this, hordeDailyCoords, ['horde', 'daily'], hordeLegend), null, { tinyIcon: 'quest_start_daily' }]; + } + } + hordeMenu.push(entry); + } + if (nAllianceCoords > 0) { + var entry = [idx, LANG.som[idx] + sprintf(LANG.qty, nAllianceCoords), this.showStuff.bind(this, allianceCoords, ['alliance', idx], allianceLegend), null]; + if (idx == 'quest') { + entry.push({ tinyIcon: 'quest_start' }); - if (nAllianceDailyCoords > 0) { - allianceMenu.push(entry); - entry = ['daily', LANG.som.daily + sprintf(LANG.qty, nAllianceDailyCoords), this.showStuff.bind(this, allianceDailyCoords, ['alliance', 'daily'], allianceLegend), null, { tinyIcon: 'quest_start_daily' }]; - } - } - allianceMenu.push(entry); - } - } - } + if (nAllianceDailyCoords > 0) { + allianceMenu.push(entry); + entry = ['daily', LANG.som.daily + sprintf(LANG.qty, nAllianceDailyCoords), this.showStuff.bind(this, allianceDailyCoords, ['alliance', 'daily'], allianceLegend), null, { tinyIcon: 'quest_start_daily' }]; + } + } + allianceMenu.push(entry); + } + } + } - allianceMenu.sort(cmpFunc); - hordeMenu.sort(cmpFunc); - this._menu.sort(cmpFunc); + allianceMenu.sort(cmpFunc); + hordeMenu.sort(cmpFunc); + this._menu.sort(cmpFunc); - if (hordeMenu.length > 0) { - this._menu.unshift(['horde', LANG.som.horde, '', hordeMenu, { tinyIcon: 'side_horde' }]); - } - if (allianceMenu.length > 0) { - this._menu.unshift(['alliance', LANG.som.alliance, '', allianceMenu, { tinyIcon: 'side_alliance' }]); - } + if (hordeMenu.length > 0) { + this._menu.unshift(['horde', LANG.som.horde, '', hordeMenu, { tinyIcon: 'side_horde' }]); + } + if (allianceMenu.length > 0) { + this._menu.unshift(['alliance', LANG.som.alliance, '', allianceMenu, { tinyIcon: 'side_alliance' }]); + } - var nothing = [-1, LANG.som_nothing, this.showStuff.bind(this, [], [-1], {})]; - nothing.checked = true; - this._menu.push(nothing); + var nothing = [-1, LANG.som_nothing, this.showStuff.bind(this, [], [-1], {})]; + nothing.checked = true; + this._menu.push(nothing); - var redButton = RedButton.create(LANG.showonmap, true); - redButton.className += ' mapper-som-button'; - // Menu.add(redButton, this._menu, { showAtCursor: true }); + var redButton = RedButton.create(LANG.showonmap, true); + redButton.className += ' mapper-som-button'; + // Menu.add(redButton, this._menu, { showAtCursor: true }); redButton.menu = this._menu; redButton.onclick = function() { (Menu.show.bind(this))(); @@ -341,164 +341,164 @@ ShowOnMap.prototype.construct = function() { return false; }.bind(redButton); // replace end - ae(d, redButton); + ae(d, redButton); - var clear; - if (!this._legend) { - this._legend = ce('div'); + var clear; + if (!this._legend) { + this._legend = ce('div'); this._legend.className = 'mapper-legend'; this._legend.style.display = 'none'; - var d2 = ce('div'); + var d2 = ce('div'); d2.className = 'mapper-legend-container'; - this._legendLabel = ce('b') + this._legendLabel = ce('b') ae(this._legendLabel, ct(LANG.som_legend)); - ae(d2, this._legendLabel); + ae(d2, this._legendLabel); - this._legendContents = ce('div'); + this._legendContents = ce('div'); this._legendContents.style.cssFloat = 'right'; - ae(d2, this._legendContents); + ae(d2, this._legendContents); - var clear = ce('div'); + var clear = ce('div'); clear.style.clear = 'right'; - ae(d2, clear); + ae(d2, clear); - ae(this._legend, d2); - } - ae(d, this._legend); + ae(this._legend, d2); + } + ae(d, this._legend); var clear = ce('div'); clear.style.clear = 'left'; - ae(d, clear); + ae(d, clear); - var components = []; - var hash = g_getHash(); - if (hash.indexOf('#show:') != -1) { - components = hash.split('.'); - } - else if (this.data.instance) { - components.push('#show:boss'); - } + var components = []; + var hash = g_getHash(); + if (hash.indexOf('#show:') != -1) { + components = hash.split('.'); + } + else if (this.data.instance) { + components.push('#show:boss'); + } - if (components.length > 0) { - if (components.length == 2 && components[1] == 'map') { - this.expanded = true; - this.mapper.toggleZoom(); - } + if (components.length > 0) { + if (components.length == 2 && components[1] == 'map') { + this.expanded = true; + this.mapper.toggleZoom(); + } - var path = components[0].split(':'); - if (path.length < 2) { - return; - } + var path = components[0].split(':'); + if (path.length < 2) { + return; + } - var menu = this._menu; - for (var n = 1; n < path.length; ++n) { - var maxToRecurse = path.length - 1; - for (var p = 0; p < menu.length; ++p) { - if (menu[p][0] == path[n]) { - if (menu[p][3] && n < maxToRecurse) { - menu = menu[p][3]; - } - else { - menu = menu[p]; - } - break; - } - } - } - if (menu && menu[2] && menu[2].constructor && menu[2].call && menu[2].apply) { // sarjuuk: check if menu[2] is function - menu[2](); - } - } + var menu = this._menu; + for (var n = 1; n < path.length; ++n) { + var maxToRecurse = path.length - 1; + for (var p = 0; p < menu.length; ++p) { + if (menu[p][0] == path[n]) { + if (menu[p][3] && n < maxToRecurse) { + menu = menu[p][3]; + } + else { + menu = menu[p]; + } + break; + } + } + } + if (menu && menu[2] && menu[2].constructor && menu[2].call && menu[2].apply) { // sarjuuk: check if menu[2] is function + menu[2](); + } + } }; ShowOnMap.prototype.setLegend = function(info) { ee(this._legendContents); - var div = ce('div'); - var count = 0; - for (var i in info) { - var sp = ce('span'); + var div = ce('div'); + var count = 0; + for (var i in info) { + var sp = ce('span'); sp.className = 'mapper-pin mapper-pin-' + i + ' mapper-legend-pin'; - if (info[i][1]) { - var a = ce('a'); + if (info[i][1]) { + var a = ce('a'); a.href = info[i][1]; ae(a, ct(info[i][0])); - ae(sp, a); - } - else { - sp.innerText = info[i][0]; - } + ae(sp, a); + } + else { + sp.innerText = info[i][0]; + } - ae(div, sp); - if ((++count) % 4 == 0) { - ae(div, ce('br')); - } - } + ae(div, sp); + if ((++count) % 4 == 0) { + ae(div, ce('br')); + } + } - ae(this._legendContents, div); + ae(this._legendContents, div); }; ShowOnMap.prototype.showStuff = function(coords, path, legendInfo) { - this.mapper.update({zone: g_pageInfo.id, coords: coords, preservelevel: true}); - this.setLegend(legendInfo); - this.checkMenu(path); + this.mapper.update({zone: g_pageInfo.id, coords: coords, preservelevel: true}); + this.setLegend(legendInfo); + this.checkMenu(path); - if (path.length == 1 && path[0] == -1) { - this.pound = ''; - location.replace('#.'); - return; - } + if (path.length == 1 && path[0] == -1) { + this.pound = ''; + location.replace('#.'); + return; + } - this.pound = '#show:' + path.join(':'); - if (this.pound != '#show:boss') { - location.replace(this.pound + (this.expanded ? '.map' : '')); - } + this.pound = '#show:' + path.join(':'); + if (this.pound != '#show:boss') { + location.replace(this.pound + (this.expanded ? '.map' : '')); + } }; ShowOnMap.prototype.clearChecks = function(menu) { - for (var i = 0; i < menu.length; ++i) { - menu[i].checked = false; - if (menu[i][3] && menu[i][3].length > 0) { - this.clearChecks(menu[i][3]); - } - } - this._legend.style.display = 'none'; + for (var i = 0; i < menu.length; ++i) { + menu[i].checked = false; + if (menu[i][3] && menu[i][3].length > 0) { + this.clearChecks(menu[i][3]); + } + } + this._legend.style.display = 'none'; }; ShowOnMap.prototype.checkMenu = function(path) { - this.clearChecks(this._menu); - if (path[0] != -1) { - this._legend.style.display = 'block'; - } - else { - this._legend.style.display = 'none'; - } + this.clearChecks(this._menu); + if (path[0] != -1) { + this._legend.style.display = 'block'; + } + else { + this._legend.style.display = 'none'; + } - var menu = this._menu; - var label = []; - for (var i = 0; i < path.length; ++i) { - for (var j = 0; j < menu.length; ++j) { - if (menu[j][0] == path[i]) { - menu[j].checked = true; - label.push([menu[j][0], menu[j][1]]); - menu = menu[j][3]; - break; - } - } - } + var menu = this._menu; + var label = []; + for (var i = 0; i < path.length; ++i) { + for (var j = 0; j < menu.length; ++j) { + if (menu[j][0] == path[i]) { + menu[j].checked = true; + label.push([menu[j][0], menu[j][1]]); + menu = menu[j][3]; + break; + } + } + } - var maxLabel = label.length - 1; - var str = ''; - var singlePinOptions = { 'rare': true, 'herb': true, 'vein': true }; - for (var i = 0; i < label.length; ++i) { - if (i > 0 && singlePinOptions[label[0][0]]) { + var maxLabel = label.length - 1; + var str = ''; + var singlePinOptions = { 'rare': true, 'herb': true, 'vein': true }; + for (var i = 0; i < label.length; ++i) { + if (i > 0 && singlePinOptions[label[0][0]]) { /* unsure, kept for reference, replacement below var span = $('span', this._legendContents); - span.removeClass('mapper-legend-pin'); - span.append($('', { text: ' ' + label[i][1].substr(label[i][1].lastIndexOf('(')) })); + span.removeClass('mapper-legend-pin'); + span.append($('', { text: ' ' + label[i][1].substr(label[i][1].lastIndexOf('(')) })); */ var span = gE(this._legendContents[0], 'span')[0]; span.className.replace(/\mapper-legend-pin\b/,''); @@ -506,322 +506,319 @@ ShowOnMap.prototype.checkMenu = function(path) { b.innerText = ' ' + label[i][1].substr(label[i][1].lastIndexOf('(')); ae(span, b); // replace end - } - else { - if (i == maxLabel) { - str += ''; - } - else { - str += ''; - } - str += label[i][1] + ''; - } - } - this._legendLabel.innerHTML = str; + } + else { + if (i == maxLabel) { + str += ''; + } + else { + str += ''; + } + str += label[i][1] + ''; + } + } + this._legendLabel.innerHTML = str; }; ShowOnMap.combinePins = function(pins, dailyOnly, hasPaths) { - var combined = {}; - var coord = null, tmpCoord = null; - var x, y; - var nPins = 0; + var combined = {}; + var coord = null, tmpCoord = null; + var x, y; + var nPins = 0; - var getCoord = function(coord, tight) { - var x = Math.floor(coord[0]); - var y = Math.floor(coord[1]); - if (!tight) { - if (x % 2 == 1) { - x += 1; - } - if (y % 2 == 1) { - y += 1; - } - } + var getCoord = function(coord, tight) { + var x = Math.floor(coord[0]); + var y = Math.floor(coord[1]); + if (!tight) { + if (x % 2 == 1) { + x += 1; + } + if (y % 2 == 1) { + y += 1; + } + } - if (combined[x] === undefined) { - combined[x] = {}; - } - if (combined[x][y] === undefined) { - combined[x][y] = []; - } + if (combined[x] === undefined) { + combined[x] = {}; + } + if (combined[x][y] === undefined) { + combined[x][y] = []; + } - return [x, y]; - } + return [x, y]; + } - for (var p = 0; p < pins.length; ++p) { - var pin = pins[p]; - if (dailyOnly) { - if (!pin.quests) { - continue; - } - var noDaily = true; - for (var n = 0; n < pin.quests.length; ++n) { - if (pin.quests[n].daily) { - noDaily = false; - break; - } - } - if (noDaily) { - continue; - } - } - else if (hasPaths) { - // Don't combine pins that have paths - coord = getCoord([pin.id, 0], true); - x = coord[0]; y = coord[1]; - var newPin = dO(pin); - newPin.coord = pin.coords[0]; + for (var p = 0; p < pins.length; ++p) { + var pin = pins[p]; + if (dailyOnly) { + if (!pin.quests) { + continue; + } + var noDaily = true; + for (var n = 0; n < pin.quests.length; ++n) { + if (pin.quests[n].daily) { + noDaily = false; + break; + } + } + if (noDaily) { + continue; + } + } + else if (hasPaths) { + // Don't combine pins that have paths + coord = getCoord([pin.id, 0], true); + x = coord[0]; y = coord[1]; + var newPin = dO(pin); + newPin.coord = pin.coords[0]; - combined[x][y].push(newPin); - nPins++; + combined[x][y].push(newPin); + nPins++; - continue; - } + continue; + } - if (pin.point == 'start' || pin.point == 'end') { - coord = getCoord(pin.coord); - x = coord[0]; y = coord[1]; - if (combined[x][y].length > 3) { - var temp = combined[x][y]; - combined[x][y] = []; - for (var i = 0; i < temp.length; ++i) { - tmpCoord = getCoord(temp[i].coord, true); - combined[tmpCoord[0]][tmpCoord[1]].push(temp[i]); - } - } + if (pin.point == 'start' || pin.point == 'end') { + coord = getCoord(pin.coord); + x = coord[0]; y = coord[1]; + if (combined[x][y].length > 3) { + var temp = combined[x][y]; + combined[x][y] = []; + for (var i = 0; i < temp.length; ++i) { + tmpCoord = getCoord(temp[i].coord, true); + combined[tmpCoord[0]][tmpCoord[1]].push(temp[i]); + } + } - combined[x][y].push(pin); - nPins++; - } - else { - for (var c = 0; c < pin.coords.length; ++c) { - coord = getCoord(pin.coords[c]); - x = coord[0]; y = coord[1]; - var newPin = dO(pin); - newPin.coord = pin.coords[c]; + combined[x][y].push(pin); + nPins++; + } + else { + for (var c = 0; c < pin.coords.length; ++c) { + coord = getCoord(pin.coords[c]); + x = coord[0]; y = coord[1]; + var newPin = dO(pin); + newPin.coord = pin.coords[c]; - if (combined[x][y].length > 3) { - var temp = combined[x][y]; - combined[x][y] = []; - for (var i = 0; i < temp.length; ++i) { - tmpCoord = getCoord(temp[i].coord, true); - combined[tmpCoord[0]][tmpCoord[1]].push(temp[i]); - } - } + if (combined[x][y].length > 3) { + var temp = combined[x][y]; + combined[x][y] = []; + for (var i = 0; i < temp.length; ++i) { + tmpCoord = getCoord(temp[i].coord, true); + combined[tmpCoord[0]][tmpCoord[1]].push(temp[i]); + } + } - combined[x][y].push(newPin); - nPins++; - } - } - } + combined[x][y].push(newPin); + nPins++; + } + } + } - var complete = []; - for (x in combined) { - for (y in combined[x]) { - complete.push({ + var complete = []; + for (x in combined) { + for (y in combined[x]) { + complete.push({ coord: [combined[x][y][0].coord[0], combined[x][y][0].coord[1]], level: combined[x][y][0].level, list: combined[x][y] }); - } - } + } + } - return [complete, nPins]; + return [complete, nPins]; }; ShowOnMap.buildTooltip = function(list, dailyOnly) { - var str = ''; - var url = ''; - var menu = []; - var pinType = -1; - var uniques = {}; - var nUniques = 0; - var pointTypes = {}; - var objType = 1; + var str = ''; + var url = ''; + var menu = []; + var pinType = -1; + var uniques = {}; + var nUniques = 0; + var pointTypes = {}; + var objType = 1; - for (var n = 0; n < list.length; ++n) { - var obj = list[n]; - url = (g_types[obj.type] && obj.id ? '?' + g_types[obj.type] + '=' + obj.id : ''); - var key = url + obj.item; - var pointKey = url + obj.point; - if (!uniques[key]) { - uniques[key] = { + for (var n = 0; n < list.length; ++n) { + var obj = list[n]; + url = (g_types[obj.type] && obj.id ? '?' + g_types[obj.type] + '=' + obj.id : ''); + var key = url + obj.item; + var pointKey = url + obj.point; + if (!uniques[key]) { + uniques[key] = { url: url, obj: obj, coords: [obj.coord], all: [obj] }; - nUniques++; - } - else { - if (!pointTypes[pointKey]) { - uniques[key].all.push(obj); - } - uniques[key].coords.push(obj.coord); - } - pointTypes[pointKey] = 1; - } + nUniques++; + } + else { + if (!pointTypes[pointKey]) { + uniques[key].all.push(obj); + } + uniques[key].coords.push(obj.coord); + } + pointTypes[pointKey] = 1; + } - var n = 0; - for (var key in uniques) { - var url = uniques[key].url; - var all = uniques[key].all; - var obj = uniques[key].obj; - var coords = uniques[key].coords; - if (n > 0) { + var n = 0; + for (var key in uniques) { + var url = uniques[key].url; + var all = uniques[key].all; + var obj = uniques[key].obj; + var coords = uniques[key].coords; + if (n > 0) { str += '
'; - } - menu.push([n++, obj.name, url]); - objType = obj.type; + } + menu.push([n++, obj.name, url]); + objType = obj.type; - if (!obj.point) { - if ((obj.reacthorde == 1 && obj.reactalliance < 1) || obj.side == 2) { - if (pinType == 2 || pinType == -1) { - pinType = 2; - } - else { - pinType = 0; - } - } - else if ((obj.reactalliance == 1 && obj.reacthorde < 1) || obj.side == 1) { - if (pinType == 3 || pinType == -1) { - pinType = 3; - } - else { - pinType = 0; - } - } - else { - pinType = 0; - } - } + if (!obj.point) { + if ((obj.reacthorde == 1 && obj.reactalliance < 1) || obj.side == 2) { + if (pinType == 2 || pinType == -1) { + pinType = 2; + } + else { + pinType = 0; + } + } + else if ((obj.reactalliance == 1 && obj.reacthorde < 1) || obj.side == 1) { + if (pinType == 3 || pinType == -1) { + pinType = 3; + } + else { + pinType = 0; + } + } + else { + pinType = 0; + } + } - str += '' + obj.name + ''; - if (coords.length > 0) { - str += ' (' + coords[0][0] + ', ' + coords[0][1] + ')
'; - } + str += '' + obj.name + ''; + if (coords.length > 0) { + str += ' (' + coords[0][0] + ', ' + coords[0][1] + ')
'; + } - if (obj.quests) { - if (obj.quests.length > 1) { - str += LANG.som_startsquestpl; - } - else { - str += LANG.som_startsquest; - } - str += '
'; - for (var q = 0; q < obj.quests.length; ++q) { - var quest = obj.quests[q]; - if (dailyOnly && !quest.daily) { - continue; - } - str += '[' + quest.level + '] ' + quest.name + ((quest.series && !quest.first) ? '(*)' : '') + ((quest.category < 0 && g_quest_sorts[quest.category]) ? ' ' + g_quest_sorts[quest.category] + '' : '') + '
'; - } - str += '
'; - } - else if (obj.description) { - str += obj.description + '
'; - } - else if (obj.point) { - for (var n = 0; n < all.length; ++n) { - var o = all[n]; - switch (o.point) { - case 'start': - str += LANG.mapper_startsquest + '
'; - if (pinType == 'end') { - pinType = 'startend'; - } - else if (pinType != 'startend') { - pinType = 'start'; - } - break; - case 'end': - str += LANG.mapper_endsquest + '
'; - if (pinType == 'start') { - pinType = 'startend'; - } - else if (pinType != 'startend') { - pinType = 'end'; - } - break; - case 'sourcestart': - str += LANG.mapper_sourcestart + '
'; - str += '
' + o.item + '
'; - if (pinType == 'end') { - pinType = 'startend'; - } - else if (pinType != 'startend') { - pinType = 'start'; - } - break; - case 'sourceend': - str += LANG.mapper_sourceend + '
'; - str += '
' + o.item + '
'; - if (pinType == 'start') { - pinType = 'startend'; - } - else if (pinType != 'startend') { - pinType = 'end'; - } - break; - case 'requirement': - str += LANG.mapper_requiredquest + '
'; - if (pinType == -1) { - pinType = o.objective; - } - break; - case 'sourcerequirement': - str += LANG.mapper_sourcereq + '
'; - str += '
' + o.item + '
'; - if (pinType == -1) { - pinType = o.objective; - } - break; - } - } - } - } + if (obj.quests) { + if (obj.quests.length > 1) { + str += LANG.som_startsquestpl; + } + else { + str += LANG.som_startsquest; + } + str += '
'; + for (var q = 0; q < obj.quests.length; ++q) { + var quest = obj.quests[q]; + if (dailyOnly && !quest.daily) { + continue; + } + str += '[' + quest.level + '] ' + quest.name + ((quest.series && !quest.first) ? '(*)' : '') + ((quest.category < 0 && g_quest_sorts[quest.category]) ? ' ' + g_quest_sorts[quest.category] + '' : '') + '
'; + } + str += '
'; + } + else if (obj.description) { + str += obj.description + '
'; + } + else if (obj.point) { + for (var n = 0; n < all.length; ++n) { + var o = all[n]; + switch (o.point) { + case 'start': + str += LANG.mapper_startsquest + '
'; + if (pinType == 'end') { + pinType = 'startend'; + } + else if (pinType != 'startend') { + pinType = 'start'; + } + break; + case 'end': + str += LANG.mapper_endsquest + '
'; + if (pinType == 'start') { + pinType = 'startend'; + } + else if (pinType != 'startend') { + pinType = 'end'; + } + break; + case 'sourcestart': + str += LANG.mapper_sourcestart + '
'; + str += '
' + o.item + '
'; + if (pinType == 'end') { + pinType = 'startend'; + } + else if (pinType != 'startend') { + pinType = 'start'; + } + break; + case 'sourceend': + str += LANG.mapper_sourceend + '
'; + str += '
' + o.item + '
'; + if (pinType == 'start') { + pinType = 'startend'; + } + else if (pinType != 'startend') { + pinType = 'end'; + } + break; + case 'requirement': + str += LANG.mapper_requiredquest + '
'; + if (pinType == -1) { + pinType = o.objective; + } + break; + case 'sourcerequirement': + str += LANG.mapper_sourcereq + '
'; + str += '
' + o.item + '
'; + if (pinType == -1) { + pinType = o.objective; + } + break; + } + } + } + } - str += '
'; - if (list.length == 1) { - str += (list[0].type == 1 ? LANG.som_viewnpc : (list[0].type == 2 ? LANG.som_viewobj : '')); - } - else if (nUniques == 1) { - str += (objType == 1 ? LANG.som_viewnpc : (objType == 2 ? LANG.som_viewobj : '')); - } - else { - str += '
' + LANG.som_view; - } - str += '
'; + str += '
'; + if (list.length == 1) { + str += (list[0].type == 1 ? LANG.som_viewnpc : (list[0].type == 2 ? LANG.som_viewobj : '')); + } + else if (nUniques == 1) { + str += (objType == 1 ? LANG.som_viewnpc : (objType == 2 ? LANG.som_viewobj : '')); + } + else { + str += '
' + LANG.som_view; + } + str += '
'; - var ret = []; - ret.push(str); - ret.push(pinType); - if (list.length == 1 || nUniques == 1) { - ret.push(url); - ret.push(null); - } - else { - ret.push('javascript:;'); - ret.push(menu); - } + var ret = []; + ret.push(str); + ret.push(pinType); + if (list.length == 1 || nUniques == 1) { + ret.push(url); + ret.push(null); + } + else { + ret.push('javascript:;'); + ret.push(menu); + } - return ret; + return ret; }; // !sarjuuk: tempfix! -Markup._fixUrl = function(url) -{ - if(!url) return ''; +Markup._fixUrl = function(url) { + if(!url) { + return ''; + } // Make local URLs absolute var firstChar = url.charAt(0); if(firstChar == '/' || firstChar == '?') - { - url = url.replace(/^[\/\?]+/, ''); - - url = '?' + url; - } + url = '?' + url.replace(/^[\/\?]+/, ''); return url; } diff --git a/template/js/Summary.js b/template/js/Summary.js index 2889fa1f..1d22384e 100644 --- a/template/js/Summary.js +++ b/template/js/Summary.js @@ -1,3675 +1,5047 @@ -// FILE ARCHIVED ON Dez 29, 2009 var g_summaries = {}; +var fi_type = 'items'; -// required for json parse -var dO = function(a){ - function b() {} - b.prototype = a; - return new b -}; +function Summary(opt) { + cO(this, opt); -function Summary(c) { - cO(this, c); - if (this.id) { - var b = this.id; - if (this.parent) { - var g = ce("div"); - g.id = b; - ae($(this.parent), g); - this.container = g - } else { - this.container = ge(b) - } - } else { - return - } - if (this.template) { - this.templateName = this.template; - this.template = Summary.templates[this.template] - } else { - return - } - g_summaries[this.id] = this; - if (this.editable == null) { - if (this.template.editable != null) { - this.editable = this.template.editable - } else { - this.editable = 1 - } - } - if (this.draggable == null) { - if (this.template.draggable != null) { - this.draggable = this.template.draggable - } else { - this.draggable = this.editable - } - } - if (this.searchable == null) { - if (this.template.searchable != null) { - this.searchable = this.template.searchable - } else { - this.searchable = (this.editable && this.draggable) - } - } - if (this.weightable == null) { - if (this.template.weightable != null) { - this.weightable = this.template.weightable - } else { - this.weightable = this.editable - } - } - if (this.textable == null) { - if (this.template.textable != null) { - this.textable = this.template.textable - } else { - this.textable = 0 - } - } - if (this.enhanceable == null) { - if (this.template.enhanceable != null) { - this.enhanceable = this.template.enhanceable - } else { - this.enhanceable = this.editable - } - } - if (this.level == null) { - if (this.template.level != null) { - this.level = this.template.level - } else { - this.level = 80 - } - } - var a = g_getGets(); - this.autoSave = 1; - if (a.compare) { - this.autoSave = 0 - } - if (a.l && !isNaN(a.l)) { - this.level = parseInt(a.l) - } - else - { - var l = gc('compare_level'); - if (l) - this.level = l; - } - if (this.groups == null) { - this.groups = []; - if (a.compare) { - this.readGroups(a.compare) - } else { - this.readGroups(gc("compare_groups")) - } - } - if (this.weights == null) { - this.weights = []; - if (this.weightable) { - if (a.compare) { - this.readWeights(a.weights) - } else { - this.readWeights(gc("compare_weights")) - } - } - } - this.showTotal = 0; - if (this.template.total != null) { - this.total = this.template.total; - this.showTotal = this.template.columns[this.total].hidden - } - if (this.template.clone != null) { - this.clone = {}; - cO(this.clone, this.template.columns[this.template.clone]); - this.clone.i = this.template.clone - } - if (a.compare && a.focus != null) { - var e = parseInt(a.focus) | 0; - if (e >= 0 && e < this.groups.length) { - this.selected = this.clone.i + e - } - } - this.initialize() + if (this.id) { + var divId = this.id; + if (this.parent) { + var d = ce('div'); + d.id = divId; + ae($(this.parent), d); + this.container = d; + } + else { + this.container = ge(divId); + } + } + else { + return; + } + + if (this.template) { + this.templateName = this.template; + this.template = Summary.templates[this.template]; + } + else { + return; + } + + g_summaries[this.id] = this; + + if (this.editable == null) { + if (this.template.editable != null) { + this.editable = this.template.editable; + } + else { + this.editable = 1; + } + } + + if (this.draggable == null) { + if (this.template.draggable != null) { + this.draggable = this.template.draggable; + } + else { + this.draggable = this.editable; + } + } + + if (this.searchable == null) { + if (this.template.searchable != null) { + this.searchable = this.template.searchable; + } + else { + this.searchable = (this.editable && this.draggable); + } + } + + if (this.weightable == null) { + if (this.template.weightable != null) { + this.weightable = this.template.weightable; + } + else { + this.weightable = this.editable; + } + } + + if (this.textable == null) { + if (this.template.textable != null) { + this.textable = this.template.textable; + } + else { + this.textable = 0; + } + } + + if (this.enhanceable == null) { + if (this.template.enhanceable != null) { + this.enhanceable = this.template.enhanceable; + } + else { + this.enhanceable = this.editable; + } + } + + if (this.level == null) { + if (this.template.level != null) { + this.level = this.template.level; + } + else { + this.level = 80; + } + } + + var GET = g_getGets(); + /* sarjuuk: GET.compare => GET.items, when using flat urls */ + + this.autoSave = 1; + if (GET.compare) { + this.autoSave = 0; + } + + if (GET.l && !isNaN(GET.l)) { + this.level = parseInt(GET.l); + } + else { + var l = gc('compare_level'); + if (l) { + this.level = l; + } + } + + if (this.groups == null) { + this.groups = []; + + if (GET.compare) { + this.readGroups(GET.compare); + } + else { + this.readGroups(gc('compare_groups')); + } + } + + if (this.weights == null) { + this.weights = []; + + if (this.weightable) { + if (GET.compare) { + this.readWeights(GET.weights); + } + else { + this.readWeights(gc('compare_weights')); + } + } + } + + this.showTotal = 0; + + if (this.template.total != null) { + this.total = this.template.total; + this.showTotal = this.template.columns[this.total].hidden; + } + + if (this.template.clone != null) { + this.clone = {}; + cO(this.clone, this.template.columns[this.template.clone]); + this.clone.i = this.template.clone; + } + + if (GET.compare && GET.focus != null) { + var f = parseInt(GET.focus) | 0; + if (f >= 0 && f < this.groups.length) { + this.selected = this.clone.i + f; + } + } + + this.initialize(); } + Summary.prototype = { - initialize: function () { - // todo: move to announcements - /* if (this.templateName == "compare" && !gc("compare_first")) { - var e = ce("div"), - b = ce("span"); - e.onclick = function (d) { - d = $E(d); - if (d._target.nodeName == "A") { - de(this); - // sc("compare_first", 20, 1, "/", ".wowhead.com") - sc("compare_first", 20, 1, "/", location.hostname) - } - }; - e.className = "summary-notice"; - b.innerHTML = LANG.su_notice; - ae(e, b); - ae(this.container, e) - } */ - this.controls = ce("div"); - this.controls.style.display = "none"; - this.controls.className = "summary-controls"; - this.textNames = ce("div"); - this.textNames.style.display = "none"; - this.textNames.className = "summary-textnames"; - var c; - if (this.onBeforeCreate != null) { - c = this.onBeforeCreate() - } - this.updateGroups(); - this.updateTraits(); - this.updateColumns(); - this.updateVisibility(); - if (this.traits.length == 0) { - this.visibility.shift(); - this.visibility.shift() - } - this.noData = ce("div"); - this.noData.className = "listview-nodata text"; - this.table = ce("table"); - this.thead = ce("thead"); - this.tbody = ce("tbody"); - this.table.id = "su_table"; - this.table.className = "grid"; - this.refreshHeader(); - ae(this.table, this.thead); - ae(this.table, this.tbody); - this.refreshRows(); - ae(this.container, this.controls); - ae(this.container, this.textNames); - ae(this.container, this.table); - this.itemTip = ce("div"); - this.itemTip.className = "summary-tip"; - this.itemTip.style.display = "none"; - var a = ce("span"); - a.innerHTML = LANG.su_itemtip; - ae(this.itemTip, a); - ae(this.container, this.itemTip); - this.refreshLink(); - if (this.onAfterCreate != null) { - this.onAfterCreate(c) - } - if (this.templateName == "compare") { - ModelViewer.addExtraPound(this.viewIn3dFromPound.bind(this)) - } - }, - updateGroups: function () { - for (var d = 0, a = this.groups.length; d < a; ++d) { - for (var c = 0, b = this.groups[d].length; c < b; ++c) { - if (this.groups[d][c][0] == 0 || (b > 1 && this.groups[d][c][0] == -1)) { - this.groups[d].splice(c, 1); --c; --b - } - } - if (b == 0) { - if (this.selected != null) { - if (this.__selected.i == d) { - this.selected = null - } - } - this.groups.splice(d, 1); --d; --a - } - } - if (this.editable) { - this.updateControls() - } - }, - updateTraits: function () { - this.traits = []; - var b, p = false, - a = []; - for (var g = 0, h = this.groups.length; g < h; ++g) { - for (var f = 0, e = this.groups[g].length; f < e; ++f) { - var n = this.groups[g][f]; - if (g_items[n[0]]) { - a.push(g_items[n[0]].jsonequip); - if (!this.enhanceable) { - continue - } - if (g_items[n[0]].jsonequip.subitems && g_items[n[0]].jsonequip.subitems[n[1]]) { - a.push(g_items[n[0]].jsonequip.subitems[n[1]].jsonequip) - } - if (g_enchants[n[2]]) { - a.push(g_enchants[n[2]].jsonequip) - } - if (g_enchants[n[3]]) { - a.push(g_enchants[n[3]].jsonequip) - } - for (var d = 4; d < 8; ++d) { - if (g_gems[n[d]]) { - a.push(g_gems[n[d]].jsonequip) - } - } - if (this.hasExtraSocket(n)) { - a.push({ - nsockets: 1 - }) - } - if (this.hasSocketBonus(n)) { - a.push(g_items[n[0]].jsonequip.socketbonusstat) - } - } - } - if (b = this.getSetBonuses(this.groups[g])) { - a.push(b) - } - } - for (var g = 0, h = this.template.traits.length; g < h; ++g) { - var l = this.template.traits[g]; - if (l.type == "sep") { - p = true; - continue - } - var m = [l.id]; - if (l.json) { - var m = l.json - } - var o = false; - for (var f = 0, e = a.length; f < e; ++f) { - for (var d = 0, c = m.length; d < c; ++d) { - if (a[f][m[d]] && (l.id != "gains" || (this.editable && this.groups.length > 1)) && (l.id != "score" || this.weights.length)) { - if (p) { - this.traits.push({}) - } - p = false; - this.traits.push(l); - o = true; - break - } - } - if (o) { - break - } - } - } - }, - updateColumns: function () { - this.columns = this.template.columns.slice(0); - if (this.template.newgroup != null) { - this.newgroup = this.template.newgroup - } - if (this.total != null) { - this.__total = this.columns[this.total] - } else { - this.__total = {} - } - this.__total.total = {}; - this.minValue = {}; - this.maxValue = {}; - this.ratings = {}; - if (this.clone != null) { - this.columns.splice(this.clone.i, 1); - var b = 0; - for (var d = 0, a = this.groups.length; d < a; ++d) { - if (this.groups[d].length < 1) { - continue - } - if (b > 0 && this.newgroup != null) { - this.newgroup++ - } - var c = {}; - cO(c, this.clone); - c.id = "group" + d; - c.group = this.groups[d]; - c.i = d; - this.columns.splice(this.clone.i + d, 0, c); - b++ - } - for (var d = 0, a = this.columns.length; d < a; ++d) { - this.calcTraitTotals(this.columns[d], this.__total, this.level) - } - if (this.selected != null) { - this.__selected = this.columns[this.selected]; - for (var d = 0, a = this.groups.length; d < a; ++d) { - if (this.clone.i + d == this.selected) { - continue - } - this.calcTraitDifference(this.columns[this.clone.i + d], this.__selected) - } - } else { - this.__selected = {} - } - if (this.total != null && (b == 1 || this.selected != null)) { - this.__total.hidden = 1 - } else { - this.__total.hidden = this.showTotal - } - } - }, - updateVisibility: function () { - this.visibility = []; - var e = [], - d = []; - if (this.visibleCols != null) { - array_walk(this.visibleCols, function (f) { - e[f] = 1 - }) - } - if (this.hiddenCols != null) { - array_walk(this.hiddenCols, function (f) { - d[f] = 1 - }) - } - for (var c = 0, a = this.columns.length; c < a; ++c) { - var b = this.columns[c]; - if (e[b.id] != null || (!b.hidden && d[b.id] == null)) { - this.visibility.push(c) - } - } - if (this.groups.length > 1 && this.textable) { - this.showTextNames() - } else { - this.textNames.style.display = "none" - } - }, + initialize: function() { + this.controls = ce('div'); + this.controls.style.display = 'none'; + this.controls.className = 'summary-controls'; - updateDraggable: function () { - for (var c = 0, len = this.dragHeaders.length; c < len; ++c) { - var _ = this.dragHeaders[c]; + this.textNames = ce('div'); + this.textNames.style.display = 'none'; + this.textNames.className = 'summary-textnames'; - _._targets = this.dragTargets; - Draggable.init(_, { - container: this.table, - onDrag: Summary.dragGroup.bind(this), - onDrop: Summary.moveGroup.bind(this) - }); - // alert(_.onmousedown); + var result; + if (this.onBeforeCreate != null) { + result = this.onBeforeCreate(); + } - } - for (var c = 0, len = this.dragIcons.length; c < len; ++c) { - var _ = this.dragIcons[c]; + this.updateGroups(); + this.updateTraits(); + this.updateColumns(); + this.updateVisibility(); - _._targets = this.dragTargets; - Draggable.init(_, { - container: this.table, - onDrop: Summary.moveGroupItem.bind(this) - }); - } - }, + if (this.traits.length == 0) { + this.visibility.shift(); + this.visibility.shift(); + } - updateWeights: function (g) { - var e = ge("su_weight"); - var k = e.childNodes[0].childNodes[0]; - var f = 0; - for (var b in g) { - if (!LANG.traits[b]) { - continue - } - if (f++>0) { - k = this.addWeight() - } - var h = k.getElementsByTagName("option"); - for (var d = 0, a = h.length; d < a; ++d) { - if (h[d].value == b) { - h[d].selected = true; - break - } - } - this.refreshWeights(k, g[b]) - } - }, - addWeight: function (g) { - var f = ge("su_weight"); - var b = ge("su_addweight"); - if (f.childNodes.length >= 14) { - b.style.display = "none" - } - b = f.childNodes[0].lastChild; - if (b.nodeName != "A") { - ae(f.childNodes[0], ct(String.fromCharCode(160, 160))); - ae(f.childNodes[0], this.createControl(LANG.firemove, "", "", this.deleteWeight.bind(this, f.childNodes[0].firstChild))) - } else { - b.firstChild.nodeValue = LANG.firemove; - b.onmouseup = this.deleteWeight.bind(this, f.childNodes[0].firstChild) - } - var h = ce("div"), - i = f.childNodes[0].childNodes[0].cloneNode(true); - ae(f, h); - i.onchange = i.onkeyup = this.refreshWeights.bind(this, i); - ae(h, i); - ae(h, ct(String.fromCharCode(160, 160))); - ae(h, this.createControl(LANG.firemove, "", "", this.deleteWeight.bind(this, i))); - if (g) { - sp($E(g)) - } - return i - }, - deleteWeight: function (g, h) { - var i = g.parentNode, - j = i.parentNode; - de(i); - if (j.childNodes.length == 1) { - var f = j.firstChild; - if (f.firstChild.selectedIndex > 0) { - var b = f.lastChild; - b.firstChild.nodeValue = LANG.ficlear; - b.onmouseup = this.resetWeights.bind(this) - } else { - while (f.childNodes.length > 1) { - de(f.childNodes[1]) - } - } - } - var b = ge("su_addweight"); - if (j.childNodes.length < 15) { - b.style.display = "" - } - if (h) { - sp($E(h)) - } - }, - showDetails: function (b) { - var c = ge("su_weight"); - g_toggleDisplay(c); - c = c.nextSibling; - b.firstChild.nodeValue = g_toggleDisplay(c) ? LANG.fihidedetails: LANG.fishowdetails - }, - calcTraitTotals: function (d, o, level) { - if (!d.group) { - return - } - d.total = {}; - d.difference = {}; - var q = { - sum: function (c, f) { - return (!isNaN(c) ? c: 0) + f - }, - min: function (c, f) { - return Math.min((!isNaN(c) ? c: f), f) - }, - max: function (c, f) { - return Math.max((!isNaN(c) ? c: 0), f) - }, - avg: function (c, i, f) { - return (!isNaN(c) ? c: 0) + (i / f) - }, - text: function (c, B, A, z, k, i, j) { - if (k) { - k = k.bind(this); - B = k(B, i, z, j) - } - return (in_array(c, B) < 0 ? B: null) - }, - custom: function (c, B, A, z, k, i, j) { - if (k) { - k = k.bind(this); - k(B, c, i, z, j) - } - return c - } - }; - var e = function (C, i, y, j, k, z, t, E) { - var x = {}; - cO(x, C); + this.noData = ce('div'); + this.noData.className = 'listview-nodata text'; - if(x.scadist && x.scaflags) - $WH.g_setJsonItemLevel(x, level); + this.table = ce('table'); + this.thead = ce('thead'); + this.tbody = ce('tbody'); - var A = (y.type == "text" || y.type == "custom" ? x: (x[i] && typeof x[i] != "object" ? x[i] : 0)); - if (i == "nsockets" && E) { - A += E - } - if (!A) { - return - } - var B = k(j.total[y.id], A, j.group.length, t, z, 0, E), - D = k(o.total[y.id], A, j.group.length, t, z, 1, E); - if (y.type == "text") { - if (B) { - j.total[y.id].push(B) - } - if (D) { - o.total[y.id].push(D) - } - } else { - j.total[y.id] = B; - o.total[y.id] = D - } - }; - for (var r in this.traits) { - r = this.traits[r]; - if (r.id && r.type) { - var b, p = q[r.type].bind(this), - u = r.calcTotal; - var v = [r.id]; - if (r.json) { - v = r.json - } - if (d.total[r.id] == null) { - if (r.type == "text") { - d.total[r.id] = [] - } else { - if (r.type == "custom") { - d.total[r.id] = {} - } - } - } - if (o.total[r.id] == null) { - if (r.type == "text") { - o.total[r.id] = [] - } else { - if (r.type == "custom") { - o.total[r.id] = {} - } - } - } - for (var m = 0, n = d.group.length; m < n; ++m) { - var a = this.hasExtraSocket(d.group[m]); - for (var l = 0, h = v.length; l < h; ++l) { - if (g_items[d.group[m][0]]) { - if (g_items[d.group[m][0]]) { - e(g_items[d.group[m][0]].jsonequip, v[l], r, d, p, u, d.group[m], a); - if (!this.enhanceable || r.itemonly) { - continue - } - if (g_items[d.group[m][0]].jsonequip.subitems && g_items[d.group[m][0]].jsonequip.subitems[d.group[m][1]]) { - e(g_items[d.group[m][0]].jsonequip.subitems[d.group[m][1]].jsonequip, v[l], r, d, p, u, d.group[m]) - } - if (g_enchants[d.group[m][2]]) { - e(g_enchants[d.group[m][2]].jsonequip, v[l], r, d, p, u, d.group[m]) - } - if (g_enchants[d.group[m][3]]) { - e(g_enchants[d.group[m][3]].jsonequip, v[l], r, d, p, u, d.group[m]) - } - for (var g = 4; g < 8; ++g) { - if (g_gems[d.group[m][g]]) { - e(g_gems[d.group[m][g]].jsonequip, v[l], r, d, p, u, d.group[m]) - } - } - if (this.hasSocketBonus(d.group[m])) { - e(g_items[d.group[m][0]].jsonequip.socketbonusstat, v[l], r, d, p, u, d.group[m]) - } - } - } - } - } - if (b = this.getSetBonuses(d.group)) { - for (var l = 0, h = v.length; l < h; ++l) { - e(b, v[l], r, d, p, u, []) - } - } - if (r.rating) { - this.ratings[r.id] = r.rating - } - if (r.type == "sum") { - if (d.total[r.id] == null) { - this.minValue[r.id] = 0 - } else { - if (this.minValue[r.id] == null || this.minValue[r.id] > d.total[r.id]) { - this.minValue[r.id] = d.total[r.id] - } - } - if (this.maxValue[r.id] == null || this.maxValue[r.id] < d.total[r.id]) { - this.maxValue[r.id] = d.total[r.id] - } - } else { - if (r.type == "custom") { - if (this.minValue[r.id] == null) { - this.minValue[r.id] = {} - } - if (this.maxValue[r.id] == null) { - this.maxValue[r.id] = {} - } - for (var w in d.total[r.id]) { - if (this.minValue[r.id][w] == null || this.minValue[r.id][w] > d.total[r.id][w]) { - this.minValue[r.id][w] = d.total[r.id][w] - } - if (this.maxValue[r.id][w] == null || this.maxValue[r.id][w] < d.total[r.id][w]) { - this.maxValue[r.id][w] = d.total[r.id][w] - } - } - } - } - } - } - }, - calcTraitDifference: function (b, g) { - b.difference = {}; - var a = { - sum: function (c, f) { - return (!isNaN(f) ? f: 0) - (!isNaN(c) ? c: 0) - }, - min: function (c, f) { - return (!isNaN(f) ? f: 0) - (!isNaN(c) ? c: 0) - }, - max: function (c, f) { - return (!isNaN(f) ? f: 0) - (!isNaN(c) ? c: 0) - }, - avg: function (c, f) { - return (!isNaN(f) ? f: 0) - (!isNaN(c) ? c: 0) - }, - text: function (f, m) { - var j = []; - for (var l = 0, c = m.length; l < c; ++l) { - if (in_array(f, m[l]) == -1) { - var k = ce("span"); - k.className = "q2"; - ae(k, ct("+" + m[l])); - j.push(k) - } - } - for (var l = 0, c = f.length; l < c; ++l) { - if (in_array(m, f[l]) == -1) { - var k = ce("span"); - k.className = "q10"; - ae(k, ct("-" + f[l])); - j.push(k) - } - } - return j - }, - custom: function (c, j, i) { - if (i) { - i = i.bind(this); - return i(j, c) - } - return {} - } - }; - for (var d in this.traits) { - d = this.traits[d]; - if (d.id && d.type) { - var e = a[d.type].bind(this), - h = d.calcDifference; - b.difference[d.id] = e(g.total[d.id], b.total[d.id], h) - } - } - }, - resetAll: function () { - this.groups = []; - this.weights = []; - this.refreshAll() - }, - refreshAll: function () { - this.updateGroups(); - this.updateTraits(); - this.updateColumns(); - this.updateVisibility(); - this.refreshHeader(); - this.refreshRows(); - this.refreshLink(); - if (this.autoSave) { - this.saveComparison(0) - } - }, - refreshHeader: function () { - if (this.groups.length && this.thead.nodeName.toLowerCase() != "thead") { - this.thead = ce("thead"); - ae(this.table, this.thead) - } - while (this.thead.firstChild) { - this.thead.removeChild(this.thead.firstChild) - } - this.dragHeaders = []; - this.dragIcons = []; - this.dragTargets = []; - this.selectLevel = ce("div"); - this.selectLevel.style.display = "none"; - var d = ce("tr"); - if (!this.groups.length) { - var f = ce("th"); - ae(d, f); - ae(this.thead, d); - this.showNoData(f); - return - } - var l = 0; - for (var u = 0, v = this.visibility.length; u < v; ++u) { - var p = this.visibility[u]; - var e = this.columns[p]; - var f = ce("th"); - if (e.id == "total") { - f.style.verticalAlign = "middle" - } else { - if (e.id == "name") { - f.style.verticalAlign = "bottom" - } else { - f.style.verticalAlign = "top" - } - } - e.__th = f; - f.__col = e; - if (e.width != null) { - f.style.width = e.width - } - if (e.align != null) { - f.style.textAlign = e.align - } - if (e.span != null) { - f.colSpan = e.span - } - if (this.selected != null && this.__selected.id == e.id) { - f.className = "checked" - } - if (e.id == "name") { - ae(f, this.selectLevel); - if (this.editable) { - var n = ce("select"); - n.onchange = (function (a) { - this.level = a.options[a.selectedIndex].value; - this.refreshAll() - }).bind(this, n); - for (var u = 80; u > 0; --u) { - var q = ce("option"); - if (u == this.level) { - q.selected = true - } - st(q, u); - ae(n, q) - } - ae(this.selectLevel, ct(LANG.pr_dialog_level + " ")); - ae(this.selectLevel, n) - } - } - if (e.group) { - this.dragTargets.push(f); - if (this.editable) { - var A = ce("div"); - A.className = "summary-group"; - m = ce("div"); - m.className = "summary-group-controls"; - var z = ce("a"); - z.href = "javascript:;"; - z.className = "summary-group-dropdown"; - ae(z, ce("span")); - z.menu = [[0, LANG.su_export, "?compare=" + this.getGroupData(l)]]; - z.menu[0].newWindow = 1; - if (this.viewableIn3d(e)) { - z.menu.push([0, LANG.su_viewin3d, this.viewIn3d.bind(this, e)]) - } - if (e.group.length > 1) { - z.menu.push([0, LANG.su_split, this.splitColumn.bind(this, e)]) - } - if (this.enhanceable && this.hasEnhancements(e.group)) { - z.menu.push([0, LANG.pr_menu_clearenh, this.clearEnhancements.bind(this, e)]) - } - z.onclick = Menu.showAtCursor; - ae(m, z); - if (this.groups.length > 1) { - z = ce("a"); - z.href = "javascript:;"; - z.className = "summary-group-focus"; - var n = ce("span"); - z.onclick = this.selectColumn.bind(this, e); - if (this.selected && this.__selected.id == e.id) { - z.onmouseover = function () { - Tooltip.show(this, LANG.tooltip_removefocus, 0, 0, "q") - }; - n.className = "selected" - } else { - z.onmouseover = function () { - Tooltip.show(this, LANG.tooltip_setfocus, 0, 0, "q") - } - } - z.onmousemove = Tooltip.cursorUpdate; - z.onmouseout = Tooltip.hide; - ae(z, n); - ae(m, z) - } - z = ce("a"); - z.href = "javascript:;"; - z.className = "summary-group-delete"; - z.onclick = this.deleteColumn.bind(this, e); - ae(z, ce("span")); - ae(m, z); - if (this.draggable) { - z = ce("a"); - z.href = "javascript:;"; - z.className = "summary-group-drag"; - ae(z, ce("span")); - ae(m, z); - A.__col = e; - A._handle = z; - this.dragHeaders.push(A) - } - ae(A, m); - ae(f, A); - if (this.draggable && this.groups.length > 1) { - if (Browser.ie) { - var x = ce("div"); - x.style.width = "80px"; - x.style.fontSize = "1px"; - x.style.height = "0"; - x.style.background = "transparent"; - ae(f, x) - } else { - A.style.minWidth = "80px" - } - } - } - var g = e.group.length, - r = 1, - c = 3, - h = 44; - if (g > 3) { - r = 0; - c = 5; - h = 26 - } - var A = ce("div"); - A.style.margin = "0 auto"; - A.style.clear = "both"; - var k = ce("div"), - m = A.cloneNode(true); - if (this.editable) { - k.className = "summary-group-bottom" - } - for (var t = 0; t < g; ++t) { - if (t % c == 0) { - m.style.width = (h * c) + "px"; - m = A.cloneNode(true); - ae(k, m) - } - var w = g_items.createIcon(e.group[t][0], r); - w.__col = e; - w.i = t; - if (this.enhanceable) { - this.refreshItem(e, t, Icon.getLink(w)) - } - this.dragIcons.push(w); - ae(m, w) - } - if (e.group.length) { - m.style.width = (h * (g % c == 0 ? c: (g % c))) + "px" - } - ae(k, m); - if (this.editable) { - f.style.padding = "0"; - m = ce("div"); - m.className = "clear"; - ae(k, m); - m = ce("div"); - m.className = "clear"; - ae(f.firstChild, m); - ae(f.firstChild, k) - } else { - ae(f, k) - } - l++ - } else { - if (e.name) { - var y = ce("b"); - ae(y, ct(e.name)); - ae(f, y) - } - } - if (this.editable && p == this.newgroup) { - this.dragTargets.push(f) - } - ae(d, f) - } - ae(this.thead, d); - if (this.draggable) { - this.updateDraggable() - } - }, - refreshItem: function (e, h, m) { - var o = e.group[h], - p = o[0], - b = [], - d = this.hasExtraSocket(o); - m.rel = this.getItemRel(o, e); - if (!this.enhanceable) { - return - } - m.oncontextmenu = rf; - if (g_items[p].jsonequip.subitems != null) { - b.push([0, (o[1] ? LANG.pr_menu_repsubitem: LANG.pr_menu_addsubitem), this.openSubitemPicker.bind(this, e, h)]) - } - if (this.canBeEnchanted(g_items[p].jsonequip.slotbak)) { - var n = [0, (o[2] ? LANG.pr_menu_repenchant: LANG.pr_menu_addenchant), this.openEnchantPicker.bind(this, e, h)]; - if (o[2] && g_enchants[o[2]]) { - n.tinyIcon = g_enchants[o[2]].icon - } - b.push(n) - } - if (g_items[p].jsonequip.nsockets || d) { - for (var g = 0, f = (g_items[p].jsonequip.nsockets | 0) + d; g < f; ++g) { - var j = (o[g + 4] > 0 ? o[g + 4] : 0), - l = (d && g == f - 1 ? 14 : g_items[p].jsonequip["socket" + (g + 1)]), - n = [0, (j ? LANG.pr_menu_repgem: LANG.pr_menu_addgem), this.openGemPicker.bind(this, e, h, 4 + g, l)]; - if (j) { - n.tinyIcon = g_gems[j].icon - } else { - n.socketColor = l - } - b.push(n) - } - } - if (this.canBeSocketed(g_items[p].jsonequip.slotbak)) { - var n = [0, LANG.pr_menu_extrasock, Summary.toggleExtraSocket.bind(this, e, h, m)]; - n.checked = d; - b.push(n) - } - if (this.hasEnhancements([o])) { - b.push([0, LANG.pr_menu_clearenh, this.clearEnhancements.bind(this, e, h)]) - } - if (b.length) { - m.oncontextmenu = rf; - m.onclick = this.onMouseClick.bind(0, m); - m.onmouseup = this.onMouseUp.bind(0, m); - m.menu = b - } - }, - refreshRows: function () { - if (this.groups.length) { - ae(this.table, this.tbody) - } - while (this.tbody.firstChild) { - this.tbody.removeChild(this.tbody.firstChild) - } - this.selectLevel.style.display = "none"; -/* start experimental */ - for (var itr = 0, len = this.visibility.length; itr < len; ++itr) - { - var reali = this.visibility[itr]; - var col = this.columns[reali]; - - if(!col.group) - continue; - - for(var jtr = 0, len2 = col.group.length; jtr < len2; ++jtr) - { - var itemId = col.group[jtr][0]; - - if(g_items[itemId].jsonequip.scadist && g_items[itemId].jsonequip.scaflags) - { - this.selectLevel.style.display = ''; - break; - } - } - } -/* end experimental */ - var a = 0; - for (trait in this.traits) { - if (this.traits[trait].id) { - this.traits[trait].i = ++a - } - ae(this.tbody, this.getRow(trait, a)) - } - if (!a) { - if (!this.groups.length && this.tbody.parentNode) { - de(this.tbody) - } - var c = ce("tr"); - var d = ce("td"); - var b = ce("span"); - if(this.visibility && this.visibility.length) - d.colSpan = this.visibility.length; - d.style.textAlign = "center"; - ae(b, ct("The items in this set don't have any comparable stats.")); - ae(d, b); - ae(c, d); - ae(this.tbody, c) - } - }, - refreshLink: function () { - var b = ge("su_link"), - e = this.getGroupData(), - f = this.getWeightData(); - if (e) { - this.itemTip.style.display = "" - } else { - this.itemTip.style.display = "none" - } - if (b) { - sc("compare_level", 20, this.level, "/", location.hostname); // custom - var d = "?compare" + (e ? "=" + e: "") + (this.level != 80 ? "&l=" + this.level: ""); - if (f[1].length && f[2].length) { - d += "&weights=" + f.join(";") - } - if (this.selected) { - d += "&focus=" + this.__selected.i - } - b.href = d - } - }, - refreshClasses: function (e) { - var i = e.options[e.selectedIndex], - a = ge("su_presets"); - while (a.firstChild) { - de(a.firstChild) - } - ae(a, ce("option")); - if (e.selectedIndex > 0) { - for (var b in i._presets) { - var d = i._presets[b]; - var g = ce("optgroup"); - g.label = LANG.presets[b]; - for (var f in d) { - var h = ce("option"); - h._weights = d[f]; - ae(h, ct(LANG.presets[f])); - ae(g, h) - } - if (g && g.childNodes.length > 0) { - ae(a, g) - } - } - if (a.childNodes.length > 1) { - a.parentNode.style.display = "" - } - } else { - a.parentNode.style.display = "none" - } - this.resetWeights() - }, - refreshPresets: function (b) { - this.resetWeights(); - var a = ge("su_classes"); - var c = b.options[b.selectedIndex]; - if (b.selectedIndex > 0) { - this.updateWeights(c._weights); - ge("su_scale").value = a.options[a.selectedIndex].text + LANG.hyphen + c.text - } - }, - resetWeights: function () { - var c = ge("su_weight"); - ge("su_scale").value = ""; - while (c.childNodes.length >= 2) { - c.removeChild(c.childNodes[1]) - } - var e = c.childNodes[0]; - while (e.childNodes.length > 1) { - e.removeChild(e.childNodes[1]) - } - e.firstChild.selectedIndex = 0; - var b = ge("su_addweight"); - if (c.childNodes.length < 15) { - b.style.display = "" - } - }, - refreshWeights: function (c, b) { - var e = c.parentNode; - while (e.childNodes.length > 1) { - de(e.childNodes[1]) - } - if (c.selectedIndex > 0) { - ae(e, ct(" ")); - var a = ce("input"); - a.type = "text"; - a.value = (b | 0); - a.maxLength = 7; - a.style.textAlign = "center"; - a.style.width = "4.5em"; - a.setAttribute("autocomplete", "off"); - a.onchange = this.sortWeights.bind(this, a); - ae(e, a); - this.sortWeights(a) - } - if (e.parentNode.childNodes.length == 1) { - if (c.selectedIndex > 0) { - ae(e, ct(String.fromCharCode(160, 160))); - ae(e, this.createControl(LANG.ficlear, "", "", this.resetWeights.bind(this))) - } - } else { - if (e.parentNode.childNodes.length > 1) { - ae(e, ct(String.fromCharCode(160, 160))); - ae(e, this.createControl(LANG.firemove, "", "", this.deleteWeight.bind(this, c))) - } - } - }, - sortWeights: function (e) { - var f = ge("su_weight"), - b = Number(e.value), - k = e.parentNode; - var j = 0; - for (var g = 0, a = f.childNodes.length; g < a; ++g) { - var h = f.childNodes[g]; - if (h.childNodes.length == 5) { - if (h.childNodes[0].tagName == "SELECT" && h.childNodes[2].tagName == "INPUT") { - if (b > Number(h.childNodes[2].value)) { - f.insertBefore(k, h); - return - }++j - } - } - } - if (j < a) { - f.insertBefore(k, f.childNodes[j]) - } else { - ae(f, k) - } - }, - saveComparison: function (refresh) { - // sc("compare_groups", 20, this.getGroupData(), "/", ".wowhead.com"); - sc("compare_groups", 20, this.getGroupData(), "/", location.hostname); - // sc("compare_weights", 20, rtrim(this.getWeightData(1).join(";"), ";"), "/", wowhead.com); - sc("compare_weights", 20, rtrim(this.getWeightData(1).join(";"), ";"), "/", location.hostname); - sc("compare_level", 20, this.level, "/", location.hostname); + this.table.id = 'su_table'; + this.table.className = 'grid'; - if (refresh) { - document.location.href = "?compare" - } - }, - getGroupData: function (g) { - var f = 0, - a = this.groups.length; - if (!isNaN(g)) { - f = g; - a = g + 1 - } - var d = "", - c = 0; - for (var e = f; e < a; ++e) { - if (this.groups[e].length < 1) { - continue - } - if (c++>0) { - d += ";" - } - for (var c = 0, b = this.groups[e].length; c < b; ++c) { - if (c > 0) { - d += ":" - } - d += this.writeItem(this.groups[e][c]) - } - } - return d - }, - getWeightData: function (k) { - var a = "", - f = "", - b = "", - g; - for (var d = 0, e = this.weights.length; d < e; ++d) { - if (d > 0) { - f += ";"; - b += ";"; - a += ";" - } - a += (k ? this.weights[d].name: urlencode(this.weights[d].name)); - var c = 0; - for (var h in this.weights[d]) { - if (!LANG.traits[h]) { - continue - } - g = fi_Lookup(h, "items"); - if (!g) { - continue - } - if (c++>0) { - f += ":"; - b += ":" - } - f += g.id; - b += this.weights[d][h] - } - } - return [a, f, b] - }, - showNoData: function (a) { - var c = this.textNames; - while (c.firstChild) { - de(c.firstChild) - } - c.style.display = "none"; - c = this.noData; - while (c.firstChild) { - de(c.firstChild) - } - ae(a, c); - var b = -1; - if (this.template.onNoData) { - b = (this.template.onNoData.bind(this, c))() - } - if (b == -1) { - ae(c, ct(LANG.su_additems || LANG.lvnodata)) - } - }, - showTextNames: function () { - var b = this.textNames; - b.style.display = ""; - b.style.paddingTop = "10px"; - while (b.firstChild) { - de(b.firstChild) - } - ae(b, ct(LANG.su_comparing)); - var e = 0; - for (var f = 0, g = this.visibility.length; f < g; ++f) { - var h = this.visibility[f]; - var d = this.columns[h]; - if (!d.group || !d.group.length) { - continue - } - if (e++>0) { - ae(b, ct(LANG.su_comparewith)) - } - if (d.group.length == 1) { - var k = g_items[d.group[0][0]].jsonequip; - var j = ce("a"); - j.className = "q" + (7 - parseInt(k.name.charAt(0))); - j.href = "?item=" + k.id; - j.rel = this.getItemRel(d.group[0], d); - ae(j, ct("[" + this.getItemName(d.group[0]) + "]")); - ae(b, j) - } else { - var c = ce("span"); - c.onmouseover = Summary.groupOver.bind(j, d.group); - c.onmousemove = Tooltip.cursorUpdate; - c.onmouseout = Tooltip.hide; - c.className = "tip"; - ae(c, ct("[" + d.group.length + " " + LANG.types[3][3] + "]")); - ae(b, c) - } - } - }, - updateControls: function () { - if (this.__lastCtrlUpdate != null && (this.__lastCtrlUpdate == this.groups.length || this.groups.length > 1)) { - return - } - this.__lastCtrlUpdate = this.groups.length; - var k = this.controls, - y; - k.style.display = ""; - while (k.firstChild) { - de(k.firstChild) - } - var f = ce("div"); - f.className = "summary-controls-right"; - ae(k, f); - y = this.createControl(LANG.su_help, null, "help-icon", null, "?help=item-comparison"); - ae(f, y); - if (this.searchable) { - var l = ce("span"); - //l.className = "icon-additem"; - y = this.createControl(LANG.su_addset, "su_addset", "additem-icon", this.openItemPicker.bind(this, 4)); - ae(l, y); - ae(f, l); - l = ce("span"); - //l.className = "icon-additem"; - y = this.createControl(LANG.su_additem, "su_additem", null, this.openItemPicker.bind(this, 3)); - y.className = "additem-icon"; - ae(l, y); - ae(f, l) - } - if (this.groups.length) { - if (this.weightable) { - var l = ce("span"); - //l.className = "icon-additem"; - y = this.createControl(LANG.su_addscale, "su_addscale", "additem-icon", this.toggleOptions.bind(this, "su_weights", "su_addscale")); - ae(l, y); - ae(f, l) - } - } - aE(document, "click", this.toggleOptions.bind(this, null, null)); - var A = ce("div"); - A.className = "clear"; - ae(f, A); - if (this.weightable) { - var z = ce("div"), - u = ce("div"); - z.style.display = "none"; - z.id = "su_weights"; - u.className = "summary-weights-inner"; - ae(z, u); - ae(f, z); - var j = ce("table"), - b = ce("tbody"), - e = ce("tr"), - g = ce("td"); - ae(j, b); - ae(b, e); - ae(e, g); - ae(g, ct(LANG.su_preset)); - g = ce("td"); - ae(e, g); - var l = ce("select"); - l.id = "su_classes"; - l.onchange = l.onkeyup = this.refreshClasses.bind(this, l); - ae(l, ce("option")); - ae(g, l); - var v = []; - for (var x in wt_presets) { - v.push(x) - } - v.sort(function (d, c) { - return strcmp(g_chr_classes[d], g_chr_classes[c]) - }); - for (var q = 0, r = v.length; q < r; ++q) { - var x = v[q], - n = ce("option"); - n.value = x; - n._presets = wt_presets[x]; - ae(n, ct(g_chr_classes[x])); - ae(l, n) - } - A = ce("span"); - A.style.display = "none"; - ae(A, ct(" ")); - ae(g, A); - l = ce("select"); - l.id = "su_presets"; - l.onchange = l.onkeyup = this.refreshPresets.bind(this, l); - ae(l, ce("option")); - ae(A, l); - ae(g, ct(" ")); - y = ce("a"); - y.href = "javascript:;"; - ae(y, ct(LANG.fishowdetails)); - y.onclick = this.showDetails.bind(this, y); - ae(g, y); - e = ce("tr"); - g = ce("td"); - ae(b, e); - ae(e, g); - ae(g, ct(LANG.su_name)); - g = ce("td"); - ae(e, g); - var q = ce("input"); - q.type = "text"; - q.id = "su_scale"; - ae(g, q); - ae(g, ct(" ")); - ae(u, j); - var h = ce("div"); - h.style.display = "none"; - h.id = "su_weight"; - ae(u, h); - A = ce("div"); - ae(h, A); - l = ce("select"); - l.onchange = l.onkeyup = this.refreshWeights.bind(this, l); - ae(l, ce("option")); - ae(A, l); - A = false; - for (var q = 0, r = this.template.traits.length; q < r; ++q) { - var m = this.template.traits[q]; - if (m.type == "sep") { - if (A && A.childNodes.length > 0) { - ae(l, A) - } - A = ce("optgroup"); - A.label = (LANG.traits[m.id] ? LANG.traits[m.id] : m.name) - } else { - if (m.type != "custom") { - var n = ce("option"); - n.value = m.id; - ae(n, ct((m.indent ? "- ": "") + LANG.traits[m.id] ? LANG.traits[m.id][0] : m.name)); - ae(A, n) - } - } - } - if (A && A.childNodes.length > 0) { - ae(l, A) - } - A = ce("div"); - A.style.display = "none"; - y = this.createControl(LANG.su_addweight, "su_addweight", "", this.addWeight.bind(this)); - ae(A, y); - ae(u, A); - A = ce("div"); - A.className = "summary-weights-buttons"; - y = ce("a"); - y.className = "help-icon"; - y.href = "?help=stat-weighting"; - y.target = "_blank"; - y.style.border = "none"; - y.style.cssFloat = y.style.styleFloat = "right"; - ae(y, ct(LANG.su_help)); - ae(A, y); - q = ce("input"); - q.type = "button"; - q.value = LANG.su_applyweight; - q.onclick = Summary.addWeightScale.bind(this); - ae(A, q); - ae(A, ct(" ")); - q = ce("input"); - q.type = "button"; - q.value = LANG.su_resetweight; - q.onclick = Summary.resetScale.bind(this); - ae(A, q); - ae(u, A) - } - if (this.autoSave) { - y = this.createControl(LANG.su_autosaving, null, "autosave-icon selected") - } else { - y = this.createControl(LANG.su_savecompare, "su_save", "save-icon", this.saveComparison.bind(this, 1)) - } - ae(k, y); - if (this.groups.length) { - y = this.createControl(LANG.su_linkcompare, "su_link", "link-icon"); - ae(k, y); - y = this.createControl(LANG.su_clear, null, "clear-icon", this.resetAll.bind(this)); - ae(k, y) - } - }, - getRow: function (a) { - var b = this.traits[a]; - this.createRow(b); - return b.__tr - }, - createRow: function (r) { - var m = ce("tr"); - r.__tr = m; - for (var h = 0, k = this.visibility.length; h < k; ++h) { - var l = this.visibility[h]; - var d = this.columns[l]; - var e = ce("td"), - q = e; - if (d.align != null) { - e.style.textAlign = d.align - } - if (this.total != null && this.__total.id == d.id || this.selected != null && this.__selected.id == d.id) { - if (r.id != "gains") { - e.style.fontWeight = "bold"; - e.className += "q1"; - if (this.selected != null && this.__selected.id == d.id) { - e.className += " checked" - } - } - } - if (!r.type) { - q.colSpan = k; - q.style.borderBottomWidth = (Browser.ie6 ? "3px": "2px"); - q.style.padding = "0"; - ae(m, e); - break - } - var o = null; - if (d.compute) { - o = (d.compute.bind(this, r, q, m, l))() - } else { - if (r.compute) { - o = (r.compute.bind(this, d, q, m, l))() - } else { - if (d.total) { - if (this.selected != null && this.__selected.id != d.id && d.difference) { - o = d.difference[r.id]; - if (o > 0) { - q.className += " q2" - } else { - if (o < 0) { - q.className += " q10" - } else { - if (o == 0) { - o = null - } - } - } - } else { - o = d.total[r.id] - } - if (o != null) { - if (o.join) { - for (var g = 0, f = o.length; g < f; ++g) { - if (g > 0) { - ae(q, ct(", ")) - } - if (o[g].appendChild) { - ae(q, o[g]) - } else { - ae(q, ct(o[g])) - } - } - o = null - } else { - if (!isNaN(o)) { - var c = Math.pow(10, (r.digits != null ? r.digits: 4)); - o = Math.round(c * o) / c; - if (!r.rating) { - o = (o < 0 ? "-": "") + number_format(Math.abs(o)) - } else { - this.selectLevel.style.display = "" - } - if (o > 0 && this.selected != null && this.__selected.id != d.id) { - o = "+" + o - } - } - } - } - } - } - } - if (this.groups.length > 1 && !this.selected && d.total && d.total[r.id] == this.maxValue[r.id] && this.maxValue[r.id] != this.minValue[r.id] && d.id != "total") { - q.style.fontWeight = "bold"; - q.className += " q2" - } - if (o != null) { - if (r.rating && !isNaN(o)) { - var b = (o < 0 ? -1 : 1) * g_convertRatingToPercent(this.level, r.rating, Math.abs(o)); - b = number_format((Math.round(b * 100) / 100)); - if (r.rating != 12 && r.rating != 37) { - b += "%" - } - var p = ce("a"); - p.className = (q.className ? q.className: "q1"); - p.style.borderBottom = "1px dotted #808080"; - p.onmouseover = (function (i, a, n, j) { - Tooltip.show(this, i + " " + j + " (" + sprintf(LANG.tooltip_combatrating, a, n) + ')
' + LANG.su_toggle + "", 0, 0, "q") - }).bind(p, o, b, this.level, LANG.traits[r.id][0]); - p.onmousemove = Tooltip.cursorUpdate; - p.onmouseout = Tooltip.hide; - p.onclick = this.toggleRatings.bind(this); - ae(p, ct(this.ratingMode ? b: o)); - aef(q, p) - } else { - aef(q, ct(o)) - } - } - if (!r.hidden) { - ae(m, e) - } - } - }, - toggleOptions: function (g, h, f) { - f = $E(f); - if (f && f._button >= 2) { - return false - } - var j = [ge("su_weights")], - k = [ge("su_addscale")], - a = null; - if (Browser.ie && f && !g && in_array(k, f._target) != -1) { - return - } - if (h) { - h = ge(h) - } - if (g && h) { - if (h.className.indexOf("selected") != -1) { - h = null - } else { - a = ge(g) - } - } else { - if (f) { - var b = f._target; - if (!b.parentNode) { - return - } - while (b.parentNode) { - if (in_array(j, b) != -1) { - return false - } - b = b.parentNode - } - } - } - for (var c = 0, d = j.length; c < d; ++c) { - if (j[c] && j[c] != a) { - j[c].style.display = "none" - } - } - for (var c = 0, d = k.length; c < d; ++c) { - if (k[c] && k[c] != h) { - k[c].className = k[c].className.replace("selected", "") - } - } - if (h) { - h.className += " selected"; - if (a) { - a.style.display = "" - } - } - if (f && g && h) { - sp(f) - } - }, - toggleWeights: function () { - if (++this.scoreMode > 2) { - this.scoreMode = 0 - } - this.refreshAll() - }, - toggleRatings: function () { - this.ratingMode = !this.ratingMode; - this.refreshAll() - }, - createControl: function (f, g, e, d, c) { - var b = ce("a"); - if (c) { - b.href = c; - b.target = "_blank" - } else { - b.href = "javascript:;" - } - if (g) { - b.id = g - } - if (e) { - b.className = e - } - if (d) { - if (Browser.ie) { - b.onmouseup = d - } else { - b.onclick = d - } - } - ae(b, ct(f)); - return b - }, - createColumn: function () { - this.groups.push([this.readItem( - 1)]); - this.refreshAll() - }, - selectColumn: function (a) { - Tooltip.hide(); - this.selected = (this.__selected.id == a.id ? null: this.clone.i + a.i); - this.refreshAll() - }, - deleteColumn: function (a, b) { - Tooltip.hide(); - b = $E(b); - if (!b.shiftKey) { - this.groups.splice(a.i, 1) - } else { - this.groups = [this.groups[a.i]] - } - if (!this.editable || this.groups.length <= 1 || this.__selected.id == a.id) { - this.selected = null - } else { - if (this.selected) { - this.selected += (this.clone.i + a.i > this.selected ? 0 : -1) - } - } - this.refreshAll(); - return false - }, - createWeightScale: function () { - var b = ge("su_weight"), - d = ge("su_scale"), - f = {}, - e = false; - f.name = d.value; - f.name = trim(f.name); - f.name = f.name.replace(/'/g, ""); - for (var c = 0, a = b.childNodes.length; c < a; ++c) { - if (b.childNodes[c].childNodes.length == 5) { - if (b.childNodes[c].childNodes[0].tagName == "SELECT" && b.childNodes[c].childNodes[2].tagName == "INPUT") { - f[b.childNodes[c].childNodes[0].options[b.childNodes[c].childNodes[0].selectedIndex].value] = Number(b.childNodes[c].childNodes[2].value); - e = true - } - } - } - if (e) { - return f - } - return null - }, - deleteWeightScale: function (a) { - Tooltip.hide(); - this.weights.splice(a, 1); - this.refreshAll() - }, - openItemPicker: function (a) { - this.searchType = a; - Lightbox.show("compare", { - onShow: this.onItemPickerShow.bind(this) - }) - }, - createItemPickerNote: function (e) { - var d = ce("small"), - c = ce("span"), - b; - this.currentSearch = ""; - this.searchTimer = 0; - ae(d, ct(LANG.su_note_name)); - this.searchName = ce("input"); - this.searchName.type = "text"; - aE(this.searchName, "keyup", this.onSearchKeyUp.bind(this)); - aE(this.searchName, "keydown", this.onSearchKeyDown.bind(this)); - ae(d, this.searchName); - this.searchMsg = ce("span"); - this.searchMsg.style.fontWeight = "bold"; - ae(d, this.searchMsg); - ae(e, d) - }, - getSetBonuses: function (l) { - var b = {}, - e = {}; - for (var g = 0, k = l.length; g < k; ++g) { - var c = l[g][0]; - if (g_items[c]) { - var m = g_items[c].jsonequip.itemset; - if (g_itemsets[m]) { - if (e[m] == null) { - e[m] = {} - } - e[m][c] = 1 - } - } - } - for (var m in e) { - var a = g_itemsets[m], - h = 0; - if (!a.setbonus) { - continue - } - for (var c in e[m]) { - h++ - } - for (var d in a.setbonus) { - if (d > h) { - break - } - for (var f in a.setbonus[d]) { - if (b[f] == null) { - b[f] = 0 - } - b[f] += a.setbonus[d][f] - } - } - } - return b - }, - onItemPickerShow: function (j, f, b) { - Lightbox.setSize(800, 564); - var c; - if (f) { - j.className = "summary-picker listview"; - var h = ce("div"), - i = ce("a"), - e = ce("div"); - h.className = "listview"; - ae(j, h); - i = ce("a"); - i.className = "screenshotviewer-close"; - i.href = "javascript:;"; - i.onclick = Lightbox.hide; - ae(i, ce("span")); - ae(j, i); - e.className = "clear"; - ae(j, e); - c = new Listview({ - template: "compare", - id: "items", - parent: h, - data: [], - clip: { - w: 780, - h: 478 - }, - createNote: this.createItemPickerNote.bind(this) - }); - if (Browser.firefox) { - aE(c.getClipDiv(), "DOMMouseScroll", this.onPickerWheel) - } else { - c.getClipDiv().onmousewheel = this.onPickerWheel - } - } else { - c = g_listviews.items - } - var k = this.searchItems.bind(this), - g = this.searchName; - setTimeout(function () { - k("", this.searchType); - g.value = ""; - g.focus() - }, - 1) - }, - openSubitemPicker: function (a, b) { - this.currentItem = { - col: a, - i: b, - item: a.group[b] - }; - Lightbox.show("subitempicker", { - onShow: this.onSubitemPickerShow.bind(this) - }) - }, - onSubitemPickerShow: function (k, g, b) { - Lightbox.setSize(800, 564); - var e, c = [], - m = this.currentItem.item[0]; - for (var i in g_items[m].jsonequip.subitems) { - var l = g_items[m].jsonequip.subitems[i]; - l.id = i; - l.item = m; - l._summary = this; - c.push(l) - } - if (g) { - k.className = "summary-picker listview"; - var h = ce("div"), - j = ce("a"), - f = ce("div"); - h.className = "listview"; - ae(k, h); - j = ce("a"); - j.className = "screenshotviewer-close"; - j.href = "javascript:;"; - j.onclick = Lightbox.hide; - ae(j, ce("span")); - ae(k, j); - f.className = "clear"; - ae(k, f); - e = new Listview({ - template: "subitempicker", - id: "subitems", - parent: h, - data: c - }); - if (Browser.firefox) { - aE(e.getClipDiv(), "DOMMouseScroll", this.onPickerWheel) - } else { - e.getClipDiv().onmousewheel = this.onPickerWheel - } - } else { - e = g_listviews.subitems; - e.setData(c); - e.clearSearch(); - e.updateFilters(true) - } - setTimeout(function () { - e.focusSearch() - }, - 1) - }, - openEnchantPicker: function (a, b) { - this.currentItem = { - col: a, - i: b, - item: a.group[b] - }; - Lightbox.show("enchantpicker", { - onShow: this.onEnchantPickerShow.bind(this) - }) - }, - createEnchantPickerNote: function (d) { - var c = ce("small"), - b; - ae(c, ct(LANG.pr_note_source)); - b = ce("a"); - b.href = "javascript:;"; - b.onclick = this.filterEnchants.bind(this, b, 0, null); - ae(b, ct(LANG.pr_note_all)); - g_setSelectedLink(b, "enchants0"); - ae(c, b); - ae(c, ct(LANG.comma)); - b = ce("a"); - b.href = "javascript:;"; - b.onclick = this.filterEnchants.bind(this, b, 0, 1); - ae(b, ct(LANG.pr_note_items)); - ae(c, b); - ae(c, ct(LANG.comma)); - b = ce("a"); - b.href = "javascript:;"; - b.onclick = this.filterEnchants.bind(this, b, 0, 2); - ae(b, ct(LANG.pr_note_profs)); - ae(c, b); - ae(d, c) - }, - canBeEnchanted: function(slot) { - return (slot == 1 || slot == 3 || slot == 16 || slot == 5 || slot == 20 || // Head, Shoulder, Back, Chest, Robe - slot == 9 || slot == 10 || slot == 6 || slot == 7 || slot == 8 || // Wrists, Hands, Waist, Legs, Feet - slot == 11 || slot == 21 || slot == 13 || slot == 17 || slot == 22 || // Finger, Main Hand, One Hand, Two Hand, Off Hand - slot == 14 || slot == 15 || slot == 26 || slot == 23) // Shield, Ranged, Held in Off Hand - }, - isValidEnchant: function (b) { - if (b.none) { - return true - } - var a = 1 << (g_items[this.currentItem.item[0]].jsonequip.slot - 1); - return ((b.slots & a) && (this.enchantSource == null || (this.enchantSource == 1 && b.source < 0) || (this.enchantSource == 2 && b.source > 0))) - }, - filterEnchants: function (b, c, d) { - switch (c) { - case 0: - this.enchantSource = d; - break; - default: - return - } - if (b && b.nodeName == "A") { - g_setSelectedLink(b, "enchants" + c) - } - g_listviews.enchants.updateFilters(true); - return false - }, - onEnchantPickerShow: function (n, j, c) { - Lightbox.setSize(800, 564); - var f; - if (j) { - n.className = "summary-picker listview"; - var e = [], - l = ce("div"), - m = ce("a"), - h = ce("div"); - e.push({ - none: 1, - __alwaysvisible: 1, - _summary: this - }); - for (var o in g_enchants) { - var b = { - id: o, - _summary: this - }; - cO(b, g_enchants[o]); - if (typeof b.name == "string") { - e.push(b) - } else { - for (var g = 0, k = g_enchants[o].name.length; g < k; ++g) { - var p = {}; - cO(p, b); - p.name = b.name[g]; - p.source = b.source[g]; - p.slots = b.slots[g]; - e.push(p) - } - } - } - l.className = "listview"; - ae(n, l); - m = ce("a"); - m.className = "screenshotviewer-close"; - m.href = "javascript:;"; - m.onclick = Lightbox.hide; - ae(m, ce("span")); - ae(n, m); - h.className = "clear"; - ae(n, h); - f = new Listview({ - template: "enchantpicker", - id: "enchants", - parent: l, - data: e, - createNote: this.createEnchantPickerNote.bind(this), - customFilter: this.isValidEnchant.bind(this) - }); - if (Browser.firefox) { - aE(f.getClipDiv(), "DOMMouseScroll", this.onPickerWheel) - } else { - f.getClipDiv().onmousewheel = this.onPickerWheel - } - } else { - f = g_listviews.enchants; - f.clearSearch(); - f.updateFilters(true) - } - setTimeout(function () { - f.focusSearch() - }, - 1) - }, - openGemPicker: function (b, c, d, a) { - this.currentItem = { - col: b, - i: c, - item: b.group[c], - socket: d, - color: a - }; - Lightbox.show("gempicker", { - onShow: this.onGemPickerShow.bind(this) - }) - }, - createGemPickerNote: function (e) { - var d = ce("small"), - b; - ae(d, ct(LANG.pr_note_source)); - b = ce("a"); - b.href = "javascript:;"; - b.onclick = this.filterGems.bind(this, b, 0, null); - ae(b, ct(LANG.pr_note_all)); - ae(d, b); - ae(d, ct(LANG.comma)); - b = ce("a"); - b.href = "javascript:;"; - b.onclick = this.filterGems.bind(this, b, 0, 1); - ae(b, ct(LANG.pr_note_bc)); - ae(d, b); - ae(d, ct(LANG.comma)); - b = ce("a"); - b.href = "javascript:;"; - b.onclick = this.filterGems.bind(this, b, 0, 2); - ae(b, ct(LANG.pr_note_wotlk)); - this.gemSource = 2; - g_setSelectedLink(b, "gems0"); - ae(d, b); - ae(e, d); - d = ce("small"); - var c = ce("span"); - c.style.padding = "0 8px"; - c.style.color = "white"; - ae(c, ct("|")); - ae(d, c); - ae(d, ct(LANG.pr_note_color)); - b = ce("a"); - b.href = "javascript:;"; - b.onclick = this.filterGems.bind(this, b, 1, null); - ae(b, ct(LANG.pr_note_all)); - ae(d, b); - ae(d, ct(LANG.comma)); - b = ce("a"); - b.href = "javascript:;"; - b.onclick = this.filterGems.bind(this, b, 1, 1); - ae(b, ct(LANG.pr_note_match)); - this.gemColor = 1; - g_setSelectedLink(b, "gems1"); - ae(d, b); - ae(e, d) - }, - matchGemSocket: function (b, c) { - for (var a = 1; a <= 8; a *= 2) { - if ((c & a) && (b & a)) { - return true - } - } - return false - }, - canBeSocketed: function (a) { - return (a == 9 || a == 10 || a == 6) - }, - hasExtraSocket: function (a) { - return this.enhanceable && (a[this.getExtraSocketPos(a[0])] ? 1 : 0) - }, - getExtraSocketPos: function (a) { - if (!a || !g_items[a]) { - return 4 - } - return 4 + (g_items[a].jsonequip.nsockets | 0) - }, - hasSocketBonus: function (b) { - var c = 0; - if (!g_items[b[0]] || !g_items[b[0]].jsonequip.nsockets) { - return false - } - for (var a = 0; a < 3; ++a) { - if (b[a + 4] && g_gems[b[a + 4]]) { - if (this.matchGemSocket(g_gems[b[a + 4]].colors, g_items[b[0]].jsonequip["socket" + (a + 1)])) {++c - } - } - } - return (c == g_items[b[0]].jsonequip.nsockets) - }, - isValidGem: function (a) { - if (a.none) { - return true - } - return ((this.gemSource == null || a.expansion == this.gemSource) && ((this.gemColor == null && this.currentItem.color != 1 && a.colors != 1) || this.matchGemSocket(a.colors, this.currentItem.color))) - }, - filterGems: function (b, c, d) { - switch (c) { - case 0: - this.gemSource = d; - break; - case 1: - this.gemColor = d; - break; - default: - return - } - if (b && b.nodeName == "A") { - g_setSelectedLink(b, "gems" + c) - } - g_listviews.gems.updateFilters(true); - return false - }, - onGemPickerShow: function (o, j, e) { - Lightbox.setSize(800, 564); - var h; - if (j) { - o.className = "summary-picker listview"; - var f = [], - m = ce("div"), - n = ce("a"), - i = ce("div"); - f.push({ - none: 1, - __alwaysvisible: 1, - _summary: this - }); - for (var l in g_gems) { - var k = { - id: l, - _summary: this - }; - cO(k, g_gems[l]); - f.push(k) - } - m.className = "listview"; - ae(o, m); - n = ce("a"); - n.className = "screenshotviewer-close"; - n.href = "javascript:;"; - n.onclick = Lightbox.hide; - ae(n, ce("span")); - ae(o, n); - i.className = "clear"; - ae(o, i); - h = new Listview({ - template: "gempicker", - id: "gems", - parent: m, - data: f, - createNote: this.createGemPickerNote.bind(this), - customFilter: this.isValidGem.bind(this) - }); - if (Browser.firefox) { - aE(h.getClipDiv(), "DOMMouseScroll", this.onPickerWheel) - } else { - h.getClipDiv().onmousewheel = this.onPickerWheel - } - } else { - h = g_listviews.gems; - h.clearSearch(); - h.updateFilters(true) - } - var c = h.getNoteTopDiv(), - b = gE(c, "small"), - g = gE(c, "a"); - if (this.currentItem.color == 1 || this.currentItem.color == 14) { - b[1].style.display = "none" - } else { - b[1].style.display = "" - } - setTimeout(function () { - h.focusSearch() - }, - 1) - }, - onPickerWheel: function (a) { - a = $E(a); - if (a._wheelDelta < 0) { - this.scrollTop += 27 - } else { - this.scrollTop -= 27 - } - }, - onMouseClick: function (b, c) { - c = $E(c); - if (c._button == 3 || c.shiftKey || c.ctrlKey) { - return false - } - }, - onMouseUp: function (b, c) { - c = $E(c); - if (c._button == 3 || c.shiftKey || c.ctrlKey) { - var f = Menu.getDiv(0, b.menu); - _cursorPos = g_getCursorPos(c); - if (Browser.ie6) { - _cursorPos.x -= 2; - _cursorPos.y -= 2 - } - var g = g_getCursorPos(c); - setTimeout(Menu.showAtCursor.bind(b, null, g.x, g.y), 1); - Tooltip.hide() - } - return false - }, - onSearchKeyUp: function (b) { - var a = trim(this.searchName.value.replace(/\s+/g, " ")); - if (a == this.currentSearch) { - return - } - this.currentSearch = a; - this.prepareSearch(a) - }, - onSearchKeyDown: function (a) { - a = $E(a); - switch (a.keyCode) { - case 13: - g_listviews.items.submitSearch(a); - break; - case 27: - hide(); - break; - case 38: - cycle(0); - break; - case 40: - cycle(1); - break - } - }, - prepareSearch: function (a) { - if (this.searchTimer > 0) { - clearTimeout(this.searchTimer); - this.searchTimer = 0 - } - if (a) { - st(this.searchMsg, sprintf(LANG["su_searching" + this.searchType], a)) - } - this.searchMsg.className = ""; - this.searchTimer = setTimeout(this.searchItems.bind(this, a, this.searchType), 333) - }, - searchItems: function (search, type) { - var lv = g_listviews.items, - _this = this, - searchResults = [{ - none: 1 - }]; - lv.searchable = false; - lv.setData(searchResults); - lv.clearSearch(); - lv.updateFilters(true); - this.searchMsg.className = ""; - if (!search) { - st(this.searchMsg, LANG["su_specifyitem" + this.searchType]); - return - } - st(this.searchMsg, sprintf(LANG["su_searching" + this.searchType], search)); -// todo: find propper format - new Ajax("?search=" + urlencode(search) + "&json&type=" + type, { - method: "POST", - search: search, - onSuccess: function (xhr, opt) { - var text = xhr.responseText; - if (text.charAt(0) != "[" || text.charAt(text.length - 1) != "]") { - return - } - var a = eval(text); - if (search == opt.search && a.length == 3) { - for (var i = 0, len = a[1].length; i < len; ++i) { - var row = {}; - row.id = a[1][i].id; - row.name = row["name_" + g_locale.name] = a[1][i].name.substring(1); - row.quality = 7 - a[1][i].name.charAt(0); - row.icon = a[1][i].icon; - row.level = a[1][i].level; - row.classs = a[1][i].classs; - row.subclass = a[1][i].subclass; - row.jsonequip = dO(a[1][i]); - row._type = 3; - row._summary = _this; - g_items.add(a[1][i].id, row); - if (_this.searchType == row._type) { - searchResults.push(row) - } -/* dropped in favour of code block from 2.5.2012 (see above) - var _ = {}; - cO(_, a[1][i]); - _._type = _this.searchType; - _._summary = _this; - searchResults.push(_) -*/ - } - for (var i = 0, len = a[2].length; i < len; ++i) { - var row = {}; - row.id = a[2][i].id; - row.name = row["name_" + g_locale.name] = a[2][i].name.substring(1); - row.quality = 7 - a[2][i].name.charAt(0); - row.minlevel = a[2][i].minlevel; - row.maxlevel = a[2][i].maxlevel; - row.type = a[2][i].type; - row.pieces = a[2][i].pieces; - row.jsonequip = {}; - for (var j = 0, len2 = row.pieces.length; j < len2; ++j) { - if (g_items[row.pieces[j]]) { - var item = g_items[row.pieces[j]]; - for (var k in item.jsonequip) { - if (LANG.traits[k] == null) { - continue - } - if (!row.jsonequip[k]) { - row.jsonequip[k] = 0 - } - row.jsonequip[k] += item.jsonequip[k] - } - } - } - row._type = 4; - row._summary = _this; - if (_this.searchType == row._type) { - searchResults.push(row) - } -/* dropped in favour of code block from 2.5.2012 (see above) - var _ = {}; - _["name_" + g_locale.name] = a[2][i].name.substring(1); - cO(_, { - quality: 7 - parseInt(a[2][i].name.charAt(0)), - icon: a[2][i].icon, - jsonequip: {} - }); - cO(_.jsonequip, a[2][i]); - g_items.add(a[2][i].id, _) -*/ - } - lv.searchable = true; - ee(_this.searchMsg) - } else { - st(_this.searchMsg, sprintf(LANG.su_noresults, opt.search)); - _this.searchMsg.className = "q10" - } - lv.setData(searchResults); - lv.clearSearch(); - lv.updateFilters(true) - } - }) - }, - ignoredSlots: { - 2 : 1, - 11 : 1, - 12 : 1, - 18 : 1, - 24 : 1, - 28 : 1 - }, - viewableIn3d: function (b) { - for (var c = 0, a = b.group.length; c < a; ++c) { - var e = g_items[b.group[c][0]].jsonequip; - if (e.slotbak > 0 && e.displayid > 0 && !this.ignoredSlots[e.slotbak]) { - return true - } - } - return false - }, - viewIn3dFromPound: function (a) { - var b = parseInt(a) | 0; - if (b >= 0 && b < this.groups.length) { - this.viewIn3d(this.columns[this.clone.i + b]) - } - }, - viewIn3d: function (b) { - var e = []; - for (var c = 0, a = b.group.length; c < a; ++c) { - var f = g_items[b.group[c][0]].jsonequip; - if (f.slotbak > 0 && f.displayid > 0 && !this.ignoredSlots[f.slotbak]) { - e.push(f.slotbak); - e.push(f.displayid) - } - } - ModelViewer.show({ - type: 4, - typeId: 9999, - equipList: e, - extraPound: b.i, - noPound: (this.autoSave ? 1 : null) - }) - }, - splitColumn: function (b) { - this.groups.splice(b.i, 1); - for (var c = 0, a = b.group.length; c < a; ++c) { - this.groups.splice(b.i, 0, [b.group[c]]) - } - this.refreshAll() - }, - hasEnhancements: function (d) { - for (var c = 0, a = d.length; c < a; ++c) { - for (var b = 1; b < 8; ++b) { - if (d[c][b] != 0) { - return true - } - } - } - return false - }, - clearEnhancements: function (b, e) { - var d = 0, - a = b.group.length; - if (!isNaN(e)) { - d = e; - a = e + 1 - } - for (var c = d; c < a; ++c) { - b.group[c] = this.readItem(b.group[c][0]) - } - this.refreshAll() - }, - readGroups: function (e) { - if (!e) { - return - } - var d = e.split(";"); - for (var f = 0, g = d.length; f < g; ++f) { - var h = [], - a = d[f].split(":"); - for (var c = 0, b = a.length; c < b; ++c) { - var k = this.readItem(a[c]); - if (g_items[k[0]]) { - h.push(k) - } - } - if (h.length) { - this.groups.push(h) - } - } - }, - readItem: function (a) { - a += ""; - var c = a.split(".", 8); - while (c.length < 8) { - c.push(0) - } - for (var b = 0; b < 8; ++b) { - c[b] = parseInt(c[b]) - } - return c - }, - writeItem: function (a) { - return a[0] ? a.join(".").replace(/(\.0)+$/, "") : "" - }, - getItemName: function (b) { - if (!g_items[b[0]]) { - return - } - var a = g_items[b[0]].jsonequip.name.substr(1); - if (g_items[b[0]].jsonequip.subitems && g_items[b[0]].jsonequip.subitems[b[1]]) { - a += " " + g_items[b[0]].jsonequip.subitems[b[1]].name - } - return a - }, - getItemRel: function (k, d) { - if (!g_items[k[0]]) { - return - } - var c = this.hasExtraSocket(k), - j = [], - b = [], - h = []; - if (k[1]) { - j.push("rand=" + k[1]) - } - if (k[2]) { - j.push("ench=" + k[2]) - } - for (var e = 0, f = (g_items[k[0]].jsonequip.nsockets | 0) + c; e < f; ++e) { - b.push(k[4 + e] > 0 ? k[4 + e] : 0) - } - if (b.length) { - j.push("gems=" + b.join(":")) - } - if (c) { - j.push("sock") - } - if (g_items[k[0]].jsonequip.itemset) { - for (var e = 0, f = d.group.length; e < f; ++e) { - var a = d.group[e][0]; - if (g_items[a] && g_items[a].jsonequip.itemset) { - h.push(a) - } - } - j.push("pcs=" + h.join(":")) - } - var g = j.join("&"); - if (g) { - g = "&" + g - } - return g - }, - readWeights: function (f) { - if (!f) { - return - } - var e = f.split(";"), - h = parseInt(e.length / 3); - if (h > 0) { - for (var g = 0; g < h; ++g) { - var b = e[g], - a = e[g + h].split(":"), - m = e[g + h * 2].split(":"); - if (a.length > 0 && a.length == m.length) { - var c = { - name: b - }, - n = false; - for (var d = 0, k = a.length; d < k; ++d) { - var l = fi_Lookup(a[d], "items"); - if (l && l.type == "num") { - c[l.name] = parseInt(m[d]); - n = true - } - } - if (n) { - this.weights.push(c) - } - } - } - } - } -}; -Summary.dragGroup = function (b, a, c) { - a.style.width = c.offsetWidth + "px" -}; -Summary.moveGroup = function (d, c, a, f) { - if (!c.__col.group.length) { - return - } - var b = [], - g; - cO(b, this.groups[c.__col.i]); - if (!a) { - if (confirm(LANG.message_deletegroup)) { - this.deleteColumn(c.__col, d) - } - return - } else { - if (f && this.newgroup != null && a.__col.id == this.columns[this.newgroup].id) { - g = this.groups.length - 1 - } else { - if (f && a.__col.id != c.__col.id) { - g = a.__col.i - } else { - return - } - } - } - if (!d.shiftKey) { - if (this.selected != null && this.clone.i + c.__col.i <= this.selected) { - this.selected-- - } - this.groups.splice(c.__col.i, 1) - } - if (this.__selected.id == c.__col.id) { - this.selected = this.clone.i + g - } else { - if (this.selected != null && this.clone.i + g <= this.selected) { - this.selected++ - } - } - this.groups.splice(g, 0, b); - this.refreshAll() -}; -Summary.moveGroupItem = function (d, c, a) { - if (!c.__col.group.length) { - return - } - var b = []; - cO(b, c.__col.group[c.i]); - if (!a || (a.__col.group && !a.__col.group.length)) { - if (confirm(sprintf(LANG.message_deleteitem, g_items[c.__col.group[c.i][0]].jsonequip.name.substring(1)))) { - c.__col.group.splice(c.i, 1); - this.refreshAll() - } - return - } else { - if (this.newgroup != null && a.__col.id == this.columns[this.newgroup].id) { - this.groups.push([b]) - } else { - if (a.__col.id != c.__col.id) { - a.__col.group.push(b) - } else { - if (d.shiftKey) { - c.__col.group.push(b) - } else { - return - } - } - } - } - if (!d.shiftKey) { - c.__col.group.splice(c.i, 1) - } - this.refreshAll() -}; -Summary.addGroupItem = function (g, h) { - if (g == 3) { - this.groups.push([this.readItem(h)]) - } else { - if (g == 4) { - var c = []; - for (var f in g_items) { - if (g_items[f].jsonequip && g_items[f].jsonequip.itemset == h) { - c.push(this.readItem(f)) - } - } - this.groups.push(c) - } - } - this.refreshAll(); - Lightbox.hide(); - if (g == 3 && g_items[h].jsonequip.subitems) { - var e; - for (var f = 0, a = this.visibility.length; f < a; ++f) { - var d = this.visibility[f]; - var b = this.columns[d]; - if (b.group && b.group[0][0] == h) { - e = b - } - } - if (e) { - this.openSubitemPicker(e, 0) - } - } - return false -}; -Summary.groupOver = function (f, d) { - var h = "", - c = {}; - for (var b = 0, a = f.length; b < a; ++b) { - c[f[b][0]] = (c[f[b][0]] | 0) + 1 - } - for (var b = 0, a = f.length; b < a; ++b) { - var g = f[b][0]; - if (g_items[g]) { - h += ""; - h += 'x' + c[g] + ""; - h += '
'; - h += '' + g_items[g]["name_" + g_locale.name] + ""; - h += "
"; - h += '
' + LANG.level + " " + g_items[g].jsonequip.level + "
"; - h += "" - } - } - if (h) { - Tooltip.showAtCursor(d, '' + h + "
") - } -}; -Summary.addWeightScale = function (a) { - a = this.createWeightScale(); - if (a) { - this.weights.push(a) - } - this.toggleOptions(); - this.refreshAll() -}; -Summary.resetScale = function () { - var a = ge("su_classes"); - a.selectedIndex = 0; - a.onchange() -}; -Summary.weightOver = function (a, h) { - var j = '' + a.name + "", - c = "", - g = "", - d, f = false; - d = 0; - for (var b in a) { - if (LANG.traits[b] == null) { - continue - } - if (d++>0) { - c += "
" - } - c += a[b]; - f = true - } - if (f) { - d = 0; - for (var b in a) { - if (LANG.traits[b] == null) { - continue - } - if (d++>0) { - g += "
" - } - g += LANG.traits[b][1] - } - j += '
' + c + '
' + g + '
' + LANG.su_toggle + "" - } - Tooltip.showAtCursor(h, j) -}; -Summary.socketOver = function (c, d) { - var f = "", - a = { - 1 : "#9D9D9D", - 2 : "#e60c0b", - 4 : "#ffff35", - 6 : "#f48905", - 8 : "#295df1", - 10 : "#b957fc", - 12 : "#22c516", - 14 : "#FFFFFF" - }; - for (var b in c) { - if (g_gems[b]) { - f += ""; - f += '
x' + c[b] + "
"; - f += '
'; - f += '' + g_gems[b].name + ""; - f += "
"; - f += '
' + g_gems[b].enchantment + "
"; - f += "" - } - } - if (f) { - Tooltip.showAtCursor(d, '' + f + "
") - } -}; -Summary.addItemSubitem = function (c) { - var a = this.currentItem.col, - b = this.currentItem.i; - a.group[b][1] = c; - this.refreshAll(); - Lightbox.hide() -}; -Summary.addItemEnchant = function (c) { - var a = this.currentItem.col, - b = this.currentItem.i; - a.group[b][2] = c; - this.refreshAll(); - Lightbox.hide() -}; -Summary.addItemGem = function (a) { - var b = this.currentItem.col, - c = this.currentItem.i, - d = this.currentItem.socket; - b.group[c][d] = a; - this.refreshAll(); - Lightbox.hide() -}; -Summary.toggleExtraSocket = function (c, d, b) { - var f = c.group[d], - e = this.getExtraSocketPos(f[0]); - f[e] = (this.hasExtraSocket(f) ? 0 : -1); - this.refreshAll() -}; -Summary.funcBox = { - createSockets: function (c, e, h, m, k, d) { - if (!c) { - return - } - var p = { - 1 : "meta", - 2 : "red", - 4 : "yellow", - 8 : "blue", - 14 : "prismatic" - }; - var f, g = 0; - for (f in p) { - if (c[f] != null && c[f] != 0) {++g - } - } - if (g == 0) { - return - } - var b = ce("div"); - b.style.paddingBottom = "3px"; - ae(e, b); - var l = 0, - g = 0; - for (f in p) { - if (c[f] != null && c[f] != 0) { - if (g > 0) { - if (g % 2 == 0) { - var b = ce("div"); - b.style.paddingBottom = "3px"; - ae(e, b) - } else { - ae(b, ct(String.fromCharCode(160, 160))) - } - } - var o = ce("a"); - o.href = "?items=3&filter=" + (f == 14 ? "gb=1;cr=81:81:81;crs=2:3:4;crv=0:0:0;ma=1": "cr=81;crs=" + (l + 1) + ";crv=0"); - o.className = "moneysocket" + p[f]; - if (d && d[f]) { - for (var n in d[f]) { - if (g_gems[n]) { - o.className += " tip"; - o.style.borderBottom = "1px dotted #808080"; - break - } - } - o.onmouseover = Summary.socketOver.bind(o, d[f]); - o.onmousemove = Tooltip.cursorUpdate; - o.onmouseout = Tooltip.hide - } - if (h) { - o.className += " " + (c[f] > 0 ? "q2": "q10"); - if (c[f] > 0) { - ae(o, ct("+")) - } - } else { - if (m && k && m[f] != k[f] && c[f] == k[f]) { - o.style.fontWeight = "bold"; - o.className += " q2" - } - } - ae(o, ct(c[f])); - ae(b, o); ++g - }++l - } - } -}; -Summary.templates = { - compare: { - total: 1, - clone: 2, - newgroup: 3, - textable: 1, - enhanceable: 1, - columns: [ - { - id: "name", - align: "left", - compute: function (c, f, e, b) { - if (!this.__total.total[c.id]) { - e.style.display = "none" + this.refreshHeader(); + + ae(this.table, this.thead); + ae(this.table, this.tbody); + + this.refreshRows(); + + ae(this.container, this.controls); + ae(this.container, this.textNames); + ae(this.container, this.table); + + this.itemTip = ce('div'); + this.itemTip.className = 'summary-tip'; + this.itemTip.style.display = 'none'; + var span = ce('span'); + span.innerHTML = LANG.su_itemtip; + ae(this.itemTip, span); + ae(this.container, this.itemTip); + + this.refreshLink(); + + if (this.onAfterCreate != null) { + this.onAfterCreate(result); + } + + if (this.templateName == 'compare') { + ModelViewer.addExtraPound(this.viewIn3dFromPound.bind(this)); + } + }, + + updateGroups: function() { + for (var i = 0, len = this.groups.length; i < len; ++i) { + for (var j = 0, len2 = this.groups[i].length; j < len2; ++j) { + if (this.groups[i][j][0] == 0 || (len2 > 1 && this.groups[i][j][0] == -1) || !g_items[this.groups[i][j][0]]) { + this.groups[i].splice(j, 1); + --j; + --len2; + } + } + + if (len2 == 0) { // Remove empty group + if (this.selected != null) { // Deselect if selected + if (this.__selected.i == i) { + this.selected = null; } - f.style.whiteSpace = "nowrap"; - f.style.paddingLeft = "4px"; - f.style.paddingRight = "20px"; - var a = (LANG.traits[c.id] ? LANG.traits[c.id][0] : c.name); - if (c.id == "gains") { - var d = ce("span"); - d.className = "tip"; - d.onmouseover = function () { - Tooltip.show(this, LANG.tooltip_gains, 0, 0, "q") + } + + this.groups.splice(i, 1); + --i; + --len; + } + } + + if (this.editable) { + this.updateControls(); + } + }, + + updateTraits: function() { + this.traits = []; + + var + setBonus, + sep = false, + dataz = []; + + // Get the items, enchants, and gems used by the summary + for (var i = 0, len = this.groups.length; i < len; ++i) { + for (var j = 0, len2 = this.groups[i].length; j < len2; ++j) { + var item = this.groups[i][j]; + + if (g_items[item[0]]) { + dataz.push(g_items[item[0]].jsonequip); + + if (!this.enhanceable) { + continue; + } + + // Subitems + if (g_items[item[0]].jsonequip.subitems && g_items[item[0]].jsonequip.subitems[item[1]]) { + dataz.push(g_items[item[0]].jsonequip.subitems[item[1]].jsonequip); + } + + // Perm Enchant + if (g_enchants[item[2]]) { + dataz.push(g_enchants[item[2]].jsonequip); + } + + // Temp Enchant + if (g_enchants[item[3]]) { + dataz.push(g_enchants[item[3]].jsonequip); + } + + // Gems + for (var k = 4; k < 8; ++k) { + if (g_gems[item[k]]) { + dataz.push(g_gems[item[k]].jsonequip); + } + } + + // Extra sockets + if (this.hasExtraSocket(item)) { + dataz.push({ nsockets: 1 }); + } + + // Socket bonuses + if (this.hasSocketBonus(item)) { + dataz.push(g_items[item[0]].jsonequip.socketbonusstat); + } + } + } + + if (setBonus = this.getSetBonuses(this.groups[i])) { + dataz.push(setBonus); + } + } + + // Find the traits used by those items + for (var i = 0, len = this.template.traits.length; i < len; ++i) { + var trait = this.template.traits[i]; + + if (trait.type == 'sep') { + sep = true; + continue; + } + + var _ = [trait.id]; + if (trait.json) { + var _ = trait.json; + } + + var found = false; + + for (var j = 0, len2 = dataz.length; j < len2; ++j) { + for (var k = 0, len3 = _.length; k < len3; ++k) { + if (dataz[j] && dataz[j][_[k]] + && (trait.id != 'gains' || (this.editable && this.groups.length > 1)) // Special case for 'Gains' + && (trait.id != 'score' || this.weights.length)) { // Special case for 'Score' + if (sep) { + this.traits.push({}); + } + sep = false; + + this.traits.push(trait); + found = true; + break; + } + } + + if (found) { + break; + } + } + } + }, + + updateColumns: function() { + this.columns = this.template.columns.slice(0); + if (this.template.newgroup != null) { + this.newgroup = this.template.newgroup; + } + + if (this.total != null) { + this.__total = this.columns[this.total]; + } + else { + this.__total = {}; + } + + this.__total.total = {}; + this.minValue = {}; + this.maxValue = {}; + this.ratings = {}; + + if (this.clone != null) { + this.columns.splice(this.clone.i, 1); + + var k = 0; + for (var i = 0, len = this.groups.length; i < len; ++i) { + if (this.groups[i].length < 1) { + continue; + } + + if (k > 0 && this.newgroup != null) { + this.newgroup++; + } + + var _ = dO(this.clone); + + _.id = 'group' + i; + _.group = this.groups[i]; + _.i = i; + + this.columns.splice(this.clone.i + i, 0, _); + + k++; + } + + for (var i = 0, len = this.columns.length; i < len; ++i) { + this.calcTraitTotals(this.columns[i], this.__total, this.level); + } + + if (this.selected != null) { + this.__selected = this.columns[this.selected]; + for (var i = 0, len = this.groups.length; i < len; ++i) { + if (this.clone.i + i == this.selected) { + continue; + } + + this.calcTraitDifference(this.columns[this.clone.i + i], this.__selected); + } + } + else { + this.__selected = {}; + } + + if (this.total != null && (k == 1 || this.selected != null)) { + this.__total.hidden = 1; + } + else { + this.__total.hidden = this.showTotal; + } + } + }, + + updateVisibility: function() { + this.visibility = []; + + var + visibleCols = [], + hiddenCols = []; + + if (this.visibleCols != null) { + array_walk(this.visibleCols, function(x) { visibleCols[x] = 1; }); + } + + if (this.hiddenCols != null) { + array_walk(this.hiddenCols, function(x) { hiddenCols[x] = 1; }); + } + + for (var i = 0, len = this.columns.length; i < len; ++i) { + var col = this.columns[i]; + if (visibleCols[col.id] != null || (!col.hidden && hiddenCols[col.id] == null)) { + this.visibility.push(i); + } + } + + if (this.groups.length > 1 && this.textable) { + this.showTextNames(); + } + else { + this.textNames.style.display = 'none'; + } + }, + + updateDraggable: function() { + for (var i = 0, len = this.dragHeaders.length; i < len; ++i) { + var _ = this.dragHeaders[i]; + + _._targets = this.dragTargets; + Draggable.init(_, { + container: this.table, + onDrag: Summary.dragGroup.bind(this), + onDrop: Summary.moveGroup.bind(this) + }); + } + + for (var i = 0, len = this.dragIcons.length; i < len; ++i) { + var _ = this.dragIcons[i]; + + _._targets = this.dragTargets; + Draggable.init(_, { + container: this.table, + onDrop: Summary.moveGroupItem.bind(this) + }); + } + }, + + updateWeights: function(weights) { + var _ = ge('su_weight'); + var c = _.childNodes[0].childNodes[0]; + var i = 0; + + for (var w in weights) { + if (!LANG.traits[w]) { + continue; + } + + if (i++ > 0) { + c = this.addWeight(); + } + + var opts = c.getElementsByTagName('option'); + + for (var j = 0, len = opts.length; j < len; ++j) { + if (opts[j].value == w) { + opts[j].selected = true; + break; + } + } + + this.refreshWeights(c, weights[w]); + } + }, + + addWeight: function(e) { + var _ = ge('su_weight'); + var a = ge('su_addweight'); + + if (_.childNodes.length >= 14) { + a.style.display = 'none'; + } + + a = _.childNodes[0].lastChild; + if (a.nodeName != 'A') { + ae(_.childNodes[0], ct(String.fromCharCode(160, 160))); + ae(_.childNodes[0], this.createControl(LANG.firemove, '', '', this.deleteWeight.bind(this, _.childNodes[0].firstChild))); + } + else { + a.firstChild.nodeValue = LANG.firemove; + a.onmouseup = this.deleteWeight.bind(this, _.childNodes[0].firstChild); + } + + var + d = ce('div'), + c = _.childNodes[0].childNodes[0].cloneNode(true); + + ae(_, d); + + c.onchange = c.onkeyup = this.refreshWeights.bind(this, c); + ae(d, c); + + ae(d, ct(String.fromCharCode(160, 160))); + ae(d, this.createControl(LANG.firemove, '', '', this.deleteWeight.bind(this, c))); + + if (e) { + sp($E(e)); + } + + return c; + }, + + deleteWeight: function(sel, e) { + var + d = sel.parentNode, + c = d.parentNode; + + de(d); + + if (c.childNodes.length == 1) { + var _ = c.firstChild; + if (_.firstChild.selectedIndex > 0) { + var a = _.lastChild; + a.firstChild.nodeValue = LANG.ficlear; + a.onmouseup = this.resetWeights.bind(this); + } + else { + while (_.childNodes.length > 1) { + de(_.childNodes[1]); + } + } + } + + var a = ge('su_addweight'); + if (c.childNodes.length < 15) { + a.style.display = ''; + } + + if (e) { + sp($E(e)); + } + }, + + showDetails: function(a) { + var foo = ge('su_weight'); + + g_toggleDisplay(foo); + + foo = foo.nextSibling; + + a.firstChild.nodeValue = g_toggleDisplay(foo) ? LANG.fihidedetails : LANG.fishowdetails; + }, + + saveScale: function() { + if (!g_user.id) { + return; + } + + var + opts = gE(ge('su_presets'), 'option'), + o; + + for (i in opts) { + if (opts[i].selected) { + o = opts[i]; + break; + } + } + + var + name = ge('su_scale').value, + id = ((o._weights ? o._weights.id : 0) | 0), + scale = { id: id, name: name }, + _ = ge('su_weight'), + n = 0; + + for (i = 0; i < _.childNodes.length; ++i) { + var + w = fi_Lookup(gE(_.childNodes[i], 'select')[0].value), + inps = gE(_.childNodes[i], 'input'), + v; + + for (j in inps) { + if (inps[j]) { + v = inps[j].value; + break; + } + } + + if (w && v && v != 0) { + scale[w.name] = v; + ++n; + } + } + + if (!name || n < 1 || (!(o._weights && o._weights.id) && g_user.weightscales && g_user.weightscales.length >= 5)) { + return alert(LANG.message_weightscalesaveerror); + } + + var data = [ 'save=1', 'name=' + urlencode(name) ]; + + if (id) { + data.push('id=' + id); + } + + scale.name = name; + n = 0; + + var scaStr = '' + for (var w in scale) { + if (!LANG.traits[w]) { + continue; + } + + if (n++ > 0) { + scaStr += ','; + } + + scaStr += w + ':' + scale[w]; + } + data.push('scale=' + scaStr); + + new Ajax('?account=weightscales', { + method: 'post', + params: data.join('&'), + onSuccess: function(xhr, opt) { + var response = parseInt(xhr.responseText); + + if (response > 0) { + if (g_user.weightscales == null) { + g_user.weightscales = []; + } + + if (scale.id) { + g_user.weightscales = array_filter(g_user.weightscales, function(x) { + return x.id != scale.id; + }); + } + + scale.id = response; + g_user.weightscales.push(scale); + + var + s = ge('su_classes'), + opts = gE(s, 'option'), + c; + + for (i in opts) { + if (opts[i].value == -1) { + c = opts[i]; + break; + } + } + + if (!c) { + c = ce('option'); + c.value = -1; + ae(c, ct(LANG.ficustom)); + aef(s, c); + aef(s, gE(s, 'option')[1]); + } + + c._presets = { custom: {} }; + for (var i = 0, len = g_user.weightscales.length; i < len; ++i) { + c._presets.custom[g_user.weightscales[i].id] = g_user.weightscales[i]; + } + + c.selected = true; + c.parentNode.onchange(); + + var + opts = gE(ge('su_presets'), 'option'), + o; + + for (i in opts) { + if (opts[i].value == scale.id) { + o = opts[i]; + break; + } + } + + if (o) { + o.text = scale.name; + o.selected = true; + o.parentNode.onchange(); + } + + alert(LANG.message_saveok); + } + else { + alert(LANG.message_weightscalesaveerror); + } + } + }); + }, + + deleteScale: function() { + if (!g_user.id) { + return; + } + + var + s = ge('su_classes'), + opts = gE(s, 'option'), + c; + + for (i in opts) { + if (opts[i].selected) { + c = opts[i]; + break; + } + } + + if (c.value == -1) { + var + opts = gE(ge('su_presets'), 'option'), + o; + + for (i in opts) { + if (opts[i].selected) { + o = opts[i]; + break; + } + } + + if (o.value && confirm(LANG.confirm_deleteweightscale)) { + new Ajax('?account=weightscales', { + method: 'post', + params: 'delete=1&id=' + o.value + }); + + g_user.weightscales = array_filter(g_user.weightscales, function(x) { + return x.id != o.value; + }); + + if (g_user.weightscales.length) { + c._presets = { custom: {} }; + for (var i = 0, len = g_user.weightscales.length; i < len; ++i) { + c._presets.custom[g_user.weightscales[i].id] = g_user.weightscales[i]; + } + } + else { + de(c); + } + + de(o); + + // $('#su_classes, #su_presets').change(); + ge('su_classes').onchange(); + ge('su_presets').onchange(); + } + } + }, + + calcTraitTotals: function(col, tot, level) { + if (!col.group) { + return; + } + + col.total = {}; + col.difference = {}; + + var traitFuncs = { + sum: function(x, y) { return (!isNaN(x) ? x : 0) + y; }, + min: function(x, y) { return Math.min((!isNaN(x) ? x : y), y); }, + max: function(x, y) { return Math.max((!isNaN(x) ? x : 0), y); }, + avg: function(x, y, n) { return (!isNaN(x) ? x : 0) + (y / n); }, + text: function(x, y, n, e, f, t, s) { + if (f) { + f = f.bind(this); + y = f(y, t, e, s); + } + + return (in_array(x, y) < 0 ? y : null); + }, + custom: function(x, y, n, e, f, t, s) { + if (f) { + f = f.bind(this); + f(y, x, t, e, s); + } + + return x; + } + }; + + var checkTrait = function(json, tj, trait, col, f, c, e, s) { + var _json = dO(json); + if (_json.scadist && _json.scaflags) { + g_setJsonItemLevel(_json, level); + } + + var + v = (trait.type == 'text' || trait.type == 'custom' ? _json : (_json[tj] && typeof _json[tj] != 'object' ? _json[tj] : 0)); + + if (tj == 'nsockets' && s) { + v += s; + } + + if (!v) { + return; + } + + var + cT = f(col.total[trait.id], v, col.group.length, e, c, 0, s), + tT = f(tot.total[trait.id], v, col.group.length, e, c, 1, s); + + if (trait.type == 'text') { + if (cT) { + col.total[trait.id].push(cT); + } + if (tT) { + tot.total[trait.id].push(tT); + } + } + else { + col.total[trait.id] = cT; + tot.total[trait.id] = tT; + } + }; + + for (var trait in this.traits) { + trait = this.traits[trait]; + + if (trait.id && trait.type) { + var + setBonus, + f = traitFuncs[trait.type].bind(this), + c = trait.calcTotal; + + var _ = [trait.id]; + if (trait.json) { + _ = trait.json; + } + + if (col.total[trait.id] == null) { + if (trait.type == 'text') { + col.total[trait.id] = []; + } + else if (trait.type == 'custom') { + col.total[trait.id] = {}; + } + } + + if (tot.total[trait.id] == null) { + if (trait.type == 'text') { + tot.total[trait.id] = []; + } + else if (trait.type == 'custom') { + tot.total[trait.id] = {}; + } + } + + for (var i = 0, len = col.group.length; i < len; ++i) { + var extraSocket = this.hasExtraSocket(col.group[i]); + + for (var j = 0, len2 = _.length; j < len2; ++j) { + if (g_items[col.group[i][0]]) { + if (g_items[col.group[i][0]]) { + checkTrait(g_items[col.group[i][0]].jsonequip, _[j], trait, col, f, c, col.group[i], extraSocket); + + if (!this.enhanceable || trait.itemonly) { + continue; + } + + if (g_items[col.group[i][0]].jsonequip.subitems && g_items[col.group[i][0]].jsonequip.subitems[col.group[i][1]]) { + checkTrait(g_items[col.group[i][0]].jsonequip.subitems[col.group[i][1]].jsonequip, _[j], trait, col, f, c, col.group[i]); + } + + if (g_enchants[col.group[i][2]]) { + checkTrait(g_enchants[col.group[i][2]].jsonequip, _[j], trait, col, f, c, col.group[i]); + } + + if (g_enchants[col.group[i][3]]) { + checkTrait(g_enchants[col.group[i][3]].jsonequip, _[j], trait, col, f, c, col.group[i]); + } + + for (var k = 4; k < 8; ++k) { + if (g_gems[col.group[i][k]]) { + checkTrait(g_gems[col.group[i][k]].jsonequip, _[j], trait, col, f, c, col.group[i]); + } + } + + if (this.hasSocketBonus(col.group[i])) { + checkTrait(g_items[col.group[i][0]].jsonequip.socketbonusstat, _[j], trait, col, f, c, col.group[i]); + } + } + } + } + } + + if (setBonus = this.getSetBonuses(col.group)) { + for (var j = 0, len2 = _.length; j < len2; ++j) { + checkTrait(setBonus, _[j], trait, col, f, c, []); + } + } + + if (trait.rating) { + this.ratings[trait.id] = trait.rating; + } + + if (trait.type == 'sum') { + if (col.total[trait.id] == null) { + this.minValue[trait.id] = 0; + } + else if (this.minValue[trait.id] == null || this.minValue[trait.id] > col.total[trait.id]) { + this.minValue[trait.id] = col.total[trait.id]; + } + if (this.maxValue[trait.id] == null || this.maxValue[trait.id] < col.total[trait.id]) { + this.maxValue[trait.id] = col.total[trait.id]; + } + } + else if (trait.type == 'custom') { + if (this.minValue[trait.id] == null) { + this.minValue[trait.id] = {}; + } + if (this.maxValue[trait.id] == null) { + this.maxValue[trait.id] = {}; + } + + for (var t in col.total[trait.id]) { + if (this.minValue[trait.id][t] == null || this.minValue[trait.id][t] > col.total[trait.id][t]) { + this.minValue[trait.id][t] = col.total[trait.id][t]; + } + if (this.maxValue[trait.id][t] == null || this.maxValue[trait.id][t] < col.total[trait.id][t]) { + this.maxValue[trait.id][t] = col.total[trait.id][t]; + } + } + } + } + } + }, + + calcTraitDifference: function(col, sel) { + col.difference = {}; + + var traitFuncs = { + sum: function(x, y) { return (!isNaN(y) ? y : 0) - (!isNaN(x) ? x : 0); }, + min: function(x, y) { return (!isNaN(y) ? y : 0) - (!isNaN(x) ? x : 0); }, + max: function(x, y) { return (!isNaN(y) ? y : 0) - (!isNaN(x) ? x : 0); }, + avg: function(x, y) { return (!isNaN(y) ? y : 0) - (!isNaN(x) ? x : 0); }, + text: function(x, y) { + var a = []; + for (var i = 0, len = y.length; i < len; ++i) { + if (in_array(x, y[i]) == -1) { + var _ = ce('span'); + _.className = 'q2'; + ae(_, ct('+' + y[i])); + a.push(_); + } + } + for (var i = 0, len = x.length; i < len; ++i) { + if (in_array(y, x[i]) == -1) { + var _ = ce('span'); + + _.className = 'q10'; + ae(_, ct('-' + x[i])); + a.push(_); + } + } + return a; + }, + custom: function(x, y, f) { + if (f) { + f = f.bind(this); + return f(y, x); + } + + return {}; + } + }; + + for (var trait in this.traits) { + trait = this.traits[trait]; + + if (trait.id && trait.type) { + var + f = traitFuncs[trait.type].bind(this), + c = trait.calcDifference; + + col.difference[trait.id] = f(sel.total[trait.id], col.total[trait.id], c); + } + } + }, + + resetAll: function() { + this.groups = []; + this.weights = []; + this.refreshAll(); + }, + + refreshAll: function() { + this.updateGroups(); + this.updateTraits(); + this.updateColumns(); + this.updateVisibility(); + this.refreshHeader(); + this.refreshRows(); + this.refreshLink(); + this.refreshSort(); + + if (this.autoSave) { + this.saveComparison(0); + } + else if (this.editable && !Browser.ie) { + window.onbeforeunload = function(e) { return LANG.message_savebeforeexit }; + } + }, + + refreshHeader: function() { + if (this.groups.length && this.thead.nodeName.toLowerCase() != 'thead') { + this.thead = ce('thead'); + ae(this.table, this.thead); + } + + while (this.thead.firstChild) { + this.thead.removeChild(this.thead.firstChild); + } + + this.dragHeaders = []; + this.dragIcons = []; + this.dragTargets = []; + + this.selectLevel = ce('div'); + this.selectLevel.style.display = 'none'; + + var tr = ce('tr'); + + if (!this.groups.length) { + var th = ce('th'); + ae(tr, th); + ae(this.thead, tr); + this.showNoData(th); + return; + } + + var groupi = 0; + for (var i = 0, len = this.visibility.length; i < len; ++i) { + var reali = this.visibility[i]; + var col = this.columns[reali]; + + var th = ce('th'); + if (col.id == 'total') { + th.style.verticalAlign = 'middle'; + } + else if (col.id == 'name') { + th.style.verticalAlign = 'bottom'; + } + else { + th.style.verticalAlign = 'top'; + } + + col.__th = th; + th.__col = col; + + if (col.width != null) { + th.style.width = col.width; + } + if (col.align != null) { + th.style.textAlign = col.align; + } + if (col.span != null) { + th.colSpan = col.span; + } + + if (this.selected != null && this.__selected.id == col.id) { + th.className = 'checked'; + } + + if (col.id == 'name') { + ae(th, this.selectLevel); + if (this.editable) { + + var s = ce('select'); + s.onchange = (function(s) { + this.level = s.options[s.selectedIndex].value; + this.refreshAll(); + }).bind(this, s); + + for (var i = 80; i > 0; --i) { + var o = ce('option'); + if (i == this.level) { + o.selected = true; + } + st(o, i); + ae(s, o); + } + + ae(this.selectLevel, ct(LANG.su_level + ' ')); + ae(this.selectLevel, s); + } + } + + if (col.group) { + this.dragTargets.push(th); + + if (this.editable) { + var _ = ce('div'); + _.className = 'summary-group'; + + div = ce('div'); + div.className = 'summary-group-controls'; + + var a = ce('a'); + a.href = 'javascript:;'; + a.className = 'summary-group-dropdown'; + ae(a, ce('span')); + a.menu = [ + [0, LANG.su_export, '?compare=' + this.getGroupData(groupi)] + ]; + a.menu[0].newWindow = 1; + + if (this.viewableIn3d(col)) { + a.menu.push([0, LANG.su_viewin3d, this.viewIn3d.bind(this, col)]); + } + + if (col.group.length > 1) { + a.menu.push([0, LANG.su_split, this.splitColumn.bind(this, col)]); + } + + if (this.enhanceable && this.hasEnhancements(col.group)) { + a.menu.push([0, LANG.pr_menu_clearenh, this.clearEnhancements.bind(this, col)]); + } + + a.onclick = Menu.showAtCursor; + ae(div, a); + + if (this.groups.length > 1) { + a = ce('a'); + a.href = 'javascript:;'; + a.className = 'summary-group-focus'; + var s = ce('span'); + a.onclick = this.selectColumn.bind(this, col); + if (this.selected && this.__selected.id == col.id) { + a.onmouseover = function() { + Tooltip.show(this, LANG.tooltip_removefocus, 0, 0, 'q'); + }; + s.className = 'selected'; + } + else { + a.onmouseover = function() { + Tooltip.show(this, LANG.tooltip_setfocus, 0, 0, 'q'); + }; + } + a.onmousemove = Tooltip.cursorUpdate; + a.onmouseout = Tooltip.hide; + ae(a, s); + ae(div, a); + } + + a = ce('a'); + a.href = 'javascript:;'; + a.className = 'summary-group-delete'; + a.onclick = this.deleteColumn.bind(this, col); + ae(a, ce('span')); + ae(div, a); + + if (this.draggable) { + a = ce('a'); + a.href = 'javascript:;'; + a.className = 'summary-group-drag'; + ae(a, ce('span')); + ae(div, a); + + _.__col = col; + _._handle = a; + this.dragHeaders.push(_); + } + + ae(_, div); + ae(th, _); + + if (this.draggable && this.groups.length > 1) { + // Spacer needed to fix the wrapping issues in the bar + _.style.minWidth = '80px'; + } + } + + var + len2 = col.group.length, + iconSize = 1, + iconPerRow = 3, + iconWidth = 44; + + if (len2 > 3) { + iconSize = 0; + iconPerRow = 5; + iconWidth = 26; + } + + var _ = ce('div'); + _.style.margin = '0 auto'; + _.style.clear = 'both'; + + var + btm = ce('div'), + div = _.cloneNode(true); + + if (this.editable) { + btm.className = 'summary-group-bottom'; + } + + for (var j = 0; j < len2; ++j) { + if (j % iconPerRow == 0) { + div.style.width = (iconWidth * iconPerRow) + 'px'; + div = _.cloneNode(true); + ae(btm, div); + } + + var icon = g_items.createIcon(col.group[j][0], iconSize); + + icon.__col = col; + icon.i = j; + + if (this.enhanceable) { + this.refreshItem(col, j, Icon.getLink(icon)); + } + + this.dragIcons.push(icon); + + ae(div, icon); + } + + if (col.group.length) { + div.style.width = (iconWidth * (len2 % iconPerRow == 0 ? iconPerRow : (len2 % iconPerRow))) + 'px'; + } + ae(btm, div); + + if (this.editable) { + th.style.padding = '0'; + + div = ce('div'); + div.className = 'clear'; + ae(btm, div); + + div = ce('div'); + div.className = 'clear'; + ae(th.firstChild, div); + + ae(th.firstChild, btm); + } + else { + ae(th, btm); + } + + groupi++; + } + else if (col.name) { + var b = ce('b'); + ae(b, ct(col.name)); + ae(th, b); + } + + if (this.editable && reali == this.newgroup) { + this.dragTargets.push(th); + } + + ae(tr, th); + } + ae(this.thead, tr); + + if (this.draggable) { + this.updateDraggable(); + } + }, + + refreshItem: function(col, i, a) { + var + item = col.group[i], + itemId = item[0], + menu = [], + + extraSocket = this.hasExtraSocket(item); + + // Random Enchant + if (g_items[itemId].jsonequip.subitems != null) { + menu.push([0, (item[1] ? LANG.pr_menu_repsubitem : LANG.pr_menu_addsubitem), this.openSubitemPicker.bind(this, col, i)]); + } + + // Enchant + if (this.canBeEnchanted(g_items[itemId].jsonequip.slotbak, g_items[itemId].jsonequip.subclass)) { + var _ = [0, (item[2] ? LANG.pr_menu_repenchant : LANG.pr_menu_addenchant), this.openEnchantPicker.bind(this, col, i)]; + + if (item[2] && g_enchants[item[2]]) { + _.tinyIcon = g_enchants[item[2]].icon; + } + + menu.push(_); + } + + // Gems + if (g_items[itemId].jsonequip.nsockets || extraSocket) { + for (var k = 0, len3 = (g_items[itemId].jsonequip.nsockets | 0) + extraSocket; k < len3; ++k) { + var + gemId = (item[k + 4] > 0 ? item[k + 4] : 0), + c = (extraSocket && k == len3 - 1 ? 14 : g_items[itemId].jsonequip['socket' + (k + 1)]), + _ = [0, (gemId ? LANG.pr_menu_repgem : LANG.pr_menu_addgem), this.openGemPicker.bind(this, col, i, 4 + k, c)]; + + if (gemId) { + _.tinyIcon = g_gems[gemId].icon; + } + else { + _.socketColor = c; + } + + menu.push(_); + } + } + + // Extra Socket + if (this.canBeSocketed(g_items[itemId].jsonequip.slotbak)) { + var _ = [0, LANG.pr_menu_extrasock, Summary.toggleExtraSocket.bind(this, col, i, a)]; + _.checked = extraSocket; + + menu.push(_); + } + + if (this.hasEnhancements([item])) { + menu.push([0, LANG.pr_menu_clearenh, this.clearEnhancements.bind(this, col, i)]); + } + + // Remove item + menu.push([0, LANG.pr_menu_remove, this.removeItem.bind(this, col.group, i)]); + + a.rel = this.getItemRel(item, col); + a.oncontextmenu = rf; + a.onclick = this.onMouseClick.bind(0, a); + a.onmouseup = this.onMouseUp.bind(0, a); + a.menu = menu; + }, + + removeItem: function(group, i) { + group.splice(i, 1); + this.refreshAll(); + }, + + refreshRows: function() { + if (this.groups.length) { + ae(this.table, this.tbody); + } + + while (this.tbody.firstChild) { + this.tbody.removeChild(this.tbody.firstChild); + } + + this.selectLevel.style.display = 'none'; + + for (var i = 0, len = this.visibility.length; i < len; ++i) { + var reali = this.visibility[i]; + var col = this.columns[reali]; + + if (!col.group) + continue; + + for (var j = 0, len2 = col.group.length; j < len2; ++j) + { + var itemId = col.group[j][0]; + + if (g_items[itemId].jsonequip.scadist && g_items[itemId].jsonequip.scaflags) + { + this.selectLevel.style.display = ''; + break; + } + } + } + + var i = 0; + for (trait in this.traits) { + if (this.traits[trait].id) { + this.traits[trait].i = ++i; + } + ae(this.tbody, this.getRow(trait, i)); + } + + if (!i) { + if (!this.groups.length && this.tbody.parentNode) { + de(this.tbody); + } + var tr = ce('tr'); + var td = ce('td'); + var span = ce('span'); + if (this.visibility && this.visibility.length) { + td.colSpan = this.visibility.length; + } + td.style.textAlign = 'center'; + ae(span, ct('The items in this set don\'t have any comparable stats.')); + ae(td, span); + ae(tr, td); + ae(this.tbody, tr); + } + }, + + getLink: function(groups, weights, level, focus) { + var href ='?compare'; + + if (groups) { + href += '=' + groups; // sarjuuk - with fixed urls: href += '?items=' + groups; + + if (level != 80) { + href += '&l=' + level; + } + + if (weights[1].length && weights[2].length) { + href += '&weights=' + weights.join(';'); + } + + if (focus !== undefined) { + href += '&focus=' + focus; + } + } + + return href; + }, + + refreshLink: function() { + var + a = ge('su_link'), + _ = this.getGroupData(), + c = this.getWeightData(); + + if (this.editable && _) { + this.itemTip.style.display = ''; + } + else { + this.itemTip.style.display = 'none'; + } + + if (a) { + var href = this.getLink(_, c, this.level, (this.selected ? this.__selected.i : undefined)); + + a.href = href; + a.target = '_blank'; + } + }, + + refreshSort: function(lv) { + if (!this.sortWeighted) { + var sm = ce('small'); + sm.style.display = 'none'; + + var sp = ce('span'); + sp.style.padding = '0 8px'; + sp.style.color = 'white'; + ae(sp, ct('|')); + ae(sm, sp); + + ae(sm, ct(LANG.pr_note_sort + ' ')); + + var s = ce('select'); + ae(sm, s); + + this.sortWeighted = sm; + } + + var + s = gE(this.sortWeighted, 'select')[0], + o = ce('option'); + + ee(s); + ae(s, o); + + if (this.weights && this.weights.length) { + for (var i = 0, len = this.weights.length; i < len; ++i) { + o = ce('option'); + o.scale = this.weights[i]; + o.selected = (o.scale == this.currentScale); + st(o, this.weights[i].name); + ae(s, o); + } + } + + this.sortWeighted.style.display = s.childNodes.length > 1 ? '' : 'none'; + + if (lv) { + ae(ce('div'), this.sortWeighted); // Remove from current parent + gE(this.sortWeighted, 'span')[0].style.display = (gE(lv.getNoteTopDiv(), 'small').length ? '' : 'none'); + + ae(lv.getNoteTopDiv(), this.sortWeighted); + s.onchange = this.sortPickerWindow.bind(this, lv, 1); + s.onchange(); + } + }, + + refreshClasses: function(sel) { + var + c = sel.options[sel.selectedIndex], + _ = ge('su_presets'); + + while (_.firstChild) { + de(_.firstChild); + } + ae(_, ce('option')); + + if (sel.selectedIndex > 0) { + for (var _group in c._presets) { + var weights = c._presets[_group]; + + if (LANG.presets[_group] != null) { + var group = ce('optgroup'); + group.label = LANG.presets[_group]; + } + else { + group = _; + } + + for (var p in weights) { + var o = ce('option'); + o.value = p; + o._weights = weights[p]; + ae(o, ct(weights[p].name ? weights[p].name :LANG.presets[p])); + ae(group, o); + } + + if (LANG.presets[_group] != null && group && group.childNodes.length > 0) { + ae(_, group); + } + } + + if (_.childNodes.length > 1) { + _.parentNode.style.display = ''; + } + } + else { + _.parentNode.style.display = 'none'; + } + + this.resetWeights(); + }, + + refreshPresets: function(sel) { + this.resetWeights(); + + var _ = ge('su_classes'); + + var o = sel.options[sel.selectedIndex]; + if (sel.selectedIndex > 0) { + this.updateWeights(o._weights); + ge('su_scale').value = (_.options[_.selectedIndex].value != -1 ? _.options[_.selectedIndex].text + LANG.hyphen : '') + o.text; + } + + if (g_user.id > 0) { + var a = ge('su_remscale'); + a.style.display = (o._weights && o._weights.name ? '' : 'none'); + } + }, + + resetWeights: function() { + var _ = ge('su_weight'); + + ge('su_scale').value = ''; + + while (_.childNodes.length >= 2) { + _.removeChild(_.childNodes[1]); + } + + var d = _.childNodes[0]; + while (d.childNodes.length > 1) { + d.removeChild(d.childNodes[1]); + } + d.firstChild.selectedIndex = 0; + + var a = ge('su_addweight'); + if (_.childNodes.length < 15) { + a.style.display = ''; + } + }, + + refreshWeights: function(sel, value) { + var d = sel.parentNode; + + while (d.childNodes.length > 1) { + de(d.childNodes[1]); + } + + if (sel.selectedIndex > 0) { + ae(d, ct(' ')); + var _ = ce('input'); + _.type = 'text'; + _.value = (value | 0); + _.maxLength = 7; + _.style.textAlign = 'center'; + _.style.width = '4.5em'; + _.setAttribute('autocomplete', 'off'); + _.onchange = this.sortWeights.bind(this, _); + ae(d, _); + this.sortWeights(_); + } + + if (d.parentNode.childNodes.length == 1) { + if (sel.selectedIndex > 0) { + ae(d, ct(String.fromCharCode(160, 160))); + ae(d, this.createControl(LANG.ficlear, '', '', this.resetWeights.bind(this))); + } + } + else if (d.parentNode.childNodes.length > 1) { + ae(d, ct(String.fromCharCode(160, 160))); + ae(d, this.createControl(LANG.firemove, '', '', this.deleteWeight.bind(this, sel))); + } + }, + + sortWeights: function(input) { + var + _ = ge('su_weight'), + v = Number(input.value), + c = input.parentNode; + + var n = 0; + for (var i = 0, len = _.childNodes.length; i < len; ++i) { + var d = _.childNodes[i]; + if (d.childNodes.length == 5) { + if (d.childNodes[0].tagName == 'SELECT' && d.childNodes[2].tagName == 'INPUT') { + if (v > Number(d.childNodes[2].value)) { + _.insertBefore(c, d); + return; + } + ++n; + } + } + } + + if (n < len) { + _.insertBefore(c, _.childNodes[n]); + } + else { + ae(_, c); + } + }, + + saveComparison: function(refresh) { + window.onbeforeunload = null; + + // g_setWowheadCookie('compare_groups', this.getGroupData(), true); + sc('compare_groups', 20, this.getGroupData(), '/', location.hostname); + // g_setWowheadCookie('compare_weights', rtrim(this.getWeightData(1).join(';'), ';'), true); + sc('compare_weights', 20, rtrim(this.getWeightData(1).join(';'), ';'), '/', location.hostname); + // g_setWowheadCookie('compare_level', this.level, true); + sc('compare_level', 20, this.level, '/', location.hostname); + + if (refresh) { + document.location.href = '?compare' + } + }, + + viewSavedComparison: function(refresh) { + window.onbeforeunload = null; + + document.location.href = '?compare'; + }, + + getGroupData: function(n) { + var + start = 0, + len = this.groups.length; + + if (!isNaN(n)) { + start = n; + len = n + 1; + } + + var + _ = '', + j = 0; + + for (var i = start; i < len; ++i) { + if (this.groups[i].length < 1) { + continue; + } + + if (j++ > 0) { + _ += ';'; + } + + for (var j = 0, len2 = this.groups[i].length; j < len2; ++j) { + if (j > 0) { + _ += ':'; + } + + _ += this.writeItem(this.groups[i][j]); + } + } + return _; + }, + + getWeightData: function(plain) { + var + n = '', + wt = '', + wtv = '', + filter; + + for (var i = 0, len = this.weights.length; i < len; ++i) { + if (i > 0) { + wt += ';'; + wtv += ';'; + n += ';'; + } + n += (plain ? this.weights[i].name : urlencode(this.weights[i].name)); + + var j = 0; + for (var w in this.weights[i]) { + if (!LANG.traits[w]) { + continue; + } + + filter = fi_Lookup(w, 'items'); + if (!filter) { + continue; + } + + if (j++ > 0) { + wt += ':'; + wtv += ':'; + } + + wt += filter.id; + wtv += this.weights[i][w]; + } + } + return [n, wt, wtv]; + }, + + showNoData: function(container) { + var div = this.textNames; + while (div.firstChild) { + de(div.firstChild); + } + div.style.display = 'none'; + + div = this.noData; + while (div.firstChild) { + de(div.firstChild); + } + ae(container, div); + + var result = -1; + if (this.template.onNoData) { + result = (this.template.onNoData.bind(this, div))(); + } + if (result == -1) { + ae(div, ct(LANG.su_additems || LANG.lvnodata)); + } + }, + + showTextNames: function() { + var div = this.textNames; + div.style.display = ''; + div.style.paddingTop = '10px'; + + while (div.firstChild) { + de(div.firstChild); + } + + ae(div, ct(LANG.su_comparing)); + + var n = 0; + for (var i = 0, len = this.visibility.length; i < len; ++i) { + var reali = this.visibility[i]; + var col = this.columns[reali]; + + if (!col.group || !col.group.length) { + continue; + } + + if (n++ > 0) { + ae(div, ct(LANG.su_comparewith)); + } + + if (col.group.length == 1) { + var item = g_items[col.group[0][0]].jsonequip; + + var a = ce('a'); + a.className = 'q' + (7 - parseInt(item.name.charAt(0))); + a.href = '?item=' + item.id; + a.rel = this.getItemRel(col.group[0], col); + ae(a, ct('[' + this.getItemName(col.group[0]) + ']')); + ae(div, a); + } + else { + var sp = ce('span'); + sp.onmouseover = Summary.groupOver.bind(a, col.group); + sp.onmousemove = Tooltip.cursorUpdate; + sp.onmouseout = Tooltip.hide; + sp.className = 'tip'; + ae(sp, ct('[' + col.group.length + ' ' + LANG.types[3][3] + ']')); + ae(div, sp); + } + } + }, + + updateControls: function() { + if (this.__lastCtrlUpdate != null && (this.__lastCtrlUpdate == this.groups.length || this.groups.length > 1)) { + return; + } + this.__lastCtrlUpdate = this.groups.length; + + var + div = this.controls, + a; + + div.style.display = ''; + + while (div.firstChild) { + de(div.firstChild); + } + + var div2 = ce('div'); + div2.className = 'summary-controls-right'; + ae(div, div2); + + a = this.createControl(LANG.su_help, null, 'help-icon', null, '?help=item-comparison'); + a.target = '_blank'; + ae(div2, a); + + if (this.searchable) { + a = this.createControl(LANG.su_addset, 'su_addset', 'additem-icon', this.openItemPicker.bind(this, 4)); + ae(div2, a); + + a = this.createControl(LANG.su_additem, 'su_additem', 'additem-icon', this.openItemPicker.bind(this, 3)); + ae(div2, a); + } + + if (this.groups.length) { + if (this.weightable) { + a = this.createControl(LANG.su_addscale, 'su_addscale', 'additem-icon', this.toggleOptions.bind(this, 'su_weights', 'su_addscale')); + ae(div2, a); + } + } + + aE(document, 'click', this.toggleOptions.bind(this, null, null)); + + var _ = ce('div'); + _.className = 'clear'; + ae(div2, _); + + if (this.weightable) { + var + d2 = ce('div'), + d = ce('div'); + + d2.style.display = 'none'; + d2.id = 'su_weights'; + d.className = 'summary-weights-inner'; + ae(d2, d); + ae(div2, d2); + + var + t = ce('table'), + tbody = ce('tbody'), + tr = ce('tr'), + td = ce('td'); + + ae(t, tbody); + ae(tbody, tr); + ae(tr, td); + + ae(td, ct(LANG.su_preset)); + + td = ce('td'); + ae(tr, td); + + var s = ce('select'); + s.id = 'su_classes'; + s.onchange = s.onkeyup = this.refreshClasses.bind(this, s); + ae(s, ce('option')); + ae(td, s); + + if (g_user.weightscales != null && g_user.weightscales.length) { + var o = ce('option'); + o.value = -1; + o._presets = { custom: {} }; + ae(o, ct(LANG.ficustom)); + ae(s, o); + + for (var i = 0, len = g_user.weightscales.length; i < len; ++i) { + o._presets.custom[g_user.weightscales[i].id] = g_user.weightscales[i]; + } + } + + var temp = []; + for (var c in wt_presets) { + temp.push(c); + } + temp.sort(function(a, b) { + return strcmp(g_chr_classes[a], g_chr_classes[b]); + }); + + for (var i = 0, len = temp.length; i < len; ++i) { + var + c = temp[i], + o = ce('option'); + + o.value = c; + o._presets = wt_presets[c]; + ae(o, ct(g_chr_classes[c])); + ae(s, o); + } + + _ = ce('span'); + _.style.display = 'none'; + ae(_, ct(' ')); + ae(td, _); + + s = ce('select'); + s.id = 'su_presets'; + s.onchange = s.onkeyup = this.refreshPresets.bind(this, s); + ae(s, ce('option')); + ae(_, s); + + ae(td, ct(' ')); + a = ce('a'); + a.href = 'javascript:;'; + ae(a, ct(LANG.fishowdetails)); + a.onclick = this.showDetails.bind(this, a); + ae(td, a); + + if (g_user.id > 0) { + ae(td, ct(' ')); + a = ce('a'); + a.href = 'javascript:;'; + a.className = 'save-icon'; + a.appendChild(ct(LANG.fisavescale)); + a.onclick = this.saveScale; + a.onmousedown = rf; + ae(td, a); + + ae(td, ct(' ')); + a = ce('a'); + a.href = 'javascript:;'; + a.id = 'su_remscale'; + a.className = 'clear-icon'; + a.style.display = 'none'; + a.appendChild(ct(LANG.fideletescale)); + a.onclick = this.deleteScale; + a.onmousedown = rf; + ae(td, a); + } + + tr = ce('tr'); + td = ce('td'); + ae(tbody, tr); + ae(tr, td); + + ae(td, ct(LANG.su_name)); + + td = ce('td'); + ae(tr, td); + + var i = ce('input'); + i.type = 'text'; + i.id = 'su_scale'; + ae(td, i); + ae(td, ct(' ')); + + ae(d, t); + + var w = ce('div'); + w.style.display = 'none'; + w.id = 'su_weight'; + ae(d, w); + _ = ce('div'); + ae(w, _); + + s = ce('select'); + s.onchange = s.onkeyup = this.refreshWeights.bind(this, s); + ae(s, ce('option')); + ae(_, s); + + _ = false; + + for (var i = 0, len = this.template.traits.length; i < len; ++i) { + var p = this.template.traits[i]; + + if (p.type == 'sep') { + if (_ && _.childNodes.length > 0) { + ae(s, _); + } + _ = ce('optgroup'); + _.label = (LANG.traits[p.id] ? LANG.traits[p.id] : p.name); + } + else if (p.type != 'custom') { + var o = ce('option'); + o.value = p.id; + ae(o, ct((p.indent ? '- ' : '') + (LANG.traits[p.id] ? LANG.traits[p.id][0] : p.name))); + ae(_, o); + } + } + if (_ && _.childNodes.length > 0) { + ae(s, _); + } + + _ = ce('div'); + _.style.display = 'none'; + a = this.createControl(LANG.su_addweight, 'su_addweight', '', this.addWeight.bind(this)); + ae(_, a); + ae(d, _); + + _ = ce('div'); + _.className = 'summary-weights-buttons'; + + a = ce('a'); + a.className = 'help-icon'; + a.href = '?help=stat-weighting'; + a.target = '_blank'; + a.style.border = 'none'; + a.style.cssFloat = a.style.styleFloat = 'right'; + ae(a, ct(LANG.su_help)); + ae(_, a); + + i = ce('input'); + i.type = 'button'; + i.value = LANG.su_applyweight; + i.onclick = Summary.addWeightScale.bind(this); + ae(_, i); + + ae(_, ct(' ')); + + i = ce('input'); + i.type = 'button'; + i.value = LANG.su_resetweight; + i.onclick = Summary.resetScale.bind(this); + ae(_, i); + + ae(d, _); + } + + if (this.autoSave) { + a = this.createControl(LANG.su_autosaving, null, 'autosave-icon selected'); + } + else { + if (gc('compare_groups')) { + a = this.createControl(LANG.su_viewsaved, 'su_viewsaved', 'save-icon', this.viewSavedComparison.bind(this, 1)); + ae(div, a); + } + + a = this.createControl(LANG.su_savecompare, 'su_save', 'save-icon', this.saveComparison.bind(this, 1)); + } + ae(div, a); + + if (this.groups.length) { + a = this.createControl(LANG.su_linkcompare, 'su_link', 'link-icon'); + ae(div, a); + + a = this.createControl(LANG.su_clear, null, 'clear-icon', this.resetAll.bind(this)); + ae(div, a); + } + }, + + getRow: function(trait) { + var row = this.traits[trait]; + this.createRow(row); + return row.__tr + }, + + createRow: function(row) { + var tr = ce('tr'); + row.__tr = tr; + + for (var i = 0, len = this.visibility.length; i < len; ++i) { + var reali = this.visibility[i]; + var col = this.columns[reali]; + + var + td = ce('td'), + _ = td; + + if (col.align != null) { + td.style.textAlign = col.align; + } + + if (this.total != null && this.__total.id == col.id || this.selected != null && this.__selected.id == col.id) { + if (row.id != 'gains') { // Special case for 'Gains' + td.style.fontWeight = 'bold'; + td.className += 'q1'; + + if (this.selected != null && this.__selected.id == col.id) { + td.className += ' checked'; + } + } + } + + if (!row.type) { + _.colSpan = len; + _.style.borderBottomWidth = '2px'; + _.style.padding = '0'; + ae(tr, td); + break; + } + + var + result = null, + sign = ''; + + if (col.compute) { + result = (col.compute.bind(this, row, _, tr, reali))(); + } + else if (row.compute) { + result = (row.compute.bind(this, col, _, tr, reali))(); + } + else if (col.total) { + if (this.selected != null && this.__selected.id != col.id && col.difference) { + result = col.difference[row.id]; + if (result > 0) { + _.className += ' q2'; + } + else if (result < 0) { + _.className += ' q10'; + } + else if (result == 0) { + result = null; + } + } + else { + result = col.total[row.id]; + } + + if (result != null) { + if (result.join) { + for (var j = 0, len2 = result.length; j < len2; ++j) { + if (j > 0) { + ae(_, ct(', ')); + } + if (result[j].appendChild) { + ae(_, result[j]); + } + else { + ae(_, ct(result[j])); + } + } + result = null; + } + else if (!isNaN(result)) { + var n = Math.pow(10, (row.digits != null ? row.digits : 4)); + result = Math.round(n * result) / n; + + if (result > 0 && this.selected != null && this.__selected.id != col.id) { + sign = '+'; + } + + if (!row.rating) { + result = (result < 0 ? '-' : '') + number_format(Math.abs(result)); + } + else { + this.selectLevel.style.display = ''; + } + } + } + } + + // Is maximum value? + if (this.groups.length > 1 && !this.selected && col.total && col.total[row.id] == this.maxValue[row.id] && this.maxValue[row.id] != this.minValue[row.id] && col.id != 'total') { + _.style.fontWeight = 'bold'; + _.className += ' q2'; + } + + if (result != null) { + if (row.rating && !isNaN(result)) { + var percent = (result < 0 ? -1 : 1) * g_convertRatingToPercent(this.level, row.rating, Math.abs(result)); + percent = number_format((Math.round(percent * 100) / 100)); + + if (row.rating != 12 && row.rating != 37) { // Neither Defense, nor Expertise + percent += '%'; + } + + var a = ce('a'); + + a.className = (_.className ? _.className : 'q1'); + a.style.borderBottom = '1px dotted #808080'; + a.onmouseover = (function(rating, percent, level, text) { + Tooltip.show(this, rating + ' ' + text + ' (' + sprintf(LANG.tooltip_combatrating, percent, level) + ')
' + LANG.su_toggle + '', 0, 0, 'q'); + }).bind(a, result, percent, this.level, LANG.traits[row.id][0]); + a.onmousemove = Tooltip.cursorUpdate; + a.onmouseout = Tooltip.hide; + a.onclick = this.toggleRatings.bind(this); + + ae(a, ct(sign + (this.ratingMode ? percent : result))); + + aef(_, a); + } + else { + aef(_, ct(sign + result)); + } + } + + if (!row.hidden) { + ae(tr, td); + } + } + }, + + toggleOptions: function(popupId, link, e) { + e = $E(e); + + if (e && e._button >= 2) { + return false; + } + + var + popups = [ge('su_weights')], + links = [ge('su_addscale')], + popup = null; + + if (Browser.ie && e && !popupId && in_array(links, e._target) != -1) { + return; + } + + if (link) { + link = ge(link); + } + if (popupId && link) { // Params provided -> a link was clicked + if (link.className.indexOf('selected') != -1) { // Already selected + link = null; + } + else { + popup = ge(popupId); + } + } + else if (e) { + var p = e._target; + + if (!p.parentNode) { + return; + } + + while (p.parentNode) { + if (in_array(popups, p) != -1) { + return false; + } + + p = p.parentNode; + } + } + + for (var i = 0, len = popups.length; i < len; ++i) { + if (popups[i] && popups[i] != popup) { + popups[i].style.display = 'none'; + } + } + for (var i = 0, len = links.length; i < len; ++i) { + if (links[i] && links[i] != link) { + links[i].className = links[i].className.replace('selected', ''); + } + } + + if (link) { + link.className += ' selected'; + + if (popup) { + popup.style.display = ''; + } + } + + if (e && popupId && link) { + sp(e); + } + }, + + toggleWeights: function() { + if (++this.scoreMode > 2) { + this.scoreMode = 0; + } + this.refreshAll(); + }, + + toggleRatings: function() { + this.ratingMode = !this.ratingMode; + + this.refreshAll(); + }, + + createControl: function(text, id, _class, onclick, href) { + var a = ce('a'); + + if (href) { + a.href = href; + a.target = '_blank'; + } + else { + a.href = 'javascript:;'; + } + + if (id) { + a.id = id; + } + + if (_class) { + a.className = _class; + } + + if (onclick) { + a.onclick = onclick; + } + + ae(a, ct(text)); + + return a; + }, + + createColumn: function() { + this.groups.push([this.readItem(-1)]); + this.refreshAll(); + }, + + selectColumn: function(col) { + Tooltip.hide(); + + this.selected = (this.__selected.id == col.id ? null : this.clone.i + col.i); + this.refreshAll(); + }, + + deleteColumn: function(col, e) { + Tooltip.hide(); + + e = $E(e); + + if (!e.shiftKey) { + this.groups.splice(col.i, 1); + } + else { + this.groups = [this.groups[col.i]]; + } + if (!this.editable || this.groups.length <= 1 || this.__selected.id == col.id) { + this.selected = null; + } + else if (this.selected) { + this.selected += (this.clone.i + col.i > this.selected ? 0 : -1); + } + this.refreshAll(); + + return false; + }, + + createWeightScale: function() { + var + _ = ge('su_weight'), + s = ge('su_scale'), + scale = {}, + found = false; + + scale.name = s.value; + scale.name = trim(scale.name); + scale.name = scale.name.replace(/'/g, ''); + + for (var i = 0, len = _.childNodes.length; i < len; ++i) { + if (_.childNodes[i].childNodes.length == 5) { + if (_.childNodes[i].childNodes[0].tagName == 'SELECT' && _.childNodes[i].childNodes[2].tagName == 'INPUT') { + scale[_.childNodes[i].childNodes[0].options[_.childNodes[i].childNodes[0].selectedIndex].value] = Number(_.childNodes[i].childNodes[2].value); + + found = true; + } + } + } + + if (found) { + return scale; + } + + return null; + }, + + deleteWeightScale: function(i) { + Tooltip.hide(); + + this.weights.splice(i, 1); + + if (!this.weights.length) { + var a = ge('enchants-default-sort'); + if (a) { + a.onclick(); + } + } + + this.refreshAll(); + }, + + calcScores: function(data, scale) { + for (var i = 0, len = data.length; i < len; ++i) { + var row = data[i]; + + row.__tr = null; + row.score = (scale ? 0 : null); + + if (row.jsonequip && scale) { + for (var w in scale) { + if (!LANG.traits[w]) { + continue; + } + + if (!isNaN(row.jsonequip[w])) { + row.score += row.jsonequip[w] * scale[w] / (!this.scoreMode ? scale.f : (this.scoreMode == 2 ? scale.m * 0.01 : 1)); + } + } + + if (!this.scoreMode) { + row.score = row.score.toFixed(2); + } + else if (this.scoreMode == 2) { + row.score = row.score.toFixed(1) + '%'; + } + } + } + + return data; + }, + + sortPickerWindow: function(lv, search) { + if (!this.sortWeighted) { + return; + } + + /* original + if ($('option:selected', this.sortWeighted)[0]) + this.currentScale = $('option:selected', this.sortWeighted)[0].scale; + * replacement */ + + var opts = gE(this.sortWeighted, 'option'); + for (i in opts) { + if (opts[i].selected) { + this.currentScale = opts[i].scale; + break; + } + } + /* replace end */ + + lv.setSort([1], true, false); + lv.setData(this.calcScores(lv.data, this.currentScale)); + + if (this.currentScale) { + lv.setSort([2], true, false); + } + + if (search && lv.id == 'items') { + this.onSearchKeyUp(0); + } + }, + + openItemPicker: function(type) { + this.searchType = type; + + Lightbox.show('compare', { onShow: this.onItemPickerShow.bind(this) }); + }, + + createItemPickerNote: function(div) { + var + sm = ce('small'), + sp = ce('span'), + a; + + this.currentSearch = ''; + this.searchTimer = 0; + + ae(sm, ct(LANG.su_note_name)); + + this.searchName = ce('input'); + this.searchName.type = 'text'; + + aE(this.searchName, 'keyup', this.onSearchKeyUp.bind(this, 333)); + aE(this.searchName, 'keydown', this.onSearchKeyDown.bind(this)); + + ae(sm, this.searchName); + this.searchMsg = sp; + this.searchMsg.style.fontWeight = 'bold'; + ae(sm, this.searchMsg); + ae(div, sm); + }, + + getSetBonuses: function(group) { + var + setbonuses = {}, + itemsetpcs = {}, + itemsetbak = {}; + + for (var i = 0, len = group.length; i < len; ++i) { + var p = group[i][0]; + if (g_items[p]) { + var + s = g_items[p].jsonequip.itemset, + _ = g_itemsets[s]; + + if (_) { + // Use the real set id for set bonus tally + s = _.idbak; + if (itemsetpcs[s] == null) { + itemsetpcs[s] = {}; + } + itemsetpcs[s][p] = 1; + itemsetbak[s] = _; + } + } + } + + for (var s in itemsetpcs) { + var + itemset = itemsetbak[s], + nItems = 0; + + if (!itemset.setbonus) { + continue; + } + + for (var p in itemsetpcs[s]) { + nItems++; + } + + for (var n in itemset.setbonus) { + if (n > nItems) { + break; + } + + for (var j in itemset.setbonus[n]) { + if (setbonuses[j] == null) { + setbonuses[j] = 0; + } + + setbonuses[j] += itemset.setbonus[n][j]; + } + } + } + + return setbonuses; + }, + + onItemPickerShow: function(dest, first, opt) { + Lightbox.setSize(800, 564); + + var lv; + + if (first) { + dest.className = 'summary-picker listview'; + + var + d = ce('div'), + a = ce('a'), + clear = ce('div'); + + d.className = 'listview'; + ae(dest, d); + + a = ce('a'); + a.className = 'screenshotviewer-close'; + a.href = 'javascript:;'; + a.onclick = Lightbox.hide; + ae(a, ce('span')); + ae(dest, a); + + clear.className = 'clear'; + ae(dest, clear); + + lv = new Listview({ + template: 'compare', + id: 'items', + parent: d, + data: [], + clip: { w: 780, h: 478 }, + createNote: this.createItemPickerNote.bind(this) + }); + + if (Browser.firefox) { + aE(lv.getClipDiv(), 'DOMMouseScroll', g_pickerWheel); + } + else { + lv.getClipDiv().onmousewheel = g_pickerWheel; + } + } + else { + lv = g_listviews.items; + } + + var + searchItems = this.searchItems.bind(this), + searchName = this.searchName; + + this.refreshSort(lv); + + setTimeout(function() { + searchItems('', this.searchType); + searchName.value = ''; + searchName.focus(); + }, 1); + }, + + openSubitemPicker: function(col, i) { + this.currentItem = { col: col, i: i, item: col.group[i] }; + + Lightbox.show('subitempicker', { onShow: this.onSubitemPickerShow.bind(this) }); + }, + + onSubitemPickerShow: function(dest, first, opt) { + Lightbox.setSize(800, 564); + + var + lv, + dataz = [], + itemId = this.currentItem.item[0]; + + for (var subitemId in g_items[itemId].jsonequip.subitems) { + var subitem = g_items[itemId].jsonequip.subitems[subitemId]; + + subitem.id = subitemId; + subitem.item = itemId; + subitem._summary = this; + + dataz.push(subitem); + } + + if (first) { + dest.className = 'summary-picker listview'; + + var + d = ce('div'), + a = ce('a'), + clear = ce('div'); + + d.className = 'listview'; + ae(dest, d); + + a = ce('a'); + a.className = 'screenshotviewer-close'; + a.href = 'javascript:;'; + a.onclick = Lightbox.hide; + ae(a, ce('span')); + ae(dest, a); + + clear.className = 'clear'; + ae(dest, clear); + + lv = new Listview({ + template: 'subitempicker', + id: 'subitems', + parent: d, + data: dataz + }); + + if (Browser.firefox) { + aE(lv.getClipDiv(), 'DOMMouseScroll', g_pickerWheel); + } + else { + lv.getClipDiv().onmousewheel = g_pickerWheel; + } + } + else { + lv = g_listviews.subitems; + + lv.setData(dataz); + lv.clearSearch(); + lv.updateFilters(true); + } + + this.refreshSort(lv); + + setTimeout(function() { + lv.focusSearch(); + }, 1); + }, + + openEnchantPicker: function(col, i) { + this.currentItem = { col: col,i: i, item: col.group[i] }; + + Lightbox.show('enchantpicker', { onShow: this.onEnchantPickerShow.bind(this) }); + }, + + createEnchantPickerNote: function(div) { + var + sm = ce('small'), + a; + + ae(sm, ct(LANG.pr_note_source)); + + a = ce('a'); + a.href = 'javascript:;'; + a.onclick = this.filterEnchants.bind(this, a, 0, null); + ae(a, ct(LANG.pr_note_all)); + + g_setSelectedLink(a, 'enchants0'); + + ae(sm, a); + ae(sm, ct(LANG.comma)); + + a = ce('a'); + a.href = 'javascript:;'; + a.onclick = this.filterEnchants.bind(this, a, 0, 1); + ae(a, ct(LANG.pr_note_items)); + + ae(sm, a); + ae(sm, ct(LANG.comma)); + + a = ce('a'); + a.href = 'javascript:;'; + a.onclick = this.filterEnchants.bind(this, a, 0, 2); + ae(a, ct(LANG.pr_note_profs)); + + ae(sm, a); + ae(div, sm); + }, + + canBeEnchanted: function(slot, subclass) { + return ((slot == 1 || slot == 3 || slot == 16 || slot == 5 || slot == 20 || // Head, Shoulder, Back, Chest, Robe + slot == 9 || slot == 10 || slot == 6 || slot == 7 || slot == 8 || // Wrists, Hands, Waist, Legs, Feet + slot == 11 || slot == 21 || slot == 13 || slot == 17 || slot == 22 || // Finger, Main Hand, One Hand, Two Hand, Off Hand + slot == 14 || slot == 15 || slot == 26 || slot == 23) && // Shield, Ranged, Held in Off Hand + (subclass != 19)) // No Wands + }, + + isValidEnchant: function(enchant) { + if (enchant.none) { + return true; + } + + var slotMask = 1 << (g_items[this.currentItem.item[0]].jsonequip.slot - 1); + + return ( + // Slot + (enchant.slots & slotMask) && + + // Source + ( + this.enchantSource == null || + (this.enchantSource == 1 && enchant.source < 0) || + (this.enchantSource == 2 && enchant.source > 0) + ) + ); + }, + + filterEnchants: function(a, wut, value) { + switch (wut) { + case 0: + this.enchantSource = value; + break; + default: + return; + } + + if (a && a.nodeName == 'A') { + g_setSelectedLink(a, 'enchants' + wut); + } + + g_listviews.enchants.updateFilters(true); + + return false; + }, + + onEnchantPickerShow: function(dest, first, opt) { + Lightbox.setSize(800, 564); + + var lv; + + if (first) { + dest.className = 'summary-picker listview'; + + var + dataz = [], + d = ce('div'), + a = ce('a'), + clear = ce('div'); + + dataz.push({ none: 1, __alwaysvisible: 1, _summary: this }); + + for (var enchantId in g_enchants) { + var enchant = { id: enchantId, _summary: this }; + + cO(enchant, g_enchants[enchantId]); + + if (typeof enchant.name == 'string') { + dataz.push(enchant); + } + else { + for (var i = 0, len = g_enchants[enchantId].name.length; i < len; ++i) { + var row = dO(enchant); + + row.name = enchant.name[i]; + row.source = enchant.source[i]; + row.slots = enchant.slots[i]; + + dataz.push(row); + } + } + } + + d.className = 'listview'; + ae(dest, d); + + a = ce('a'); + a.className = 'screenshotviewer-close'; + a.href = 'javascript:;'; + a.onclick = Lightbox.hide; + ae(a, ce('span')); + ae(dest, a); + + clear.className = 'clear'; + ae(dest, clear); + + lv = new Listview({ + template: 'enchantpicker', + id: 'enchants', + parent: d, + data: dataz, + createNote: this.createEnchantPickerNote.bind(this), + customFilter: this.isValidEnchant.bind(this) + }); + + if (Browser.firefox) { + aE(lv.getClipDiv(), 'DOMMouseScroll', g_pickerWheel); + } + else { + lv.getClipDiv().onmousewheel = g_pickerWheel; + } + } + else { + lv = g_listviews.enchants; + + lv.clearSearch(); + lv.updateFilters(true); + } + + this.refreshSort(lv); + + setTimeout(function() { + lv.focusSearch(); + }, 1); + }, + + openGemPicker: function(col, i, socket, color) { + this.currentItem = { + col: col, + i: i, + item: col.group[i], + socket: socket, + color: color + }; + + Lightbox.show('gempicker', { onShow: this.onGemPickerShow.bind(this) }); + }, + + createGemPickerNote: function(div) { + var + sm = ce('small'), + a; + + ae(sm, ct(LANG.pr_note_source)); + + a = ce('a'); + a.href = 'javascript:;'; + a.onclick = this.filterGems.bind(this, a, 0, null); + ae(a, ct(LANG.pr_note_all)); + + ae(sm, a); + ae(sm, ct(LANG.comma)); + + a = ce('a'); + a.href = 'javascript:;'; + a.onclick = this.filterGems.bind(this, a, 0, 1); + ae(a, ct(LANG.pr_note_bc)); + + ae(sm, a); + ae(sm, ct(LANG.comma)); + + a = ce('a'); + a.href = 'javascript:;'; + a.onclick = this.filterGems.bind(this, a, 0, 2); + ae(a, ct(LANG.pr_note_wotlk)); + this.gemSource = 2; + g_setSelectedLink(a, 'gems0'); + + ae(sm, a); + ae(div, sm); + + sm = ce('small'); + + var sp = ce('span'); + sp.style.padding = '0 8px'; + sp.style.color = 'white'; + ae(sp, ct('|')); + ae(sm, sp); + + ae(sm, ct(LANG.pr_note_color)); + + a = ce('a'); + a.href = 'javascript:;'; + a.onclick = this.filterGems.bind(this, a, 1, null); + ae(a, ct(LANG.pr_note_all)); + + ae(sm, a); + ae(sm, ct(LANG.comma)); + + a = ce('a'); + a.href = 'javascript:;'; + a.onclick = this.filterGems.bind(this, a, 1, 1); + ae(a, ct(LANG.pr_note_match)); + + this.gemColor = 1; + g_setSelectedLink(a, 'gems1'); + + ae(sm, a); + ae(div, sm); + }, + + matchGemSocket: function(gemColor, socketColor) { + for (var i = 1; i <= 8; i *= 2) { + if ((socketColor & i) && (gemColor & i)) { + return true; + } + } + + return false; + }, + + canBeSocketed: function(slot) { + return (slot== 9 || slot == 10 || slot == 6); // Wrists, Hands, and Waist + }, + + hasExtraSocket: function(item) { + return this.enhanceable && (item[this.getExtraSocketPos(item[0])] ? 1 : 0); + }, + + getExtraSocketPos: function(itemId) { + if (!itemId || !g_items[itemId]) { + return 4; + } + + return 4 + (g_items[itemId].jsonequip.nsockets | 0); + }, + + hasSocketBonus: function(item) { + var nMatches = 0; + + if (!g_items[item[0]] || !g_items[item[0]].jsonequip.nsockets) { + return false; + } + + for (var j = 0; j < 3; ++j) { + if (item[j + 4] && g_gems[item[j + 4]]) { + if (this.matchGemSocket(g_gems[item[j + 4]].colors, g_items[item[0]].jsonequip['socket' + (j + 1)])) { + ++nMatches; + } + } + } + + return (nMatches == g_items[item[0]].jsonequip.nsockets); + }, + + isValidGem: function(gem) { + if (gem.none) { + return true; + } + + return ( + // Source + (this.gemSource == null || gem.expansion == this.gemSource) && + + // Color + ( + ((this.currentItem.color != 1 && gem.colors != 1) && // Always match meta gems and sockets + this.gemColor == null) || + this.matchGemSocket(gem.colors, this.currentItem.color) + ) + ); + }, + + filterGems: function(a, wut, value) { + switch (wut) { + case 0: + this.gemSource = value; + break; + case 1: + this.gemColor = value; + break; + default: + return; + } + + if (a && a.nodeName == 'A') { + g_setSelectedLink(a, 'gems' + wut); + } + + g_listviews.gems.updateFilters(true); + + return false; + }, + + onGemPickerShow: function(dest, first, opt) { + Lightbox.setSize(800, 564); + + var lv; + + if (first) { + dest.className = 'summary-picker listview'; + + var + dataz = [], + d = ce('div'), + a = ce('a'), + clear = ce('div'); + + dataz.push({ none: 1, __alwaysvisible: 1, _summary: this }); + + for (var gemId in g_gems) { + var gem = { id: gemId, _summary: this }; + + cO(gem, g_gems[gemId]); + + dataz.push(gem); + } + + d.className = 'listview'; + ae(dest, d); + + a = ce('a'); + a.className = 'screenshotviewer-close'; + a.href = 'javascript:;'; + a.onclick = Lightbox.hide; + ae(a, ce('span')); + ae(dest, a); + + clear.className = 'clear'; + ae(dest, clear); + + lv = new Listview({ + template: 'gempicker', + id: 'gems', + parent: d, + data: dataz, + createNote: this.createGemPickerNote.bind(this), + customFilter: this.isValidGem.bind(this) + }); + + if (Browser.firefox) { + aE(lv.getClipDiv(), 'DOMMouseScroll', g_pickerWheel); + } + else { + lv.getClipDiv().onmousewheel = g_pickerWheel; + } + } + else { + lv = g_listviews.gems; + + lv.clearSearch(); + lv.updateFilters(true); + } + + var + div = lv.getNoteTopDiv(), + sms = gE(div, 'small'), + as = gE(div, 'a'); + + if (this.currentItem.color == 1 || this.currentItem.color == 14) { // Meta, Prismatic + sms[1].style.display = 'none'; // Hide 'Color' filter + } + else { + sms[1].style.display = ''; // Show 'Color' filter + } + + this.refreshSort(lv); + + setTimeout(function() { + lv.focusSearch(); + }, 1); + }, + + onMouseClick: function(a, e) { + e = $E(e); + + if (e._button == 3 || e.shiftKey || e.ctrlKey) { + return false; + } + }, + + onMouseUp: function(a, e) { + e = $E(e); + if (e._button == 3 || e.shiftKey || e.ctrlKey) { // Right click + var f = Menu.getDiv(0, a.menu); + + var pos = g_getCursorPos(e); + setTimeout(Menu.showAtCursor.bind(a, null, pos.x, pos.y), 1); // Timeout needed for the context menu to be disabled + // setTimeout(Menu.showAtXY.bind(null, this.menu, pos.x, pos.y), 1); // 5.x + + Tooltip.hide(); + } + + return false; + }, + + onSearchKeyUp: function(delay) { + var search = trim(this.searchName.value.replace(/\s+/g, ' ')); + + if (search == this.currentSearch && isNaN(delay)) { + return; + } + this.currentSearch = search; + + this.prepareSearch(search, delay); + }, + + onSearchKeyDown: function(e) { + e = $E(e); + + switch (e.keyCode) { + case 13: // Enter + g_listviews.items.submitSearch(e); + break; +/* sarjuuk todo: internal misconception ... hide() and cycle(dir) are members of Livesearch and cant be reused here without further adaptation + case 27: // Escape + hide(); + break; + case 38: // Up + cycle(0); + break; + case 40: // Down + cycle(1); + break; +*/ + } + }, + + prepareSearch: function(search, delay) { + if (isNaN(delay)) { + delay = 1000; + } + + if (this.searchTimer > 0) { + clearTimeout(this.searchTimer); + this.searchTimer = 0; + } + + if (search) { + st(this.searchMsg, sprintf(LANG['su_searching' + this.searchType], search)); + } + this.searchMsg.className = ''; + + this.searchTimer = setTimeout(this.searchItems.bind(this, search, this.searchType), delay); + }, + + searchItems: function(search, type) { + var + lv = g_listviews.items, + _this = this, + searchResults = [{ none: 1 }]; + + lv.searchable = false; + lv.setData(searchResults); + lv.clearSearch(); + lv.updateFilters(true); + this.searchMsg.className = ''; + + if (!search && !this.currentScale) { + st(this.searchMsg, LANG['su_specifyitem' + this.searchType]); + return; + } + st(this.searchMsg, sprintf(LANG['su_searching' + this.searchType], search)); + + new Ajax('?search=' + urlencode(search) + '&json&type=' + type + pr_getScaleFilter(this.currentScale, 1), { + method: 'POST', + search: search, + onSuccess: function(xhr, opt) { + var text = xhr.responseText; + if (text.charAt(0) != '[' || text.charAt(text.length - 1) != ']') { + return; + } + + var a = eval(text); + if (search == opt.search && a.length == 3 && a[1].length) { + for (var i = 0, len = a[1].length; i < len; ++i) { + var row = {}; + row.id = a[1][i].id; + row.name = row['name_' + g_locale.name] = a[1][i].name.substring(1); + row.quality = 7 - a[1][i].name.charAt(0); + row.icon = a[1][i].icon; + row.level = a[1][i].level; + row.classs = a[1][i].classs; + row.subclass = a[1][i].subclass; + row.jsonequip = dO(a[1][i]); + + row._type = 3; + row._summary = _this; + + g_items.add(a[1][i].id, row); + + if (_this.searchType == row._type) { + searchResults.push(row); + } + } + + for (var i = 0, len = a[2].length; i < len; ++i) { + var row = {}; + row.id = a[2][i].id; + row.name = row['name_' + g_locale.name] = a[2][i].name.substring(1); + row.quality = 7 - a[2][i].name.charAt(0); + row.minlevel = a[2][i].minlevel; + row.maxlevel = a[2][i].maxlevel; + row.type = a[2][i].type; + row.pieces = a[2][i].pieces; + row.jsonequip = {}; + + for (var j = 0, len2 = row.pieces.length; j < len2; ++j) { + if (g_items[row.pieces[j]]) { + var item = g_items[row.pieces[j]]; + for (var k in item.jsonequip) { + if (LANG.traits[k] == null) { + continue; + } + if (!row.jsonequip[k]) { + row.jsonequip[k] = 0; + } + row.jsonequip[k] += item.jsonequip[k]; + } + } + } + + row._type = 4; + row._summary = _this; + + if (_this.searchType == row._type) { + searchResults.push(row); + } + } + lv.searchable = true; + ee(_this.searchMsg) + } + else { + st(_this.searchMsg, sprintf(LANG.su_noresults, opt.search)); + _this.searchMsg.className = 'q10'; + } + + lv.setData(searchResults); + lv.clearSearch(); + lv.updateFilters(true); + + _this.sortPickerWindow(lv); + } + }); + }, + + // Item slots to ignore when checking if the column can be viewed in 3D + ignoredSlots: { + 2: 1, // Neck + 11: 1, // Finger + 12: 1, // Trinket + 18: 1, // Bag + 24: 1, // Projectile + 28: 1 // Relic + }, + + viewableIn3d: function(col) { + for (var i = 0, len = col.group.length; i < len; ++i) { + var d = g_items[col.group[i][0]].jsonequip; + if (d.slotbak > 0 && d.displayid > 0 && !this.ignoredSlots[d.slotbak]) { + return true; + } + } + + return false; + }, + + viewIn3dFromPound: function(pound) { + var p = parseInt(pound) | 0; + if (p >= 0 && p < this.groups.length) { + this.viewIn3d(this.columns[this.clone.i + p]); + } + }, + + viewIn3d: function(col) { + var stuff = []; + + for (var i = 0, len = col.group.length; i < len; ++i) { + var d = g_items[col.group[i][0]].jsonequip; + if (d.slotbak > 0 && d.displayid > 0 && !this.ignoredSlots[d.slotbak]) { + stuff.push(d.slotbak); + stuff.push(d.displayid); + } + } + + ModelViewer.show({ + type: 4, + typeId: 9999, + equipList: stuff, + extraPound: col.i, + noPound: (this.autoSave ? 1 : null) + }); + }, + + splitColumn: function(col) { + this.groups.splice(col.i, 1); + + for (var i = 0, len = col.group.length; i < len; ++i) { + this.groups.splice(col.i, 0, [col.group[i]]); + } + + this.refreshAll(); + }, + + hasEnhancements: function(group) { + for (var i = 0, len = group.length; i < len; ++i) { + for (var j = 1; j < 8; ++j) { + if (group[i][j] != 0) { + return true; + } + } + } + + return false; + }, + + clearEnhancements: function(col, n) { + var + start = 0, + len = col.group.length; + + if (!isNaN(n)) { + start = n; + len = n + 1; + } + + for (var i = start; i < len; ++i) { + col.group[i] = this.readItem(col.group[i][0] + '.' + col.group[i][1]); + } + + this.refreshAll(); + }, + + readGroups: function(txt) { // Used to read either the 'compare' GET value or the 'compare_groups' cookie. + if (!txt) { + return; + } + + var parts = txt.split(';'); + for (var i = 0, len = parts.length; i < len; ++i) { + var + group = [], + itemIds = parts[i].split(':'); + + for (var j = 0, len2 = itemIds.length; j < len2; ++j) { + var item = this.readItem(itemIds[j]); + + if (g_items[item[0]]) { + group.push(item); + } + } + + if (group.length) { + this.groups.push(group); + } + } + }, + + readItem: function(txt) { + txt += ''; // Force string type + + var item = txt.split('.', 8); + while (item.length < 8) { + item.push(0); + } + + for (var i = 0; i < 8; ++i) { + item[i] = parseInt(item[i]); + } + + return item; + }, + + writeItem: function(item) { + return item[0] ? item.join('.').replace(/(\.0)+$/, "") : ''; + }, + + getItemName: function(item) { + if (!g_items[item[0]]) { + return; + } + + var name = g_items[item[0]].jsonequip.name.substr(1); + + if (g_items[item[0]].jsonequip.subitems && g_items[item[0]].jsonequip.subitems[item[1]]) { + name += ' ' + g_items[item[0]].jsonequip.subitems[item[1]].name; + } + + return name; + }, + + getItemRel: function(item, col) { + if (!g_items[item[0]]) { + return; + } + + var + extraSocket = this.hasExtraSocket(item), + rel = [], + gems = [], + pcs = []; + + if (item[1]) { + rel.push('rand=' + item[1]); + } + + if (item[2]) { + rel.push('ench=' + item[2]); + } + + for (var i = 0, len = (g_items[item[0]].jsonequip.nsockets | 0) + extraSocket; i < len; ++i) { + gems.push(item[4 + i] > 0 ? item[4 + i] : 0); + } + + if (gems.length) { + rel.push('gems=' + gems.join(':')); + } + + if (extraSocket) { + rel.push('sock'); + } + + if (g_items[item[0]].jsonequip.itemset) { + for (var i = 0, len = col.group.length; i < len; ++i) { + var p = col.group[i][0]; + if (g_items[p] && g_items[p].jsonequip.itemset) { + pcs.push(p); + } + } + rel.push('pcs=' + pcs.join(':')); + } + + if (this.level < 80) + rel.push('lvl=' + this.level); + + var result = rel.join('&'); + + if (result) { + result = '&' + result; + } + + return result; + }, + + readWeights: function(txt) { // Used to read either the 'weights' GET value or the 'compare_weights' cookie. + if (!txt) { + return; + } + + var + parts = txt.split(';'), + nScales = parseInt(parts.length / 3); // Name, Ids, Values, Name, Ids, Values, ... + + if (nScales > 0) { + for (var i = 0; i < nScales; ++i) { + var + name = parts[i], + ids = parts[i + nScales].split(':'), + values = parts[i + nScales * 2].split(':'); + + if (ids.length > 0 && ids.length == values.length) { + var + weight = { name: name }, + found = false; + + for (var j = 0, len = ids.length; j < len; ++j) { + var filter = fi_Lookup(ids[j], 'items'); + if (filter && filter.type == 'num') { + + weight[filter.name] = parseInt(values[j]); + found = true; + } + } + + if (found) { + this.weights.push(weight); + } + } + } + } + } +}; + +Summary.dragGroup = function(e, obj, orig) { + obj.style.width = orig.offsetWidth + 'px'; +}; + +Summary.moveGroup = function(e, obj, targ, cursor) { + if (!obj.__col.group.length) { + return; + } + + var + group = [], + pos; + + cO(group, this.groups[obj.__col.i]); + + if (!targ) { + if (confirm(LANG.message_deletegroup)) { + this.deleteColumn(obj.__col, e); + } + + return; + } + else if (cursor && this.newgroup != null && targ.__col.id == this.columns[this.newgroup].id) { + pos = this.groups.length - 1; + } + else if (cursor && targ.__col.id != obj.__col.id) { + pos = targ.__col.i; + } + else { + return; + } + + if (!e.shiftKey) { + if (this.selected != null && this.clone.i + obj.__col.i <= this.selected) { + this.selected--; + } + + this.groups.splice(obj.__col.i, 1); + } + + if (this.__selected.id == obj.__col.id) { + this.selected = this.clone.i + pos; + } + else if (this.selected != null && this.clone.i + pos <= this.selected) { + this.selected++; + } + + this.groups.splice(pos, 0, group); + this.refreshAll(); +}; + +Summary.moveGroupItem = function(e, obj, targ) { + if (!obj.__col.group.length) { + return; + } + + var item = []; + cO(item, obj.__col.group[obj.i]); + + if (!targ || (targ.__col.group && !targ.__col.group.length)) { + if (confirm(sprintf(LANG.message_deleteitem, g_items[obj.__col.group[obj.i][0]].jsonequip.name.substring(1)))) { + obj.__col.group.splice(obj.i, 1); + this.refreshAll(); + } + return; + } + else if (this.newgroup != null && targ.__col.id == this.columns[this.newgroup].id) { + this.groups.push([item]); + } + else if (targ.__col.id != obj.__col.id) { + targ.__col.group.push(item); + } + else if (e.shiftKey) { + obj.__col.group.push(item); + } + else { + return; + } + + if (!e.shiftKey) { + obj.__col.group.splice(obj.i, 1); + } + this.refreshAll(); +}; + +Summary.addGroupItem = function(type, item) { + if (type == 3) { + this.groups.push([this.readItem(item.id)]); + } + else if (type == 4) { + var _ = []; + for (var i in g_items) { + if (g_items[i].jsonequip && g_items[i].jsonequip.itemset == item.id) { + _.push(this.readItem(i)); + } + } + this.groups.push(_); + } + + this.refreshAll(); + Lightbox.hide(); + if (type == 3 && g_items[item.id].jsonequip.subitems) { + + var lastGroup; + + for (var i = 0, len = this.visibility.length; i < len; ++i) { + var reali = this.visibility[i]; + var col = this.columns[reali]; + if (col.group && col.group[0][0] == item.id) { + lastGroup = col; + } + } + + if (lastGroup) { + this.openSubitemPicker(lastGroup, 0); + } + } + + return false; +}; + +Summary.groupOver = function(group, e) { + var + buff = '', + count = {}; + + for (var i = 0, len = group.length; i < len; ++i) { + count[group[i][0]] = (count[group[i][0]] | 0) + 1; + } + + for (var i = 0, len = group.length; i < len; ++i) { + var itemId = group[i][0]; + + if (g_items[itemId]) { + buff += ''; + buff += 'x' + count[itemId] + ''; + buff += '
'; + buff += '' + g_items[itemId]['name_' + g_locale.name] + ''; + buff += '
'; + buff += '
' + LANG.level + ' ' + g_items[itemId].jsonequip.level + '
'; + buff += ''; + } + } + + if (buff) { + Tooltip.showAtCursor(e, '' + buff + '
'); + } +}; + +Summary.addWeightScale = function(scale) { + scale = this.createWeightScale(); + + if (scale) { + this.weights.push(scale); + } + + this.toggleOptions(); + this.refreshAll(); +}; + +Summary.resetScale = function() { + var _ = ge('su_classes'); + + _.selectedIndex = 0; + _.onchange(); +}; + +Summary.weightOver = function(weight, e) { + var + buff = '' + weight.name + '', + leftTd = '', + rightTd = '', + i, + found = false; + + i = 0; + for (var w in weight) { + if (LANG.traits[w] == null) { + continue; + } + + if (i++>0) { + leftTd += '
'; + } + + leftTd += weight[w]; + + found = true; + } + + if (found) { + i = 0; + for (var w in weight) { + if (LANG.traits[w] == null) { + continue; + } + + if (i++>0) { + rightTd += '
'; + } + + rightTd += LANG.traits[w][1]; + } + buff += '
' + leftTd + '
' + rightTd + '
' + LANG.su_toggle + ''; + } + + Tooltip.showAtCursor(e, buff); +}; + +Summary.socketOver = function(gems, e) { + var buff = ''; + + for (var i in gems) { + if (g_gems[i]) { + buff += ''; + buff += '
x' + gems[i] + '
'; + buff += '
'; + buff += '' + g_gems[i].name + ''; + buff += '
'; + buff += '
' + g_gems[i].enchantment + '
'; + buff += ''; + } + } + + if (buff) { + Tooltip.showAtCursor(e, '' + buff + '
'); + } +}; + +Summary.addItemSubitem = function(subitemId) { + var + col = this.currentItem.col, + i = this.currentItem.i; + + col.group[i][1] = subitemId; + + this.refreshAll(); + Lightbox.hide(); +}; + +Summary.addItemEnchant = function(enchantId) { + var + col = this.currentItem.col, + i = this.currentItem.i; + + col.group[i][2] = enchantId; + + this.refreshAll(); + Lightbox.hide(); +}; + +Summary.addItemGem = function(gemId) { + var + col = this.currentItem.col, + i = this.currentItem.i, + s = this.currentItem.socket; + + col.group[i][s] = gemId; + + this.refreshAll(); + Lightbox.hide(); +}; + +Summary.toggleExtraSocket = function(col, i, a) { + var + item = col.group[i], + socket = this.getExtraSocketPos(item[0]); + + item[socket] = (this.hasExtraSocket(item) ? 0 : -1); + + this.refreshAll(); +}; + +Summary.funcBox = { + createSockets: function(sockets, td, selected, minSockets, maxSockets, gems) { + if (!sockets) { + return; + } + + var gem_colors = { + 1 : 'meta', + 2 : 'red', + 4 : 'yellow', + 8 : 'blue', + 14 : 'prismatic' + }; + + var + color, + j = 0; + + for (color in gem_colors) { + if (sockets[color] != null && sockets[color] != 0) { + ++j; + } + } + + if (j == 0) { + return; + } + + var div = ce('div'); + div.style.paddingBottom = '3px'; + ae(td, div); + + var + i = 0, + j = 0; + + for (color in gem_colors) { + if (sockets[color] != null && sockets[color] != 0) { + if (j > 0) { + if (j % 2 == 0) { + var div = ce('div'); + div.style.paddingBottom = '3px'; + ae(td, div); + } + else { + ae(div, ct(String.fromCharCode(160, 160))); + } + } + + var a = ce('a'); + a.href = '?items=3&filter=' + (color == 14 ? 'gb=1;cr=81:81:81;crs=2:3:4;crv=0:0:0;ma=1' : 'cr=81;crs=' + (i + 1) + ';crv=0'); + a.className = 'moneysocket' + gem_colors[color]; + + if (gems && gems[color]) { + for (var x in gems[color]) { + if (g_gems[x]) { + a.className += ' tip'; + a.style.borderBottom = '1px dotted #808080'; + break; + } + } + + a.onmouseover = Summary.socketOver.bind(a, gems[color]); + a.onmousemove = Tooltip.cursorUpdate; + a.onmouseout = Tooltip.hide; + } + + if (selected) { + a.className += ' ' + (sockets[color] > 0 ? 'q2' : 'q10'); + if (sockets[color] > 0) { + ae(a, ct('+')); + } + } + else if (minSockets && maxSockets && minSockets[color] != maxSockets[color] && sockets[color] == maxSockets[color]) { + a.style.fontWeight = 'bold'; + a.className += ' q2'; + } + + ae(a, ct(sockets[color])); + ae(div, a); + + ++j; + } + + ++i; + } + } +}; + +Summary.templates = { + compare: { + total: 1, + clone: 2, + newgroup: 3, + textable: 1, + enhanceable: 1, + + columns: [ + { + id: 'name', + align: 'left', + compute: function(trait, td, tr, i) { + if (!this.__total.total[trait.id]) { + tr.style.display = 'none'; + } + + td.style.whiteSpace = 'nowrap'; + td.style.paddingLeft = '4px'; + td.style.paddingRight = '20px'; + + var res = (LANG.traits[trait.id] ? LANG.traits[trait.id][0] : trait.name); + if (trait.id == 'gains') { + var sp = ce('span'); + sp.className = 'tip'; + sp.onmouseover = function() { + Tooltip.show(this, LANG.tooltip_gains, 0, 0, 'q'); }; - d.onmousemove = Tooltip.cursorUpdate; - d.onmouseout = Tooltip.hide; - ae(d, ct(a)); - ae(f, d) - } else { - return a + sp.onmousemove = Tooltip.cursorUpdate; + sp.onmouseout = Tooltip.hide; + ae(sp, ct(res)); + ae(td, sp); + } + else { + return res; } } }, - { id: "total", name: "Total", align: "center", hidden: 1 }, - { align: "center" }, - { id: "newgroup", align: "center", width: "100%" } + { id: 'total', name: 'Total', align: 'center', hidden: 1 }, + { align: 'center' }, + { id: 'newgroup', align: 'center', width: '100%' } ], - traits: [ - { id: "sepgeneral", type: "sep" }, + + traits: [ + { id: 'sepgeneral', type: 'sep' }, { - id: "score", + id: 'score', name: LANG.score, - type: "custom", - json: ["id"], - calcTotal: function (k, g, e) { + type: 'custom', + json: ['id'], + calcTotal: function(item, total, isTotal) { if (this.scoreMode == null) { - this.scoreMode = 0 + this.scoreMode = 0; } - for (var b = 0, c = this.weights.length; b < c; ++b) { - var a = 0, - d = 0, - h = this.weights[b]; - for (var j in h) { - if (!LANG.traits[j]) { - continue + + for (var i = 0, len = this.weights.length; i < len; ++i) { + var + score = 0, + f = 0, + + weights = this.weights[i]; + + for (var w in weights) { + if (!LANG.traits[w]) { + continue; } - d += h[j]; - if (!isNaN(k[j])) { - a += k[j] * h[j] + + f += weights[w]; + if (!isNaN(item[w])) { + score += item[w] * weights[w]; } } - g[b] = (g[b] | 0) + a; - this.weights[b].f = d; - if (!e && (this.weights[b].m == null || g[b] > this.weights[b].m)) { - this.weights[b].m = g[b] + total[i] = (total[i] | 0) + score; + this.weights[i].f = f; + + if (!isTotal && (this.weights[i].m == null || total[i] > this.weights[i].m)) { + this.weights[i].m = total[i]; } } }, - calcDifference: function (e, d) { - var g = {}; - for (var f = 0, c = this.weights.length; f < c; ++f) { - g[f] = e[f] - d[f] + calcDifference: function(a, b) { + var diff = {}; + for (var i = 0, len = this.weights.length; i < len; ++i) { + diff[i] = a[i] - b[i]; } - return g + + return diff; }, - compute: function (c, h) { - if (!c.total || !c.difference) { - return + compute: function(col, td) { + if (!col.total || !col.difference) { + return; } - var e = 0, - o = (this.selected != null && this.__selected.id != c.id); - h.style.whiteSpace = "nowrap"; - h.style.padding = "4px"; - for (var j = 0, k = this.weights.length; j < k; ++j) { - var f = this.weights[j]; - var g = (o ? c.difference.score[j] : c.total.score[j]), - b = f.name; - if (g != null) { - if (!f.name) { - f.name = sprintf(LANG.su_customscale, ++e) + + var n = 0, + _ = (this.selected != null && this.__selected.id != col.id); + + td.style.whiteSpace = 'nowrap'; + td.style.padding = '4px'; + + for (var i = 0, len = this.weights.length; i < len; ++i) { + var weight = this.weights[i]; + var + score = (_ ? col.difference.score[i] : col.total.score[i]), + name = weight.name; + + if (score != null) { + if (!weight.name) { + weight.name = sprintf(LANG.su_customscale, ++n); } + switch (this.scoreMode) { case 0: - g = (f.f != 0 ? g / f.f: 0).toFixed(2); + score = (weight.f != 0 ? score / weight.f : 0).toFixed(2); break; case 2: - g = (f.m ? 100 * g / f.m: 0).toFixed(1) + "%"; - break + score = (weight.m ? 100 * score / weight.m : 0).toFixed(1) + '%'; + break; } - var m = ce("a"); - m.className = "summary-score-remove"; - m.href = "javascript:;"; - m.onclick = this.deleteWeightScale.bind(this, j); - ae(m, ct("x")); - ae(h, m); - var l = ce("div"); - l.className = "summary-score-row" + (j % 2); - ae(h, l); - var m = ce("a"); - m.className = (o ? (g > 0 ? "q2": "q10") : "q1"); - m.style.borderBottom = "1px dotted #808080"; - m.href = "javascript:;"; - m.onclick = this.toggleWeights.bind(this); - m.onmouseover = Summary.weightOver.bind(m, f); - m.onmousemove = Tooltip.cursorUpdate; - m.onmouseout = Tooltip.hide; - ae(m, ct(g)); - ae(l, m) + + var a = ce('a'); + a.className = 'summary-score-remove'; + a.href = 'javascript:;'; + a.onclick = this.deleteWeightScale.bind(this, i); + ae(a, ct('x')); + ae(td, a); + + var d = ce('div'); + d.className = 'summary-score-row' + (i % 2); + ae(td, d); + + var a = ce('a'); + a.className = (_ ? (score > 0 ? 'q2' : 'q10') : 'q1'); + a.style.borderBottom = '1px dotted #808080'; + a.href = 'javascript:;'; + a.onclick = this.toggleWeights.bind(this); + a.onmouseover = Summary.weightOver.bind(a, weight); + a.onmousemove = Tooltip.cursorUpdate; + a.onmouseout = Tooltip.hide; + ae(a, ct(score)); + ae(d, a); } } } }, - { id: "sepgeneral", type: "sep" }, - { id: "level", type: "avg", digits: 1, itemonly: 1 }, - { id: "reqlevel", type: "max" }, + { id: 'sepgeneral', type: 'sep' }, + { id: 'level', type: 'avg', digits: 1, itemonly: 1 }, + { id: 'reqlevel', type: 'max' }, - { id: "sepbasestats", type: "sep" }, - { id: "agi", type: "sum" }, - { id: "int", type: "sum" }, - { id: "sta", type: "sum" }, - { id: "spi", type: "sum" }, - { id: "str", type: "sum" }, - { id: "health", type: "sum" }, - { id: "mana", type: "sum" }, - { id: "healthrgn", type: "sum" }, - { id: "manargn", type: "sum" }, + { id: 'sepbasestats', type: 'sep' }, + { id: 'agi', type: 'sum' }, + { id: 'int', type: 'sum' }, + { id: 'sta', type: 'sum' }, + { id: 'spi', type: 'sum' }, + { id: 'str', type: 'sum' }, + { id: 'health', type: 'sum' }, + { id: 'mana', type: 'sum' }, + { id: 'healthrgn', type: 'sum' }, + { id: 'manargn', type: 'sum' }, - { id: "sepdefensivestats", type: "sep" }, - { id: "armor", type: "sum" }, - { id: "blockrtng", type: "sum", rating: 15 }, - { id: "block", type: "sum" }, - { id: "defrtng", type: "sum", rating: 12 }, - { id: "dodgertng", type: "sum", rating: 13 }, - { id: "parryrtng", type: "sum", rating: 14 }, - { id: "resirtng", type: "sum", rating: 35 }, + { id: 'sepdefensivestats', type: 'sep' }, + { id: 'armor', type: 'sum' }, + { id: 'blockrtng', type: 'sum', rating: 15 }, + { id: 'block', type: 'sum' }, + { id: 'defrtng', type: 'sum', rating: 12 }, + { id: 'dodgertng', type: 'sum', rating: 13 }, + { id: 'parryrtng', type: 'sum', rating: 14 }, + { id: 'resirtng', type: 'sum', rating: 35 }, - { id: "sepoffensivestats", type: "sep" }, - { id: "atkpwr", type: "sum" }, - { id: "feratkpwr", type: "sum", indent: 1 }, - { id: "armorpenrtng", type: "sum", rating: 44 }, - { id: "critstrkrtng", type: "sum", rating: 32 }, - { id: "exprtng", type: "sum", rating: 37 }, - { id: "hastertng", type: "sum", rating: 36 }, - { id: "hitrtng", type: "sum", rating: 31 }, - { id: "splpen", type: "sum" }, - { id: "splpwr", type: "sum" }, - { id: "arcsplpwr", type: "sum", indent: 1 }, - { id: "firsplpwr", type: "sum", indent: 1 }, - { id: "frosplpwr", type: "sum", indent: 1 }, - { id: "holsplpwr", type: "sum", indent: 1 }, - { id: "natsplpwr", type: "sum", indent: 1 }, - { id: "shasplpwr", type: "sum", indent: 1 }, + { id: 'sepoffensivestats', type: 'sep' }, + { id: 'atkpwr', type: 'sum' }, + { id: 'feratkpwr', type: 'sum', indent: 1 }, + { id: 'armorpenrtng', type: 'sum', rating: 44 }, + { id: 'critstrkrtng', type: 'sum', rating: 32 }, + { id: 'exprtng', type: 'sum', rating: 37 }, + { id: 'hastertng', type: 'sum', rating: 36 }, + { id: 'hitrtng', type: 'sum', rating: 31 }, + { id: 'splpen', type: 'sum' }, + { id: 'splpwr', type: 'sum' }, + { id: 'arcsplpwr', type: 'sum', indent: 1 }, + { id: 'firsplpwr', type: 'sum', indent: 1 }, + { id: 'frosplpwr', type: 'sum', indent: 1 }, + { id: 'holsplpwr', type: 'sum', indent: 1 }, + { id: 'natsplpwr', type: 'sum', indent: 1 }, + { id: 'shasplpwr', type: 'sum', indent: 1 }, - { id: "sepweaponstats", type: "sep" }, - { id: "dmg", type: "sum" }, - { id: "mledps", type: "sum" }, - { id: "rgddps", type: "sum" }, - { id: "mledmgmin", type: "sum" }, - { id: "rgddmgmin", type: "sum" }, - { id: "mledmgmax", type: "sum" }, - { id: "rgddmgmax", type: "sum" }, - { id: "mlespeed", type: "sum" }, - { id: "rgdspeed", type: "sum" }, + { id: 'sepweaponstats', type: 'sep' }, - { id: "sepresistances", type: "sep" }, - { id: "arcres", type: "sum" }, - { id: "firres", type: "sum" }, - { id: "frores", type: "sum" }, - { id: "holres", type: "sum" }, - { id: "natres", type: "sum" }, - { id: "shares", type: "sum" }, + { id: 'dmg', type: 'sum' }, + { id: 'mledps', type: 'sum' }, + { id: 'rgddps', type: 'sum' }, - { id: "sepindividualstats", type: "sep" }, - { id: "mleatkpwr", type: "sum" }, - { id: "mlecritstrkrtng", type: "sum", rating: 19 }, - { id: "mlehastertng", type: "sum", rating: 28 }, - { id: "mlehitrtng", type: "sum", rating: 16 }, - { id: "rgdatkpwr", type: "sum" }, - { id: "rgdcritstrkrtng", type: "sum", rating: 20 }, - { id: "rgdhastertng", type: "sum", rating: 29 }, - { id: "rgdhitrtng", type: "sum", rating: 17 }, - { id: "splcritstrkrtng", type: "sum", rating: 21 }, - { id: "splhastertng", type: "sum", rating: 30 }, - { id: "splhitrtng", type: "sum", rating: 18 }, - { id: "spldmg", type: "sum" }, - { id: "splheal", type: "sum" }, + { id: 'mledmgmin', type: 'sum' }, + { id: 'rgddmgmin', type: 'sum' }, - { id: "", name: LANG.sockets, type: "sep" }, + { id: 'mledmgmax', type: 'sum' }, + { id: 'rgddmgmax', type: 'sum' }, + + { id: 'mlespeed', type: 'avg' }, + { id: 'rgdspeed', type: 'avg' }, + + { id: 'sepresistances', type: 'sep' }, + { id: 'arcres', type: 'sum' }, + { id: 'firres', type: 'sum' }, + { id: 'frores', type: 'sum' }, + { id: 'holres', type: 'sum' }, + { id: 'natres', type: 'sum' }, + { id: 'shares', type: 'sum' }, + + { id: 'sepindividualstats', type: 'sep' }, + { id: 'mleatkpwr', type: 'sum' }, + { id: 'mlecritstrkrtng', type: 'sum', rating: 19 }, + { id: 'mlehastertng', type: 'sum', rating: 28 }, + { id: 'mlehitrtng', type: 'sum', rating: 16 }, + { id: 'rgdatkpwr', type: 'sum' }, + { id: 'rgdcritstrkrtng', type: 'sum', rating: 20 }, + { id: 'rgdhastertng', type: 'sum', rating: 29 }, + { id: 'rgdhitrtng', type: 'sum', rating: 17 }, + { id: 'splcritstrkrtng', type: 'sum', rating: 21 }, + { id: 'splhastertng', type: 'sum', rating: 30 }, + { id: 'splhitrtng', type: 'sum', rating: 18 }, + { id: 'spldmg', type: 'sum' }, + { id: 'splheal', type: 'sum' }, + + { id: '', name: LANG.sockets, type: 'sep' }, { - id: "gems", + id: 'gems', name: LANG.gems, - type: "custom", - json: ["id"], + type: 'custom', + json: ['id'], itemonly: 1, - calcTotal: function (e, d, f, a, b) { - for (var c = 1; c <= 8; c *= 2) { - if (d[c] == null) { - d[c] = {} + calcTotal: function(item, total, isTotal, equipInfo, extraSocket) { + for (var i = 1; i <= 8; i *= 2) { + if (total[i] == null) { + total[i] = {}; } } - if (d[14] == null) { - d[14] = {} + + if (total[14] == null) { + total[14] = {}; } - for (var c = 1; c < 4; ++c) { - if ((s = e["socket" + c]) && a[c + 3]) { - d[s][a[c + 3]] = (d[s][a[c + 3]] | 0) + 1 + + for (var i = 1; i < 4; ++i) { + if ((s = item['socket' + i]) && equipInfo[i + 3]) { + total[s][equipInfo[i + 3]] = (total[s][equipInfo[i + 3]] | 0) + 1; } } - c = (e.nsockets | 0) + 4; - if (b && a[c]) { - d[14][a[c]] = (d[14][c] | 0) + 1 + + i = (item.nsockets | 0) + 4; + if (extraSocket && equipInfo[i]) { + total[14][equipInfo[i]] = (total[14][i] | 0) + 1; } }, hidden: 1 }, { - id: "sockets", + id: 'sockets', name: LANG.sockets, - type: "custom", - json: ["socket1"], - calcTotal: function (e, d, f, a, b) { - for (var c = 1; c <= 8; c *= 2) { - d[c] = (d[c] | 0) + type: 'custom', + json: ['socket1'], + calcTotal: function(item, total, isTotal, equipInfo, extraSocket) { + for (var i = 1; i <= 8; i *= 2) { + total[i] = (total[i] | 0); } - d[14] = (d[14] | 0); - for (var c = 1; c < 4; ++c) { - if (s = e["socket" + c]) { - d[s]++ + + total[14] = (total[14] | 0); + + for (var i = 1; i < 4; ++i) { + if (s = item['socket' + i]) { + total[s]++; } } - if (b) { - d[14]++ + + if (extraSocket) { + total[14]++; } }, - calcDifference: function (d, c) { - var f = {}; - for (var e = 1; e <= 8; e *= 2) { - if (d[e] != null || c[e] != null) { - f[e] = (d[e] | 0) - (c[e] | 0) + calcDifference: function(a, b) { + var diff = {}; + for (var i = 1; i <= 8; i *= 2) { + if (a[i] != null || b[i] != null) { + diff[i] = (a[i] | 0) - (b[i] | 0); } } - return f + return diff; }, - compute: function (b, d) { - var a = (this.selected != null && this.__selected.id != b.id); - var c = a ? b.difference: b.total; - if (!c) { - return + compute: function(col, td) { + var _ = (this.selected != null && this.__selected.id != col.id); + var total = _ ? col.difference : col.total; + + if (!total) { + return; } + if (this.groups.length > 1) { - Summary.funcBox.createSockets(c.sockets, d, a, this.minValue.sockets, this.maxValue.sockets, c.gems) - } else { - Summary.funcBox.createSockets(c.sockets, d, a, null, null, c.gems) + Summary.funcBox.createSockets(total.sockets, td, _, this.minValue['sockets'], this.maxValue['sockets'], total.gems); + } + else { + Summary.funcBox.createSockets(total.sockets, td, _, null, null, total.gems); } } }, - { id: "nsockets", type: "sum" }, - { id: "", type: "sep" }, + { id: 'nsockets', type: 'sum' }, + { id: '', type: 'sep' }, { - id: "gains", + id: 'gains', name: LANG.gains, - type: "custom", - json: ["id"], - compute: function (b, g) { - if (b.id == this.columns[this.total].id || !b.total) { - return + type: 'custom', + json: ['id'], + compute: function(col, td) { + if (col.id == this.columns[this.total].id || !col.total) { + return; } - g.style.whiteSpace = "nowrap"; - g.style.textAlign = "left"; - var d = 0; - for (var c in this.minValue) { - if (b.total[c] > this.minValue[c]) { - if (d++>0) { - ae(g, ce("br")) + + td.style.whiteSpace = 'nowrap'; + td.style.textAlign = 'left'; + + var i = 0; + for (var trait in this.minValue) { + if (col.total[trait] > this.minValue[trait]) { + if (i++ > 0) { + ae(td, ce('br')); } - var f = (Math.round(1000 * (b.total[c] - this.minValue[c])) / 1000); - ae(g, ct(f + " " + LANG.traits[c][1])); - if (this.ratings[c] != null) { - var a = g_convertRatingToPercent(this.level, this.ratings[c], f); - a = number_format((Math.round(a * 100) / 100)); - if (this.ratings[c] != 12 && this.ratings[c] != 37) { - a += "%" + + var value = (Math.round(1000 * (col.total[trait] - this.minValue[trait])) / 1000); + + ae(td, ct(value + ' ' + LANG.traits[trait][1])); + + if (this.ratings[trait] != null) { + var percent = g_convertRatingToPercent(this.level, this.ratings[trait], value); + + percent = number_format((Math.round(percent * 100) / 100)); + + if (this.ratings[trait] != 12 && this.ratings[trait] != 37) { // Neither Defense, nor Expertise + percent += '%'; } - var e = ce("small"); - ae(e, ct(" (" + a + ")")); - ae(g, e) + + var s = ce('small'); + ae(s, ct(' (' + percent + ')')); + ae(td, s); } } } } } ] - }, - itemset: { - total: 1, - clone: 2, - editable: 0, - columns: [{ - id: "name", - align: "left", - compute: function (b, d, c, a) { - if (!this.__total.total[b.id]) { - c.style.display = "none" - } - return (LANG.traits[b.id] ? LANG.traits[b.id][0] : b.name) - } - }, - { id: "total", name: "Total", align: "center" }, - { align: "center" }], - traits: [ - { id: "str", type: "sum" }, - { id: "agi", type: "sum" }, - { id: "sta", type: "sum" }, - { id: "int", type: "sum" }, - { id: "spi", type: "sum" }, - { id: "health", type: "sum" }, - { id: "mana", type: "sum" }, - { id: "healthrgn", type: "sum" }, - { id: "manargn", type: "sum" }, - { id: "armor", type: "sum" }, - { id: "block", type: "sum" }, - { id: "defrtng", type: "sum", rating: 12 }, - { id: "dodgertng", type: "sum", rating: 13 }, - { id: "parryrtng", type: "sum", rating: 14 }, - { id: "resirtng", type: "sum", rating: 35 }, - { id: "blockrtng", type: "sum", rating: 15 }, - { id: "atkpwr", type: "sum" }, - { id: "feratkpwr", type: "sum" }, - { id: "armorpenrtng", type: "sum", rating: 44 }, - { id: "critstrkrtng", type: "sum", rating: 32 }, - { id: "exprtng", type: "sum", rating: 37 }, - { id: "hastertng", type: "sum", rating: 36 }, - { id: "hitrtng", type: "sum", rating: 31 }, - { id: "splpen", type: "sum" }, - { id: "splpwr", type: "sum" }, - { id: "arcsplpwr", type: "sum" }, - { id: "firsplpwr", type: "sum" }, - { id: "frosplpwr", type: "sum" }, - { id: "holsplpwr", type: "sum" }, - { id: "natsplpwr", type: "sum" }, - { id: "shasplpwr", type: "sum" }, - { id: "dps", type: "sum" }, - { id: "dmg", type: "sum" }, - { id: "arcres", type: "sum" }, - { id: "firres", type: "sum" }, - { id: "frores", type: "sum" }, - { id: "holres", type: "sum" }, - { id: "natres", type: "sum" }, - { id: "shares", type: "sum" }, - { id: "mleatkpwr", type: "sum" }, - { id: "mlecritstrkrtng", type: "sum", rating: 19 }, - { id: "mlehastertng", type: "sum", rating: 28 }, - { id: "mlehitrtng", type: "sum", rating: 16 }, - { id: "rgdatkpwr", type: "sum" }, - { id: "rgdcritstrkrtng", type: "sum", rating: 20 }, - { id: "rgdhastertng", type: "sum", rating: 29 }, - { id: "rgdhitrtng", type: "sum", rating: 17 }, - { id: "splcritstrkrtng", type: "sum", rating: 21 }, - { id: "splhastertng", type: "sum", rating: 30 }, - { id: "splhitrtng", type: "sum", rating: 18 }, - { id: "spldmg", type: "sum" }, - { id: "splheal", type: "sum" }, - { id: "sockets", + }, + + itemset: { + total: 1, + clone: 2, + editable: 0, + + columns: [ + { + id: 'name', + align: 'left', + compute: function(trait, td, tr, i) { + if (!this.__total.total[trait.id]) { + tr.style.display = 'none'; + } + + return (LANG.traits[trait.id] ? LANG.traits[trait.id][0] : trait.name); + } + }, + { id: 'total', name: 'Total', align: 'center' }, + { align: 'center' } + ], + + traits: [ + { id: 'str', type: 'sum' }, + { id: 'agi', type: 'sum' }, + { id: 'sta', type: 'sum' }, + { id: 'int', type: 'sum' }, + { id: 'spi', type: 'sum' }, + { id: 'health', type: 'sum' }, + { id: 'mana', type: 'sum' }, + { id: 'healthrgn', type: 'sum' }, + { id: 'manargn', type: 'sum' }, + + { id: 'armor', type: 'sum' }, + { id: 'block', type: 'sum' }, + { id: 'defrtng', type: 'sum', rating: 12 }, + { id: 'dodgertng', type: 'sum', rating: 13 }, + { id: 'parryrtng', type: 'sum', rating: 14 }, + { id: 'resirtng', type: 'sum', rating: 35 }, + { id: 'blockrtng', type: 'sum', rating: 15 }, + { id: 'atkpwr', type: 'sum' }, + { id: 'feratkpwr', type: 'sum' }, + { id: 'armorpenrtng', type: 'sum', rating: 44 }, + { id: 'critstrkrtng', type: 'sum', rating: 32 }, + { id: 'exprtng', type: 'sum', rating: 37 }, + { id: 'hastertng', type: 'sum', rating: 36 }, + { id: 'hitrtng', type: 'sum', rating: 31 }, + { id: 'splpen', type: 'sum' }, + { id: 'splpwr', type: 'sum' }, + { id: 'arcsplpwr', type: 'sum' }, + { id: 'firsplpwr', type: 'sum' }, + { id: 'frosplpwr', type: 'sum' }, + { id: 'holsplpwr', type: 'sum' }, + { id: 'natsplpwr', type: 'sum' }, + { id: 'shasplpwr', type: 'sum' }, + + { id: 'dps', type: 'sum' }, + { id: 'dmg', type: 'sum' }, + + { id: 'arcres', type: 'sum' }, + { id: 'firres', type: 'sum' }, + { id: 'frores', type: 'sum' }, + { id: 'holres', type: 'sum' }, + { id: 'natres', type: 'sum' }, + { id: 'shares', type: 'sum' }, + + { id: 'mleatkpwr', type: 'sum' }, + { id: 'mlecritstrkrtng', type: 'sum', rating: 19 }, + { id: 'mlehastertng', type: 'sum', rating: 28 }, + { id: 'mlehitrtng', type: 'sum', rating: 16 }, + { id: 'rgdatkpwr', type: 'sum' }, + { id: 'rgdcritstrkrtng', type: 'sum', rating: 20 }, + { id: 'rgdhastertng', type: 'sum', rating: 29 }, + { id: 'rgdhitrtng', type: 'sum', rating: 17 }, + { id: 'splcritstrkrtng', type: 'sum', rating: 21 }, + { id: 'splhastertng', type: 'sum', rating: 30 }, + { id: 'splhitrtng', type: 'sum', rating: 18 }, + { id: 'spldmg', type: 'sum' }, + { id: 'splheal', type: 'sum' }, + + { + id: 'sockets', name: LANG.sockets, - type: "custom", - json: ["socket1"], - calcTotal: function (c, b) { - for (var a = 1; a <= 8; a *= 2) { - b[a] = (b[a] | 0) + type: 'custom', + json: ['socket1'], + calcTotal: function(item, total) { + for (var i = 1; i <= 8; i *= 2) { + total[i] = (total[i] | 0); } - for (var a = 1; a < 4; ++a) { - if (s = c["socket" + a]) { - b[s]++ + + for (var i = 1; i < 4; ++i) { + if (s = item['socket' + i]) { + total[s]++; } } }, - calcDifference: function (d, c) { - var f = {}; - for (var e = 1; e <= 8; e *= 2) { - if (d[e] != null || c[e] != null) { - f[e] = (d[e] | 0) - (c[e] | 0) + calcDifference: function(a, b) { + var diff = {}; + for (var i = 1; i <= 8; i *= 2) { + if (a[i] != null || b[i] != null) { + diff[i] = (a[i] | 0) - (b[i] | 0); } } - return f + return diff; }, - compute: function (b, d) { - var a = (this.selected != null && this.__selected.id != b.id); - var c = a ? b.difference: b.total; - if (!c) { - return + compute: function(col, td) { + var _ = (this.selected != null && this.__selected.id != col.id); + var total = _ ? col.difference : col.total; + + if (!total) { + return; } + if (this.groups.length > 1) { - Summary.funcBox.createSockets(c.sockets, d, a, this.minValue.sockets, this.maxValue.sockets) - } else { - Summary.funcBox.createSockets(c.sockets, d, a) + Summary.funcBox.createSockets(total.sockets, td, _, this.minValue['sockets'], this.maxValue['sockets']); + } + else { + Summary.funcBox.createSockets(total.sockets, td, _); } } } ] - } + } }; + Listview.templates.compare = { - sort: [1], - nItemsPerPage: -1, - hideBands: 2, - hideNav: 1 | 2, - hideHeader: 1, - searchable: 1, - searchDelay: 100, - poundable: 0, - filtrable: 0, - clip: { - w: 780, - h: 486 - }, - onBeforeCreate: function () { - this.applySort() - }, - onSearchSubmit: function (a) { - if (this.nRowsVisible != 1) { - return - } (Summary.addGroupItem.bind(a._summary, a._type, a.id))() - }, - columns: [{ - id: "item", - type: "text", - align: "left", - value: "name", - compute: function (f, h, g) { - if (f.none) { - g.style.display = "none"; - return - } - var b = ce("a"); - b.className = "q" + f.quality; - b.style.fontFamily = "Verdana, sans-serif"; - b.onclick = rf; - switch (f._type) { - case 3: - if (!Browser.ie67) { - this.template.columns[0].span = 2; - var c = ce("td"); - c.style.width = "1px"; - c.style.padding = "0"; - c.style.borderRight = "none"; - var d = Icon.create(f.icon, 0, null, "?item=" + f.id), - e = Icon.getLink(d); - ae(c, d); - ae(g, c); - h.style.borderLeft = "none"; - e.onclick = rf; - b.href = "?item=" + f.id + sort: [1], + nItemsPerPage: -1, + hideBands: 2, + hideNav: 1 | 2, + hideHeader: 1, + searchable: 1, + searchDelay: 100, + poundable: 0, + filtrable: 0, + clip: { + w: 780, + h: 486 + }, + + onBeforeCreate: function() { + this.applySort(); + }, + + onSearchSubmit: function(item) { + if (this.nRowsVisible != 1) { + return; + } + + (Summary.addGroupItem.bind(item._summary, item._type, item))(); + }, + + columns: [ + { + id: 'item', + type: 'text', + align: 'left', + value: 'name', + compute: function(item, td, tr) { + if (item.none) { + tr.style.display = 'none'; + return; + } + + var a = ce('a'); + a.className = 'q' + item.quality; + a.style.fontFamily = 'Verdana, sans-serif'; + + switch (item._type) { + case 3: + this.template.columns[0].span = 2; + + var i = ce('td'); + i.style.width = '1px'; + i.style.padding = '0'; + i.style.borderRight = 'none'; + + var + icon = Icon.create(item.icon, 0, null, '?item=' + item.id), + link = Icon.getLink(icon); + + ae(i, icon); + ae(tr, i); + td.style.borderLeft = 'none'; + + link.onclick = rf; + + a.href = '?item=' + item.id; + break; + case 4: + a.href = '?itemset=' + item.id; + break; + } + + ae(a, ct(item.name)); + + nw(td); + ae(td, a); + + tr.onclick = function(e) { + e = $E(e); + if (e._button != 2 || e._target != a) { + e.preventDefault(); + (Summary.addGroupItem.bind(item._summary, item._type, item))(); + } + }; + }, + sortFunc: function(a, b, col) { + if (a.none) { + return -1; + } + if (b.none) { + return 1; + } + + return ( + -strcmp(a.level | a.minlevel, b.level | b.minlevel) || + -strcmp(a.quality, b.quality) || + strcmp(a.name, b.name) + ); + } + }, + { + id: 'level', + name: LANG.level, + type: 'range', + getMinValue: function(item) { + return item.minlevel | item.level; + }, + getMaxValue: function(item) { + return item.maxlevel | item.level; + }, + compute: function(item, td, tr) { + if (item.none) { + return; + } + + switch (item._type) { + case 3: + return item.level; + break; + case 4: + if (item.minlevel > 0 && item.maxlevel > 0) { + if (item.minlevel != item.maxlevel) { + return item.minlevel + LANG.hyphen + item.maxlevel; + } + else { + return item.minlevel; + } + } + else { + return -1; + } + break; + } + }, + sortFunc: function(a, b, col) { + if (a.none) { + return -1; + } + if (b.none) { + return 1; + } + + return ( + -strcmp(a.score, b.score) || + strcmp(a.name, b.name) + ); + } + }, + { + id: 'pieces', + name: LANG.pieces, + getValue: function(item) { + return item.pieces ? item.pieces.length : null; + }, + compute: function(item, td) { + if (item.pieces) { + td.style.padding = '0'; + Listview.funcBox.createCenteredIcons(item.pieces, td); + } + else { + td.style.display = 'none'; + } + } + }, + { + id: 'type', + name: LANG.type, + type: 'text', + compute: function(item, td, tr) { + td.className = 'small q1'; + nw(td); + var a = ce('a'); + + switch (item._type) { + case 3: + var it = Listview.funcBox.getItemType(item.classs, item.subclass, item.subsubclass); + a.href = it.url; + ae(a, ct(it.text)); + break; + case 4: + ae(a, ct(g_itemset_types[item.type])); + break; + } + + ae(td, a); + }, + getVisibleText: function(item) { + return Listview.funcBox.getItemType(item.classs, item.subclass, item.subsubclass).text; + } + }, + { + id: 'score', + align: 'center', + compute: function(item, td, tr) { + if (item.score != null) { + var + n = parseFloat(item.score), + s = ce('div'); + + s.className = 'small q' + (n ? (n > 0 ? 2 : 10) : 0); + st(s, (n ? (n > 0 ? '+' : '-') + item.score : 0)); + ae(td, s); } - break; - case 4: - b.href = "?itemset=" + f.id; - break - } - ae(b, ct(f.name)); - nw(h); - ae(h, b); - g.onclick = Summary.addGroupItem.bind(f._summary, f._type, f.id) - }, - sortFunc: function (d, c, e) { - if (d.none) { - return -1 - } - if (c.none) { - return 1 - } - return ( -strcmp(d.quality, c.quality) || strcmp(d.name, c.name) || -strcmp(d.level, c.level)) - } - }, - { - id: "level", - name: LANG.level, - type: "range", - getMinValue: function (a) { - return a.minlevel | a.level - }, - getMaxValue: function (a) { - return a.maxlevel | a.level - }, - compute: function (a, c, b) { - if (a.none) { - return - } - switch (a._type) { - case 3: - return a.level; - break; - case 4: - if (a.minlevel > 0 && a.maxlevel > 0) { - if (a.minlevel != a.maxlevel) { - return a.minlevel + LANG.hyphen + a.maxlevel - } else { - return a.minlevel - } - } else { - return -1 - } - break + else { + td.style.display = 'none'; + } } } - }, - { - id: "pieces", - name: LANG.pieces, - getValue: function (a) { - return a.pieces ? a.pieces.length: null - }, - compute: function (a, b) { - b.style.padding = "0"; - Listview.funcBox.createCenteredIcons(a.pieces, b) - } - }, - { - id: "type", - name: LANG.type, - type: "text", - compute: function (d, f, e) { - f.className = "small q1"; - nw(f); - var b = ce("a"); - switch (d._type) { - case 3: - var c = Listview.funcBox.getItemType(d.classs, d.subclass, d.subsubclass); - b.href = c.url; - ae(b, ct(c.text)); - break; - case 4: - ae(b, ct(g_itemset_types[d.type])); - break - } - ae(f, b) - }, - getVisibleText: function (a) { - return Listview.funcBox.getItemType(a.classs, a.subclass, a.subsubclass).text - } - }] + ] }; + Listview.templates.subitempicker = { - sort: [1], - nItemsPerPage: -1, - hideBands: 2, - hideNav: 1 | 2, - hideHeader: 1, - searchable: 1, - searchDelay: 100, - poundable: 0, - filtrable: 0, - clip: { - w: 780, - h: 486 - }, - onBeforeCreate: function () { - this.applySort(); - if (!Browser.ie67) { - this.template.columns[0].span = 2 - } - }, - onSearchSubmit: function (a) { - if (this.nRowsVisible != 2 || !a.id) { - return - } (Summary.addItemSubitem.bind(a._summary, a.id))() - }, - columns: [{ - id: "subitem", - type: "text", - align: "left", - value: "name", - compute: function (j, c, e) { - if (j.none) { - return - } - var b = "?item=" + j.item, - k = g_items[j.item]; - if (!Browser.ie67) { - var d = ce("td"); - d.style.width = "1px"; - d.style.padding = "0"; - d.style.borderRight = "none"; - var f = Icon.create(k.icon, 0, null, b), - g = Icon.getLink(f); - ae(d, f); - ae(e, d); - c.style.borderLeft = "none"; - g.onclick = rf; - g.rel = "rand=" + j.id - } - var h = ce("a"); - if (j.quality != -1) { - h.className = "q" + k.quality - } - h.style.fontFamily = "Verdana, sans-serif"; - h.onclick = rf; - h.href = b; - h.rel = "rand=" + j.id; - ae(h, ct(k["name_" + g_locale.name] + " " + j.name)); - nw(c); - ae(c, h); - e.onclick = Summary.addItemSubitem.bind(j._summary, j.id) - } - }, - { - id: "enchantment", - type: "text", - align: "left", - value: "enchantment", - compute: function (a, e, b) { - if (a.none) { - return - } - var c = ce("div"); - c.className = "small crop"; - e.title = a.enchantment; - ae(c, ct(a.enchantment)); - ae(e, c) - } - }] + sort: [1], + nItemsPerPage: -1, + hideBands: 2, + hideNav: 1 | 2, + hideHeader: 1, + searchable: 1, + searchDelay: 100, + poundable: 0, + filtrable: 0, + clip: { + w: 780, + h: 486 + }, + + onBeforeCreate: function() { + this.applySort(); + }, + + onSearchSubmit: function(subitem) { + if (this.nRowsVisible != 2 || !subitem.id) { // None + return; + } + + (Summary.addItemSubitem.bind(subitem._summary, subitem.id))(); + }, + + columns: [ + { + id: 'subitem', + type: 'text', + align: 'left', + value: 'name', + compute: function(subitem, td, tr) { + if (subitem.none) { + return; + } + + var + url = '?item=' + subitem.item, + item = g_items[subitem.item]; + + var i = ce('td'); + i.style.width = '1px'; + i.style.padding = '0'; + i.style.borderRight = 'none'; + + var + icon = Icon.create(item.icon, 0, null, url), + link = Icon.getLink(icon); + + ae(i, icon); + ae(tr, i); + td.style.borderLeft = 'none'; + + link.onclick = rf; + link.rel = 'rand=' + subitem.id; + + var a = ce('a'); + + if (subitem.quality != -1) { + a.className = 'q' + item.quality; + } + + a.style.fontFamily = 'Verdana, sans-serif'; + a.href = url; + a.rel = 'rand=' + subitem.id; + + ae(a, ct(item['name_' + g_locale.name] + ' ' + subitem.name)); + + nw(td); + ae(td, a); + + tr.onclick = function(e) { + e = $E(e); + if (e._button != 2 || e._target != a) { + e.preventDefault(); + (Summary.addItemSubitem.bind(subitem._summary, subitem.id))(); + } + }; + } + }, + { + id: 'enchantment', + type: 'text', + align: 'left', + value: 'enchantment', + compute: function(subitem, td, tr) { + if (subitem.none) { + return; + } + + var d = ce('div'); + d.className = 'small crop'; + td.title = subitem.enchantment; + ae(d, ct(subitem.enchantment)); + ae(td, d); + }, + sortFunc: function(a, b, col) { + if (a.none) { + return -1; + } + if (b.none) { + return 1; + } + + return ( + -strcmp(a.score, b.score) || + strcmp(a.name, b.name) + ); + } + }, + { + id: 'score', + align: 'center', + compute: function(subitem, td, tr) { + if (subitem.none) { + return; + } + + if (subitem.score != null) { + var + n = parseFloat(subitem.score), + s = ce('div'); + + s.className = 'small q' + (n ? (n > 0 ? 2 : 10) : 0); + st(s, (n ? (n > 0 ? '+' : '-') + subitem.score : 0)); + ae(td, s); + } + } + } + ] }; + Listview.templates.enchantpicker = { - sort: [1], - nItemsPerPage: -1, - hideBands: 2, - hideNav: 1 | 2, - hideHeader: 1, - searchable: 1, - searchDelay: 100, - poundable: 0, - filtrable: 0, - clip: { - w: 780, - h: 486 - }, - onBeforeCreate: function () { - this.applySort(); - if (!Browser.ie67) { - this.template.columns[0].span = 2 - } - }, - onSearchSubmit: function (a, b) { - if (this.nRowsVisible != 2 || !a.id) { - return - } (Summary.addItemEnchant.bind(a._summary, a.id))() - }, - columns: [{ - id: "enchant", - type: "text", - align: "left", - value: "name", - compute: function (h, j, g) { - if (h.none) { - return - } - var c = (h.source > 0 ? "?spell=": "?item=") + Math.abs(h.source); - if (!Browser.ie67) { - var d = ce("td"); - d.style.width = "1px"; - d.style.padding = "0"; - d.style.borderRight = "none"; - var e = Icon.create(h.icon, 0, null, c), - f = Icon.getLink(e); - ae(d, e); - ae(g, d); - j.style.borderLeft = "none"; - f.onclick = rf - } - var b = ce("a"); - if (h.quality != -1) { - b.className = "q" + h.quality - } - b.style.fontFamily = "Verdana, sans-serif"; - b.onclick = rf; - b.href = c; - ae(b, ct(h.name)); - nw(j); - ae(j, b); - g.onclick = Summary.addItemEnchant.bind(h._summary, h.id) - }, - sortFunc: function (d, c, e) { - if (d.none) { - return -1 - } - if (c.none) { - return 1 - } - return ( -strcmp(d.quality, c.quality) || strcmp(d.type, c.type) || strcmp(d.name, c.name)) - } - }, - { - id: "enchantment", - type: "text", - align: "left", - value: "enchantment", - compute: function (b, e, a) { - if (b.none) { - return - } - var c = ce("div"); - c.className = "small crop"; - e.title = b.enchantment; - ae(c, ct(b.enchantment)); - ae(e, c) - } - }, - { - id: "skill", - type: "text", - compute: function (b, c, a) { - if (b.none) { - ee(a); - a.onclick = Summary.addItemEnchant.bind(b._summary, 0); - c.colSpan = (Browser.ie67 ? 3 : 4); - c.style.fontWeight = "bold"; - c.style.textAlign = "center"; - return LANG.dash + LANG.pr_noneenchant + LANG.dash - } - c.className = "small q0"; - nw(c); - if (b.skill > 0) { - return g_spell_skills[b.skill] - } else { - return LANG.types[3][0] - } - }, - getVisibleText: function (a) { - if (a.none) { - return - } - if (a.skill > 0) { - return g_spell_skills[a.skill] - } else { - return LANG.types[3][0] - } - } - }] + sort: [1], + nItemsPerPage: -1, + hideBands: 2, + hideNav: 1 | 2, + hideHeader: 1, + searchable: 1, + searchDelay: 100, + poundable: 0, + filtrable: 0, + clip: { + w: 780, + h: 486 + }, + + onBeforeCreate: function() { + this.applySort(); + }, + + onSearchSubmit: function(enchant, n) { + if (this.nRowsVisible != 2 || !enchant.id) { // None + return; + } + + (Summary.addItemEnchant.bind(enchant._summary, enchant.id))(); + }, + + columns: [ + { + id: 'enchant', + type: 'text', + align: 'left', + value: 'name', + span: 2, + compute: function(enchant, td, tr) { + if (enchant.none) { + return; + } + + var url = (enchant.source > 0 ? '?spell=' : '?item=') + Math.abs(enchant.source); + + var i = ce('td'); + i.style.width = '1px'; + i.style.padding = '0'; + i.style.borderRight = 'none'; + + var + icon = Icon.create(enchant.icon, 0, null, url), + link = Icon.getLink(icon); + + ae(i, icon); + ae(tr, i); + td.style.borderLeft = 'none'; + + link.onclick = rf; + + var a = ce('a'); + + if (enchant.quality != -1) { + a.className = 'q' + enchant.quality; + } + + a.style.fontFamily = 'Verdana, sans-serif'; + a.href = url; + + ae(a, ct(enchant.name)); + + nw(td); + ae(td, a); + + tr.onclick = function(e) { + e = $E(e); + if (e._button != 2 || e._target != a) { + e.preventDefault(); + (Summary.addItemEnchant.bind(enchant._summary, enchant.id))(); + } + }; + }, + sortFunc: function(a, b, col) { + if (a.none) { + return -1; + } + if (b.none) { + return 1; + } + + return ( + -strcmp(a.quality, b.quality) || + strcmp(a.type, b.type) || + strcmp(a.name, b.name) + ); + } + }, + { + id: 'enchantment', + type: 'text', + align: 'left', + value: 'enchantment', + compute: function(enchant, td, tr) { + if (enchant.none) { + return; + } + + var d = ce('div'); + d.className = 'small crop'; + td.title = enchant.enchantment; + ae(d, ct(enchant.enchantment)); + ae(td, d); + }, + sortFunc: function(a, b, col) { + if (a.none) { + return -1; + } + if (b.none) { + return 1; + } + + return ( + -strcmp(a.score, b.score) || + strcmp(a.name, b.name) + ); + } + }, + { + id: 'skill', + type: 'text', + compute: function(enchant, td, tr) { + if (enchant.none) { + return; + } + + td.className = 'small q0'; + nw(td); + + if (enchant.skill > 0) { + return g_spell_skills[enchant.skill]; + } + else { + return LANG.types[3][0]; + } + }, + getVisibleText: function(enchant) { + if (enchant.none) { + return; + } + + if (enchant.skill > 0) { + return g_spell_skills[enchant.skill]; + } + else { + return LANG.types[3][0]; + } + } + }, + { + id: 'score', + align: 'center', + compute: function(enchant, td, tr) { + if (enchant.none) { + ee(tr); + + tr.onclick = Summary.addItemEnchant.bind(enchant._summary, 0); + td.colSpan = 5; + td.style.fontWeight = 'bold'; + td.style.textAlign = 'center'; + return LANG.dash + LANG.pr_noneenchant + LANG.dash; + } + + if (enchant.score != null) { + var + n = parseFloat(enchant.score), + s = ce('div'); + + s.className = 'small q' + (n ? (n > 0 ? 2 : 10) : 0); + st(s, (n ? (n > 0 ? '+' : '-') + enchant.score : 0)); + ae(td, s); + } + } + } + ] }; + Listview.templates.gempicker = { - sort: [1], - nItemsPerPage: -1, - hideBands: 2, - hideNav: 1 | 2, - hideHeader: 1, - searchable: 1, - searchDelay: 100, - poundable: 0, - filtrable: 0, - clip: { - w: 780, - h: 486 - }, - onBeforeCreate: function () { - this.applySort(); - if (!Browser.ie67) { - this.template.columns[0].span = 2 - } - }, - onSearchSubmit: function (a) { - if (this.nRowsVisible != 2 || !a.id) { - return - } (Summary.addItemGem.bind(a._summary, a.id))() - }, - sexyColors: { - 1 : "#9D9D9D", - 2 : "#e60c0b", - 4 : "#ffff35", - 6 : "#f48905", - 8 : "#295df1", - 10 : "#b957fc", - 12 : "#22c516", - 14 : "#FFFFFF" - }, - columns: [{ - id: "gem", - type: "text", - align: "left", - value: "name", - compute: function (h, g, f) { - if (h.none) { - return - } - if (!Browser.ie67) { - var c = ce("td"); - c.style.width = "1px"; - c.style.padding = "0"; - c.style.borderRight = "none"; - var d = Icon.create(h.icon, 0, null, "?item=" + h.id), - e = Icon.getLink(d); - ae(c, d); - ae(f, c); - g.style.borderLeft = "none"; - e.onclick = rf - } - var b = ce("a"); - b.className = "q" + h.quality; - b.style.fontFamily = "Verdana, sans-serif"; - b.onclick = rf; - b.href = "?item=" + h.id; - ae(b, ct(h.name)); - nw(g); - ae(g, b); - f.onclick = Summary.addItemGem.bind(h._summary, h.id) - }, - sortFunc: function (d, c, e) { - if (d.none) { - return -1 - } - if (c.none) { - return 1 - } - return ( -strcmp(d.gearscore, c.gearscore) || -strcmp(d.quality, c.quality) || strcmp(d.colors, c.colors) || strcmp(d.icon, c.icon) || strcmp(d.name, c.name)) - } - }, - { - id: "enchantment", - type: "text", - align: "left", - value: "enchantment", - compute: function (e, c, a) { - if (e.none) { - return - } - var b = ce("div"); - b.className = "small crop"; - c.title = e.enchantment; - ae(b, ct(e.enchantment)); - ae(c, b) - } - }, - { - id: "colors", - compute: function (c, b, a) { - if (c.none) { - ee(a); - a.onclick = Summary.addItemGem.bind(c._summary, 0); - b.colSpan = (Browser.ie67 ? 3 : 4); - b.style.fontWeight = "bold"; - b.style.textAlign = "center"; - return LANG.dash + LANG.pr_nonegem + LANG.dash - } - b.className = "small"; - nw(b); - b.style.color = this.template.sexyColors[c.colors]; - return g_gem_colors[c.colors] - }, - getVisibleText: function (a) { - if (a.none) { - return - } - return g_gem_colors[a.colors] - } - }] -}; \ No newline at end of file + sort: [1], + nItemsPerPage: -1, + hideBands: 2, + hideNav: 1 | 2, + hideHeader: 1, + searchable: 1, + searchDelay: 100, + poundable: 0, + filtrable: 0, + clip: { + w: 780, + h: 486 + }, + + onBeforeCreate: function() { + this.applySort(); + }, + + onSearchSubmit: function(gem) { + if (this.nRowsVisible != 2 || !gem.id) { // None + return; + } + + (Summary.addItemGem.bind(gem._summary, gem.id))(); + }, + + columns: [ + { + id: 'gem', + type: 'text', + align: 'left', + value: 'name', + span: 2, + compute: function(gem, td, tr) { + if (gem.none) { + return; + } + + var i = ce('td'); + i.style.width = '1px'; + i.style.padding = '0'; + i.style.borderRight = 'none'; + + var + icon = Icon.create(gem.icon, 0, null, '?item=' + gem.id), + link = Icon.getLink(icon); + + ae(i, icon); + ae(tr, i); + td.style.borderLeft = 'none'; + + link.onclick = rf; + + var a = ce('a'); + a.className = 'q' + gem.quality; + a.style.fontFamily = 'Verdana, sans-serif'; + a.href = '?item=' + gem.id; + + ae(a, ct(gem.name)); + + nw(td); + ae(td, a); + + tr.onclick = function(e) { + e = $E(e); + if (e._button != 2 || e._target != a) { + e.preventDefault(); + (Summary.addItemGem.bind(gem._summary, gem.id))(); + } + }; + }, + sortFunc: function(a, b, col) { + if (a.none) { + return -1; + } + if (b.none) { + return 1; + } + + return ( + -strcmp(a.quality, b.quality) || + strcmp(a.colors, b.colors) || + strcmp(a.icon, b.icon) || + strcmp(a.name, b.name) + ); + } + }, + { + id: 'enchantment', + type: 'text', + align: 'left', + value: 'enchantment', + compute: function(gem, td, tr) { + if (gem.none) { + return; + } + + var d = ce('div'); + d.className = 'small crop'; + td.title = gem.enchantment; + ae(d, ct(gem.enchantment)); + ae(td, d); + }, + sortFunc: function(a, b, col) { + if (a.none) { + return -1; + } + if (b.none) { + return 1; + } + + return ( + -strcmp(a.score, b.score) || + strcmp(a.name, b.name) + ); + } + }, + { + id: 'colors', + compute: function(gem, td, tr) { + if (gem.none) { + return; + } + + td.className = 'small gem' + gem.colors; + nw(td); + + return g_gem_colors[gem.colors]; + }, + getVisibleText: function(gem) { + if (gem.none) { + return; + } + + return g_gem_colors[gem.colors]; + } + }, + { + id: 'score', + align: 'center', + compute: function(gem, td, tr) { + if (gem.none) { + ee(tr); + + tr.onclick = Summary.addItemGem.bind(gem._summary, 0); + td.colSpan = 5; + td.style.fontWeight = 'bold'; + td.style.textAlign = 'center'; + + return LANG.dash + LANG.pr_nonegem + LANG.dash; + } + + if (gem.score != null) { + var + n = parseFloat(gem.score), + s = ce('div'); + + s.className = 'small q' + (n ? (n > 0 ? 2 : 10) : 0); + st(s, (n ? (n > 0 ? '+' : '-') + gem.score : 0)); + ae(td, s); + } + } + } + ] +}; + +/* sarjuuk: bandaid .. belongs to profile.js */ +function pr_getScaleFilter(scale, noFilter) { + var temp = []; + + if (scale) { + for (var i = 0, len = fi_filters.items.length; i < len; ++i) { + var f = fi_filters.items[i]; + + if (LANG.traits[f.name] && scale[f.name]) { + temp.push([f.id, scale[f.name]]); + } + } + } + + temp.sort(function(a, b) { + return -strcmp(a[1], b[1]); + }); + + var wt = [], wtv = []; + for (var i = 0, len = temp.length; i < len; ++i) { + wt.push(temp[i][0]); + wtv.push(temp[i][1]); + } + + if (wt.length && wtv.length) { + return (noFilter ? '&' : ';gm=3;rf=1;') + 'wt=' + wt.join(':') + (noFilter ? '&' : ';') + 'wtv=' + wtv.join(':'); + } + + return ''; +} + diff --git a/template/js/TalentCalc.js b/template/js/TalentCalc.js index 535a0331..133447c9 100644 --- a/template/js/TalentCalc.js +++ b/template/js/TalentCalc.js @@ -1,43 +1,41 @@ var $WowheadTalentCalculator; function TalentCalc() { - var - MODE_DEFAULT = 0, - MODE_PET = 1, + var + MODE_DEFAULT = 0, + MODE_PET = 1, - MIN_LEVEL = 10, - MAX_LEVEL = 80, + MIN_LEVEL = 10, + MAX_LEVEL = 80, - _versionBuild = 85, - _self = this, + _versionBuild = 85, + _self = this, _opt, - _data = {}, - _glyphLookup = {}, + _data = {}, + _glyphLookup = {}, + _talentLookup = {}, _build, _firstBuild, _firstGlyphs, _glyphs, - _currentClass = -1, - _oldClass = -1, - _nClassChanges = 0, + _currentClass = -1, + _oldClass = -1, + _nClassChanges = 0, _currentGlyphSlot, - _filteredGlyphs = false, - _locked = false, + _filteredGlyphs = false, + _locked = false, _mode, _nTrees, _nTiers, _nGlyphs, _glyphSlots, - _glyphOrder = [1,2], - _glyphLevels = { - 1: [], // Major - 2: [] // Minor - }, + _glyphOrder = [1, 2], + _glyphLevels = { 1: [], 2: [] }, // Major, Minor _pointsPerTier, _basePoints, - _bonusPoints = 0, + _bonusPoints = 0, _pointsFromBonus, - _maxLevel = MAX_LEVEL, + _maxLevel = MAX_LEVEL, _pointsToSpend, _referenceArray, @@ -49,8 +47,8 @@ function TalentCalc() { _lnkExport, _lnkRestore, _glyphDiv, - _glyphIcons = {}, - _glyphLinks = {}, + _glyphIcons = {}, + _glyphLinks = {}, _divWrapper, _divUpper, _lblClass, @@ -66,12 +64,12 @@ function TalentCalc() { swfModel, - _encoding = '0zMcmVokRsaqbdrfwihuGINALpTjnyxtgevElBCDFHJKOPQSUWXYZ123456789', - _blizzEncoding = 'aZbYcXdWeVfUgThSiRjQkPlOmNnMoLpKqJrIsHtGuFvEwDxCyBzA0123456789_=+-.', - _newTree = 'Z', + _encoding = '0zMcmVokRsaqbdrfwihuGINALpTjnyxtgevElBCDFHJKOPQSUWXYZ123456789', + _blizzEncoding = 'aZbYcXdWeVfUgThSiRjQkPlOmNnMoLpKqJrIsHtGuFvEwDxCyBzA0123456789_=+-.', + _newTree = 'Z', _onChangeCallback, - _info = {}; + _info = {}; // ************************************************************* // ************************************************************* @@ -83,91 +81,91 @@ function TalentCalc() { return _data[_currentClass]; }; - this.addGlyph = function (itemId) { - if (itemId) { - _addGlyph(_currentGlyphSlot, itemId); - } + this.addGlyph = function (itemId) { + if (itemId) { + _addGlyph(_currentGlyphSlot, itemId); + } else { - _removeGlyph(_currentGlyphSlot); - } + _removeGlyph(_currentGlyphSlot); + } - Lightbox.hide() - }; + Lightbox.hide() + }; - this.getBlizzBuild = function () { - if (_currentClass == -1) { - return; - } + this.getBlizzBuild = function () { + if (_currentClass == -1) { + return; + } - var + var c = _data[_currentClass], blizz = ''; - for (var tree = 0; tree < _nTrees; ++tree) { - for (var i = 0; i < c[tree].t.length; ++i) { - blizz += c[tree].t[i].k; - } - } + for (var tree = 0; tree < _nTrees; ++tree) { + for (var i = 0; i < c[tree].t.length; ++i) { + blizz += c[tree].t[i].k; + } + } - blizz = rtrim(blizz, '0'); + blizz = rtrim(blizz, '0'); - return blizz; - }; + return blizz; + }; - this.getBlizzGlyphs = function () { - if (_currentClass == -1) { - return; - } + this.getBlizzGlyphs = function () { + if (_currentClass == -1) { + return; + } - var + var c = _data[_currentClass], blizz = ''; - for (var slot = 0; slot < _nGlyphs; ++slot) { - if (slot > 0) { - blizz += ':'; - } + for (var slot = 0; slot < _nGlyphs; ++slot) { + if (slot > 0) { + blizz += ':'; + } - if (c.glyphs[slot]) { - blizz += c.glyphs[slot]; - } + if (c.glyphs[slot]) { + blizz += c.glyphs[slot]; + } else { - blizz += '0'; - } - } + blizz += '0'; + } + } - return blizz; - }; + return blizz; + }; - this.getGlyphs = function () { - var res = []; + this.getGlyphs = function () { + var res = []; - if (_currentClass != -1) { - var c = _data[_currentClass]; + if (_currentClass != -1) { + var c = _data[_currentClass]; - if (c) { - for (var slot = 0; slot < _nGlyphs; ++slot) { - if (c.glyphs[slot]) { - res.push(g_glyphs[c.glyphs[slot]]); - } - } - } - } + if (c) { + for (var slot = 0; slot < _nGlyphs; ++slot) { + if (c.glyphs[slot]) { + res.push(g_glyphs[c.glyphs[slot]]); + } + } + } + } - return res; - }; + return res; + }; - this.getSpentFromBlizzBuild = function (build, classId) { - var + this.getSpentFromBlizzBuild = function (build, classId) { + var c = _data[classId], spent = []; - for (var i = 0; i < _nTrees; ++i) { + for (var i = 0; i < _nTrees; ++i) { spent.push(0); - } + } - if (c) { - var + if (c) { + var tree = 0, talent = 0; @@ -177,45 +175,45 @@ function TalentCalc() { } for (var i = 0; i < build.length; ++i) { - var n = Math.min(parseInt(build.charAt(i)), c[tree].t[talent].m); - if (isNaN(n)) { - continue; - } + var n = Math.min(parseInt(build.charAt(i)), c[tree].t[talent].m); + if (isNaN(n)) { + continue; + } - for (var k = 0; k < n; ++k) { + for (var k = 0; k < n; ++k) { ++spent[tree]; - } + } - if (++talent > c[tree].t.length - 1) { - talent = 0; - if (++tree > _nTrees - 1) { - break; - } - } - } - } + if (++talent > c[tree].t.length - 1) { + talent = 0; + if (++tree > _nTrees - 1) { + break; + } + } + } + } - return spent; - }; + return spent; + }; - this.getTalents = function () { - var res = []; + this.getTalents = function () { + var res = []; - if (_currentClass != -1) { - var c = _data[_currentClass]; - if (c) { - for (var tree = 0; tree < _nTrees; ++tree) { - for (i = 0; i < c[tree].t.length; ++i) { - if (c[tree].t[i].k) { - res.push(c[tree].t[i]); - } - } - } - } - } + if (_currentClass != -1) { + var c = _data[_currentClass]; + if (c) { + for (var tree = 0; tree < _nTrees; ++tree) { + for (i = 0; i < c[tree].t.length; ++i) { + if (c[tree].t[i].k) { + res.push(c[tree].t[i]); + } + } + } + } + } - return res; - }; + return res; + }; this.getTalentRanks = function(talentId) { if (_currentClass == -1) { @@ -229,70 +227,70 @@ function TalentCalc() { return 0; }; - this.getWhBuild = function () { - if (_currentClass == -1) { - return; - } + this.getWhBuild = function () { + if (_currentClass == -1) { + return; + } - var + var c = _data[_currentClass], wh = '', blizz, i; - for (var tree = 0; tree < _nTrees; ++tree) { - blizz = ''; - for (i = 0; i < c[tree].t.length; ++i) { - blizz += c[tree].t[i].k; - } + for (var tree = 0; tree < _nTrees; ++tree) { + blizz = ''; + for (i = 0; i < c[tree].t.length; ++i) { + blizz += c[tree].t[i].k; + } - blizz = rtrim(blizz, '0'); + blizz = rtrim(blizz, '0'); - wh += _convertBlizzToWh(blizz); + wh += _convertBlizzToWh(blizz); - i = blizz.length; - if (i % 2 == 1) { + i = blizz.length; + if (i % 2 == 1) { ++i; - } + } - if (i < c[tree].t.length) { - wh += _newTree; - } - } + if (i < c[tree].t.length) { + wh += _newTree; + } + } - var res; + var res; - if (_mode == MODE_PET) { - res = _encoding.charAt(Math.floor(_currentClass / 10)) + _encoding.charAt((2 * (_currentClass % 10)) + (_bonusPoints ? 1 : 0)); - } + if (_mode == MODE_PET) { + res = _encoding.charAt(Math.floor(_currentClass / 10)) + _encoding.charAt((2 * (_currentClass % 10)) + (_bonusPoints ? 1 : 0)); + } else { - res = _encoding.charAt(_getOldIdFromClassId(_currentClass) * 3); - } + res = _encoding.charAt(_getOldIdFromClassId(_currentClass) * 3); + } - res += rtrim(wh, _newTree); + res += rtrim(wh, _newTree); - return res; - }; + return res; + }; - this.getWhGlyphs = function () { - if (_currentClass == -1) { - return; - } + this.getWhGlyphs = function () { + if (_currentClass == -1) { + return; + } - var + var c = _data[_currentClass], glyphs = {}; - for (var slot = 0; slot < _nGlyphs; ++slot) { + for (var slot = 0; slot < _nGlyphs; ++slot) { var glyphType = _getGlyphTypeFromSlot(slot); if (glyphs[glyphType] == null) { glyphs[glyphType] = ''; } - if (c.glyphs[slot]) { - glyphs[glyphType] += _encoding.charAt(g_glyphs[c.glyphs[slot]].index); - } - } + if (c.glyphs[slot]) { + glyphs[glyphType] += _encoding.charAt(g_glyphs[c.glyphs[slot]].index); + } + } var res = '', encodeLen = 0; for (var i = 0, len = _glyphOrder.length; i < len; ++i) { @@ -311,77 +309,77 @@ function TalentCalc() { res = rtrim(res, _newTree); return res; - }; + }; - this.initialize = function (container, opt) { - if (_container) { - return; - } + this.initialize = function (container, opt) { + if (_container) { + return; + } - container = $(container); - if (!container) { - return; - } + container = $(container); + if (!container) { + return; + } - _container = container; - _container.className = "talentcalc"; - if (opt == null) { - opt = {}; - } + _container = container; + _container.className = "talentcalc"; + if (opt == null) { + opt = {}; + } - _opt = opt; + _opt = opt; - if (_opt.onChange) { - _onChangeCallback = _opt.onChange; - } + if (_opt.onChange) { + _onChangeCallback = _opt.onChange; + } - if (_opt.mode == MODE_PET) { - _mode = MODE_PET; - _nTrees = 1; - _nTiers = 6; - _pointsPerTier = 3; - _basePoints = 16; + if (_opt.mode == MODE_PET) { + _mode = MODE_PET; + _nTrees = 1; + _nTiers = 6; + _pointsPerTier = 3; + _basePoints = 16; _pointsFromBonus = 4 - _referenceArray = g_pet_families; + _referenceArray = g_pet_families; - _container.className += " talentcalc-pet"; + _container.className += " talentcalc-pet"; _setGlyphSlots(0); - } + } else { - _mode = MODE_DEFAULT; - _nTrees = 3; - _nTiers = 11; - _glyphLevels = { - 1 : [15, 30, 80], // Major - 2 : [15, 50, 70] // Minor - }; - _pointsPerTier = 5; - _basePoints = 71; + _mode = MODE_DEFAULT; + _nTrees = 3; + _nTiers = 11; + _glyphLevels = { + 1 : [15, 30, 80], // Major + 2 : [15, 50, 70] // Minor + }; + _pointsPerTier = 5; + _basePoints = 71; _pointsFromBonus = 0; - _referenceArray = g_chr_classes; + _referenceArray = g_chr_classes; - _container.className += " talentcalc-default"; + _container.className += " talentcalc-default"; - $WowheadTalentCalculator = _self; + $WowheadTalentCalculator = _self; _setGlyphSlots(MAX_LEVEL); - _initGlyphData(); - } + _initGlyphData(); + } - _pointsToSpend = _basePoints + _bonusPoints; + _pointsToSpend = _basePoints + _bonusPoints; _divWrapper = ce('div'); _divWrapper.className = 'talentcalc-wrapper'; ae(_container, _divWrapper); - _createSidebar(); - _createUpper(); - _createMain(); - _createModel(); - _createLower(); + _createSidebar(); + _createUpper(); + _createMain(); + _createModel(); + _createLower(); /* - _createSidebar(); + _createSidebar(); _createUpper(); _createTreeNames(); _createMasteries(); @@ -390,9 +388,9 @@ function TalentCalc() { _createLower(); */ - if (_opt.whBuild) { - _setWhBuild(_opt.whBuild); - } + if (_opt.whBuild) { + _setWhBuild(_opt.whBuild); + } else if (_opt.classId > 0 && _referenceArray[_opt.classId]) { if (_opt.blizzBuild) { _setBlizzBuild(_opt.classId, _opt.blizzBuild); @@ -400,71 +398,71 @@ function TalentCalc() { else { _setClass(_opt.classId); } - } + } - if (_opt.whGlyphs) { - _setWhGlyphs(_opt.whGlyphs); - } + if (_opt.whGlyphs) { + _setWhGlyphs(_opt.whGlyphs); + } else if (_opt.blizzGlyphs) { _setBlizzGlyphs(_opt.blizzGlyphs); - } - }; + } + }; - this.promptBlizzBuild = function () { - if (_mode == MODE_PET) { - return; - } + this.promptBlizzBuild = function () { + if (_mode == MODE_PET) { + return; + } - var + var classId, url = prompt(LANG.prompt_importblizz, ""); - if (!url) { - return; - } + if (!url) { + return; + } if (url.match(/talent-calculator#([\w=+-.])c[0-9]{2}(![\w=+-.]*![\w=+-.]*![\w=+-.]*!?[\w=+-.]*)/)) { // Bnet Url classId = _blizzEncoding.indexOf(RegExp.$1); - _setBlizzBuild(classId, RegExp.$2, true); + _setBlizzBuild(classId, RegExp.$2, true); - return; - } + return; + } else if (url.match(/\?cid=([0-9]+)&tal=([0-9]+)/)) { // old style - classId = parseInt(RegExp.$1); - _setBlizzBuild(classId, RegExp.$2); + classId = parseInt(RegExp.$1); + _setBlizzBuild(classId, RegExp.$2); return; } else { - var idx = url.indexOf("?tal="); - if (idx != -1) { - for (var i in g_file_classes) { - if (url.indexOf(g_file_classes[i]) != -1) { - classId = parseInt(i); + var idx = url.indexOf("?tal="); + if (idx != -1) { + for (var i in g_file_classes) { + if (url.indexOf(g_file_classes[i]) != -1) { + classId = parseInt(i); - break; - } - } - if (classId) { - _setBlizzBuild(classId, url.substring(idx + 5)); + break; + } + } + if (classId) { + _setBlizzBuild(classId, url.substring(idx + 5)); - return; - } - } - } + return; + } + } + } - alert(LANG.alert_invalidurl); - }; + alert(LANG.alert_invalidurl); + }; - this.promptWhBuild = function () { - var url = prompt(LANG.prompt_importwh, ''); + this.promptWhBuild = function () { + var url = prompt(LANG.prompt_importwh, ''); - if (!url) { - return; - } + if (!url) { + return; + } - var pos = url.indexOf('='); - if(pos != -1) { + var pos = url.indexOf('='); + if (pos != -1) { var hash = url.substr(pos); var @@ -475,114 +473,114 @@ function TalentCalc() { _setWhBuild(build); _setWhGlyphs(glyphs); } - }; - - this.registerClass = function (classId, data) { - _registerClass(classId, data) - }; - - this.reset = function (tree) { - if (_currentClass == -1) { - return; - } - - if (tree > _nTrees - 1) { - return; - } - - _locked = false; - _resetTree(tree, _currentClass, true) - }; - - this.resetAll = function () { - if (!_data[_currentClass]) { - return; - } - - _locked = false; - _resetAll(_currentClass); - _onChange(); - }; - - this.resetBuild = function () { - if (!_data[_currentClass]) { - return; - } - - _locked = false; - - _resetBuild(_currentClass); - _refreshAll(_currentClass); - _onChange(); - }; - - this.resetGlyphs = function () { - _resetGlyphs(); - _onChange(); - }; - - this.restore = function () { - _restore(); - }; - - this.setBlizzBuild = function (classId, build) { - _setBlizzBuild(classId, build); - }; - - this.setBlizzGlyphs = function (glyphs) { - if (_currentClass == -1) { - return; - } - - _setBlizzGlyphs(glyphs); - }; - - this.setBonusPoints = function () { - if (_mode != MODE_PET) { - return; - } - - _setPoints(-1, _pointsFromBonus); - }; - - this.setClass = function (classId) { - return _setClass(classId); - }; - - this.setLevelCap = function (lvl) { - _setLevelCap(lvl); }; - this.setLock = function (locked) { - if (_currentClass == -1) { - return; - } + this.registerClass = function (classId, data) { + _registerClass(classId, data) + }; - _setLock(locked); - }; + this.reset = function (tree) { + if (_currentClass == -1) { + return; + } - this.setWhBuild = function (build) { - return _setWhBuild(build); - }; + if (tree > _nTrees - 1) { + return; + } - this.setWhGlyphs = function (glyphs) { - if (_currentClass == -1) { - return; - } + _locked = false; + _resetTree(tree, _currentClass, true) + }; - _setWhGlyphs(glyphs); - }; + this.resetAll = function () { + if (!_data[_currentClass]) { + return; + } + + _locked = false; + _resetAll(_currentClass); + _onChange(); + }; + + this.resetBuild = function () { + if (!_data[_currentClass]) { + return; + } + + _locked = false; + + _resetBuild(_currentClass); + _refreshAll(_currentClass); + _onChange(); + }; + + this.resetGlyphs = function () { + _resetGlyphs(); + _onChange(); + }; + + this.restore = function () { + _restore(); + }; + + this.setBlizzBuild = function (classId, build) { + _setBlizzBuild(classId, build); + }; + + this.setBlizzGlyphs = function (glyphs) { + if (_currentClass == -1) { + return; + } + + _setBlizzGlyphs(glyphs); + }; + + this.setBonusPoints = function () { + if (_mode != MODE_PET) { + return; + } + + _setPoints(-1, _pointsFromBonus); + }; + + this.setClass = function (classId) { + return _setClass(classId); + }; + + this.setLevelCap = function (lvl) { + _setLevelCap(lvl); + }; + + this.setLock = function (locked) { + if (_currentClass == -1) { + return; + } + + _setLock(locked); + }; + + this.setWhBuild = function (build) { + return _setWhBuild(build); + }; + + this.setWhGlyphs = function (glyphs) { + if (_currentClass == -1) { + return; + } + + _setWhGlyphs(glyphs); + }; this.setPetModel = function(npcId) { _updateModel(_currentClass, npcId); // NYI! } - this.showSummary = function (mode) { - if (_currentClass == -1) { - return; - } + this.showSummary = function (mode) { + if (_currentClass == -1) { + return; + } - var + var c = _data[_currentClass], bg = window.open('?talent=summary', '', 'toolbar=no,menubar=yes,status=yes,scrollbars=yes,resizable=yes'), i, @@ -590,112 +588,112 @@ function TalentCalc() { k, buffer = '' + document.title + ''; - bg.document.open(); + bg.document.open(); - if (mode) { // Printable version - buffer += '

'; + if (mode) { // Printable version + buffer += '

'; - if (_mode == MODE_PET) { - buffer += sprintf(LANG.tc_printh, _getRequiredLevel(), g_pet_families[c.n]); - } + if (_mode == MODE_PET) { + buffer += sprintf(LANG.tc_printh, _getRequiredLevel(), g_pet_families[c.n]); + } else { - buffer += sprintf(LANG.tc_printh, _getRequiredLevel(), g_chr_classes[c.n]) + ' (' + c[0].k + '/' + c[1].k + '/' + c[2].k + ')'; - } + buffer += sprintf(LANG.tc_printh, _getRequiredLevel(), g_chr_classes[c.n]) + ' (' + c[0].k + '/' + c[1].k + '/' + c[2].k + ')'; + } - buffer += '

'; - buffer += '

'; + buffer += ''; + buffer += '

'; - for (i = 0; i < _nTrees; ++i) { - buffer += '

' + c[i].n + ' (' + c[i].k + ' ' + LANG[c[i].k == 1 ? 'tc_point': 'tc_points'] + ')

'; - buffer += '
'; - k = 0; + for (i = 0; i < _nTrees; ++i) { + buffer += '

' + c[i].n + ' (' + c[i].k + ' ' + LANG[c[i].k == 1 ? 'tc_point': 'tc_points'] + ')

'; + buffer += '
'; + k = 0; - for (j = 0; j < c[i].t.length; ++j) { - if (c[i].t[j].k) { - if (k) { - buffer += '

'; - } + for (j = 0; j < c[i].t.length; ++j) { + if (c[i].t[j].k) { + if (k) { + buffer += '

'; + } - buffer += '' + c[i].t[j].n + '' + LANG.hyphen + sprintf(LANG.tc_rank, c[i].t[j].k, c[i].t[j].m) + '
'; - buffer += _getTalentDescription(c[i].t[j]); + buffer += '' + c[i].t[j].n + '' + LANG.hyphen + sprintf(LANG.tc_rank, c[i].t[j].k, c[i].t[j].m) + '
'; + buffer += _getTalentDescription(c[i].t[j]); ++k; - } - } + } + } - if (k == 0) { - buffer += LANG.tc_none; - } + if (k == 0) { + buffer += LANG.tc_none; + } - buffer += '
' - } + buffer += '
' + } - buffer += '

' + LANG.tc_glyphs + '

'; - buffer += '
'; - glyphCount = 0; + buffer += '

' + LANG.tc_glyphs + '

'; + buffer += '
'; + glyphCount = 0; - for (i = 0; i < _nGlyphs; ++i) { - glyph = g_glyphs[c.glyphs[i]]; - if (glyph) { - if (glyphCount) { - buffer += '

'; - } + for (i = 0; i < _nGlyphs; ++i) { + glyph = g_glyphs[c.glyphs[i]]; + if (glyph) { + if (glyphCount) { + buffer += '

'; + } - buffer += '' + glyph.name + ' '; - if (glyph.type == 1) { - buffer += '(' + LANG.tc_majgly + ')
'; - } + buffer += '' + glyph.name + ' '; + if (glyph.type == 1) { + buffer += '(' + LANG.tc_majgly + ')
'; + } else { - buffer += '(' + LANG.tc_mingly + ')
'; - } + buffer += '(' + LANG.tc_mingly + ')
'; + } - buffer += glyph.description; + buffer += glyph.description; - glyphCount++ - } - } + glyphCount++ + } + } - if (glyphCount == 0) { - buffer += LANG.tc_none; - } + if (glyphCount == 0) { + buffer += LANG.tc_none; + } - buffer += '
'; - } + buffer += '
'; + } else { // Summary - buffer += '
';
-			for (i = 0; i < _nTrees; ++i) {
-				buffer += '' + c[i].n + ' (' + c[i].k + ' ' + LANG[c[i].k == 1 ? 'tc_point': 'tc_points'] + ')\n\n';
-				k = 0;
-				for (j = 0; j < c[i].t.length; ++j) {
-					if (c[i].t[j].k) {
-						buffer += '    ' + c[i].t[j].k + '/' + c[i].t[j].m + ' ' + c[i].t[j].n + '\n';
+            buffer += '
';
+            for (i = 0; i < _nTrees; ++i) {
+                buffer += '' + c[i].n + ' (' + c[i].k + ' ' + LANG[c[i].k == 1 ? 'tc_point': 'tc_points'] + ')\n\n';
+                k = 0;
+                for (j = 0; j < c[i].t.length; ++j) {
+                    if (c[i].t[j].k) {
+                        buffer += '    ' + c[i].t[j].k + '/' + c[i].t[j].m + ' ' + c[i].t[j].n + '\n';
                         ++k;
-					}
-				}
-				if (k == 0) {
-					buffer += '    ' + LANG.tc_none + '\n';
-				}
-				buffer += '\n';
-			}
-			buffer += '
'; - } + } + } + if (k == 0) { + buffer += '    ' + LANG.tc_none + '\n'; + } + buffer += '\n'; + } + buffer += '
'; + } - buffer += ''; + buffer += ''; - bg.document.write(buffer); - bg.document.close() - }; + bg.document.write(buffer); + bg.document.close() + }; - this.simplifyGlyphName = function (name) { - return _simplifyGlyphName(name); - }; + this.simplifyGlyphName = function (name) { + return _simplifyGlyphName(name); + }; - this.toggleLock = function () { - if (_currentClass == -1) { - return; - } + this.toggleLock = function () { + if (_currentClass == -1) { + return; + } - _toggleLock(); - }; + _toggleLock(); + }; // ************************************************************* // ************************************************************* @@ -703,56 +701,56 @@ function TalentCalc() { // ************************************************************* // ************************************************************* - function _addGlyph(slot, itemId, stealth) { - var + function _addGlyph(slot, itemId, stealth) { + var cls = _data[_currentClass]; glyph = g_glyphs[itemId]; - if (glyph && _isValidGlyph(slot, glyph)) { - if (cls.glyphs[slot]) { - cls.glyphItems[cls.glyphs[slot]] = 0; - } + if (glyph && _isValidGlyph(slot, glyph)) { + if (cls.glyphs[slot]) { + cls.glyphItems[cls.glyphs[slot]] = 0; + } - cls.glyphs[slot] = itemId; - cls.glyphItems[itemId] = 1; + cls.glyphs[slot] = itemId; + cls.glyphItems[itemId] = 1; - if (!stealth) { - _updateGlyph(slot); - _onChange(); - } - } - } + if (!stealth) { + _updateGlyph(slot); + _onChange(); + } + } + } - function _afterCapDecrease() { - var c = _data[_currentClass]; + function _afterCapDecrease() { + var c = _data[_currentClass]; - if (c.k > _pointsToSpend) { - for (var tree = _nTrees - 1; tree >= 0; --tree) { - for (var i = c[tree].t.length - 1; i >= 0; --i) { - var k = c[tree].t[i].k; + if (c.k > _pointsToSpend) { + for (var tree = _nTrees - 1; tree >= 0; --tree) { + for (var i = c[tree].t.length - 1; i >= 0; --i) { + var k = c[tree].t[i].k; - for (var j = 0; j < k; ++j) { - _decrementTalent(c[tree].t[i]); + for (var j = 0; j < k; ++j) { + _decrementTalent(c[tree].t[i]); - if (c.k <= _pointsToSpend) { - return; - } - } - } - } - } - } + if (c.k <= _pointsToSpend) { + return; + } + } + } + } + } + } - function _bonusPointsOnClick(_this, e) { + function _bonusPointsOnClick(_this, e) { _setPoints(-1, (_bonusPoints ? 0 : _pointsFromBonus)); - _bonusPointsOnMouseOver(_this, e); - } + _bonusPointsOnMouseOver(_this, e); + } - function _bonusPointsOnMouseOver(_this, e) { - if(_mode == MODE_PET) { + function _bonusPointsOnMouseOver(_this, e) { + if (_mode == MODE_PET) { Tooltip.showAtCursor(e, LANG[_bonusPoints ? "tc_rembon": "tc_addbon"], null, null, "q"); } - } + } function _setLevelCapOnClick(_this, e) { _setLevelCap(prompt($WH.sprintf(LANG.prompt_ratinglevel, MIN_LEVEL, MAX_LEVEL), _maxLevel)); @@ -764,122 +762,132 @@ function TalentCalc() { Tooltip.showAtCursor(e, LANG.tooltip_changelevel, null, null, 'q'); } - function _createArrow(bc, bf, bg) { - var bh = ce("div"), - be, - bd; - bh.className = "talentcalc-arrow"; - switch (bc) { - case 0: - bf = 15; - be = _createTable(1, 2); - be.className = "talentcalc-arrow-down"; - bd = be.firstChild.childNodes[0].childNodes[0].style; - bd.width = "15px"; - bd.height = "4px"; - bd = be.firstChild.childNodes[1].childNodes[0].style; - bd.backgroundPosition = "bottom"; - bd.height = (bg - 4) + "px"; - break; - case 1: - be = _createTable(2, 2, true); - be.className = "talentcalc-arrow-leftdown"; - bd = be.firstChild.childNodes[0].childNodes[0].style; - bd.backgroundPosition = "left"; - bd.width = (bf - 4) + "px"; - bd.height = "11px"; - bd = be.firstChild.childNodes[0].childNodes[1].style; - bd.backgroundPosition = "right"; - bd.width = "4px"; - bd = be.firstChild.childNodes[1].childNodes[0].style; - bd.backgroundPosition = "bottom left"; - bd.backgroundRepeat = "no-repeat"; - bd.height = (bg - 11) + "px"; - break; - case 2: - be = _createTable(2, 2, true); - be.className = "talentcalc-arrow-rightdown"; - bd = be.firstChild.childNodes[0].childNodes[0].style; - bd.backgroundPosition = "left"; - bd.width = "4px"; - bd = be.firstChild.childNodes[0].childNodes[1].style; - bd.backgroundPosition = "right"; - bd.width = (bf - 4) + "px"; - bd.height = "11px"; - bd = be.firstChild.childNodes[1].childNodes[0].style; - bd.backgroundPosition = "bottom right"; - bd.backgroundRepeat = "no-repeat"; - bd.height = (bg - 11) + "px"; - break; - case 3: - bg = 15; - be = _createTable(2, 1); - be.className = "talentcalc-arrow-right"; - bd = be.firstChild.childNodes[0].childNodes[0].style; - bd.backgroundPosition = "left"; - bd.width = "4px"; - bd = be.firstChild.childNodes[0].childNodes[1].style; - bd.backgroundPosition = "right"; - bd.width = (bf - 4) + "px"; - break; - case 4: - bg = 15; - be = _createTable(2, 1); - be.className = "talentcalc-arrow-left"; - bd = be.firstChild.childNodes[0].childNodes[0].style; - bd.backgroundPosition = "left"; - bd.width = (bf - 4) + "px"; - bd = be.firstChild.childNodes[0].childNodes[1].style; - bd.backgroundPosition = "right"; - bd.width = "4px"; - break - } - bh.style.width = bf + "px"; - bh.style.height = bg + "px"; - ae(bh, be); - return bh - } + function _createArrow(arrowType, width, height) { + var + d = ce('div'), + t, + _; - function _createLower() { - var - be, - bf, - bd; + d.className = 'talentcalc-arrow'; - _divLower = ce("div"); - _divLower.className = "talentcalc-lower"; - _divLower.style.display = "none"; + switch(arrowType) { + case 0: // Down + width = 15; + t = _createTable(1, 2); + t.className = 'talentcalc-arrow-down'; - for (var bc = 0; bc < _nTrees; ++bc) { - be = _lblTreePoints[bc] = ce("div"); - be.className = "talentcalc-lower-tree" + (bc + 1); - bf = ce("p"); - bf.className = "rcorners"; - ae(bf, ce("b")); - ae(bf, ce("span")); - bd = ce("a"); - bd.href = "javascript:;"; - bd.onclick = _self.reset.bind(null, bc); - g_addTooltip(bd, LANG.tc_resettree); - ae(bf, bd); - ae(be, bf); - ae(_divLower, be) - } - // ae(_container, _divLower) - ae(_divWrapper, _divLower) - } + _ = t.firstChild.childNodes[0].childNodes[0].style; + _.width = '15px'; + _.height = '4px'; + _ = t.firstChild.childNodes[1].childNodes[0].style; + _.backgroundPosition = 'bottom'; + _.height = (height - 4) + 'px'; + break; + case 1: // Leftdown + t = _createTable(2, 2, true); + t.className = 'talentcalc-arrow-leftdown'; - function _createMain() { - _divMain = ce("div"); - _divMain.className = "talentcalc-main"; + _ = t.firstChild.childNodes[0].childNodes[0].style; + _.backgroundPosition = 'left'; + _.width = (width - 4) + 'px'; + _.height = '11px'; + _ = t.firstChild.childNodes[0].childNodes[1].style; + _.backgroundPosition = 'right'; + _.width = '4px'; + _ = t.firstChild.childNodes[1].childNodes[0].style; + _.backgroundPosition = 'bottom left'; + _.backgroundRepeat = 'no-repeat'; + _.height = (height - 11) + 'px'; + break; + case 2: // Rightdown + t = _createTable(2, 2, true); + t.className = 'talentcalc-arrow-rightdown'; - var clear = ce("div"); - clear.className = "clear"; - ae(_divMain, clear); + _ = t.firstChild.childNodes[0].childNodes[0].style; + _.backgroundPosition = 'left'; + _.width = '4px'; + _ = t.firstChild.childNodes[0].childNodes[1].style; + _.backgroundPosition = 'right'; + _.width = (width - 4) + 'px'; + _.height = '11px'; + _ = t.firstChild.childNodes[1].childNodes[0].style; + _.backgroundPosition = 'bottom right'; + _.backgroundRepeat = 'no-repeat'; + _.height = (height - 11) + 'px'; + break; + case 3: // Right + height = 15; + t = _createTable(2, 1); + t.className = 'talentcalc-arrow-right'; - // ae(_container, _divMain); - ae(_divWrapper, _divMain); - } + _ = t.firstChild.childNodes[0].childNodes[0].style; + _.backgroundPosition = 'left'; + _.width = '4px'; + _ = t.firstChild.childNodes[0].childNodes[1].style; + _.backgroundPosition = 'right'; + _.width = (width - 4) + 'px'; + break; + case 4: // Left + height = 15; + t = _createTable(2, 1); + t.className = 'talentcalc-arrow-left'; + + _ = t.firstChild.childNodes[0].childNodes[0].style; + _.backgroundPosition = 'left'; + _.width = (width - 4) + 'px'; + _ = t.firstChild.childNodes[0].childNodes[1].style; + _.backgroundPosition = 'right'; + _.width = '4px'; + break; + } + + d.style.width = width + 'px'; + d.style.height = height + 'px'; + + ae(d, t); + return d; + } + + function _createLower() { + var + _, + __, + ___; + + _divLower = ce('div'); + _divLower.className = 'talentcalc-lower'; + _divLower.style.display = 'none'; + + for (var tree = 0; tree < _nTrees; ++tree) { + _ = _lblTreePoints[tree] = ce('div'); + _.className = 'talentcalc-lower-tree' + (tree + 1); + + __ = ce('p'); + __.className = 'rcorners'; + ae(__, ce('b')); + ae(__, ce('span')); + ___ = ce('a'); + ___.href = 'javascript:;'; + ___.onclick = _self.reset.bind(null, tree); + g_addTooltip(___, LANG.tc_resettree); + ae(__, ___); + ae(_, __); + ae(_divLower, _); + } + + ae(_divWrapper, _divLower); + } + + function _createMain() { + _divMain = ce("div"); + _divMain.className = "talentcalc-main"; + + var clear = ce("div"); + clear.className = "clear"; + ae(_divMain, clear); + + ae(_divWrapper, _divMain); + } function _createModel() { if (_mode != MODE_PET) { @@ -899,510 +907,592 @@ function TalentCalc() { clear.className = 'clear'; ae(_divModel, clear); - // ae(_container, _divModel); ae(_divWrapper, _divModel); } - function _createPetTalents(classId) { - var + function _createPetTalents(classId) { + var data = [{}], talent, _; - for (var i = 0, len = g_pet_talents.length; i < len; ++i) { - var talents = g_pet_talents[i]; + for (var i = 0, len = g_pet_talents.length; i < len; ++i) { + var talents = g_pet_talents[i]; - if (in_array(talents.f, classId) >= 0) { - data[0].n = talents.n; - data[0].t = []; - data[0].i = i; + if (in_array(talents.f, classId) >= 0) { + data[0].n = talents.n; + data[0].t = []; + data[0].i = i; data[0].icon = talents.icon; - for (var j = 0, bf = talents.t.length; j < bf; ++j) { - talent = talents.t[j]; + for (var j = 0, bf = talents.t.length; j < bf; ++j) { + talent = talents.t[j]; - _ = data[0].t[j] = {}; - cO(_, talent); + _ = data[0].t[j] = {}; + cO(_, talent); if (talent.f && in_array(talent.f, classId) == -1) _.hidden = true; - } - break; - } - } - return data; - } + } + break; + } + } + return data; + } - function _createSidebar() { - var + function _createSidebar() { + var sidebarDivInner, _, __, ___; - _divSidebar = ce("div"); - _divSidebar.className = "talentcalc-sidebar rcorners"; - sidebarDivInner = ce("div"); - sidebarDivInner.className = "talentcalc-sidebar-inner"; - _ = ce("a"); - _.className = "talentcalc-button-help"; - _.href = (_mode == MODE_PET ? "http://petopia.brashendeavors.net/html/patch30/patch30faq_talents.php": "?help=talent-calculator"); - _.target = "_blank"; - ae(_, ct(LANG.tc_help)); - ae(sidebarDivInner, _); - _controlsDiv = ce("div"); - _controlsDiv.className = "talentcalc-sidebar-controls"; - _controlsDiv.style.display = "none"; - _ = ce("a"); - _.className = "talentcalc-button-reset"; - _.href = "javascript:;"; - _.onclick = _self.resetAll; - ae(_, ct(LANG.tc_resetall)); - ae(_controlsDiv, _); - _ = _lnkLock = ce("a"); - _.className = "talentcalc-button-lock"; - _.href = "javascript:;"; - _.onclick = _toggleLock; - ae(_, ct(LANG.tc_lock)); - ae(_controlsDiv, _); - _ = ce("div"); - _.className = "clear"; - ae(_controlsDiv, _); - ae(sidebarDivInner, _controlsDiv); - _ = ce("div"); - _.className = "talentcalc-sidebar-controls2"; - __ = ce("a"); - __.className = "talentcalc-button-import"; - __.href = "javascript:;"; - __.onclick = _self.promptBlizzBuild; - ae(__, ct(LANG.tc_import)); - ae(_, __); + _divSidebar = ce('div'); + _divSidebar.className = 'talentcalc-sidebar rcorners'; - __ = _lnkSummary = ce("a"); - __.className = "talentcalc-button-summary"; - __.style.display = "none"; - __.href = "javascript:;"; - __.onclick = _self.showSummary.bind(null, 1); - ae(__, ct(LANG.tc_summary)); - ae(_, __); + sidebarDivInner = ce('div'); + sidebarDivInner.className = 'talentcalc-sidebar-inner'; - __ = _lnkRestore = ce("a"); - __.className = "talentcalc-button-restore"; - __.style.display = "none"; - __.href = "javascript:;"; - __.onclick = _restore; - ae(__, ct(LANG.tc_restore)); - ae(_, __); + _ = ce('a'); + _.className = 'talentcalc-button-help'; + _.href = (_mode == MODE_PET ? 'http://petopia.brashendeavors.net/html/patch30/patch30faq_talents.php' : '?help=talent-calculator'); + _.target = '_blank'; + ae(_, ct(LANG.tc_help)); + ae(sidebarDivInner, _); - __ = _lnkExport = ce("a"); - __.className = "talentcalc-button-export"; - __.style.display = "none"; - __.href = "javascript:;"; - __.target = "_blank"; + _controlsDiv = ce('div'); + _controlsDiv.className = 'talentcalc-sidebar-controls'; + _controlsDiv.style.display = 'none'; + + _ = ce('a'); + _.className = 'talentcalc-button-reset'; + _.href = 'javascript:;'; + _.onclick = _self.resetAll; + ae(_, ct(LANG.tc_resetall)); + ae(_controlsDiv, _); + + _ = _lnkLock = ce('a'); + _.className = 'talentcalc-button-lock'; + _.href = 'javascript:;'; + _.onclick = _toggleLock; + ae(_, ct(LANG.tc_lock)); + ae(_controlsDiv, _); + + _ = ce('div'); + _.className = 'clear'; + ae(_controlsDiv, _); + + ae(sidebarDivInner, _controlsDiv); + + _ = ce('div'); + _.className = 'talentcalc-sidebar-controls2'; + + __ = ce('a'); + __.className = 'talentcalc-button-import'; + __.href = 'javascript:;'; + __.onclick = (_opt.profiler ? _self.promptWhBuild : _self.promptBlizzBuild); + ae(__, ct(LANG.tc_import)); + ae(_, __); + + __ = _lnkSummary = ce('a'); + __.className = 'talentcalc-button-summary'; + __.style.display = 'none'; + __.href = 'javascript:;'; + __.onclick = _self.showSummary.bind(null, 1); + ae(__, ct(LANG.tc_summary)); + ae(_, __); + + __ = _lnkRestore = ce('a'); + __.className = 'talentcalc-button-restore'; + __.style.display = 'none'; + __.href = 'javascript:;'; + __.onclick = _restore; + ae(__, ct(LANG.tc_restore)); + ae(_, __); + + __ = _lnkExport = ce('a'); + __.className = 'talentcalc-button-export'; + __.style.display = 'none'; + __.href = 'javascript:;'; + __.target = '_blank'; ae(__, ct(LANG.tc_link)); - ae(_, __) + ae(_, __); - __ = ce("div"); - __.className = "clear"; - ae(_, __); - ae(sidebarDivInner, _); - _ = ce("div"); - ae(sidebarDivInner, _); - if (_mode == MODE_DEFAULT) { - _glyphDiv = ce("div"); - _glyphDiv.style.display = "none"; - _ = ce("h3"); - ae(_, ct(LANG.tc_glyphs)); - ae(_glyphDiv, _); - __ = ce("a"); - __.href = "javascript:;"; - __.onclick = _self.resetGlyphs; - g_addTooltip(__, LANG.tc_resetglyphs); - ae(__, ct("[x]")); - ae(_, __); - _ = ce("div"); - _.className = "talentcalc-sidebar-majorglyphs q9"; - __ = ce("b"); - ae(__, ct(g_item_glyphs[1])); - ae(_, __); - ae(_glyphDiv, _); - _ = ce("div"); - _.className = "talentcalc-sidebar-minorglyphs q9"; - __ = ce("b"); - ae(__, ct(g_item_glyphs[2])); - ae(_, __); - ae(_glyphDiv, _); - _ = ce("div"); - _.className = "clear"; - ae(_glyphDiv, _); - var bq = ce("table"), - bf = ce("tbody"), - bh, - bd, - be, - bk, - bj, - bm; - bq.className = "icontab"; - for (var bi = 0; bi < 3; ++bi) { - bh = ce("tr"); - for (var bl = 0; bl < 2; ++bl) { - var bn = (bl * 3) + bi; - bd = ce("th"); - bk = Icon.create("inventoryslot_empty", 1, null, "javascript:;"); - bj = Icon.getLink(bk); - _glyphIcons[bn] = bk; - ae(bd, bk); - ae(bh, bd); - be = ce("td"); - bm = ce("a"); - _glyphLinks[bn] = bm; - ae(be, bm); - ae(bh, be); - bm.target = bj.target = "_blank"; - bm.rel = bj.rel = "np"; - bm.onmousedown = bj.onmousedown = rf; - bm.onclick = bj.onclick = rf; - g_onClick(bm, _glyphClick.bind(bm, bn)); - bm.onmouseover = _showGlyphTooltip.bind(null, bm, bn); - bm.onmousemove = Tooltip.cursorUpdate; - bm.onmouseout = Tooltip.hide; - g_onClick(bj, _glyphClick.bind(bj, bn)); - bj.onmouseover = _showGlyphTooltip.bind(null, bj, bn); - bj.onmouseout = Tooltip.hide; - be.oncontextmenu = rf - } - ae(bf, bh) - } - ae(bq, bf); - ae(_glyphDiv, bq); - ae(sidebarDivInner, _glyphDiv) - } - ae(_divSidebar, sidebarDivInner); - _ = ce("div"); - _.className = "talentcalc-sidebar-anchor"; - ae(_, _divSidebar); - ae(_container, _); - } + __ = ce('div'); + __.className = 'clear'; + ae(_, __); - function _createTable(be, bi, bc) { - var bk = ce("table"), - bd = ce("tbody"), - bf, - bj; - for (var bg = 0; bg < bi; ++bg) { - bf = ce("tr"); - for (var bh = 0; bh < be; ++bh) { - if (bc && bg > 0) { - bj = ce("th"); - bj.colSpan = 2; - ae(bf, bj); - break - } else { - ae(bf, ce("td")) - } - } - ae(bd, bf) - } - ae(bk, bd); - return bk - } + ae(sidebarDivInner, _); - function _createTrees(bo) { - var bw = _data[bo], - bA; - bw.k = 0; - bw.div = ce("div"); - bw.div.style.display = "none"; - aef(_divMain, bw.div); - for (var bm = 0; bm < _nTrees; ++bm) { - bw[bm].k = 0; - var bv = ce("div"); - d2 = ce("div"); - bv.style.backgroundRepeat = "no-repeat"; - bv.style.cssFloat = bv.style.styleFloat = "left"; - if (bm > 0) { - bv.style.borderLeft = "1px solid #404040" - } - d2.style.overflow = "hidden"; - d2.style.width = (_mode == MODE_DEFAULT ? "204px": "244px"); - ae(d2, _createTable(4, _nTiers)); - ae(bv, d2); - ae(bw.div, bv); - var br = gE(bv, "td"), - by, - bx = ""; - if (!Browser.ie6) { - bx = "?" + _versionBuild - } - if (_mode == MODE_PET) { - bv.style.backgroundImage = "url(images/talent/pets/bg_" + (bw[0].i + 1) + ".jpg" + bx + ")"; - by = "images/talent/pets/icons_" + (bw[0].i + 1) + ".jpg" + bx - } else { - bv.style.backgroundImage = "url(images/talent/classes/backgrounds/" + g_file_classes[bo] + "_" + (bm + 1) + ".jpg" + bx + ")"; - by = "images/talent/classes/icons/" + g_file_classes[bo] + "_" + (bm + 1) + ".jpg" + bx; - } - for (var bq = bw[bm].t.length - 1; bq >= 0; --bq) { - var bj = bw[bm].t[bq], - bu = Icon.create(by, 1, null, "javascript:;"), - bf = Icon.getLink(bu), - bn = br[(bj.y * 4 + bj.x + 1) - 1]; - if (Browser.ie6) { - bf.onfocus = tb - } - bf.rel = "np"; - bf.target = "_blank"; - bf.onmousedown = rf; - bf.onclick = rf; - g_onClick(bf, _iconClick.bind(bf, bj)); - bf.onmouseover = _showTooltip.bind(null, bf, bj); - bf.onmouseout = Tooltip.hide; - var bt = ce("div"), - bz = ce("div"); - ae(bz, ct("0")); - bt.className = "icon-border"; - bz.className = "icon-bubble"; - ae(bu, bt); - ae(bu, bz); - bj.k = 0; - bj.i = bq; - bj.tree = bm; - bj.classId = bo; - bj.icon = bu; - bj.link = bf; - bj.border = bt; - bj.bubble = bz; - if (!bj.hidden) { - ae(bn, bu) - } - if (bj.r) { - var bh = bw[bm].t[bj.r[0]], - be = bj.x - bh.x, - bd = bj.y - bh.y, - bp, - bk, - bi, - bs, - bg = -1; - if (bh.links == null) { - bh.links = [bq] - } else { - bh.links.push(bq) - } - if (bd > 0) { - if (be == 0) { - bg = 0 - } else { - if (be < 0) { - bg = 1 - } else { - bg = 2 - } - } - } else { - if (bd == 0) { - if (be > 0) { - bg = 3 - } else { - if (be < 0) { - bg = 4 - } - } - } - } - if (_mode == MODE_PET) { - bi = (Math.abs(be) - 1) * 60; - bs = (Math.abs(bd) - 1) * 60 - } else { - bi = (Math.abs(be) - 1) * 50; - bs = (Math.abs(bd) - 1) * 50 - } - if (_mode == MODE_PET) { - switch (bg) { - case 0: - bs += 27; - bp = 21; - bk = 6 - bs; - break - } - } else { - switch (bg) { - case 0: - bs += 17; - bp = 16; - bk = 6 - bs; - break; - case 1: - bi += 36; - bs += 42; - bp = 16; - bk = 6 - bs; - break; - case 2: - bi += 37; - bs += 42; - bp = -6; - bk = 6 - bs; - break; - case 3: - bi += 15; - bp = -6; - bk = 12; - break; - case 4: - bi += 15; - bp = 37; - bk = 12; - break - } - } - var bc = _createArrow(bg, bi, bs); - bc.style.left = bp + "px"; - bc.style.top = bk + "px"; - var bl = ce("div"); - bl.className = "talentcalc-arrow-anchor"; - ae(bl, bc); - if (!bj.hidden) { - bn.insertBefore(bl, bn.firstChild) - } - bj.arrow = bc - } - } - } - } + _ = ce('div'); + ae(sidebarDivInner, _); - function _createUpper() { - var bf, bd, be; - _divUpper = ce("div"); - _divUpper.className = "talentcalc-upper rcorners"; - _divUpper.style.display = "none"; - bf = ce("div"); - bf.className = "talentcalc-upper-inner"; - bd = ce("span"); - bd.className = "talentcalc-upper-class"; - be = _lblClass = ce("a"); - be.target = '_blank'; - be.style.fontWeight = 'bold'; - ae(bd, be); - ae(bd, ct(" ")); - _lblSpec = ce("b"); - ae(bd, _lblSpec); - ae(bf, bd); - bd = ce("span"); - bd.className = "talentcalc-upper-ptsleft"; - ae(bd, ct(LANG.tc_ptsleft)); - _lblPtsLeft = ce("b"); - ae(bd, _lblPtsLeft); - ae(bf, bd); - if (_mode == MODE_PET) { - be = _lnkBonusPoints = ce("a"); - be.href = "javascript:;"; - be.onclick = _bonusPointsOnClick.bind(null, be); - be.onmouseover = _bonusPointsOnMouseOver.bind(null, be); - be.onmousemove = Tooltip.cursorUpdate; - be.onmouseout = Tooltip.hide; - ae(bd, be) - } - bd = ce("span"); - bd.className = "talentcalc-upper-reqlevel"; - ae(bd, ct(LANG.tc_reqlevel)); - _lblReqLevel = ce("b"); - ae(bd, _lblReqLevel); + if (_mode == MODE_DEFAULT) { + _glyphDiv = ce('div'); + _glyphDiv.style.display = 'none'; - be = _lnkMaxLevel = ce('a'); - be.className = 'q1'; - be.href = 'javascript:;'; - be.onclick = _setLevelCapOnClick.bind(null, be); - be.onmouseover = _setLevelCapOnMouseOver.bind(null, be); - be.onmousemove = Tooltip.cursorUpdate; - be.onmouseout = Tooltip.hide; + _ = ce('h3'); + ae(_, ct(LANG.tc_glyphs)); + ae(_glyphDiv, _); - if(!_opt.profiler) - { - $WH.ae(bd, $WH.ct(' (')); - $WH.ae(bd, be); - $WH.ae(bd, $WH.ct(')')); + __ = ce('a'); + __.href = 'javascript:;'; + __.onclick = _self.resetGlyphs; + g_addTooltip(__, LANG.tc_resetglyphs); + ae(__, ct('[x]')); + ae(_, __); + _ = ce('div'); + _.className = 'talentcalc-sidebar-majorglyphs q9'; + __ = ce('b'); + ae(__, ct(g_item_glyphs[1])); + ae(_, __); + ae(_glyphDiv, _); + _ = ce('div'); + _.className = 'talentcalc-sidebar-minorglyphs q9'; + __ = ce('b'); + ae(__, ct(g_item_glyphs[2])); + ae(_, __); + ae(_glyphDiv, _); + _ = ce('div'); + _.className = 'clear'; + ae(_glyphDiv, _); + + var + table = ce('table'), + tbody = ce('tbody'), + tr, + th, + td, + icon, + link, + a; + + table.className = 'icontab'; + + for (var y = 0; y < 3; ++y) { + tr = ce('tr'); + for (var z = 0; z < 2; ++z) { + var slot = (z * 3) + y; + th = ce('th'); + icon = Icon.create('inventoryslot_empty', 1, null, 'javascript:;'); + link = Icon.getLink(icon); + + _glyphIcons[slot] = icon; + ae(th, icon); + ae(tr, th); + td = ce('td'); + + a = ce('a'); + _glyphLinks[slot] = a; + ae(td, a); + ae(tr, td); + + a.target = link.target = '_blank'; + a.rel = link.rel = 'np'; + a.onmousedown = link.onmousedown = rf; + a.onclick = link.onclick = rf; + + g_onClick(a, _glyphClick.bind(a, slot)); + a.onmouseover = _showGlyphTooltip.bind(null, a, slot); + a.onmousemove = Tooltip.cursorUpdate; + a.onmouseout = Tooltip.hide; + + g_onClick(link, _glyphClick.bind(link, slot)); + link.onmouseover = _showGlyphTooltip.bind(null, link, slot); + link.onmouseout = Tooltip.hide; + + td.oncontextmenu = rf; + } + ae(tbody, tr); + } + ae(table, tbody); + ae(_glyphDiv, table); + ae(sidebarDivInner, _glyphDiv); } - ae(bf, bd); - bd = ce("div"); - bd.className = "clear"; - ae(bf, bd); - ae(_divUpper, bf); + ae(_divSidebar, sidebarDivInner); - // ae(_container, _divUpper) - ae(_divWrapper, _divUpper) - } + _ = ce('div'); + _.className = 'talentcalc-sidebar-anchor'; + ae(_, _divSidebar); - function _convertBlizzToWh(bg) { - var bc = ""; - var bf = []; - for (var be = 0; be < bg.length; be += 2) { - for (var bd = 0; bd < 2; ++bd) { - bf[bd] = parseInt(bg.substring(be + bd, be + bd + 1)); - if (isNaN(bf[bd])) { - bf[bd] = 0 - } - } - bc += _encoding.charAt(bf[0] * 6 + bf[1]) - } - return bc - } + ae(_container, _); + } - function _decrementTalent(bj, bf, bi) { - var bh = _data[bj.classId]; - if (bj.k > 0) { - if (bj.links) { - for (bd = 0; bd < bj.links.length; ++bd) { - if (bh[bj.tree].t[bj.links[bd]].k) { - return - } - } - } - var be = 0; - bj.k--; - for (var bd = 0; bd < bh[bj.tree].t.length; ++bd) { - var bg = bh[bj.tree].t[bd]; - if (bg.k && bj.y != bg.y) { - if (be < bg.y * _pointsPerTier) { - bj.k++; - return - } - } - be += bg.k - } - bh[bj.tree].k--; - bd = bh.k--; - _updateTree(bj.tree, bf, null, bj.classId); - if (bf) { - _showTooltip(bi, bj); - if (bd >= _pointsToSpend) { - for (var bc = 0; bc < _nTrees; ++bc) { - _updateTree(bc, true, null, bj.classId) - } - } - _onChange(); - } - } - } + function _createTable(nCols, nRows, arrowMaker) { + var + t = ce('table'), + tb = ce('tbody'), + tr, + _; - function _getClassIdFromOldId(oldId) { - var L = _getClassIdFromOldId.L; + for (var y = 0; y < nRows; ++y) { + tr = ce('tr'); - if (L == null) { - L = _getClassIdFromOldId.L = {}; - for (var classId in _getOldIdFromClassId.L) { - L[_getOldIdFromClassId.L[classId]] = classId; - } - } + for (var x = 0; x < nCols; ++x) { + if (arrowMaker && y > 0) { + _ = ce('th'); + _.colSpan = 2; + ae(tr, _); + break; + } + else { + var td = ce('td'); + td.className = 'talentcalc-main-cell'; + ae(tr, td); + } + } + ae(tb, tr); + } + ae(t, tb); - return L[oldId]; - } + return t; + } - function _getOldIdFromClassId(classId) { - return _getOldIdFromClassId.L[classId]; - } - _getOldIdFromClassId.L = { + function _createTrees(classId) { + var + c = _data[classId], + _; + + c.k = 0; + + c.div = ce('div'); + c.div.style.display = 'none'; + aef(_divMain, c.div); + + for (var tree = 0; tree < _nTrees; ++tree) { + c[tree].k = 0; + + var + d = ce('div'), + d2 = ce('div'); + + d.style.backgroundRepeat = 'no-repeat'; + d.style.cssFloat = d.style.styleFloat = 'left'; + if (tree > 0) { + d.style.borderLeft = '1px solid #404040'; // Separator + } + + d2.style.overflow = 'hidden'; + d2.style.width = (_mode == MODE_DEFAULT ? '204px' : '244px'); + + ae(d2, _createTable(4, _nTiers)); + + ae(d, d2); + ae(c.div, d); + + var + tds = gE(d, 'td'), + iconBg, + afterUrl = '?' + _versionBuild; + + if (_mode == MODE_PET) { + d.style.backgroundImage = 'url(' + g_staticUrl + '/images/talent/pets/bg_' + (c[0].i + 1) + '.jpg' + afterUrl + ')'; + iconBg = g_staticUrl + '/images/talent/pets/icons_' + (c[0].i + 1) + '.jpg' + afterUrl + } + else { + d.style.backgroundImage = 'url(' + g_staticUrl + '/images/talent/classes/backgrounds/' + g_file_classes[classId] + '_' + (tree + 1) + '.jpg' + afterUrl + ')'; + iconBg = g_staticUrl + '/images/talent/classes/icons/' + g_file_classes[classId] + '_' + (tree + 1) + '.jpg' + afterUrl; + } + + for (var i = c[tree].t.length - 1; i >= 0; --i) { + var + talent = c[tree].t[i], + icon = Icon.create(iconBg, 1, null, 'javascript:;'), + link = Icon.getLink(icon), + targetTd = tds[(talent.y * 4 + talent.x + 1) - 1]; + + _talentLookup[c[tree].t[i].i] = talent; + + link.rel = 'np'; + link.target = '_blank'; + link.onmousedown = rf; + link.onclick = rf; + g_onClick(link, _iconClick.bind(link, talent)); + link.onmouseover = _showTooltip.bind(null, link, talent); + link.onmouseout = Tooltip.hide; + + var + border = ce('div'), + bubble = ce('div'); + + ae(bubble, ct('0')); + + border.className = 'icon-border'; + bubble.className = 'icon-bubble'; + + ae(icon, border); + ae(icon, bubble); + + talent.k = 0; + talent.i = i; + talent.tree = tree; + talent.classId = classId; + + talent.icon = icon; + talent.link = link; + talent.border = border; + talent.bubble = bubble; + + if (!talent.hidden) { + ae(targetTd, icon); + } + + if (talent.r) { + var + requiredTalent = c[tree].t[talent.r[0]], + dX = talent.x - requiredTalent.x, + dY = talent.y - requiredTalent.y, + l, + t, + w, + h, + arrowType = -1; + + if (requiredTalent.links == null) { + requiredTalent.links = [i]; + } + else { + requiredTalent.links.push(i); + } + + if (dY > 0) { + if (dX == 0) { + arrowType = 0; // Down + } + else if (dX < 0) { + arrowType = 1; // Leftdown + } + else { + arrowType = 2; // Rightdown + } + } + else if (dY == 0) { + if (dX > 0) { + arrowType = 3; // Right + } + else if (dX < 0) { + arrowType = 4; // Left + } + } + + if (_mode == MODE_PET) { + w = (Math.abs(dX) - 1) * 60; + h = (Math.abs(dY) - 1) * 60; + } + else { + w = (Math.abs(dX) - 1) * 50; + h = (Math.abs(dY) - 1) * 50; + } + + if (_mode == MODE_PET) { + switch (arrowType) { + case 0: // Down + h += 27; + l = 21; + t = 6 - h; + break; + } + } + else { + switch (arrowType) { + case 0: // Down + h += 17; + l = 16; + t = 6 - h; + break; + case 1: // Leftdown + w += 36; + h += 42; + l = 16; + t = 6 - h; + break; + case 2: // Rightdown + w += 37; + h += 42; + l = -6; + t = 6 - h; + break; + case 3: // Right + w += 15; + l = -6; + t = 12; + break; + case 4: // Left + w += 15; + l = 37; + t = 12; + break; + } + } + + var arrow = _createArrow(arrowType, w, h); + arrow.style.left = l + 'px'; + arrow.style.top = t + 'px'; + + var div = ce('div'); + div.className = 'talentcalc-arrow-anchor'; + ae(div, arrow); + + if (!talent.hidden) { + targetTd.insertBefore(div, targetTd.firstChild); + } + + talent.arrow = arrow; + } + } + } + } + + function _createUpper() { + var + _, + __; + + _divUpper = ce('div'); + _divUpper.className = 'talentcalc-upper rcorners'; + _divUpper.style.display = 'none'; + + _ = ce('span'); + _.className = 'talentcalc-upper-class'; + _lblClass = a = ce('a'); + a.target = '_blank'; + a.style.fontWeight = 'bold'; + ae(_, a); + ae(_, ct(' ')); + _lblSpec = ce('b'); + ae(_, _lblSpec); + ae(_divUpper, _); + + _ = ce('span'); + _.className = 'talentcalc-upper-ptsleft'; + ae(_, ct(LANG.tc_ptsleft)); + _lblPtsLeft = ce('b'); + ae(_, _lblPtsLeft); + ae(_divUpper, _); + + if (_mode == MODE_PET) { + __ = _lnkBonusPoints = ce('a'); + __.href = 'javascript:;'; + __.onclick = _bonusPointsOnClick.bind(null, __); + __.onmouseover = _bonusPointsOnMouseOver.bind(null, __); + __.onmousemove = Tooltip.cursorUpdate; + __.onmouseout = Tooltip.hide; + ae(_, __); + } + + _ = ce('span'); + _.className = 'talentcalc-upper-reqlevel'; + ae(_, ct(LANG.tc_reqlevel)); + _lblReqLevel = ce('b'); + ae(_, _lblReqLevel); + + __ = _lnkMaxLevel = ce('a'); + __.className = 'q1'; + __.href = 'javascript:;'; + __.onclick = _setLevelCapOnClick.bind(null, __); + __.onmouseover = _setLevelCapOnMouseOver.bind(null, __); + __.onmousemove = Tooltip.cursorUpdate; + __.onmouseout = Tooltip.hide; + + if (!_opt.profiler) { + ae(_, ct(' (')); + ae(_, __); + ae(_, ct(')')); + } + + ae(_divUpper, _); + + _ = ce('div'); + _.className = 'clear'; + ae(_divUpper, _); + + ae(_divWrapper, _divUpper); + } + + function _convertBlizzToWh(blizz) { + var wh = ''; + var values = []; + + for (var i = 0; i < blizz.length; i += 2) { + for (var j = 0; j < 2; ++j) { + values[j] = parseInt(blizz.substring(i + j, i + j + 1)); + if (isNaN(values[j])) { + values[j] = 0; + } + } + + wh += _encoding.charAt(values[0] * 6 + values[1]); + } + + return wh; + } + + function _decrementTalent(talent, refresh, _this) { + var c = _data[talent.classId]; + + if (talent.k > 0) { + // Test 1: Ensures that talent dependencies are respected. + if (talent.links) { + for (i = 0; i < talent.links.length; ++i) { + if (c[talent.tree].t[talent.links[i]].k) { + return; + } + } + } + + // Test 2: Simulate that a point was removed and make sure that everything is still fine. + talent.k--; + + var + sum = 0; + + for (var i = 0; i < c[talent.tree].t.length; ++i) { + var fooTalent = c[talent.tree].t[i]; + if (fooTalent.k && talent.y != fooTalent.y) { + if (sum < fooTalent.y * _pointsPerTier) { // Damn it. + talent.k++; // Reset talent. + return; + } + } + sum += fooTalent.k; + } + + c[talent.tree].k--; + i = c.k--; + + _updateTree(talent.tree, refresh, null, talent.classId); + if (refresh) { + _showTooltip(_this, talent); + + if (i >= _pointsToSpend) { + for (var tree = 0; tree < _nTrees; ++tree) { + _updateTree(tree, true, null, talent.classId); + } + } + + _onChange(); + } + } + } + + function _getClassIdFromOldId(oldId) { + var L = _getClassIdFromOldId.L; + + if (L == null) { + L = _getClassIdFromOldId.L = {}; + for (var classId in _getOldIdFromClassId.L) { + L[_getOldIdFromClassId.L[classId]] = classId; + } + } + + return L[oldId]; + } + + function _getOldIdFromClassId(classId) { + return _getOldIdFromClassId.L[classId]; + } + _getOldIdFromClassId.L = { 6: 9, // Death Knight 11: 0, // Druid 3: 1, // Hunter @@ -1413,9 +1503,9 @@ function TalentCalc() { 7: 6, // Shaman 9: 7, // Warlock 1: 8 // Warrior - }; + }; - function _getGlyphTypeFromSlot(slot) { + function _getGlyphTypeFromSlot(slot) { var skip = 0; for (var i = 0, len = _glyphOrder.length; i < len; ++i) { var glyphType = _glyphOrder[i]; @@ -1426,7 +1516,7 @@ function TalentCalc() { skip += _glyphLevels[glyphType].length; } - } + } function _isGlyphLocked(slot) { var notFound = (in_array(_glyphSlots[_getGlyphTypeFromSlot(slot)], slot) == -1); @@ -1448,18 +1538,18 @@ function TalentCalc() { return 0; } - function _getRequiredLevel() { - var + function _getRequiredLevel() { + var c = _data[_currentClass], r; - if (_mode == MODE_PET) { - r = Math.max(_bonusPoints ? 60 : 0, c.k > 0 ? (c.k - _bonusPoints) * 4 + 16 : 0); - } + if (_mode == MODE_PET) { + r = Math.max(_bonusPoints ? 60 : 0, c.k > 0 ? (c.k - _bonusPoints) * 4 + 16 : 0); + } else { - r = (c.k ? c.k + 9 : 0); + r = (c.k ? c.k + 9 : 0); // r = (c.k > 0 ? Math.max(0, 2 - c.k) + Math.min(36, c.k - 1) * 2 + Math.max(0, c.k - 37) + 9 : 0); - } + } for (var slot = 0; slot < _nGlyphs; ++slot) { if (g_glyphs[c.glyphs[slot]]) { @@ -1469,185 +1559,187 @@ function TalentCalc() { } return r; - } + } - function _getTalentDescription(talent, next) { - var description = talent.d; - var rank = Math.max(0, talent.k - 1) + (next ? 1 : 0); + function _getTalentDescription(talent, next) { + var description = talent.d; + var rank = Math.max(0, talent.k - 1) + (next ? 1 : 0); - return talent.d[rank]; - } + return talent.d[rank]; + } - function _glyphClick(slot, right) { - if (!_locked) { - if (right) { - if (_removeGlyph(slot)) { - _showGlyphTooltip(this, slot); - } - } + function _glyphClick(slot, right) { + if (!_locked) { + if (right) { + if (_removeGlyph(slot)) { + _showGlyphTooltip(this, slot); + } + } else { - _currentGlyphSlot = slot; - Lightbox.show( + _currentGlyphSlot = slot; + Lightbox.show( "glyphpicker", { onShow: _glyphPickerOnShow } ) - } - } - } + } + } + } - function _glyphPickerOnShow(dest, first, opt) { - Lightbox.setSize(800, 564); + function _glyphPickerOnShow(dest, first, opt) { + Lightbox.setSize(800, 564); - var + var lv, - _filteredGlyphs = false; + _filteredGlyphs = false; + if (first) { + dest.className = "talentcalc-glyphpicker listview"; - if (first) { - dest.className = "talentcalc-glyphpicker listview"; - - var + var dataz = [], div = ce("div"), anch = ce("a"), clear = ce("div"); - dataz.push({ none: 1 }); + dataz.push({ none: 1 }); - for (var itemId in g_glyphs) { - dataz.push(g_glyphs[itemId]); - } + for (var itemId in g_glyphs) { + dataz.push(g_glyphs[itemId]); + } - div.className = "listview"; - ae(dest, div); + div.className = "listview"; + ae(dest, div); - anch.className = "screenshotviewer-close"; - anch.href = "javascript:;"; - anch.onclick = Lightbox.hide; - ae(anch, ce("span")); - ae(dest, anch); + anch.className = "screenshotviewer-close"; + anch.href = "javascript:;"; + anch.onclick = Lightbox.hide; + ae(anch, ce("span")); + ae(dest, anch); - clear.className = "clear"; - ae(dest, clear); + clear.className = "clear"; + ae(dest, clear); - lv = new Listview({ - template: "glyph", - id: "glyphs", - parent: div, - data: dataz, - customFilter: _isValidGlyph.bind(0, null), + lv = new Listview({ + template: "glyph", + id: "glyphs", + parent: div, + data: dataz, + customFilter: _isValidGlyph.bind(0, null), createNote: _createGlyphPickerNote - }); + }); - if (Browser.firefox) { - aE(lv.getClipDiv(), "DOMMouseScroll", g_pickerWheel); - } + if (Browser.firefox) { + aE(lv.getClipDiv(), "DOMMouseScroll", g_pickerWheel); + } else { - lv.getClipDiv().onmousewheel = g_pickerWheel; - } - } + lv.getClipDiv().onmousewheel = g_pickerWheel; + } + } else { - lv = g_listviews.glyphs; + lv = g_listviews.glyphs; - lv.clearSearch(); - lv.updateFilters(true) - } + lv.clearSearch(); + lv.updateFilters(true) + } - setTimeout(function () { + setTimeout(function () { lv.createNote(lv.noteTop, lv.noteBot); - lv.focusSearch() - }, - 1) - } + lv.focusSearch() + }, 1); + } - function _iconClick(talent, right) { - if (_locked) { - return; - } + function _iconClick(talent, right) { + if (_locked) { + return; + } - if (right) { - _decrementTalent(talent, true, this); - } + if (right) { + _decrementTalent(talent, true, this); + } else { - _incrementTalent(talent, true, this); - } - } + _incrementTalent(talent, true, this); + } + } - function _incrementTalent(bg, bd, bf) { - var be = _data[bg.classId]; - if (be.k < _pointsToSpend) { - if (bg.enabled && bg.k < bg.m) { - be.k++; - be[bg.tree].k++; - bg.k++; - _updateTree(bg.tree, bd, bg, bg.classId); - if (bd) { - _showTooltip(bf, bg); - if (be.k == _pointsToSpend) { - for (var bc = 0; bc < _nTrees; ++bc) { - if (bc != bg.tree) { - _updateTree(bc, bd, null, bg.classId) - } - } - } - _onChange(); - } - } - } - else { - if (_mode == MODE_PET && be.k == _pointsToSpend && !bd) { - _setPoints(-1, 4, true); - _incrementTalent(bg, bd, bf) - } - } - } + function _incrementTalent(talent, refresh, _this) { + var c = _data[talent.classId]; - function _initGlyphData() { - var + if (c.k < _pointsToSpend) { + if (talent.enabled && talent.k < talent.m) { + c.k++; + c[talent.tree].k++; + talent.k++; + + _updateTree(talent.tree, refresh, talent, talent.classId); + + if (refresh) { + _showTooltip(_this, talent); + + if (c.k == _pointsToSpend) { + for (var tree = 0; tree < _nTrees; ++tree) { + if (tree != talent.tree) { + _updateTree(tree, refresh, null, talent.classId); + } + } + + } + + _onChange(); + } + } + } + else if (_mode == MODE_PET && c.k == _pointsToSpend && !refresh) { + _setPoints(-1, _pointsFromBonus, true); + _incrementTalent(talent, refresh, _this); // Try again + } + } + + function _initGlyphData() { + var glyph, c, t, ids = []; - for (var itemId in g_glyphs) { - ids.push(itemId); - } + for (var itemId in g_glyphs) { + ids.push(itemId); + } - ids.sort(); + ids.sort(); - for (var i = 0, len = ids.length; i < len; ++i) { - var itemId = ids[i]; + for (var i = 0, len = ids.length; i < len; ++i) { + var itemId = ids[i]; - glyph = g_glyphs[itemId]; - c = glyph.classs; - t = glyph.type; + glyph = g_glyphs[itemId]; + c = glyph.classs; + t = glyph.type; - if (!_glyphLookup[c]) { + if (!_glyphLookup[c]) { _glyphLookup[c] = {}; - for(var n in _glyphLevels) { + for (var n in _glyphLevels) { _glyphLookup[c][n] = []; } - } + } - if(!_glyphLookup[c][t]) + if (!_glyphLookup[c][t]) continue; - glyph.id = itemId; - glyph.index = _glyphLookup[c][t].length; + glyph.id = itemId; + glyph.index = _glyphLookup[c][t].length; - _glyphLookup[c][t].push(glyph.id); - } - } + _glyphLookup[c][t].push(glyph.id); + } + } - function _isValidGlyph(slot, glyph) { - if (glyph.none) { - return true - } + function _isValidGlyph(slot, glyph) { + if (glyph.none) { + return true + } - var cls = _data[_currentClass]; + var cls = _data[_currentClass]; - var valid = ( + var valid = ( // Class glyph.classs == _currentClass && @@ -1663,7 +1755,7 @@ function TalentCalc() { } return valid && (glyph.level <= _maxLevel); - } + } function _createGlyphPickerNote(div) { div.innerHTML = ''; @@ -1672,475 +1764,529 @@ function TalentCalc() { } } - function _onChange() { - var c = _data[_currentClass]; - if (!c) { - return; - } + function _onChange() { + var c = _data[_currentClass]; + if (!c) { + return; + } - _info.mode = _mode; - _info.classId = _currentClass; - _info.locked = _locked; - _info.requiredLevel = _getRequiredLevel(); - _info.pointsLeft = _pointsToSpend - c.k; - _info.pointsSpent = (_mode == MODE_PET ? c[0].k: [c[0].k, c[1].k, c[2].k]); - _info.bonusPoints = _bonusPoints; + _info.mode = _mode; + _info.classId = _currentClass; + _info.locked = _locked; + _info.requiredLevel = _getRequiredLevel(); + _info.pointsLeft = _pointsToSpend - c.k; + _info.pointsSpent = (_mode == MODE_PET ? c[0].k: [c[0].k, c[1].k, c[2].k]); + _info.bonusPoints = _bonusPoints; - st(_lblSpec, '(' + (_mode == MODE_PET ? c.k: _info.pointsSpent.join('/')) + ')'); - st(_lblReqLevel, _info.requiredLevel ? _info.requiredLevel: '-'); + st(_lblSpec, '(' + (_mode == MODE_PET ? c.k: _info.pointsSpent.join('/')) + ')'); + st(_lblReqLevel, _info.requiredLevel ? _info.requiredLevel: '-'); st(_lnkMaxLevel, _maxLevel); st(_lblPtsLeft, _info.pointsLeft); - if (_locked) { - st(_lnkLock, LANG.tc_unlock); - _lnkLock.className = 'talentcalc-button-unlock'; - } + if (_locked) { + st(_lnkLock, LANG.tc_unlock); + _lnkLock.className = 'talentcalc-button-unlock'; + } else { - st(_lnkLock, LANG.tc_lock); - _lnkLock.className = 'talentcalc-button-lock'; - } + st(_lnkLock, LANG.tc_lock); + _lnkLock.className = 'talentcalc-button-lock'; + } - if (_mode == MODE_PET) { - if (_bonusPoints) { - st(_lnkBonusPoints, '[-]'); - _lnkBonusPoints.className = 'q10' - } else { - st(_lnkBonusPoints, '[+]'); - _lnkBonusPoints.className = 'q2' - } - } + if (_mode == MODE_PET) { + if (_bonusPoints) { + st(_lnkBonusPoints, '[-]'); + _lnkBonusPoints.className = 'q10'; + } else { + st(_lnkBonusPoints, '[+]'); + _lnkBonusPoints.className = 'q2'; + } + } - if(_lnkExport) { + if (_lnkExport) { _lnkExport.href = (_mode == MODE_PET ? '?petcalc#' : '?talent#') + _self.getWhBuild() + (_mode == MODE_PET ? '' : ':' + _self.getWhGlyphs()); } - for (var tree = 0; tree < _nTrees; ++tree) { - var bd = _lblTreePoints[tree].firstChild.childNodes[1]; - st(bd, ' (' + c[tree].k + ')') - } + for (var tree = 0; tree < _nTrees; ++tree) { + var span = _lblTreePoints[tree].firstChild.childNodes[1]; + st(span, ' (' + c[tree].k + ')'); + } - if (_onChangeCallback) { - _onChangeCallback(_self, _info, c) - } - } + if (_onChangeCallback) { + _onChangeCallback(_self, _info, c); + } + } - function _onClassChange() { - st(_lblClass, _referenceArray[_currentClass]); - if (_mode == MODE_PET) { - _lblClass.href = "?pet=" + _currentClass; + function _onClassChange() { + st(_lblClass, _referenceArray[_currentClass]); + if (_mode == MODE_PET) { + _lblClass.href = '?pet=' + _currentClass; _updateModel(_currentClass); - _divModel.style.display = ""; - } + _divModel.style.display = ''; + } else { _lblClass.href = '?class=' + _currentClass; - _lblClass.className = "c" + _currentClass; - } + _lblClass.className = 'c' + _currentClass; + } - if (_nClassChanges == 0) { // First time - _controlsDiv.style.display = ""; - _lnkSummary.style.display = ""; + if (_nClassChanges == 0) { // First time + _controlsDiv.style.display = ''; + _lnkSummary.style.display = ''; - if (_lnkExport) { - _lnkExport.style.display = ""; - } + if (_lnkExport) { + _lnkExport.style.display = ''; + } - if (_glyphDiv) { - _glyphDiv.style.display = ""; - } + if (_glyphDiv) { + _glyphDiv.style.display = ''; + } - _divUpper.style.display = ""; - _divLower.style.display = ""; - } + _divUpper.style.display = ''; + _divLower.style.display = ''; + } - var c = _data[_currentClass]; + var c = _data[_currentClass]; - for (var tree = 0; tree < _nTrees; ++tree) { - var span = _lblTreePoints[tree].firstChild.childNodes[0]; - if (_mode == MODE_DEFAULT) { - span.style.backgroundImage = "url(images/talent/classes/trees/" + g_file_classes[_currentClass] + "_" + (tree + 1) + ".gif)"; - } - st(span, c[tree].n); - } + for (var tree = 0; tree < _nTrees; ++tree) { + var span = _lblTreePoints[tree].firstChild.childNodes[0]; + if (_mode == MODE_DEFAULT) { + span.style.backgroundImage = 'url(images/talent/classes/trees/' + g_file_classes[_currentClass] + '_' + (tree + 1) + '.gif)'; + } + st(span, c[tree].n); + } - _afterCapDecrease(); - _refreshAll(_currentClass); - _onChange(); + _afterCapDecrease(); + _refreshAll(_currentClass); + _onChange(); ++_nClassChanges; - } + } - function _parseBlizzBuild(bk, bi) { - var bj = _data[bi]; - var bl = 0, - bd = 0; - var bf = null, - bc; - for (var bh = 0; bh < bk.length; ++bh) { - var be = Math.min(parseInt(bk.charAt(bh)), bj[bl].t[bd].m); - if (isNaN(be)) { - continue - } - for (var bg = 0; bg < be; ++bg) { - _incrementTalent(bj[bl].t[bd]) - } - if (bf) { - for (var bg = 0; bg < bc; ++bg) { - _incrementTalent(bf) - } - bf = null - } - if (bj[bl].t[bd].k < be) { - bf = bj[bl].t[bd]; - bc = be - bj[bl].t[bd].k - } - if (++bd > bj[bl].t.length - 1) { - bd = 0; - if (++bl > _nTrees - 1) { - break - } - } - } - } + function _parseBlizzBuild(build, classId) { + var c = _data[classId]; - function _parseBlizzGlyphs(bk) { - var be = ("" + bk).split(":", _nGlyphs), - bh = 0, - bd = 0; - for (var bf = 0, bg = be.length; bf < bg && bf < _nGlyphs; ++bf) { - var bc = be[bf], - bi = g_glyphs[bc]; - if (bi) { - var bj = -1; - if (bi.type == 1) { - if (bh < _glyphLevels[1].length) { - bj = _glyphLevels[1][bh]; ++bh - } - } else { - if (bd < _glyphLevels[2].length) { - bj = _glyphLevels[2][bd]; ++bd - } - } - if (bj != -1) { - _addGlyph(bj, bc, true) - } - } else { - if (_getGlyphTypeFromSlot(bf) == 1) {++bh - } else {++bd - } - } - } - } + var + tree = 0, + talent = 0; - function _parseWhBuild(bn, bk) { - var bl = _data[bk]; - var bo = 0, - be = 0; - var bm = []; - var bg = null, - bd; - for (var bj = 0; bj < bn.length; ++bj) { - var bc = bn.charAt(bj); - if (bc != _newTree) { - var bf = _encoding.indexOf(bc); - if (bf < 0) { - continue - } - bm[1] = bf % 6; - bm[0] = (bf - bm[1]) / 6; - for (var bi = 0; bi < 2; ++bi) { - bf = Math.min(bm[bi], bl[bo].t[be].m); - for (var bh = 0; bh < bf; ++bh) { - _incrementTalent(bl[bo].t[be]) - } - if (bg) { - for (var bh = 0; bh < bd; ++bh) { - _incrementTalent(bg) - } - bg = null - } - if (bl[bo].t[be].k < bf) { - bg = bl[bo].t[be]; - bd = bf - bl[bo].t[be].k - } - if (++be >= bl[bo].t.length) { - break - } - } - } - if (be >= bl[bo].t.length || bc == _newTree) { - be = 0; - if (++bo > _nTrees - 1) { - return - } - } - } - } + var fixTalent = []; - function _parseWhGlyphs(bd) { - var bg = 0; - for (var be = 0, bc = bd.length; be < bc && be < _nGlyphs; ++be) { - var bf = bd.charAt(be); - if (bf == "Z") { - bg = 3; - continue; - } - _addGlyph(bg, _glyphLookup[_currentClass][_getGlyphTypeFromSlot(bg)][_encoding.indexOf(bf)], true); - ++bg; - } - } + // Fix for extra talent digit in blizzard mage builds + if (classId == 8 && build.length == 62) + build = build.substr(0,15) + build.substr(16); - function _refreshAll(classId) { - _refreshGlyphs(); + for (var i = 0; i < build.length; ++i) { + var n = Math.min(parseInt(build.charAt(i)), c[tree].t[talent].m); + if (isNaN(n)) { + continue; + } - for (var tree = 0; tree < _nTrees; ++tree) { - _updateTree(tree, true, null, classId); - } - } + for (var k = 0; k < n; ++k) { + _incrementTalent(c[tree].t[talent]); + } - function _refreshGlyphs() { - if (_mode != MODE_DEFAULT) { - return; - } + for (var f = 0; f < fixTalent.length; ++f) { + if (fixTalent[f][0].enabled && fixTalent[f][1] > 0) { + for (var k = 0; k < fixTalent[f][1]; ++k) { + _incrementTalent(fixTalent[f][0]); + } - var nGlyphs = 0; - for (var bd = 0; bd < _nGlyphs; ++bd) { - if (_updateGlyph(bd)) { + fixTalent[f][1] = 0; + } + } + + if (c[tree].t[talent].k < n) { + fixTalent.push([c[tree].t[talent], n - c[tree].t[talent].k]); + } + + if (++talent > c[tree].t.length - 1) { + talent = 0; + if (++tree > _nTrees - 1) { + break; + } + } + } + } + + function _parseBlizzGlyphs(glyphs) { + var + glyphIds = ('' + glyphs).split(':', _nGlyphs), + nextOfType = {}; + + for (var i = 0, len = glyphIds.length; i < len && i < _nGlyphs; ++i) { + var + glyphId = glyphIds[i], + glyph = g_glyphs[glyphId]; + + if (glyph) { + var slot = -1; + + if (nextOfType[glyph.type] == null) { + nextOfType[glyph.type] = 0; + } + + if (nextOfType[glyph.type] < _glyphSlots[glyph.type].length) { + slot = _glyphSlots[glyph.type][nextOfType[glyph.type]]; + ++nextOfType[glyph.type]; + } + + if (slot != -1) { + _addGlyph(slot, glyphId, true); + } + } + else { + ++nextOfType[_getGlyphTypeFromSlot(i)]; + } + } + } + + function _parseWhBuild(build, classId) { + var c = _data[classId]; + + var + tree = 0, + talent = 0; + + var values = []; + var fixTalent = []; + + for (var i = 0; i < build.length; ++i) { + var ch = build.charAt(i); + if (ch != _newTree) { + var n = _encoding.indexOf(ch); + if (n < 0) { + continue; + } + + values[1] = n % 6; + values[0] = (n - values[1]) / 6; + + for (var j = 0; j < 2; ++j) { + n = Math.min(values[j], c[tree].t[talent].m); + + for (var k = 0; k < n; ++k) { + _incrementTalent(c[tree].t[talent]); + } + + for (var f = 0; f < fixTalent.length; ++f) { + if (fixTalent[f][0].enabled && fixTalent[f][1] > 0) { + for (var k = 0; k < fixTalent[f][1]; ++k) { + _incrementTalent(fixTalent[f][0]); + } + + fixTalent[f][1] = 0; + } + } + + if (c[tree].t[talent].k < n) { + fixTalent.push([c[tree].t[talent], n - c[tree].t[talent].k]); + } + + if (++talent >= c[tree].t.length) { + break; + } + } + } + + if (talent >= c[tree].t.length || ch == _newTree) { + talent = 0; + + if (++tree > _nTrees - 1) { + return; + } + } + } + } + + function _parseWhGlyphs(glyphs) { + var + slot = 0; + + for (var i = 0, len = glyphs.length; i < len && i < _nGlyphs; ++i) { + var c = glyphs.charAt(i); + if (c == 'Z') { + slot = 3; + continue; + } + _addGlyph(slot, _glyphLookup[_currentClass][_getGlyphTypeFromSlot(slot)][_encoding.indexOf(c)], true); + ++slot; + } + } + + function _refreshAll(classId) { + _refreshGlyphs(); + + for (var tree = 0; tree < _nTrees; ++tree) { + _updateTree(tree, true, null, classId); + } + } + + function _refreshGlyphs() { + if (_mode != MODE_DEFAULT) { + return; + } + + var nGlyphs = 0; + for (var bd = 0; bd < _nGlyphs; ++bd) { + if (_updateGlyph(bd)) { ++nGlyphs; - } - } + } + } - _glyphDiv.style.display = (nGlyphs == 0 && _locked && _opt.profiler ? "none": "") - } + _glyphDiv.style.display = (nGlyphs == 0 && _locked && _opt.profiler ? "none": "") + } - function _registerClass(be, bd) { - if (_data[be] == null) { - bd.n = be; - _data[be] = bd; - var bf = _data[be]; - bf.glyphs = []; - bf.glyphItems = {}; - _createTrees(be); - if (_build && _build.classId == be) { - for (var bc = 0; bc < _nTrees; ++bc) { - _updateTree(bc, false, null, be) - } - if (_build.wh || _build.blizz) { - _locked = true; - if (_build.wh) { - _parseWhBuild(_build.wh, be) - } else { - _parseBlizzBuild(_build.blizz, be) - } - } - } else { - _locked = false - } - _build = null; - if (_glyphs && _glyphs.classId == be) { - if (_glyphs.wh) { - _parseWhGlyphs(_glyphs.wh) - } else { - _parseBlizzGlyphs(_glyphs.blizz) - } - } - _glyphs = null; - if (be == _currentClass) { - _onClassChange(); - bf.div.style.display = ""; - for (var bc = 0; bc < _nTrees; ++bc) { - _updateTree(bc, true, null, be) - } - } - } - } + function _registerClass(classId, data) { + if (_data[classId] == null) { + data.n = classId; + _data[classId] = data; - function _removeGlyph(be, bc) { - var bd = _data[_currentClass]; - if (bd.glyphs[be]) { - bd.glyphItems[bd.glyphs[be]] = 0; - bd.glyphs[be] = 0; - if (!bc) { - _updateGlyph(be); - _onChange(); - } - return true; - } - } + var c = _data[classId]; - function _resetAll(bc) { - _resetBuild(bc); - _resetGlyphs(); - _refreshAll(bc); - } + c.glyphs = []; + c.glyphItems = {}; - function _resetBuild(bd) { - if (_mode == MODE_PET) { - _setPoints(-1, 0, true) - } - for (var bc = 0; bc < _nTrees; ++bc) { - _resetTree(bc, bd, false); - } - } + _createTrees(classId); - function _resetGlyphs(bc) { - var be = _data[_currentClass]; - if (!be) { - return; - } - for (var bd = 0; bd < _nGlyphs; ++bd) { - _removeGlyph(bd, !bc); - } - _refreshGlyphs(); - } + if (_build && _build.classId == classId) { + for (var tree = 0; tree < _nTrees; ++tree) { + _updateTree(tree, false, null, classId); + } - function _resetTree(bc, bf, be) { - var bg = _data[bf]; - var bd; - for (bd = 0; bd < bg[bc].t.length; ++bd) { - bg[bc].t[bd].k = 0 - } - bd = (bg.k < _pointsToSpend); - bg.k -= bg[bc].k; - bg[bc].k = 0; - if (be) { - if (bd) { - _updateTree(bc, true, null, bf) - } else { - for (bc = 0; bc < _nTrees; ++bc) { - _updateTree(bc, true, null, bf) - } - } - _onChange(); - } - } + if (_build.wh || _build.blizz) { + _locked = true; + + if (_build.wh) { + _parseWhBuild(_build.wh, classId); + } + else { + _parseBlizzBuild(_build.blizz, classId); + } + } + } + else { + _locked = false; + } + + _build = null; + + if (_glyphs && _glyphs.classId == classId) { + if (_glyphs.wh) { + _parseWhGlyphs(_glyphs.wh); + } + else { + _parseBlizzGlyphs(_glyphs.blizz); + } + } + _glyphs = null; + + if (classId == _currentClass) { + _onClassChange(); + + c.div.style.display = ''; + + for (var tree = 0; tree < _nTrees; ++tree) { + _updateTree(tree, true, null, classId); + } + } + } + } + + function _removeGlyph(slot, stealth) { + var c = _data[_currentClass]; + + if (c.glyphs[slot]) { + c.glyphItems[c.glyphs[slot]] = 0; + c.glyphs[slot] = 0; + + if (!stealth) { + _updateGlyph(slot); + _onChange(); + } + + return true; + } + } + + function _resetAll(classId) { + _resetBuild(classId); + _resetGlyphs(); + _refreshAll(classId); + } + + function _resetBuild(classId) { + if (_mode == MODE_PET) { + _setPoints(-1, 0, true); + } + + for (var tree = 0; tree < _nTrees; ++tree) { + _resetTree(tree, classId, false); + } + } + + function _resetGlyphs(refresh) { + var c = _data[_currentClass]; + if (!c) { + return; + } + + for (var slot = 0; slot < _nGlyphs; ++slot) { + _removeGlyph(slot, !refresh); + } + + _refreshGlyphs(); + } + + function _resetTree(tree, classId, refresh) { + var c = _data[classId]; + var i; + + for (i = 0; i < c[tree].t.length; ++i) { + c[tree].t[i].k = 0; + } + + i = (c.k < _pointsToSpend); + c.k -= c[tree].k; + c[tree].k = 0; + + if (refresh) { + if (i) { + _updateTree(tree, true, null, classId) + } + else { + for (tree = 0; tree < _nTrees; ++tree) { + _updateTree(tree, true, null, classId); + } + } + + _onChange(); + } + } function _restore() { - if (_firstBuild) { - if (_firstBuild.wh) { - _setWhBuild(_firstBuild.wh); - } + if (_firstBuild) { + if (_firstBuild.wh) { + _setWhBuild(_firstBuild.wh); + } else { - _setBlizzBuild(_firstBuild.classId, _firstBuild.blizz); - } - } - if (_firstGlyphs && _firstGlyphs.wh) { + _setBlizzBuild(_firstBuild.classId, _firstBuild.blizz); + } + } + if (_firstGlyphs && _firstGlyphs.wh) { _setWhGlyphs(_firstGlyphs.wh); - } - } + } + } - function _setBlizzBuild(bc, bd) { - if (_referenceArray[bc] == null) { - return - } - if (!bd) { - return - } - _locked = true; - if (!_firstBuild) { - _firstBuild = { - classId: bc, - blizz: bd - }; - _lnkRestore.style.display = "" - } - if (_data[bc]) { - _resetBuild(bc); - _refreshAll(bc); - _parseBlizzBuild(bd, bc); - _refreshAll(bc) - } else { - _build = { - classId: bc, - blizz: bd - } - } - if (!_setClass(bc)) { - _onChange(); - } - } + function _setBlizzBuild(classId, build) { + if (_referenceArray[classId] == null) { + return; + } - function _setBlizzGlyphs(bc) { - if (!bc) { - return - } - if (_data[_currentClass]) { - _resetGlyphs(); - _parseBlizzGlyphs(bc); - _refreshGlyphs(); - _onChange(); - } else { - _glyphs = { - classId: _currentClass, - blizz: bc - } - } - } + if (!build) { + return; + } - function _setClass(classId) { - if (_referenceArray[classId] == null) { - return; - } + _locked = true; - if (classId != _currentClass) { - _oldClass = _currentClass; - _currentClass = classId; + if (!_firstBuild) { + _firstBuild = { classId: classId, blizz: build }; + _lnkRestore.style.display = ""; + } + if (_data[classId]) { + _resetBuild(classId); + _refreshAll(classId); + _parseBlizzBuild(build, classId); + _refreshAll(classId); + } + else { + _build = { classId: classId, blizz: build }; + } - if (_mode == MODE_PET && _data[classId] == null) { - _registerClass(classId, _createPetTalents(classId)); - } + if (!_setClass(classId)) { + _onChange(); + } + } + + function _setBlizzGlyphs(glyphs) { + if (!glyphs) { + return; + } + + if (_data[_currentClass]) { + _resetGlyphs(); + _parseBlizzGlyphs(glyphs); + _refreshGlyphs(); + _onChange(); + } + else { + _glyphs = { classId: _currentClass, blizz: glyphs }; + } + } + + function _setClass(classId) { + if (_referenceArray[classId] == null) { + return; + } + + if (classId != _currentClass) { + _oldClass = _currentClass; + _currentClass = classId; + + if (_mode == MODE_PET && _data[classId] == null) { + _registerClass(classId, _createPetTalents(classId)); + } else { - if (_data[classId]) { - _onClassChange(); + if (_data[classId]) { + _onClassChange(); - var c = _data[classId]; - c.div.style.display = ""; - } + var c = _data[classId]; + c.div.style.display = ""; + } else { - g_ajaxIshRequest("?data=talents&class=" + classId + "&" + _versionBuild); - } - } + g_ajaxIshRequest("?data=talents&class=" + classId + "&" + _versionBuild); + } + } - if (_data[_oldClass]) { - _data[_oldClass].div.style.display = "none"; - } + if (_data[_oldClass]) { + _data[_oldClass].div.style.display = "none"; + } - return true; - } - } + return true; + } + } function _setLevelCap(lvl) { lvl = parseInt(lvl); - if (isNaN(lvl) || lvl < MIN_LEVEL || lvl > MAX_LEVEL) { - return; - } + if (isNaN(lvl) || lvl < MIN_LEVEL || lvl > MAX_LEVEL) { + return; + } _maxLevel = lvl; var basePoints; - if (_mode == MODE_PET) { - basePoints = Math.max(0, Math.floor((lvl - 16) / 4)); - } + if (_mode == MODE_PET) { + basePoints = Math.max(0, Math.floor((lvl - 16) / 4)); + } else { - basePoints = Math.max(0, lvl - 9); + basePoints = Math.max(0, lvl - 9); // basePoints = Math.max(0, Math.min(10, lvl) - 9) + Math.max(0, Math.floor((Math.min(80, lvl) - 9) / 2)) + Math.max(0, lvl - 80); - } + } _setPoints(basePoints, -1); _setGlyphSlots(lvl); _refreshGlyphs(); - }; + }; - function _setLock(locked) { - if (_locked != locked) { - _locked = locked; + function _setLock(locked) { + if (_locked != locked) { + _locked = locked; - _refreshAll(_currentClass); - _onChange(1); - } - } + _refreshAll(_currentClass); + _onChange(1); + } + } function _setPoints(base, bonus, stealth) { var bak = _pointsToSpend; @@ -2179,8 +2325,8 @@ function TalentCalc() { var glyphType = _glyphOrder[i]; _glyphSlots[glyphType] = []; - for(var j = 0, len2 = _glyphLevels[glyphType].length; j < len2; ++j) { - if(level >= _glyphLevels[glyphType][j]) { + for (var j = 0, len2 = _glyphLevels[glyphType].length; j < len2; ++j) { + if (level >= _glyphLevels[glyphType][j]) { _glyphSlots[glyphType].push(slot); _nGlyphs++; } @@ -2190,178 +2336,200 @@ function TalentCalc() { } } - function _setWhBuild(bg) { - if (!bg) { - return; - } - var bc = bg, - bd = false, - be; - if (_mode == MODE_PET) { - var bh = _encoding.indexOf(bg.charAt(0)); - if (bh >= 0 && bh <= 4) { - var bf = _encoding.indexOf(bg.charAt(1)); - if (bf % 2 == 1) { - _setPoints(-1, 4, true); - --bf - } else { - _setPoints(-1, 0, true) - } - be = bh * 10 + (bf / 2); - if (g_pet_families[be] != null) { - bg = bg.substr(2); - bd = true - } - } - } else { - var bh = _encoding.indexOf(bg.charAt(0)); - if (bh >= 0 && bh <= 27) { - var bf = bh % 3, - be = (bh - bf) / 3; - be = _getClassIdFromOldId(be); - if (be != null) { - bg = bg.substr(1); - bd = true - } - } - } - if (bd) { - if (bg.length) { - _locked = true; - if (!_firstBuild) { - _firstBuild = { - wh: bc - }; - _lnkRestore.style.display = "" - } - } - if (_data[be]) { - _resetBuild(be); - _parseWhBuild(bg, be); - _refreshAll(be) - } else { - _build = { - classId: be, - wh: bg - } - } - if (!_setClass(be)) { - _onChange(); - } - return be; - } - } + function _setWhBuild(build) { + if (!build) { + return; + } - function _setWhGlyphs(bc) { - if (!bc) { - return; - } - if (!_firstGlyphs) { - _firstGlyphs = { - wh: bc - } - } - if (_data[_currentClass]) { - _resetGlyphs(); - _parseWhGlyphs(bc); - _refreshGlyphs(); - _onChange(); - } else { - _glyphs = { - classId: _currentClass, - wh: bc - } - } - } + var + unalteredBuild = build, + valid = false, + classId; - function _showGlyphTooltip(_this, slot) { - var + if (_mode == MODE_PET) { + var n = _encoding.indexOf(build.charAt(0)); + if (n >= 0 && n <= 4) { + var d = _encoding.indexOf(build.charAt(1)); + + if (d % 2 == 1) { + _setPoints(-1, _pointsFromBonus, true); + --d; + } + else { + _setPoints(-1, 0, true); + } + + classId = n * 10 + (d / 2); + if (g_pet_families[classId] != null) { + build = build.substr(2); + valid = true; + } + } + } + else { + var n = _encoding.indexOf(build.charAt(0)); + if (n >= 0 && n <= 27) { + var + d = n % 3, + classId = (n - d) / 3; + + + classId = _getClassIdFromOldId(classId); + if (classId != null) { + build = build.substr(1); + valid = true; + } + } + } + + if (valid) { + if (build.length) { + _locked = true; + + if (!_firstBuild) { + _firstBuild = { wh: unalteredBuild }; + _lnkRestore.style.display = ''; + } + } + + if (_data[classId]) { + _resetBuild(classId); + _parseWhBuild(build, classId); + _refreshAll(classId); + } + else { + _build = { classId: classId, wh: build }; + } + + if (!_setClass(classId)) { + _onChange(); + } + + return classId; + } + } + + function _setWhGlyphs(glyphs) { + if (!glyphs) { + return; + } + + if (!_firstGlyphs) { + _firstGlyphs = { wh: glyphs }; + } + + if (_data[_currentClass]) { + _resetGlyphs(); + _parseWhGlyphs(glyphs); + _refreshGlyphs(); + _onChange(); + } + else { + _glyphs = { classId: _currentClass, wh: glyphs }; + } + } + + function _showGlyphTooltip(_this, slot) { + var c = _data[_currentClass]; upper = "", lower = "", glyph = g_glyphs[c.glyphs[slot]], locked = _isGlyphLocked(slot); - if (glyph && !locked) { - upper += "" + glyph.name + ""; - upper += '
' + LANG[slot <= 2 ? "tc_majgly": "tc_mingly"] + ""; + if (glyph && !locked) { + upper += "" + glyph.name + ""; + upper += '
' + LANG[slot <= 2 ? "tc_majgly": "tc_mingly"] + ""; - lower += '' + glyph.description + ""; - if (!_locked) { // If glyphs are locked, do not show instructions on how to click to remove them. - lower += '
' + LANG["tc_remgly"] + ""; - } - } + lower += '' + glyph.description + ""; + if (!_locked) { // If glyphs are locked, do not show instructions on how to click to remove them. + lower += '
' + LANG["tc_remgly"] + ""; + } + } else if (!locked) { - upper += '' + LANG.tc_empty + ""; - upper += '
' + LANG[slot <= 2 ? "tc_majgly": "tc_mingly"] + ""; + upper += '' + LANG.tc_empty + ""; + upper += '
' + LANG[slot <= 2 ? "tc_majgly": "tc_mingly"] + ""; - if (!_locked) { // If glyphs are locked, do not show instructions on how to click to add them. - lower += '' + LANG.tc_addgly + ""; - } - } + if (!_locked) { // If glyphs are locked, do not show instructions on how to click to add them. + lower += '' + LANG.tc_addgly + ""; + } + } else { upper += '' + LANG.tc_locked + ''; upper += '
' + LANG[slot <= 2 ? "tc_majgly": "tc_mingly"] + ''; lower += '' + sprintf(LANG.tc_lockgly, _getGlyphSlotLevel(slot)) + ''; } - if (glyph && _this.parentNode.className.indexOf("icon") != 0) { - Tooltip.setIcon(glyph.icon); - } + if (glyph && _this.parentNode.className.indexOf("icon") != 0) { + Tooltip.setIcon(glyph.icon); + } else { - Tooltip.setIcon(null); - } + Tooltip.setIcon(null); + } - Tooltip.show(_this, "
" + upper + "
" + lower + "
") - } + Tooltip.show(_this, "
" + upper + "
" + lower + "
") + } - function _showTooltip(bf, be) { - var bd = _data[be.classId], - bc = "
"; - if (be.z) { - bc += '' + be.z + "" - } - bc += be.n + "
" + sprintf(LANG.tc_rank, be.k, be.m) + "
"; - if (be.r) { - if (bd[be.tree].t[be.r[0]].k < be.r[1]) { - bc += ''; - bc += sprintf(LANG[be.r[1] == 1 ? "tc_prereq": "tc_prereqpl"], be.r[1], bd[be.tree].t[be.r[0]].n); - bc += "
" - } - } - if (bd[be.tree].k < be.y * _pointsPerTier) { - bc += '' + sprintf(LANG.tc_tier, (be.y * _pointsPerTier), bd[be.tree].n) + "
" - } - if (be.t && be.t.length >= 1) { - bc += be.t[0] - } - bc += "
"; - if (be.t && be.t.length > 1) { - bc += be.t[1] + "
" - } - bc += '' + _getTalentDescription(be) + "
"; - if (_locked) {} else { - if (be.enabled) { - if (!be.k) { - bc += '' + LANG.tc_learn + "
" - } else { - if (be.k == be.m) { - bc += '' + LANG["tc_unlearn"] + "
" - } - } - if (be.k && be.k < be.m) { - bc += "
" + LANG.tc_nextrank + '
' + _getTalentDescription(be, 1) + "
" - } - } - } - bc += "
"; - Tooltip.show(bf, bc) - } + function _showTooltip(_this, talent) { + var + c = _data[talent.classId], + buffer = '
'; - function _simplifyGlyphName(name) { + if (talent.z) { + buffer += '' + talent.z + ''; + } + + buffer += talent.n + '
' + sprintf(LANG.tc_rank, talent.k, talent.m) + '
'; + + if (talent.r) { + if (c[talent.tree].t[talent.r[0]].k < talent.r[1]) { + buffer += ''; + buffer += sprintf(LANG[talent.r[1] == 1 ? 'tc_prereq' : 'tc_prereqpl'], talent.r[1], c[talent.tree].t[talent.r[0]].n); + buffer += '
'; + } + } + + if (c[talent.tree].k < talent.y * _pointsPerTier) { + buffer += '' + sprintf(LANG.tc_tier, (talent.y * _pointsPerTier), c[talent.tree].n) + '
'; + } + + if (talent.t && talent.t.length >= 1) { + buffer += talent.t[0]; + } + + buffer += '
'; + + if (talent.t && talent.t.length > 1) { + buffer += talent.t[1] + '
'; + } + + buffer += '' + _getTalentDescription(talent) + '
'; + + if (_locked) { + + } + else if (talent.enabled) { + if (!talent.k) { + buffer += '' + LANG.tc_learn + '
'; + } + else if (talent.k == talent.m) { + buffer += '' + LANG.tc_unlearn + '
'; + } + + if (talent.k && talent.k < talent.m) { + buffer += '
' + LANG.tc_nextrank + '
' + _getTalentDescription(talent, 1) + '
'; + } + } + + buffer += '
'; + + Tooltip.show(_this, g_setTooltipItemLevel(buffer, _getRequiredLevel())); + } + + function _simplifyGlyphName(name) { var str; - switch (g_locale.id) { + switch (g_locale.id) { case 0: str = name.replace(/^Glyph of (the )?/i, ''); break; @@ -2384,18 +2552,18 @@ function TalentCalc() { // ucFirst return str.charAt(0).toUpperCase() + str.substr(1); - } + } - function _toggleLock() { - _locked = !_locked; - _refreshAll(_currentClass); - _onChange(); + function _toggleLock() { + _locked = !_locked; + _refreshAll(_currentClass); + _onChange(); - return _locked; - } + return _locked; + } - function _updateGlyph(slot) { - var + function _updateGlyph(slot) { + var c = _data[_currentClass], icon = _glyphIcons[slot], link = Icon.getLink(icon), @@ -2403,8 +2571,8 @@ function TalentCalc() { a = _glyphLinks[slot], glyph; - if (c.glyphs[slot]) { - glyph = g_glyphs[c.glyphs[slot]]; + if (c.glyphs[slot]) { + glyph = g_glyphs[c.glyphs[slot]]; if (locked || glyph.level > _maxLevel) { _removeGlyph(slot); @@ -2413,101 +2581,117 @@ function TalentCalc() { if (glyph && !locked) { - Icon.setTexture(icon, 1, glyph.icon); - a.href = link.href = '?item=' + glyph.id; + Icon.setTexture(icon, 1, glyph.icon); + a.href = link.href = '?item=' + glyph.id; - st(a, _simplifyGlyphName(glyph.name)); - a.className = 'q1'; + st(a, _simplifyGlyphName(glyph.name)); + a.className = 'q1'; - return true; - } + return true; + } else { - Icon.setTexture(icon, 1, 'inventoryslot_empty'); - a.href = link.href = 'javascript:;'; + Icon.setTexture(icon, 1, 'inventoryslot_empty'); + a.href = link.href = 'javascript:;'; - st(a, (!locked ? LANG.tc_empty : LANG.tc_locked)); - a.className = 'q0'; + st(a, (!locked ? LANG.tc_empty : LANG.tc_locked)); + a.className = 'q0'; - return false; - } - } + return false; + } + } - function _updateTree(bl, bh, bd, bi) { - var bj = _data[bi]; - var bg; - var bc; - if (!bd || bj.k == _pointsToSpend) { - bc = 0; - bg = _pointsToSpend - 21 - } else { - bc = bd.i; - bg = Math.floor(bj[bl].k / 5) * 5 + 5 - } - if (bd != null && bd.links != null) { - for (var be = 0, bf = bd.links.length; be < bf; ++be) { - if (bc > bd.links[be]) { - bc = bd.links[be] - } - } - } - for (var be = bc; be < bj[bl].t.length; ++be) { - bd = bj[bl].t[be]; - if (bj.k == _pointsToSpend && !bd.k) { - bd.enabled = 0 - } else { - if (bj[bl].k >= bd.y * _pointsPerTier) { - if (bd.r) { - if (bj[bl].t[bd.r[0]].k >= bd.r[1]) { - bd.enabled = 1 - } else { - bd.enabled = 0 - } - } else { - bd.enabled = 1 - } - } else { - bd.enabled = 0 - } - } - if (bh) { - if (bd.enabled && (!_locked || bd.k)) { - if ((bd.k == bd.m)) { - bd.border.style.backgroundPosition = "-42px 0"; - bd.bubble.style.color = "#E7BA00" - } else { - bd.border.style.backgroundPosition = "-84px 0"; - bd.bubble.style.color = "#17FD17" - } - Icon.moveTexture(bd.icon, 1, be, 0); - bd.link.className = "bubbly"; - bd.bubble.style.visibility = "visible"; - if (bd.r) { - var bk = bd.arrow.firstChild; - if (bk.className.charAt(bk.className.length - 1) != "2") { - bk.className += "2" - } - } - } else { - bd.border.style.backgroundPosition = "0 0"; - Icon.moveTexture(bd.icon, 1, be, 1); - bd.link.className = ""; - bd.bubble.style.visibility = "hidden"; - if (bd.r) { - var bk = bd.arrow.firstChild; - if (bk.className.charAt(bk.className.length - 1) == "2") { - bk.className = bk.className.substr(0, bk.className.length - 1) - } - } - } - bd.bubble.firstChild.nodeValue = bd.k; - bd.link.href = "?spell=" + bd.s[Math.max(0, bd.k - 1)] - } - } - } + function _updateTree(tree, refresh, talent, classId) { + var c = _data[classId]; + + var highestLevel; + var bc; + + if (!talent || c.k == _pointsToSpend) { + bc = 0; + highestLevel = _pointsToSpend - 21; + } + else { + bc = talent.i; + highestLevel = Math.floor(c[tree].k / _pointsPerTier) * _pointsPerTier + 5; + } + if (talent != null && talent.links != null) { + for (var i = 0, bf = talent.links.length; i < bf; ++i) { + if (bc > talent.links[i]) { + bc = talent.links[i]; + } + } + } + + for (var i = bc; i < c[tree].t.length; ++i) { + talent = c[tree].t[i]; + + if (c.k == _pointsToSpend && !talent.k) { + talent.enabled = 0; + } + else { + if (c[tree].k >= talent.y * _pointsPerTier) { + if (talent.r) { + if (c[tree].t[talent.r[0]].k >= talent.r[1]) { + talent.enabled = 1; + } + else { + talent.enabled = 0; + } + } + else { + talent.enabled = 1; + } + } + else { + talent.enabled = 0; + } + } + + if (refresh) { + if (talent.enabled && (!_locked || talent.k)) { + if (talent.k == talent.m) { + talent.border.style.backgroundPosition = '-42px 0'; + talent.bubble.style.color = '#E7BA00'; + } + else { + talent.border.style.backgroundPosition = '-84px 0'; + talent.bubble.style.color = '#17FD17'; + } + + Icon.moveTexture(talent.icon, 1, i, 0); + talent.link.className = 'bubbly'; + talent.bubble.style.visibility = 'visible'; + + if (talent.r) { + var _ = talent.arrow.firstChild; + if (_.className.charAt(_.className.length - 1) != '2') { + _.className += '2'; + } + + } + } + else { + talent.border.style.backgroundPosition = '0 0'; + Icon.moveTexture(talent.icon, 1, i, 1); + talent.link.className = ''; + talent.bubble.style.visibility = 'hidden'; + + if (talent.r) { + var _ = talent.arrow.firstChild; + if (_.className.charAt(_.className.length - 1) == '2') { + _.className = _.className.substr(0, _.className.length - 1); + } + } + } + + talent.bubble.firstChild.nodeValue = talent.k; + talent.link.href = '?spell=' + talent.s[Math.max(0, talent.k - 1)]; + } + } + } function _updateModel(classId, npcId) { - - var swfUrl = "http://static.wowhead.com"; // g_staticUrl + var swfUrl = "http://static.wowhead.com"; // sarjuuk: g_staticUrl if (_mode != MODE_PET){ return; @@ -2523,16 +2707,16 @@ function TalentCalc() { c.npcId = npcId; } - if(!g_pets[c.npcId] || g_pets[c.npcId].family != classId) { + if (!g_pets[c.npcId] || g_pets[c.npcId].family != classId) { var models = []; - for(var i in g_pets) { - if(g_pets[i].family == classId) { + for (var i in g_pets) { + if (g_pets[i].family == classId) { models.push(g_pets[i].id); } } - if(!models.length) { + if (!models.length) { return; } @@ -2575,39 +2759,39 @@ TalentCalc.MODE_DEFAULT = 0; TalentCalc.MODE_PET = 1; Listview.templates.glyph = { - sort: [1], - nItemsPerPage: -1, - hideBands: 2, - hideNav: 1 | 2, - hideHeader: 1, - searchable: 1, - searchDelay: 100, - poundable: 0, - filtrable: 0, - clip: { - w: 780, - h: 486 - }, + sort: [1], + nItemsPerPage: -1, + hideBands: 2, + hideNav: 1 | 2, + hideHeader: 1, + searchable: 1, + searchDelay: 100, + poundable: 0, + filtrable: 0, + clip: { + w: 780, + h: 486 + }, - onBeforeCreate: function () { + onBeforeCreate: function () { this.applySort(); - }, + }, - onSearchSubmit: function(glyph) { - if (this.nRowsVisible != 1) { - return; + onSearchSubmit: function(glyph) { + if (this.nRowsVisible != 1) { + return; } - $WowheadTalentCalculator.addGlyph(glyph.id); - }, + $WowheadTalentCalculator.addGlyph(glyph.id); + }, - columns: [ + columns: [ { id: 'glyph', type: 'text', align: 'left', value: 'name', - span: 2, + span: 2, compute: function (glyph, td, tr) { if (glyph.none) { return; @@ -2669,21 +2853,21 @@ Listview.templates.glyph = { } }, { - id: 'level', - type: 'text', - align: 'center', - value: 'level', - compute: function(glyph, td) { - if(glyph.none) { + id: 'level', + type: 'text', + align: 'center', + value: 'level', + compute: function(glyph, td) { + if (glyph.none) { return; } - td.className = 'small q0'; - td.style.whiteSpace = 'nowrap'; - return LANG.tc_level.replace('%s', glyph.level); - } - }, - { + td.className = 'small q0'; + td.style.whiteSpace = 'nowrap'; + return LANG.tc_level.replace('%s', glyph.level); + } + }, + { id: 'skill', type: 'text', align: 'center', @@ -2699,7 +2883,7 @@ Listview.templates.glyph = { ee(tr); tr.onclick = $WowheadTalentCalculator.addGlyph.bind(null, 0); - td.colSpan = 5; + td.colSpan = 5; td.style.fontWeight = 'bold'; td.style.textAlign = 'center'; @@ -2720,4 +2904,4 @@ Listview.templates.glyph = { } } ] -}; \ No newline at end of file +}; diff --git a/template/js/global.js b/template/js/global.js index 9735d9b8..a0fed358 100644 --- a/template/js/global.js +++ b/template/js/global.js @@ -19,472 +19,623 @@ var U_GROUP_GREEN_TEXT = U_GROUP_MOD | U_GROUP_BUREAU | U_GROUP_DEV; var U_GROUP_MODERATOR = U_GROUP_ADMIN | U_GROUP_MOD | U_GROUP_BUREAU; var U_GROUP_COMMENTS_MODERATOR = U_GROUP_MODERATOR | U_GROUP_LOCALIZER; var U_GROUP_PREMIUM_PERMISSIONS = U_GROUP_PREMIUM | U_GROUP_STAFF | U_GROUP_VIP; -function $(c) { - if (arguments.length > 1) { - var b = []; - var a; - for (var d = 0, a = arguments.length; d < a; ++d) { - b.push($(arguments[d])) - } - return b - } - if (typeof c == "string") { - c = ge(c) - } - return c + +function $(z) { + if (arguments.length > 1) { + var el = []; + var len; + + for (var i = 0, len = arguments.length; i < len; ++i) { + el.push($(arguments[i])); + } + + return el; + } + + if (typeof z == 'string') { + z = ge(z); + } + + return z; } -function $E(a) { - if (!a) { - if (typeof event != "undefined") { - a = event - } else { - return null - } - } - if (a.which) { - a._button = a.which - } else { - a._button = a.button; - if (Browser.ie) { - if (a._button & 4) { - a._button = 2 - } else { - if (a._button & 2) { - a._button = 3 - } - } - } else { - a._button = a.button + 1 - } - } - a._target = a.target ? a.target: a.srcElement; - a._wheelDelta = a.wheelDelta ? a.wheelDelta: -a.detail; - return a + +function $E(e) { + if (!e) { + if (typeof event != 'undefined') { + e = event; + } + else { + return null; + } + } + + // Netscape standard (1 = Left, 2 = Middle, 3 = Right) + if (e.which) { + e._button = e.which; + } + else { + e._button = e.button; + // IE8 doesnt have a button set, so add 1 to at least register as a left click + if (Browser.ie6789 && e._button) { + if (e._button & 4) { + e._button = 2; // Middle + } + else if (e._button & 2) { + e._button = 3; // Right + } + } + else { + e._button = e.button + 1 + } + } + + e._target = e.target ? e.target : e.srcElement; + + e._wheelDelta = e.wheelDelta ? e.wheelDelta : -e.detail; + + return e; } -function $A(c) { - var e = []; - for (var d = 0, b = c.length; d < b; ++d) { - e.push(c[d]) - } - return e + +function $A(a) { + var r = []; + for (var i = 0, len = a.length; i < len; ++i) { + r.push(a[i]); + } + + return r; } + function bindfunc() { args = $A(arguments); - var b = args.shift(); - var a = args.shift(); + var __method = args.shift(); + var object = args.shift(); + return function() { - return b.apply(a, args.concat($A(arguments))) + return __method.apply(object, args.concat($A(arguments))); + }; +} + +if (!Function.prototype.bind) { + Function.prototype.bind = function() { + var + __method = this, + args = $A(arguments), + object = args.shift(); + + return function() { + return __method.apply(object, args.concat($A(arguments))); + }; + }; +} + +if (!String.prototype.ltrim) { + String.prototype.ltrim = function() { + return this.replace(/^\s*/, ''); } } -Function.prototype.bind = function() { - var - __method = this, - args = $A(arguments), - object = args.shift(); - - return function() { - return __method.apply(object, args.concat($A(arguments))); - } -}; - -if (!String.prototype.ltrim) { - String.prototype.ltrim = function() { - return this.replace(/^\s*/, "") - } -} if (!String.prototype.rtrim) { - String.prototype.rtrim = function() { - return this.replace(/\s*$/, "") - } + String.prototype.rtrim = function() { + return this.replace(/\s*$/, ''); + } } + if (!String.prototype.trim) { - String.prototype.trim = function() { - return this.ltrim().rtrim() - } + String.prototype.trim = function() { + return this.ltrim().rtrim(); + } } + if (!String.prototype.removeAllWhitespace) { - String.prototype.removeAllWhitespace = function() { - return this.replace("/s+/g", "") - } + String.prototype.removeAllWhitespace = function() { + return this.replace('/s+/g', ''); + } } -function strcmp(d, c) { - if (d == c) { - return 0 - } - if (d == null) { - return -1 - } - if (c == null) { - return 1 - } - var f = parseFloat(d), - e = parseFloat(c); - if (!isNaN(f) && !isNaN(e) && f != e) { - return f < e ? -1 : 1 - } - return d < c ? -1 : 1 + +function strcmp(a, b) { + if (a == b) { + return 0; + } + + if (a == null) { + return -1; + } + + if (b == null) { + return 1; + } + + // Natural sorting for strings starting with a number + var + _a = parseFloat(a), + _b = parseFloat(b); + if (!isNaN(_a) && !isNaN(_b) && _a != _b) { + return _a < _b ? -1 : 1; + } + + // String comparison done with a native JS function that supports accents and non-latin characters + if (typeof a == 'string' && typeof b == 'string') { + return a.localeCompare(b); + } + + // Other + return a < b ? -1 : 1; } -function trim(a) { - return a.replace(/(^\s*|\s*$)/g, "") + +function trim(str) { + return str.replace(/(^\s*|\s*$)/g, ''); } -function rtrim(c, d) { - var b = c.length; - while (--b > 0 && c.charAt(b) == d) {} - c = c.substring(0, b + 1); - if (c == d) { - c = "" - } - return c + +function rtrim(z, y) { + var a = z.length; + + while (--a > 0 && z.charAt(a) == y) { } + + z = z.substring(0, a + 1); + + if (z == y) { + z = ''; + } + + return z; } -function sprintf(b) { - var a; - for (a = 1, len = arguments.length; a < len; ++a) { - b = b.replace("$" + a, arguments[a]) - } - return b + +function sprintf(z) { + var i; + for (i = 1, len = arguments.length; i < len; ++i) { + z = z.replace('$' + i, arguments[i]); + } + + return z; } -function sprintfa(b) { - var a; - for (a = 1, len = arguments.length; a < len; ++a) { - b = b.replace(new RegExp("\\$" + a, "g"), arguments[a]) - } - return b + +// This version supports multiple occurences of the same token. +function sprintfa(z) { + var i; + for (i = 1, len = arguments.length; i < len; ++i) { + z = z.replace(new RegExp('\\$' + i, 'g'), arguments[i]); + } + + return z; } -function sprintfo(c) { - if (typeof c == "object" && c.length) { - var a = c; - c = a[0]; - var b; - for (b = 1; b < a.length; ++b) { - c = c.replace("$" + b, a[b]) - } - return c - } + +// This version works with an array object as the paremeter. +function sprintfo(z) { + if (typeof z == 'object' && z.length) { + var args = z; + z = args[0]; + + var i; + for (i = 1; i < args.length; ++i) { + z = z.replace('$' + i, args[i]); + } + + return z; + } } -function str_replace(e, d, c) { - while (e.indexOf(d) != -1) { - e = e.replace(d, c) - } - return e + +function str_replace(z, a, b) { + while (z.indexOf(a) != -1) { + z = z.replace(a, b); + } + + return z; } -function urlencode(a) { - a = encodeURIComponent(a); - a = str_replace(a, "+", "+"); - return a + +// Encode URL for internal use (e.g. Ajax) +function urlencode(z) { + z = encodeURIComponent(z); + z = str_replace(z, '+', '%2B'); + return z; } -function urlencode2(a) { - a = encodeURIComponent(a); - a = str_replace(a, " ", "+"); - return a + +// Encode URL for visible use (e.g. href) +function urlencode2(z) { + z = encodeURIComponent(z); + z = str_replace(z, '%20', '+'); + z = str_replace(z, '%3D', '='); + + return z; } -function number_format(a) { - x = ("" + parseFloat(a)).split("."); - a = x[0]; - x = x.length > 1 ? "." + x[1] : ""; - if (a.length <= 3) { - return a + x - } - return number_format(a.substr(0, a.length - 3)) + "," + a.substr(a.length - 3) + x + +// Group digits (e.g. 1234 --> 1,234) +function number_format(z) { + x = ('' + parseFloat(z)).split('.'); + z = x[0]; + x = x.length > 1 ? "." + x[1] : ''; + + if (z.length <= 3) { + return z + x; + } + + return number_format(z.substr(0, z.length - 3)) + ',' + z.substr(z.length - 3) + x; } function is_array(arr) { - return !!(arr && arr.constructor == Array); + return !!(arr && arr.constructor == Array); } function in_array(arr, val, func, idx) { - if (arr == null) { - return -1; - } + if (arr == null) { + return -1; + } - if (func) { - return in_arrayf(arr, val, func, idx); - } + if (func) { + return in_arrayf(arr, val, func, idx); + } - for (var i = idx || 0, len = arr.length; i < len; ++i) { - if (arr[i] == val) { - return i; - } - } + for (var i = idx || 0, len = arr.length; i < len; ++i) { + if (arr[i] == val) { + return i; + } + } - return -1; + return -1; } function in_arrayf(arr, val, func, idx) { - for (var i = idx || 0, len = arr.length; i < len; ++i) { - if (func(arr[i]) == val) { - return i; - } - } - return -1; + for (var i = idx || 0, len = arr.length; i < len; ++i) { + if (func(arr[i]) == val) { + return i; + } + } + return -1; } function rs() { - var e = rs.random; - var b = ""; - for (var a = 0; a < 16; a++) { - var d = Math.floor(Math.random() * e.length); - if (a == 0 && d < 11) { - d += 10 - } - b += e.substring(d, d + 1) - } - return b + var e = rs.random; + var b = ''; + for (var a = 0; a < 16; a++) { + var d = Math.floor(Math.random() * e.length); + if (a == 0 && d < 11) { + d += 10; + } + b += e.substring(d, d + 1); + } + return b; } rs.random = "0123456789abcdefghiklmnopqrstuvwxyz"; -function isset(a) { - return typeof window[a] != "undefined" + +function isset(name) { + return typeof window[name] != "undefined"; } -function array_filter(c, g) { - var e=[]; - for (var d = 0, b = c.length; d < b; ++d) { - if (g(c[d])) { - e.push(c[d]) - } - } - return e + +function array_filter(a, f) { + var res = []; + for (var i = 0, len = a.length; i < len; ++i) { + if (f(a[i])) { + res.push(a[i]); + } + } + return res; } -function array_walk(d, h, c) { - var g; - for (var e = 0, b = d.length; e < b; ++e) { - g = h(d[e], c, d, e); - if (g != null) { - d[e] = g - } - } + +function array_walk(a, f, ud) { + var res; + for (var i = 0, len = a.length; i < len; ++i) { + res = f(a[i], ud, a, i); + if (res != null) { + a[i] = res; + } + } } -function array_apply(d, h, c) { - var g; - for (var e = 0, b = d.length; e < b; ++e) { - h(d[e], c, d, e) - } + +function array_apply(a, f, ud) { + var res; + for (var i = 0, len = a.length; i < len; ++i) { + f(a[i], ud, a, i); + } } -function ge(a) { - return document.getElementById(a) + +// Get element +function ge(z) { + if(typeof z != 'string') { + return z; + } + + return document.getElementById(z); } -function gE(a, b) { - return a.getElementsByTagName(b) + +// Get elements by tag name +function gE(z, y) { + return z.getElementsByTagName(y); } -function ce(d, b, e) { - var a = document.createElement(d); - if (b) { - cOr(a, b) - } - if (e) { - ae(a, e) - } - return a + +// Create element +function ce(z, p, c) { + var a = document.createElement(z); + + if (p) { + cOr(a, p); + } + + if (c) { + ae(a, c); + } + + return a; } -function de(a) { - a.parentNode.removeChild(a) + +// Delete element +function de(z) { + if (!z || !z.parentNode) { + return; + } + + z.parentNode.removeChild(z); } -function ae(a, b) { - if (is_array(b)) { - array_apply(b, a.appendChild.bind(a)); - return b - } else { - return a.appendChild(b) - } + +// Append element +function ae(z, y) { + if (is_array(y)) { + array_apply(y, z.appendChild.bind(z)); + + return y; + } + else { + return z.appendChild(y); + } } -function aef(a, b) { - return a.insertBefore(b, a.firstChild) + +// Prepend element +function aef(z, y) { + return z.insertBefore(y, z.firstChild); } -function ee(a, b) { - if (!b) { - b = 0 - } - while (a.childNodes[b]) { - a.removeChild(a.childNodes[b]) - } + +// Empty element +function ee(z, y) { + if (!y) { + y = 0; + } + while (z.childNodes[y]) { + z.removeChild(z.childNodes[y]); + } } -function ct(a) { - return document.createTextNode(a) + +// Create text element +function ct(z) { + return document.createTextNode(z); } -function st(a, b) { - if (a.firstChild && a.firstChild.nodeType == 3) { - a.firstChild.nodeValue = b - } else { - aef(a, ct(b)) - } + +// Set element's text +function st(z, y) { + if (z.firstChild && z.firstChild.nodeType == 3) { + z.firstChild.nodeValue = y; + } + else { + aef(z, ct(y)); + } } -function nw(a) { - a.style.whiteSpace = "nowrap" + +// Add "white-space: nowrap" style to element +function nw(z) { + z.style.whiteSpace = "nowrap"; } + +// Return false function rf() { - return false + return false; } -function rf2(a) { - a = $E(a); - if (a.ctrlKey || a.shiftKey || a.altKey || a.metaKey) { - return - } - return false + +// Return false only if no control key is pressed +function rf2(e) { + e = $E(e); + + if (e.ctrlKey || e.shiftKey || e.altKey || e.metaKey) { + return; + } + + return false; } + +// Remove focus from current element function tb() { - this.blur() + this.blur(); } -function ac(c, d) { - var a = 0, - g = 0, - b; - while (c) { - a += c.offsetLeft; - g += c.offsetTop; - b = c.parentNode; - while (b && b != c.offsetParent && b.offsetParent) { - if (b.scrollLeft || b.scrollTop) { - a -= (b.scrollLeft | 0); - g -= (b.scrollTop | 0); - break - } - b = b.parentNode - } - c = c.offsetParent - } - if (Lightbox.isVisible()) { - d = true - } - if (d && !Browser.ie6) { - var f = g_getScroll(); - a += f.x; - g += f.y - } - var e = [a, g]; - e.x = a; - e.y = g; - return e + +function ac(el, fixedPos) { + var + x = 0, + y = 0, + el2; + + while (el) { + x += el.offsetLeft; + y += el.offsetTop; + + el2 = el.parentNode; + while (el2 && el2 != el.offsetParent && el2.offsetParent) { // Considers scroll position for elements inside an 'overflow: auto' div. + if (el2.scrollLeft || el2.scrollTop) { + x -= (el2.scrollLeft | 0); + y -= (el2.scrollTop | 0); + break; + } + + el2 = el2.parentNode; + } + + el = el.offsetParent; + } + + if (isset('Lightbox') && Lightbox.isVisible()) { // Assumes that calls made while the Lightbox is visible are on 'position: fixed' elements. + fixedPos = true; + } + + if (fixedPos) { + var scroll = g_getScroll(); + x += scroll.x; + y += scroll.y + } + + var result = [x, y]; + result.x = x; + result.y = y; + return result; } -function aE(b, c, a) { - if (Browser.ie) { - b.attachEvent("on" + c, a) - } else { - b.addEventListener(c, a, false) - } + +// Attach event +function aE(z, y, x) { + if (z.addEventListener) { + z.addEventListener(y, x, false); + } + else if (z.attachEvent) { + z.attachEvent('on' + y, x); + } } -function dE(b, c, a) { - if (Browser.ie) { - b.detachEvent("on" + c, a) - } else { - b.removeEventListener(c, a, false) - } + +// Detach event +function dE(z, y, x) { + if (z.removeEventListener) { + z.removeEventListener(y, x, false); + } + else if (z.detachEvent) { + z.detachEvent('on' + y, x); + } } -function sp(a) { - if (!a) { - a = event - } - if (Browser.ie) { - a.cancelBubble = true - } else { - a.stopPropagation() - } + +// Stop propagation +function sp(z) { + if (!z) { + z = event; + } + + if (Browser.ie6789) { + z.cancelBubble = true + } + else { + z.stopPropagation(); + } } // Set cookie function sc(z, y, x, w, v) { - var a = new Date(); - var b = z + "=" + escape(x) + "; "; - a.setDate(a.getDate() + y); - b += "expires=" + a.toUTCString() + "; "; - if (w) { - b += "path=" + w + "; "; - } - if (v) { - b += "domain=" + v + "; "; - } - document.cookie = b; + var a = new Date(); + var b = z + "=" + escape(x) + "; "; + + a.setDate(a.getDate() + y); + b += "expires=" + a.toUTCString() + "; "; + + if (w) { + b += "path=" + w + "; "; + } + + if (v) { + b += "domain=" + v + "; "; + } + + document.cookie = b; gc(z); - gc.C[z] = x; + gc.C[z] = x; } // Delete cookie function dc(z) { - sc(z, -1); - gc.C[z] = null; + sc(z, -1); + gc.C[z] = null; } // Get all cookies (return value is cached) function gc(z) { - if (gc.I == null) { // Initialize cookie table - var words = unescape(document.cookie).split("; "); + if (gc.I == null) { // Initialize cookie table + var words = unescape(document.cookie).split("; "); - gc.C = {}; - for (var i = 0, len = words.length; i < len; ++i) { - var + gc.C = {}; + for (var i = 0, len = words.length; i < len; ++i) { + var pos = words[i].indexOf("="), name, value; - if (pos != -1) { - name = words[i].substr(0, pos); - value = words[i].substr(pos + 1); - } + if (pos != -1) { + name = words[i].substr(0, pos); + value = words[i].substr(pos + 1); + } else { - name = words[i]; - value = ""; - } + name = words[i]; + value = ""; + } - gc.C[name] = value; - } + gc.C[name] = value; + } - gc.I = 1; - } + gc.I = 1; + } - if (!z) { - return gc.C; - } + if (!z) { + return gc.C; + } else { - return gc.C[z]; - } + return gc.C[z]; + } } +// Prevent element from being selected/dragged (IE only) function ns(a) { - if (Browser.ie) { - a.onfocus = tb; - a.onmousedown = a.onselectstart = a.ondragstart = rf - } + if (Browser.ie6789) { + a.onfocus = tb; + a.onmousedown = a.onselectstart = a.ondragstart = rf; + } } -function eO(b) { - for (var a in b) { - delete b[a] - } + +// Empty object +function eO(z) { + for (var p in z) { + delete z[p]; + } } + +// Duplicate object function dO(s) { function f(){}; f.prototype = s; return new f; } -function cO(c, a) { - for (var b in a) { - if (a[b] !== null && typeof a[b] == "object" && a[b].length) { - c[b] = a[b].slice(0) - } else { - c[b] = a[b] - } - } + +// Copy object +function cO(d, s) { + for (var p in s) { + if (s[p] !== null && typeof s[p] == "object" && s[p].length) { + d[p] = s[p].slice(0); + } + else { + d[p] = s[p]; + } + } + + return d; } -function cOr(c, a) { - for (var b in a) { - if (typeof a[b] == "object") { - if (a[b].length) { - c[b] = a[b].slice(0) - } else { - if (!c[b]) { - c[b] = {} - } - cOr(c[b], a[b]) - } - } else { - c[b] = a[b] - } - } + +// Copy object (recursive) +function cOr(d, s) { + for (var p in s) { + if (typeof s[p] == 'object') { + if (s[p].length) { + d[p] = s[p].slice(0); + } + else { + if (!d[p]) { + d[p] = {}; + } + + cOr(d[p], s[p]); + } + } + else { + d[p] = s[p]; + } + } + + return d; } + Browser = { - ie: !!(window.attachEvent && !window.opera), - opera: !!window.opera, - safari: navigator.userAgent.indexOf('Safari') != -1, - firefox: navigator.userAgent.indexOf('Firefox') != -1, - chrome: navigator.userAgent.indexOf('Chrome') != -1 + ie: !!(window.attachEvent && !window.opera), + opera: !!window.opera, + safari: navigator.userAgent.indexOf('Safari') != -1, + firefox: navigator.userAgent.indexOf('Firefox') != -1, + chrome: navigator.userAgent.indexOf('Chrome') != -1 }; + Browser.ie9 = Browser.ie && navigator.userAgent.indexOf('MSIE 9.0') != -1; Browser.ie8 = Browser.ie && navigator.userAgent.indexOf('MSIE 8.0') != -1&& !Browser.ie9; Browser.ie7 = Browser.ie && navigator.userAgent.indexOf('MSIE 7.0') != -1 && !Browser.ie8; @@ -498,67 +649,76 @@ navigator.userAgent.match(/Gecko\/([0-9]+)/); Browser.geckoVersion = parseInt(RegExp.$1) | 0; OS = { - windows: navigator.appVersion.indexOf('Windows') != -1, - mac: navigator.appVersion.indexOf('Macintosh') != -1, - linux: navigator.appVersion.indexOf('Linux') != -1 + windows: navigator.appVersion.indexOf('Windows') != -1, + mac: navigator.appVersion.indexOf('Macintosh') != -1, + linux: navigator.appVersion.indexOf('Linux') != -1 }; var DomContentLoaded = new function() { - var b = []; - var a = []; - this.now = function() { - array_apply(b, function(c) { - c() - }) - }; - this.delayed = function() { - array_apply(a, function(c) { - c() - }); - DomContentLoaded = null - }; - this.addEvent = function(c) { - b.push(c) - }; - this.addDelayedEvent = function(c) { - a.push(c) - } + var _now = []; + var _del = []; + + this.now = function() { + array_apply(_now, function(f) { + f(); + }); + }; + + this.delayed = function() { + array_apply(_del, function(f) { + f(); + }); + + DomContentLoaded = null; + }; + + this.addEvent = function(f) { + _now.push(f); + }; + + this.addDelayedEvent = function(f) { + _del.push(f); + } }; + function g_getWindowSize() { - var a = 0, - b = 0; - if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { - a = document.documentElement.clientWidth; - b = document.documentElement.clientHeight - } else { - if (document.body && (document.body.clientWidth || document.body.clientHeight)) { - a = document.body.clientWidth; - b = document.body.clientHeight - } else { - if (typeof window.innerWidth == "number") { - a = window.innerWidth; - b = window.innerHeight - } - } - } - return { - w: a, - h: b - } + var + width = 0, + height = 0; + + if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { + // IE 6+ in 'standards compliant mode' + width = document.documentElement.clientWidth; + height = document.documentElement.clientHeight; + } + else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { + // IE 4 compatible + width = document.body.clientWidth; + height = document.body.clientHeight; + } + else if (typeof window.innerWidth == 'number') { // Non-IE + width = window.innerWidth; + height = window.innerHeight; + } + + return { + w: width, + h: height + }; } function g_getScroll() { - var + var x = 0, y = 0; - if (typeof(window.pageYOffset) == "number") { - // Netscape compliant - x = window.pageXOffset; - y = window.pageYOffset - } + if (typeof(window.pageYOffset) == "number") { + // Netscape compliant + x = window.pageXOffset; + y = window.pageYOffset + } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { - // DOM compliant + // DOM compliant x = document.body.scrollLeft; y = document.body.scrollTop } @@ -566,19 +726,19 @@ function g_getScroll() { // IE6 standards compliant mode x = document.documentElement.scrollLeft; y = document.documentElement.scrollTop - } - return { - x: x, - y: y - }; + } + return { + x: x, + y: y + }; } function g_getCursorPos(e) { - var + var x, y; - if (window.innerHeight) { + if (window.innerHeight) { // ok, something of a workaround here... MS9+ sends a MSEventObj istead of mouseEvent . whatever // but the properties for that are client[X|Y] DIAF! @@ -591,73 +751,80 @@ function g_getCursorPos(e) { x = e.pageX; y = e.pageY } - } + } else { - var scroll = g_getScroll(); + var scroll = g_getScroll(); - x = e.clientX + scroll.x; - y = e.clientY + scroll.y - } + x = e.clientX + scroll.x; + y = e.clientY + scroll.y + } - return { - x: x, - y: y - }; + return { + x: x, + y: y + }; } -function g_scrollTo(c, b) { - var l, k = g_getWindowSize(), - m = g_getScroll(), - i = k.w, - e = k.h, - g = m.x, - d = m.y; - c = $(c); - if (b == null) { - b = [] - } else { - if (typeof b == "number") { - b = [b] - } - } - l = b.length; - if (l == 0) { - b[0] = b[1] = b[2] = b[3] = 0 - } else { - if (l == 1) { - b[1] = b[2] = b[3] = b[0] - } else { - if (l == 2) { - b[2] = b[0]; - b[3] = b[1] - } else { - if (l == 3) { - b[3] = b[1] - } - } - } - } - l = ac(c); - var a = l[0] - b[3], - h = l[1] - b[0], - j = l[0] + c.offsetWidth + b[1], - f = l[1] + c.offsetHeight + b[2]; - if (j - a > i || a < g) { - g = a - } else { - if (j - i > g) { - g = j - i - } - } - if (f - h > e || h < d) { - d = h - } else { - if (f - e > d) { - d = f - e - } - } - scrollTo(g, d) +function g_scrollTo(n, p) { + var + _, + windowSize = g_getWindowSize(), + scroll = g_getScroll(), + bcw = windowSize.w, + bch = windowSize.h, + bsl = scroll.x, + bst = scroll.y; + + n = $(n); + + // Padding + if (p == null) { + p = []; + } + else if (typeof p == 'number') { + p = [p]; + } + + _ = p.length; + if (_ == 0) { + p[0] = p[1] = p[2] = p[3] = 0; + } + else if (_ == 1) { + p[1] = p[2] = p[3] = p[0]; + } + else if (_ == 2) { + p[2] = p[0]; + p[3] = p[1]; + } + else if (_ == 3) { + p[3] = p[1]; + } + + _ = ac(n); + + var + nl = _[0] - p[3], + nt = _[1] - p[0], + nr = _[0] + n.offsetWidth + p[1], + nb = _[1] + n.offsetHeight + p[2]; + + if (nr - nl > bcw || nl < bsl) { + bsl = nl; + } + else if (nr - bcw > bsl) { + bsl = nr - bcw; + } + + if (nb - nt > bch || nt < bst) { + bst = nt; + } + else if (nb - bch > bst) { + bst = nb - bch; + } + + scrollTo(bsl, bst); } + function g_addCss(b) { var c = ce("style"); c.type = "text/css"; @@ -3642,19 +3809,20 @@ var Menu = { } return a }, - fixUrls: function(g, c, e, b, f) { - if (!f) { - f = 0 + fixUrls: function(menu, url, hash, opt, depth) { + if (!depth) { + depth = 0 } - for (var d = 0, a = g.length; d < a; ++d) { - if (g[d][2] == null) { - g[d][2] = c + g[d][0] + (e ? e: "") + for (var i = 0, len = menu.length; i < len; ++i) { + if (menu[i][2] == null) { + menu[i][2] = url + menu[i][0] + (hash ? hash : "") } - if (g[d][3]) { - if (b == true || (typeof b == "object" && b[f] == true)) { - Menu.fixUrls(g[d][3], c, e, b, f + 1) - } else { - Menu.fixUrls(g[d][3], c + g[d][0] + ".", e, b, f + 1) + if (menu[i][3]) { + if (opt == true || (typeof opt == "object" && opt[depth] == true)) { + Menu.fixUrls(menu[i][3], url, hash, opt, depth + 1) + } + else { + Menu.fixUrls(menu[i][3], url + menu[i][0] + ".", hash, opt, depth + 1) } } } diff --git a/template/js/locale_dede.js b/template/js/locale_dede.js index 28e7b9fd..f4bde372 100644 --- a/template/js/locale_dede.js +++ b/template/js/locale_dede.js @@ -3671,27 +3671,85 @@ var LANG = { teamcontrib5v5: "5v5 Arena-Teambeteiligung" }, + pr_notice: 'Zum ersten Mal hier? – Seid nicht schüchtern! Schaut ruhig mal auf unserer Hilfeseite (zurzeit noch unübersetzt) nach!   Schließen', + pr_datasource: 'Daten in dieser Registerkarte wurden das letzte Mal $2 von $1 durch den Wowhead-Client aktualisiert.', + pr_purgedata: "Klickt, um alle Abschlussdaten in der aktuellen Registerkarte zu löschen.
Nur der Benuzter, der die Daten hochgeladen hat, darf sie löschen.", + + message_nocharacterselected: "Es wurden keine Charakter ausgewählt.", + message_toomanycharacters: "Bitte wählt nur 1 Charakter.", + message_noprofileselected: "Es wurden keine Profile ausgewählt.", + message_norowselected: "Bitte wählt einen oder mehrere Gegenstände zum $1 von dieser Liste.", + message_characterresync: "Eine Resynchronisierung wurde für die ausgewählten Charakter angefordert.", + message_resyncerror: "Ein Fehler trat bei der Resynchronisierung auf:", + message_saveerror: "Fehler: Euer Profil konnte nicht gespeichert werden. Normale Konten haben eine Beschränkung auf 10 Profile. Bitte löscht einige von Eurer Benutzerseite oder registriert Euer Konto für Premium für mehr Platz.", + message_saveok: "Speichern erfolgreich!", + message_saveasinvalidname: "Ungültiger Name.", + message_invalidlevel: "Todesritter müssen mindestens Stufe 55 sein.", + message_missingregion: "Bitte wählt eine Region.", + message_missingrealm: "Bitte wählt einen Realm.", + message_missingcharacter: "Bitte gebt einen Charakternamen ein.", + message_profilenotsaved: "$1Achtung:$2 Eure Änderungen wurden nicht gespeichert!", + message_nosignatureselected: "Keine Signaturen ausgewählt.", + message_toomanysignatures: "Bitte wählt nur 1 Signatur.", + message_nosigbookmarks: "Ihr habt Eurem Benutzerprofil keine Charaktere hinzugefügt. Bitte fügt einige hinzu, um fortzusetzen.", + message_bookmarkforsig: "Bitte fügt diesen Charakter zu Eurem Benutzerprofil hinzu, bevor Ihr eine Signatur erstellt.", + pr_dialog_level: "Stufe: ", - pr_menu_clearenh: "Verbesserungen entfernen", - pr_menu_addsubitem: "Zufällige Eigenschaft hinzufügen", - pr_menu_repsubitem: "Zufällige Eigenschaft ersetzen", - pr_menu_addenchant: "Verzauberung hinzufügen...", - pr_menu_repenchant: "Verzauberung ersetzen...", - pr_menu_addgem: "Edelstein hinzufügen...", - pr_menu_repgem: "Edelstein ersetzen...", - pr_menu_extrasock: "Zusätzlicher Sockel", - pr_note_source: "Quelle: ", - pr_note_all: "Alle", - pr_note_items: "Gegenstände", - pr_note_profs: "Berufe", - pr_note_bc: "BC", - pr_note_wotlk: "WotLK", - pr_note_color: "Farbe: ", - pr_note_match: "Match", + + menu_charlookup: "Nach Namen suchen...", + menu_newprofile: "Neues individuelles Profil", + menu_chooseclassspec: "Wählt Eure Klasse/Spezialisierung", + + pr_menu_equip: "Anlegen...", + pr_menu_replace: "Ersetzen...", + pr_menu_add: "Hinzufügen...", + pr_menu_unequip: "Ablegen", + pr_menu_remove: "Entfernen", + pr_menu_addgem: "Edelstein hinzufügen...", + pr_menu_repgem: "Edelstein ersetzen...", + pr_menu_addenchant: "Verzauberung hinzufügen...", + pr_menu_repenchant: "Verzauberung ersetzen...", + pr_menu_addsubitem: "Zufällige Eigenschaft hinzufügen", + pr_menu_repsubitem: "Zufällige Eigenschaft ersetzen", + pr_menu_extrasock: "Zusätzlicher Sockel", + pr_menu_display: "Vorschau", + pr_menu_clearenh: "Verbesserungen entfernen", + pr_menu_links: "Links", + pr_menu_compare: "Vergleichen", + pr_menu_upgrades: "Bessere Gegenstände finden", + pr_menu_whowears: "Wer trägt dies?", + pr_noneitem: "Nichts", pr_nonegem: "Nichts", pr_noneenchant: "Nichts", + pr_note_color: "Farbe: ", + pr_note_source: "Quelle: ", + pr_note_view: "Anzeigen: ", + pr_note_type: "Art: ", + pr_note_name: "Name: ", + pr_note_family: "Familie: ", + pr_note_sort: "Sortieren nach: ", + + ddaysago: "vor $1 Tagen", + + pr_note_all: "Alle", + pr_note_bc: "BC", + pr_note_subcategories: "Unterkategorien", + pr_note_earned: "Errungen", + pr_note_complete: "Komplett", + pr_note_incomplete: "Unvollständig", + pr_note_excluded: "Ausgeschlossen", + pr_note_items: "Gegenstände", + pr_note_match: "Verwendete Filter", + pr_note_profs: "Berufe", + pr_note_wotlk: "WotLK", + pr_note_usable: "Benutzbar", + pr_note_known: "Bekannt", + pr_note_missing: "Fehlend", + pr_note_normal: "Normal", + pr_note_exotic: "Exotisch", + su_notice: 'Euer erstes Mal? Nur keine falsche Scheu! Schaut einfach auf unsere Hilfeseite!', su_itemtip: "Tipp: Shift- oder rechtsklickt Gegenstände für mehr Optionen.", diff --git a/template/js/locale_enus.js b/template/js/locale_enus.js index e1842247..a6dcee6e 100644 --- a/template/js/locale_enus.js +++ b/template/js/locale_enus.js @@ -3716,27 +3716,85 @@ var LANG = { teamcontrib5v5: "5v5 arena team contribution" }, + pr_notice: 'First time? – Don\'t be shy! Just check out our Help page!   close', + pr_datasource: 'Data in this tab was last updated $2 by $1 using the Wowhead Client.', + pr_purgedata: "Click to delete all completion data in the current tab.
Only the user who uploaded the data may purge it.", + + message_nocharacterselected: "No characters selected.", + message_toomanycharacters: "Please select only 1 character.", + message_noprofileselected: "No profiles selected.", + message_norowselected: "Please select one or more items to $1 from this list.", + message_characterresync: "An Armory resync has been requested for the selected characters.", + message_resyncerror: "An error occurred when resyncing:", + message_saveerror: "Error: Your profile could not be saved. Wowhead accounts have a limit of ten profiles. Please delete some from your user page, or upgrade your account to Premium for more space.", + message_saveok: "Save successful!", + message_saveasinvalidname: "Invalid name.", + message_invalidlevel: "Death Knights must be at least level 55.", + message_missingregion: "Please select a region.", + message_missingrealm: "Please select a realm.", + message_missingcharacter: "Please enter a character name.", + message_profilenotsaved: "$1Warning:$2 Your changes haven't been saved!", + message_nosignatureselected: "No signatures selected.", + message_toomanysignatures: "Please select only 1 signature.", + message_nosigbookmarks: "You have not bookmarked any characters. Please add some to continue.", + message_bookmarkforsig: "Please bookmark this character before creating a signature.", + pr_dialog_level: "Level:", - pr_menu_clearenh: "Clear Enhancements", - pr_menu_addsubitem: "Add Random Property...", - pr_menu_repsubitem: "Replace Random Property...", - pr_menu_addenchant: "Add Enchant...", - pr_menu_repenchant: "Replace Enchant...", - pr_menu_addgem: "Add Gem...", - pr_menu_repgem: "Replace Gem...", - pr_menu_extrasock: "Extra Socket", - pr_note_source: "Source: ", - pr_note_all: "All", - pr_note_items: "Items", - pr_note_profs:"Professions", - pr_note_bc: "BC", - pr_note_wotlk: "WotLK", - pr_note_color: "Color: ", - pr_note_match: "Match", + + menu_charlookup: "Lookup by name...", + menu_newprofile: "New Custom Profile", + menu_chooseclassspec: "Choose Your Class/Spec", + + pr_menu_equip: "Equip...", + pr_menu_replace: "Replace...", + pr_menu_add: "Add...", + pr_menu_unequip: "Unequip", + pr_menu_remove: "Remove", + pr_menu_addgem: "Add Gem...", + pr_menu_repgem: "Replace Gem...", + pr_menu_addenchant: "Add Enchant...", + pr_menu_repenchant: "Replace Enchant...", + pr_menu_addsubitem: "Add Random Property...", + pr_menu_repsubitem: "Replace Random Property...", + pr_menu_extrasock: "Extra Socket", + pr_menu_display: "Display on Character", + pr_menu_clearenh: "Clear Enhancements", + pr_menu_links: "Links", + pr_menu_compare: "Compare", + pr_menu_upgrades: "Find Upgrades", + pr_menu_whowears: "Who Wears This?", + pr_noneitem: "None", pr_nonegem: "None", pr_noneenchant: "None", + pr_note_color: "Color: ", + pr_note_source: "Source: ", + pr_note_view: "View: ", + pr_note_type: "Type: ", + pr_note_name: "Name: ", + pr_note_family: "Family: ", + pr_note_sort: "Sort by: ", + + ddaysago: "$1 days ago", + + pr_note_all: "All", + pr_note_bc: "BC", + pr_note_subcategories: "Subcategories", + pr_note_earned: "Earned", + pr_note_complete: "Complete", + pr_note_incomplete: "Incomplete", + pr_note_excluded: "Excluded", + pr_note_items: "Items", + pr_note_match: "Match", + pr_note_profs: "Professions", + pr_note_wotlk: "WotLK", + pr_note_usable: "Usable", + pr_note_known: "Known", + pr_note_missing: "Missing", + pr_note_normal: "Normal", + pr_note_exotic: "Exotic", + su_notice: 'First time? – Don\'t be shy! Just check out our Help page!', su_itemtip: "Tip: Shift or right-click items for more options.", diff --git a/template/js/locale_eses.js b/template/js/locale_eses.js index a1cf1679..ed38eb92 100644 --- a/template/js/locale_eses.js +++ b/template/js/locale_eses.js @@ -3674,21 +3674,29 @@ var LANG = { teamcontrib5v5: "Contribución de equipo de arena 5v5" }, - pr_notice:'¿La primera vez? – ¡No temas! ¡Visita nuestra página de ayuda!   cerrar', - pr_datasource:'Los datos de esta pestaña se actualizarón por última vez el $2 por $1 usando el Cliente Wowhead.', - message_nocharacterselected:"No hay personajes seleccionados.", - message_noprofileselected:"No hay perfiles seleccionados.", - message_norowselected:"Por favor, selecciona uno o más objetos a $1 de esta lista.", - message_characterresync:"Se ha solicitado una resincronación para los personajes seleccionados.", - message_resyncerror:"Ha ocurrido un error al resincronizar este personaje:", - message_saveerror:"Error: No se pudo guardar el perfil. Las cuentas de Wowhead tienen un límite de 10 perfiles. Por favor, borra algunos de tu página de usuario o actualiza tu cuenta a Premium para tener más espacio.", - message_saveok:"¡Guardado completado!", - message_saveasinvalidname:"Nombre inválido.", - message_invalidlevel:"Los Caballeros de la Muerte deben tener al menos nivel 55.", - message_missingregion:"Por favor, selecciona una región.", - message_missingrealm:"Por favor, selecciona el reino.", - message_missingcharacter:"Por favor, introduce el nombre de un personaje.", - message_profilenotsaved:"$1Atención:$2 ¡Los cambios no se guardaron!", + pr_notice: '¿La primera vez? – ¡No temas! ¡Visita nuestra página de ayuda!   cerrar', + pr_datasource: 'Los datos de esta pestaña se actualizarón por última vez el $2 por $1 usando el Cliente Wowhead.', + pr_purgedata: "Haz click para eliminar todos los datos recogidos en la pestaña actual.
Solo aquel que ha subido los datos puede hacerlo.", + + message_nocharacterselected: "No hay personajes seleccionados.", + message_toomanycharacters: "Por favor, selecciona solo 1 personaje.", + message_noprofileselected: "No hay perfiles seleccionados.", + message_norowselected: "Por favor, selecciona uno o más objetos a $1 de esta lista.", + message_characterresync: "Se ha solicitado una resincronación para los personajes seleccionados.", + message_resyncerror: "Ha ocurrido un error al resincronizar:", + message_saveerror: "Error: No se pudo guardar el perfil. Las cuentas de Wowhead tienen un límite de 10 perfiles. Por favor, borra algunos de tu página de usuario o actualiza tu cuenta a Premium para tener más espacio.", + message_saveok: "¡Guardado completado!", + message_saveasinvalidname: "Nombre inválido.", + message_invalidlevel: "Los Caballeros de la Muerte deben tener al menos nivel 55.", + message_missingregion: "Por favor, selecciona una región.", + message_missingrealm: "Por favor, selecciona el reino.", + message_missingcharacter: "Por favor, introduce el nombre de un personaje.", + message_profilenotsaved: "$1Atención:$2 ¡Los cambios no se guardaron!", + message_nosignatureselected: "No hay firmas seleccionadas.", + message_toomanysignatures: "Por favor, selecciona sólo una firma.", + message_nosigbookmarks: "No has marcado como favorito ningún personaje. Añade alguno para continuar.", + message_bookmarkforsig: "Por favor, añade a favoritos este personaje antes de crear una firma.", + confirm_linkcharacter:"Este personaje se añadirá a tu lista de personajes.\n\n¿Quieres continuar?", confirm_linkedcharacter:"Este personaje se ha añadido a tu lista.\n\n¿Quieres verlo ahora?", confirm_unlinkcharacter:"¿Estás seguro de que quieres eliminar los personajes seleccionados de tu lista?", @@ -3793,27 +3801,30 @@ var LANG = { pr_qf_raid:"Banda", pr_qf_n:"10", pr_qf_h:"25", - menu_charlookup:"Búsqueda por Nombre...", - menu_newprofile:"Nuevo perfil personalizado", - menu_chooseclassspec:"Elige tu Clase/Especialización", - pr_menu_equip:"Equipar...", - pr_menu_replace:"Reemplazar...", - pr_menu_add:"Añadir...", - pr_menu_unequip:"Desequipar", - pr_menu_remove:"Eliminar", - pr_menu_addgem:"Añadir gema...", - pr_menu_repgem:"Reemplazar Gema...", - pr_menu_addenchant:"Añadir encantamiento...", - pr_menu_repenchant:"Reemplazar Encantamiento...", - pr_menu_addsubitem:"Añadir propiedad aleatoria...", - pr_menu_repsubitem:"Reemplazar propiedad aleatoria...", - pr_menu_extrasock:"Hueco extra", - pr_menu_display:"Previsualizar", - pr_menu_clearenh:"Limpiar mejoras", - pr_menu_links:"Enlaces", - pr_menu_compare:"Comparar", - pr_menu_upgrades:"Buscar mejoras", - pr_menu_whowears:"¿Quién lleva esto?", + + menu_charlookup: "Búsqueda por Nombre...", + menu_newprofile: "Nuevo perfil personalizado", + menu_chooseclassspec: "Elige tu Clase/Especialización", + + pr_menu_equip: "Equipar...", + pr_menu_replace: "Reemplazar...", + pr_menu_add: "Añadir...", + pr_menu_unequip: "Desequipar", + pr_menu_remove: "Eliminar", + pr_menu_addgem: "Añadir gema...", + pr_menu_repgem: "Reemplazar Gema...", + pr_menu_addenchant: "Añadir encantamiento...", + pr_menu_repenchant: "Reemplazar Encantamiento...", + pr_menu_addsubitem: "Añadir propiedad aleatoria...", + pr_menu_repsubitem: "Reemplazar propiedad aleatoria...", + pr_menu_extrasock: "Hueco extra", + pr_menu_display: "Previsualizar", + pr_menu_clearenh: "Limpiar mejoras", + pr_menu_links: "Enlaces", + pr_menu_compare: "Comparar", + pr_menu_upgrades: "Buscar mejoras", + pr_menu_whowears: "¿Quién lleva esto?", + pr_queue_unknown:"Desconocido", pr_queue_noprocess:"La cola no se está procesando actualmente.", pr_queue_resyncreq:"Se ha seleccionado una resincronización para este personaje.", @@ -3939,32 +3950,35 @@ var LANG = { pr_statstt_str:"Aumenta el poder de ataque en $1", pr_statstt_str2:"Aumenta el poder de ataque en $1
Aumenta el valor de bloqueo en $2", pr_ach_overall:"Progreso global", - pr_note_color:"Color: ", - pr_note_source:"Fuente: ", - pr_note_view:"Vista: ", - pr_note_type:"Tipo: ", - pr_note_name:"Nombre: ", - pr_note_family:"Familia: ", - pr_note_sort:"Ordenar por: ", - ddaysago:"Hace $1 días", - pr_note_all:"Todo", - pr_note_bc:"BC", - pr_note_subcategories:"Subcategorías", - pr_note_earned:"Logrados", - pr_note_complete:"Completo", - pr_note_incomplete:"Incompleto", - pr_note_excluded:"Excluido", - pr_note_items:"Objetos", - pr_note_match:"Aplicar", - pr_note_profs:"Profesiones", - pr_note_wotlk:"WotLK", - pr_note_usable:"Utilizable", - pr_note_known:"Conocido", - pr_note_missing:"Faltan", - pr_note_normal:"Normal", - pr_note_exotic:"Exótica", - pr_note_gearscore:"Puntuación de equipo", - pr_note_weighted:"Valorado", + + pr_note_color: "Color: ", + pr_note_source: "Fuente: ", + pr_note_view: "Vista: ", + pr_note_type: "Tipo: ", + pr_note_name: "Nombre: ", + pr_note_family: "Familia: ", + pr_note_sort: "Ordenar por: ", + + ddaysago: "Hace $1 días", + + pr_note_all: "Todo", + pr_note_bc: "BC", + pr_note_subcategories: "Subcategorías", + pr_note_earned: "Logrados", + pr_note_complete: "Completo", + pr_note_incomplete: "Incompleto", + pr_note_excluded: "Excluido", + pr_note_items: "Objetos", + pr_note_match: "Aplicar", + pr_note_profs: "Profesiones", + pr_note_wotlk: "WotLK", + pr_note_usable: "Utilizable", + pr_note_known: "Conocido", + pr_note_missing: "Faltan", + pr_note_normal: "Normal", + pr_note_exotic: "Exótica", + + pr_note_weighted:"Valorado", /* some relic text..? */ su_notice: '¿Tu primera vez? ¡No seas vergonzoso! !Mira nuestra página de ayuda!', su_itemtip: "Consejo: Usa Shift o Click derecho en los objetos para ver más opciones.", diff --git a/template/js/locale_frfr.js b/template/js/locale_frfr.js index dcb43c2b..36d869fb 100644 --- a/template/js/locale_frfr.js +++ b/template/js/locale_frfr.js @@ -3660,21 +3660,29 @@ var LANG = { teamcontrib5v5: "Contribution d'un équipe d'aréna 5v5" }, - pr_notice:'Première fois? Ne soyez pas gêné! Visitez notre page d\'aide!   close', - pr_datasource:'Les données dans cette table ont été updatées $2 par $1 en utilisant le Client Wowhead.', - message_nocharacterselected:"Aucun personnages sélectionnés.", - message_noprofileselected:"Aucun profile de sélectionné.", - message_norowselected:"Veuillez sélectionner un ou plusieurs objets à $1 de cette liste.", - message_characterresync:"Une resynchronisation de l'Armurerie a été demandé pour le personnage sélectionné.", - message_resyncerror:"Une erreur est survenu lors de la resynchronisation de ce personnage:", - message_saveerror:"Erreur: Votre profile n'a pas pu être sauvegardé. Les comptes Wowhead ont une limite de dix profiles. Veuillez en supprimer quelques uns de votre page d'usager ou passez à un compte Premium pour avoir plus de place.", - message_saveok:"Sauvegarde réussi!", - message_saveasinvalidname:"Nom invalide.", - message_invalidlevel:"Les Chevaliers de la Mort doivent être au moins niveau 55.", - message_missingregion:"Veuillez sélectionner une région.", - message_missingrealm:"Veuillez sélectionner un royaume.", - message_missingcharacter:"Veuillez entrer un nom de personnage.", - message_profilenotsaved:"$1Attention:$2 Vos changement n'ont pas été sauvegardés!", + pr_notice: 'Première fois? Ne soyez pas gêné! Visitez notre page d\'aide!   close', + pr_datasource: 'Les données dans cette table ont été updatées $2 par $1 en utilisant le Client Wowhead.', + pr_purgedata: "Cliquer pour supprimer toutes les données d'accomplissement dans l'onglet présent.
Seul l'utilisateur qui a uploadé les données peut les effacer.", + + message_nocharacterselected: "Aucun personnage sélectionné.", + message_toomanycharacters: "Veuillez sélectionner 1 seul personnage.", + message_noprofileselected: "Aucun profile de sélectionné.", + message_norowselected: "Veuillez sélectionner un ou plusieurs objets à $1 de cette liste.", + message_characterresync: "Une resynchronisation de l'Armurerie a été demandée pour le personnage sélectionné.", + message_resyncerror: "Une erreur est survenue lors de la resynchronisation de ce personnage:", + message_saveerror: "Erreur: Votre profil n'a pas pu être sauvegardé. Les comptes Wowhead ont une limite de dix profils. Veuillez en supprimer quelques-uns de votre page d'utilisateur ou passez à un compte Premium pour avoir plus de place.", + message_saveok: "Sauvegarde réussi!", + message_saveasinvalidname: "Nom invalide.", + message_invalidlevel: "Les Chevaliers de la Mort doivent être au moins niveau 55.", + message_missingregion: "Veuillez sélectionner une région.", + message_missingrealm: "Veuillez sélectionner un royaume.", + message_missingcharacter: "Veuillez entrer un nom de personnage.", + message_profilenotsaved: "$1Attention:$2 Vos changements n'ont pas été sauvegardés!", + message_nosignatureselected: "Aucune signature de sélectionnée.", + message_toomanysignatures: "Veuillez sélectionner 1 seule signature.", + message_nosigbookmarks: "Vous n'avez signé aucun personnage. Veuillez en ajouter pour continuer.", + message_bookmarkforsig: "Veuillez mettre ce personnage en favori avant de créer une signature.", + confirm_linkcharacter:"Ce personnage va être ajouté à votre liste de personnage.\n\nVoulez-vous continuer?", confirm_linkedcharacter:"Ce personnage a été ajouté a votre liste.\n\nVoulez-vous être rediriger?", confirm_unlinkcharacter:"Êtes vous sûr que vous voulez supprimer le personnage sélectionné de votre liste?", @@ -3781,28 +3789,31 @@ var LANG = { pr_qf_notsaved:"Le profile n'a pas été sauvegardé!", pr_qf_raid:"Raid", pr_qf_n:"10", - pr_qf_h:"25", - menu_charlookup:"Recherche par nomo...", - menu_newprofile:"Nouveau Profile Personalisé", - menu_chooseclassspec:"Choisissez Votre Classe/Spec", - pr_menu_equip:"Équipe...", - pr_menu_replace:"Remplacer...", - pr_menu_add:"Ajouter...", - pr_menu_unequip:"Déséquiper", - pr_menu_remove:"Enlever", - pr_menu_addgem:"Ajouter une gemme...", - pr_menu_repgem:"Remplacer la gemme...", - pr_menu_addenchant:"Ajouter un enchantement...", - pr_menu_repenchant:"Remplacer l'enchantement...", - pr_menu_addsubitem:"Ajouter enchantement aléatoire...", - pr_menu_repsubitem:"Remplacer la propriété aléatoire...", - pr_menu_extrasock:"Châsse supplémentaire", - pr_menu_display:"Essayage", - pr_menu_clearenh:"Nettoyer les améliorations", - pr_menu_links:"Liens", - pr_menu_compare:"Comparer", - pr_menu_upgrades:"Trouver des améliorations", - pr_menu_whowears:"Qui porte ceci?", + pr_qf_h:"25", + + menu_charlookup: "Recherche par nomo...", + menu_newprofile: "Nouveau Profile Personalisé", + menu_chooseclassspec: "Choisissez Votre Classe/Spec", + + pr_menu_equip: "Équipe...", + pr_menu_replace: "Remplacer...", + pr_menu_add: "Ajouter...", + pr_menu_unequip: "Déséquiper", + pr_menu_remove: "Enlever", + pr_menu_addgem: "Ajouter une gemme...", + pr_menu_repgem: "Remplacer la gemme...", + pr_menu_addenchant: "Ajouter un enchantement...", + pr_menu_repenchant: "Remplacer l'enchantement...", + pr_menu_addsubitem: "Ajouter enchantement aléatoire...", + pr_menu_repsubitem: "Remplacer la propriété aléatoire...", + pr_menu_extrasock: "Châsse supplémentaire", + pr_menu_display: "Essayage", + pr_menu_clearenh: "Nettoyer les améliorations", + pr_menu_links: "Liens", + pr_menu_compare: "Comparer", + pr_menu_upgrades: "Trouver des améliorations", + pr_menu_whowears: "Qui porte ceci?", + pr_queue_unknown:"Inconnu", pr_queue_noprocess:"La file d'attente n'est pas en cours de traitement.", pr_queue_resyncreq:"Une resynchronisation complète de l'Armurerie pour ce personnage a été demandée.", @@ -3928,33 +3939,36 @@ var LANG = { pr_statstt_str:"Augmente la puissance d'attaque de $1", pr_statstt_str2:"Augmente la puissance d'attaque de $1
Augmente la valeur de blocage de $2", pr_ach_overall:"Progrès global", - pr_note_color:"Couleur : ", - pr_note_source:"Source : ", - pr_note_view:"Vue : ", - pr_note_type:"Type : ", - pr_note_name:"Nom : ", - pr_note_family:"Famille : ", - pr_note_sort:"Trier par : ", - ddaysago:"$1 jours avant", - pr_note_all:"Tous", - pr_note_bc:"BC", - pr_note_subcategories:"Sous-catégories", - pr_note_earned:"Accomplis", - pr_note_complete:"Complète", - pr_note_incomplete:"Incomplet", - pr_note_excluded:"Exclus", - pr_note_items:"Objets", - pr_note_match:"Critère", - pr_note_profs:"Métiers", - pr_note_wotlk:"WotLK", - pr_note_usable:"Utilisable", - pr_note_known:"Connu", - pr_note_missing:"Manquant", - pr_note_normal:"Standard", - pr_note_exotic:"Exotique", - pr_note_gearscore:"Score d'équipement", - pr_note_weighted:"Valorisé", - + + pr_note_color: "Couleur : ", + pr_note_source: "Source : ", + pr_note_view: "Vue : ", + pr_note_type: "Type : ", + pr_note_name: "Nom : ", + pr_note_family: "Famille : ", + pr_note_sort: "Trier par : ", + + ddaysago: "$1 jours avant", + + pr_note_all: "Tous", + pr_note_bc: "BC", + pr_note_subcategories: "Sous-catégories", + pr_note_earned: "Accomplis", + pr_note_complete: "Complète", + pr_note_incomplete: "Incomplet", + pr_note_excluded: "Exclus", + pr_note_items: "Objets", + pr_note_match: "Critère", + pr_note_profs: "Métiers", + pr_note_wotlk: "WotLK", + pr_note_usable: "Utilisable", + pr_note_known: "Connu", + pr_note_missing: "Manquant", + pr_note_normal: "Standard", + pr_note_exotic: "Exotique", + + pr_note_weighted:"Valorisé", /* some relic text..? */ + su_notice: 'Première visite? – Ne soyez pas intimidé! Vous n\'avez qu\'à lire notre page d\'aide !', su_itemtip: "Conseil: Tenir Shift enfoncé ou clique-droit sur l'objet pour plus d'options.", @@ -3969,22 +3983,22 @@ var LANG = { su_additem: "Objet", su_addset: "Ensemble d'objets", su_toggle: "Cliquez pour alterner l'affichage", - + su_preset: "Prédéterminée : ", su_name: "Nom : ", su_level: "Niveau : ", su_addweight: "Ajouter un autre facteur", su_applyweight: "Ajouter", su_resetweight: "Réinitialiser", - + su_export: "Exporter", su_viewin3d: "Voir en 3D", su_split: "Séparer", - + su_customscale: "Échelle personalisée #$1", su_comparing: "Comparaison de ", su_comparewith: " avec ", - + su_note_name: "Nom : ", su_searching3: 'En train de chercher pour les objets nommés "$1"...', su_searching4: 'En train de chercher pour les ensembles d\'objets nommés "$1"...', @@ -3993,18 +4007,18 @@ var LANG = { su_added3: 'Ajout de l\'objet [$3] pour comparaison.', su_added4: 'Ajout de l\'ensemble d\'objet [$3] pour comparaison.', su_noresults: 'Aucun résultat trouvé pour "$1"!', - + tooltip_setfocus: 'Établir le focus
Compare toutes les autres colonnes à celle-ci.', tooltip_removefocus: "Enlever le focus", tooltip_gains: "Bonus que vous obtenez au delà des
caractéristiques communes à toutes les colonnes.", - + instancereqlevel_tip: "Niveau requis pour entrer dans l'instance", lfgreqlevel_tip: "Niveau requis pour joindre la file d'attente de l'instance via
l'outil de CG.", - + message_deleteitem: "Supprimer $1?", message_deletegroup: "Supprimer ce groupe ?", achievements_label: "Haut-faits:", - + tc_rank: "Rang $1/$2", tc_tier: "Requiert $1 points en $2", tc_prereq: "Requiert $1 point en $2", @@ -4055,18 +4069,18 @@ var LANG = { tc_remgly2: "Maj-click pour enlever", tc_nonegly: "Aucun", tc_glyphnote: "Certains glyphes ont été filtrés à cause de la restriction de niveau.", - + tc_viewtalents: "Voir les arbres de talent", tc_viewsummary: "Voir les sommaires", - + alert_invalidurl: "URL invalide.", alert_chooseclass: "Veuillez d'abord sélectionner une classe.", alert_choosefamily: "Veuillez d'abord sélectionner une famille de familier.", alert_buildempty: "Votre template est vide.", - + prompt_importwh: "Veuillez coller l'URL d'un template fait avec le calculateur de talents de Wowhead :", prompt_importblizz: "Veuillez coller l'URL d'un template fait avec le calculateur de talents de Blizzard :", - + stackof_format: "Paquet de $1: $2%", charactersremaining_format: "$1 caractères restants.", diff --git a/template/js/locale_ruru.js b/template/js/locale_ruru.js index 3795f867..696e3d50 100644 --- a/template/js/locale_ruru.js +++ b/template/js/locale_ruru.js @@ -3304,7 +3304,7 @@ var LANG = { queststart: [ [3, "Предмет"], [1, "НИП"], [2, "Объект"] ], questend: [ [1, "НИП"], [2, "Объект"] ], spellsource: [ - [1, "Все"], [3, "Ремесло"], [9, "Открытие"], [4, "Добыча"], [6, "Задание"], + [1, "Все"], [3, "Ремесло"], [9, "Открытие"], [4, "Добыча"], [6, "Задание"], [10, "Талант"], [8, "Тренер"], [7, "Продавец"], [2, "Нет"] ], itemsource: [ @@ -3330,7 +3330,7 @@ var LANG = { [22448, "Малый радужный осколок"], [14343, "Малый сверкающий осколок"], [11177, "Малый светозарный осколок"], [11138, "Малый светящийся осколок"], [34052, "Осколок грез"], [10998, "Простая Астральная субстанция"],[16202, "Простая вечная субстанция"], [22447, "Простая планарная субстанция"],[11174, "Простая субстанция Пустоты"], [11134, "Простая таинственная субстанция"], [11083, "Пыль духа"], [16204, "Пыль иллюзий"], [11137, "Пыль провидения"], [11176, "Сонная пыль"], [10940, "Странная пыль"], - [22445, "Чародейная пыль"] + [22445, "Чародейная пыль"] ], flags: [ [1, '0x00000001'], [2, '0x00000002'], [3, '0x00000004'], [4, '0x00000008'], [5, '0x00000010'], @@ -3401,7 +3401,7 @@ var LANG = { uniqueequipped: "Не более 1 в вооружении", usableinarenas: "Используется на аренах", usablewhenshapeshifted: "Используется в формах", - + sepsource: "Источник", craftedprof: "Ремесленное производство", dropsin: "Добыча из...", @@ -3661,22 +3661,29 @@ var LANG = { teamcontrib5v5: "Очки команды арены 5х5" }, - pr_notice:'Первый раз? – Не стесняйтесь! Взгляните на страницу помощи!   закрыть', - pr_datasource:'Данные в этой вкладке были последний раз обновлены пользователем $1 $2 используя Wowhead Client.', + pr_notice: 'Первый раз? – Не стесняйтесь! Взгляните на страницу помощи!   закрыть', + pr_datasource: 'Данные в этой вкладке были последний раз обновлены пользователем $1 $2 используя Wowhead Client.', + pr_purgedata: "Нажмите, чтобы удалить все собранные данные в текущей вкладке.
Только тот, кто загрузил данные, может их удалить.", + + message_nocharacterselected: "Выберите персонажей.", + message_toomanycharacters: "Выберите только одного персонажа.", + message_noprofileselected: "Выберите профили.", + message_norowselected: "Выберите один или более пунктов что бы $1 из списка.", + message_characterresync: "Запущена ресинхронизация с Оружейной для выбранных персонажей.", + message_resyncerror: "Во время обработки данных произошла ошибка:", + message_saveerror: "Ошибка: Профиль не может быть сохранен. Учетные записи Wowhead имеют ограничение в 10 профилей. Пожалуйста, удалите несколько существующих профилей на вашей странице, или приобретите Премиум аккаунт для получения больших возможностей.", + message_saveok: "Успешно сохранено!", + message_saveasinvalidname: "Некорректное название.", + message_invalidlevel: "Рыцари Смерти должны быть 55-го уровня или выше.", + message_missingregion: "Требуется указать регион.", + message_missingrealm: "Выберите игровой мир.", + message_missingcharacter: "Введите имя персонажа.", + message_profilenotsaved: "$1Внимание:$2 Изменения не сохранены!", + message_nosignatureselected: "Нет подписей.", + message_toomanysignatures: "Пожалуйста, выберите только одну подпись.", + message_nosigbookmarks: "У вас нет персонажей в закладках. Чтобы продолжить, добавьте персонажа в закладки.", + message_bookmarkforsig: "Добавьте этого персонажа в закладки перед созданием подписи.", - message_nocharacterselected:"Выберите персонажей.", - message_noprofileselected:"Выберите профили.", - message_norowselected:"Выберите один или более пунктов что бы $1 из списка.", - message_characterresync:"Запущена ресинхронизация с Оружейной для выбранных персонажей.", - message_resyncerror:"Во время ресинхронизации персонажа произошла ошибка:", - message_saveerror:"Ошибка: Профиль не может быть сохранен. Учетные записи Wowhead имеют ограничение в 10 профилей. Пожалуйста, удалите несколько существующих профилей на вашей странице, или приобретите Премиум аккаунт для получения больших возможностей.", - message_saveok:"Успешно сохранено!", - message_saveasinvalidname:"Некорректное название.", - message_invalidlevel:"Рыцари Смерти должны быть 55-го уровня или выше.", - message_missingregion:"Требуется указать регион.", - message_missingrealm:"Выберите игровой мир.", - message_missingcharacter:"Введите имя персонажа.", - message_profilenotsaved:"$1Внимание:$2 Изменения не сохранены!", confirm_linkcharacter:"Этот персонаж будет добавлен в ваш список персонажей.\n\nВы действительно хотите продолжить?", confirm_linkedcharacter:"Этот персонаж добавлен в ваш список персонажей.\n\nПерейти к списку?", confirm_unlinkcharacter:"Вы уверены, что хотите удалить этого персонажа из списка своих персонажей?", @@ -3784,27 +3791,30 @@ var LANG = { pr_qf_raid:"Рейд", pr_qf_n:"10", pr_qf_h:"25", - menu_charlookup:"Поиск по имени...", - menu_newprofile:"Новый профиль", - menu_chooseclassspec:"Выберите класс/спек", - pr_menu_equip:"Одеть...", - pr_menu_replace:"Заменить...", - pr_menu_add:"Добавить...", - pr_menu_unequip:"Снять", - pr_menu_remove:"Удалить", - pr_menu_addgem:"Инкрустировать...", - pr_menu_repgem:"Заменить камень...", - pr_menu_addenchant:"Добавить улучшение...", - pr_menu_repenchant:"Заменить чары...", - pr_menu_addsubitem:"Добавить случайное свойство...", - pr_menu_repsubitem:"Заменить случайное улучшение...", - pr_menu_extrasock:"Дополнительное гнездо", - pr_menu_display:"Примерить", - pr_menu_clearenh:"Сбросить улучшения", - pr_menu_links:"Ссылки", - pr_menu_compare:"Сравнить", - pr_menu_upgrades:"Найти лучше", - pr_menu_whowears:"Кто носит это?", + + menu_charlookup: "Поиск по имени...", + menu_newprofile: "Новый профиль", + menu_chooseclassspec: "Выберите класс/спек", + + pr_menu_equip: "Одеть...", + pr_menu_replace: "Заменить...", + pr_menu_add: "Добавить...", + pr_menu_unequip: "Снять", + pr_menu_remove: "Удалить", + pr_menu_addgem: "Инкрустировать...", + pr_menu_repgem: "Заменить камень...", + pr_menu_addenchant: "Добавить улучшение...", + pr_menu_repenchant: "Заменить чары...", + pr_menu_addsubitem: "Добавить случайное свойство...", + pr_menu_repsubitem: "Заменить случайное улучшение...", + pr_menu_extrasock: "Дополнительное гнездо", + pr_menu_display: "Примерить", + pr_menu_clearenh: "Сбросить улучшения", + pr_menu_links: "Ссылки", + pr_menu_compare: "Сравнить", + pr_menu_upgrades: "Найти лучше", + pr_menu_whowears: "Кто носит это?", + pr_queue_unknown:"Неизвестно", pr_queue_noprocess:"Очередь синхронизации отключена.", pr_queue_resyncreq:"Запущена синхронизация с Оружейной для этого персонажа.", @@ -3930,32 +3940,35 @@ var LANG = { pr_statstt_str:"Увеличивает силу атаки на $1.", pr_statstt_str2:"Увеличивает силу атаки на $1.
Увеличивает показатель блокирования на $2.", pr_ach_overall:"Общий прогресс", - pr_note_color:"Цвет: ", - pr_note_source:"Источник: ", - pr_note_view:"Просмотр: ", - pr_note_type:"Тип: ", - pr_note_name:"Название: ", - pr_note_family:"Семейство: ", - pr_note_sort:"Сортировать: ", - ddaysago:"$1 дней назад", - pr_note_all:"Все", - pr_note_bc:"BC", - pr_note_subcategories:"Подкатегории", - pr_note_earned:"Заработано", - pr_note_complete:"Завершено", - pr_note_incomplete:"Не завершено", - pr_note_excluded:"Исключено", - pr_note_items:"Предметы", - pr_note_match:"Совпадение", - pr_note_profs:"Профессии", - pr_note_wotlk:"WotLK", - pr_note_usable:"Используется", - pr_note_known:"Известно", - pr_note_missing:"Отсутствует", - pr_note_normal:"Обычный", - pr_note_exotic:"Экзотический", - pr_note_gearscore:"Очки экипировки", - pr_note_weighted:"Взвешено", + + pr_note_color: "Цвет: ", + pr_note_source: "Источник: ", + pr_note_view: "Просмотр: ", + pr_note_type: "Тип: ", + pr_note_name: "Название: ", + pr_note_family: "Семейство: ", + pr_note_sort: "Сортировать: ", + + ddaysago: "$1 дней назад", + + pr_note_all: "Все", + pr_note_bc: "BC", + pr_note_subcategories: "Подкатегории", + pr_note_earned: "Заработано", + pr_note_complete: "Завершено", + pr_note_incomplete: "Не завершено", + pr_note_excluded: "Исключено", + pr_note_items: "Предметы", + pr_note_match: "Совпадение", + pr_note_profs: "Профессии", + pr_note_wotlk: "WotLK", + pr_note_usable: "Используется", + pr_note_known: "Известно", + pr_note_missing: "Отсутствует", + pr_note_normal: "Обычный", + pr_note_exotic: "Экзотический", + + pr_note_weighted:"Взвешено", /* some relic text..? */ su_notice: 'Впервые? Не стесняйтесь посетить нашу справочную страницу!', su_itemtip: "Подсказка: кликните мышью удерживая шифт или правой кнопкой для других опций.", @@ -4006,7 +4019,7 @@ var LANG = { message_deleteitem: "Удалить $1?", message_deletegroup: "Удалить эту группу?", achievements_label: "Достижения:", - + tc_rank: "Ранг $1/$2", tc_tier: "Требуется $1 очк. в талантах $2", tc_prereq: "Требуется $1 очк. в $2", @@ -4057,18 +4070,18 @@ var LANG = { tc_remgly2: "Щелкните левой кнопкой мыши удерживая шифт, что бы удалить", tc_nonegly: "Нет", tc_glyphnote: "Некоторые символы были убраны из списка из-за несоответствия уровню.", - + tc_viewtalents: "Открыть таланты", tc_viewsummary: "Открыть обзор", - + alert_invalidurl: "Неверная ссылка.", alert_chooseclass: "Выбирете класс.", alert_choosefamily: "Выбирете породу животного.", alert_buildempty: "У вас пустой шаблон.", - + prompt_importwh: "Вставьте ссылку на шаблон, сделанный в калькуляторе талантов Wowhead:", prompt_importblizz: "Вставьте ссылку на шаблон, сделанный в калькуляторе талантов Blizzard:", - + stackof_format: "$1 предмет: $2%", charactersremaining_format: "Осталось символов: $1", diff --git a/template/js/maps.js b/template/js/maps.js index d761cd75..0c99496b 100644 --- a/template/js/maps.js +++ b/template/js/maps.js @@ -1,17 +1,17 @@ function ma_Init() { - ma_AddOptions(ge('maps-ek'), [1, 3, 4, 8, 10, 11, 12, 28, 33, 36, 38, 40, 41, 44, 45, 46, 47, 51, 85, 130, 139, 267, 1497, 1519, 1537, 3430, 3433, 3487, 4080, 4298]); - ma_AddOptions(ge('maps-kalimdor'), [14, 15, 16, 17, 141, 148, 215, 331, 357, 361, 400, 405, 406, 440, 490, 493, 618, 1377, 1637, 1638, 1657, 3524, 3525, 3557]); - ma_AddOptions(ge('maps-outland'), [3483, 3518, 3519, 3520, 3521, 3522, 3523, 3703]); - ma_AddOptions(ge('maps-northrend'), [65, 66, 67, 210, 394, 495, 2817, 3537, 3711, 4197, 4395, 4742]); - ma_AddOptions(ge('maps-battlegrounds'), [2597, 3277, 4384, 3358, 3820, 4710]); - ma_AddOptions(ge('maps-raids'), [ + ma_AddOptions(ge('maps-ek'), [1, 3, 4, 8, 10, 11, 12, 28, 33, 36, 38, 40, 41, 44, 45, 46, 47, 51, 85, 130, 139, 267, 1497, 1519, 1537, 3430, 3433, 3487, 4080, 4298]); + ma_AddOptions(ge('maps-kalimdor'), [14, 15, 16, 17, 141, 148, 215, 331, 357, 361, 400, 405, 406, 440, 490, 493, 618, 1377, 1637, 1638, 1657, 3524, 3525, 3557]); + ma_AddOptions(ge('maps-outland'), [3483, 3518, 3519, 3520, 3521, 3522, 3523, 3703]); + ma_AddOptions(ge('maps-northrend'), [65, 66, 67, 210, 394, 495, 2817, 3537, 3711, 4197, 4395, 4742]); + ma_AddOptions(ge('maps-battlegrounds'), [2597, 3277, 4384, 3358, 3820, 4710]); + ma_AddOptions(ge('maps-raids'), [ 1977, 2677, 2717, 3428, 3429, // Classic: Zul'Gurub, Blackwing Lair, Molten Core, Ahn'Qiraj, Ruins of Ahn'Qiraj 3457, 3606, 3607, 3805, 3836, // BC: Karazhan, Hyjal Summit, Serpentshrine Cavern, Zul'Aman, Magtheridon's Lair 3845, 3923, 3959, 4075, // BC: Tempest Keep, Gruul's Lair, Black Temple, Sunwell Plateau 2159, 3456, 4273, 4493, 4500, // WotLK: Onyxia's Lair, Naxxramas, Ulduar, The Obsidian Sanctum, The Eye of Eternity 4603, 4722, 4812, 4987 // WotlK: Vault of Archavon, Trial of the Crusader, Icecrown Citadel, The Ruby Sanctum ]); - ma_AddOptions(ge('maps-dungeons'), [ + ma_AddOptions(ge('maps-dungeons'), [ 209, 491, 717, 718, 719, // Classic: Shadowfang Keep, Razorfen Kraul, The Stockade, Wailing Caverns, Blackfathom Deeps 721, 722, 796, 1176, 1337, // Classic: Gnomeregan, Razorfen Downs, Scarlet Monastery, Zul'Farrak, Uldaman 1477, 1581, 1583, 1584, 2017, // Classic: The Temple of Atal'Hakkar, The Deadmines, Blackrock Spire, Blackrock Depths, Stratholme @@ -26,66 +26,66 @@ function ma_Init() { 4820, // WotlK: Halls of Reflection ]); - myMapper = new Mapper({ - parent: 'mapper-generic', - editable: true, - zoom: 1, - onPinUpdate: ma_UpdateLink, - onMapUpdate: ma_UpdateLink - }); + myMapper = new Mapper({ + parent: 'mapper-generic', + editable: true, + zoom: 1, + onPinUpdate: ma_UpdateLink, + onMapUpdate: ma_UpdateLink + }); - var _ = location.href.indexOf('maps='); - if (_ != -1) { - _ = location.href.substr(_ + 5); - if (myMapper.setLink(_)) { - ge('mapper').style.display = ''; - } - } + var _ = location.href.indexOf('maps='); + if (_ != -1) { + _ = location.href.substr(_ + 5); + if (myMapper.setLink(_)) { + ge('mapper').style.display = ''; + } + } } function ma_AddOptions(s, a) { - a.sort(ma_Sort); + a.sort(ma_Sort); - array_apply(a, function (x) { - var o = ce('option'); - o.value = x - ae(o, ct(g_zones[typeof x == 'string' ? parseInt(x) : x])); - ae(s, o); - }); + array_apply(a, function (x) { + var o = ce('option'); + o.value = x + ae(o, ct(g_zones[typeof x == 'string' ? parseInt(x) : x])); + ae(s, o); + }); } function ma_Sort(a, b) { - if (typeof a == 'string') { - a = parseInt(a); - } + if (typeof a == 'string') { + a = parseInt(a); + } - if (typeof b == 'string') { - b = parseInt(b); - } + if (typeof b == 'string') { + b = parseInt(b); + } - return strcmp(g_zones[a], g_zones[b]); + return strcmp(g_zones[a], g_zones[b]); } function ma_ChooseZone(s) { - if (s.value && s.value != '0') { - if (myMapper.getZone() == 0) { - ge('mapper').style.display = ''; - } + if (s.value && s.value != '0') { + if (myMapper.getZone() == 0) { + ge('mapper').style.display = ''; + } myMapper.setZone(s.value); - } + } - s.selectedIndex = 0; + s.selectedIndex = 0; } function ma_UpdateLink(_) { - var + var b = '?maps', l = _.getLink(); - - if (l) { - b += '=' + l; - } - ge('link-to-this-map').href = b; -}; \ No newline at end of file + if (l) { + b += '=' + l; + } + + ge('link-to-this-map').href = b; +}; diff --git a/template/js/swfobject.js b/template/js/swfobject.js index 863f0fc1..94a21c57 100644 --- a/template/js/swfobject.js +++ b/template/js/swfobject.js @@ -1,777 +1,777 @@ -/*! SWFObject v2.2 - is released under the MIT License +/*! SWFObject v2.2 + is released under the MIT License */ var swfobject = function() { - - var UNDEF = "undefined", - OBJECT = "object", - SHOCKWAVE_FLASH = "Shockwave Flash", - SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash", - FLASH_MIME_TYPE = "application/x-shockwave-flash", - EXPRESS_INSTALL_ID = "SWFObjectExprInst", - ON_READY_STATE_CHANGE = "onreadystatechange", - - win = window, - doc = document, - nav = navigator, - - plugin = false, - domLoadFnArr = [main], - regObjArr = [], - objIdArr = [], - listenersArr = [], - storedAltContent, - storedAltContentId, - storedCallbackFn, - storedCallbackObj, - isDomLoaded = false, - isExpressInstallActive = false, - dynamicStylesheet, - dynamicStylesheetMedia, - autoHideShow = true, - - /* Centralized function for browser feature detection - - User agent string detection is only used when no good alternative is possible - - Is executed directly for optimal performance - */ - ua = function() { - var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF, - u = nav.userAgent.toLowerCase(), - p = nav.platform.toLowerCase(), - windows = p ? /win/.test(p) : /win/.test(u), - mac = p ? /mac/.test(p) : /mac/.test(u), - webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit - ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html - playerVersion = [0,0,0], - d = null; - if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) { - d = nav.plugins[SHOCKWAVE_FLASH].description; - if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+ - plugin = true; - ie = false; // cascaded feature detection for Internet Explorer - d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); - playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10); - playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10); - playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0; - } - } - else if (typeof win.ActiveXObject != UNDEF) { - try { - var a = new ActiveXObject(SHOCKWAVE_FLASH_AX); - if (a) { // a will return null when ActiveX is disabled - d = a.GetVariable("$version"); - if (d) { - ie = true; // cascaded feature detection for Internet Explorer - d = d.split(" ")[1].split(","); - playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; - } - } - } - catch(e) {} - } - return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac }; - }(), - - /* Cross-browser onDomLoad - - Will fire an event as soon as the DOM of a web page is loaded - - Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/ - - Regular onload serves as fallback - */ - onDomLoad = function() { - if (!ua.w3) { return; } - if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically - callDomLoadFunctions(); - } - if (!isDomLoaded) { - if (typeof doc.addEventListener != UNDEF) { - doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false); - } - if (ua.ie && ua.win) { - doc.attachEvent(ON_READY_STATE_CHANGE, function() { - if (doc.readyState == "complete") { - doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee); - callDomLoadFunctions(); - } - }); - if (win == top) { // if not inside an iframe - (function(){ - if (isDomLoaded) { return; } - try { - doc.documentElement.doScroll("left"); - } - catch(e) { - setTimeout(arguments.callee, 0); - return; - } - callDomLoadFunctions(); - })(); - } - } - if (ua.wk) { - (function(){ - if (isDomLoaded) { return; } - if (!/loaded|complete/.test(doc.readyState)) { - setTimeout(arguments.callee, 0); - return; - } - callDomLoadFunctions(); - })(); - } - addLoadEvent(callDomLoadFunctions); - } - }(); - - function callDomLoadFunctions() { - if (isDomLoaded) { return; } - try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early - var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span")); - t.parentNode.removeChild(t); - } - catch (e) { return; } - isDomLoaded = true; - var dl = domLoadFnArr.length; - for (var i = 0; i < dl; i++) { - domLoadFnArr[i](); - } - } - - function addDomLoadEvent(fn) { - if (isDomLoaded) { - fn(); - } - else { - domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+ - } - } - - /* Cross-browser onload - - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/ - - Will fire an event as soon as a web page including all of its assets are loaded - */ - function addLoadEvent(fn) { - if (typeof win.addEventListener != UNDEF) { - win.addEventListener("load", fn, false); - } - else if (typeof doc.addEventListener != UNDEF) { - doc.addEventListener("load", fn, false); - } - else if (typeof win.attachEvent != UNDEF) { - addListener(win, "onload", fn); - } - else if (typeof win.onload == "function") { - var fnOld = win.onload; - win.onload = function() { - fnOld(); - fn(); - }; - } - else { - win.onload = fn; - } - } - - /* Main function - - Will preferably execute onDomLoad, otherwise onload (as a fallback) - */ - function main() { - if (plugin) { - testPlayerVersion(); - } - else { - matchVersions(); - } - } - - /* Detect the Flash Player version for non-Internet Explorer browsers - - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description: - a. Both release and build numbers can be detected - b. Avoid wrong descriptions by corrupt installers provided by Adobe - c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports - - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available - */ - function testPlayerVersion() { - var b = doc.getElementsByTagName("body")[0]; - var o = createElement(OBJECT); - o.setAttribute("type", FLASH_MIME_TYPE); - var t = b.appendChild(o); - if (t) { - var counter = 0; - (function(){ - if (typeof t.GetVariable != UNDEF) { - var d = t.GetVariable("$version"); - if (d) { - d = d.split(" ")[1].split(","); - ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; - } - } - else if (counter < 10) { - counter++; - setTimeout(arguments.callee, 10); - return; - } - b.removeChild(o); - t = null; - matchVersions(); - })(); - } - else { - matchVersions(); - } - } - - /* Perform Flash Player and SWF version matching; static publishing only - */ - function matchVersions() { - var rl = regObjArr.length; - if (rl > 0) { - for (var i = 0; i < rl; i++) { // for each registered object element - var id = regObjArr[i].id; - var cb = regObjArr[i].callbackFn; - var cbObj = {success:false, id:id}; - if (ua.pv[0] > 0) { - var obj = getElementById(id); - if (obj) { - if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match! - setVisibility(id, true); - if (cb) { - cbObj.success = true; - cbObj.ref = getObjectById(id); - cb(cbObj); - } - } - else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported - var att = {}; - att.data = regObjArr[i].expressInstall; - att.width = obj.getAttribute("width") || "0"; - att.height = obj.getAttribute("height") || "0"; - if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); } - if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); } - // parse HTML object param element's name-value pairs - var par = {}; - var p = obj.getElementsByTagName("param"); - var pl = p.length; - for (var j = 0; j < pl; j++) { - if (p[j].getAttribute("name").toLowerCase() != "movie") { - par[p[j].getAttribute("name")] = p[j].getAttribute("value"); - } - } - showExpressInstall(att, par, id, cb); - } - else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF - displayAltContent(obj); - if (cb) { cb(cbObj); } - } - } - } - else { // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content) - setVisibility(id, true); - if (cb) { - var o = getObjectById(id); // test whether there is an HTML object element or not - if (o && typeof o.SetVariable != UNDEF) { - cbObj.success = true; - cbObj.ref = o; - } - cb(cbObj); - } - } - } - } - } - - function getObjectById(objectIdStr) { - var r = null; - var o = getElementById(objectIdStr); - if (o && o.nodeName == "OBJECT") { - if (typeof o.SetVariable != UNDEF) { - r = o; - } - else { - var n = o.getElementsByTagName(OBJECT)[0]; - if (n) { - r = n; - } - } - } - return r; - } - - /* Requirements for Adobe Express Install - - only one instance can be active at a time - - fp 6.0.65 or higher - - Win/Mac OS only - - no Webkit engines older than version 312 - */ - function canExpressInstall() { - return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312); - } - - /* Show the Adobe Express Install dialog - - Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75 - */ - function showExpressInstall(att, par, replaceElemIdStr, callbackFn) { - isExpressInstallActive = true; - storedCallbackFn = callbackFn || null; - storedCallbackObj = {success:false, id:replaceElemIdStr}; - var obj = getElementById(replaceElemIdStr); - if (obj) { - if (obj.nodeName == "OBJECT") { // static publishing - storedAltContent = abstractAltContent(obj); - storedAltContentId = null; - } - else { // dynamic publishing - storedAltContent = obj; - storedAltContentId = replaceElemIdStr; - } - att.id = EXPRESS_INSTALL_ID; - if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; } - if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; } - doc.title = doc.title.slice(0, 47) + " - Flash Player Installation"; - var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn", - fv = "MMredirectURL=" + encodeURI(win.location).toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title; - if (typeof par.flashvars != UNDEF) { - par.flashvars += "&" + fv; - } - else { - par.flashvars = fv; - } - // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, - // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work - if (ua.ie && ua.win && obj.readyState != 4) { - var newObj = createElement("div"); - replaceElemIdStr += "SWFObjectNew"; - newObj.setAttribute("id", replaceElemIdStr); - obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf - obj.style.display = "none"; - (function(){ - if (obj.readyState == 4) { - obj.parentNode.removeChild(obj); - } - else { - setTimeout(arguments.callee, 10); - } - })(); - } - createSWF(att, par, replaceElemIdStr); - } - } - - /* Functions to abstract and display alternative content - */ - function displayAltContent(obj) { - if (ua.ie && ua.win && obj.readyState != 4) { - // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, - // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work - var el = createElement("div"); - obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content - el.parentNode.replaceChild(abstractAltContent(obj), el); - obj.style.display = "none"; - (function(){ - if (obj.readyState == 4) { - obj.parentNode.removeChild(obj); - } - else { - setTimeout(arguments.callee, 10); - } - })(); - } - else { - obj.parentNode.replaceChild(abstractAltContent(obj), obj); - } - } - function abstractAltContent(obj) { - var ac = createElement("div"); - if (ua.win && ua.ie) { - ac.innerHTML = obj.innerHTML; - } - else { - var nestedObj = obj.getElementsByTagName(OBJECT)[0]; - if (nestedObj) { - var c = nestedObj.childNodes; - if (c) { - var cl = c.length; - for (var i = 0; i < cl; i++) { - if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) { - ac.appendChild(c[i].cloneNode(true)); - } - } - } - } - } - return ac; - } - - /* Cross-browser dynamic SWF creation - */ - function createSWF(attObj, parObj, id) { - var r, el = getElementById(id); - if (ua.wk && ua.wk < 312) { return r; } - if (el) { - if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content - attObj.id = id; - } - if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML - var att = ""; - for (var i in attObj) { - if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries - if (i.toLowerCase() == "data") { - parObj.movie = attObj[i]; - } - else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword - att += ' class="' + attObj[i] + '"'; - } - else if (i.toLowerCase() != "classid") { - att += ' ' + i + '="' + attObj[i] + '"'; - } - } - } - var par = ""; - for (var j in parObj) { - if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries - par += ''; - } - } - el.outerHTML = '' + par + ''; - objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only) - r = getElementById(attObj.id); - } - else { // well-behaving browsers - var o = createElement(OBJECT); - o.setAttribute("type", FLASH_MIME_TYPE); - for (var m in attObj) { - if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries - if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword - o.setAttribute("class", attObj[m]); - } - else if (m.toLowerCase() != "classid") { // filter out IE specific attribute - o.setAttribute(m, attObj[m]); - } - } - } - for (var n in parObj) { - if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element - createObjParam(o, n, parObj[n]); - } - } - el.parentNode.replaceChild(o, el); - r = o; - } - } - return r; - } - - function createObjParam(el, pName, pValue) { - var p = createElement("param"); - p.setAttribute("name", pName); - p.setAttribute("value", pValue); - el.appendChild(p); - } - - /* Cross-browser SWF removal - - Especially needed to safely and completely remove a SWF in Internet Explorer - */ - function removeSWF(id) { - var obj = getElementById(id); - if (obj && obj.nodeName == "OBJECT") { - if (ua.ie && ua.win) { - obj.style.display = "none"; - (function(){ - if (obj.readyState == 4) { - removeObjectInIE(id); - } - else { - setTimeout(arguments.callee, 10); - } - })(); - } - else { - obj.parentNode.removeChild(obj); - } - } - } - - function removeObjectInIE(id) { - var obj = getElementById(id); - if (obj) { - for (var i in obj) { - if (typeof obj[i] == "function") { - obj[i] = null; - } - } - obj.parentNode.removeChild(obj); - } - } - - /* Functions to optimize JavaScript compression - */ - function getElementById(id) { - var el = null; - try { - el = doc.getElementById(id); - } - catch (e) {} - return el; - } - - function createElement(el) { - return doc.createElement(el); - } - - /* Updated attachEvent function for Internet Explorer - - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks - */ - function addListener(target, eventType, fn) { - target.attachEvent(eventType, fn); - listenersArr[listenersArr.length] = [target, eventType, fn]; - } - - /* Flash Player and SWF content version matching - */ - function hasPlayerVersion(rv) { - var pv = ua.pv, v = rv.split("."); - v[0] = parseInt(v[0], 10); - v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0" - v[2] = parseInt(v[2], 10) || 0; - return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false; - } - - /* Cross-browser dynamic CSS creation - - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php - */ - function createCSS(sel, decl, media, newStyle) { - if (ua.ie && ua.mac) { return; } - var h = doc.getElementsByTagName("head")[0]; - if (!h) { return; } // to also support badly authored HTML pages that lack a head element - var m = (media && typeof media == "string") ? media : "screen"; - if (newStyle) { - dynamicStylesheet = null; - dynamicStylesheetMedia = null; - } - if (!dynamicStylesheet || dynamicStylesheetMedia != m) { - // create dynamic stylesheet + get a global reference to it - var s = createElement("style"); - s.setAttribute("type", "text/css"); - s.setAttribute("media", m); - dynamicStylesheet = h.appendChild(s); - if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) { - dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1]; - } - dynamicStylesheetMedia = m; - } - // add style rule - if (ua.ie && ua.win) { - if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) { - dynamicStylesheet.addRule(sel, decl); - } - } - else { - if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) { - dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}")); - } - } - } - - function setVisibility(id, isVisible) { - if (!autoHideShow) { return; } - var v = isVisible ? "visible" : "hidden"; - if (isDomLoaded && getElementById(id)) { - getElementById(id).style.visibility = v; - } - else { - createCSS("#" + id, "visibility:" + v); - } - } + var UNDEF = "undefined", + OBJECT = "object", + SHOCKWAVE_FLASH = "Shockwave Flash", + SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash", + FLASH_MIME_TYPE = "application/x-shockwave-flash", + EXPRESS_INSTALL_ID = "SWFObjectExprInst", + ON_READY_STATE_CHANGE = "onreadystatechange", - /* Filter to avoid XSS attacks - */ - function urlEncodeIfNecessary(s) { - var regex = /[\\\"<>\.;]/; - var hasBadChars = regex.exec(s) != null; - return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s; - } - - /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only) - */ - var cleanup = function() { - if (ua.ie && ua.win) { - window.attachEvent("onunload", function() { - // remove listeners to avoid memory leaks - var ll = listenersArr.length; - for (var i = 0; i < ll; i++) { - listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]); - } - // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect - var il = objIdArr.length; - for (var j = 0; j < il; j++) { - removeSWF(objIdArr[j]); - } - // cleanup library's main closures to avoid memory leaks - for (var k in ua) { - ua[k] = null; - } - ua = null; - for (var l in swfobject) { - swfobject[l] = null; - } - swfobject = null; - }); - } - }(); - - return { - /* Public API - - Reference: http://code.google.com/p/swfobject/wiki/documentation - */ - registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) { - if (ua.w3 && objectIdStr && swfVersionStr) { - var regObj = {}; - regObj.id = objectIdStr; - regObj.swfVersion = swfVersionStr; - regObj.expressInstall = xiSwfUrlStr; - regObj.callbackFn = callbackFn; - regObjArr[regObjArr.length] = regObj; - setVisibility(objectIdStr, false); - } - else if (callbackFn) { - callbackFn({success:false, id:objectIdStr}); - } - }, - - getObjectById: function(objectIdStr) { - if (ua.w3) { - return getObjectById(objectIdStr); - } - }, - - embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) { - var callbackObj = {success:false, id:replaceElemIdStr}; - if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) { - setVisibility(replaceElemIdStr, false); - addDomLoadEvent(function() { - widthStr += ""; // auto-convert to string - heightStr += ""; - var att = {}; - if (attObj && typeof attObj === OBJECT) { - for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs - att[i] = attObj[i]; - } - } - att.data = swfUrlStr; - att.width = widthStr; - att.height = heightStr; - var par = {}; - if (parObj && typeof parObj === OBJECT) { - for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs - par[j] = parObj[j]; - } - } - if (flashvarsObj && typeof flashvarsObj === OBJECT) { - for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs - if (typeof par.flashvars != UNDEF) { - par.flashvars += "&" + k + "=" + flashvarsObj[k]; - } - else { - par.flashvars = k + "=" + flashvarsObj[k]; - } - } - } - if (hasPlayerVersion(swfVersionStr)) { // create SWF - var obj = createSWF(att, par, replaceElemIdStr); - if (att.id == replaceElemIdStr) { - setVisibility(replaceElemIdStr, true); - } - callbackObj.success = true; - callbackObj.ref = obj; - } - else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install - att.data = xiSwfUrlStr; - showExpressInstall(att, par, replaceElemIdStr, callbackFn); - return; - } - else { // show alternative content - setVisibility(replaceElemIdStr, true); - } - if (callbackFn) { callbackFn(callbackObj); } - }); - } - else if (callbackFn) { callbackFn(callbackObj); } - }, - - switchOffAutoHideShow: function() { - autoHideShow = false; - }, - - ua: ua, - - getFlashPlayerVersion: function() { - return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] }; - }, - - hasFlashPlayerVersion: hasPlayerVersion, - - createSWF: function(attObj, parObj, replaceElemIdStr) { - if (ua.w3) { - return createSWF(attObj, parObj, replaceElemIdStr); - } - else { - return undefined; - } - }, - - showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) { - if (ua.w3 && canExpressInstall()) { - showExpressInstall(att, par, replaceElemIdStr, callbackFn); - } - }, - - removeSWF: function(objElemIdStr) { - if (ua.w3) { - removeSWF(objElemIdStr); - } - }, - - createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) { - if (ua.w3) { - createCSS(selStr, declStr, mediaStr, newStyleBoolean); - } - }, - - addDomLoadEvent: addDomLoadEvent, - - addLoadEvent: addLoadEvent, - - getQueryParamValue: function(param) { - var q = doc.location.search || doc.location.hash; - if (q) { - if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark - if (param == null) { - return urlEncodeIfNecessary(q); - } - var pairs = q.split("&"); - for (var i = 0; i < pairs.length; i++) { - if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) { - return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1))); - } - } - } - return ""; - }, - - // For internal usage only - expressInstallCallback: function() { - if (isExpressInstallActive) { - var obj = getElementById(EXPRESS_INSTALL_ID); - if (obj && storedAltContent) { - obj.parentNode.replaceChild(storedAltContent, obj); - if (storedAltContentId) { - setVisibility(storedAltContentId, true); - if (ua.ie && ua.win) { storedAltContent.style.display = "block"; } - } - if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); } - } - isExpressInstallActive = false; - } - } - }; + win = window, + doc = document, + nav = navigator, + + plugin = false, + domLoadFnArr = [main], + regObjArr = [], + objIdArr = [], + listenersArr = [], + storedAltContent, + storedAltContentId, + storedCallbackFn, + storedCallbackObj, + isDomLoaded = false, + isExpressInstallActive = false, + dynamicStylesheet, + dynamicStylesheetMedia, + autoHideShow = true, + + /* Centralized function for browser feature detection + - User agent string detection is only used when no good alternative is possible + - Is executed directly for optimal performance + */ + ua = function() { + var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF, + u = nav.userAgent.toLowerCase(), + p = nav.platform.toLowerCase(), + windows = p ? /win/.test(p) : /win/.test(u), + mac = p ? /mac/.test(p) : /mac/.test(u), + webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit + ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html + playerVersion = [0,0,0], + d = null; + if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) { + d = nav.plugins[SHOCKWAVE_FLASH].description; + if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+ + plugin = true; + ie = false; // cascaded feature detection for Internet Explorer + d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); + playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10); + playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10); + playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0; + } + } + else if (typeof win.ActiveXObject != UNDEF) { + try { + var a = new ActiveXObject(SHOCKWAVE_FLASH_AX); + if (a) { // a will return null when ActiveX is disabled + d = a.GetVariable("$version"); + if (d) { + ie = true; // cascaded feature detection for Internet Explorer + d = d.split(" ")[1].split(","); + playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; + } + } + } + catch(e) {} + } + return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac }; + }(), + + /* Cross-browser onDomLoad + - Will fire an event as soon as the DOM of a web page is loaded + - Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/ + - Regular onload serves as fallback + */ + onDomLoad = function() { + if (!ua.w3) { return; } + if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically + callDomLoadFunctions(); + } + if (!isDomLoaded) { + if (typeof doc.addEventListener != UNDEF) { + doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false); + } + if (ua.ie && ua.win) { + doc.attachEvent(ON_READY_STATE_CHANGE, function() { + if (doc.readyState == "complete") { + doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee); + callDomLoadFunctions(); + } + }); + if (win == top) { // if not inside an iframe + (function(){ + if (isDomLoaded) { return; } + try { + doc.documentElement.doScroll("left"); + } + catch(e) { + setTimeout(arguments.callee, 0); + return; + } + callDomLoadFunctions(); + })(); + } + } + if (ua.wk) { + (function(){ + if (isDomLoaded) { return; } + if (!/loaded|complete/.test(doc.readyState)) { + setTimeout(arguments.callee, 0); + return; + } + callDomLoadFunctions(); + })(); + } + addLoadEvent(callDomLoadFunctions); + } + }(); + + function callDomLoadFunctions() { + if (isDomLoaded) { return; } + try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early + var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span")); + t.parentNode.removeChild(t); + } + catch (e) { return; } + isDomLoaded = true; + var dl = domLoadFnArr.length; + for (var i = 0; i < dl; i++) { + domLoadFnArr[i](); + } + } + + function addDomLoadEvent(fn) { + if (isDomLoaded) { + fn(); + } + else { + domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+ + } + } + + /* Cross-browser onload + - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/ + - Will fire an event as soon as a web page including all of its assets are loaded + */ + function addLoadEvent(fn) { + if (typeof win.addEventListener != UNDEF) { + win.addEventListener("load", fn, false); + } + else if (typeof doc.addEventListener != UNDEF) { + doc.addEventListener("load", fn, false); + } + else if (typeof win.attachEvent != UNDEF) { + addListener(win, "onload", fn); + } + else if (typeof win.onload == "function") { + var fnOld = win.onload; + win.onload = function() { + fnOld(); + fn(); + }; + } + else { + win.onload = fn; + } + } + + /* Main function + - Will preferably execute onDomLoad, otherwise onload (as a fallback) + */ + function main() { + if (plugin) { + testPlayerVersion(); + } + else { + matchVersions(); + } + } + + /* Detect the Flash Player version for non-Internet Explorer browsers + - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description: + a. Both release and build numbers can be detected + b. Avoid wrong descriptions by corrupt installers provided by Adobe + c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports + - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available + */ + function testPlayerVersion() { + var b = doc.getElementsByTagName("body")[0]; + var o = createElement(OBJECT); + o.setAttribute("type", FLASH_MIME_TYPE); + var t = b.appendChild(o); + if (t) { + var counter = 0; + (function(){ + if (typeof t.GetVariable != UNDEF) { + var d = t.GetVariable("$version"); + if (d) { + d = d.split(" ")[1].split(","); + ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; + } + } + else if (counter < 10) { + counter++; + setTimeout(arguments.callee, 10); + return; + } + b.removeChild(o); + t = null; + matchVersions(); + })(); + } + else { + matchVersions(); + } + } + + /* Perform Flash Player and SWF version matching; static publishing only + */ + function matchVersions() { + var rl = regObjArr.length; + if (rl > 0) { + for (var i = 0; i < rl; i++) { // for each registered object element + var id = regObjArr[i].id; + var cb = regObjArr[i].callbackFn; + var cbObj = {success:false, id:id}; + if (ua.pv[0] > 0) { + var obj = getElementById(id); + if (obj) { + if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match! + setVisibility(id, true); + if (cb) { + cbObj.success = true; + cbObj.ref = getObjectById(id); + cb(cbObj); + } + } + else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported + var att = {}; + att.data = regObjArr[i].expressInstall; + att.width = obj.getAttribute("width") || "0"; + att.height = obj.getAttribute("height") || "0"; + if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); } + if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); } + // parse HTML object param element's name-value pairs + var par = {}; + var p = obj.getElementsByTagName("param"); + var pl = p.length; + for (var j = 0; j < pl; j++) { + if (p[j].getAttribute("name").toLowerCase() != "movie") { + par[p[j].getAttribute("name")] = p[j].getAttribute("value"); + } + } + showExpressInstall(att, par, id, cb); + } + else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF + displayAltContent(obj); + if (cb) { cb(cbObj); } + } + } + } + else { // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content) + setVisibility(id, true); + if (cb) { + var o = getObjectById(id); // test whether there is an HTML object element or not + if (o && typeof o.SetVariable != UNDEF) { + cbObj.success = true; + cbObj.ref = o; + } + cb(cbObj); + } + } + } + } + } + + function getObjectById(objectIdStr) { + var r = null; + var o = getElementById(objectIdStr); + if (o && o.nodeName == "OBJECT") { + if (typeof o.SetVariable != UNDEF) { + r = o; + } + else { + var n = o.getElementsByTagName(OBJECT)[0]; + if (n) { + r = n; + } + } + } + return r; + } + + /* Requirements for Adobe Express Install + - only one instance can be active at a time + - fp 6.0.65 or higher + - Win/Mac OS only + - no Webkit engines older than version 312 + */ + function canExpressInstall() { + return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312); + } + + /* Show the Adobe Express Install dialog + - Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75 + */ + function showExpressInstall(att, par, replaceElemIdStr, callbackFn) { + isExpressInstallActive = true; + storedCallbackFn = callbackFn || null; + storedCallbackObj = {success:false, id:replaceElemIdStr}; + var obj = getElementById(replaceElemIdStr); + if (obj) { + if (obj.nodeName == "OBJECT") { // static publishing + storedAltContent = abstractAltContent(obj); + storedAltContentId = null; + } + else { // dynamic publishing + storedAltContent = obj; + storedAltContentId = replaceElemIdStr; + } + att.id = EXPRESS_INSTALL_ID; + if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; } + if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; } + doc.title = doc.title.slice(0, 47) + " - Flash Player Installation"; + var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn", + fv = "MMredirectURL=" + encodeURI(win.location).toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title; + if (typeof par.flashvars != UNDEF) { + par.flashvars += "&" + fv; + } + else { + par.flashvars = fv; + } + // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, + // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work + if (ua.ie && ua.win && obj.readyState != 4) { + var newObj = createElement("div"); + replaceElemIdStr += "SWFObjectNew"; + newObj.setAttribute("id", replaceElemIdStr); + obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf + obj.style.display = "none"; + (function(){ + if (obj.readyState == 4) { + obj.parentNode.removeChild(obj); + } + else { + setTimeout(arguments.callee, 10); + } + })(); + } + createSWF(att, par, replaceElemIdStr); + } + } + + /* Functions to abstract and display alternative content + */ + function displayAltContent(obj) { + if (ua.ie && ua.win && obj.readyState != 4) { + // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, + // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work + var el = createElement("div"); + obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content + el.parentNode.replaceChild(abstractAltContent(obj), el); + obj.style.display = "none"; + (function(){ + if (obj.readyState == 4) { + obj.parentNode.removeChild(obj); + } + else { + setTimeout(arguments.callee, 10); + } + })(); + } + else { + obj.parentNode.replaceChild(abstractAltContent(obj), obj); + } + } + + function abstractAltContent(obj) { + var ac = createElement("div"); + if (ua.win && ua.ie) { + ac.innerHTML = obj.innerHTML; + } + else { + var nestedObj = obj.getElementsByTagName(OBJECT)[0]; + if (nestedObj) { + var c = nestedObj.childNodes; + if (c) { + var cl = c.length; + for (var i = 0; i < cl; i++) { + if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) { + ac.appendChild(c[i].cloneNode(true)); + } + } + } + } + } + return ac; + } + + /* Cross-browser dynamic SWF creation + */ + function createSWF(attObj, parObj, id) { + var r, el = getElementById(id); + if (ua.wk && ua.wk < 312) { return r; } + if (el) { + if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content + attObj.id = id; + } + if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML + var att = ""; + for (var i in attObj) { + if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries + if (i.toLowerCase() == "data") { + parObj.movie = attObj[i]; + } + else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword + att += ' class="' + attObj[i] + '"'; + } + else if (i.toLowerCase() != "classid") { + att += ' ' + i + '="' + attObj[i] + '"'; + } + } + } + var par = ""; + for (var j in parObj) { + if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries + par += ''; + } + } + el.outerHTML = '' + par + ''; + objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only) + r = getElementById(attObj.id); + } + else { // well-behaving browsers + var o = createElement(OBJECT); + o.setAttribute("type", FLASH_MIME_TYPE); + for (var m in attObj) { + if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries + if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword + o.setAttribute("class", attObj[m]); + } + else if (m.toLowerCase() != "classid") { // filter out IE specific attribute + o.setAttribute(m, attObj[m]); + } + } + } + for (var n in parObj) { + if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element + createObjParam(o, n, parObj[n]); + } + } + el.parentNode.replaceChild(o, el); + r = o; + } + } + return r; + } + + function createObjParam(el, pName, pValue) { + var p = createElement("param"); + p.setAttribute("name", pName); + p.setAttribute("value", pValue); + el.appendChild(p); + } + + /* Cross-browser SWF removal + - Especially needed to safely and completely remove a SWF in Internet Explorer + */ + function removeSWF(id) { + var obj = getElementById(id); + if (obj && obj.nodeName == "OBJECT") { + if (ua.ie && ua.win) { + obj.style.display = "none"; + (function(){ + if (obj.readyState == 4) { + removeObjectInIE(id); + } + else { + setTimeout(arguments.callee, 10); + } + })(); + } + else { + obj.parentNode.removeChild(obj); + } + } + } + + function removeObjectInIE(id) { + var obj = getElementById(id); + if (obj) { + for (var i in obj) { + if (typeof obj[i] == "function") { + obj[i] = null; + } + } + obj.parentNode.removeChild(obj); + } + } + + /* Functions to optimize JavaScript compression + */ + function getElementById(id) { + var el = null; + try { + el = doc.getElementById(id); + } + catch (e) {} + return el; + } + + function createElement(el) { + return doc.createElement(el); + } + + /* Updated attachEvent function for Internet Explorer + - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks + */ + function addListener(target, eventType, fn) { + target.attachEvent(eventType, fn); + listenersArr[listenersArr.length] = [target, eventType, fn]; + } + + /* Flash Player and SWF content version matching + */ + function hasPlayerVersion(rv) { + var pv = ua.pv, v = rv.split("."); + v[0] = parseInt(v[0], 10); + v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0" + v[2] = parseInt(v[2], 10) || 0; + return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false; + } + + /* Cross-browser dynamic CSS creation + - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php + */ + function createCSS(sel, decl, media, newStyle) { + if (ua.ie && ua.mac) { return; } + var h = doc.getElementsByTagName("head")[0]; + if (!h) { return; } // to also support badly authored HTML pages that lack a head element + var m = (media && typeof media == "string") ? media : "screen"; + if (newStyle) { + dynamicStylesheet = null; + dynamicStylesheetMedia = null; + } + if (!dynamicStylesheet || dynamicStylesheetMedia != m) { + // create dynamic stylesheet + get a global reference to it + var s = createElement("style"); + s.setAttribute("type", "text/css"); + s.setAttribute("media", m); + dynamicStylesheet = h.appendChild(s); + if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) { + dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1]; + } + dynamicStylesheetMedia = m; + } + // add style rule + if (ua.ie && ua.win) { + if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) { + dynamicStylesheet.addRule(sel, decl); + } + } + else { + if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) { + dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}")); + } + } + } + + function setVisibility(id, isVisible) { + if (!autoHideShow) { return; } + var v = isVisible ? "visible" : "hidden"; + if (isDomLoaded && getElementById(id)) { + getElementById(id).style.visibility = v; + } + else { + createCSS("#" + id, "visibility:" + v); + } + } + + /* Filter to avoid XSS attacks + */ + function urlEncodeIfNecessary(s) { + var regex = /[\\\"<>\.;]/; + var hasBadChars = regex.exec(s) != null; + return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s; + } + + /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only) + */ + var cleanup = function() { + if (ua.ie && ua.win) { + window.attachEvent("onunload", function() { + // remove listeners to avoid memory leaks + var ll = listenersArr.length; + for (var i = 0; i < ll; i++) { + listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]); + } + // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect + var il = objIdArr.length; + for (var j = 0; j < il; j++) { + removeSWF(objIdArr[j]); + } + // cleanup library's main closures to avoid memory leaks + for (var k in ua) { + ua[k] = null; + } + ua = null; + for (var l in swfobject) { + swfobject[l] = null; + } + swfobject = null; + }); + } + }(); + + return { + /* Public API + - Reference: http://code.google.com/p/swfobject/wiki/documentation + */ + registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) { + if (ua.w3 && objectIdStr && swfVersionStr) { + var regObj = {}; + regObj.id = objectIdStr; + regObj.swfVersion = swfVersionStr; + regObj.expressInstall = xiSwfUrlStr; + regObj.callbackFn = callbackFn; + regObjArr[regObjArr.length] = regObj; + setVisibility(objectIdStr, false); + } + else if (callbackFn) { + callbackFn({success:false, id:objectIdStr}); + } + }, + + getObjectById: function(objectIdStr) { + if (ua.w3) { + return getObjectById(objectIdStr); + } + }, + + embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) { + var callbackObj = {success:false, id:replaceElemIdStr}; + if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) { + setVisibility(replaceElemIdStr, false); + addDomLoadEvent(function() { + widthStr += ""; // auto-convert to string + heightStr += ""; + var att = {}; + if (attObj && typeof attObj === OBJECT) { + for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs + att[i] = attObj[i]; + } + } + att.data = swfUrlStr; + att.width = widthStr; + att.height = heightStr; + var par = {}; + if (parObj && typeof parObj === OBJECT) { + for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs + par[j] = parObj[j]; + } + } + if (flashvarsObj && typeof flashvarsObj === OBJECT) { + for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs + if (typeof par.flashvars != UNDEF) { + par.flashvars += "&" + k + "=" + flashvarsObj[k]; + } + else { + par.flashvars = k + "=" + flashvarsObj[k]; + } + } + } + if (hasPlayerVersion(swfVersionStr)) { // create SWF + var obj = createSWF(att, par, replaceElemIdStr); + if (att.id == replaceElemIdStr) { + setVisibility(replaceElemIdStr, true); + } + callbackObj.success = true; + callbackObj.ref = obj; + } + else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install + att.data = xiSwfUrlStr; + showExpressInstall(att, par, replaceElemIdStr, callbackFn); + return; + } + else { // show alternative content + setVisibility(replaceElemIdStr, true); + } + if (callbackFn) { callbackFn(callbackObj); } + }); + } + else if (callbackFn) { callbackFn(callbackObj); } + }, + + switchOffAutoHideShow: function() { + autoHideShow = false; + }, + + ua: ua, + + getFlashPlayerVersion: function() { + return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] }; + }, + + hasFlashPlayerVersion: hasPlayerVersion, + + createSWF: function(attObj, parObj, replaceElemIdStr) { + if (ua.w3) { + return createSWF(attObj, parObj, replaceElemIdStr); + } + else { + return undefined; + } + }, + + showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) { + if (ua.w3 && canExpressInstall()) { + showExpressInstall(att, par, replaceElemIdStr, callbackFn); + } + }, + + removeSWF: function(objElemIdStr) { + if (ua.w3) { + removeSWF(objElemIdStr); + } + }, + + createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) { + if (ua.w3) { + createCSS(selStr, declStr, mediaStr, newStyleBoolean); + } + }, + + addDomLoadEvent: addDomLoadEvent, + + addLoadEvent: addLoadEvent, + + getQueryParamValue: function(param) { + var q = doc.location.search || doc.location.hash; + if (q) { + if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark + if (param == null) { + return urlEncodeIfNecessary(q); + } + var pairs = q.split("&"); + for (var i = 0; i < pairs.length; i++) { + if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) { + return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1))); + } + } + } + return ""; + }, + + // For internal usage only + expressInstallCallback: function() { + if (isExpressInstallActive) { + var obj = getElementById(EXPRESS_INSTALL_ID); + if (obj && storedAltContent) { + obj.parentNode.replaceChild(storedAltContent, obj); + if (storedAltContentId) { + setVisibility(storedAltContentId, true); + if (ua.ie && ua.win) { storedAltContent.style.display = "block"; } + } + if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); } + } + isExpressInstallActive = false; + } + } + }; }();