diff --git a/index.php b/index.php index d12973cd..3a208145 100644 --- a/index.php +++ b/index.php @@ -58,6 +58,7 @@ switch ($pageCall) $altClass = 'talent'; case 'profile': // character profiler [nyi] case 'profiles': // character profile listing [nyi] + case 'profiler': // character profiler main page case 'quest': case 'quests': case 'race': @@ -142,8 +143,8 @@ switch ($pageCall) default: // unk parameter given -> ErrorPage if (isset($_GET['power'])) die('$WowheadPower.register(0, '.User::$localeId.', {})'); - else // in conjunction with a propper rewriteRule in .htaccess... - (new GenericPage)->error(); + else // in conjunction with a proper rewriteRule in .htaccess... + (new GenericPage($pageCall))->error(); break; } diff --git a/localization/locale_dede.php b/localization/locale_dede.php index e9673428..b13bf3a1 100644 --- a/localization/locale_dede.php +++ b/localization/locale_dede.php @@ -884,7 +884,7 @@ $lang = array( )), 10 => "Währung", 12 => "Quest", - 13 => "schlüssel", + 13 => "Schlüssel", ), 'statType' => array( "Erhöht Euer Mana um %d.", diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index 64011efd..70ace67b 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -94,7 +94,7 @@ $lang = array( 'cappedHint' => 'Подсказка: Удалите характеристики с капом (например, меткость).', 'groupBy' => "Группировать", 'gb' => array( - ['Нет", "none'], ['Слот", "slot'], ['Уровень", "level'], ['Источник", "source'] + ['Нет', 'none'], ['Слот', 'slot'], ['Уровень', 'level'], ['Источник', 'source'] ), 'compareTool' => "Инструмент сравнения предметов", 'talentCalc' => "Расчёт талантов", diff --git a/pages/achievement.php b/pages/achievement.php index 0a48a09f..0e81c220 100644 --- a/pages/achievement.php +++ b/pages/achievement.php @@ -32,9 +32,9 @@ class AchievementPage extends GenericPage protected $tabId = 0; protected $mode = CACHETYPE_PAGE; - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); // temp locale if ($this->mode == CACHETYPE_TOOLTIP && isset($_GET['domain'])) diff --git a/pages/achievements.php b/pages/achievements.php index 0867a478..e0410d47 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -45,7 +45,7 @@ class AchievementsPage extends GenericPage $this->filterObj = new AchievementListFilter(); $this->getCategoryFromUrl($pageParam); - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['achievements']); $this->subCat = $pageParam ? '='.$pageParam : ''; diff --git a/pages/class.php b/pages/class.php index 2b50f056..7ba3e726 100644 --- a/pages/class.php +++ b/pages/class.php @@ -18,9 +18,9 @@ class ClassPage extends GenericPage protected $mode = CACHETYPE_PAGE; protected $js = ['swfobject.js']; - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); $this->typeId = intVal($id); diff --git a/pages/classes.php b/pages/classes.php index 6fc6f9ab..3981aefd 100644 --- a/pages/classes.php +++ b/pages/classes.php @@ -16,9 +16,9 @@ class ClassesPage extends GenericPage protected $tabId = 0; protected $mode = CACHETYPE_PAGE; - public function __construct() + public function __construct($pageCall, $pageParam) { - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['classes']); } diff --git a/pages/compare.php b/pages/compare.php index 44a4035f..f5c39253 100644 --- a/pages/compare.php +++ b/pages/compare.php @@ -9,6 +9,7 @@ class ComparePage extends GenericPage { protected $tpl = 'compare'; protected $tabId = 1; + protected $path = [1, 3]; protected $mode = CACHETYPE_NONE; protected $js = array( 'profile.js', @@ -27,9 +28,9 @@ class ComparePage extends GenericPage private $compareString = ''; - public function __construct() + public function __construct($pageCall, $__) { - parent::__construct(); + parent::__construct($pageCall, $__); // prefer $_GET over $_COOKIE if (!empty($_GET['compare'])) diff --git a/pages/currencies.php b/pages/currencies.php index 9256dadc..8a5cf043 100644 --- a/pages/currencies.php +++ b/pages/currencies.php @@ -21,7 +21,7 @@ class CurrenciesPage extends GenericPage { $this->getCategoryFromUrl($pageParam); - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['currencies']); } diff --git a/pages/currency.php b/pages/currency.php index 2696c7c0..677fe56c 100644 --- a/pages/currency.php +++ b/pages/currency.php @@ -17,9 +17,9 @@ class CurrencyPage extends GenericPage protected $tabId = 0; protected $mode = CACHETYPE_PAGE; - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); $this->typeId = intVal($id); diff --git a/pages/event.php b/pages/event.php index 067de1d2..92e14a15 100644 --- a/pages/event.php +++ b/pages/event.php @@ -20,9 +20,9 @@ class EventPage extends GenericPage private $hId = 0; private $eId = 0; - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); $this->typeId = intVal($id); diff --git a/pages/events.php b/pages/events.php index 219e3f6a..dc8dda4d 100644 --- a/pages/events.php +++ b/pages/events.php @@ -21,7 +21,7 @@ class EventsPage extends GenericPage { $this->getCategoryFromUrl($pageParam);; - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['events']); } diff --git a/pages/faction.php b/pages/faction.php index 44b14bd4..c5f182b3 100644 --- a/pages/faction.php +++ b/pages/faction.php @@ -17,9 +17,9 @@ class FactionPage extends GenericPage protected $tabId = 0; protected $mode = CACHETYPE_PAGE; - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); $this->typeId = intVal($id); diff --git a/pages/factions.php b/pages/factions.php index fb329729..67d4d55f 100644 --- a/pages/factions.php +++ b/pages/factions.php @@ -26,7 +26,7 @@ class FactionsPage extends GenericPage { $this->getCategoryFromUrl($pageParam);; - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['factions']); } diff --git a/pages/genericPage.class.php b/pages/genericPage.class.php index e6e11e46..21b9f450 100644 --- a/pages/genericPage.class.php +++ b/pages/genericPage.class.php @@ -61,7 +61,7 @@ class GenericPage protected $lvData = []; protected $title = [CFG_NAME]; // for title-Element protected $name = ''; // for h1-Element - protected $tabId = 0; + protected $tabId = null; protected $gDataKey = false; // adds the dataKey to the user vars protected $js = []; protected $css = []; @@ -71,12 +71,12 @@ class GenericPage private $isCached = false; private $cacheDir = 'cache/template/'; private $jsgBuffer = []; - private $gLocale = []; private $gPageInfo = []; private $gUser = []; + private $pageTemplate = []; private $community = ['co' => [], 'sc' => [], 'vi' => []]; - public function __construct() + public function __construct($pageCall/*, $pageParam */) { $this->time = microtime(true); @@ -92,10 +92,10 @@ class GenericPage else { $this->gUser = User::getUserGlobals(); - $this->gLocale = array( - 'id' => User::$localeId, - 'name' => User::$localeString - ); + $this->pageTemplate['pageName'] = strtolower($pageCall); + + if (isset($this->tabId)) + $this->pageTemplate['activeTab'] = $this->tabId; if (!$this->isValidPage() || !$this->tpl) $this->error(); @@ -177,6 +177,12 @@ class GenericPage 'name' => $this->name ); + if (!empty($this->path)) + $this->pageTemplate['breadcrumb'] = $this->path; + + if (!empty($this->filter)) + $this->pageTemplate['filter'] = empty($this->filter['query']) ? 0 : 1; + if (method_exists($this, 'postCache')) // e.g. update dates for events and such $this->postCache(); @@ -326,8 +332,9 @@ class GenericPage public function notFound($typeStr) // unknown ID { - $this->typeStr = $typeStr; - $this->mysql = DB::Aowow()->getStatistics(); + $this->typeStr = $typeStr; + $this->mysql = DB::Aowow()->getStatistics(); + $this->hasComContent = false; $this->display('text-page-generic'); exit(); diff --git a/pages/item.php b/pages/item.php index e4ff89e4..6d808f1b 100644 --- a/pages/item.php +++ b/pages/item.php @@ -23,9 +23,9 @@ class ItemPage extends genericPage 'filters.js' // lolwut? ); - public function __construct($__, $param) + public function __construct($pageCall, $param) { - parent::__construct(); + parent::__construct($pageCall, $param); $conditions = [['i.id', intVal($param)]]; @@ -777,7 +777,7 @@ class ItemPage extends genericPage if (count($extraCols) == 3) $extraCols[] = 'Listview.extraCols.condition'; - Util::$pageTemplate->extendGlobalIds(TYPE_WORLDEVENT, $e); + $this->extendGlobalIds(TYPE_WORLDEVENT, $e); $row['condition'][] = array( 'type' => TYPE_WORLDEVENT, 'typeId' => -$e, diff --git a/pages/items.php b/pages/items.php index 7b5220f7..4e3c3108 100644 --- a/pages/items.php +++ b/pages/items.php @@ -84,7 +84,7 @@ class ItemsPage extends GenericPage $this->filterObj = new ItemListFilter(); $this->getCategoryFromUrl($pageParam); - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['items']); $this->subCat = $pageParam ? '='.$pageParam : ''; diff --git a/pages/itemset.php b/pages/itemset.php index 2339b831..edb1a086 100644 --- a/pages/itemset.php +++ b/pages/itemset.php @@ -21,9 +21,9 @@ class ItemsetPage extends GenericPage 'Summary.js' ); - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); $this->typeId = intVal($id); diff --git a/pages/itemsets.php b/pages/itemsets.php index b4834935..eba06256 100644 --- a/pages/itemsets.php +++ b/pages/itemsets.php @@ -22,7 +22,7 @@ class ItemsetsPage extends GenericPage $this->filterObj = new ItemsetListFilter(); $this->getCategoryFromUrl($pageParam); - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['itemsets']); } diff --git a/pages/main.php b/pages/main.php index ca1e8b83..449e53c7 100644 --- a/pages/main.php +++ b/pages/main.php @@ -17,6 +17,8 @@ class MainPage extends GenericPage protected function generateContent() { + parent::__construct('home'); + // load news $rows = DB::Aowow()->select('SELECT * FROM ?_news ORDER BY time DESC, id DESC LIMIT 5'); foreach ($rows as $i => $row) diff --git a/pages/maps.php b/pages/maps.php index b642d96f..bb5447f0 100644 --- a/pages/maps.php +++ b/pages/maps.php @@ -9,6 +9,7 @@ class MapsPage extends GenericPage { protected $tpl = 'maps'; protected $tabId = 1; + protected $path = [1, 1]; protected $mode = CACHETYPE_NONE; protected $js = array( 'maps.js', @@ -20,9 +21,9 @@ class MapsPage extends GenericPage ['path' => 'Mapper_ie6.css', 'ieCond' => 'lte IE 6'] ); - public function __construct() + public function __construct($pageCall, $__) { - parent::__construct(); + parent::__construct($pageCall, $__); $this->name = Lang::$maps['maps']; } diff --git a/pages/more.php b/pages/more.php index dfc082bb..4e8e5daf 100644 --- a/pages/more.php +++ b/pages/more.php @@ -27,12 +27,12 @@ class MorePage extends GenericPage 'help' => [-13, null, ''] ); - public function __construct($page, $subPage) + public function __construct($pageCall, $subPage) { - parent::__construct(); + parent::__construct($pageCall, $subPage); // chack if page is valid - if ($_ = @$this->validPages[$page]) + if ($_ = @$this->validPages[$pageCall]) { // check if subpage is valid if (!isset($_[1])) @@ -40,7 +40,7 @@ class MorePage extends GenericPage if (($_[1] = array_search($subPage, $this->subPages[$_[0]])) === false) $this->error(); - if ($page == 'help') // ye.. hack .. class definitions only allow static values + if ($pageCall == 'help') // ye.. hack .. class definitions only allow static values $_[2] = Lang::$main['helpTopics'][$_[1]]; } $this->type = $_[0]; diff --git a/pages/npc.php b/pages/npc.php index ab2b2b5d..d65371cb 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -25,9 +25,9 @@ class NpcPage extends GenericPage // ['path' => 'Mapper_ie6.css', 'ieCond' => 'lte IE 6'] ); - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); // temp locale if ($this->mode == CACHETYPE_TOOLTIP && isset($_GET['domain'])) @@ -100,7 +100,7 @@ class NpcPage extends GenericPage { if ($h = $_['holidayId']) { - Util::$pageTemplate->extendGlobalIds(TYPE_WORLDEVENT, $_['id']); + $this->extendGlobalIds(TYPE_WORLDEVENT, $_['id']); $infobox[] = Util::ucFirst(Lang::$game['eventShort']).Lang::$main['colon'].'[event='.$h.']'; } } diff --git a/pages/npcs.php b/pages/npcs.php index 037d2c19..009e8f0c 100644 --- a/pages/npcs.php +++ b/pages/npcs.php @@ -23,7 +23,7 @@ class NpcsPage extends GenericPage $this->filterObj = new CreatureListFilter(); $this->getCategoryFromUrl($pageParam);; - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['npcs']); $this->subCat = $pageParam ? '='.$pageParam : ''; diff --git a/pages/object.php b/pages/object.php index 5aef07e3..7475c25f 100644 --- a/pages/object.php +++ b/pages/object.php @@ -32,9 +32,9 @@ class ObjectPage extends GenericPage all of this has to be done manually */ - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); // temp locale if ($this->mode == CACHETYPE_TOOLTIP && isset($_GET['domain'])) @@ -72,7 +72,7 @@ class ObjectPage extends GenericPage { if ($h = $_['holidayId']) { - Util::$pageTemplate->extendGlobalIds(TYPE_WORLDEVENT, $_['id']); + $this->extendGlobalIds(TYPE_WORLDEVENT, $_['id']); $infobox[] = Util::ucFirst(Lang::$game['eventShort']).Lang::$main['colon'].'[event='.$h.']'; } } @@ -107,7 +107,7 @@ class ObjectPage extends GenericPage if ($idx < 0) continue; - Util::$pageTemplate->extendGlobalIds(TYPE_ITEM, $idx); + $this->extendGlobalIds(TYPE_ITEM, $idx); $l = Lang::$gameObject['key'].Lang::$main['colon'].'[item='.$idx.']'; } @@ -120,7 +120,7 @@ class ObjectPage extends GenericPage // linked trap if ($_ = $this->subject->getField('linkedTrap')) { - Util::$pageTemplate->extendGlobalIds(TYPE_OBJECT, $_); + $this->extendGlobalIds(TYPE_OBJECT, $_); $infobox[] = Lang::$gameObject['trap'].Lang::$main['colon'].'[object='.$_.']'; } @@ -152,7 +152,7 @@ class ObjectPage extends GenericPage { if ($_ = $this->subject->getField('mStone')) { - Util::$pageTemplate->extendGlobalIds(TYPE_ZONE, $_[2]); + $this->extendGlobalIds(TYPE_ZONE, $_[2]); $m = Lang::$game['meetingStone'].Lang::$main['colon'].'[zone='.$_[2].']'; $l = $_[0]; diff --git a/pages/objects.php b/pages/objects.php index b33ca0d2..953c67d3 100644 --- a/pages/objects.php +++ b/pages/objects.php @@ -23,7 +23,7 @@ class ObjectsPage extends GenericPage $this->filterObj = new GameObjectListFilter(); $this->getCategoryFromUrl($pageParam);; - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['gameObjects']); $this->subCat = $pageParam ? '='.$pageParam : ''; diff --git a/pages/pet.php b/pages/pet.php index 7ad33da5..f03357cc 100644 --- a/pages/pet.php +++ b/pages/pet.php @@ -18,9 +18,9 @@ class PetPage extends GenericPage protected $mode = CACHETYPE_PAGE; protected $js = ['swfobject.js']; - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); $this->typeId = intVal($id); diff --git a/pages/pets.php b/pages/pets.php index da20e719..e16f9c0d 100644 --- a/pages/pets.php +++ b/pages/pets.php @@ -21,7 +21,7 @@ class PetsPage extends GenericPage { $this->getCategoryFromUrl($pageParam);; - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['pets']); } diff --git a/pages/profile.php b/pages/profile.php index 018c4992..0c575c17 100644 --- a/pages/profile.php +++ b/pages/profile.php @@ -47,8 +47,8 @@ class ProfilePage extends GenericPage } else if (count($_) == 3) { - if ($_ = DB::Aowow()->selectCell('SELECT 2161862')) // some query to validate existence of char - $this->profileId = $_; + if ($foo = DB::Aowow()->selectCell('SELECT 2161862')) // some query to validate existence of char + $this->profileId = $foo; else $this->notFound(Util::ucFirst(Lang::$game['profile'])); diff --git a/pages/quest.php b/pages/quest.php index 6e218c94..5dc369be 100644 --- a/pages/quest.php +++ b/pages/quest.php @@ -23,9 +23,9 @@ class QuestPage extends GenericPage ['path' => 'Mapper_ie6.css', 'ieCond' => 'lte IE 6'] ); - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); // temp locale if ($this->mode == CACHETYPE_TOOLTIP && isset($_GET['domain'])) diff --git a/pages/quests.php b/pages/quests.php index 7aeb02d2..d470b332 100644 --- a/pages/quests.php +++ b/pages/quests.php @@ -24,7 +24,7 @@ class QuestsPage extends GenericPage $this->filterObj = new QuestListFilter(); $this->getCategoryFromUrl($pageParam);; - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['quests']); $this->subCat = $pageParam ? '='.$pageParam : ''; diff --git a/pages/race.php b/pages/race.php index 412fc42d..4bd1b98e 100644 --- a/pages/race.php +++ b/pages/race.php @@ -18,9 +18,9 @@ class RacePage extends GenericPage protected $mode = CACHETYPE_PAGE; protected $js = ['swfobject.js']; - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); $this->typeId = intVal($id); diff --git a/pages/races.php b/pages/races.php index e2533e73..7240cd55 100644 --- a/pages/races.php +++ b/pages/races.php @@ -16,9 +16,9 @@ class RacesPage extends GenericPage protected $tabId = 0; protected $mode = CACHETYPE_PAGE; - public function __construct() + public function __construct($pageCall, $pageParam) { - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['races']); } diff --git a/pages/search.php b/pages/search.php index 25eb1895..efd0b07f 100644 --- a/pages/search.php +++ b/pages/search.php @@ -54,7 +54,7 @@ class SearchPage extends GenericPage ['_searchFaction'], ['_searchSkill'], ['_searchPet'], ['_searchCreatureAbility'], ['_searchSpell'], ); - public function __construct($__, $pageParam) + public function __construct($pageCall, $pageParam) { $this->search = urlDecode(trim($pageParam)); $this->query = strtr($this->search, '?*', '_%'); @@ -109,7 +109,7 @@ class SearchPage extends GenericPage $this->notFound(); } - parent::__construct($__, $pageParam); // just to set g_user and g_locale + parent::__construct($pageCall, $pageParam); // just to set g_user and g_locale } private function tokenizeQuery() diff --git a/pages/skill.php b/pages/skill.php index b9d35a54..eff77da0 100644 --- a/pages/skill.php +++ b/pages/skill.php @@ -19,9 +19,9 @@ class SkillPage extends GenericPage private $cat = 0; - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); $this->typeId = intVal($id); diff --git a/pages/skills.php b/pages/skills.php index 84c5be47..5ba37797 100644 --- a/pages/skills.php +++ b/pages/skills.php @@ -21,7 +21,7 @@ class SkillsPage extends GenericPage { $this->getCategoryFromUrl($pageParam);; - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['skills']); } diff --git a/pages/spell.php b/pages/spell.php index 81c22f06..a44b8aa9 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -21,9 +21,9 @@ class SpellPage extends GenericPage private $difficulties = []; private $firstRank = 0; - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); // temp locale if ($this->mode == CACHETYPE_TOOLTIP && isset($_GET['domain'])) diff --git a/pages/spells.php b/pages/spells.php index 09113f7a..cdab3c3d 100644 --- a/pages/spells.php +++ b/pages/spells.php @@ -88,7 +88,7 @@ class SpellsPage extends GenericPage $this->filterObj = new SpellListFilter(); $this->getCategoryFromUrl($pageParam);; - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['spells']); $this->subCat = $pageParam ? '='.$pageParam : ''; diff --git a/pages/talent.php b/pages/talent.php index 19aaabf4..c30a0dc2 100644 --- a/pages/talent.php +++ b/pages/talent.php @@ -9,6 +9,7 @@ class TalentPage extends GenericPage { protected $tpl = 'talent'; protected $tabId = 1; + protected $path = [1]; protected $mode = CACHETYPE_NONE; protected $gDataKey = true; protected $js = ['TalentCalc.js']; @@ -21,9 +22,9 @@ class TalentPage extends GenericPage private $isPetCalc = false; - public function __construct($pageCall) + public function __construct($pageCall, $__) { - parent::__construct(); + parent::__construct($pageCall, $__); $this->isPetCalc = $pageCall == 'petcalc'; $this->name = $this->isPetCalc ? Lang::$main['petCalc'] : Lang::$main['talentCalc']; @@ -47,7 +48,10 @@ class TalentPage extends GenericPage array_unshift($this->title, $this->name); } - protected function generatePath() {} + protected function generatePath() + { + $this->path[] = $this->isPetCalc ? 2 : 0; + } } ?> diff --git a/pages/title.php b/pages/title.php index b6079776..bfbe822e 100644 --- a/pages/title.php +++ b/pages/title.php @@ -24,9 +24,9 @@ class TitlePage extends GenericPage private $nameFixed = ''; - public function __construct($__, $id) + public function __construct($pageCall, $id) { - parent::__construct(); + parent::__construct($pageCall, $id); $this->typeId = intVal($id); @@ -40,7 +40,7 @@ class TitlePage extends GenericPage protected function generatePath() { - $this->path[] = $this->subject->getField('typeCat'); + $this->path[] = $this->subject->getField('category'); } protected function generateTitle() diff --git a/pages/titles.php b/pages/titles.php index 009abcfe..074f3c25 100644 --- a/pages/titles.php +++ b/pages/titles.php @@ -21,7 +21,7 @@ class TitlesPage extends GenericPage { $this->getCategoryFromUrl($pageParam);; - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['titles']); } diff --git a/pages/zones.php b/pages/zones.php index 68029076..bfe81b78 100644 --- a/pages/zones.php +++ b/pages/zones.php @@ -29,7 +29,7 @@ class ZonesPage extends GenericPage { $this->getCategoryFromUrl($pageParam);; - parent::__construct(); + parent::__construct($pageCall, $pageParam); $this->name = Util::ucFirst(Lang::$game['zones']); } diff --git a/static/css/global.css b/static/css/global.css index 44033625..d3c50bc6 100644 --- a/static/css/global.css +++ b/static/css/global.css @@ -405,7 +405,7 @@ h1 a, h2 a, h3 a, h4 a, h5 a, h1 a.icontiny span, h2 a.icontiny span, h3 a.icont overflow: hidden; } -a#toptabs-menu-language +a#toplinks-language { padding-left: 21px; background: url(../images/icons/language.gif) left center no-repeat; @@ -536,7 +536,7 @@ a#toptabs-menu-language #main-precontents { background: #141414; - padding: 10px; + padding: 5px; border-left: 1px solid #101010; border-right: 1px solid #101010; } @@ -580,15 +580,7 @@ span.breadcrumb-ellipsis { float: right; font-size: 14px; margin-right: 4px; -} - -.path -{ - cursor: default; - font-size: 15px; - /*padding: 0 0 10px 20px; */ - padding-left: 20px; - background: url(../images/icons/favicon.gif) left 1px no-repeat; + padding: 5px 0 5px 0px; } #footer @@ -994,20 +986,6 @@ span.menu-buttons span.hassubmenu { background: url(../images/Menu/arrow-down.gif) right center no-repeat; } -/* start note: remove with breadcrumbs */ -.menuarrow -{ - padding-right: 16px; - background: url(../images/Menu/arrow-right.gif) right center no-repeat; -} - -.menuarrowd -{ - padding-right: 11px; - background: url(../images/Menu/arrow-down.gif) right center no-repeat; -} -/* end note */ - .tabs, .text ul.tabs, ul.tabs { margin: 0; @@ -3575,7 +3553,7 @@ a:hover, a.open, .infobox li div, .text b color: #E5CC80; } -.text ul li, .comment-body ul li +.text ul, .comment-body ul { /* color: #c3030b; */ list-style-type: square; diff --git a/static/js/Book.js b/static/js/Book.js index 6ecedf22..d11b354d 100644 --- a/static/js/Book.js +++ b/static/js/Book.js @@ -1,99 +1,99 @@ function Book(opt) { - if (!opt.parent || !opt.pages || opt.pages.length == 0) { - return; - } + if (!opt.parent || !opt.pages || opt.pages.length == 0) { + return; + } - opt.parent = $WH.ge(opt.parent); + opt.parent = $WH.ge(opt.parent); - var + var d, a, _; - this.nPages = opt.pages.length; + this.nPages = opt.pages.length; - this.parent = $WH.ge(opt.parent); - this.parent.className += ' book'; + this.parent = $WH.ge(opt.parent); + this.parent.className += ' book'; - d = $WH.ce('div'); - d.className = 'paging'; - if (this.nPages == 1) { - d.style.display = 'none'; - } - $WH.ns(d); + d = $WH.ce('div'); + d.className = 'paging'; + if (this.nPages == 1) { + d.style.display = 'none'; + } + $WH.ns(d); - _ = $WH.ce('div'); - _.style.visibility = 'hidden'; - _.className = 'previous'; - a = $WH.ce('a'); - a.appendChild($WH.ct(String.fromCharCode(8249) + LANG.lvpage_previous)); - a.href = 'javascript:;'; - a.onclick = this.previous.bind(this); - _.appendChild(a); - d.appendChild(_); + _ = $WH.ce('div'); + _.style.visibility = 'hidden'; + _.className = 'previous'; + a = $WH.ce('a'); + a.appendChild($WH.ct(String.fromCharCode(8249) + LANG.lvpage_previous)); + a.href = 'javascript:;'; + a.onclick = this.previous.bind(this); + _.appendChild(a); + d.appendChild(_); - _ = $WH.ce('div'); - _.style.visibility = 'hidden'; - _.className = 'next'; - a = $WH.ce('a'); - a.appendChild($WH.ct(LANG.lvpage_next + String.fromCharCode(8250))); - a.href = 'javascript:;'; - a.onclick = this.next.bind(this); - _.appendChild(a); - d.appendChild(_); + _ = $WH.ce('div'); + _.style.visibility = 'hidden'; + _.className = 'next'; + a = $WH.ce('a'); + a.appendChild($WH.ct(LANG.lvpage_next + String.fromCharCode(8250))); + a.href = 'javascript:;'; + a.onclick = this.next.bind(this); + _.appendChild(a); + d.appendChild(_); - _ = $WH.ce('b'); - _.appendChild($WH.ct('1')); - d.appendChild(_); + _ = $WH.ce('b'); + _.appendChild($WH.ct('1')); + d.appendChild(_); - d.appendChild($WH.ct(LANG.lvpage_of)); + d.appendChild($WH.ct(LANG.lvpage_of)); - _ = $WH.ce('b'); - _.appendChild($WH.ct(this.nPages)); - d.appendChild(_); + _ = $WH.ce('b'); + _.appendChild($WH.ct(this.nPages)); + d.appendChild(_); - opt.parent.appendChild(d); + opt.parent.appendChild(d); - for (var i = 0; i < this.nPages; ++i) { - d = $WH.ce('div'); - d.className = 'page'; - d.style.display = 'none'; + for (var i = 0; i < this.nPages; ++i) { + d = $WH.ce('div'); + d.className = 'page'; + d.style.display = 'none'; - d.innerHTML = opt.pages[i]; + d.innerHTML = opt.pages[i]; - opt.parent.appendChild(d); - } + opt.parent.appendChild(d); + } - this.page = 1; - this.changePage(opt.page || 1); + this.page = 1; + this.changePage(opt.page || 1); } Book.prototype = { - changePage: function(page) { - if (page < 1) { - page = 1; - } + changePage: function(page) { + if (page < 1) { + page = 1; + } else if (page > this.nPages) { page = this.nPages; - } + } - var _ = this.parent.childNodes; - _[this.page].style.display = 'none'; - _[page].style.display = ''; - this.page = page; + var _ = this.parent.childNodes; + _[this.page].style.display = 'none'; + _[page].style.display = ''; + this.page = page; - _ = _[0].childNodes; - _[0].style.visibility = (page == 1) ? 'hidden': 'visible'; - _[1].style.visibility = (page == this.nPages) ? 'hidden': 'visible'; + _ = _[0].childNodes; + _[0].style.visibility = (page == 1) ? 'hidden': 'visible'; + _[1].style.visibility = (page == this.nPages) ? 'hidden': 'visible'; - _[2].innerHTML = page; - }, + _[2].innerHTML = page; + }, - next: function() { - this.changePage(this.page + 1); - }, + next: function() { + this.changePage(this.page + 1); + }, - previous: function() { - this.changePage(this.page - 1); - } + previous: function() { + this.changePage(this.page - 1); + } }; diff --git a/static/js/Mapper.js b/static/js/Mapper.js index 643a598a..1c970be9 100644 --- a/static/js/Mapper.js +++ b/static/js/Mapper.js @@ -346,7 +346,7 @@ Mapper.prototype = { this.level = level; } - var type = g_locale.name; + var type = Locale.getName(); if($WH.isset('g_ptr') && g_ptr) type = 'ptr'; diff --git a/static/js/Markup.js b/static/js/Markup.js index ed45ee40..8ee2c587 100644 --- a/static/js/Markup.js +++ b/static/js/Markup.js @@ -4,7 +4,7 @@ var MARKUP_MODE_COMMENT = 1, MARKUP_MODE_ARTICLE = 2, MARKUP_MODE_QUICKFACTS = 3, MARKUP_MODE_SIGNATURE = 4, - MARKUP_MODE_REPLY = 5, + MARKUP_MODE_REPLY = 5, MARKUP_CLASS_ADMIN = 40, MARKUP_CLASS_STAFF = 30, MARKUP_CLASS_PREMIUM = 20, @@ -28,4098 +28,4098 @@ MarkupSourceMap[MARKUP_SOURCE_PTR] = 'ptr'; MarkupSourceMap[MARKUP_SOURCE_BETA] = 'beta'; var Markup = { - MODE_COMMENT: MARKUP_MODE_COMMENT, - MODE_REPLY: MARKUP_MODE_REPLY, - MODE_ARTICLE: MARKUP_MODE_ARTICLE, - MODE_QUICKFACTS: MARKUP_MODE_QUICKFACTS, - MODE_SIGNATURE: MARKUP_MODE_SIGNATURE, - - SOURCE_LIVE: MARKUP_SOURCE_LIVE, - SOURCE_PTR: MARKUP_SOURCE_PTR, - SOURCE_BETA: MARKUP_SOURCE_BETA, - - CLASS_ADMIN: MARKUP_CLASS_ADMIN, - CLASS_STAFF: MARKUP_CLASS_STAFF, - CLASS_PREMIUM: MARKUP_CLASS_PREMIUM, - CLASS_USER: MARKUP_CLASS_USER, - CLASS_PENDING: MARKUP_CLASS_PENDING, - - whitelistedWebsites: [/(.*\.)?wowhead.com/i, /(.*\.)?thottbot.com/i, /(.*\.)?torhead.com/i, /(.*\.)?mmoui.com/i, /(.*\.)?tankspot.com/i, /(.*\.)?guildfans.com/i, /(.*\.)?allakhazam.com/i, /(.*\.)?zam.com/i, /(.*\.)?blizzard.com/i, /(.*\.)?worldofwarcraft.com/i, /(.*\.)?wow-europe.com/i, /(.*\.)?battle.net/i, /(.*\.)?sc2ranks.com/i, /(.*\.)?torchlightarmory.com/i, /(.*\.)?vindictusdb.com/i, /(.*\.)?wowinterface.com/i, /(.*\.)?vginterface.com/i, /(.*\.)?lotrointerface.com/i, /(.*\.)?eq2interface.com/i, /(.*\.)?eqinterface.com/i, /(.*\.)?mmo-champion.com/i, /(.*\.)?joystiq.com/i, /(.*\.)?wow-heroes.com/i, /(.*\.)?be-imba.hu/i, /(.*\.)?wowpedia.org/i, /(.*\.)?curse.com/i, /(.*\.)?elitistjerks.com/i, /(.*\.)?wowwiki.com/i, /(.*\.)?worldoflogs.com/i, /(.*\.)?wowinsider.com/i, /(.*\.)?guildwork.com/i], - - rolesToClass: function(roles) - { - if(roles & (U_GROUP_ADMIN|U_GROUP_VIP|U_GROUP_DEV)) - return Markup.CLASS_ADMIN; - else if(roles & U_GROUP_STAFF) - return Markup.CLASS_STAFF; - else if(roles & U_GROUP_PREMIUM) - return Markup.CLASS_PREMIUM; - else if(roles & U_GROUP_PENDING) - return Markup.CLASS_PENDING; - else - return Markup.CLASS_USER; - }, - - defaultSource: false, - nameCol: 'name_enus', - domainToLocale: { - 'www': 'enus', - 'ptr': 'ptr', - 'beta': 'beta', - 'mop': 'beta', - 'fr': 'frfr', - 'de': 'dede', - 'es': 'eses', - 'ru': 'ruru', - 'pt': 'ptbr' - }, - maps: [], - firstTags: {}, - postTags: [], - collectTags: {}, - excludeTags: {}, - tooltipTags: {}, - tooltipBare: {}, - attributes: { - id: { req: false, valid: /^[a-z0-9_-]+$/i }, - title: { req: false, valid: /[\S ]+/ }, - 'class': { req: false, valid: /\S+/ } - }, - IsLinkAllowed: function(link) - { - var matches = link.match('[a-z]+:\/\/([a-z0-9\.\-]+)'); - - if(!matches) - return true; - - var domain = matches[1]; - var allowed = false; - - for(var i in Markup.whitelistedWebsites) - { - var r = Markup.whitelistedWebsites[i]; - - if(domain.search(r) == 0) - allowed = true; - } - - return allowed; - }, - tags: { - '': - { - empty: true, - noHelp: true, - allowInReplies: true, - toHtml: function(attr, extra) - { - extra = extra || $.noop; - - if(attr._text == ' ' && !extra.noNbsp) - attr._text = ' '; - - attr._text = attr._text.replace(/\\\[/g, '['); - - if(extra && extra.noLink) - return attr._text; - else if(extra && extra.needsRaw) - return attr._rawText; - else - { - var link = []; - var text = Markup._preText(attr._rawText.replace(/(https?:\/\/|www\.)([\/_a-z0-9\%\?#@\-\+~&=;:']|\.[a-z0-9\-])+/gi, function(match) { - matchUrl = Markup._preText(match.replace(/^www/, 'http://www')); - match = Markup._preText(match); - var i = link.length; - link.push([matchUrl, match]); - return '$L' + i; - })); - text = text.replace(/\$L([\d+]) /gi, '$L$1 '); - for(var i in link) - { - text = text.replace('$L' + i, function(match) { - if(Markup.allow < Markup.CLASS_USER && !Markup.IsLinkAllowed(link[i][0])) - return $WH.sprintf('[$1]', LANG.linkremoved); - var url = ''; - return url; - }); - } - return text; - } - }, - toText: function(attr) - { - return attr._text; - } - }, - achievement: - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - diff: { req: false, valid: /^[0-9]+$/ }, - icon: { req: false, valid: /^false$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - var rel = []; - - if(attr.diff) - rel.push('diff=' + attr.diff); - - if(g_achievements[id] && g_achievements[id][nameCol]) - { - var ach = g_achievements[id]; - return ' ' + Markup._safeHtml(ach[nameCol]) + ''; - } - return '(' + LANG.types[10][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_achievements[id] && g_achievements[id][nameCol]) - return Markup._safeHtml(g_achievements[id][nameCol]); - return LANG.types[10][0] + ' #' + id; - } - }, - achievementpoints: - { - empty: true, - attr: - { - unnamed: {req: true, valid: /^[0-9]+$/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - var str = '' + attr.unnamed + ''; - return str; - } - }, - anchor: - { - empty: true, - ltrim: true, - rtrim: true, - attr: - { - unnamed: { req: false, valid: /\S+/ } - }, - validate: function(attr) - { - if(!attr.unnamed && !attr.id) - return false; - return true; - }, - toHtml: function(attr) - { - if(!attr.unnamed && attr.id) - { - attr.unnamed = attr.id; - attr.id = null; - } - return ''; - } - }, - acronym: - { - empty: false, - attr: - { - unnamed: { req: false } - }, - toHtml: function(attr) - { - return ['', '']; - } - }, - b: - { - empty: false, - allowInReplies: true, - toHtml: function(attr) - { - return ['', '']; - }, - fromHtml: function(str) - { - return str.replace(/<(b|big|strong)\b[\s\S]*?>([\s\S]*?)<\/\1>/gi, '[b]$2[/b]'); - } - }, - blip: - { - empty: true, - attr: - { - unnamed: { req: true, valid: /\S+/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - var url = 'http://blip.tv/play/' + attr.unnamed; - var width = 600; - var height = 368; - - var html = ''; - // object tag causing issues in chrome? - /*html += ''; - html += ''; - html += ''; - html += '';*/ - html += ''; - //html += ''; - - return html; - } - }, - br: - { - empty: true, - toHtml: function(attr) - { - return '
'; - }, - fromHtml: function(str) - { - return str.replace(//gi, "\n"); - } - }, - 'class': - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - icon: { req: false, valid: /^false$/i }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - if(attr.unnamed >= 1 && attr.unnamed <= 11) - return true; - return false; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_classes[id] && g_classes[id][nameCol]) - { - var cls = g_classes[id]; - return ' ' + Markup._safeHtml(cls[nameCol]) + ''; - } - return '(' + LANG.types[13][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_classes[id] && g_classes[id][nameCol]) - return Markup._safeHtml(g_classes[id][nameCol]); - return LANG.types[13][0] + ' #' + id; - } - }, - code: - { - block: true, - empty: false, - rtrim: true, - itrim: true, - helpText: true, - allowedChildren: { '': 1 }, - toHtml: function(attr) - { - var open = '
';
-				return [open, '
']; - } - }, - color: - { - empty: false, - attr: - { - unnamed: { req: true, valid: /^.*/i } - }, - allowedClass: MARKUP_CLASS_STAFF, - /* Syntax: name: class */ - extraColors: {deathknight: 'c6', dk: 'c6', druid: 'c11', hunter: 'c3', mage: 'c8', paladin: 'c2', priest: 'c5', rogue: 'c4', shaman: 'c7', warlock: 'c9', warrior: 'c1', poor: 'q0', common: 'q1', uncommon: 'q2', rare: 'q3', epic: 'q4', legendary: 'q5', artifact: 'q6', heirloom: 'q7'}, - toHtml: function(attr) - { - var valid = /^(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow|c\d+|r\d+|q\d*?|#[a-f0-9]{6})$/i; - var str = '']; - } - }, - currency: - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - amount: { req: false, valid: /^[0-9\:]+$/ }, - icon: { req: false, valid: /^false$/i }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_gatheredcurrencies[id] && g_gatheredcurrencies[id][nameCol]) - { - var curr = g_gatheredcurrencies[id]; - if(attr.amount) - return ' ' + attr.amount.split(':').join(' - ') + ''; - else - return ' ' + Markup._safeHtml(curr[nameCol]) + ''; - } - - return '(' + LANG.types[17][0] + ' #' + id + ')' + (attr.amount > 0 ? ' x' + attr.amount : ''); - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_gatheredcurrencies[id] && g_gatheredcurrencies[id][nameCol]) - return Markup._safeHtml(g_gatheredcurrencies[id][nameCol]); - return LANG.types[17][0] + ' #' + id; - } - }, - db: - { - empty: true, - attr: - { - unnamed: { req: true, valid: /^(live|ptr|beta|mop)$/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - if(attr.unnamed == 'live') - Markup.defaultSource = Markup.SOURCE_LIVE; - else if(attr.unnamed == 'ptr') - Markup.defaultSource = Markup.SOURCE_PTR; - else if(attr.unnamed == 'beta' || attr.unnamed == 'mop') - Markup.defaultSource = Markup.SOURCE_BETA; - return ''; - }, - toText: function(attr) - { - if(attr.unnamed == 'live') - Markup.defaultSource = Markup.SOURCE_LIVE; - else if(attr.unnamed == 'ptr') - Markup.defaultSource = Markup.SOURCE_PTR; - else if(attr.unnamed == 'beta' || attr.unnamed == 'mop') - Markup.defaultSource = Markup.SOURCE_BETA; - return ''; - } - }, - del: - { - empty: false, - attr: - { - copy: { req: false, valid: /^true$/ } - }, - toHtml: function(attr) - { - var str = '']; - } - }, - div: - { - empty: false, - block: true, - ltrim: true, - rtrim: true, - itrim: true, - attr: - { - clear: { req: false, valid: /^(left|right|both)$/i }, - unnamed: { req: false, valid: /^hidden$/i }, - 'float': { req: false, valid: /^(left|right)$/i }, - align: { req: false, valid: /^(left|right|center)$/i }, - margin: { req: false, valid: /^\d+(px|em|\%)$/ }, - width: { req: false, valid: /^[0-9]+(px|em|\%)$/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - var str = ' 0) - str += ' style="' + styles.join(';') + '"'; - if(classes.length > 0) - str += ' class="' + classes.join(' ') + '"'; - - str += '>'; - return [str, '']; - }, - fromHtml: function(str, depth) - { - depth = depth || 0; - - var m; - if(m = Markup.matchOuterTags(str, '', '', 'g')) - { - for(var i = 0; i < m.length; ++i) - { - var align = m[i][1].match(/float:\s*(left|right)"/i), - width = m[i][1].match(/width[:="]+\s*([0-9]+)/i); - - str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n" + Array(depth + 1).join("\t") + '[div' + (align ? ' float=' + align[1] : '') + (width ? ' width=' + width[1] : '') + ']' + Markup.tags.div.fromHtml(m[i][0], depth + 1) + '[/div]'); - } - } - - return str; - } - }, - event: - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_holidays[id] && g_holidays[id][nameCol]) - { - var evt = g_holidays[id]; - return '' + Markup._safeHtml(evt[nameCol]) + ''; - } - return '(' + LANG.types[12][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_holidays[id] && g_holidays[id][nameCol]) - return Markup._safeHtml(g_holidays[id][nameCol]); - return LANG.types[12][0] + ' #' + id; - } - }, - faction: - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_factions[id] && g_factions[id][nameCol]) - { - var fac = g_factions[id]; - return '' + Markup._safeHtml(fac[nameCol]) + ''; - } - return '(' + LANG.types[8][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_factions[id] && g_factions[id][nameCol]) - return Markup._safeHtml(g_factions[id][nameCol]); - return LANG.types[8][0] + ' #' + id; - } - }, - feedback: - { - empty: true, - allowedClass: MARKUP_CLASS_STAFF, - attr: - { - mailto: { req: false, valid: /^true$/i } - }, - toHtml: function(attr) - { - return 'feedback@wowhead.com'; - } - }, - forumrules: - { - empty: true, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - return 'forum rules'; - } - }, - hr: - { - empty: true, - trim: true, - allowedModes: { article: 1, quickfacts: 1, comment: 1 }, - toHtml: function(attr) - { - return '
'; - }, - fromHtml: function(str) - { - return str.replace(//gi, '[hr]'); - } - }, - h2: - { - block: true, - empty: false, - ltrim: true, - rtrim: true, - itrim: true, - allowedClass: MARKUP_CLASS_STAFF, - attr: - { - unnamed: { req: false, valid: /^first$/i }, - clear: { req: false, valid: /^(true|both|left|right)$/i }, - toc: { req: false, valid: /^false$/i } - }, - toHtml: function(attr) - { - if(!attr.id) - attr.id = g_urlize(attr._textContents); - str = ' 0) - str += ' class="' + classes.join(' ') + '"'; - if(attr.clear) - { - if(attr.clear == 'true' || attr.clear == 'both') - str += ' style="clear: both"'; - else - str += ' style="clear: ' + attr.clear + '"'; - } - return [str + '>', '']; - }, - fromHtml: function(str) - { - return str.replace(/([\s\S]*?)<\/h2>/gi, "\n[h2]$1[/h2]"); - } - }, - h3: - { - block: true, - empty: false, - ltrim: true, - rtrim: true, - itrim: true, - attr: - { - unnamed: { req: false, valid: /^first$/i }, - toc: { req: false, valid: /^false$/i } - }, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - if(!attr.id) - attr.id = g_urlize(attr._textContents); - var str = ' 0) - str += ' class="' + classes.join(' ') + '"'; - return [str + '>', '']; - }, - fromHtml: function(str) - { - return str.replace(/([\s\S]*?)<\/h3>/gi, "\n[h3]$1[/h3]"); - } - }, - html: - { - empty: false, - allowedClass: MARKUP_CLASS_ADMIN, - allowedChildren: { '': 1 }, - rawText: true, - taglessSkip: true, - toHtml: function(attr) - { - return [attr._contents]; - } - }, - i: - { - empty: false, - allowInReplies: true, - toHtml: function(attr) - { - return ['', '']; - }, - fromHtml: function(str) - { - return str.replace(/<(i|em)\b[\s\S]*?>([\s\S]*?)<\/\1>/gi, '[i]$1[/i]'); - } - }, - icon: - { - empty: false, - itrim: true, - attr: - { - align: { req: false, valid: /^right$/i }, - 'float': { req: false, valid: /^(left|right)$/i }, - name: { req: false, valid: /\S+/ }, - size: { req: false, valid: /^(tiny|small|medium|large)$/ }, - unnamed: { req: false, valid: /^class$/i }, - url: { req: false, valid: /\S+/ }, - preset: { req: false, valid: /\S+/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - presets: { - boss: g_staticUrl + '/images/icons/boss.gif', - heroic: g_staticUrl + '/images/icons/heroic.gif' - }, - validate: function(attr) - { - if(!attr.name && !attr.url && !attr.preset) - return false; - if(attr.preset && !Markup.tags.icon.presets[attr.preset]) - return false; - return true; - }, - toHtml: function(attr) - { - var size = (attr.size ? attr.size : "tiny"); - if(!attr.name) attr.name = ''; - - if(size == "tiny") { - var str = ''; - } - else - str += attr.name + '">'; - return [str, '
']; - } - else - { - var str = '' : '">' ); - - var sizes = {'small': 0, 'medium': 1, 'large': 2}; - var url = null; - if(attr.url && Markup._isUrlSafe(attr.url)) - url = attr.url; - else if(attr._textContents && Markup._isUrlSafe(attr._textContents)) - url = attr._textContents; - - icon = Icon.create(attr.name.toLowerCase(), sizes[size], null, url); - - str += icon.innerHTML + ''; - return [str]; - } - } - }, - iconlist: - { - empty: false, - block: true, - ltrim: true, - rtrim: true, - attr: - { - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - taglessSkip: true, - allowedClass: MARKUP_CLASS_STAFF, - allowedChildren: { b: 1, achievement: 1, currency: 1, faction: 1, holiday: 1, item: 1, itemset: 1, npc: 1, object: 1, pet: 1, quest: 1, spell: 1, title: 1, zone: 1 }, - toHtml: function(attr) - { - var domain = Markup._getDatabaseDomainInfo(attr)[2]; - - var str = '', m; - for(var i = 0; i < attr._nodes.length; ++i) - { - var node = $WH.dO(attr._nodes[i]); - node.attr.domain = domain; - - var html = Markup.tags[node.name].toHtml(node.attr), - type = node.name, - href = '', - icon = ''; - - if(typeof html != 'string') // Bold open/close tags - html = html[0] + node.attr._contents + html[1]; - else if(typeof html == 'string' && (m = html.match(/href="(.+?)".+?url\(\/images\/wow\/icons\/tiny\/(.+?)\.gif\)/))) - { - node.attr.icon = 'false'; - html = Markup.tags[node.name].toHtml(node.attr); - href = m[1]; - icon = m[2]; - } - - if(html) - str += '' + (icon ? Markup.toHtml('[icon name=' + icon + ' size=small url=' + href + ']', { skipReset: true }) : '
  •  
') + '' + html + ''; - } - - if(str) - str = '
' + str + '
'; - - return [str]; - } - }, - img: - { - empty: true, - attr: - { - src: { req: false, valid: /\S+/ }, - icon: { req: false, valid: /\S+/ }, - id: { req: false, valid: /^[0-9]+$/ }, - blog: { req: false, valid: /^[0-9]+$/ }, - size: { req: false, valid: /^(thumb|resized|normal|large|medium|small|tiny)$/i }, - width: { req: false, valid: /^[0-9]+$/ }, - height: { req: false, valid: /^[0-9]+$/ }, - 'float': { req: false, valid: /^(left|right|center)$/i }, - border: { req: false, valid: /^[0-9]+$/ }, - margin: { req: false, valid: /^[0-9]+$/ } - }, - blogSize: /^(thumb|normal)$/i, - idSize: /^(thumb|resized|normal)$/i, - iconSize: /^(large|medium|small|tiny)$/i, - allowedClass: MARKUP_CLASS_STAFF, - validate: function(attr) - { - if(attr.src) - return true; - else if(attr.id) - return (attr.size ? Markup.tags.img.idSize.test(attr.size) : true); - else if(attr.icon) - return (attr.size ? Markup.tags.img.iconSize.test(attr.size) : true); - else if(attr.blog) - return (attr.size ? Markup.tags.img.blogSize.test(attr.size) : true); - return false; - }, - toHtml: function(attr) - { - var str = '' + str; - post = ''; - var screenshot = { - url: url, - caption: img.alt, - width: img.width, - height: img.height, - noMarkup: true - }; - g_screenshots[Markup.uid].push(screenshot); - } - else - str += ' src="' + g_staticUrl + '/uploads/blog/images/' + attr.blog + (img.type == 3 ? '.png' : '.jpg') + '" alt="' + Markup._safeHtml(img.alt) + '" width="' + img.width + '" height="' + img.height + '"'; - } - else - return ('Image #' + attr.blog); - } - - if(attr.width) - str += ' width="' + attr.width + '"'; - if(attr.height) - str += ' height="' + attr.height + '"'; - if(attr['float']) - { - if(attr['float'] == 'center') - { - str = '
' + str + ' style="margin: 10px auto"'; - post = '
'; - } - else - { - str += ' style="float: ' + attr['float'] + ';'; - if(!attr.margin) - attr.margin = 10; - if(attr['float'] == 'left') - str += ' margin: 0 ' + attr.margin + 'px ' + attr.margin + 'px 0"'; - else - str += ' margin: 0 0 ' + attr.margin + 'px ' + attr.margin + 'px"'; - } - } - if(attr.border != 0) - str += ' class="border"'; - if(attr.title) - str += ' alt="' + attr.title + '"'; - else - str += ' alt=""'; - str += ' />' + post; - return str; - }, - fromHtml: function(str) - { - var m; - if(m = str.match(//gi)) - { - for(var i = 0; i < m.length; ++i) - { - var source = m[i].match(/src="([\s\S]+?)"/i), - width = m[i].match(/width[:="]+\s*([0-9]+)/i), - height = m[i].match(/height[:="]+\s*([0-9]+)/i), - border = m[i].match(/border[:="]+\s*([0-9]+)/i); - - str = str.replace(m[i], '[img src=' + source[1] + (width ? ' width=' + width[1] : '') + (height ? ' height=' + height[1] : '') + ' border=' + (border ? border[1] : 0) + ']'); - } - } - return str; - } - }, - ins: - { - empty: false, - toHtml: function(attr) - { - return ['', '']; - } - }, - item: - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - icon: { req: false, valid: /^false$/i }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_items[id] && g_items[id][nameCol]) - { - var item = g_items[id]; - var str = ' '; - str += Markup._safeHtml(item[nameCol]) + ''; - return str; - } - return '(' + LANG.types[3][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_items[id] && g_items[id][nameCol]) - return Markup._safeHtml(g_items[id][nameCol]); - return LANG.types[3][0] + ' #' + id; - } - }, - itemset: - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^-?[0-9]+$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_itemsets[id] && g_itemsets[id][nameCol]) - { - var set = g_itemsets[id]; - return '' + Markup._safeHtml(set[nameCol]) + ''; - } - return '(' + LANG.types[4][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_itemsets[id] && g_itemsets[id][nameCol]) - return Markup._safeHtml(g_itemsets[id][nameCol]); - return LANG.types[4][0] + ' #' + id; - } - }, - li: - { - empty: false, - itrim: true, - allowedParents: { ul: 1, ol: 1 }, - helpText: function() - { - var str = ''; - str += '[ul]'; - for(var i = 0; i < 3; ++i) - str += '\n[li]' + LANG.markup_li + '[/li]'; - str += '\n[/ul]\n\n'; - str += '[ol]'; - for(var i = 0; i < 3; ++i) - str += '\n[li]' + LANG.markup_li + '[/li]'; - str += '\n[/ol]\n'; - return str.toLowerCase(); - }, - toHtml: function(attr) - { - return ['
', '
']; - }, - fromHtml: function(str, depth) - { - depth = depth || 0; - - var m; - if(m = Markup.matchOuterTags(str, '', '', 'g')) - { - for(var i = 0; i < m.length; ++i) - str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n\t" + Array(depth + 1).join("\t") + '[li]' + Markup.tags.li.fromHtml(m[i][0], depth + 1) + '[/li]'); - } - - return str; - } - }, - lightbox: - { - empty: false, - allowedClass: MARKUP_CLASS_STAFF, - attr: - { - unnamed: { req: true, valid: /^(map|model|screenshot)$/ }, - zone: { req: false, valid: /^-?[0-9]+[a-z]?$/i }, - floor: { req: false, valid: /^[0-9]+$/ }, - pins: { req: false, valid: /^[0-9]+$/ } - }, - validate: function(attr) - { - switch(attr.unnamed) - { - case 'map': - if(attr.zone) - return true; - break; - case 'model': - break; - case 'screenshot': - break; - } - return false; - }, - toHtml: function(attr) - { - var url = ''; - var onclick = ''; - switch(attr.unnamed) - { - case 'map': - url = '/maps=' + attr.zone; - if(attr.floor) - url += '.' + attr.floor; - if(attr.pins) - url += ':' + attr.pins; - var link = url.substr(6); - - onclick = 'if(!g_isLeftClick(event)) return; MapViewer.show({ link: \'' + link + '\' }); return false;'; - break; - } - - if(url && onclick) - return ['', '']; - return ''; - } - }, - map: - { - empty: false, - attr: - { - zone: { req: true, valid: /^-?[0-9a-z\-_]+$/i }, - source: { req: false, valid: /\S+/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - allowedChildren: { pin: 1 }, - toHtml: function(attr) - { - var coords = attr._contents; - attr.id = 'dsgdfngjkfdg' + (Markup.maps.length); - var str = '
'; - - Markup.maps.push([attr.id, attr.zone, coords]); - - return [ str ]; - } - }, - n5: - { - empty: true, - attr: - { - unnamed: { req: true, valid: /^[0-9\.]+$/ } - }, - toHtml: function(attr) - { - return GetN5(attr.unnamed); - } - }, - pin: - { - empty: false, - attr: - { - url: { req: false, valid: /\S+/ }, - type: { req: false, valid: /^[0-9]+$/ }, - x: { req: true, valid: /^[0-9]{1,2}(\.[0-9])?$/ }, - y: { req: true, valid: /^[0-9]{1,2}(\.[0-9])?$/ }, - path: { req: false, valid: /^([0-9]{1,2}(\.[0-9])?[,:]?)+$/ } - }, - taglessSkip: true, - allowedClass: MARKUP_CLASS_STAFF, - allowedParents: { map: 1 }, - toHtml: function(attr) - { - if(attr.url && !Markup._isUrlSafe(attr.url)) - attr.url = ''; - var label = attr._contents; - if(attr.url && attr.url.indexOf('npc=') != -1) - label = '' + label + '
Click to view this NPC'; - - var lines = null; - if(attr.path) - { - var coords = attr.path.split(':'), lines = []; - for(var i = 0, len = coords.length; i < len; ++i) - { - var parts = coords[i].split(','); - if(parts.length == 2) - lines.push([parseFloat(parts[0] || 0), parseFloat(parts[1] || 0)]); - } - } - - return [ [parseFloat(attr.x || 0), parseFloat(attr.y || 0), { label: label, url: attr.url, type: attr.type, lines: lines }] ]; - /*var str = '[' + parseFloat(attr.x || 0) + ',' + parseFloat(attr.y || 0) + ',{label: \'' + Markup._safeJsString(label) + '\''; - if(attr.url) - str += ', url: \'' + Markup._safeJsString(Markup._fixUrl(attr.url)) + '\''; - if(attr.type) - str += ', type: \'' + Markup._safeJsString(attr.type) + '\''; - str += '}]'; - return [ [str] ];*/ - } - }, - markupdoc: - { - empty: true, - attr: - { - tag: { req: false, valid: /[a-z0-9]+/i }, - help: { req: false, valid: /^(admin|staff|premium|user|pending)$/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - validate: function(attr) - { - if(attr.tag && !Markup.tags[attr.tag]) - return false; - return true; - }, - toHtml: function(attr) - { - var str = '', - helpClass = (attr.help ? Markup['CLASS_' + attr.help.toUpperCase()] : false); - - if(helpClass) - str += LANG.markup_helpdoc + '
'; - - if(attr.tag) - str = Markup._generateTagDocs(attr.tag, helpClass); - else - { - for(var tag in Markup.tags) - { - if(!helpClass && str != '') - str += '
'; - str += Markup._generateTagDocs(tag, helpClass); - } - } - - return str + (helpClass ? '
' + LANG.markup_help1 + '' + LANG.markup_help2 + '
' : ''); - } - }, - menu: - { - empty: true, - trim: true, - ltrim: true, - rtrim: true, - attr: - { - tab: { req: true, valid: /^[0-9]+$/ }, - path: { req: true, valid: /\S+/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - var path = attr.path.split(','); - // sarjuuk: nyi :( PageTemplate.set({activeTab: attr.tab, breadcrumb: path}); - } - }, - minibox: - { - empty: false, - rtrim: true, - itrim: true, - attr: - { - 'float': { req: false, valid: /^(left|right)$/i } - }, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - var str = ''; - return [str, '']; - } - }, - model: - { - empty: false, - attr: - { - item: { req: false, valid: /^[0-9]+$/ }, - object: { req: false, valid: /^[0-9]+$/ }, - npc: { req: false, valid: /^[0-9]+$/ }, - itemset: { req: false, valid: /^[0-9,]+$/ }, - slot: { req: false, valid: /^[0-9]+$/ }, - humanoid: { req: false, valid: /^1$/ }, - 'float': { req: false, valid: /^(left|right)$/i }, - img: { req: false, valid: /\S+/ }, - link: { req: false, valid: /\S+/ }, - label: { req: false, valid: /[\S ]+/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - skipSlots: { 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1, 10: 1, 16: 1, 19: 1, 20: 1 }, - toHtml: function(attr) - { - var str = ''; - if(attr.npc) - { - str = '' + Markup._safeHtml(attr._contents) + '' + Markup._safeHtml(attr._contents) + '' + Markup._safeHtml(attr._contents) + ''; - } - else - return ['[model]', '[/model]']; - return [str, '']; - } - }, - money: - { - empty: true, - attr: - { - unnamed: { req: false, valid: /^[0-9]+$/ }, - side: { req: false, valid: /^(alliance|horde|both)$/i }, - items: { req: false, valid: /^[0-9,]+$/ }, - currency: { req: false, valid: /^[0-9,]+$/ }, - achievement: { req: false, valid: /\S+/ }, - arena: { req: false, valid: /^[0-9]+$/ }, - honor: { req: false, valid: /^[0-9]+$/ }, - }, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - var items = [], - currency = []; - - if(attr.items) - { - var split = attr.items.split(','); - if(split.length >= 2) - for(var i = 0; i < split.length-1; i += 2) - items.push([split[i], split[i+1]]); - } - - if(attr.currency) - { - var split = attr.currency.split(','); - if(split.length >= 2) - for(var i = 0; i < split.length-1; i += 2) - currency.push([split[i], split[i+1]]); - } - - // Backwards compatability - if(attr.honor) - currency.push([104, attr.honor]); - if(attr.arena) - currency.push([103, attr.arena]); - - return g_getMoneyHtml(attr.unnamed, attr.side, items, currency, attr.achievement); - } - }, - npc: - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_npcs[id] && g_npcs[id][nameCol]) - { - var npc = g_npcs[id]; - return '' + Markup._safeHtml(npc[nameCol]) + ''; - } - return '(' + LANG.types[1][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_npcs[id] && g_npcs[id][nameCol]) - return Markup._safeHtml(g_npcs[id][nameCol]); - return LANG.types[1][0] + ' #' + id; - } - }, - object: - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_objects[id] && g_objects[id][nameCol]) - { - var obj = g_objects[id]; - return '' + Markup._safeHtml(obj[nameCol]) + ''; - } - return '(' + LANG.types[2][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_objects[id] && g_objects[id][nameCol]) - return Markup._safeHtml(g_objects[id][nameCol]); - return LANG.types[2][0] + ' #' + id; - } - }, - ol: - { - block: true, - empty: false, - ltrim: true, - rtrim: true, - itrim: true, - allowedChildren: { li: 1 }, - toHtml: function(attr) - { - var open = ' 0) - open += ' class="' + classes.join(' ') + '"'; - open += Markup._addGlobalAttributes(attr) + '>'; - return [open, '']; - }, - fromHtml: function(str, depth) - { - depth = depth || 0; - - var m; - if(m = Markup.matchOuterTags(str, '', '', 'g')) - { - for(var i = 0; i < m.length; ++i) - { - str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n" + Array(depth + 1).join("\t") + '[ol]' + Markup.tags.ol.fromHtml(m[i][0], depth + 1) + "\n" + Array(depth + 1).join("\t") + '[/ol]'); - } - } - - return str; - } - }, - p: - { - empty: false, - ltrim: true, - rtrim: true, - itrim: true, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - return ['

','

']; - }, - fromHtml: function(str) - { - var m; - if(m = str.match(/[\s\S]*?<\/p>/gi)) - { - for(var i = 0; i < m.length; ++i) - { - var align = m[i].match(/^([\s\S]*?)<\/p>/i); - - str = str.replace(m[i], '[pad][div' + (align ? ' align=' + align[1] : '') + ']' + (inside ? inside[1] : '') + '[/div][pad]'); - - } - } - return str; - } - }, - pad: - { - empty: true, - block: true, - trim: true, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - var str = '
'; - return str; - } - }, - pet: - { - empty: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - icon: { req: false, valid: /^false$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_pet_families && g_pet_families[id] && g_pets && g_pets[id]) - { - var str = ''; - str += '' + Markup._safeHtml(g_pet_families[id]) + ''; - return str; - } - return '(' + LANG.types[9][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - - if(g_pet_families && g_pet_families[id]) - return Markup._safeHtml(g_pet_families[id]); - return LANG.types[9][0] + ' #' + id; - } - }, - pre: - { - empty: false, - block: true, - rtrim: true, - toHtml: function(attr) - { - var open = '
';
-				return [open, '
']; - }, - fromHtml: function(str) - { - return str.replace(/([\s\S]*?)<\/pre>/gi, '[pre]$1[/pre]'); - } - }, - quest: - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - icon: { req: false, valid: /^false$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_quests[id] && g_quests[id][nameCol]) - { - var quest = g_quests[id]; - return ' ' + Markup._safeHtml(quest[nameCol]) + ''; - } - return '(' + LANG.types[5][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_quests[id] && g_quests[id][nameCol]) - return Markup._safeHtml(g_quests[id][nameCol]); - return LANG.types[5][0] + ' #' + id; - } - }, - quote: - { - block: true, - empty: false, - rtrim: true, - ltrim: true, - itrim: true, - attr: - { - unnamed: { req: false, valid: /[\S ]+/ }, - url: { req: false, valid: /\S+/ }, - blizzard: { req: false, valid: /^true$/ }, - pname: { req: false }, - wowhead: { req: false, valid: /^true$/ }, - display: { req: false, valid: /^block$/ }, - align: { req: false, valid: /^(left|right|center)$/i }, - collapse: { req: false, valid: /^true$/ } - }, - allowedModes: { article: 1, quickfacts: 1, comment: 1 }, - validate: function(attr) { - if(attr.blizzard || attr.wowhead || attr.collapse || attr.url) - { - if(Markup.allow < Markup.CLASS_STAFF) - return false; - } - return true; - }, - toHtml: function(attr) - { - var str = '= 0) pname = 'Blue Tracker'; - // override with attr.pname if it exists - if(typeof(attr.pname) != 'undefined') pname = attr.pname; - - var username = attr.unnamed.trim(); - if(username.length <= 0) - return ['','']; - str = str.replace('class="quote', 'class="quote-blizz'); - str += (attr.collapse ? ' collapse' : '') + '">
' - - var matches = url.match(/https?:\/\/(us|eu)\.battle\.net\/wow\/en\/blog\/([0-9]+)/i) || url.match(/https?:\/\/(us|eu)\.battle\.net\/wow\/en\/forum\/topic\/([0-9]+)/i); - - if(matches) { - str += 'Originally posted by Blizzard (Official Post' - - var topicId = matches[2]; - str += ' | Blue Tracker)' + - '

' + username + '

'; - } - else - str += ( - attr.url && Markup._isUrlSafe(attr.url) ? - 'Originally posted by Blizzard ' + - '(' + pname + ')' + - '

' - :'

' + username + '

' - ); - - return [str, '
']; - - } - return ['','']; - } - else if(attr.wowhead /*Markup.inBlog*/) - { - str = str.replace('class="quote', 'class="quote-wh'); - str += (attr.collapse ? ' collapse' : '') + '">'; - str += '
'; - return [str, '
']; - } - else - { - str += '">'; - if(attr.unnamed) - { - var username = attr.unnamed.trim(); - if(username.length > 0) - { - str += ''; - if(attr.url && Markup._isUrlSafe(attr.url)) - str += '' + username + ''; - else if(g_isUsernameValid(username)) - str += '' + username + ''; - else - str += username; - str += ' '+ LANG.markup_said + '
'; - } - } - return [str, '']; - } - } - }, - race: - { - empty: true, - allowInReplies: true, - valid: { 1: true, 2: true, 3: true, 4: true, 5: true, 6: true, 7: true, 8: true, 9: true, 10: true, 11: true, 22: true, 24: true, 25: true }, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - gender: { req: false, valid: /^(0|1)$/ }, - icon: { req: false, valid: /^false$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - if(Markup.tags.race.valid[attr.unnamed]) - return true; - return false; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var gender = attr.gender | 0; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_races[id] && g_races[id][nameCol]) - { - var race = g_races[id]; - return ' ' + Markup._safeHtml(race[nameCol]) + ''; - } - return '(' + LANG.types[14][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_races[id] && g_races[id][nameCol]) - return Markup._safeHtml(g_races[id][nameCol]); - return LANG.types[14][0] + ' #' + id; - } - }, - reveal: - { - empty: false, - rtrim: true, - ltrim: true, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - if(!Markup.inBlog || Markup.inBlog > 1) - return ['', '']; - - return [' (read more)']; - Markup.reveals++; - } - }, - s: - { - empty: false, - allowInReplies: true, - toHtml: function(attr) - { - return ['', '']; - }, - fromHtml: function(str) - { - return str.replace(/([\s\S]*?)<\/del>/gi, '[s]$1[/s]'); - } - }, - screenshot: - { - empty: false, - attr: - { - id: { req: false, valid: /^[0-9]+$/ }, - url: { req: false, valid: /\S+/ }, - thumb: { req: false, valid: /\S+/ }, - size: { req: false, valid: /^(thumb|resized|normal)$/i }, - width: { req: false, valid: /^[0-9]+$/ }, - height: { req: false, valid: /^[0-9]+$/ }, - 'float': { req: false, valid: /^(left|right)$/i }, - border: { req: false, valid: /^[0-9]+$/ } - }, - taglessSkip: true, - allowedClass: MARKUP_CLASS_STAFF, - validate: function(attr) - { - if(attr.url && !attr.thumb) - return false; - else if(!attr.id && !attr.url) - return false; - return true; - }, - toHtml: function(attr) - { - var url = ''; - var thumb = ''; - - if(attr.id) - { - url = g_staticUrl + '/uploads/screenshots/normal/' + attr.id + '.jpg'; - - var thumbId = attr.id; - if(attr.thumb && attr.thumb.match(/^[0-9]+$/)) - { - thumbId = attr.thumb; - attr.thumb = null; - } - - thumb = g_staticUrl + '/uploads/screenshots/' + (attr.size ? attr.size : 'thumb') + '/' + thumbId + '.jpg'; - } - else if(attr.url) - url = attr.url; - - if(attr.thumb) - thumb = attr.thumb; - - var caption = attr._contents.replace(/\n/g, '
'); - - if(!g_screenshots[Markup.uid]) - g_screenshots[Markup.uid] = []; - var str = ''; - - - str += '']; - } - }, - script: - { - ltrim: true, - rtrim: true, - empty: false, - attr: - { - src: { req: false, valid: /^\S+$/ } - }, - allowedClass: MARKUP_CLASS_ADMIN, - allowedChildren: { '': 1 }, - rawText: true, - taglessSkip: true, - toHtml: function(attr) - { - if(attr.src) - { - $.getScript(attr.src, function() { - $.globalEval(attr._contents); - }); - } - else - $.globalEval(attr._contents); - return ['']; - } - }, - section: - { - empty: false, - ltrim: true, - rtrim: true, - trim: true, - allowedClass: MARKUP_CLASS_STAFF, - attr: - { - }, - toHtml: function(attr) - { - return ['
', '
']; - } - }, - skill: - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - icon: { req: false, valid: /^false$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_skills[id] && g_skills[id][nameCol]) - { - var skill = g_skills[id]; - return ' ' + Markup._safeHtml(skill[nameCol]) + ''; - } - return '(' + LANG.types[15][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_skills[id] && g_skills[id][nameCol]) - return Markup._safeHtml(g_skills[id][nameCol]); - return LANG.types[15][0] + ' #' + id; - } - }, - sig: - { - empty: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ } - }, - allowedClass: MARKUP_CLASS_PREMIUM, - allowedModes: { signature: 1 }, - toHtml: function(attr) - { - return; - return ''; - } - }, - small: - { - empty: false, - toHtml: function(attr) - { - return ['', '']; - }, - fromHtml: function(str) - { - return str.replace(/([\s\S]*?)<\/small>/gi, '[small]$1[/small]'); - } - }, - span: - { - empty: false, - attr: - { - unnamed: { req: false, valid: /^(hidden|invisible)$/ }, - tooltip: { req: false, valid: /\S+/ }, - tooltip2: { req: false, valid: /\S+/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - var str = ' 0) - str += ' style="' + styles.join(';') + '"'; - - if(attr.tooltip && Markup.tooltipTags[attr.tooltip]) - str += ' onmouseover="$WH.Tooltip.showAtCursor(event, Markup.tooltipTags[\'' + attr.tooltip + '\'], 0, 0, ' + (Markup.tooltipBare[attr.tooltip] ? 'null' : "'q'") + ', ' + (attr.tooltip2 && Markup.tooltipTags[attr.tooltip2] ? "Markup.tooltipTags['" + attr.tooltip2 + "']" : 'null') + ')" onmousemove="$WH.Tooltip.cursorUpdate(event)" onmouseout="$WH.Tooltip.hide()"'; - - str += '>'; - return [str, '']; - } - }, - spell: - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - diff: { req: false, valid: /^[0-9]+$/ }, - icon: { req: false, valid: /^false$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - buff: { req: false, valid: /^true$/ }, - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - var rel = []; - - if(attr.buff) - rel.push('buff'); - if(attr.diff) - rel.push('diff=' + attr.diff); - - if(g_spells[id] && g_spells[id][nameCol]) - { - var spell = g_spells[id]; - return ' ' + Markup._safeHtml(spell[nameCol]) + ''; - } - - return '(' + LANG.types[6][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_spells[id] && g_spells[id][nameCol]) - return Markup._safeHtml(g_spells[id][nameCol]); - return LANG.types[6][0] + ' #' + id; - } - }, - spoiler: - { - block: true, - empty: false, - rtrim: true, - ltrim: true, - itrim: true, - toHtml: function(attr) - { - return ['
' + LANG.markup_spoil + '', '']; - } - }, - statistic: - { - empty: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - icon: { req: false, valid: /^false$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_achievements[id] && g_achievements[id][nameCol]) - { - var ach = g_achievements[id]; - return ' ' + Markup._safeHtml(ach[nameCol]) + ''; - } - return '(' + LANG.types[10][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_achievements[id] && g_achievements[id][nameCol]) - return Markup._safeHtml(g_achievements[id][nameCol]); - return LANG.types[10][0] + ' #' + id; - } - }, - style: - { - ltrim: true, - rtrim: true, - empty: false, - allowedClass: MARKUP_CLASS_ADMIN, - allowedChildren: { '': 1 }, - rawText: true, - taglessSkip: true, - toHtml: function(attr) - { - g_addCss(attr._contents); - return ['']; - } - }, - sub: - { - empty: false, - toHtml: function(attr) - { - return ['', '']; - }, - fromHtml: function(str) - { - return str.replace(/([\s\S]*?)<\/sub>/gi, '[sub]$1[/sub]'); - } - }, - sup: - { - empty: false, - toHtml: function(attr) - { - return ['', '']; - }, - fromHtml: function(str) - { - return str.replace(/([\s\S]*?)<\/sup>/gi, '[sup]$1[/sup]'); - } - }, - tabs: - { - block: true, - empty: false, - ltrim: true, - rtrim: true, - itrim: true, - allowedClass: MARKUP_CLASS_STAFF, - allowedChildren: { tab: 1 }, - attr: { - name: { req: true, valid: /\S+/ }, - width: { req: false, valid: /^[0-9]+(px|em|\%)$/ } - }, - toHtml: function(attr) { - attr.id = g_urlize(attr.name); - var x = Markup.preview; - var str = '
'; - str += ''; - str += tab.content; - str += '
'; - str += ''; - } - - str += ''; - str += ''; - - setTimeout(Markup.createTabs.bind(null, attr, tabs, (x ? 'preview' : '')), 100); - return [str]; - } - }, - tab: - { - block: true, - empty: false, - ltrim: true, - rtrim: true, - itrim: true, - allowedClass: MARKUP_CLASS_STAFF, - allowedParents: { tabs: 1 }, - attr: { - name: { req:true, valid: /[\S ]+/ }, - icon: { req:false, valid: /\S+/ } - }, - toHtml: function(attr) - { - attr.id = g_urlize(attr.name); - attr.name = $WH.str_replace(attr.name, "_", ' '); - if(typeof(attr['class']) != 'undefined') - attr['class'] = $WH.str_replace(attr['class'], "_", ' '); - return [{content: attr._contents, id: attr.id, name: attr.name, icon: attr.icon, 'class': attr['class']}]; - } - }, - table: - { - //block: true, - empty: false, - ltrim: true, - rtrim: true, - itrim: true, - allowedChildren: { tr: 1 }, - attr: - { - border: { req: false, valid: /^[0-9]+$/ }, - cellspacing: { req: false, valid: /^[0-9]+$/ }, - cellpadding: { req: false, valid: /^[0-9]+$/ }, - width: { req: false, valid: /^[0-9]+(px|em|\%)$/ } - }, - toHtml: function(attr) - { - var str = '']; - }, - fromHtml: function(str, depth) - { - depth = depth || 0; - - var m; - if(m = Markup.matchOuterTags(str, '', '', 'g')) - { - for(var i = 0; i < m.length; ++i) - { - var border = m[i][1].match(/border[:="]+\s*([0-9]+)/i), - width = m[i][1].match(/width[:="]+\s*([0-9]+)/i), - spacing = m[i][1].match(/cellspacing="([\s\S]+?)"/i), - padding = m[i][1].match(/cellpadding="([\s\S]+?)"/i); - - str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n" + Array(depth + 1).join("\t") + '[table' + (border ? ' border=' + border[1] : '') + (width ? ' width=' + width[1] : '') + (spacing ? ' cellspacing=' + spacing[1] : '') + (padding ? ' cellpadding=' + padding[1] : '') + ']' + Markup.tags.table.fromHtml(m[i][0], depth + 1) + "\n" + Array(depth + 1).join("\t") + '[/table]'); - } - } - - return str; - } - }, - tr: { - empty: false, - itrim: true, - allowedChildren: { td: 1 }, - allowedParents: { table: 1 }, - toHtml: function(attr) - { - return ['', '']; - }, - fromHtml: function(str, depth) - { - depth = depth || 0; - - var m; - if(m = Markup.matchOuterTags(str, '', '', 'g')) - { - for(var i = 0; i < m.length; ++i) - { - str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n\t" + Array(depth + 1).join("\t") + '[tr]' + Markup.tags.tr.fromHtml(m[i][0], depth + 1) + "\n" + Array(depth + 1).join("\t") + '[/tr]'); - } - } - - return str; - } - }, - td: - { - empty: false, - itrim: true, - allowedParents: { tr: 1 }, - attr: - { - unnamed: { req: false, valid: /^header$/ }, - align: { req: false, valid: /^(right|left|center|justify)$/i }, - valign: { req: false, valid: /^(top|middle|bottom|baseline)$/i }, - colspan: { req: false, valid: /^[0-9]+$/ }, - rowspan: { req: false, valid: /^[0-9]+$/ }, - width: { req: false, valid: /^[0-9]+(px|em|\%)$/ } - }, - toHtml: function(attr) - { - var str = '<' + (attr.unnamed ? 'th' : 'td') + Markup._addGlobalAttributes(attr); - if(attr.align != undefined) - str += ' align="' + attr.align + '"'; - if(attr.valign != undefined) - str += ' valign="' + attr.valign + '"'; - if(attr.colspan != undefined) - str += ' colspan="' + attr.colspan + '"'; - if(attr.rowspan != undefined) - str += ' rowspan="' + attr.rowspan + '"'; - if(attr.width != undefined) - str += ' style="width: ' + attr.width + '"'; - str += '>'; - return [str, '']; - }, - fromHtml: function(str, depth) - { - depth = depth || 0; - - var t = ['td', 'th'], m; - for(var j = 0; j < t.length; ++j) - { - if(m = Markup.matchOuterTags(str, '<' + t[j] + '\\b[\\s\\S]*?>', '', 'g')) - { - for(var i = 0; i < m.length; ++i) - { - var width = m[i][1].match(/width[:="]+\s*([0-9]+)/i), - align = m[i][1].match(/align="([\s\S]+?)"/i), - valign = m[i][1].match(/valign="([\s\S]+?)"/i), - colspan = m[i][1].match(/colspan="([\s\S]+?)"/i), - rowspan = m[i][1].match(/rowspan="([\s\S]+?)"/i); - - str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n\t\t" + Array(depth + 1).join("\t") + '[td' + (t[j] == 'th' ? '=header' : '') + (width ? ' width=' + width[1] : '') + (align ? ' align=' + align[1] : '') + (valign ? ' valign=' + valign[1] : '') + (colspan ? ' colspan=' + colspan[1] : '') + (rowspan ? ' rowspan=' + rowspan[1] : '') + ']' + Markup.tags.td.fromHtml(m[i][0], depth + 1) + '[/td]'); - } - } - } - - return str; - } - }, - time: - { - empty: true, - count: 0, - attr: - { - until: { req: false, valid: /^\d+$/ }, - since: { req: false, valid: /^\d+$/ }, - server: { req: false, valid: /^true$/ } - }, - validate: function(attr) - { - if(!attr.until && !attr.since) - return false; - return true; - }, - toHtml: function(attr) - { - var id = Markup.tags.time.count++; - var str = '' + Markup.tags.time.getTime(attr) + ''; - setInterval(Markup.tags.time.updateTime.bind(null, id, attr), 5000); - return str; - }, - getTime: function(attr) - { - var now; - if(attr.server) - now = g_serverTime.getTime() / 1000; - else - now = (new Date()).getTime() / 1000; - var delay = 0; - if(attr.until) - delay = attr.until - now; - else - delay = now - attr.since; - - if(delay > 0) - return g_formatTimeElapsed(delay); - else - return '0 ' + LANG.timeunitspl[6]; - }, - updateTime: function(id, attr) - { - var span = $WH.ge('markupTime' + id); - if(!span) - return; - - span.firstChild.nodeValue = Markup.tags.time.getTime(attr); - } - }, - toc: - { - block: true, - post: true, - trim: true, - ltrim: true, - rtrim: true, - collect: { h2: 1, h3: 1 }, - exclude: { tabs: { h2: 1, h3: 1 }, minibox: { h2: 1, h3: 1 } }, - allowedClass: MARKUP_CLASS_STAFF, - attr: - { - h3: { req: false, valid: /^false$/ } - }, - postHtml: function(attr, nodes) - { - var str = ' 0) - str += ' class="' + classes.join(' ') + '"'; - str += Markup._addGlobalAttributes(attr) + '>' + LANG.markup_toc + '
    '; - var lastNode = ""; - var indent = 1; - var allowH3 = (attr.h3 != 'false'); - var myNodes = []; - for(var node in nodes.h2) - myNodes.push(nodes.h2[node]); - for(var node in nodes.h3) - myNodes.push(nodes.h3[node]); - myNodes.sort(function(a, b) { - return a.offset - b.offset; - }); - - for(var i in myNodes) - { - node = myNodes[i]; - if(node.name == 'h2' && node.attr.toc != 'false') - { - if(lastNode == 'h3') - { - str += '
'; - indent--; - } - str += '
  • ' + node.attr._textContents + '
  • '; - lastNode = 'h2'; - } - if(node.name == 'h3' && allowH3 && node.attr.toc != 'false' && (lastNode != '' || nodes.h2.length == 0)) - { - if(lastNode == 'h2') - { - str += ''; - } - return str; - } - }, - toggler: - { - empty: false, - attr: - { - id: { req: true, valid: /^[a-z0-9_-]+$/i }, - unnamed: { req: false, valid: /^hidden$/i } - }, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - var str = ''; - return [str, '']; - } - }, - tooltip: - { - empty: false, - attr: - { - unnamed: { req: false, valid: /\S+/ }, - name: { req: false, valid: /\S+/ }, - bare: { req: false, valid: /^true$/i }, - label: { req: false, valid: /[\S ]+/ } - }, - taglessSkip: true, - allowedClass: MARKUP_CLASS_STAFF, - validate: function(attr) - { - if(!attr.unnamed && !attr.name) - return false; - return true; - }, - toHtml: function(attr) - { - if(attr.unnamed) - return ['', '']; - else - { - Markup.tooltipTags[attr.name] = (attr.label ? '
    ' + attr.label + '
    ' : '') + attr._contents; - if(attr.bare) - Markup.tooltipBare[attr.name] = true; - return ['']; - } - } - }, - u: - { - empty: false, - allowInReplies: true, - toHtml: function(attr) - { - return ['', '']; - }, - fromHtml: function(str) - { - return str.replace(/<(ins|u)\b[\s\S]*?>([\s\S]*?)<\/\1>/gi, '[u]$2[/u]'); - } - }, - ul: - { - block: true, - empty: false, - ltrim: true, - rtrim: true, - itrim: true, - allowedChildren: { li: 1 }, - toHtml: function(attr) - { - var open = ' 0) - open += ' class="' + classes.join(' ') + '"'; - open += Markup._addGlobalAttributes(attr) + '>'; - return [open, '']; - }, - fromHtml: function(str, depth) - { - depth = depth || 0; - - var m; - if(m = Markup.matchOuterTags(str, '', '', 'g')) - { - for(var i = 0; i < m.length; ++i) - { - str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n" + Array(depth + 1).join("\t") + '[ul]' + Markup.tags.ul.fromHtml(m[i][0], depth + 1) + "\n" + Array(depth + 1).join("\t") + '[/ul]'); - } - } - - return str; - } - }, - url: - { - allowedClass: MARKUP_CLASS_USER, - allowInReplies: true, - empty: false, - helpText: '[url=http://www.google.com]' + LANG.markup_url + '[/url]', - attr: - { - unnamed: { req: false, valid: /\S+/ }, - rel: { req: false, valid: /(item|quest|spell|achievement|npc|object)=([0-9]+)/ }, - onclick: { req: false, valid: /[\S ]+/ }, - tooltip: { req: false, valid: /\S+/ }, - tooltip2: { req: false, valid: /\S+/ } - }, - validate: function(attr) - { - if(attr.onclick && Markup.allow < Markup.CLASS_ADMIN) - return false; - - if(attr.tooltip && Markup.allow < Markup.CLASS_STAFF) - return false; - - var target = ''; - if(attr.unnamed && /^(mailto:|irc:)/i.test(attr.unnamed.trim()) && Markup.allow < Markup.CLASS_STAFF) - return false; - - if(attr.unnamed && /^(javascript:)/i.test(attr.unnamed.trim())) - return false; - - return true; - }, - toHtml: function(attr) - { - var target; - if(attr.unnamed) // in the form [url=blah] - { - target = attr.unnamed; - target = target.replace(/&/, '&'); - if(!target.match(/^([^:\\.\/]+):/i) && target.charAt(0) != '/' && target.charAt(0) != '#') - target = '/' + target; - if(Markup._isUrlSafe(target, true)) - { - var pre = '']; - } - else - { - return ['', '']; - } - } - else // [url]blah[/url] - { - target = attr._textContents; - target = target.replace(/&/, '&'); - if(Markup._isUrlSafe(target)) - { - var pre = '']; - } - else - { - return ['', '']; - } - } - }, - fromHtml: function(str) - { - return str.replace(/([\s\S]*?)<\/a>/gi, '[url=$1]$2[\/url]'); - } - }, - video: - { - empty: true, - attr: - { - id: { req: true, valid: /^[0-9]+$/ }, - unnamed: { req: false, valid: /^embed$/i }, - 'float': { req: false, valid: /^(left|right)$/i }, // Thumbnail only - border: { req: false, valid: /^[0-9]+$/ } // Thumbnail only - }, - ltrim: true, - rtrim: true, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - if(g_videos[attr.id]) - { - var html = '', video = g_videos[attr.id]; - if(attr.unnamed) - { - if(video.videoType == 1) // YouTube - html += Markup.toHtml('[youtube=' + video.videoId + ']', { skipReset: true }); - } - else - { - if(!g_videos[Markup.uid]) - g_videos[Markup.uid] = []; - - html += ''; - - g_videos[Markup.uid].push($WH.dO(video)); - } - return html; - } - return 'Video #' + attr.id + ''; - } - }, - visitedpage: - { - empty: false, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - $.post('/visited-page', { id: attr.unnamed }, function() { AchievementCheck(); }); - return ''; - } - }, - wowheadresponse: - { - block: true, - empty: false, - rtrim: true, - ltrim: true, - itrim: true, - attr: - { - unnamed: { req: true, valid: /[\S ]+/ }, - roles: { req: true, valid: /[0-9]+/ } - }, - allowedModes: { article: 1, quickfacts: 1, comment: 1 }, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - var str = '' + username + ' ' + LANG.markup_said + '
    '; - return [str, '']; - } - }, - youtube: - { - empty: true, - attr: - { - unnamed: { req: true, valid: /\S+/ }, - width: { req: false, valid: /^[0-9]+$/ }, - height: { req: false, valid: /^[0-9]+$/ }, - autoplay: { req: false, valid: /^true$/ } - }, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - var url = 'http://www.youtube.com/v/' + attr.unnamed + '&fs=1&rel=0' + (attr.autoplay ? '&autoplay=1' : ''); - var width = attr.width ? attr.width : 640; - var height = attr.height ? attr.height : 385; - - var html = ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - - return html; - }, - fromHtml: function(str) - { - var m; - if(m = str.match(/<\/iframe>/gi)) - { - for(var i = 0; i < m.length; ++i) - { - var source = m[i].match(/src="[\s\S]*?youtube\.com\/embed\/([\s\S]*?)"/i), - width = m[i].match(/width[:="]+\s*([0-9]+)/i), - height = m[i].match(/height[:="]+\s*([0-9]+)/i), - border = m[i].match(/border[:="]+\s*([0-9]+)/i); - - str = str.replace(m[i], '[youtube=' + source[1] + (width ? ' width=' + width[1] : '') + (height ? ' height=' + height[1] : '') + ']'); - } - } - return str; - } - }, - center: - { - empty: false, - allowInReplies: false, - allowedClass: MARKUP_CLASS_STAFF, - toHtml: function(attr) - { - return ['
    ', '
    ']; - }, - fromHtml: function(str) - { - return str.replace(/
    ([\s\S]+?)<\/center>/gi, '[pad][div align=center]$1[/div][pad]'); - } - }, - title: - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_titles[id] && g_titles[id][nameCol]) - { - return '' + Markup._safeHtml(g_titles[id][nameCol]) + ''; - } - return '(' + LANG.types[11][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_titles[id] && g_titles[id][nameCol]) - return Markup._safeHtml(g_titles[id][nameCol]); - return LANG.types[11][0] + ' #' + id; - } - }, - zone: - { - empty: true, - allowInReplies: true, - attr: - { - unnamed: { req: true, valid: /^[0-9]+$/ }, - domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, - site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } - }, - validate: function(attr) - { - if((attr.domain || attr.site) && Markup.dbpage) - return false; - return true; - }, - toHtml: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var url = domainInfo[0]; - var nameCol = domainInfo[1]; - - if(g_gatheredzones[id] && g_gatheredzones[id][nameCol]) - { - return '' + Markup._safeHtml(g_gatheredzones[id][nameCol]) + ''; - } - return '(' + LANG.types[7][0] + ' #' + id + ')'; - }, - toText: function(attr) - { - var id = attr.unnamed; - var domainInfo = Markup._getDatabaseDomainInfo(attr); - var nameCol = domainInfo[1]; - - if(g_gatheredzones[id] && g_gatheredzones[id][nameCol]) - return Markup._safeHtml(g_gatheredzones[id][nameCol]); - return LANG.types[7][0] + ' #' + id; - } - } - }, - - _addGlobalAttributes: function(attr) - { - var attribs = ''; - if(Markup.allow < Markup.CLASS_STAFF) - return attribs; - if(attr.id) - attribs += ' id="' + attr.id + '"'; - if(attr.title) - attribs += ' title="' + Markup._safeQuotes(attr.title) + '"'; - if(attr['class']) - attribs += ' class="' + attr['class'] + '"'; - if(attr['data-highlight']) - attribs += ' data-highlight="' + attr['data-highlight'] + '"'; - - return attribs; - }, - - _generateTagDocs: function(tagName, helpClass) - { - var tag = Markup.tags[tagName]; - if(!tag) - return ''; - - if(helpClass) - { - if((tag.allowedClass && tag.allowedClass > helpClass) || (!tag.helpText && (tag.empty || tag.allowedParents || tag.allowedChildren || !LANG['markup_' + tagName]))) - return ''; - - if(tag.helpText && typeof tag.helpText == 'function') - var str = tag.helpText(); - else if(tag.helpText && typeof tag.helpText == 'string') - var str = tag.helpText; - else - var str = '[' + tagName + ']' + LANG['markup_' + tagName].toLowerCase() + '[/' + tagName + ']'; - - return '
    ' + str + '
    ' + Markup.toHtml(str, { skipReset: true }) + ''; - } - - var str = '

    Tag: [' + Markup._safeHtml(tagName) + ']

    '; - str += ''; - - if(tag.attr) - { - /*str += '';*/ - str += ''; - } - - str += ''; - - str += ''; - - if(tag.allowedChildren) - { - str += ''; - } - - if(tag.allowedParents) - { - str += ''; - } - - if(tag.presets) - { - str += ''; - } - - if(tag.trim) - { - str += ''; - } - - if(tag.ltrim) - { - str += ''; - } - - if(tag.rtrim) - { - str += ''; - } - - if(tag.itrim) - { - str += ''; - } - - if(tag.block) - { - str += ''; - } - - str += '
    Attributes:'; - for(var a in tag.attr) - { - str += ''; - str += ''; - str += ''; - } - str += '
    ' + a + '
    Required:' + (tag.attr[a].req ? 'Yes' : 'No') + '
    Valid:' + (tag.attr[a].valid ? Markup._safeHtml(tag.attr[a].valid.toString()) : '--') + '
    Attributes:'; - for(var a in tag.attr) - { - str += '
    '; - str += ''; - str += '
    '; - if(a == 'unnamed') - str += 'Self ([' + tagName + '=???])'; - else - str += a; - str += '
    Required:' + (tag.attr[a].req ? 'Yes' : 'No') + '
    Valid:' + (tag.attr[a].valid ? Markup._safeHtml(tag.attr[a].valid.toString()) : '--') + '
    '; - } - str += '
    Has closing tag:' + (tag.empty ? 'No' : 'Yes') + '
    Required group:'; - if(tag.allowedClass == MARKUP_CLASS_ADMIN) - str += 'Administrator'; - else if(tag.allowedClass == MARKUP_CLASS_STAFF) - str += 'Staff'; - else if(tag.allowedClass == MARKUP_CLASS_PREMIUM) - str += 'Premium'; - else if(tag.allowedClass && tag.allowedClass != MARKUP_CLASS_PENDING) - str += 'Not pending'; - else - str += 'None'; - str += '
    Allowed children:'; - for(var t in tag.allowedChildren) - str += Markup._safeHtml(t) + '
    '; - str += '
    Allowed parents:'; - for(var t in tag.allowedParents) - str += Markup._safeHtml(t) + '
    '; - str += '
    Preset values:'; - for(var p in tag.presets) - str += ''; - str += '
    ' + p + '' + Markup._safeHtml(tag.presets[p]) + '
    Trim whitespace
    Trim preceding whitespace
    Trim following whitespace
    Trim whitespace around interior content
    Automatically remove top padding if not the first item
    '; - - return str; - }, - - _init: function() - { - if(!this.inited) - { - var ltrimTags = [], rtrimTags = [], trimTags = []; - for(var tag in Markup.tags) - { - if(Markup.tags[tag].block) - this.firstTags[tag] = true; - if(Markup.tags[tag].exclude) - { - for(var ex in Markup.tags[tag].exclude) - { - if(!this.excludeTags[ex]) - this.excludeTags[ex] = {}; - this.excludeTags[ex][tag] = Markup.tags[tag].exclude[ex]; - } - } - if(Markup.tags[tag].post) - this.postTags.push(tag); - if(Markup.tags[tag].trim) - trimTags.push(tag); - if(Markup.tags[tag].ltrim) - ltrimTags.push(tag); - if(Markup.tags[tag].rtrim) - rtrimTags.push(tag); - } - - if(ltrimTags.length > 0) - this.ltrimRegex = new RegExp('\\s*\\[(' + ltrimTags.join('|') + ')([^a-z0-9]+.*)?]', 'ig'); - if(rtrimTags.length > 0) - this.rtrimRegex = new RegExp('\\[\/(' + rtrimTags.join('|') + ')\\]\\s*', 'ig'); - if(trimTags.length > 0) - this.trimRegex = new RegExp('\\s*\\[(' + trimTags.join('|') + ')([^\\[]*)?\\]\\s*', 'ig'); - - this.inited = true; - - $('[data-highlight]') - .live('mouseenter', function() { - var _ = $(this).attr('data-highlight').split(':'); - - if(_.length != 2) - return; - - var elem = $('#' + _[0]).get(0), - start = parseInt(_[1]), - text = $(elem).val(); - - if(!elem || !start || !text) - return; - - var top = $(elem).val(text.substr(0, start))[0].scrollHeight; - - $(elem).val(text).animate({ scrollTop: top }, 250); - elem.selectionStart = start; - elem.selectionEnd = start; - }); - } - }, - - _safeJsString: function(str) - { - return str.replace(/'/g, '\''); - }, - - _safeQuotes: function(str) - { - return str.replace('"', '\"').replace("'", "\'"); - }, - - _safeHtml: function(html) - { - var allowedEscapes = ['nbsp', 'ndash']; - html = html.replace(/&/g, '&'); - if(allowedEscapes.length > 0) - html = html.replace(new RegExp('&(' + allowedEscapes.join('|') + ');', 'g'), '&$1;'); - return html.replace(//g, '>').replace(/"/g, '"'); - }, - - _preText: function(str) - { - str = Markup._safeHtml(str); - str = str.replace(/\n/g, '
    '); - return str; - }, - - _getDatabaseDomainInfo: function(attr) - { - var url = ''; - var nameCol = Markup.nameCol; - - var domain = false; - if(attr.domain) - domain = attr.domain; - else if(attr.site) - domain = attr.site; - else if(Markup.defaultSource) - domain = MarkupSourceMap[Markup.defaultSource]; - - if(domain) - { - if(domain == 'beta') - domain = 'mop'; - url = 'http://' + domain + '.wowhead.com'; - nameCol = 'name_' + Markup.domainToLocale[domain]; - } - else if(location.href.indexOf('wowheadnews.com') != -1) - url = 'http://www.wowhead.com'; - - return [url, nameCol, domain]; - }, - - _isUrlSafe: function(str, extras) - { - if(!str) - return true; - if(str == 'javascript:;') - return true; - - var result = str.match(/^([^:\\./]+):/i); - - if(result && result[1]) - { - var protocol = result[1]; - - if(protocol == 'http' || protocol == 'https') - return true; - - if(extras && (protocol == 'mailto' || protocol == 'irc')) - return true; - - if(protocol != 'mailto' && str.indexOf('://') == -1) - return true; - - return false; - } - - return true; - }, - - _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; - } - - return url; - }, - - _isUrlExternal: function(str) - { - if(!str) - return false; - return (str.indexOf('wowhead.com') == -1 && str.match(/^([^:\\./]+):/i)); - }, - - _nodeSearch: function(node, name, depth) - { - if(!depth) depth = 0; - if(depth >= 3) return; - if(node.name == name) - return true; - else if(node.parent) - return Markup._nodeSearch(node.parent, name, depth+1); - }, - - _parse: function(str, opts) - { - Markup.nameCol = 'name_' + g_locale.name; - if(opts && opts.locale) - Markup.nameCol = 'name_' + Markup.domainToLocale[opts.locale]; - else if($WH.isset('g_beta') && g_beta) - Markup.nameCol = 'name_beta'; - else if($WH.isset('g_ptr') && g_ptr) - Markup.nameCol = 'name_ptr'; - else if($WH.isset('g_old') && g_old) - Markup.nameCol = 'name_old'; - - if(!str) - str = ""; - - str = str.replace(/\r/g, ''); - - if(!opts) opts = {}; - if(!opts.skipReset) - { - Markup.uid = opts.uid || 'abc'; - Markup.root = opts.root; - Markup.preview = opts.preview || false; - Markup.dbpage = opts.dbpage || false; - Markup.defaultSource = false; - - if(Markup.uid != 'abc') - g_screenshots[Markup.uid] = []; - } - - if(opts.roles && (opts.roles & (U_GROUP_ADMIN|U_GROUP_EDITOR|U_GROUP_MOD|U_GROUP_BUREAU|U_GROUP_DEV|U_GROUP_BLOGGER)) && opts.mode != Markup.MODE_SIGNATURE) - opts.mode = Markup.MODE_ARTICLE; - Markup.mode = opts.mode || Markup.MODE_ARTICLE; - Markup.allow = opts.allow || Markup.CLASS_STAFF; - Markup.inBlog = opts.inBlog ? opts.inBlog : 0; - - if(opts.stopAtBreak) - { - var breakPos = str.indexOf('[break]'); - if(breakPos != -1) - str = str.substring(0, breakPos); - } - else - str = str.replace('[break]', ''); - - var tree = new MarkupTree(); - str = str.trim(); - //str = Markup._safeHtml(str); + MODE_COMMENT: MARKUP_MODE_COMMENT, + MODE_REPLY: MARKUP_MODE_REPLY, + MODE_ARTICLE: MARKUP_MODE_ARTICLE, + MODE_QUICKFACTS: MARKUP_MODE_QUICKFACTS, + MODE_SIGNATURE: MARKUP_MODE_SIGNATURE, + + SOURCE_LIVE: MARKUP_SOURCE_LIVE, + SOURCE_PTR: MARKUP_SOURCE_PTR, + SOURCE_BETA: MARKUP_SOURCE_BETA, + + CLASS_ADMIN: MARKUP_CLASS_ADMIN, + CLASS_STAFF: MARKUP_CLASS_STAFF, + CLASS_PREMIUM: MARKUP_CLASS_PREMIUM, + CLASS_USER: MARKUP_CLASS_USER, + CLASS_PENDING: MARKUP_CLASS_PENDING, + + whitelistedWebsites: [/(.*\.)?wowhead.com/i, /(.*\.)?thottbot.com/i, /(.*\.)?torhead.com/i, /(.*\.)?mmoui.com/i, /(.*\.)?tankspot.com/i, /(.*\.)?guildfans.com/i, /(.*\.)?allakhazam.com/i, /(.*\.)?zam.com/i, /(.*\.)?blizzard.com/i, /(.*\.)?worldofwarcraft.com/i, /(.*\.)?wow-europe.com/i, /(.*\.)?battle.net/i, /(.*\.)?sc2ranks.com/i, /(.*\.)?torchlightarmory.com/i, /(.*\.)?vindictusdb.com/i, /(.*\.)?wowinterface.com/i, /(.*\.)?vginterface.com/i, /(.*\.)?lotrointerface.com/i, /(.*\.)?eq2interface.com/i, /(.*\.)?eqinterface.com/i, /(.*\.)?mmo-champion.com/i, /(.*\.)?joystiq.com/i, /(.*\.)?wow-heroes.com/i, /(.*\.)?be-imba.hu/i, /(.*\.)?wowpedia.org/i, /(.*\.)?curse.com/i, /(.*\.)?elitistjerks.com/i, /(.*\.)?wowwiki.com/i, /(.*\.)?worldoflogs.com/i, /(.*\.)?wowinsider.com/i, /(.*\.)?guildwork.com/i], + + rolesToClass: function(roles) + { + if(roles & (U_GROUP_ADMIN|U_GROUP_VIP|U_GROUP_DEV)) + return Markup.CLASS_ADMIN; + else if(roles & U_GROUP_STAFF) + return Markup.CLASS_STAFF; + else if(roles & U_GROUP_PREMIUM) + return Markup.CLASS_PREMIUM; + else if(roles & U_GROUP_PENDING) + return Markup.CLASS_PENDING; + else + return Markup.CLASS_USER; + }, + + defaultSource: false, + nameCol: 'name_enus', + domainToLocale: { + 'www': 'enus', + 'ptr': 'ptr', + 'beta': 'beta', + 'mop': 'beta', + 'fr': 'frfr', + 'de': 'dede', + 'es': 'eses', + 'ru': 'ruru', + 'pt': 'ptbr' + }, + maps: [], + firstTags: {}, + postTags: [], + collectTags: {}, + excludeTags: {}, + tooltipTags: {}, + tooltipBare: {}, + attributes: { + id: { req: false, valid: /^[a-z0-9_-]+$/i }, + title: { req: false, valid: /[\S ]+/ }, + 'class': { req: false, valid: /\S+/ } + }, + IsLinkAllowed: function(link) + { + var matches = link.match('[a-z]+:\/\/([a-z0-9\.\-]+)'); + + if(!matches) + return true; + + var domain = matches[1]; + var allowed = false; + + for(var i in Markup.whitelistedWebsites) + { + var r = Markup.whitelistedWebsites[i]; + + if(domain.search(r) == 0) + allowed = true; + } + + return allowed; + }, + tags: { + '': + { + empty: true, + noHelp: true, + allowInReplies: true, + toHtml: function(attr, extra) + { + extra = extra || $.noop; + + if(attr._text == ' ' && !extra.noNbsp) + attr._text = ' '; + + attr._text = attr._text.replace(/\\\[/g, '['); + + if(extra && extra.noLink) + return attr._text; + else if(extra && extra.needsRaw) + return attr._rawText; + else + { + var link = []; + var text = Markup._preText(attr._rawText.replace(/(https?:\/\/|www\.)([\/_a-z0-9\%\?#@\-\+~&=;:']|\.[a-z0-9\-])+/gi, function(match) { + matchUrl = Markup._preText(match.replace(/^www/, 'http://www')); + match = Markup._preText(match); + var i = link.length; + link.push([matchUrl, match]); + return '$L' + i; + })); + text = text.replace(/\$L([\d+]) /gi, '$L$1 '); + for(var i in link) + { + text = text.replace('$L' + i, function(match) { + if(Markup.allow < Markup.CLASS_USER && !Markup.IsLinkAllowed(link[i][0])) + return $WH.sprintf('[$1]', LANG.linkremoved); + var url = ''; + return url; + }); + } + return text; + } + }, + toText: function(attr) + { + return attr._text; + } + }, + achievement: + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + diff: { req: false, valid: /^[0-9]+$/ }, + icon: { req: false, valid: /^false$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + var rel = []; + + if(attr.diff) + rel.push('diff=' + attr.diff); + + if(g_achievements[id] && g_achievements[id][nameCol]) + { + var ach = g_achievements[id]; + return ' ' + Markup._safeHtml(ach[nameCol]) + ''; + } + return '(' + LANG.types[10][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_achievements[id] && g_achievements[id][nameCol]) + return Markup._safeHtml(g_achievements[id][nameCol]); + return LANG.types[10][0] + ' #' + id; + } + }, + achievementpoints: + { + empty: true, + attr: + { + unnamed: {req: true, valid: /^[0-9]+$/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + var str = '' + attr.unnamed + ''; + return str; + } + }, + anchor: + { + empty: true, + ltrim: true, + rtrim: true, + attr: + { + unnamed: { req: false, valid: /\S+/ } + }, + validate: function(attr) + { + if(!attr.unnamed && !attr.id) + return false; + return true; + }, + toHtml: function(attr) + { + if(!attr.unnamed && attr.id) + { + attr.unnamed = attr.id; + attr.id = null; + } + return ''; + } + }, + acronym: + { + empty: false, + attr: + { + unnamed: { req: false } + }, + toHtml: function(attr) + { + return ['', '']; + } + }, + b: + { + empty: false, + allowInReplies: true, + toHtml: function(attr) + { + return ['', '']; + }, + fromHtml: function(str) + { + return str.replace(/<(b|big|strong)\b[\s\S]*?>([\s\S]*?)<\/\1>/gi, '[b]$2[/b]'); + } + }, + blip: + { + empty: true, + attr: + { + unnamed: { req: true, valid: /\S+/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + var url = 'http://blip.tv/play/' + attr.unnamed; + var width = 600; + var height = 368; + + var html = ''; + // object tag causing issues in chrome? + /*html += ''; + html += ''; + html += ''; + html += '';*/ + html += ''; + //html += ''; + + return html; + } + }, + br: + { + empty: true, + toHtml: function(attr) + { + return '
    '; + }, + fromHtml: function(str) + { + return str.replace(//gi, "\n"); + } + }, + 'class': + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + icon: { req: false, valid: /^false$/i }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + if(attr.unnamed >= 1 && attr.unnamed <= 11) + return true; + return false; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_classes[id] && g_classes[id][nameCol]) + { + var cls = g_classes[id]; + return ' ' + Markup._safeHtml(cls[nameCol]) + ''; + } + return '(' + LANG.types[13][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_classes[id] && g_classes[id][nameCol]) + return Markup._safeHtml(g_classes[id][nameCol]); + return LANG.types[13][0] + ' #' + id; + } + }, + code: + { + block: true, + empty: false, + rtrim: true, + itrim: true, + helpText: true, + allowedChildren: { '': 1 }, + toHtml: function(attr) + { + var open = '
    ';
    +                return [open, '
    ']; + } + }, + color: + { + empty: false, + attr: + { + unnamed: { req: true, valid: /^.*/i } + }, + allowedClass: MARKUP_CLASS_STAFF, + /* Syntax: name: class */ + extraColors: {deathknight: 'c6', dk: 'c6', druid: 'c11', hunter: 'c3', mage: 'c8', paladin: 'c2', priest: 'c5', rogue: 'c4', shaman: 'c7', warlock: 'c9', warrior: 'c1', poor: 'q0', common: 'q1', uncommon: 'q2', rare: 'q3', epic: 'q4', legendary: 'q5', artifact: 'q6', heirloom: 'q7'}, + toHtml: function(attr) + { + var valid = /^(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow|c\d+|r\d+|q\d*?|#[a-f0-9]{6})$/i; + var str = '']; + } + }, + currency: + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + amount: { req: false, valid: /^[0-9\:]+$/ }, + icon: { req: false, valid: /^false$/i }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_gatheredcurrencies[id] && g_gatheredcurrencies[id][nameCol]) + { + var curr = g_gatheredcurrencies[id]; + if(attr.amount) + return ' ' + attr.amount.split(':').join(' - ') + ''; + else + return ' ' + Markup._safeHtml(curr[nameCol]) + ''; + } + + return '(' + LANG.types[17][0] + ' #' + id + ')' + (attr.amount > 0 ? ' x' + attr.amount : ''); + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_gatheredcurrencies[id] && g_gatheredcurrencies[id][nameCol]) + return Markup._safeHtml(g_gatheredcurrencies[id][nameCol]); + return LANG.types[17][0] + ' #' + id; + } + }, + db: + { + empty: true, + attr: + { + unnamed: { req: true, valid: /^(live|ptr|beta|mop)$/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + if(attr.unnamed == 'live') + Markup.defaultSource = Markup.SOURCE_LIVE; + else if(attr.unnamed == 'ptr') + Markup.defaultSource = Markup.SOURCE_PTR; + else if(attr.unnamed == 'beta' || attr.unnamed == 'mop') + Markup.defaultSource = Markup.SOURCE_BETA; + return ''; + }, + toText: function(attr) + { + if(attr.unnamed == 'live') + Markup.defaultSource = Markup.SOURCE_LIVE; + else if(attr.unnamed == 'ptr') + Markup.defaultSource = Markup.SOURCE_PTR; + else if(attr.unnamed == 'beta' || attr.unnamed == 'mop') + Markup.defaultSource = Markup.SOURCE_BETA; + return ''; + } + }, + del: + { + empty: false, + attr: + { + copy: { req: false, valid: /^true$/ } + }, + toHtml: function(attr) + { + var str = '']; + } + }, + div: + { + empty: false, + block: true, + ltrim: true, + rtrim: true, + itrim: true, + attr: + { + clear: { req: false, valid: /^(left|right|both)$/i }, + unnamed: { req: false, valid: /^hidden$/i }, + 'float': { req: false, valid: /^(left|right)$/i }, + align: { req: false, valid: /^(left|right|center)$/i }, + margin: { req: false, valid: /^\d+(px|em|\%)$/ }, + width: { req: false, valid: /^[0-9]+(px|em|\%)$/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + var str = ' 0) + str += ' style="' + styles.join(';') + '"'; + if(classes.length > 0) + str += ' class="' + classes.join(' ') + '"'; + + str += '>'; + return [str, '']; + }, + fromHtml: function(str, depth) + { + depth = depth || 0; + + var m; + if(m = Markup.matchOuterTags(str, '', '', 'g')) + { + for(var i = 0; i < m.length; ++i) + { + var align = m[i][1].match(/float:\s*(left|right)"/i), + width = m[i][1].match(/width[:="]+\s*([0-9]+)/i); + + str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n" + Array(depth + 1).join("\t") + '[div' + (align ? ' float=' + align[1] : '') + (width ? ' width=' + width[1] : '') + ']' + Markup.tags.div.fromHtml(m[i][0], depth + 1) + '[/div]'); + } + } + + return str; + } + }, + event: + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_holidays[id] && g_holidays[id][nameCol]) + { + var evt = g_holidays[id]; + return '' + Markup._safeHtml(evt[nameCol]) + ''; + } + return '(' + LANG.types[12][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_holidays[id] && g_holidays[id][nameCol]) + return Markup._safeHtml(g_holidays[id][nameCol]); + return LANG.types[12][0] + ' #' + id; + } + }, + faction: + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_factions[id] && g_factions[id][nameCol]) + { + var fac = g_factions[id]; + return '' + Markup._safeHtml(fac[nameCol]) + ''; + } + return '(' + LANG.types[8][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_factions[id] && g_factions[id][nameCol]) + return Markup._safeHtml(g_factions[id][nameCol]); + return LANG.types[8][0] + ' #' + id; + } + }, + feedback: + { + empty: true, + allowedClass: MARKUP_CLASS_STAFF, + attr: + { + mailto: { req: false, valid: /^true$/i } + }, + toHtml: function(attr) + { + return 'feedback@wowhead.com'; + } + }, + forumrules: + { + empty: true, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + return 'forum rules'; + } + }, + hr: + { + empty: true, + trim: true, + allowedModes: { article: 1, quickfacts: 1, comment: 1 }, + toHtml: function(attr) + { + return '
    '; + }, + fromHtml: function(str) + { + return str.replace(//gi, '[hr]'); + } + }, + h2: + { + block: true, + empty: false, + ltrim: true, + rtrim: true, + itrim: true, + allowedClass: MARKUP_CLASS_STAFF, + attr: + { + unnamed: { req: false, valid: /^first$/i }, + clear: { req: false, valid: /^(true|both|left|right)$/i }, + toc: { req: false, valid: /^false$/i } + }, + toHtml: function(attr) + { + if(!attr.id) + attr.id = g_urlize(attr._textContents); + str = ' 0) + str += ' class="' + classes.join(' ') + '"'; + if(attr.clear) + { + if(attr.clear == 'true' || attr.clear == 'both') + str += ' style="clear: both"'; + else + str += ' style="clear: ' + attr.clear + '"'; + } + return [str + '>', '']; + }, + fromHtml: function(str) + { + return str.replace(/([\s\S]*?)<\/h2>/gi, "\n[h2]$1[/h2]"); + } + }, + h3: + { + block: true, + empty: false, + ltrim: true, + rtrim: true, + itrim: true, + attr: + { + unnamed: { req: false, valid: /^first$/i }, + toc: { req: false, valid: /^false$/i } + }, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + if(!attr.id) + attr.id = g_urlize(attr._textContents); + var str = ' 0) + str += ' class="' + classes.join(' ') + '"'; + return [str + '>', '']; + }, + fromHtml: function(str) + { + return str.replace(/([\s\S]*?)<\/h3>/gi, "\n[h3]$1[/h3]"); + } + }, + html: + { + empty: false, + allowedClass: MARKUP_CLASS_ADMIN, + allowedChildren: { '': 1 }, + rawText: true, + taglessSkip: true, + toHtml: function(attr) + { + return [attr._contents]; + } + }, + i: + { + empty: false, + allowInReplies: true, + toHtml: function(attr) + { + return ['', '']; + }, + fromHtml: function(str) + { + return str.replace(/<(i|em)\b[\s\S]*?>([\s\S]*?)<\/\1>/gi, '[i]$1[/i]'); + } + }, + icon: + { + empty: false, + itrim: true, + attr: + { + align: { req: false, valid: /^right$/i }, + 'float': { req: false, valid: /^(left|right)$/i }, + name: { req: false, valid: /\S+/ }, + size: { req: false, valid: /^(tiny|small|medium|large)$/ }, + unnamed: { req: false, valid: /^class$/i }, + url: { req: false, valid: /\S+/ }, + preset: { req: false, valid: /\S+/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + presets: { + boss: g_staticUrl + '/images/icons/boss.gif', + heroic: g_staticUrl + '/images/icons/heroic.gif' + }, + validate: function(attr) + { + if(!attr.name && !attr.url && !attr.preset) + return false; + if(attr.preset && !Markup.tags.icon.presets[attr.preset]) + return false; + return true; + }, + toHtml: function(attr) + { + var size = (attr.size ? attr.size : "tiny"); + if(!attr.name) attr.name = ''; + + if(size == "tiny") { + var str = ''; + } + else + str += attr.name + '">'; + return [str, '
    ']; + } + else + { + var str = '' : '">' ); + + var sizes = {'small': 0, 'medium': 1, 'large': 2}; + var url = null; + if(attr.url && Markup._isUrlSafe(attr.url)) + url = attr.url; + else if(attr._textContents && Markup._isUrlSafe(attr._textContents)) + url = attr._textContents; + + icon = Icon.create(attr.name.toLowerCase(), sizes[size], null, url); + + str += icon.innerHTML + ''; + return [str]; + } + } + }, + iconlist: + { + empty: false, + block: true, + ltrim: true, + rtrim: true, + attr: + { + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + taglessSkip: true, + allowedClass: MARKUP_CLASS_STAFF, + allowedChildren: { b: 1, achievement: 1, currency: 1, faction: 1, holiday: 1, item: 1, itemset: 1, npc: 1, object: 1, pet: 1, quest: 1, spell: 1, title: 1, zone: 1 }, + toHtml: function(attr) + { + var domain = Markup._getDatabaseDomainInfo(attr)[2]; + + var str = '', m; + for(var i = 0; i < attr._nodes.length; ++i) + { + var node = $WH.dO(attr._nodes[i]); + node.attr.domain = domain; + + var html = Markup.tags[node.name].toHtml(node.attr), + type = node.name, + href = '', + icon = ''; + + if(typeof html != 'string') // Bold open/close tags + html = html[0] + node.attr._contents + html[1]; + else if(typeof html == 'string' && (m = html.match(/href="(.+?)".+?url\(\/images\/wow\/icons\/tiny\/(.+?)\.gif\)/))) + { + node.attr.icon = 'false'; + html = Markup.tags[node.name].toHtml(node.attr); + href = m[1]; + icon = m[2]; + } + + if(html) + str += '' + (icon ? Markup.toHtml('[icon name=' + icon + ' size=small url=' + href + ']', { skipReset: true }) : '
    •  
    ') + '' + html + ''; + } + + if(str) + str = '
    ' + str + '
    '; + + return [str]; + } + }, + img: + { + empty: true, + attr: + { + src: { req: false, valid: /\S+/ }, + icon: { req: false, valid: /\S+/ }, + id: { req: false, valid: /^[0-9]+$/ }, + blog: { req: false, valid: /^[0-9]+$/ }, + size: { req: false, valid: /^(thumb|resized|normal|large|medium|small|tiny)$/i }, + width: { req: false, valid: /^[0-9]+$/ }, + height: { req: false, valid: /^[0-9]+$/ }, + 'float': { req: false, valid: /^(left|right|center)$/i }, + border: { req: false, valid: /^[0-9]+$/ }, + margin: { req: false, valid: /^[0-9]+$/ } + }, + blogSize: /^(thumb|normal)$/i, + idSize: /^(thumb|resized|normal)$/i, + iconSize: /^(large|medium|small|tiny)$/i, + allowedClass: MARKUP_CLASS_STAFF, + validate: function(attr) + { + if(attr.src) + return true; + else if(attr.id) + return (attr.size ? Markup.tags.img.idSize.test(attr.size) : true); + else if(attr.icon) + return (attr.size ? Markup.tags.img.iconSize.test(attr.size) : true); + else if(attr.blog) + return (attr.size ? Markup.tags.img.blogSize.test(attr.size) : true); + return false; + }, + toHtml: function(attr) + { + var str = '' + str; + post = ''; + var screenshot = { + url: url, + caption: img.alt, + width: img.width, + height: img.height, + noMarkup: true + }; + g_screenshots[Markup.uid].push(screenshot); + } + else + str += ' src="' + g_staticUrl + '/uploads/blog/images/' + attr.blog + (img.type == 3 ? '.png' : '.jpg') + '" alt="' + Markup._safeHtml(img.alt) + '" width="' + img.width + '" height="' + img.height + '"'; + } + else + return ('Image #' + attr.blog); + } + + if(attr.width) + str += ' width="' + attr.width + '"'; + if(attr.height) + str += ' height="' + attr.height + '"'; + if(attr['float']) + { + if(attr['float'] == 'center') + { + str = '
    ' + str + ' style="margin: 10px auto"'; + post = '
    '; + } + else + { + str += ' style="float: ' + attr['float'] + ';'; + if(!attr.margin) + attr.margin = 10; + if(attr['float'] == 'left') + str += ' margin: 0 ' + attr.margin + 'px ' + attr.margin + 'px 0"'; + else + str += ' margin: 0 0 ' + attr.margin + 'px ' + attr.margin + 'px"'; + } + } + if(attr.border != 0) + str += ' class="border"'; + if(attr.title) + str += ' alt="' + attr.title + '"'; + else + str += ' alt=""'; + str += ' />' + post; + return str; + }, + fromHtml: function(str) + { + var m; + if(m = str.match(//gi)) + { + for(var i = 0; i < m.length; ++i) + { + var source = m[i].match(/src="([\s\S]+?)"/i), + width = m[i].match(/width[:="]+\s*([0-9]+)/i), + height = m[i].match(/height[:="]+\s*([0-9]+)/i), + border = m[i].match(/border[:="]+\s*([0-9]+)/i); + + str = str.replace(m[i], '[img src=' + source[1] + (width ? ' width=' + width[1] : '') + (height ? ' height=' + height[1] : '') + ' border=' + (border ? border[1] : 0) + ']'); + } + } + return str; + } + }, + ins: + { + empty: false, + toHtml: function(attr) + { + return ['', '']; + } + }, + item: + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + icon: { req: false, valid: /^false$/i }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_items[id] && g_items[id][nameCol]) + { + var item = g_items[id]; + var str = ' '; + str += Markup._safeHtml(item[nameCol]) + ''; + return str; + } + return '(' + LANG.types[3][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_items[id] && g_items[id][nameCol]) + return Markup._safeHtml(g_items[id][nameCol]); + return LANG.types[3][0] + ' #' + id; + } + }, + itemset: + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^-?[0-9]+$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_itemsets[id] && g_itemsets[id][nameCol]) + { + var set = g_itemsets[id]; + return '' + Markup._safeHtml(set[nameCol]) + ''; + } + return '(' + LANG.types[4][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_itemsets[id] && g_itemsets[id][nameCol]) + return Markup._safeHtml(g_itemsets[id][nameCol]); + return LANG.types[4][0] + ' #' + id; + } + }, + li: + { + empty: false, + itrim: true, + allowedParents: { ul: 1, ol: 1 }, + helpText: function() + { + var str = ''; + str += '[ul]'; + for(var i = 0; i < 3; ++i) + str += '\n[li]' + LANG.markup_li + '[/li]'; + str += '\n[/ul]\n\n'; + str += '[ol]'; + for(var i = 0; i < 3; ++i) + str += '\n[li]' + LANG.markup_li + '[/li]'; + str += '\n[/ol]\n'; + return str.toLowerCase(); + }, + toHtml: function(attr) + { + return ['
    ', '
    ']; + }, + fromHtml: function(str, depth) + { + depth = depth || 0; + + var m; + if(m = Markup.matchOuterTags(str, '', '', 'g')) + { + for(var i = 0; i < m.length; ++i) + str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n\t" + Array(depth + 1).join("\t") + '[li]' + Markup.tags.li.fromHtml(m[i][0], depth + 1) + '[/li]'); + } + + return str; + } + }, + lightbox: + { + empty: false, + allowedClass: MARKUP_CLASS_STAFF, + attr: + { + unnamed: { req: true, valid: /^(map|model|screenshot)$/ }, + zone: { req: false, valid: /^-?[0-9]+[a-z]?$/i }, + floor: { req: false, valid: /^[0-9]+$/ }, + pins: { req: false, valid: /^[0-9]+$/ } + }, + validate: function(attr) + { + switch(attr.unnamed) + { + case 'map': + if(attr.zone) + return true; + break; + case 'model': + break; + case 'screenshot': + break; + } + return false; + }, + toHtml: function(attr) + { + var url = ''; + var onclick = ''; + switch(attr.unnamed) + { + case 'map': + url = '/maps=' + attr.zone; + if(attr.floor) + url += '.' + attr.floor; + if(attr.pins) + url += ':' + attr.pins; + var link = url.substr(6); + + onclick = 'if(!g_isLeftClick(event)) return; MapViewer.show({ link: \'' + link + '\' }); return false;'; + break; + } + + if(url && onclick) + return ['', '']; + return ''; + } + }, + map: + { + empty: false, + attr: + { + zone: { req: true, valid: /^-?[0-9a-z\-_]+$/i }, + source: { req: false, valid: /\S+/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + allowedChildren: { pin: 1 }, + toHtml: function(attr) + { + var coords = attr._contents; + attr.id = 'dsgdfngjkfdg' + (Markup.maps.length); + var str = '
    '; + + Markup.maps.push([attr.id, attr.zone, coords]); + + return [ str ]; + } + }, + n5: + { + empty: true, + attr: + { + unnamed: { req: true, valid: /^[0-9\.]+$/ } + }, + toHtml: function(attr) + { + return GetN5(attr.unnamed); + } + }, + pin: + { + empty: false, + attr: + { + url: { req: false, valid: /\S+/ }, + type: { req: false, valid: /^[0-9]+$/ }, + x: { req: true, valid: /^[0-9]{1,2}(\.[0-9])?$/ }, + y: { req: true, valid: /^[0-9]{1,2}(\.[0-9])?$/ }, + path: { req: false, valid: /^([0-9]{1,2}(\.[0-9])?[,:]?)+$/ } + }, + taglessSkip: true, + allowedClass: MARKUP_CLASS_STAFF, + allowedParents: { map: 1 }, + toHtml: function(attr) + { + if(attr.url && !Markup._isUrlSafe(attr.url)) + attr.url = ''; + var label = attr._contents; + if(attr.url && attr.url.indexOf('npc=') != -1) + label = '' + label + '
    Click to view this NPC'; + + var lines = null; + if(attr.path) + { + var coords = attr.path.split(':'), lines = []; + for(var i = 0, len = coords.length; i < len; ++i) + { + var parts = coords[i].split(','); + if(parts.length == 2) + lines.push([parseFloat(parts[0] || 0), parseFloat(parts[1] || 0)]); + } + } + + return [ [parseFloat(attr.x || 0), parseFloat(attr.y || 0), { label: label, url: attr.url, type: attr.type, lines: lines }] ]; + /*var str = '[' + parseFloat(attr.x || 0) + ',' + parseFloat(attr.y || 0) + ',{label: \'' + Markup._safeJsString(label) + '\''; + if(attr.url) + str += ', url: \'' + Markup._safeJsString(Markup._fixUrl(attr.url)) + '\''; + if(attr.type) + str += ', type: \'' + Markup._safeJsString(attr.type) + '\''; + str += '}]'; + return [ [str] ];*/ + } + }, + markupdoc: + { + empty: true, + attr: + { + tag: { req: false, valid: /[a-z0-9]+/i }, + help: { req: false, valid: /^(admin|staff|premium|user|pending)$/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + validate: function(attr) + { + if(attr.tag && !Markup.tags[attr.tag]) + return false; + return true; + }, + toHtml: function(attr) + { + var str = '', + helpClass = (attr.help ? Markup['CLASS_' + attr.help.toUpperCase()] : false); + + if(helpClass) + str += LANG.markup_helpdoc + '
    '; + + if(attr.tag) + str = Markup._generateTagDocs(attr.tag, helpClass); + else + { + for(var tag in Markup.tags) + { + if(!helpClass && str != '') + str += '
    '; + str += Markup._generateTagDocs(tag, helpClass); + } + } + + return str + (helpClass ? '
    ' + LANG.markup_help1 + '' + LANG.markup_help2 + '
    ' : ''); + } + }, + menu: + { + empty: true, + trim: true, + ltrim: true, + rtrim: true, + attr: + { + tab: { req: true, valid: /^[0-9]+$/ }, + path: { req: true, valid: /\S+/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + var path = attr.path.split(','); + PageTemplate.set({activeTab: attr.tab, breadcrumb: path}); + } + }, + minibox: + { + empty: false, + rtrim: true, + itrim: true, + attr: + { + 'float': { req: false, valid: /^(left|right)$/i } + }, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + var str = ''; + return [str, '']; + } + }, + model: + { + empty: false, + attr: + { + item: { req: false, valid: /^[0-9]+$/ }, + object: { req: false, valid: /^[0-9]+$/ }, + npc: { req: false, valid: /^[0-9]+$/ }, + itemset: { req: false, valid: /^[0-9,]+$/ }, + slot: { req: false, valid: /^[0-9]+$/ }, + humanoid: { req: false, valid: /^1$/ }, + 'float': { req: false, valid: /^(left|right)$/i }, + img: { req: false, valid: /\S+/ }, + link: { req: false, valid: /\S+/ }, + label: { req: false, valid: /[\S ]+/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + skipSlots: { 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1, 10: 1, 16: 1, 19: 1, 20: 1 }, + toHtml: function(attr) + { + var str = ''; + if(attr.npc) + { + str = '' + Markup._safeHtml(attr._contents) + '' + Markup._safeHtml(attr._contents) + '' + Markup._safeHtml(attr._contents) + ''; + } + else + return ['[model]', '[/model]']; + return [str, '']; + } + }, + money: + { + empty: true, + attr: + { + unnamed: { req: false, valid: /^[0-9]+$/ }, + side: { req: false, valid: /^(alliance|horde|both)$/i }, + items: { req: false, valid: /^[0-9,]+$/ }, + currency: { req: false, valid: /^[0-9,]+$/ }, + achievement: { req: false, valid: /\S+/ }, + arena: { req: false, valid: /^[0-9]+$/ }, + honor: { req: false, valid: /^[0-9]+$/ }, + }, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + var items = [], + currency = []; + + if(attr.items) + { + var split = attr.items.split(','); + if(split.length >= 2) + for(var i = 0; i < split.length-1; i += 2) + items.push([split[i], split[i+1]]); + } + + if(attr.currency) + { + var split = attr.currency.split(','); + if(split.length >= 2) + for(var i = 0; i < split.length-1; i += 2) + currency.push([split[i], split[i+1]]); + } + + // Backwards compatability + if(attr.honor) + currency.push([104, attr.honor]); + if(attr.arena) + currency.push([103, attr.arena]); + + return g_getMoneyHtml(attr.unnamed, attr.side, items, currency, attr.achievement); + } + }, + npc: + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_npcs[id] && g_npcs[id][nameCol]) + { + var npc = g_npcs[id]; + return '' + Markup._safeHtml(npc[nameCol]) + ''; + } + return '(' + LANG.types[1][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_npcs[id] && g_npcs[id][nameCol]) + return Markup._safeHtml(g_npcs[id][nameCol]); + return LANG.types[1][0] + ' #' + id; + } + }, + object: + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_objects[id] && g_objects[id][nameCol]) + { + var obj = g_objects[id]; + return '' + Markup._safeHtml(obj[nameCol]) + ''; + } + return '(' + LANG.types[2][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_objects[id] && g_objects[id][nameCol]) + return Markup._safeHtml(g_objects[id][nameCol]); + return LANG.types[2][0] + ' #' + id; + } + }, + ol: + { + block: true, + empty: false, + ltrim: true, + rtrim: true, + itrim: true, + allowedChildren: { li: 1 }, + toHtml: function(attr) + { + var open = ' 0) + open += ' class="' + classes.join(' ') + '"'; + open += Markup._addGlobalAttributes(attr) + '>'; + return [open, '']; + }, + fromHtml: function(str, depth) + { + depth = depth || 0; + + var m; + if(m = Markup.matchOuterTags(str, '', '', 'g')) + { + for(var i = 0; i < m.length; ++i) + { + str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n" + Array(depth + 1).join("\t") + '[ol]' + Markup.tags.ol.fromHtml(m[i][0], depth + 1) + "\n" + Array(depth + 1).join("\t") + '[/ol]'); + } + } + + return str; + } + }, + p: + { + empty: false, + ltrim: true, + rtrim: true, + itrim: true, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + return ['

    ','

    ']; + }, + fromHtml: function(str) + { + var m; + if(m = str.match(/[\s\S]*?<\/p>/gi)) + { + for(var i = 0; i < m.length; ++i) + { + var align = m[i].match(/^([\s\S]*?)<\/p>/i); + + str = str.replace(m[i], '[pad][div' + (align ? ' align=' + align[1] : '') + ']' + (inside ? inside[1] : '') + '[/div][pad]'); + + } + } + return str; + } + }, + pad: + { + empty: true, + block: true, + trim: true, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + var str = '
    '; + return str; + } + }, + pet: + { + empty: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + icon: { req: false, valid: /^false$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_pet_families && g_pet_families[id] && g_pets && g_pets[id]) + { + var str = ''; + str += '' + Markup._safeHtml(g_pet_families[id]) + ''; + return str; + } + return '(' + LANG.types[9][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + + if(g_pet_families && g_pet_families[id]) + return Markup._safeHtml(g_pet_families[id]); + return LANG.types[9][0] + ' #' + id; + } + }, + pre: + { + empty: false, + block: true, + rtrim: true, + toHtml: function(attr) + { + var open = '
    ';
    +                return [open, '
    ']; + }, + fromHtml: function(str) + { + return str.replace(/([\s\S]*?)<\/pre>/gi, '[pre]$1[/pre]'); + } + }, + quest: + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + icon: { req: false, valid: /^false$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_quests[id] && g_quests[id][nameCol]) + { + var quest = g_quests[id]; + return ' ' + Markup._safeHtml(quest[nameCol]) + ''; + } + return '(' + LANG.types[5][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_quests[id] && g_quests[id][nameCol]) + return Markup._safeHtml(g_quests[id][nameCol]); + return LANG.types[5][0] + ' #' + id; + } + }, + quote: + { + block: true, + empty: false, + rtrim: true, + ltrim: true, + itrim: true, + attr: + { + unnamed: { req: false, valid: /[\S ]+/ }, + url: { req: false, valid: /\S+/ }, + blizzard: { req: false, valid: /^true$/ }, + pname: { req: false }, + wowhead: { req: false, valid: /^true$/ }, + display: { req: false, valid: /^block$/ }, + align: { req: false, valid: /^(left|right|center)$/i }, + collapse: { req: false, valid: /^true$/ } + }, + allowedModes: { article: 1, quickfacts: 1, comment: 1 }, + validate: function(attr) { + if(attr.blizzard || attr.wowhead || attr.collapse || attr.url) + { + if(Markup.allow < Markup.CLASS_STAFF) + return false; + } + return true; + }, + toHtml: function(attr) + { + var str = '= 0) pname = 'Blue Tracker'; + // override with attr.pname if it exists + if(typeof(attr.pname) != 'undefined') pname = attr.pname; + + var username = attr.unnamed.trim(); + if(username.length <= 0) + return ['','']; + str = str.replace('class="quote', 'class="quote-blizz'); + str += (attr.collapse ? ' collapse' : '') + '">
    ' + + var matches = url.match(/https?:\/\/(us|eu)\.battle\.net\/wow\/en\/blog\/([0-9]+)/i) || url.match(/https?:\/\/(us|eu)\.battle\.net\/wow\/en\/forum\/topic\/([0-9]+)/i); + + if(matches) { + str += 'Originally posted by Blizzard (Official Post' + + var topicId = matches[2]; + str += ' | Blue Tracker)' + + '

    ' + username + '

    '; + } + else + str += ( + attr.url && Markup._isUrlSafe(attr.url) ? + 'Originally posted by Blizzard ' + + '(' + pname + ')' + + '

    ' + :'

    ' + username + '

    ' + ); + + return [str, '
    ']; + + } + return ['','']; + } + else if(attr.wowhead /*Markup.inBlog*/) + { + str = str.replace('class="quote', 'class="quote-wh'); + str += (attr.collapse ? ' collapse' : '') + '">'; + str += '
    '; + return [str, '
    ']; + } + else + { + str += '">'; + if(attr.unnamed) + { + var username = attr.unnamed.trim(); + if(username.length > 0) + { + str += ''; + if(attr.url && Markup._isUrlSafe(attr.url)) + str += '' + username + ''; + else if(g_isUsernameValid(username)) + str += '' + username + ''; + else + str += username; + str += ' '+ LANG.markup_said + '
    '; + } + } + return [str, '']; + } + } + }, + race: + { + empty: true, + allowInReplies: true, + valid: { 1: true, 2: true, 3: true, 4: true, 5: true, 6: true, 7: true, 8: true, 9: true, 10: true, 11: true, 22: true, 24: true, 25: true }, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + gender: { req: false, valid: /^(0|1)$/ }, + icon: { req: false, valid: /^false$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + if(Markup.tags.race.valid[attr.unnamed]) + return true; + return false; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var gender = attr.gender | 0; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_races[id] && g_races[id][nameCol]) + { + var race = g_races[id]; + return ' ' + Markup._safeHtml(race[nameCol]) + ''; + } + return '(' + LANG.types[14][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_races[id] && g_races[id][nameCol]) + return Markup._safeHtml(g_races[id][nameCol]); + return LANG.types[14][0] + ' #' + id; + } + }, + reveal: + { + empty: false, + rtrim: true, + ltrim: true, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + if(!Markup.inBlog || Markup.inBlog > 1) + return ['', '']; + + return [' (read more)']; + Markup.reveals++; + } + }, + s: + { + empty: false, + allowInReplies: true, + toHtml: function(attr) + { + return ['', '']; + }, + fromHtml: function(str) + { + return str.replace(/([\s\S]*?)<\/del>/gi, '[s]$1[/s]'); + } + }, + screenshot: + { + empty: false, + attr: + { + id: { req: false, valid: /^[0-9]+$/ }, + url: { req: false, valid: /\S+/ }, + thumb: { req: false, valid: /\S+/ }, + size: { req: false, valid: /^(thumb|resized|normal)$/i }, + width: { req: false, valid: /^[0-9]+$/ }, + height: { req: false, valid: /^[0-9]+$/ }, + 'float': { req: false, valid: /^(left|right)$/i }, + border: { req: false, valid: /^[0-9]+$/ } + }, + taglessSkip: true, + allowedClass: MARKUP_CLASS_STAFF, + validate: function(attr) + { + if(attr.url && !attr.thumb) + return false; + else if(!attr.id && !attr.url) + return false; + return true; + }, + toHtml: function(attr) + { + var url = ''; + var thumb = ''; + + if(attr.id) + { + url = g_staticUrl + '/uploads/screenshots/normal/' + attr.id + '.jpg'; + + var thumbId = attr.id; + if(attr.thumb && attr.thumb.match(/^[0-9]+$/)) + { + thumbId = attr.thumb; + attr.thumb = null; + } + + thumb = g_staticUrl + '/uploads/screenshots/' + (attr.size ? attr.size : 'thumb') + '/' + thumbId + '.jpg'; + } + else if(attr.url) + url = attr.url; + + if(attr.thumb) + thumb = attr.thumb; + + var caption = attr._contents.replace(/\n/g, '
    '); + + if(!g_screenshots[Markup.uid]) + g_screenshots[Markup.uid] = []; + var str = ''; + + + str += '']; + } + }, + script: + { + ltrim: true, + rtrim: true, + empty: false, + attr: + { + src: { req: false, valid: /^\S+$/ } + }, + allowedClass: MARKUP_CLASS_ADMIN, + allowedChildren: { '': 1 }, + rawText: true, + taglessSkip: true, + toHtml: function(attr) + { + if(attr.src) + { + $.getScript(attr.src, function() { + $.globalEval(attr._contents); + }); + } + else + $.globalEval(attr._contents); + return ['']; + } + }, + section: + { + empty: false, + ltrim: true, + rtrim: true, + trim: true, + allowedClass: MARKUP_CLASS_STAFF, + attr: + { + }, + toHtml: function(attr) + { + return ['
    ', '
    ']; + } + }, + skill: + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + icon: { req: false, valid: /^false$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_skills[id] && g_skills[id][nameCol]) + { + var skill = g_skills[id]; + return ' ' + Markup._safeHtml(skill[nameCol]) + ''; + } + return '(' + LANG.types[15][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_skills[id] && g_skills[id][nameCol]) + return Markup._safeHtml(g_skills[id][nameCol]); + return LANG.types[15][0] + ' #' + id; + } + }, + sig: + { + empty: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ } + }, + allowedClass: MARKUP_CLASS_PREMIUM, + allowedModes: { signature: 1 }, + toHtml: function(attr) + { + return; + return ''; + } + }, + small: + { + empty: false, + toHtml: function(attr) + { + return ['', '']; + }, + fromHtml: function(str) + { + return str.replace(/([\s\S]*?)<\/small>/gi, '[small]$1[/small]'); + } + }, + span: + { + empty: false, + attr: + { + unnamed: { req: false, valid: /^(hidden|invisible)$/ }, + tooltip: { req: false, valid: /\S+/ }, + tooltip2: { req: false, valid: /\S+/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + var str = ' 0) + str += ' style="' + styles.join(';') + '"'; + + if(attr.tooltip && Markup.tooltipTags[attr.tooltip]) + str += ' onmouseover="$WH.Tooltip.showAtCursor(event, Markup.tooltipTags[\'' + attr.tooltip + '\'], 0, 0, ' + (Markup.tooltipBare[attr.tooltip] ? 'null' : "'q'") + ', ' + (attr.tooltip2 && Markup.tooltipTags[attr.tooltip2] ? "Markup.tooltipTags['" + attr.tooltip2 + "']" : 'null') + ')" onmousemove="$WH.Tooltip.cursorUpdate(event)" onmouseout="$WH.Tooltip.hide()"'; + + str += '>'; + return [str, '']; + } + }, + spell: + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + diff: { req: false, valid: /^[0-9]+$/ }, + icon: { req: false, valid: /^false$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + buff: { req: false, valid: /^true$/ }, + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + var rel = []; + + if(attr.buff) + rel.push('buff'); + if(attr.diff) + rel.push('diff=' + attr.diff); + + if(g_spells[id] && g_spells[id][nameCol]) + { + var spell = g_spells[id]; + return ' ' + Markup._safeHtml(spell[nameCol]) + ''; + } + + return '(' + LANG.types[6][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_spells[id] && g_spells[id][nameCol]) + return Markup._safeHtml(g_spells[id][nameCol]); + return LANG.types[6][0] + ' #' + id; + } + }, + spoiler: + { + block: true, + empty: false, + rtrim: true, + ltrim: true, + itrim: true, + toHtml: function(attr) + { + return ['
    ' + LANG.markup_spoil + '', '']; + } + }, + statistic: + { + empty: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + icon: { req: false, valid: /^false$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_achievements[id] && g_achievements[id][nameCol]) + { + var ach = g_achievements[id]; + return ' ' + Markup._safeHtml(ach[nameCol]) + ''; + } + return '(' + LANG.types[10][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_achievements[id] && g_achievements[id][nameCol]) + return Markup._safeHtml(g_achievements[id][nameCol]); + return LANG.types[10][0] + ' #' + id; + } + }, + style: + { + ltrim: true, + rtrim: true, + empty: false, + allowedClass: MARKUP_CLASS_ADMIN, + allowedChildren: { '': 1 }, + rawText: true, + taglessSkip: true, + toHtml: function(attr) + { + g_addCss(attr._contents); + return ['']; + } + }, + sub: + { + empty: false, + toHtml: function(attr) + { + return ['', '']; + }, + fromHtml: function(str) + { + return str.replace(/([\s\S]*?)<\/sub>/gi, '[sub]$1[/sub]'); + } + }, + sup: + { + empty: false, + toHtml: function(attr) + { + return ['', '']; + }, + fromHtml: function(str) + { + return str.replace(/([\s\S]*?)<\/sup>/gi, '[sup]$1[/sup]'); + } + }, + tabs: + { + block: true, + empty: false, + ltrim: true, + rtrim: true, + itrim: true, + allowedClass: MARKUP_CLASS_STAFF, + allowedChildren: { tab: 1 }, + attr: { + name: { req: true, valid: /\S+/ }, + width: { req: false, valid: /^[0-9]+(px|em|\%)$/ } + }, + toHtml: function(attr) { + attr.id = g_urlize(attr.name); + var x = Markup.preview; + var str = '
    '; + str += ''; + str += tab.content; + str += '
    '; + str += ''; + } + + str += ''; + str += ''; + + setTimeout(Markup.createTabs.bind(null, attr, tabs, (x ? 'preview' : '')), 100); + return [str]; + } + }, + tab: + { + block: true, + empty: false, + ltrim: true, + rtrim: true, + itrim: true, + allowedClass: MARKUP_CLASS_STAFF, + allowedParents: { tabs: 1 }, + attr: { + name: { req:true, valid: /[\S ]+/ }, + icon: { req:false, valid: /\S+/ } + }, + toHtml: function(attr) + { + attr.id = g_urlize(attr.name); + attr.name = $WH.str_replace(attr.name, "_", ' '); + if(typeof(attr['class']) != 'undefined') + attr['class'] = $WH.str_replace(attr['class'], "_", ' '); + return [{content: attr._contents, id: attr.id, name: attr.name, icon: attr.icon, 'class': attr['class']}]; + } + }, + table: + { + //block: true, + empty: false, + ltrim: true, + rtrim: true, + itrim: true, + allowedChildren: { tr: 1 }, + attr: + { + border: { req: false, valid: /^[0-9]+$/ }, + cellspacing: { req: false, valid: /^[0-9]+$/ }, + cellpadding: { req: false, valid: /^[0-9]+$/ }, + width: { req: false, valid: /^[0-9]+(px|em|\%)$/ } + }, + toHtml: function(attr) + { + var str = '']; + }, + fromHtml: function(str, depth) + { + depth = depth || 0; + + var m; + if(m = Markup.matchOuterTags(str, '', '', 'g')) + { + for(var i = 0; i < m.length; ++i) + { + var border = m[i][1].match(/border[:="]+\s*([0-9]+)/i), + width = m[i][1].match(/width[:="]+\s*([0-9]+)/i), + spacing = m[i][1].match(/cellspacing="([\s\S]+?)"/i), + padding = m[i][1].match(/cellpadding="([\s\S]+?)"/i); + + str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n" + Array(depth + 1).join("\t") + '[table' + (border ? ' border=' + border[1] : '') + (width ? ' width=' + width[1] : '') + (spacing ? ' cellspacing=' + spacing[1] : '') + (padding ? ' cellpadding=' + padding[1] : '') + ']' + Markup.tags.table.fromHtml(m[i][0], depth + 1) + "\n" + Array(depth + 1).join("\t") + '[/table]'); + } + } + + return str; + } + }, + tr: { + empty: false, + itrim: true, + allowedChildren: { td: 1 }, + allowedParents: { table: 1 }, + toHtml: function(attr) + { + return ['', '']; + }, + fromHtml: function(str, depth) + { + depth = depth || 0; + + var m; + if(m = Markup.matchOuterTags(str, '', '', 'g')) + { + for(var i = 0; i < m.length; ++i) + { + str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n\t" + Array(depth + 1).join("\t") + '[tr]' + Markup.tags.tr.fromHtml(m[i][0], depth + 1) + "\n" + Array(depth + 1).join("\t") + '[/tr]'); + } + } + + return str; + } + }, + td: + { + empty: false, + itrim: true, + allowedParents: { tr: 1 }, + attr: + { + unnamed: { req: false, valid: /^header$/ }, + align: { req: false, valid: /^(right|left|center|justify)$/i }, + valign: { req: false, valid: /^(top|middle|bottom|baseline)$/i }, + colspan: { req: false, valid: /^[0-9]+$/ }, + rowspan: { req: false, valid: /^[0-9]+$/ }, + width: { req: false, valid: /^[0-9]+(px|em|\%)$/ } + }, + toHtml: function(attr) + { + var str = '<' + (attr.unnamed ? 'th' : 'td') + Markup._addGlobalAttributes(attr); + if(attr.align != undefined) + str += ' align="' + attr.align + '"'; + if(attr.valign != undefined) + str += ' valign="' + attr.valign + '"'; + if(attr.colspan != undefined) + str += ' colspan="' + attr.colspan + '"'; + if(attr.rowspan != undefined) + str += ' rowspan="' + attr.rowspan + '"'; + if(attr.width != undefined) + str += ' style="width: ' + attr.width + '"'; + str += '>'; + return [str, '']; + }, + fromHtml: function(str, depth) + { + depth = depth || 0; + + var t = ['td', 'th'], m; + for(var j = 0; j < t.length; ++j) + { + if(m = Markup.matchOuterTags(str, '<' + t[j] + '\\b[\\s\\S]*?>', '', 'g')) + { + for(var i = 0; i < m.length; ++i) + { + var width = m[i][1].match(/width[:="]+\s*([0-9]+)/i), + align = m[i][1].match(/align="([\s\S]+?)"/i), + valign = m[i][1].match(/valign="([\s\S]+?)"/i), + colspan = m[i][1].match(/colspan="([\s\S]+?)"/i), + rowspan = m[i][1].match(/rowspan="([\s\S]+?)"/i); + + str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n\t\t" + Array(depth + 1).join("\t") + '[td' + (t[j] == 'th' ? '=header' : '') + (width ? ' width=' + width[1] : '') + (align ? ' align=' + align[1] : '') + (valign ? ' valign=' + valign[1] : '') + (colspan ? ' colspan=' + colspan[1] : '') + (rowspan ? ' rowspan=' + rowspan[1] : '') + ']' + Markup.tags.td.fromHtml(m[i][0], depth + 1) + '[/td]'); + } + } + } + + return str; + } + }, + time: + { + empty: true, + count: 0, + attr: + { + until: { req: false, valid: /^\d+$/ }, + since: { req: false, valid: /^\d+$/ }, + server: { req: false, valid: /^true$/ } + }, + validate: function(attr) + { + if(!attr.until && !attr.since) + return false; + return true; + }, + toHtml: function(attr) + { + var id = Markup.tags.time.count++; + var str = '' + Markup.tags.time.getTime(attr) + ''; + setInterval(Markup.tags.time.updateTime.bind(null, id, attr), 5000); + return str; + }, + getTime: function(attr) + { + var now; + if(attr.server) + now = g_serverTime.getTime() / 1000; + else + now = (new Date()).getTime() / 1000; + var delay = 0; + if(attr.until) + delay = attr.until - now; + else + delay = now - attr.since; + + if(delay > 0) + return g_formatTimeElapsed(delay); + else + return '0 ' + LANG.timeunitspl[6]; + }, + updateTime: function(id, attr) + { + var span = $WH.ge('markupTime' + id); + if(!span) + return; + + span.firstChild.nodeValue = Markup.tags.time.getTime(attr); + } + }, + toc: + { + block: true, + post: true, + trim: true, + ltrim: true, + rtrim: true, + collect: { h2: 1, h3: 1 }, + exclude: { tabs: { h2: 1, h3: 1 }, minibox: { h2: 1, h3: 1 } }, + allowedClass: MARKUP_CLASS_STAFF, + attr: + { + h3: { req: false, valid: /^false$/ } + }, + postHtml: function(attr, nodes) + { + var str = ' 0) + str += ' class="' + classes.join(' ') + '"'; + str += Markup._addGlobalAttributes(attr) + '>' + LANG.markup_toc + '
      '; + var lastNode = ""; + var indent = 1; + var allowH3 = (attr.h3 != 'false'); + var myNodes = []; + for(var node in nodes.h2) + myNodes.push(nodes.h2[node]); + for(var node in nodes.h3) + myNodes.push(nodes.h3[node]); + myNodes.sort(function(a, b) { + return a.offset - b.offset; + }); + + for(var i in myNodes) + { + node = myNodes[i]; + if(node.name == 'h2' && node.attr.toc != 'false') + { + if(lastNode == 'h3') + { + str += '
    '; + indent--; + } + str += '
  • ' + node.attr._textContents + '
  • '; + lastNode = 'h2'; + } + if(node.name == 'h3' && allowH3 && node.attr.toc != 'false' && (lastNode != '' || nodes.h2.length == 0)) + { + if(lastNode == 'h2') + { + str += ''; + } + return str; + } + }, + toggler: + { + empty: false, + attr: + { + id: { req: true, valid: /^[a-z0-9_-]+$/i }, + unnamed: { req: false, valid: /^hidden$/i } + }, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + var str = ''; + return [str, '']; + } + }, + tooltip: + { + empty: false, + attr: + { + unnamed: { req: false, valid: /\S+/ }, + name: { req: false, valid: /\S+/ }, + bare: { req: false, valid: /^true$/i }, + label: { req: false, valid: /[\S ]+/ } + }, + taglessSkip: true, + allowedClass: MARKUP_CLASS_STAFF, + validate: function(attr) + { + if(!attr.unnamed && !attr.name) + return false; + return true; + }, + toHtml: function(attr) + { + if(attr.unnamed) + return ['', '']; + else + { + Markup.tooltipTags[attr.name] = (attr.label ? '
    ' + attr.label + '
    ' : '') + attr._contents; + if(attr.bare) + Markup.tooltipBare[attr.name] = true; + return ['']; + } + } + }, + u: + { + empty: false, + allowInReplies: true, + toHtml: function(attr) + { + return ['', '']; + }, + fromHtml: function(str) + { + return str.replace(/<(ins|u)\b[\s\S]*?>([\s\S]*?)<\/\1>/gi, '[u]$2[/u]'); + } + }, + ul: + { + block: true, + empty: false, + ltrim: true, + rtrim: true, + itrim: true, + allowedChildren: { li: 1 }, + toHtml: function(attr) + { + var open = ' 0) + open += ' class="' + classes.join(' ') + '"'; + open += Markup._addGlobalAttributes(attr) + '>'; + return [open, '']; + }, + fromHtml: function(str, depth) + { + depth = depth || 0; + + var m; + if(m = Markup.matchOuterTags(str, '', '', 'g')) + { + for(var i = 0; i < m.length; ++i) + { + str = str.replace(m[i][1] + m[i][0] + m[i][2], "\n" + Array(depth + 1).join("\t") + '[ul]' + Markup.tags.ul.fromHtml(m[i][0], depth + 1) + "\n" + Array(depth + 1).join("\t") + '[/ul]'); + } + } + + return str; + } + }, + url: + { + allowedClass: MARKUP_CLASS_USER, + allowInReplies: true, + empty: false, + helpText: '[url=http://www.google.com]' + LANG.markup_url + '[/url]', + attr: + { + unnamed: { req: false, valid: /\S+/ }, + rel: { req: false, valid: /(item|quest|spell|achievement|npc|object)=([0-9]+)/ }, + onclick: { req: false, valid: /[\S ]+/ }, + tooltip: { req: false, valid: /\S+/ }, + tooltip2: { req: false, valid: /\S+/ } + }, + validate: function(attr) + { + if(attr.onclick && Markup.allow < Markup.CLASS_ADMIN) + return false; + + if(attr.tooltip && Markup.allow < Markup.CLASS_STAFF) + return false; + + var target = ''; + if(attr.unnamed && /^(mailto:|irc:)/i.test(attr.unnamed.trim()) && Markup.allow < Markup.CLASS_STAFF) + return false; + + if(attr.unnamed && /^(javascript:)/i.test(attr.unnamed.trim())) + return false; + + return true; + }, + toHtml: function(attr) + { + var target; + if(attr.unnamed) // in the form [url=blah] + { + target = attr.unnamed; + target = target.replace(/&/, '&'); + if(!target.match(/^([^:\\.\/]+):/i) && target.charAt(0) != '/' && target.charAt(0) != '#') + target = '/' + target; + if(Markup._isUrlSafe(target, true)) + { + var pre = '']; + } + else + { + return ['', '']; + } + } + else // [url]blah[/url] + { + target = attr._textContents; + target = target.replace(/&/, '&'); + if(Markup._isUrlSafe(target)) + { + var pre = '']; + } + else + { + return ['', '']; + } + } + }, + fromHtml: function(str) + { + return str.replace(/([\s\S]*?)<\/a>/gi, '[url=$1]$2[\/url]'); + } + }, + video: + { + empty: true, + attr: + { + id: { req: true, valid: /^[0-9]+$/ }, + unnamed: { req: false, valid: /^embed$/i }, + 'float': { req: false, valid: /^(left|right)$/i }, // Thumbnail only + border: { req: false, valid: /^[0-9]+$/ } // Thumbnail only + }, + ltrim: true, + rtrim: true, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + if(g_videos[attr.id]) + { + var html = '', video = g_videos[attr.id]; + if(attr.unnamed) + { + if(video.videoType == 1) // YouTube + html += Markup.toHtml('[youtube=' + video.videoId + ']', { skipReset: true }); + } + else + { + if(!g_videos[Markup.uid]) + g_videos[Markup.uid] = []; + + html += ''; + + g_videos[Markup.uid].push($WH.dO(video)); + } + return html; + } + return 'Video #' + attr.id + ''; + } + }, + visitedpage: + { + empty: false, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + $.post('/visited-page', { id: attr.unnamed }, function() { AchievementCheck(); }); + return ''; + } + }, + wowheadresponse: + { + block: true, + empty: false, + rtrim: true, + ltrim: true, + itrim: true, + attr: + { + unnamed: { req: true, valid: /[\S ]+/ }, + roles: { req: true, valid: /[0-9]+/ } + }, + allowedModes: { article: 1, quickfacts: 1, comment: 1 }, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + var str = '' + username + ' ' + LANG.markup_said + '
    '; + return [str, '']; + } + }, + youtube: + { + empty: true, + attr: + { + unnamed: { req: true, valid: /\S+/ }, + width: { req: false, valid: /^[0-9]+$/ }, + height: { req: false, valid: /^[0-9]+$/ }, + autoplay: { req: false, valid: /^true$/ } + }, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + var url = 'http://www.youtube.com/v/' + attr.unnamed + '&fs=1&rel=0' + (attr.autoplay ? '&autoplay=1' : ''); + var width = attr.width ? attr.width : 640; + var height = attr.height ? attr.height : 385; + + var html = ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + + return html; + }, + fromHtml: function(str) + { + var m; + if(m = str.match(/<\/iframe>/gi)) + { + for(var i = 0; i < m.length; ++i) + { + var source = m[i].match(/src="[\s\S]*?youtube\.com\/embed\/([\s\S]*?)"/i), + width = m[i].match(/width[:="]+\s*([0-9]+)/i), + height = m[i].match(/height[:="]+\s*([0-9]+)/i), + border = m[i].match(/border[:="]+\s*([0-9]+)/i); + + str = str.replace(m[i], '[youtube=' + source[1] + (width ? ' width=' + width[1] : '') + (height ? ' height=' + height[1] : '') + ']'); + } + } + return str; + } + }, + center: + { + empty: false, + allowInReplies: false, + allowedClass: MARKUP_CLASS_STAFF, + toHtml: function(attr) + { + return ['
    ', '
    ']; + }, + fromHtml: function(str) + { + return str.replace(/
    ([\s\S]+?)<\/center>/gi, '[pad][div align=center]$1[/div][pad]'); + } + }, + title: + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_titles[id] && g_titles[id][nameCol]) + { + return '' + Markup._safeHtml(g_titles[id][nameCol]) + ''; + } + return '(' + LANG.types[11][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_titles[id] && g_titles[id][nameCol]) + return Markup._safeHtml(g_titles[id][nameCol]); + return LANG.types[11][0] + ' #' + id; + } + }, + zone: + { + empty: true, + allowInReplies: true, + attr: + { + unnamed: { req: true, valid: /^[0-9]+$/ }, + domain: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ }, + site: { req: false, valid: /^(beta|mop|ptr|www|de|es|fr|ru|pt)$/ } + }, + validate: function(attr) + { + if((attr.domain || attr.site) && Markup.dbpage) + return false; + return true; + }, + toHtml: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var url = domainInfo[0]; + var nameCol = domainInfo[1]; + + if(g_gatheredzones[id] && g_gatheredzones[id][nameCol]) + { + return '' + Markup._safeHtml(g_gatheredzones[id][nameCol]) + ''; + } + return '(' + LANG.types[7][0] + ' #' + id + ')'; + }, + toText: function(attr) + { + var id = attr.unnamed; + var domainInfo = Markup._getDatabaseDomainInfo(attr); + var nameCol = domainInfo[1]; + + if(g_gatheredzones[id] && g_gatheredzones[id][nameCol]) + return Markup._safeHtml(g_gatheredzones[id][nameCol]); + return LANG.types[7][0] + ' #' + id; + } + } + }, + + _addGlobalAttributes: function(attr) + { + var attribs = ''; + if(Markup.allow < Markup.CLASS_STAFF) + return attribs; + if(attr.id) + attribs += ' id="' + attr.id + '"'; + if(attr.title) + attribs += ' title="' + Markup._safeQuotes(attr.title) + '"'; + if(attr['class']) + attribs += ' class="' + attr['class'] + '"'; + if(attr['data-highlight']) + attribs += ' data-highlight="' + attr['data-highlight'] + '"'; + + return attribs; + }, + + _generateTagDocs: function(tagName, helpClass) + { + var tag = Markup.tags[tagName]; + if(!tag) + return ''; + + if(helpClass) + { + if((tag.allowedClass && tag.allowedClass > helpClass) || (!tag.helpText && (tag.empty || tag.allowedParents || tag.allowedChildren || !LANG['markup_' + tagName]))) + return ''; + + if(tag.helpText && typeof tag.helpText == 'function') + var str = tag.helpText(); + else if(tag.helpText && typeof tag.helpText == 'string') + var str = tag.helpText; + else + var str = '[' + tagName + ']' + LANG['markup_' + tagName].toLowerCase() + '[/' + tagName + ']'; + + return '
    ' + str + '
    ' + Markup.toHtml(str, { skipReset: true }) + ''; + } + + var str = '

    Tag: [' + Markup._safeHtml(tagName) + ']

    '; + str += ''; + + if(tag.attr) + { + /*str += '';*/ + str += ''; + } + + str += ''; + + str += ''; + + if(tag.allowedChildren) + { + str += ''; + } + + if(tag.allowedParents) + { + str += ''; + } + + if(tag.presets) + { + str += ''; + } + + if(tag.trim) + { + str += ''; + } + + if(tag.ltrim) + { + str += ''; + } + + if(tag.rtrim) + { + str += ''; + } + + if(tag.itrim) + { + str += ''; + } + + if(tag.block) + { + str += ''; + } + + str += '
    Attributes:'; + for(var a in tag.attr) + { + str += ''; + str += ''; + str += ''; + } + str += '
    ' + a + '
    Required:' + (tag.attr[a].req ? 'Yes' : 'No') + '
    Valid:' + (tag.attr[a].valid ? Markup._safeHtml(tag.attr[a].valid.toString()) : '--') + '
    Attributes:'; + for(var a in tag.attr) + { + str += '
    '; + str += ''; + str += '
    '; + if(a == 'unnamed') + str += 'Self ([' + tagName + '=???])'; + else + str += a; + str += '
    Required:' + (tag.attr[a].req ? 'Yes' : 'No') + '
    Valid:' + (tag.attr[a].valid ? Markup._safeHtml(tag.attr[a].valid.toString()) : '--') + '
    '; + } + str += '
    Has closing tag:' + (tag.empty ? 'No' : 'Yes') + '
    Required group:'; + if(tag.allowedClass == MARKUP_CLASS_ADMIN) + str += 'Administrator'; + else if(tag.allowedClass == MARKUP_CLASS_STAFF) + str += 'Staff'; + else if(tag.allowedClass == MARKUP_CLASS_PREMIUM) + str += 'Premium'; + else if(tag.allowedClass && tag.allowedClass != MARKUP_CLASS_PENDING) + str += 'Not pending'; + else + str += 'None'; + str += '
    Allowed children:'; + for(var t in tag.allowedChildren) + str += Markup._safeHtml(t) + '
    '; + str += '
    Allowed parents:'; + for(var t in tag.allowedParents) + str += Markup._safeHtml(t) + '
    '; + str += '
    Preset values:'; + for(var p in tag.presets) + str += ''; + str += '
    ' + p + '' + Markup._safeHtml(tag.presets[p]) + '
    Trim whitespace
    Trim preceding whitespace
    Trim following whitespace
    Trim whitespace around interior content
    Automatically remove top padding if not the first item
    '; + + return str; + }, + + _init: function() + { + if(!this.inited) + { + var ltrimTags = [], rtrimTags = [], trimTags = []; + for(var tag in Markup.tags) + { + if(Markup.tags[tag].block) + this.firstTags[tag] = true; + if(Markup.tags[tag].exclude) + { + for(var ex in Markup.tags[tag].exclude) + { + if(!this.excludeTags[ex]) + this.excludeTags[ex] = {}; + this.excludeTags[ex][tag] = Markup.tags[tag].exclude[ex]; + } + } + if(Markup.tags[tag].post) + this.postTags.push(tag); + if(Markup.tags[tag].trim) + trimTags.push(tag); + if(Markup.tags[tag].ltrim) + ltrimTags.push(tag); + if(Markup.tags[tag].rtrim) + rtrimTags.push(tag); + } + + if(ltrimTags.length > 0) + this.ltrimRegex = new RegExp('\\s*\\[(' + ltrimTags.join('|') + ')([^a-z0-9]+.*)?]', 'ig'); + if(rtrimTags.length > 0) + this.rtrimRegex = new RegExp('\\[\/(' + rtrimTags.join('|') + ')\\]\\s*', 'ig'); + if(trimTags.length > 0) + this.trimRegex = new RegExp('\\s*\\[(' + trimTags.join('|') + ')([^\\[]*)?\\]\\s*', 'ig'); + + this.inited = true; + + $('[data-highlight]') + .live('mouseenter', function() { + var _ = $(this).attr('data-highlight').split(':'); + + if(_.length != 2) + return; + + var elem = $('#' + _[0]).get(0), + start = parseInt(_[1]), + text = $(elem).val(); + + if(!elem || !start || !text) + return; + + var top = $(elem).val(text.substr(0, start))[0].scrollHeight; + + $(elem).val(text).animate({ scrollTop: top }, 250); + elem.selectionStart = start; + elem.selectionEnd = start; + }); + } + }, + + _safeJsString: function(str) + { + return str.replace(/'/g, '\''); + }, + + _safeQuotes: function(str) + { + return str.replace('"', '\"').replace("'", "\'"); + }, + + _safeHtml: function(html) + { + var allowedEscapes = ['nbsp', 'ndash']; + html = html.replace(/&/g, '&'); + if(allowedEscapes.length > 0) + html = html.replace(new RegExp('&(' + allowedEscapes.join('|') + ');', 'g'), '&$1;'); + return html.replace(//g, '>').replace(/"/g, '"'); + }, + + _preText: function(str) + { + str = Markup._safeHtml(str); + str = str.replace(/\n/g, '
    '); + return str; + }, + + _getDatabaseDomainInfo: function(attr) + { + var url = ''; + var nameCol = Markup.nameCol; + + var domain = false; + if(attr.domain) + domain = attr.domain; + else if(attr.site) + domain = attr.site; + else if(Markup.defaultSource) + domain = MarkupSourceMap[Markup.defaultSource]; + + if(domain) + { + if(domain == 'beta') + domain = 'mop'; + url = 'http://' + domain + '.wowhead.com'; + nameCol = 'name_' + Markup.domainToLocale[domain]; + } + else if(location.href.indexOf('wowheadnews.com') != -1) + url = 'http://www.wowhead.com'; + + return [url, nameCol, domain]; + }, + + _isUrlSafe: function(str, extras) + { + if(!str) + return true; + if(str == 'javascript:;') + return true; + + var result = str.match(/^([^:\\./]+):/i); + + if(result && result[1]) + { + var protocol = result[1]; + + if(protocol == 'http' || protocol == 'https') + return true; + + if(extras && (protocol == 'mailto' || protocol == 'irc')) + return true; + + if(protocol != 'mailto' && str.indexOf('://') == -1) + return true; + + return false; + } + + return true; + }, + + _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; + } + + return url; + }, + + _isUrlExternal: function(str) + { + if(!str) + return false; + return (str.indexOf('wowhead.com') == -1 && str.match(/^([^:\\./]+):/i)); + }, + + _nodeSearch: function(node, name, depth) + { + if(!depth) depth = 0; + if(depth >= 3) return; + if(node.name == name) + return true; + else if(node.parent) + return Markup._nodeSearch(node.parent, name, depth+1); + }, + + _parse: function(str, opts) + { + Markup.nameCol = 'name_' + Locale.getName(); + if(opts && opts.locale) + Markup.nameCol = 'name_' + Markup.domainToLocale[opts.locale]; + else if($WH.isset('g_beta') && g_beta) + Markup.nameCol = 'name_beta'; + else if($WH.isset('g_ptr') && g_ptr) + Markup.nameCol = 'name_ptr'; + else if($WH.isset('g_old') && g_old) + Markup.nameCol = 'name_old'; + + if(!str) + str = ""; + + str = str.replace(/\r/g, ''); + + if(!opts) opts = {}; + if(!opts.skipReset) + { + Markup.uid = opts.uid || 'abc'; + Markup.root = opts.root; + Markup.preview = opts.preview || false; + Markup.dbpage = opts.dbpage || false; + Markup.defaultSource = false; + + if(Markup.uid != 'abc') + g_screenshots[Markup.uid] = []; + } + + if(opts.roles && (opts.roles & (U_GROUP_ADMIN|U_GROUP_EDITOR|U_GROUP_MOD|U_GROUP_BUREAU|U_GROUP_DEV|U_GROUP_BLOGGER)) && opts.mode != Markup.MODE_SIGNATURE) + opts.mode = Markup.MODE_ARTICLE; + Markup.mode = opts.mode || Markup.MODE_ARTICLE; + Markup.allow = opts.allow || Markup.CLASS_STAFF; + Markup.inBlog = opts.inBlog ? opts.inBlog : 0; + + if(opts.stopAtBreak) + { + var breakPos = str.indexOf('[break]'); + if(breakPos != -1) + str = str.substring(0, breakPos); + } + else + str = str.replace('[break]', ''); + + var tree = new MarkupTree(); + str = str.trim(); + //str = Markup._safeHtml(str); // Resetting this prop causes TOC not to work when // there are multiple markup sections on a page. -// this.collectTags = {}; - if(this.postTags.length) - { - for(var i in this.postTags) - { - var tag = this.postTags[i]; - if(str.indexOf('['+tag) != -1) - if(!(Markup.tags[tag].allowedModes && Markup.tags[tag].allowedModes[MarkupModeMap[opts.mode]] == undefined)) - for(var collect in Markup.tags[tag].collect) - this.collectTags[collect] = true; - } - } +// this.collectTags = {}; + if(this.postTags.length) + { + for(var i in this.postTags) + { + var tag = this.postTags[i]; + if(str.indexOf('['+tag) != -1) + if(!(Markup.tags[tag].allowedModes && Markup.tags[tag].allowedModes[MarkupModeMap[opts.mode]] == undefined)) + for(var collect in Markup.tags[tag].collect) + this.collectTags[collect] = true; + } + } - //str = str.replace(this.ltrimRegex, function(match, $1, $2) { return '[' + $1 + ($2 ? $2 : '') + ']'; }); - //str = str.replace(this.rtrimRegex, function(match, $1) { return '[/' + $1 + ']'; }); - //str = str.replace(this.trimRegex, function(match, $1, $2) { return '[' + $1 + ($2 ? $2 : '') + ']'; }); + //str = str.replace(this.ltrimRegex, function(match, $1, $2) { return '[' + $1 + ($2 ? $2 : '') + ']'; }); + //str = str.replace(this.rtrimRegex, function(match, $1) { return '[/' + $1 + ']'; }); + //str = str.replace(this.trimRegex, function(match, $1, $2) { return '[' + $1 + ($2 ? $2 : '') + ']'; }); - str = str.replace(/\n(\s*)\n/g, '\n\n'); - //str = str.replace(/\n/g, '
    '); + str = str.replace(/\n(\s*)\n/g, '\n\n'); + //str = str.replace(/\n/g, '
    '); - var len = str.length; - var textStart = 0, idx = 0, open = -1, close = -1, goodTag = true, isClose = false; - var getValue = function(str) - { - var quote, space, value; - if(str.charAt(0) == '"' || str.charAt(0) == "'") - { - quote = str.charAt(0); - var end = str.indexOf(quote, 1); - if(end > -1) - { - value = str.substring(1, end); - str = str.substring(end+1).trim(); - return { value: Markup._safeHtml(value), str: str }; - } - } + var len = str.length; + var textStart = 0, idx = 0, open = -1, close = -1, goodTag = true, isClose = false; + var getValue = function(str) + { + var quote, space, value; + if(str.charAt(0) == '"' || str.charAt(0) == "'") + { + quote = str.charAt(0); + var end = str.indexOf(quote, 1); + if(end > -1) + { + value = str.substring(1, end); + str = str.substring(end+1).trim(); + return { value: Markup._safeHtml(value), str: str }; + } + } - space = str.indexOf(' '); - if(space > -1) - { - value = str.substring(0, space); - str = str.substring(space+1).trim(); - } - else - { - value = str; - str = ''; - } + space = str.indexOf(' '); + if(space > -1) + { + value = str.substring(0, space); + str = str.substring(space+1).trim(); + } + else + { + value = str; + str = ''; + } - return { value: value, str: str }; - }; - var unnamedRe = /^\s*[a-z0-9]+\s*=/; - while(idx < len) - { - open = str.indexOf('[', idx); - if(open > -1) - { - idx = open + 1; - if(open > 0 && str.charAt(open-1) == '\\') - { - goodTag = false; - open = -1; - } - else - { - close = str.indexOf(']',idx); - } - } - else - idx = len; + return { value: value, str: str }; + }; + var unnamedRe = /^\s*[a-z0-9]+\s*=/; + while(idx < len) + { + open = str.indexOf('[', idx); + if(open > -1) + { + idx = open + 1; + if(open > 0 && str.charAt(open-1) == '\\') + { + goodTag = false; + open = -1; + } + else + { + close = str.indexOf(']',idx); + } + } + else + idx = len; - var tagName, attrs = {}; + var tagName, attrs = {}; - if(opts.highlight && $(opts.highlight)) - attrs['data-highlight'] = opts.highlight + ':' + open; + if(opts.highlight && $(opts.highlight)) + attrs['data-highlight'] = opts.highlight + ':' + open; - if(close > -1) - { - var tagContents = str.substring(open+1, close); - if(tagContents.charAt(0) == '/') - { - isClose = true; - tagName = tagContents.substr(1).trim().toLowerCase(); - } + if(close > -1) + { + var tagContents = str.substring(open+1, close); + if(tagContents.charAt(0) == '/') + { + isClose = true; + tagName = tagContents.substr(1).trim().toLowerCase(); + } - if(!isClose) - { - var space = tagContents.indexOf(' '), assign = tagContents.indexOf('='); - var quote; - if((assign < space || space == -1) && assign > -1) - { - tagName = tagContents.substring(0, assign).toLowerCase(); - tagContents = tagContents.substring(assign+1).trim(); - var ret = getValue(tagContents); - tagContents = ret.str; - if(Markup.tags[tagName] == undefined || Markup.tags[tagName].attr == undefined || Markup.tags[tagName].attr.unnamed == undefined) - { - goodTag = false; - } - else - attrs.unnamed = ret.value; - } - else if(space > -1) - { - tagName = tagContents.substring(0, space).toLowerCase(); - tagContents = tagContents.substring(space+1).trim(); - if(tagContents.indexOf('=') == -1) // legacy support, [quote name] - { - if(Markup.tags[tagName] == undefined || Markup.tags[tagName].attr == undefined || Markup.tags[tagName].attr.unnamed == undefined) - { - goodTag = false; - } - else - attrs.unnamed = tagContents; - tagContents = ''; - } - } - else - { - tagName = tagContents.toLowerCase(); - tagContents = ''; - } + if(!isClose) + { + var space = tagContents.indexOf(' '), assign = tagContents.indexOf('='); + var quote; + if((assign < space || space == -1) && assign > -1) + { + tagName = tagContents.substring(0, assign).toLowerCase(); + tagContents = tagContents.substring(assign+1).trim(); + var ret = getValue(tagContents); + tagContents = ret.str; + if(Markup.tags[tagName] == undefined || Markup.tags[tagName].attr == undefined || Markup.tags[tagName].attr.unnamed == undefined) + { + goodTag = false; + } + else + attrs.unnamed = ret.value; + } + else if(space > -1) + { + tagName = tagContents.substring(0, space).toLowerCase(); + tagContents = tagContents.substring(space+1).trim(); + if(tagContents.indexOf('=') == -1) // legacy support, [quote name] + { + if(Markup.tags[tagName] == undefined || Markup.tags[tagName].attr == undefined || Markup.tags[tagName].attr.unnamed == undefined) + { + goodTag = false; + } + else + attrs.unnamed = tagContents; + tagContents = ''; + } + } + else + { + tagName = tagContents.toLowerCase(); + tagContents = ''; + } - if(Markup.tags[tagName] == undefined) - { - goodTag = false; - } - else if(goodTag) - { - var tag = Markup.tags[tagName]; + if(Markup.tags[tagName] == undefined) + { + goodTag = false; + } + else if(goodTag) + { + var tag = Markup.tags[tagName]; - while(tagContents != '') - { - var attr = ''; - if(!unnamedRe.test(tagContents)) - { - attr = 'unnamed'; - } - else - { - assign = tagContents.indexOf('='); - if(assign == -1) - { - goodTag = false; - break; - } + while(tagContents != '') + { + var attr = ''; + if(!unnamedRe.test(tagContents)) + { + attr = 'unnamed'; + } + else + { + assign = tagContents.indexOf('='); + if(assign == -1) + { + goodTag = false; + break; + } - attr = tagContents.substring(0, assign).trim().toLowerCase(); - tagContents = tagContents.substring(assign+1).trim(); - } + attr = tagContents.substring(0, assign).trim().toLowerCase(); + tagContents = tagContents.substring(assign+1).trim(); + } - var ret = getValue(tagContents); - tagContents = ret.str; - if(tag.attr == undefined || tag.attr[attr] == undefined) - { - if(Markup.attributes[attr] == undefined || (Markup.attributes[attr].valid != undefined && !Markup.attributes[attr].valid.test(ret.value))) - { - goodTag = false; - break; - } - } - attrs[attr] = ret.value; - } + var ret = getValue(tagContents); + tagContents = ret.str; + if(tag.attr == undefined || tag.attr[attr] == undefined) + { + if(Markup.attributes[attr] == undefined || (Markup.attributes[attr].valid != undefined && !Markup.attributes[attr].valid.test(ret.value))) + { + goodTag = false; + break; + } + } + attrs[attr] = ret.value; + } - if(goodTag && tag.attr) - { - for(var a in tag.attr) - { - if(tag.attr[a].req && attrs[a] == undefined) - { - goodTag = false; - break; - } - else if(attrs[a] == undefined) - continue; + if(goodTag && tag.attr) + { + for(var a in tag.attr) + { + if(tag.attr[a].req && attrs[a] == undefined) + { + goodTag = false; + break; + } + else if(attrs[a] == undefined) + continue; - if(tag.attr[a].valid != undefined && !tag.attr[a].valid.test(attrs[a])) - { - goodTag = false; - break; - } - } + if(tag.attr[a].valid != undefined && !tag.attr[a].valid.test(attrs[a])) + { + goodTag = false; + break; + } + } - if(goodTag && tag.validate != undefined) { - goodTag = tag.validate(attrs); - } - } - } - } - else if(Markup.tags[tagName] == undefined) - goodTag = false; - } - else - goodTag = false; + if(goodTag && tag.validate != undefined) { + goodTag = tag.validate(attrs); + } + } + } + } + else if(Markup.tags[tagName] == undefined) + goodTag = false; + } + else + goodTag = false; - if(goodTag) - { - if(textStart != open) - { - var s = str.substring(textStart, open).replace(/\\\[/g, '['); - var text = { _rawText: s }; - tree.openTag('', text); - } - if(isClose) - goodTag = tree.closeTag(tagName); - else - goodTag = tree.openTag(tagName, attrs); + if(goodTag) + { + if(textStart != open) + { + var s = str.substring(textStart, open).replace(/\\\[/g, '['); + var text = { _rawText: s }; + tree.openTag('', text); + } + if(isClose) + goodTag = tree.closeTag(tagName); + else + goodTag = tree.openTag(tagName, attrs); - if(goodTag) - textStart = idx = close + 1; - else - textStart = open; - } - goodTag = true; - isClose = false; - open = close = -1; - } + if(goodTag) + textStart = idx = close + 1; + else + textStart = open; + } + goodTag = true; + isClose = false; + open = close = -1; + } - if(textStart < len) - { - var s = str.substr(textStart).replace(/\\\[/g, '['); - var text = { _rawText: s }; - tree.openTag('', text); - } + if(textStart < len) + { + var s = str.substr(textStart).replace(/\\\[/g, '['); + var text = { _rawText: s }; + tree.openTag('', text); + } - return tree; - }, + return tree; + }, - createMaps: function() - { - for(var i = 0; i < Markup.maps.length; ++i) - { - var m = Markup.maps[i]; - new Mapper({parent: m[0], zone: m[1], coords: m[2], unique: i}); - } - Markup.maps = []; - }, + createMaps: function() + { + for(var i = 0; i < Markup.maps.length; ++i) + { + var m = Markup.maps[i]; + new Mapper({parent: m[0], zone: m[1], coords: m[2], unique: i}); + } + Markup.maps = []; + }, - toHtml: function(str, opts) - { - if(!opts) - opts = {}; - if(!opts.allow) - { - if(opts.roles) - opts.allow = Markup.rolesToClass(opts.roles); - else - opts.allow = Markup.CLASS_STAFF; - } + toHtml: function(str, opts) + { + if(!opts) + opts = {}; + if(!opts.allow) + { + if(opts.roles) + opts.allow = Markup.rolesToClass(opts.roles); + else + opts.allow = Markup.CLASS_STAFF; + } - var tree = Markup._parse(str, opts); - var html = tree.toHtml(); - if(opts.prepend) - html = opts.prepend + html; - if(opts.append) - html += opts['append']; - setTimeout(Markup.createMaps, 250); - return html; - }, + var tree = Markup._parse(str, opts); + var html = tree.toHtml(); + if(opts.prepend) + html = opts.prepend + html; + if(opts.append) + html += opts['append']; + setTimeout(Markup.createMaps, 250); + return html; + }, - fromHtml: function(str, depth) - { - // Clean up the html source - str = str.replace(/\n+/g, ''); - str = str.replace(/\s+/g, ' '); - str = str.replace(/> <'); - //str = str.replace(/ <'); + //str = str.replace(/[\s\S]*?<\/style>/g, ''); - str = str.replace(/<\/?[a-z][a-z0-9]*\b[\s\S]*?>/g, ' '); - str = str.replace(//g, ''); - str = str.replace(/\n[\n]+/g, "\n\n"); - str = str.replace(/[ ]+/g, ' '); - str = str.replace(/\t/g, ' '); + // Strip remaining html + str = str.replace(/[\s\S]*?<\/style>/g, ''); + str = str.replace(/<\/?[a-z][a-z0-9]*\b[\s\S]*?>/g, ' '); + str = str.replace(//g, ''); + str = str.replace(/\n[\n]+/g, "\n\n"); + str = str.replace(/[ ]+/g, ' '); + str = str.replace(/\t/g, ' '); - return $WH.trim(str); - }, + return $WH.trim(str); + }, - removeTags: function(str, opts) - { - var tree = Markup._parse(str, opts); - return tree.tagless(); - }, + removeTags: function(str, opts) + { + var tree = Markup._parse(str, opts); + return tree.tagless(); + }, - matchOuterTags: function(str, left, right, flags) - { - var g = flags.indexOf('g') > -1, - f = flags.replace(/g/g, ''), - x = new RegExp(left + '|' + right, 'g' + f), // Open or close tag - l = new RegExp(left, f), // Open tag only - a = [], - t, s, m, n; + matchOuterTags: function(str, left, right, flags) + { + var g = flags.indexOf('g') > -1, + f = flags.replace(/g/g, ''), + x = new RegExp(left + '|' + right, 'g' + f), // Open or close tag + l = new RegExp(left, f), // Open tag only + a = [], + t, s, m, n; - do - { - t = 0; - while(m = x.exec(str)) - { - if(l.test(m[0])) - { - if (!t++) - { - s = x.lastIndex; - n = m; - } - } - else if (t) - { - if(!--t) - { - a.push([str.slice(s, m.index), n[0], m[0]]); - if (!g) return a; - } - } - } - } while(t && (x.lastIndex = s)); + do + { + t = 0; + while(m = x.exec(str)) + { + if(l.test(m[0])) + { + if (!t++) + { + s = x.lastIndex; + n = m; + } + } + else if (t) + { + if(!--t) + { + a.push([str.slice(s, m.index), n[0], m[0]]); + if (!g) return a; + } + } + } + } while(t && (x.lastIndex = s)); - return (a.length ? a : false); - }, + return (a.length ? a : false); + }, - getImageUploadIds: function(str, opts) - { - var tree = Markup._parse(str, opts); - return tree.imageUploadIds(); - }, + getImageUploadIds: function(str, opts) + { + var tree = Markup._parse(str, opts); + return tree.imageUploadIds(); + }, - printHtml: function(str, div, opts) - { - div = $WH.ge(div); - var html = Markup.toHtml(str, opts); - div.innerHTML = html; - Markup.createMaps(); - }, + printHtml: function(str, div, opts) + { + div = $WH.ge(div); + var html = Markup.toHtml(str, opts); + div.innerHTML = html; + Markup.createMaps(); + }, - toggleReveal: function(id) - { - var span = $('#reveal-' + id); - if(span.length == 0) - return; + toggleReveal: function(id) + { + var span = $('#reveal-' + id); + if(span.length == 0) + return; - var toggle = $('#revealtoggle-' + id); + var toggle = $('#revealtoggle-' + id); - if(span.is(':visible')) - { - span.hide(); - toggle.text('(read more)'); - } - else - { - span.show(); - toggle.text('(hide)'); - } - }, + if(span.is(':visible')) + { + span.hide(); + toggle.text('(read more)'); + } + else + { + span.show(); + toggle.text('(hide)'); + } + }, - mapperPreview: function(id) - { - try { - window.mapper = Markup.maps[id]; - var win = window.open('?edit=mapper-preview', 'mapperpreview', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=800,height=540'); - win.focus(); - } catch(e) {} - }, + mapperPreview: function(id) + { + try { + window.mapper = Markup.maps[id]; + var win = window.open('?edit=mapper-preview', 'mapperpreview', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=800,height=540'); + win.focus(); + } catch(e) {} + }, - createTabs: function(parent, tabs, preview) - { - var _ = new Tabs({parent: $WH.ge('dsf67g4d-' + parent.id + (preview ? '-preview' : '')), forum:1, noScroll: (preview ? true : false)}); - for(var i = 0; i < tabs.length; ++i) - { - var tab = tabs[i]; - _.add(tab.name, {id:parent.id + '-' + tab.id, icon: tab.icon, 'class': tab['class']}); - } - _.flush(); - } + createTabs: function(parent, tabs, preview) + { + var _ = new Tabs({parent: $WH.ge('dsf67g4d-' + parent.id + (preview ? '-preview' : '')), forum:1, noScroll: (preview ? true : false)}); + for(var i = 0; i < tabs.length; ++i) + { + var tab = tabs[i]; + _.add(tab.name, {id:parent.id + '-' + tab.id, icon: tab.icon, 'class': tab['class']}); + } + _.flush(); + } }; var MarkupUtil = { - ltrimText: function(attr) - { - attr._rawText = attr._rawText.ltrim(); - return attr; - }, - rtrimText: function(attr) - { - attr._rawText = attr._rawText.rtrim(); - return attr; - }, + ltrimText: function(attr) + { + attr._rawText = attr._rawText.ltrim(); + return attr; + }, + rtrimText: function(attr) + { + attr._rawText = attr._rawText.rtrim(); + return attr; + }, - checkSiblingTrim: function(lastNode, node) - { - if(node.name == '' && (Markup.tags[lastNode.name].rtrim || Markup.tags[lastNode.name].trim)) - node.attr = MarkupUtil.ltrimText(node.attr); - else if(lastNode.name == '' && (Markup.tags[node.name].ltrim || Markup.tags[node.name].trim)) - lastNode.attr = MarkupUtil.rtrimText(lastNode.attr); - return [lastNode, node]; - } + checkSiblingTrim: function(lastNode, node) + { + if(node.name == '' && (Markup.tags[lastNode.name].rtrim || Markup.tags[lastNode.name].trim)) + node.attr = MarkupUtil.ltrimText(node.attr); + else if(lastNode.name == '' && (Markup.tags[node.name].ltrim || Markup.tags[node.name].trim)) + lastNode.attr = MarkupUtil.rtrimText(lastNode.attr); + return [lastNode, node]; + } }; var MarkupTree = function() { - this.nodes = []; - this.currentNode = null; + this.nodes = []; + this.currentNode = null; }; MarkupTree.prototype = { - openTag: function(tag, attrs) - { - // Allowed class defaults to pending users - if(tag != '' && Markup.tags[tag] && !Markup.tags[tag].allowedClass) - Markup.tags[tag].allowedClass = MARKUP_CLASS_PENDING; + openTag: function(tag, attrs) + { + // Allowed class defaults to pending users + if(tag != '' && Markup.tags[tag] && !Markup.tags[tag].allowedClass) + Markup.tags[tag].allowedClass = MARKUP_CLASS_PENDING; - if(!Markup.tags[tag]) - { - //document.write('bad tag name: "' + tag + '"
    '); - return false; - } - else if(Markup.tags[tag].allowedModes && Markup.tags[tag].allowedModes[MarkupModeMap[Markup.mode]] == undefined) - { - return false; // tag not allowed in this mode - } - else if(Markup.tags[tag].allowedClass && Markup.tags[tag].allowedClass > Markup.allow) - { - return false; // tag requires a higher user class - } + if(!Markup.tags[tag]) + { + //document.write('bad tag name: "' + tag + '"
    '); + return false; + } + else if(Markup.tags[tag].allowedModes && Markup.tags[tag].allowedModes[MarkupModeMap[Markup.mode]] == undefined) + { + return false; // tag not allowed in this mode + } + else if(Markup.tags[tag].allowedClass && Markup.tags[tag].allowedClass > Markup.allow) + { + return false; // tag requires a higher user class + } - if(Markup.mode == MARKUP_MODE_REPLY && !Markup.tags[tag].allowInReplies) - return false; // Not allowed in comment replies + if(Markup.mode == MARKUP_MODE_REPLY && !Markup.tags[tag].allowInReplies) + return false; // Not allowed in comment replies - var node = { name: tag, attr: attrs, parent: null, nodes: [] }; - if(this.currentNode) - node.parent = this.currentNode; + var node = { name: tag, attr: attrs, parent: null, nodes: [] }; + if(this.currentNode) + node.parent = this.currentNode; - if(Markup.tags[tag].allowedParents) - { - if(node.parent != null) - { - if(Markup.tags[tag].allowedParents[node.parent.name] === undefined) - return false; - } - else if(Markup.root == undefined || Markup.tags[tag].allowedParents[Markup.root] == undefined) - return false; - } - if(node.parent && Markup.tags[node.parent.name].allowedChildren && Markup.tags[node.parent.name].allowedChildren[tag] == undefined) - return false; + if(Markup.tags[tag].allowedParents) + { + if(node.parent != null) + { + if(Markup.tags[tag].allowedParents[node.parent.name] === undefined) + return false; + } + else if(Markup.root == undefined || Markup.tags[tag].allowedParents[Markup.root] == undefined) + return false; + } + if(node.parent && Markup.tags[node.parent.name].allowedChildren && Markup.tags[node.parent.name].allowedChildren[tag] == undefined) + return false; - if(this.currentNode) - { - if(this.currentNode.nodes.length == 0 && node.name == '' && Markup.tags[this.currentNode.name].itrim) - node.attr = MarkupUtil.ltrimText(node.attr); - else if(this.currentNode.nodes.length > 0) - { - var lastNodeIndex = this.currentNode.nodes.length-1; - var result = MarkupUtil.checkSiblingTrim(this.currentNode.nodes[lastNodeIndex], node); - this.currentNode.nodes[lastNodeIndex] = result[0]; - node = result[1]; - } + if(this.currentNode) + { + if(this.currentNode.nodes.length == 0 && node.name == '' && Markup.tags[this.currentNode.name].itrim) + node.attr = MarkupUtil.ltrimText(node.attr); + else if(this.currentNode.nodes.length > 0) + { + var lastNodeIndex = this.currentNode.nodes.length-1; + var result = MarkupUtil.checkSiblingTrim(this.currentNode.nodes[lastNodeIndex], node); + this.currentNode.nodes[lastNodeIndex] = result[0]; + node = result[1]; + } - if(node.name == '') - { - node.attr._text = Markup._preText(node.attr._rawText); - if(node.attr._text.length > 0) - this.currentNode.nodes.push(node); - } - else - this.currentNode.nodes.push(node); - } - else - { - if(this.nodes.length > 0) - { - var lastNodeIndex = this.nodes.length-1; - var result = MarkupUtil.checkSiblingTrim(this.nodes[lastNodeIndex], node); - this.nodes[lastNodeIndex] = result[0]; - node = result[1]; - } + if(node.name == '') + { + node.attr._text = Markup._preText(node.attr._rawText); + if(node.attr._text.length > 0) + this.currentNode.nodes.push(node); + } + else + this.currentNode.nodes.push(node); + } + else + { + if(this.nodes.length > 0) + { + var lastNodeIndex = this.nodes.length-1; + var result = MarkupUtil.checkSiblingTrim(this.nodes[lastNodeIndex], node); + this.nodes[lastNodeIndex] = result[0]; + node = result[1]; + } - if(node.name == '') - { - node.attr._text = Markup._preText(node.attr._rawText); - if(node.attr._text.length > 0) - this.nodes.push(node); - } - else - this.nodes.push(node); - } + if(node.name == '') + { + node.attr._text = Markup._preText(node.attr._rawText); + if(node.attr._text.length > 0) + this.nodes.push(node); + } + else + this.nodes.push(node); + } - if(!Markup.tags[tag].empty && !Markup.tags[tag].post) - this.currentNode = node; + if(!Markup.tags[tag].empty && !Markup.tags[tag].post) + this.currentNode = node; - return true; - }, + return true; + }, - closeTag: function(tag) - { - if(Markup.tags[tag].empty || Markup.tags[tag].post) // empty tag means no close tag - return false; - if(!this.currentNode) // no tag open, so how are we closing one? - return false; - else if(this.currentNode.name == tag) // valid close - { - if(this.currentNode.nodes.length > 0) - { - var lastNodeIndex = this.currentNode.nodes.length-1; - if(Markup.tags[this.currentNode.name].itrim && this.currentNode.nodes[lastNodeIndex].name == '') - { - var node = this.currentNode.nodes[lastNodeIndex]; - node.attr = MarkupUtil.rtrimText(node.attr); - node.attr._text = Markup._preText(node.attr._rawText); - this.currentNode.nodes[lastNodeIndex] = node; - } - } + closeTag: function(tag) + { + if(Markup.tags[tag].empty || Markup.tags[tag].post) // empty tag means no close tag + return false; + if(!this.currentNode) // no tag open, so how are we closing one? + return false; + else if(this.currentNode.name == tag) // valid close + { + if(this.currentNode.nodes.length > 0) + { + var lastNodeIndex = this.currentNode.nodes.length-1; + if(Markup.tags[this.currentNode.name].itrim && this.currentNode.nodes[lastNodeIndex].name == '') + { + var node = this.currentNode.nodes[lastNodeIndex]; + node.attr = MarkupUtil.rtrimText(node.attr); + node.attr._text = Markup._preText(node.attr._rawText); + this.currentNode.nodes[lastNodeIndex] = node; + } + } - this.currentNode = this.currentNode.parent; - } - else - { // a tag was closed, but doesnt match the current open tag, so probably invalid nesting. attempt to find the matching tag, then fail if we cant - var findLastNode = function(name, nodes) - { - for(var i = nodes.length-1; i >= 0; --i) - { - if(nodes[i].name == name) - return i; - } - return -1; - }; - var idx; - if(this.currentNode.parent) - idx = findLastNode(tag, this.currentNode.parent.nodes); - else - idx = findLastNode(tag, this.nodes); + this.currentNode = this.currentNode.parent; + } + else + { // a tag was closed, but doesnt match the current open tag, so probably invalid nesting. attempt to find the matching tag, then fail if we cant + var findLastNode = function(name, nodes) + { + for(var i = nodes.length-1; i >= 0; --i) + { + if(nodes[i].name == name) + return i; + } + return -1; + }; + var idx; + if(this.currentNode.parent) + idx = findLastNode(tag, this.currentNode.parent.nodes); + else + idx = findLastNode(tag, this.nodes); - if(idx == -1) // no matching tag - return false; - } + if(idx == -1) // no matching tag + return false; + } - return true; - }, + return true; + }, - toHtml: function() - { - var postNodes = []; + toHtml: function() + { + var postNodes = []; - var collection = {}; - for(var x in Markup.collectTags) - collection[x] = []; - this.tagless(true); - var currentOffset = 0; - var processNodes = function(nodes, depth, exclusions) - { - var str = ''; - for(var i = 0; i < nodes.length; ++i) - { - var node = nodes[i]; + var collection = {}; + for(var x in Markup.collectTags) + collection[x] = []; + this.tagless(true); + var currentOffset = 0; + var processNodes = function(nodes, depth, exclusions) + { + var str = ''; + for(var i = 0; i < nodes.length; ++i) + { + var node = nodes[i]; - if(depth == 0 && i == 0 && Markup.firstTags[node.name]) // first in text - node.attr.first = true; - else if(depth > 0 && i == 0 && Markup.firstTags[node.parent.name]) // first in block - node.attr.first = true; - if(i == nodes.length-1 && Markup.firstTags[node.name]) // last thing, block - node.attr.last = true; + if(depth == 0 && i == 0 && Markup.firstTags[node.name]) // first in text + node.attr.first = true; + else if(depth > 0 && i == 0 && Markup.firstTags[node.parent.name]) // first in block + node.attr.first = true; + if(i == nodes.length-1 && Markup.firstTags[node.name]) // last thing, block + node.attr.last = true; - if(Markup.excludeTags[node.name]) - exclusions[node.name] = (exclusions[node.name] ? exclusions[node.name] + 1 : 1); - for(var ex in exclusions) - { - for(var t in Markup.excludeTags[ex]) - { - if(Markup.excludeTags[ex][t][node.name]) - node.attr[t] = false; - } - } + if(Markup.excludeTags[node.name]) + exclusions[node.name] = (exclusions[node.name] ? exclusions[node.name] + 1 : 1); + for(var ex in exclusions) + { + for(var t in Markup.excludeTags[ex]) + { + if(Markup.excludeTags[ex][t][node.name]) + node.attr[t] = false; + } + } - if(Markup.collectTags[node.name]) - { - node.offset = currentOffset++; - collection[node.name].push(node); - } - if(Markup.tags[node.name].post) - { - var comment = ''; - str += comment; - postNodes.push([node, comment]); - } - else if(Markup.tags[node.name].empty) - { - var html; - if(node.parent && Markup.tags[node.parent.name].rawText) - html = Markup.tags[node.name].toHtml(node.attr, { needsRaw: true }); - else - html = Markup.tags[node.name].toHtml(node.attr); - if(typeof html == 'string') - str += html; - else if(html !== undefined) - { - if(str == '') - str = []; - str.push(html); - } - } - else - { - var contents = arguments.callee(node.nodes, depth+1, exclusions); - node.attr._contents = contents; - node.attr._nodes = node.nodes; - var tags = Markup.tags[node.name].toHtml(node.attr); - if(tags.length == 2) - str += tags[0] + contents + tags[1]; - else if(tags.length == 1) - { - if(typeof tags[0] == 'string') - str += tags[0]; - else - { - if(str == '') - str = []; - str.push(tags[0]); - } - } - } + if(Markup.collectTags[node.name]) + { + node.offset = currentOffset++; + collection[node.name].push(node); + } + if(Markup.tags[node.name].post) + { + var comment = ''; + str += comment; + postNodes.push([node, comment]); + } + else if(Markup.tags[node.name].empty) + { + var html; + if(node.parent && Markup.tags[node.parent.name].rawText) + html = Markup.tags[node.name].toHtml(node.attr, { needsRaw: true }); + else + html = Markup.tags[node.name].toHtml(node.attr); + if(typeof html == 'string') + str += html; + else if(html !== undefined) + { + if(str == '') + str = []; + str.push(html); + } + } + else + { + var contents = arguments.callee(node.nodes, depth+1, exclusions); + node.attr._contents = contents; + node.attr._nodes = node.nodes; + var tags = Markup.tags[node.name].toHtml(node.attr); + if(tags.length == 2) + str += tags[0] + contents + tags[1]; + else if(tags.length == 1) + { + if(typeof tags[0] == 'string') + str += tags[0]; + else + { + if(str == '') + str = []; + str.push(tags[0]); + } + } + } - if(exclusions[node.name]) - { - exclusions[node.name]--; - if(exclusions[node.name] == 0) - delete exclusions[node.name]; - } - } - return str; - }; - str = processNodes(this.nodes, 0, []); - for(var i = 0; i < postNodes.length; ++i) - { - var node = postNodes[i][0]; - var replace = postNodes[i][1]; - var html = Markup.tags[node.name].postHtml(node.attr, collection); - if(typeof html == 'string') - str = str.replace(replace, html); - } + if(exclusions[node.name]) + { + exclusions[node.name]--; + if(exclusions[node.name] == 0) + delete exclusions[node.name]; + } + } + return str; + }; + str = processNodes(this.nodes, 0, []); + for(var i = 0; i < postNodes.length; ++i) + { + var node = postNodes[i][0]; + var replace = postNodes[i][1]; + var html = Markup.tags[node.name].postHtml(node.attr, collection); + if(typeof html == 'string') + str = str.replace(replace, html); + } - return str; - }, + return str; + }, - tagless: function(n) - { - var processNodes = function(nodes) - { - var str = ''; - for(var i = 0; i < nodes.length; ++i) - { - var node = nodes[i]; - var contents = arguments.callee(node.nodes); - if(n) { - node.attr._textContents = contents; - } else - { - node.attr._contents = contents; - } - if(node.name == '') - str += Markup.tags[node.name].toHtml(node.attr, { noLink: true, noNbsp: true }); - else if(Markup.tags[node.name].toText) - str += Markup.tags[node.name].toText(node.attr); - if(!Markup.tags[node.name].taglessSkip) - str += contents; - } - return str; - }; - if(n) - processNodes(this.nodes); - else { - var str = processNodes(this.nodes); - str = str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); - return str; - } - }, + tagless: function(n) + { + var processNodes = function(nodes) + { + var str = ''; + for(var i = 0; i < nodes.length; ++i) + { + var node = nodes[i]; + var contents = arguments.callee(node.nodes); + if(n) { + node.attr._textContents = contents; + } else + { + node.attr._contents = contents; + } + if(node.name == '') + str += Markup.tags[node.name].toHtml(node.attr, { noLink: true, noNbsp: true }); + else if(Markup.tags[node.name].toText) + str += Markup.tags[node.name].toText(node.attr); + if(!Markup.tags[node.name].taglessSkip) + str += contents; + } + return str; + }; + if(n) + processNodes(this.nodes); + else { + var str = processNodes(this.nodes); + str = str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); + return str; + } + }, - imageUploadIds: function() - { - var ids = []; + imageUploadIds: function() + { + var ids = []; - var processNodes = function(nodes) - { - for(var i = 0; i < nodes.length; ++i) - { - var node = nodes[i]; - if(node.name == 'img' && node.attr.upload) - ids.push(node.attr.upload); + var processNodes = function(nodes) + { + for(var i = 0; i < nodes.length; ++i) + { + var node = nodes[i]; + if(node.name == 'img' && node.attr.upload) + ids.push(node.attr.upload); - arguments.callee(node.nodes); - } - }; - processNodes(this.nodes); - return ids; - } + arguments.callee(node.nodes); + } + }; + processNodes(this.nodes); + return ids; + } }; Markup.tags.modelviewer = Markup.tags.model; // Backwards compatability @@ -4128,54 +4128,54 @@ Markup.reveals = 0; Markup._init(); $(document).ready(function() { - $('.quote-header').each(function(i) { - var $this = $(this); - var sibs = $this.siblings(); - if(sibs.hasClass('quote-body')) - { - var a = $('', { href: 'javascript:;', 'class': 'toggle' }); + $('.quote-header').each(function(i) { + var $this = $(this); + var sibs = $this.siblings(); + if(sibs.hasClass('quote-body')) + { + var a = $('', { href: 'javascript:;', 'class': 'toggle' }); - a.click(function(header) { - var $head = $(header); - var parent = $head.parent(); + a.click(function(header) { + var $head = $(header); + var parent = $head.parent(); - parent.toggleClass('collapse'); + parent.toggleClass('collapse'); - if(parent.hasClass('collapse')) - $(this).html('Expand'); - else - $(this).html('Collapse'); - }.bind(a, this)); + if(parent.hasClass('collapse')) + $(this).html('Expand'); + else + $(this).html('Collapse'); + }.bind(a, this)); - if($(this).parent().hasClass('collapse')) - a.html('Expand'); - else - a.html('Collapse'); + if($(this).parent().hasClass('collapse')) + a.html('Expand'); + else + a.html('Collapse'); - $this.append(a); - } - }); + $this.append(a); + } + }); - $('.quote-wh').each(function(i) { - var $this = $(this); - var a = $('', { href: 'javascript:;', 'class': 'toggle' }); + $('.quote-wh').each(function(i) { + var $this = $(this); + var a = $('', { href: 'javascript:;', 'class': 'toggle' }); - a.click(function(thisObj) { - var $this = $(thisObj); + a.click(function(thisObj) { + var $this = $(thisObj); - $this.toggleClass('collapse'); + $this.toggleClass('collapse'); - if($this.hasClass('collapse')) - $(this).html('Expand'); - else - $(this).html('Collapse'); - }.bind(a, this)); + if($this.hasClass('collapse')) + $(this).html('Expand'); + else + $(this).html('Collapse'); + }.bind(a, this)); - if($(this).hasClass('collapse')) - a.html('Expand'); - else - a.html('Collapse'); + if($(this).hasClass('collapse')) + a.html('Expand'); + else + a.html('Collapse'); - $this.append(a); - }); + $this.append(a); + }); }); diff --git a/static/js/Profiler.js b/static/js/Profiler.js index dc77e711..2db735e1 100644 --- a/static/js/Profiler.js +++ b/static/js/Profiler.js @@ -981,12 +981,10 @@ function Profiler() { // Breadcrumb if (_isArmoryProfile(_profile.genuine)) { - // PageTemplate.set({ breadcrumb: [1, 5, 0, _profile.region[0], _profile.battlegroup[0], _profile.realm[0]] }); - g_initPath([1, 5, 0, _profile.region[0], _profile.battlegroup[0], _profile.realm[0]]); + PageTemplate.set({ breadcrumb: [1, 5, 0, _profile.region[0], _profile.battlegroup[0], _profile.realm[0]] }); } else { - // PageTemplate.set({ breadcrumb: [1, 5, 1] }); - g_initPath([1, 5, 1]); + PageTemplate.set({ breadcrumb: [1, 5, 1] }); } // ************************ @@ -7455,7 +7453,7 @@ function ProfilerCompletion(_parent) { } if (_opt.onDemand && !_loading && !_loaded) { - $WH.g_ajaxIshRequest(g_host + '?data=' + _opt.onDemand + (_opt.dataArgs ? _opt.dataArgs(_profile) : '') + '&locale=' + g_locale.id + '&t=' + g_dataKey + '&callback=$WowheadProfiler.loadOnDemand&' + (new Date().getTime())); + $WH.g_ajaxIshRequest(g_host + '?data=' + _opt.onDemand + (_opt.dataArgs ? _opt.dataArgs(_profile) : '') + '&locale=' + Locale.getId() + '&t=' + g_dataKey + '&callback=$WowheadProfiler.loadOnDemand&' + (new Date().getTime())); _imgLoading.style.display = 'block'; _divTipQuests.style.display = 'none'; _loading = this; @@ -8382,7 +8380,7 @@ function ProfilerCompletion(_parent) { if (_category !== null) { if (_opt.onDemand && _opt.partial && !_loaded[_category] && !_loading) { - $WH.g_ajaxIshRequest(g_host + '?data=' + _opt.onDemand + '&locale=' + g_locale.id + '&catg=' + _category + '&t=' + g_dataKey + '&callback=$WowheadProfiler.loadOnDemand&' + (new Date().getTime())); + $WH.g_ajaxIshRequest(g_host + '?data=' + _opt.onDemand + '&locale=' + Locale.getId() + '&catg=' + _category + '&t=' + g_dataKey + '&callback=$WowheadProfiler.loadOnDemand&' + (new Date().getTime())); _imgLoading.style.display = 'block'; _divTipQuests.style.display = 'none'; _loading = this; diff --git a/static/js/Summary.js b/static/js/Summary.js index a12564de..42e462f3 100644 --- a/static/js/Summary.js +++ b/static/js/Summary.js @@ -3245,7 +3245,7 @@ Summary.prototype = { for (var i = 0, len = a[1].length; i < len; ++i) { var row = {}; row.id = a[1][i].id; - row.name = row['name_' + g_locale.name] = a[1][i].name.substring(1); + row.name = row['name_' + Locale.getName()] = a[1][i].name.substring(1); row.quality = 7 - a[1][i].name.charAt(0); row.icon = a[1][i].icon; row.level = a[1][i].level; @@ -3266,7 +3266,7 @@ Summary.prototype = { for (var i = 0, len = a[2].length; i < len; ++i) { var row = {}; row.id = a[2][i].id; - row.name = row['name_' + g_locale.name] = a[2][i].name.substring(1); + row.name = row['name_' + Locale.getName()] = a[2][i].name.substring(1); row.quality = 7 - a[2][i].name.charAt(0); row.minlevel = a[2][i].minlevel; row.maxlevel = a[2][i].maxlevel; @@ -3687,7 +3687,7 @@ Summary.groupOver = function(group, e) { buff += ''; buff += 'x' + count[itemId] + ''; buff += '
    '; - buff += '' + g_items[itemId]['name_' + g_locale.name] + ''; + buff += '' + g_items[itemId]['name_' + Locale.getName()] + ''; buff += '
    '; buff += '
    ' + LANG.level + ' ' + g_items[itemId].jsonequip.level + '
    '; buff += ''; @@ -4660,7 +4660,7 @@ Listview.templates.subitempicker = { a.href = url; a.rel = 'rand=' + subitem.id; - $WH.ae(a, $WH.ct(item['name_' + g_locale.name] + ' ' + subitem.name)); + $WH.ae(a, $WH.ct(item['name_' + Locale.getName()] + ' ' + subitem.name)); $WH.nw(td); $WH.ae(td, a); diff --git a/static/js/TalentCalc.js b/static/js/TalentCalc.js index eb0fc204..a6e145e3 100644 --- a/static/js/TalentCalc.js +++ b/static/js/TalentCalc.js @@ -2243,7 +2243,7 @@ function TalentCalc() { c.div.style.display = ""; } else { - $WH.g_ajaxIshRequest('?data=talents&class=' + classId + '&locale=' + g_locale.id + '&t=' + g_dataKey + '&' + _versionBuild); + $WH.g_ajaxIshRequest('?data=talents&class=' + classId + '&locale=' + Locale.getId() + '&t=' + g_dataKey + '&' + _versionBuild); } } @@ -2529,7 +2529,7 @@ function TalentCalc() { function _simplifyGlyphName(name) { var str; - switch (g_locale.id) { + switch (Locale.getId()) { case 0: str = name.replace(/^Glyph of (the )?/i, ''); break; diff --git a/static/js/basic.js b/static/js/basic.js index 99717db3..58a85400 100644 --- a/static/js/basic.js +++ b/static/js/basic.js @@ -1328,8 +1328,8 @@ $WH.g_setTooltipLevel = function(tooltip, level) { if (_ == 'number') { var arr = $WH.g_getDataSource(); - if (arr[tooltip] && arr[tooltip][(buff ? 'buff_' : 'tooltip_') + g_locale.name]) { - tooltip = arr[tooltip][(buff ? 'buff_' : 'tooltip_') + g_locale.name]; + if (arr[tooltip] && arr[tooltip][(buff ? 'buff_' : 'tooltip_') + Locale.getName()]) { + tooltip = arr[tooltip][(buff ? 'buff_' : 'tooltip_') + Locale.getName()]; } else { return tooltip; // Error @@ -1528,9 +1528,9 @@ $WH.g_enhanceTooltip = function(tooltip, isStatic, useGets, showSlider, buff, kn arr = $WH.g_getDataSource(), id = tooltip; - if (arr[id] && arr[id][(buff ? 'buff_' : 'tooltip_') + g_locale.name]) { - tooltip = arr[id][(buff ? 'buff_' : 'tooltip_') + g_locale.name]; - spellJson = arr[id][(buff ? 'buff' : '') + 'spells_' + g_locale.name]; + if (arr[id] && arr[id][(buff ? 'buff_' : 'tooltip_') + Locale.getName()]) { + tooltip = arr[id][(buff ? 'buff_' : 'tooltip_') + Locale.getName()]; + spellJson = arr[id][(buff ? 'buff' : '') + 'spells_' + Locale.getName()]; if (spellJson) { tooltip = $WH.g_setTooltipSpells(tooltip, knownSpells, spellJson); @@ -1595,7 +1595,7 @@ $WH.g_enhanceTooltip = function(tooltip, isStatic, useGets, showSlider, buff, kn $(chooseSpells) .append('') - .append('
    ' + g_spells[i]['name_' + g_locale.name] + (g_spells[i]['rank_' + g_locale.name] ? ' (' + g_spells[i]['rank_' + g_locale.name] + ')' : '') + '') + .append('') .append('
    '); $('#known-' + i).change($WH.g_tooltipSpellsChange.bind(this)); @@ -1646,7 +1646,7 @@ $WH.g_staticTooltipLevelClick = function (div, level, noSlider, buff) { } var arr = $WH.g_getDataSource(); - _ = $WH.g_setTooltipLevel(arr[itemId][(buff ? 'buff_' : 'tooltip_') + g_locale.name], level, buff); + _ = $WH.g_setTooltipLevel(arr[itemId][(buff ? 'buff_' : 'tooltip_') + Locale.getName()], level, buff); _ = $WH.g_enhanceTooltip(_, true); div.innerHTML = '
    ' + _ + '
    '; diff --git a/static/js/filters.js b/static/js/filters.js index f7248759..b0444f96 100644 --- a/static/js/filters.js +++ b/static/js/filters.js @@ -522,6 +522,12 @@ function fi_reset(_this) { fi_resetCriterion($WH.ge('fi_criteria')); fi_resetCriterion($WH.ge('fi_weight')); + // custom start (originally a click on reset would reload the page with empty filters) + var bc = PageTemplate.get('breadcrumb'); + if (typeof bc[1] !== 'undefined') + Menu.modifyUrl(Menu.findItem(mn_database, [bc[1]]), {}, {}); + // custom end + var _ = $WH.ge('sdkgnsdkn436'); if (_) { _.parentNode.style.display = 'none'; @@ -1467,11 +1473,12 @@ function fi_dropdownSync(_this) { function fi_init(type) { fi_type = type; - var s = $WH.ge('fi_subcat'); - if (g_initPath.lastIt && g_initPath.lastIt[3]) { - if (s) { - Menu.add(s, g_initPath.lastIt[3]); - } + var + s = $WH.ge('fi_subcat'), + m = Menu.findItem(mn_path, PageTemplate.get('breadcrumb')); + + if (s && m[3]) { + Menu.add(s, m[3]); } else if (s) { $WH.de(s.parentNode); @@ -1846,7 +1853,7 @@ function fi_filterParamToJson(filters) { if(filters) { var parts = filters.split(';'); - $WH.array_walk(parts, function(part){ + $.each(parts, function(idx, part) { $WH.g_splitQueryParam(part, result); }); } @@ -1859,7 +1866,7 @@ function fi_filterJsonToParam(json) { var i = 0; - $WH.array_walk(json, function(value, _, __, name) { + $.each(json, function(name, value) { if (value !== '') { if (i++ > 0) { result += ';'; diff --git a/static/js/global.js b/static/js/global.js index f9e22272..3ab79e3c 100644 --- a/static/js/global.js +++ b/static/js/global.js @@ -330,326 +330,630 @@ function g_urlize(str, allowLocales, profile) { return str; } -function g_createHeader(c) { - var k = $WH.ce("dl"), - p = (c == 5); - for (var j = 0, l = mn_path.length; j < l; ++j) { - var f = $WH.ce("dt"); - var q = $WH.ce("a"); - var m = $WH.ce("ins"); - var g = $WH.ce("big"); - var e = $WH.ce("span"); - var o = mn_path[j][0]; - var h = (o == c); - var d = (!h && mn_path[j][3]); - if (p && o == 5) { - d = true; - mn_path[j][3] = mn_profiles - } - if (d) { - Menu.add(q, mn_path[j][3]); - } else { - q.onmouseover = Menu._hide - } - if (mn_path[j][2]) { - q.href = mn_path[j][2] - } else { - q.href = "javascript:;"; - $WH.ns(q); - q.style.cursor = "default" - } - if (h) { - q.className = "selected" - } - $WH.ae(g, $WH.ct(mn_path[j][1].charAt(0))); - $WH.ae(m, g); - $WH.ae(m, $WH.ct(mn_path[j][1].substr(1))); - $WH.ae(q, m); - $WH.ae(q, e); - $WH.ae(f, q); - $WH.ae(k, f) +var PageTemplate = new function() +{ + var self = this; + + /**********/ + /* PUBLIC */ + /**********/ + + self.init = function() + { + // Top links + initUserMenu(); + initFeedbackLink(); + initLanguageMenu(); + + initFilterDisclosure(); // sarjuuk: custom (visibility toggle for filters was removed at some point) + + // UI before page contents + initFloatingStuff(); + initTopTabs(); + initTopBar(); + initBreadcrumb(); + + inited = true; } - $WH.ae($WH.ge("toptabs-generic"), k); - var b = $WH.ge("topbar-buttons"); - if (c != null && c >= 0 && c < mn_path.length) { - c = parseInt(c); - switch (c) { + + self.get = function(name) + { + return opt[name]; + } + + self.set = function(options) + { + if(!options) + return; + + var old = {}; + $.extend(old, opt); + $.extend(opt, options); + + opt.activeTab = parseInt(opt.activeTab); + + if(inited) // Update UI on the fly if already created + { + if(opt.activeTab != old.activeTab) + { + updateTopTabs(); + updateTopBar(); + } + + if(opt.breadcrumb != old.breadcrumb) + { + updateBreadcrumb(); + } + } + } + + self.getBreadcrumb = function() + { + return $bread; + } + + self.updateBreadcrumb = function() + { + updateBreadcrumb(); + } + + self.expandBreadcrumb = function() + { + return expandBreadcrumb(); + } + + /***********/ + /* PRIVATE */ + /***********/ + + var inited = false; + var opt = {}; + var $bread; + var $tabs; + var checkedMenuItems = []; + + function construct() + { + createDomElements(); // Create nodes for which getters are available + addBrowserClasses(); + } + + function createDomElements() + { + $bread = $(''); + } + + function addBrowserClasses() + { + // This is done before the tag is loaded, so class names are added to the tag instead + if($WH.Browser.ie6) $(document.documentElement).addClass('ie6 ie67 ie678'); + if($WH.Browser.ie7) $(document.documentElement).addClass('ie7 ie67 ie678'); + if($WH.Browser.ie8) $(document.documentElement).addClass('ie8 ie678'); + } + + function initUserMenu() + { + var $link = $('#toplinks-user'); + if(!$link.length) + return; + + $link.attr('href', '?user=' + g_user.name); + + var menu = []; + + // User Page + var userPage = ['user-page', LANG.userpage, '?user=' + g_user.name, null, {checkedUrl: new RegExp('user=' + g_user.name + '$', 'i')}]; + menu.push(userPage); + + // Settings + var settings = ['settings', LANG.settings, 'https://' + window.location.hostname + '?account', null, {icon: g_staticUrl + '/images/icons/cog.gif', checkedUrl: /account/i}]; + menu.push(settings); + + // Reputation + var reputation = ['reputation', LANG.reputation, '?reputation']; + menu.push(reputation); + + // Guides + var guides = ['guides', 'My Guides', '?my-guides']; + menu.push(guides); + + addCharactersMenu(menu); + addProfilesMenu(menu); + + // Premium Upgrade + var premiumUpgrade; + if(!g_user.premium) + { + premiumUpgrade = ['premium-upgrade', LANG.premiumupgrade, '?premium', null, {className: 'q7', checkedUrl: /premium/i}]; + menu.push(premiumUpgrade); + } + + // Sign Out + menu.push(['sign-out', LANG.signout, '?account=signout']); + + Menu.add($link, menu); + $link.addClass('hassubmenu'); + } + + function addCharactersMenu(userMenu) + { + if(!g_user.characters || !g_user.characters.length) + return; + + // Menu will be generated on the fly + var characters = ['characters', LANG.tab_characters, '?user=' + g_user.name + '#characters', null, {onBeforeShow: generateCharactersSubmenu} ]; + + userMenu.push(characters); + } + + function addProfilesMenu(userMenu) + { + if(!g_user.profiles || !g_user.profiles.length) + return; + + // Menu will be generated on the fly + var profiles = ['profiles', LANG.tab_profiles, '?user=' + g_user.name + '#profiles', null, {onBeforeShow: generateProfilesSubmenu} ]; + + userMenu.push(profiles); + } + + function generateCharactersSubmenu(menuItem) + { + var submenu = []; + + // Sort by realm, region, name + g_user.characters.sort(function(a, b) + { + return $WH.strcmp(a.realmname, b.realmname) || $WH.strcmp(a.region, b.region) || $WH.strcmp(a.name, b.name); + }); + + var lastKey; + $.each(g_user.characters, function(idx, character) + { + if(!character.region || !character.realm || !character.name) + return; + + // Group by realm+region + var key = character.region + character.realm; + if(key != lastKey) + { + var heading = [, character.realmname + ' (' + character.region.toUpperCase() + ')', g_getProfileRealmUrl(character)]; + submenu.push(heading); + lastKey = key; + } + + var menuItem = [character.id, character.name, g_getProfileUrl(character), null, + { + className: (character.pinned ? 'icon-star-right ' : '') + 'c' + character.classs, + tinyIcon: $WH.g_getProfileIcon(character.race, character.classs, character.gender, character.level, character.id, 'tiny') + }]; + + submenu.push(menuItem); + }); + + menuItem[MENU_IDX_SUB] = submenu; + } + + function generateProfilesSubmenu(menuItem) + { + var submenu = []; + + // Sort by name + g_user.profiles.sort(function(a, b) + { + return $WH.strcmp(a.name, b.name); + }); + + $.each(g_user.profiles, function(idx, profile) + { + var menuItem = [profile.id, profile.name, g_getProfileUrl(profile), null, + { + className: 'c' + profile.classs, + tinyIcon: $WH.g_getProfileIcon(profile.race, profile.classs, profile.gender, profile.level, profile.icon, 'tiny') + }]; + + submenu.push(menuItem); + }); + + submenu.push([0, LANG.menu_newprofile, '?profile&new', null, {tinyIcon: 'inv_misc_questionmark'}]); + + menuItem[MENU_IDX_SUB] = submenu; + } + + function initFeedbackLink() + { + $('#toplinks-feedback') + .attr('href', 'javascript:;') + .click(function() + { + ContactTool.show(); + }); + } + + function initLanguageMenu() + { + var linkBefore = 'http://'; + var linkAfter = location.pathname + location.search + location.hash; + var localeId = Locale.getId(); + + var menu = []; + var currentLocale; + + $.each(Locale.getAllByName(), function(idx, locale) + { + var menuItem = [ + locale.id, + locale.description, + g_host + '?locale=' + locale.id, // sarjuuk: edited for unsupported subdomains # linkBefore + locale.domain + linkAfter + null, // more custom + {rel: linkBefore + linkAfter + " domain=" + locale.domain} // also custom + ]; + + if(locale.id == localeId) + { + menuItem.checked = true; + currentLocale = locale; + } + + menu.push(menuItem); + }); + + setLanguageMenu($('#toplinks-language'), menu, currentLocale); + + $(document).ready(function() + { + setLanguageMenu($('#footer-links-language'), menu, currentLocale); + }); + } + + function setLanguageMenu($node, menu, locale) + { + $node.attr('href', 'javascript:;'); + // $node.text(locale.description); + + $node.addClass('hassubmenu'); + Menu.add($node, menu); + } + + function initFloatingStuff() + { + // Expand button + $('#header-expandsite') + .attr('href', 'javascript:;') + .click(expandButtonClick); + } + + function initTopTabs() + { + var $topTabs = $('#toptabs-generic'); + if(!$topTabs.length) + return; + + $tabs = $('
    '); + + $.each(mn_path, function(idx, menuItem) + { + var $dt = $('
    ' + menuItem[MENU_IDX_NAME].charAt(0) + '' + menuItem[MENU_IDX_NAME].substr(1) + '
    '); + var $a = $dt.children('a'); + + Menu.linkifyItem(menuItem, $a); + + $dt.appendTo($tabs); + }); + + updateTopTabs(); + + $tabs.appendTo($topTabs); + } + + function initTopBar() + { + var $topBar = $('#topbar'); + if(!$topBar.length) + return; + + // Search + var $search = $('div.topbar-search', $topBar); + + // custom start (note: html5 supports placeholder attribute) + var inp = $WH.ge('livesearch-generic'); + if (inp.value == '') { + inp.className = 'search-database'; + } + inp.onmouseover = function() { + if ($WH.trim(this.value) != '') { + this.className = ''; + } + }; + inp.onfocus = function() { + this.className = ''; + }; + inp.onblur = function() { + if ($WH.trim(this.value) == '') { + this.className = 'search-database'; + this.value = ''; + } + }; + // custom end + + // Icon + var $icon = $('').attr('href', 'javascript:;'); + + $icon.click(searchIconClick) + .appendTo($search); + + $('form', $search).submit(g_preventEmptyFormSubmission); + LiveSearch.attach($('input', $search)); + + var windowSize = $WH.g_getWindowSize(); + if(windowSize.w && windowSize.w < 1024) + $('div.topbar-search input').css('width', '180px'); + + updateTopBar(); + } + + function initBreadcrumb() + { + // (Already created) + + updateBreadcrumb(); + + $bread.appendTo($('#main-precontents')); + } + + function initFilterDisclosure() + { + if (opt.filter == null) + return; + + var + _ = $WH.ge('main-precontents'), + d = $WH.ce('div'), + a = $WH.ce('a'); + + d.className = 'path-right'; + a.href = 'javascript:;'; + a.id = 'fi_toggle'; + $WH.ns(a); + a.onclick = fi_toggle; + + if (opt.filter) { + a.className = 'disclosure-on'; + $WH.ae(a, $WH.ct(LANG.fihide)); + } + else { + a.className = 'disclosure-off'; + $WH.ae(a, $WH.ct(LANG.fishow)); + } + + $WH.ae(d, a); + $WH.ae(_, d); + } + + function updateTopTabs() + { + if(!$tabs) + return; + + var $as = $('a', $tabs); + + $.each(mn_path, function(idx, menuItem) + { + var $a = $($as.get(idx)); + + var isActiveTab = (menuItem[MENU_IDX_ID] == opt.activeTab); + if(isActiveTab) + { + $a.addClass('active'); + Menu.remove($a); + } + else + { + $a.removeClass('active'); + if(menuItem[MENU_IDX_SUB]) + Menu.add($a, menuItem[MENU_IDX_SUB]); + } + }); + } + + function updateTopBar() + { + var $buttons = $('#topbar div.topbar-buttons'); + if(!$buttons.length) + return; + + $buttons.empty(); + + switch(opt.activeTab) + { case 0: // Database - Menu.addButtons(b, [ - [0, LANG.menu_browse, null, mn_database], // Browse - Menu.findItem(mn_tools, [8]), // Utilities - Menu.findItem(mn_tools, [8, 4]) // Random Page - ]); - break; - case 1: // Tools - Menu.addButtons(b, [ - [0, LANG.calculators, null, mn_tools.slice(0,4)], // Calculators - Menu.findItem(mn_tools, [1]), // Maps - Menu.findItem(mn_tools, [8]), // Utilities - Menu.findItem(mn_tools, [6]), // Guides + Menu.addButtons($buttons,[ + [0, LANG.menu_browse, null, mn_database], // Browse + Menu.findItem(mn_tools, [8]), // Utilities + Menu.findItem(mn_tools, [8, 4]) // Random Page ]); break; - case 2: - Menu.addButtons(b, Menu.implode(mn_more)); + + case 1: // Tools + // Create "Calculators" group to decrease width used + var calculators = [ + [, LANG.calculators], + Menu.findItem(mn_tools, [0]), // Talent Calculator + Menu.findItem(mn_tools, [2]), // Hunter Pet Calculator + Menu.findItem(mn_tools, [3]) // Item Comparison + ]; + + // MoP link + if (mn_tools[2][0] == 10) { + var tmp = calculators[3]; + calculators[3] = Menu.findItem(mn_tools, [10]); + calculators[4] = tmp; + + Menu.addButtons($buttons, Menu.implode(calculators)); + Menu.addButtons($buttons, Menu.implode(mn_tools.slice(4))); // Skip first 4 menu items + } else { + Menu.addButtons($buttons, Menu.implode(calculators)); + Menu.addButtons($buttons, Menu.implode(mn_tools.slice(3))); // Skip first 4 menu items + } + break; - case 5: - pr_initTopBarSearch(); - break - } - } - else { - $WH.ae(b, $WH.ct(String.fromCharCode(160))); - } -} -function g_updateHeader(a) { - $WH.ee($WH.ge("toptabs-generic")); - $WH.ee($WH.ge("topbar-buttons")); - g_createHeader(a) -} -function g_initHeader(a) { - g_createHeader(a); - var d = $WH.ge("livesearch-generic"); - var b = d.previousSibling; - var c = d.parentNode; - $WH.ns(b); - b.onclick = function() { - this.parentNode.onsubmit() - }; - if ($WH.Browser.ie) { - setTimeout(function() { - d.value = "" - }, - 1) - } - if (d.value == "") { - d.className = "search-database" - } - d.onmouseover = function() { - if ($WH.trim(this.value) != "") { - this.className = "" - } - }; - d.onfocus = function() { - this.className = "" - }; - d.onblur = function() { - if ($WH.trim(this.value) == "") { - this.className = "search-database"; - this.value = "" - } - }; - c.onsubmit = function() { - var e = this.elements[0].value; - if ($WH.trim(e) == "") { - return false - } - this.submit() - } -} -function g_initHeaderMenus() { - var c = $WH.ge("toptabs-menu-user"); - if (c) { - menu = [[0, LANG.userpage, "?user=" + g_user.name], [0, LANG.settings, "?account"], [0, LANG.signout, "?account=signout"]]; - if (location.href.match(new RegExp("/?user=" + g_user.name + "$", "i"))) { - menu[0].checked = 1 - } else { - if (location.href.indexOf("?account") != -1) { - menu[1].checked = 1 - } - } - Menu.add(c, menu); - c.href = "?user=" + g_user.name - } - c = $WH.ge("toptabs-menu-profiles"); - if (c) { - c.menu = []; - if (g_user.characters) { - c.menu.push([, LANG.tab_characters]); - for (var f = 0, b = g_user.characters.length; f < b; ++f) { - var h = g_user.characters[f], - e = [0, h.name + " (" + h.realmname + LANG.hyphen + h.region.toUpperCase() + ")", "?profile=" + h.region + "." + h.realm + "." + g_cleanCharacterName(h.name)]; - e.smallIcon = h.icon ? h.icon: "chr_" + g_file_races[h.race] + "_" + g_file_genders[h.gender] + "_" + g_file_classes[h.classs] + "0" + (h.level > 59 ? (Math.floor((h.level - 60) / 10) + 2) : 1); - c.menu.push(e) - } - } - c.menu.push([, LANG.tab_profiles]); - if (g_user.profiles) { - for (var f = 0, b = g_user.profiles.length; f < b; ++f) { - var h = g_user.profiles[f], - e = [0, h.name, "?profile=" + h.id]; - e.smallIcon = h.icon ? h.icon: "chr_" + g_file_races[h.race] + "_" + g_file_genders[h.gender] + "_" + g_file_classes[h.classs] + "0" + (h.level > 59 ? (Math.floor((h.level - 60) / 10) + 2) : 1); - c.menu.push(e) - } - } - var e = [0, "(" + LANG.button_new + ")", "?profile&new"]; - e.smallIcon = "inv_misc_questionmark"; - c.menu.push(e); - c.menu.rightAligned = 1; - Menu.add(c, c.menu); - c.href = "?user=" + g_user.name + (g_user.profiles ? "#profiles": (g_user.characters ? "#characters": "")) - } - c = $WH.ge("toptabs-menu-language"); - if (c) { - var g = "www", - d = location.href, - j = location.hostname.indexOf("."); - if (j != -1 && j <= 5) { - g = location.hostname.substr(0, j) - } - j = d.indexOf("#"); - if (j != -1) { - d = d.substr(0, j) - } - //menu = [[0, "Deutsch", (g_locale.id != 3 ? d.replace(g, "de") : null)], [0, "English", (g_locale.id != 0 ? d.replace(g, "www") : null)], [0, "Espa" + String.fromCharCode(241) + "ol", (g_locale.id != 6 ? d.replace(g, "es") : null)], [0, "Fran" + String.fromCharCode(231) + "ais", (g_locale.id != 2 ? d.replace(g, "fr") : null)], [0, String.fromCharCode(1056, 1091, 1089, 1089, 1082, 1080, 1081), (g_locale.id != 8 ? d.replace(g, "ru") : null)]]; - var rel = d.match(/()\?((item|quest|spell|achievement|npc|object)=([0-9]+))/); - rel = (rel && rel[2]) ? rel[2] : ""; + case 2: // More + Menu.addButtons($buttons, Menu.implode(mn_more)); + break; - menu = [ - [0, "Deutsch", (g_locale.id != 3 ? "?locale=3" : null), , {rel: rel + " domain=de"}], - [0, "English", (g_locale.id != 0 ? "?locale=0" : null), , {rel: rel + " domain=en"}], - [0, "Espa" + String.fromCharCode(241) + "ol", (g_locale.id != 6 ? "?locale=6" : null), , {rel: rel + " domain=es"}], - [0, "Fran" + String.fromCharCode(231) + "ais", (g_locale.id != 2 ? "?locale=2" : null), , {rel: rel + " domain=fr"}], - [0, String.fromCharCode(1056, 1091, 1089, 1089, 1082, 1080, 1081), (g_locale.id != 8 ? "?locale=8" : null), , {rel: rel + " domain=ru"}] - ]; - menu.rightAligned = 1; - if (g_locale.id != 25) { - menu[{ - 0 : 1, - 2 : 3, - 3 : 0, - 6 : 2, - 8 : 4 - } [g_locale.id]].checked = 1 + case 3: // Community + Menu.addButtons($buttons, Menu.implode(mn_community)); + Menu.addButtons($buttons, [ + Menu.findItem(mn_tools, [8]) // Utilities + ]); + break; + + case 4: // Staff + Menu.addButtons($buttons, Menu.implode(mn_staff)); + break; + + case 5: // News + Menu.addButtons($buttons, Menu.implode(mn_news)); + break; + + case 6: // Guides + var entries = [ [ 1, 'List of guides', '/guides' ], [ 2, 'Write new guide', '/guide=new' ] ]; + + if(g_user.id) + entries.push([ 3, 'My guides', '/my-guides' ]); + + Menu.addButtons($buttons, entries); + break; } - Menu.add(c, menu); } - $('#toplinks-feedback').attr('href', 'javascript:;').click(function() + function updateBreadcrumb() { - ContactTool.show(); - }); -} -function g_initPath(q, f) { - var h = mn_path, - c = null, - k = null, - p = 0, - l = $WH.ge("main-precontents"), - o = $WH.ce("div"); - $WH.ee(l); - if (g_initPath.lastIt) { - g_initPath.lastIt.checked = null - } - o.className = "path"; - if (f != null) { - var m = $WH.ce("div"); - m.className = "path-right"; - var r = $WH.ce("a"); - r.href = "javascript:;"; - r.id = "fi_toggle"; - $WH.ns(r); - r.onclick = fi_toggle; - if (f) { - r.className = "disclosure-on"; - $WH.ae(r, $WH.ct(LANG.fihide)) - } else { - r.className = "disclosure-off"; - $WH.ae(r, $WH.ct(LANG.fishow)) - } - $WH.ae(m, r); - $WH.ae(l, m) - } - for (var g = 0; g < q.length; ++g) { - var r, b, t = 0; - for (var e = 0; e < h.length; ++e) { - if (h[e][0] == q[g]) { - t = 1; - h = h[e]; - h.checked = 1; - break - } - } - if (!t) { - p = 1; - break - } - r = $WH.ce("a"); - b = $WH.ce("span"); - if (h[2]) { - r.href = h[2] - } else { - r.href = "javascript:;"; - $WH.ns(r); - r.style.textDecoration = "none"; - r.style.color = "white"; - r.style.cursor = "default" - } - if (g < q.length - 1 && h[3]) { - b.className = "menuarrow" - } - //$WH.ae(r, $WH.ct(h[4] == null ? h[1] : h[4])); - $WH.ae(r, $WH.ct(h[1])); - if (g == 0) { - Menu.add(r, mn_path); - } else { - Menu.add(r, c[3]); + if(!opt.breadcrumb || !opt.breadcrumb.length) // Empty + { + $bread.hide(); + return; } - $WH.ae(b, r); - $WH.ae(o, b); - k = b; - c = h; - h = h[3]; - if (!h) { - p = 1; - break + $bread.empty(); + + // Uncheck previously checked menu items, if any + if(checkedMenuItems.length) + { + $.each(checkedMenuItems, function() {this.checked = false;Menu.updateItem(this)}); + checkedMenuItems = []; } + + var path = Menu.getFullPath(mn_path, opt.breadcrumb); + if(!path.length) + return; + + var lastIdx = (path.length - 1); + + $.each(path, function(idx, menuItem) + { + var menuOpt = Menu.getItemOpt(menuItem); + + menuItem.checked = true; + checkedMenuItems.push(menuItem); + Menu.updateItem(menuItem); + + var $span = expandBreadcrumb(); + var $textHolder = $span; + + if(menuItem[MENU_IDX_URL]) + { + $textHolder = $('', { + href: Menu.getItemUrl(menuItem) + }).appendTo($span); + } + + if(menuOpt.breadcrumb) + $textHolder.text(menuOpt.breadcrumb); + else + $textHolder.text(menuItem[MENU_IDX_NAME]); + + Menu.add($textHolder, menuItem.parentMenu); + + $span.appendTo($bread); + + // Add ellipsis as appropriate + if(idx == lastIdx && menuItem[MENU_IDX_SUB]) + { + $span.addClass('breadcrumb-arrow'); + + var $ellipsis = $('...'); + Menu.add($ellipsis, menuItem[MENU_IDX_SUB]); + + $ellipsis.appendTo($bread); + } + }); + + $bread.trigger('update'); // Some features rely on this event to add stuff to the breadcrumb + $bread.show(); } - if (p && k) { - k.className = "" - } else { - if (c && c[3]) { - k.className = "menuarrow"; - r = $WH.ce("a"); - b = $WH.ce("span"); - r.href = "javascript:;"; - $WH.ns(r); - r.style.textDecoration = "none"; - r.style.paddingRight = "16px"; - r.style.color = "white"; - r.style.cursor = "default"; - $WH.ae(r, $WH.ct("...")); - Menu.add(r, c[3]); - $WH.ae(b, r); - $WH.ae(o, b) - } + + function expandBreadcrumb() + { + $bread.children('span:last').addClass('breadcrumb-arrow'); + + return $('').appendTo($bread); } - // not really usefull - // var m = $WH.ce("div"); - // m.className = "clear"; - // $WH.ae(o, m); - $WH.ae(l, o); - g_initPath.lastIt = c + + // EVENTS + + function expandButtonClick() + { + $('#sidebar, #header-expandsite').remove(); + + if($('#layout').hasClass('nosidebar')) + return; + + // Free room allocated for the sidebar + $('#wrapper').animate( + {'margin-right': '10px'}, + 333, + null, + function() + { + $('#wrapper').css('margin-right', '0px'); + $('#layout').addClass('nosidebar'); + } + ); + } + + function searchIconClick() + { + $(this).prev('form').submit().children('input').focus(); + } + + construct(); } -function g_addTooltip(b, c, a) { - if (!a && c.indexOf("") == -1) { - a = "q" + +function g_addTooltip(element, text, className) { + if (!className && text.indexOf('
    ') == -1) { + className = 'q'; } - b.onmouseover = function(d) { - $WH.Tooltip.showAtCursor(d, c, 0, 0, a) + + element.onmouseover = function(d) { + $WH.Tooltip.showAtCursor(d, text, 0, 0, className); }; - b.onmousemove = $WH.Tooltip.cursorUpdate; - b.onmouseout = $WH.Tooltip.hide + + element.onmousemove = $WH.Tooltip.cursorUpdate; + element.onmouseout = $WH.Tooltip.hide; } -function g_addStaticTooltip(b, c, a) { - if (!a && c.indexOf("
    ") == -1) { - a = "q" + +function g_addStaticTooltip(icon, text, className) { + if (!className && text.indexOf('
    ') == -1) { + className = 'q'; } - b.onmouseover = function(d) { - $WH.Tooltip.show(b, c, 0, 0, a) + + icon.onmouseover = function(d) { + $WH.Tooltip.show(icon, text, 0, 0, className); }; - b.onmouseout = $WH.Tooltip.hide + + icon.onmouseout = $WH.Tooltip.hide; } function g_formatTimeElapsed(delay) { @@ -1100,80 +1404,51 @@ function g_getMoneyHtml(money, side, costItems, costCurrency, achievementPoints) return html; } -function g_numberFormat(f, b, l, h) { - var c = f, - a = b; - var e = function(r, q) { - var i = Math.pow(10, q); - return (Math.round(r * i) / i).toString() - }; - c = !isFinite( + c) ? 0 : +c; - a = !isFinite( + a) ? 0 : Math.abs(a); - var p = (typeof h === "undefined") ? ",": h; - var d = (typeof l === "undefined") ? ".": l; - var o = (a > 0) ? e(c, a) : e(Math.round(c), a); - var m = e(Math.abs(c), a); - var k, g; - if (m >= 1000) { - k = m.split(/\D/); - g = k[0].length % 3 || 3; - k[0] = o.slice(0, g + (c < 0)) + k[0].slice(g).replace(/(\d{3})/g, p + "$1"); - o = k.join(d) - } else { - o = o.replace(".", d) - } - var j = o.indexOf(d); - if (a >= 1 && j !== -1 && (o.length - j - 1) < a) { - o += new Array(a - (o.length - j - 1)).join(0) + "0" - } else { - if (a >= 1 && j === -1) { - o += d + new Array(a).join(0) + "0" +function g_insertTag(where, tagOpen, tagClose, repFunc) { + var n = $WH.ge(where); + + n.focus(); + if (n.selectionStart != null) { + var + s = n.selectionStart, + e = n.selectionEnd, + sL = n.scrollLeft, + sT = n.scrollTop; + + var selectedText = n.value.substring(s, e); + if (typeof repFunc == 'function') { + selectedText = repFunc(selectedText); } + + n.value = n.value.substr(0, s) + tagOpen + selectedText + tagClose + n.value.substr(e); + n.selectionStart = n.selectionEnd = e + tagOpen.length; + + n.scrollLeft = sL; + n.scrollTop = sT; } - return o -} -function g_expandSite() { - $WH.ge("wrapper").className = "nosidebar"; - var a = $WH.ge("topbar-expand"); - if (a) { - $WH.de(a) - } - a = $WH.ge("sidebar"); - if (a) { - $WH.de(a) - } -} -function g_insertTag(d, a, i, j) { - var b = $(d); - b.focus(); - if (b.selectionStart != null) { - var l = b.selectionStart, - h = b.selectionEnd, - k = b.scrollLeft, - c = b.scrollTop; - var g = b.value.substring(l, h); - if (typeof j == "function") { - g = j(g) + else if (document.selection && document.selection.createRange) { + var range = document.selection.createRange(); + + if (range.parentElement() != n) { + return; } - b.value = b.value.substr(0, l) + a + g + i + b.value.substr(h); - b.selectionStart = b.selectionEnd = h + a.length; - b.scrollLeft = k; - b.scrollTop = c - } else { - if (document.selection && document.selection.createRange) { - var f = document.selection.createRange(); - if (f.parentElement() != b) { - return - } - var g = f.text; - if (typeof j == "function") { - g = j(g) - } - f.text = a + g + i + + var selectedText = range.text; + if (typeof repFunc == 'function') { + selectedText = repFunc(selectedText); } + + range.text = tagOpen + selectedText + tagClose; +/* + range.moveEnd("character", -tagClose.length); + range.moveStart("character", range.text.length); + + range.select(); +*/ } - if (b.onkeyup) { - b.onkeyup() + + if (n.onkeyup) { + n.onkeyup(); } } @@ -1200,7 +1475,7 @@ function g_getCurrentDomain() { if (!g_isIpAddress(hostname)) { // Only keep the last 2 parts var parts = hostname.split('.'); - if(parts.length > 2) { + if (parts.length > 2) { parts.splice(0, parts.length - 2); } hostname = parts.join('.'); @@ -1211,52 +1486,77 @@ function g_getCurrentDomain() { return hostname; } -function g_onAfterTyping(a, d, c) { - var e; - var b = function() { - if (e) { - clearTimeout(e); - e = null +function g_onAfterTyping(input, func, delay) { + var timerId; + var ldsgksdgnlk623 = function() { + if (timerId) { + clearTimeout(timerId); + timerId = null; } - e = setTimeout(d, c) + timerId = setTimeout(func, delay); }; - a.onkeyup = b + input.onkeyup = ldsgksdgnlk623; } -function g_onClick(c, d) { - var b = 0; - function a(e) { - if (b) { - if (b != e) { - return - } - } else { - b = e - } - d(true) - } - c.oncontextmenu = function() { - a(1); - return false - }; - c.onmouseup = function(f) { - f = $WH.$E(f); - if (f._button == 3 || f.shiftKey || f.ctrlKey) { - a(2) - } else { - if (f._button == 1) { - d(false) + +function g_onClick(el, func) { + var firstEvent = 0; + + function rightClk(n) { + if (firstEvent) { + if (firstEvent != n) { + return; } } - return false + else { + firstEvent = n; + } + + func(true); + } + + el.onclick = function(e) { + e = $WH.$E(e); + + if (e._button == 2) { // middle click + return true; + } + + return false; + } + + el.oncontextmenu = function() { + rightClk(1); + + return false; + }; + + el.onmouseup = function(e) { + e = $WH.$E(e); + + if (e._button == 3 || e.shiftKey || e.ctrlKey) { // Right/Shift/Ctrl + rightClk(2); + } + else if (e._button == 1) { // Left + func(false); + } + + return false; } } -function g_isLeftClick(a) { - a = $WH.$E(a); - return (a && a._button == 1) + +function g_isLeftClick(e) { + e = $WH.$E(e); + return (e && e._button == 1); +} + +function g_preventEmptyFormSubmission() { // Used on the homepage and in the top bar + if (!$.trim(this.elements[0].value)) { + return false; + } } function g_isExternalUrl(url) { - if(!url) { + if (!url) { return false; } @@ -1376,6 +1676,215 @@ function g_modifyUrl(url, params, opt) { return url + hash; } +function g_GetExpansionClassName(expansion) { + switch (expansion) { + case 0: + return null; + case 1: + return "icon-bc-right"; + case 2: + return "icon-wotlk-right"; + } + + return null; +} + +function g_addPages(d, opt) { + function createPageSquare(n, customText) { + var foo; + if (n == opt.page) { + foo = $WH.ce('span'); + foo.className = 'selected'; + } + else { + foo = $WH.ce('a'); + foo.href = (n > 1 ? opt.url + opt.sep + n + opt.pound : opt.url + opt.pound); + } + $WH.ae(foo, $WH.ct(customText != null ? customText : n)); + return foo; + } + + if (!opt.pound) { + opt.pound = ''; + } + + if (!opt.sep) { + opt.sep = '.'; + } + + if (opt.allOrNothing && opt.nPages <= 1) { + return; + } + + var leftAligned = (opt.align && opt.align == 'left'); + + var + divPages = $WH.ce('div'), + pagesNumbers, + para = $WH.ce('var'); + + divPages.className = 'pages'; + if (leftAligned) { + divPages.className += ' pages-left'; + } + + // Pages + if (opt.nPages > 1) { + pagesNumbers = $WH.ce('div'); + pagesNumbers.className = 'pages-numbers'; + + var minPage = Math.max(2, opt.page - 2); + var maxPage = Math.min(opt.nPages - 1, opt.page + 2); + + var elements = []; // Temporarily stored in an array so the order can be reversed when left-aligned. + + if (opt.page != opt.nPages) { + elements.push(createPageSquare(opt.page + 1, LANG.lvpage_next + String.fromCharCode(8250))); + } + + elements.push(createPageSquare(opt.nPages)); + if (maxPage < opt.nPages - 1) { + var sp = $WH.ce('span'); + $WH.ae(sp, $WH.ct('...')); + elements.push(sp); + } + + for (var i = maxPage; i >= minPage; --i) { + elements.push(createPageSquare(i)); + } + + if (minPage > 2) { + var sp = $WH.ce('span'); + $WH.ae(sp, $WH.ct('...')); + elements.push(sp); + } + elements.push(createPageSquare(1)); + + if (opt.page != 1) { + elements.push(createPageSquare(opt.page - 1, String.fromCharCode(8249) + LANG.lvpage_previous)); + } + + if (leftAligned) { + elements.reverse(); + } + + for (var i = 0, len = elements.length; i < len; ++i) { + $WH.ae(pagesNumbers, elements[i]); + } + + pagesNumbers.firstChild.style.marginRight = '0'; + pagesNumbers.lastChild.style.marginLeft = '0'; + } + + // Number of items + var para = $WH.ce('var'); + $WH.ae(para, $WH.ct($WH.sprintf(LANG[opt.wording[opt.nItems == 1 ? 0 : 1]], opt.nItems))); + + if (opt.nPages > 1) { // Go to page + var sp = $WH.ce('span'); + $WH.ae(sp, $WH.ct(String.fromCharCode(8211))); + $WH.ae(para, sp); + + var pageIcon = $WH.ce('a'); + pageIcon.className = 'gotopage'; + pageIcon.href = 'javascript:;'; + $WH.ns(pageIcon); + + if ($WH.Browser.ie) { + $WH.ae(pageIcon, $WH.ct(' ')); + } + + pageIcon.onclick = function() { + var n = prompt($WH.sprintf(LANG.prompt_gotopage, 1, opt.nPages), opt.page); + if (n != null) { + n |= 0; + if (n != opt.page && n >= 1 && n <= opt.nPages) { + document.location.href = (n > 1 ? opt.url + opt.sep + n + opt.pound : opt.url + opt.pound); + } + } + }; + pageIcon.onmouseover = function(event) { + $WH.Tooltip.showAtCursor(event, LANG.tooltip_gotopage, 0, 0, 'q2'); + }; + pageIcon.onmousemove = $WH.Tooltip.cursorUpdate; + pageIcon.onmouseout = $WH.Tooltip.hide; + $WH.ae(para, pageIcon); + } + + if (leftAligned) { + $WH.ae(divPages, para); + if (pagesNumbers) { + $WH.ae(divPages, pagesNumbers); + } + } + else { + if (pagesNumbers) { + $WH.ae(divPages, pagesNumbers); + } + $WH.ae(divPages, para); + } + + $WH.ae(d, divPages); +} + +function g_disclose(el, _this) { + _this.className = 'disclosure-' + (g_toggleDisplay(el) ? 'on' : 'off'); + + return false; +} + +/* Displays a warning when the user attempts to leave the page if some elements are modified, unless the user leaves the page + * by submitting the form. + * + * The jQuery form object must be passed as first argument; the second argument is an array of jQuery objects of fields that + * are being watched for changes. The third argument is the warning message shown. + * + * This function must be called in the on ready event. + */ + +function g_setupChangeWarning(form, elements, warningMessage) { + /* Still skip IE since it triggers this when anchor links are clicked. */ + if ($.browser.msie) { + return; + } + + if (!form) { + return; + } + + function ShowWarning() { return warningMessage; } + + form.submit(function() { window.onbeforeunload = null; }); + + var initialText = []; + + for (var idx in elements) { + var text = elements[idx]; + + if (!text) { + continue; + } + + initialText[idx] = text.val(); + text.keydown(function() { + for (var idx in elements) { + var text = elements[idx]; + + if (!text) { + continue; + } + + if (text.val() != initialText[idx]) { + window.onbeforeunload = ShowWarning; + return; + } + + window.onbeforeunload = null; + } + }); + } +} + DomContentLoaded.addEvent(function () { $WH.array_apply($WH.gE(document, 'dfn'), function(x){ var text = x.title; @@ -1402,142 +1911,24 @@ DomContentLoaded.addEvent(function () { */ }); -function g_GetExpansionClassName(expansion) { - switch (expansion) { - case 0: - return null; - case 1: - return "icon-bc-right"; - case 2: - return "icon-wotlk-right"; - } - return null; -} +/* +Global comment-related functions +*/ -function g_addPages(l, b) { - function p(r, d) { - var i; - if (r == b.page) { - i = $WH.ce("span"); - i.className = "selected" - } else { - i = $WH.ce("a"); - i.href = (r > 1 ? b.url + b.sep + r + b.pound: b.url + b.pound) - } - $WH.ae(i, $WH.ct(d != null ? d: r)); - return i - } - if (!b.pound) { - b.pound = "" - } - if (!b.sep) { - b.sep = "." - } - if (b.allOrNothing && b.nPages <= 1) { - return - } - var c = (b.align && b.align == "left"); - var e = $WH.ce("div"), - k, - q = $WH.ce("var"); - e.className = "pages"; - if (c) { - e.className += " pages-left" - } - if (b.nPages > 1) { - k = $WH.ce("div"); - k.className = "pages-numbers"; - var o = Math.max(2, b.page - 3); - var h = Math.min(b.nPages - 1, b.page + 3); - var m = []; - if (b.page != b.nPages) { - m.push(p(b.page + 1, LANG.lvpage_next + String.fromCharCode(8250))) - } - m.push(p(b.nPages)); - if (h < b.nPages - 1) { - var a = $WH.ce("span"); - $WH.ae(a, $WH.ct("...")); - m.push(a) - } - for (var g = h; g >= o; --g) { - m.push(p(g)) - } - if (o > 2) { - var a = $WH.ce("span"); - $WH.ae(a, $WH.ct("...")); - m.push(a) - } - m.push(p(1)); - if (b.page != 1) { - m.push(p(b.page - 1, String.fromCharCode(8249) + LANG.lvpage_previous)) - } - if (c) { - m.reverse() - } - for (var g = 0, j = m.length; g < j; ++g) { - $WH.ae(k, m[g]) - } - k.firstChild.style.marginRight = "0"; - k.lastChild.style.marginLeft = "0" - } - var q = $WH.ce("var"); - $WH.ae(q, $WH.ct($WH.sprintf(LANG[b.wording[b.nItems == 1 ? 0 : 1]], b.nItems))); - if (b.nPages > 1) { - var a = $WH.ce("span"); - $WH.ae(a, $WH.ct(String.fromCharCode(8211))); - $WH.ae(q, a); - var f = $WH.ce("a"); - f.className = "gotopage"; - f.href = "javascript:;"; - $WH.ns(f); - if ($WH.Browser.ie) { - $WH.ae(f, $WH.ct(" ")) - } - f.onclick = function() { - var d = prompt($WH.sprintf(LANG.prompt_gotopage, 1, b.nPages), b.page); - if (d != null) { - d |= 0; - if (d != b.page && d >= 1 && d <= b.nPages) { - document.location.href = (d > 1 ? b.url + b.sep + d + b.pound: b.url + b.pound) - } - } - }; - f.onmouseover = function(d) { - $WH.Tooltip.showAtCursor(d, LANG.tooltip_gotopage, 0, 0, "q") - }; - f.onmousemove = $WH.Tooltip.cursorUpdate; - f.onmouseout = $WH.Tooltip.hide; - $WH.ae(q, f) - } - if (c) { - $WH.ae(e, q); - if (k) { - $WH.ae(e, k) - } - } else { - if (k) { - $WH.ae(e, k) - } - $WH.ae(e, q) - } - $WH.ae(l, e) -} -function g_disclose(a, b) { - b.className = "disclosure-" + (g_toggleDisplay(a) ? "on": "off"); - return false -} function co_addYourComment() { tabsContribute.focus(0); - var ta = $WH.gE(document.forms['addcomment'], "textarea")[0]; - ta.focus() + var ta = $WH.gE(document.forms['addcomment'], 'textarea')[0]; + ta.focus(); } + function co_cancelReply() { - $WH.ge("replybox-generic").style.display = "none"; - document.forms.addcomment.elements.replyto.value = "" + $WH.ge('replybox-generic').style.display = 'none'; + document.forms.addcomment.elements.replyto.value = ''; } + function co_validateForm(f) { - var ta = $WH.gE(f, "textarea")[0]; + var ta = $WH.gE(f, 'textarea')[0]; if (g_user.permissions & 1) { return true; @@ -1546,55 +1937,70 @@ function co_validateForm(f) { if (Listview.funcBox.coValidate(ta)) { return true; } - return false + + return false; } + + +/* +Global screenshot-related functions +*/ function ss_submitAScreenshot() { - tabsContribute.focus(1) + tabsContribute.focus(1); } + function ss_validateForm(f) { if (!f.elements.screenshotfile.value.length) { alert(LANG.message_noscreenshot); return false; } + return true; } + function ss_appendSticky() { - var _ = $WH.ge("infobox-sticky-ss"); - var type = g_pageInfo.type; + var _ = $WH.ge('infobox-sticky-ss'); + + var type = g_pageInfo.type; var typeId = g_pageInfo.typeId; - var pos = $WH.in_array(lv_screenshots, 1, function(a) { - return a.sticky; + + var pos = $WH.in_array(lv_screenshots, 1, function(x) { + return x.sticky; }); if (pos != -1) { var screenshot = lv_screenshots[pos]; - var a = $WH.ce("a"); - a.href = "#screenshots:id=" + screenshot.id; + var a = $WH.ce('a'); + a.href = '#screenshots:id=' + screenshot.id; a.onclick = function(a) { - ScreenshotViewer.show({ - screenshots: lv_screenshots, - pos: pos - }); + ScreenshotViewer.show({ screenshots: lv_screenshots, pos: pos }); return $WH.rf2(a); }; var size = (lv_videos && lv_videos.length ? [120, 90] : [150, 150]); var - img = $WH.ce("img"), + img = $WH.ce('img'), scale = Math.min(size[0] / screenshot.width, size[1] / screenshot.height); - img.src = g_staticUrl + "/uploads/screenshots/thumb/" + screenshot.id + ".jpg"; + img.src = g_staticUrl + '/uploads/screenshots/thumb/' + screenshot.id + '.jpg'; img.width = Math.round(scale * screenshot.width); img.height = Math.round(scale * screenshot.height); - img.className = "border"; + img.className = 'border'; $WH.ae(a, img); + $WH.ae(_, a); var th = $WH.ge('infobox-screenshots'); - var a = $WH.ce("a"); - $WH.ae(a, $WH.ct(th.innerText + " (" + lv_screenshots.length + ")")); - a.href = "#screenshots" + var a = $WH.ce('a'); + + if (!th) { + var sections = $('th', _.parentNode); + th = sections[sections.length - (lv_videos && lv_videos.length ? 2 : 1)]; + } + + $WH.ae(a, $WH.ct(th.innerText + ' (' + lv_screenshots.length + ')')); + a.href = '#screenshots' a.title = $WH.sprintf(LANG.infobox_showall, lv_screenshots.length); a.onclick = function() { tabsRelated.focus((lv_videos && lv_videos.length) || (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO)) ? -2 : -1); @@ -1605,27 +2011,561 @@ function ss_appendSticky() { } else { var a; + if (g_user.id > 0) { a = ''; } else { a = ''; } - _.innerHTML = $WH.sprintf(LANG.infobox_noneyet, a + LANG.infobox_submitone + "") + _.innerHTML = $WH.sprintf(LANG.infobox_noneyet, a + LANG.infobox_submitone + '') } } + +var g_screenshots = {}; +var ScreenshotViewer = new function() { + var + screenshots, + pos, + imgWidth, + imgHeight, + scale, + desiredScale, + oldHash, + mode = 0, + collectionId, + container, + screen, + imgDiv, + aPrev, + aNext, + aCover, + aOriginal, + divFrom, + divCaption, + loadingImage, + lightboxComponents; + + function computeDimensions(captionExtraHeight) { + var screenshot = screenshots[pos]; + + var availHeight = Math.max(50, Math.min(618, $WH.g_getWindowSize().h - 72 - captionExtraHeight)); + + if (mode != 1 || screenshot.id || screenshot.resize) { + desiredScale = Math.min(772 / screenshot.width, 618 / screenshot.height); + scale = Math.min(772 / screenshot.width, availHeight / screenshot.height); + } + else { + desiredScale = scale = 1; + } + + if (desiredScale > 1) { + desiredScale = 1; + } + + if (scale > 1) { + scale = 1; + } + + imgWidth = Math.round(scale * screenshot.width); + imgHeight = Math.round(scale * screenshot.height); + var lbWidth = Math.max(480, imgWidth); + + Lightbox.setSize(lbWidth + 20, imgHeight + 52 + captionExtraHeight); + + if ($WH.Browser.ie6) { + screen.style.width = lbWidth + 'px'; + if (screenshots.length > 1) { + aPrev.style.height = aNext.style.height = imgHeight + 'px' + } else { + aCover.style.height = imgHeight + 'px' + } + } + if (captionExtraHeight) { + imgDiv.firstChild.width = imgWidth; + imgDiv.firstChild.height = imgHeight; + } + } + + function getPound(pos) { + var + screenshot = screenshots[pos], + buff = '#screenshots:'; + + if (mode == 0) { + buff += 'id=' + screenshot.id; + } + else { + buff += collectionId + ':' + (pos + 1); + } + return buff; + } + + function render(resizing) { + if (resizing && (scale == desiredScale) && $WH.g_getWindowSize().h > container.offsetHeight) { + return; + } + container.style.visibility = 'hidden'; + var + screenshot = screenshots[pos], + resized = (screenshot.width > 772 || screenshot.height > 618); + + computeDimensions(0); + + var url = (screenshot.url ? screenshot.url: g_staticUrl + '/uploads/screenshots/' + (resized ? 'resized/': 'normal/') + screenshot.id + '.jpg'); + + var html = + ' 1); + + if (hasFrom1) { + var + postedOn = new Date(screenshot.date), + elapsed = (g_serverTime - postedOn) / 1000; + var a = divFrom.firstChild.childNodes[1]; + a.href = '?user=' + screenshot.user; + a.innerHTML = screenshot.user; + + var s = divFrom.firstChild.childNodes[3]; + $WH.ee(s); + Listview.funcBox.coFormatDate(s, elapsed, postedOn); + + divFrom.firstChild.style.display = ''; + } + else { + divFrom.firstChild.style.display = 'none'; + } + + var s = divFrom.childNodes[1]; + $WH.ee(s); + if (screenshot.user) { + if (hasFrom1) { + $WH.ae(s, $WH.ct(' ' + LANG.dash + ' ')); + } + var a = $WH.ce('a'); + a.href = 'javascript:;'; + a.onclick = ContactTool.show.bind(ContactTool, { + mode: 3, + screenshot: screenshot + }); + a.className = 'icon-report' + g_addTooltip(a, LANG.report_tooltip, 'q2'); + $WH.ae(a, $WH.ct(LANG.report)); + $WH.ae(s, a); + } + + s = divFrom.childNodes[2]; + + if (hasFrom2) { + var buff = ''; + if (screenshot.user) { + buff = LANG.dash; + } + buff += (pos + 1) + LANG.lvpage_of + screenshots.length; + + s.innerHTML = buff; + s.style.display = ''; + } + else { + s.style.display = 'none'; + } + + divFrom.style.display = (hasFrom1 || hasFrom2 ? '': 'none'); + + var hasCaption = (screenshot.caption != null && screenshot.caption.length); + var hasSubject = (screenshot.subject != null && screenshot.subject.length && screenshot.type && screenshot.typeId); + + if (hasCaption || hasSubject) { + var html = ''; + + if (hasSubject) { + html += LANG.types[screenshot.type][0] + LANG.colon; + html += ''; + html += screenshot.subject; + html += ''; + } + + if (hasCaption) { + if (hasSubject) { + html += LANG.dash; + } + html += (screenshot.noMarkup ? screenshot.caption : Markup.toHtml(screenshot.caption, { mode: Markup.MODE_SIGNATURE })); + } + + divCaption.innerHTML = html; + divCaption.style.display = ''; + } + else { + divCaption.style.display = 'none'; + } + + if (screenshots.length > 1) { + aPrev.href = getPound(peekPos(-1)); + aNext.href = getPound(peekPos(1)); + + aPrev.style.display = aNext.style.display = ''; + aCover.style.display = 'none'; + } + else { + aPrev.style.display = aNext.style.display = 'none'; + aCover.style.display = ''; + } + + location.replace(getPound(pos)); + } + + Lightbox.reveal(); + + if (divCaption.offsetHeight > 18) { + computeDimensions(divCaption.offsetHeight - 18); + } + container.style.visibility = 'visible'; + } + + function peekPos(change) { + var foo = pos; + foo += change; + + if (foo < 0) { + foo = screenshots.length - 1; + } + else if (foo >= screenshots.length) { + foo = 0; + } + + return foo; + } + + function prevScreenshot() { + pos = peekPos(-1); + onRender(); + + return false; + } + + function nextScreenshot() { + pos = peekPos(1); + onRender(); + + return false; + } + + function onKeyUp(e) { + e = $WH.$E(e); + switch (e.keyCode) { + case 37: // Left + prevScreenshot(); + break; + case 39: // Right + nextScreenshot(); + break; + } + } + + function onResize() { + render(1); + } + + function onHide() { + cancelImageLoading(); + + if (screenshots.length > 1) { + $WH.dE(document, 'keyup', onKeyUp); + } + + if (oldHash && mode == 0) { + if (oldHash.indexOf(':id=') != -1) { + oldHash = '#screenshots'; + } + location.replace(oldHash); + } + else { + location.replace('#.'); + } + } + + function onShow(dest, first, opt) { + if (typeof opt.screenshots == 'string') { + screenshots = g_screenshots[opt.screenshots]; + mode = 1; + collectionId = opt.screenshots; + } + else { + screenshots = opt.screenshots; + mode = 0; + collectionId = null; + } + container = dest; + + pos = 0; + if (opt.pos && opt.pos >= 0 && opt.pos < screenshots.length) { + pos = opt.pos; + } + + if (first) { + dest.className = 'screenshotviewer'; + + screen = $WH.ce('div'); + + screen.className = 'screenshotviewer-screen'; + + aPrev = $WH.ce('a'); + aNext = $WH.ce('a'); + aPrev.className = 'screenshotviewer-prev'; + aNext.className = 'screenshotviewer-next'; + aPrev.href = 'javascript:;'; + aNext.href = 'javascript:;'; + + var foo = $WH.ce('span'); + $WH.ae(foo, $WH.ce('b')); + // var b = $WH.ce('b'); + // $WH.ae(b, $WH.ct(LANG.previous)); + // $WH.ae(foo, b); + $WH.ae(aPrev, foo); + var foo = $WH.ce('span'); + $WH.ae(foo, $WH.ce('b')); + // var b = $WH.ce('b'); + // $WH.ae(b, $WH.ct(LANG.next)); + // $WH.ae(foo, b); + $WH.ae(aNext, foo); + + aPrev.onclick = prevScreenshot; + aNext.onclick = nextScreenshot; + + aCover = $WH.ce('a'); + aCover.className = 'screenshotviewer-cover'; + aCover.href = 'javascript:;'; + aCover.onclick = Lightbox.hide; + var foo = $WH.ce('span'); + $WH.ae(foo, $WH.ce('b')); + // var b = $WH.ce('b'); + // $WH.ae(b, $WH.ct(LANG.close)); + // $WH.ae(foo, b); + $WH.ae(aCover, foo); + if ($WH.Browser.ie6) { + $WH.ns(aPrev); + $WH.ns(aNext); + aPrev.onmouseover = aNext.onmouseover = aCover.onmouseover = function() { + this.firstChild.style.display = 'block'; + }; + aPrev.onmouseout = aNext.onmouseout = aCover.onmouseout = function() { + this.firstChild.style.display = ''; + }; + + } + $WH.ae(screen, aPrev); + $WH.ae(screen, aNext); + $WH.ae(screen, aCover); + + imgDiv = $WH.ce('div'); + $WH.ae(screen, imgDiv); + + $WH.ae(dest, screen); + + var aClose = $WH.ce('a'); + aClose.className = 'screenshotviewer-close'; + // aClose.className = 'dialog-x'; + aClose.href = 'javascript:;'; + aClose.onclick = Lightbox.hide; + $WH.ae(aClose, $WH.ce('span')); + // $WH.ae(aClose, $WH.ct(LANG.close)); + $WH.ae(dest, aClose); + + aOriginal = $WH.ce('a'); + aOriginal.className = 'screenshotviewer-original'; + // aOriginal.className = 'dialog-arrow'; + aOriginal.href = 'javascript:;'; + aOriginal.target = '_blank'; + $WH.ae(aOriginal, $WH.ce('span')); + // $WH.ae(aOriginal, $WH.ct(LANG.original)); + $WH.ae(dest, aOriginal); + + divFrom = $WH.ce('div'); + divFrom.className = 'screenshotviewer-from'; + var sp = $WH.ce('span'); + $WH.ae(sp, $WH.ct(LANG.lvscreenshot_from)); + $WH.ae(sp, $WH.ce('a')); + $WH.ae(sp, $WH.ct(' ')); + $WH.ae(sp, $WH.ce('span')); + $WH.ae(divFrom, sp); + $WH.ae(divFrom, $WH.ce('span')); + $WH.ae(divFrom, $WH.ce('span')); + $WH.ae(dest, divFrom); + + divCaption = $WH.ce('div'); + divCaption.className = 'screenshotviewer-caption'; + $WH.ae(dest, divCaption); + var d = $WH.ce('div'); + d.className = 'clear'; + $WH.ae(dest, d); + } + + oldHash = location.hash; + + if (screenshots.length > 1) { + $WH.aE(document, 'keyup', onKeyUp); + } + + onRender(); + } + + function onRender() { + var screenshot = screenshots[pos]; + if (!screenshot.width || !screenshot.height) { + if (loadingImage) { + loadingImage.onload = null; + loadingImage.onerror = null; + } + else { + container.className = ''; + lightboxComponents = []; + while (container.firstChild) { + lightboxComponents.push(container.firstChild); + $WH.de(container.firstChild); + } + } + + var lightboxTimer = setTimeout(function() { + screenshot.width = 126; + screenshot.height = 22; + computeDimensions(0); + screenshot.width = null; + screenshot.height = null; + + var div = $WH.ce('div'); + div.style.margin = '0 auto'; + div.style.width = '126px'; + var img = $WH.ce('img'); + img.src = g_staticUrl + '/images/ui/misc/progress-anim.gif'; + img.width = 126; + img.height = 22; + $WH.ae(div, img); + $WH.ae(container, div); + + Lightbox.reveal(); + container.style.visiblity = 'visible'; + }, 150); + + loadingImage = new Image(); + loadingImage.onload = (function(screen, timer) { + clearTimeout(timer); + screen.width = this.width; + screen.height = this.height; + loadingImage = null; + restoreLightbox(); + render(); + }).bind(loadingImage, screenshot, lightboxTimer); + loadingImage.onerror = (function(timer) { + clearTimeout(timer); + loadingImage = null; + Lightbox.hide(); + restoreLightbox(); + }).bind(loadingImage, lightboxTimer); + loadingImage.src = (screenshot.url ? screenshot.url : g_staticUrl + '/uploads/screenshots/normal/' + screenshot.id + '.jpg'); + } + else { + render(); + } + } + + function cancelImageLoading() { + if (!loadingImage) { + return; + } + + loadingImage.onload = null; + loadingImage.onerror = null; + loadingImage = null; + + restoreLightbox(); + } + + function restoreLightbox() { + if (!lightboxComponents) { + return; + } + + $WH.ee(container); + container.className = 'screenshotviewer'; + for (var i = 0; i < lightboxComponents.length; ++i) + $WH.ae(container, lightboxComponents[i]); + lightboxComponents = null; + } + + this.checkPound = function() { + if (location.hash && location.hash.indexOf('#screenshots') == 0) { + if (!g_listviews['screenshots']) { // Standalone screenshot viewer + var parts = location.hash.split(':'); + if (parts.length == 3) { + var + collection = g_screenshots[parts[1]], + p = parseInt(parts[2]); + + if (collection && p >= 1 && p <= collection.length) { + ScreenshotViewer.show({ + screenshots: parts[1], + pos: p - 1 + }); + } + } + } + } + } + + this.show = function(opt) { + Lightbox.show('screenshotviewer', { + onShow: onShow, + onHide: onHide, + onResize: onResize + }, opt); + } + + DomContentLoaded.addEvent(this.checkPound) +}; + + +/* +Global video-related functions +*/ + var vi_thumbnails = { - 1 : "http://i3.ytimg.com/vi/$1/default.jpg" + 1: 'http://i3.ytimg.com/vi/$1/default.jpg' // YouTube }; + var vi_siteurls = { - 1 : "http://www.youtube.com/watch?v=$1" + 1: 'http://www.youtube.com/watch?v=$1' // YouTube }; + var vi_sitevalidation = { - 1 : /^http:\/\/www\.youtube\.com\/watch\?v=([^& ]{11})/ + 1: /^http:\/\/www\.youtube\.com\/watch\?v=([^& ]{11})/ // YouTube }; + function vi_submitAVideo() { - tabsContribute.focus(2) + tabsContribute.focus(2); } + function vi_validateForm(f) { if (!f.elements['videourl'].value.length) { alert(LANG.message_novideo); @@ -1636,7 +2576,7 @@ function vi_validateForm(f) { for (var i in vi_sitevalidation) { if (f.elements['videourl'].value.match(vi_sitevalidation[i])) { urlmatch = true; - break + break; } } @@ -1644,39 +2584,46 @@ function vi_validateForm(f) { alert(LANG.message_novideo); return false; } + return true; } + function vi_appendSticky() { - var _ = $WH.ge("infobox-sticky-vi"); - var type = g_pageInfo.type; + var _ = $WH.ge('infobox-sticky-vi'); + + var type = g_pageInfo.type; var typeId = g_pageInfo.typeId; - var pos = $WH.in_array(lv_videos, 1, function(a) { - return a.sticky + + var pos = $WH.in_array(lv_videos, 1, function(x) { + return x.sticky; }); if (pos != -1) { var video = lv_videos[pos]; - var a = $WH.ce("a"); - a.href = "#videos:id=" + video.id; + var a = $WH.ce('a'); + a.href = '#videos:id=' + video.id; a.onclick = function(e) { - VideoViewer.show({ - videos: lv_videos, - pos: pos - }); - return $WH.rf2(e) + VideoViewer.show({ videos: lv_videos, pos: pos }); + return $WH.rf2(e); }; - var img = $WH.ce("img"); + var img = $WH.ce('img'); img.src = $WH.sprintf(vi_thumbnails[video.videoType], video.videoId); - img.className = "border"; + img.className = 'border'; $WH.ae(a, img); + $WH.ae(_, a); var th = $WH.ge('infobox-videos'); - var a = $WH.ce("a"); - $WH.ae(a, $WH.ct(th.innerText + " (" + lv_videos.length + ")")); - a.href = "#videos" + var a = $WH.ce('a'); + if (!th) { + var sections = $('th', _.parentNode); + th = sections[sections.length - (lv_videos && lv_videos.length ? 2 : 1)]; + } + + $WH.ae(a, $WH.ct(th.innerText + ' (' + lv_videos.length + ')')); + a.href = '#videos' a.title = $WH.sprintf(LANG.infobox_showall, lv_videos.length); a.onclick = function() { tabsRelated.focus(-1); @@ -1687,6 +2634,7 @@ function vi_appendSticky() { } else { var a; + if (g_user.id > 0) { a = '' } @@ -1694,7 +2642,7 @@ function vi_appendSticky() { a = '' } - _.innerHTML = $WH.sprintf(LANG.infobox_noneyet, a + LANG.infobox_suggestone + "") + _.innerHTML = $WH.sprintf(LANG.infobox_noneyet, a + LANG.infobox_suggestone + '') } } @@ -2093,6 +3041,7 @@ var VideoViewer = new function() { DomContentLoaded.addEvent(this.checkPound) }; + var Dialog = function() { var _self = this, @@ -3136,7 +4085,7 @@ Tabs.prototype = { return; } - if(this.tabs[index].locked) { + if (this.tabs[index].locked) { return this.onShow(this.tabs[index], this.tabs[this.selectedTab]); } @@ -3224,7 +4173,7 @@ Tabs.prototype = { $WH.ae(d, s); } - if(tab.tooltip) { + if (tab.tooltip) { a.onmouseover = (function(tooltip, e) { $WH.Tooltip.showAtCursor(e, tooltip, 0, 0, 'q'); }).bind(a, tab.tooltip); a.onmousemove = $WH.Tooltip.cursorUpdate; a.onmouseout = $WH.Tooltip.hide; @@ -3288,7 +4237,7 @@ Tabs.prototype = { this.tabs[index].tooltip = text; var _ = $WH.gE(this.uls[0], 'a'); - if(text == null) { + if (text == null) { _[index].onmouseover = _[index].onmousemove = _[index].onmouseout = null; } else { @@ -3331,7 +4280,7 @@ Tabs.onLoad = function() { var _ = location.hash.substr(1).split(':')[0]; if (_) { return $WH.in_array(this.tabs, _, function(x) { - if(!x.locked) { + if (!x.locked) { return x.id; } }); @@ -3837,7 +4786,7 @@ Listview.prototype = { if (this.mode == Listview.MODE_DIV) { this.mainContainer = this.mainDiv = $WH.ce('div'); - if(!this.noStyle) { + if (!this.noStyle) { this.mainContainer.className = 'listview-mode-div'; } } @@ -3851,7 +4800,7 @@ Listview.prototype = { } if (this.mode == Listview.MODE_TILED || this.mode == Listview.MODE_CALENDAR) { - if(!this.noStyle) + if (!this.noStyle) this.table.className = 'listview-mode-' + (this.mode == Listview.MODE_TILED ? 'tiled' : 'calendar'); var @@ -4238,7 +5187,7 @@ Listview.prototype = { this.createCbControls(div, topBar); } - if(div.firstChild) { // Not empty + if (div.firstChild) { // Not empty div.className = 'listview-withselected' + (topBar ? '' : '2'); } @@ -4276,7 +5225,7 @@ Listview.prototype = { if (this.nDaysPerMonth && this.nDaysPerMonth.length) { starti = 0; - for(var i = 0; i < this.rowOffset; ++i) { + for (var i = 0; i < this.rowOffset; ++i) { starti += this.nDaysPerMonth[i]; } endi = starti + this.nDaysPerMonth[i]; @@ -4366,7 +5315,7 @@ Listview.prototype = { else if (this.mode == Listview.MODE_CALENDAR) { var tr = $WH.ce('tr'); - for(var i = 0; i < 7; ++i) { + for (var i = 0; i < 7; ++i) { var th = $WH.ce('th'); $WH.st(th, LANG.date_days[i]); $WH.ae(tr, th); @@ -4392,7 +5341,7 @@ Listview.prototype = { } if (k != 0) { - for(; k < 7; ++k) { + for (; k < 7; ++k) { var foo = $WH.ce('td'); foo.className = 'empty-cell'; $WH.ae(tr, foo); @@ -5518,7 +6467,7 @@ Listview.sortIndexedRows = function(a, b) { for (var idx in sort) { _ = cols[Math.abs(sort[idx]) - 1]; - if(!_) { + if (!_) { _ = this.template; } @@ -6153,7 +7102,7 @@ Listview.extraCols = { a.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/tiny/' + g_achievements[item.achievement].icon.toLowerCase() + '.gif)'; a.style.whiteSpace = 'nowrap'; - $WH.st(a, g_achievements[item.achievement]['name_' + g_locale.name]); + $WH.st(a, g_achievements[item.achievement]['name_' + Locale.getName()]); $WH.ae(td, a); } }, @@ -6199,14 +7148,14 @@ Listview.extraCols = { a.style.fontFamily = 'Verdana, sans-serif'; a.href = '?item=' + row.yield; a.className = 'q' + g_items[row.yield].quality; - $WH.ae(a, $WH.ct(g_items[row.yield]['name_' + g_locale.name])); + $WH.ae(a, $WH.ct(g_items[row.yield]['name_' + Locale.getName()])); $WH.ae(wrapper, a); $WH.ae(td, wrapper); } }, getVisibleText: function(row) { if (row.yield && g_items[row.yield]) { - return g_items[row.yield]['name_' + g_locale.name]; + return g_items[row.yield]['name_' + Locale.getName()]; } }, sortFunc: function(a, b, col) { @@ -6214,7 +7163,7 @@ Listview.extraCols = { return (a.yield && g_items[a.yield] ? 1 : (b.yield && g_items[b.yield] ? -1 : 0)); } return -$WH.strcmp(g_items[a.yield].quality, g_items[b.yield].quality) || - $WH.strcmp(g_items[a.yield]['name_' + g_locale.name], g_items[b.yield]['name_' + g_locale.name]); + $WH.strcmp(g_items[a.yield]['name_' + Locale.getName()], g_items[b.yield]['name_' + Locale.getName()]); } }, @@ -6358,7 +7307,7 @@ Listview.extraCols = { cnd.color = cond.status ? 'q2' : 'q10'; cnd.links = [{ icon: item.icon.toLowerCase(), - name: item['name_' + g_locale.name], + name: item['name_' + Locale.getName()], url : '?skill=' + cond.typeId }]; @@ -6380,7 +7329,7 @@ Listview.extraCols = { cnd.color = cond.status ? 'q2' : 'q10'; cnd.links = [{ icon: item.icon.toLowerCase(), - name: item['name_' + g_locale.name], + name: item['name_' + Locale.getName()], url : '?spell=' + cond.typeId }]; @@ -6399,7 +7348,7 @@ Listview.extraCols = { cnd.color = cond.status ? 'q2' : 'q10'; cnd.links = [{ icon : item.icon.toLowerCase(), - name : item['name_' + g_locale.name], + name : item['name_' + Locale.getName()], url : '?item=' + cond.typeId, color: 'q' + item.quality }]; @@ -6419,7 +7368,7 @@ Listview.extraCols = { cnd.color = cond.status ? 'q2' : 'q10'; cnd.links = [{ icon: item.icon.toLowerCase(), - name: item['name_' + g_locale.name], + name: item['name_' + Locale.getName()], url : '?achievement=' + cond.typeId }]; @@ -6437,7 +7386,7 @@ Listview.extraCols = { cnd.state = $WH.ct((cond.status == 1 ? LANG.progress : (cond.status == 2 ? LANG.pr_note_complete : LANG.pr_note_incomplete)) + LANG.colon); cnd.color = cond.status == 1 ? 'q1' : cond.status == 2 ? 'q2' : 'q10'; cnd.links = [{ - name: item['name_' + g_locale.name], + name: item['name_' + Locale.getName()], url : '?quest=' + cond.typeId }]; @@ -6479,7 +7428,7 @@ Listview.extraCols = { cnd.color = cond.status == 1 ? 'q1' : cond.status == 2 ? 'q2' : 'q10'; cnd.links = [{ icon: item.icon.toLowerCase(), - name: item['name_' + g_locale.name], + name: item['name_' + Locale.getName()], url :'?event=' + cond.typeId }]; @@ -7118,7 +8067,7 @@ Listview.funcBox = { a.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/tiny/' + item.icon.toLowerCase() + '.gif)'; a.style.whiteSpace = 'nowrap'; - $WH.st(a, item['name_' + g_locale.name]); + $WH.st(a, item['name_' + Locale.getName()]); $WH.ae(sp, a); if (num > 1) { @@ -8494,7 +9443,7 @@ Listview.funcBox = { }, moneyCurrencyOver: function(currencyId, count, e) { - var buff = g_gatheredcurrencies[currencyId]['name_' + g_locale.name /*g_loc.getName()*/]; + var buff = g_gatheredcurrencies[currencyId]['name_' + Locale.getName() /*g_loc.getName()*/]; // justice / valor points handling removed @@ -9834,7 +10783,7 @@ Listview.templates = { if (npc.minlevel > 0 && npc.maxlevel > 0) { buff += ' '; - if(npc.maxlevel == 9999) { + if (npc.maxlevel == 9999) { buff += '??'; } else if (npc.minlevel != npc.maxlevel) { @@ -10269,7 +11218,7 @@ Listview.templates = { } if (quest.titlereward && g_titles[quest.titlereward]) { - var title = g_titles[quest.titlereward]['name_' + g_locale.name]; + var title = g_titles[quest.titlereward]['name_' + Locale.getName()]; title = title.replace('%s', '<' + LANG.name + '>'); var span = $WH.ce('a'); span.className = 'q1'; @@ -10290,7 +11239,7 @@ Listview.templates = { } if (quest.titlereward && g_titles[quest.titlereward]) { - buff += ' ' + g_titles[quest.titlereward]['name_' + g_locale.name]; + buff += ' ' + g_titles[quest.titlereward]['name_' + Locale.getName()]; } return buff; @@ -10298,8 +11247,8 @@ Listview.templates = { sortFunc: function(a, b, col) { var lenA = (a.itemchoices != null ? a.itemchoices.length : 0) + (a.itemrewards != null ? a.itemrewards.length : 0); var lenB = (b.itemchoices != null ? b.itemchoices.length : 0) + (b.itemrewards != null ? b.itemrewards.length : 0); - var titleA = (a.titlereward && g_titles[a.titlereward] ? g_titles[a.titlereward]['name_' + g_locale.name] : ''); - var titleB = (b.titlereward && g_titles[b.titlereward] ? g_titles[b.titlereward]['name_' + g_locale.name] : ''); + var titleA = (a.titlereward && g_titles[a.titlereward] ? g_titles[a.titlereward]['name_' + Locale.getName()] : ''); + var titleB = (b.titlereward && g_titles[b.titlereward] ? g_titles[b.titlereward]['name_' + Locale.getName()] : ''); return $WH.strcmp(lenA, lenB) || $WH.strcmp(titleA, titleB); } }, @@ -10329,7 +11278,7 @@ Listview.templates = { var buff = ''; for (var i = 0; quest.currencyrewards && i < quest.currencyrewards.length; ++i) { if (g_gatheredcurrencies[quest.currencyrewards[i][0]]) { - buff += ' ' + g_gatheredcurrencies[quest.currencyrewards[i][0]]['name_' + g_locale.name]; + buff += ' ' + g_gatheredcurrencies[quest.currencyrewards[i][0]]['name_' + Locale.getName()]; } } return buff; @@ -11221,7 +12170,7 @@ Listview.templates = { var item = g_spells[Math.abs(trigger)]; a.className = 'icontiny tinyspecial'; a.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/tiny/' + item['icon'] + '.gif)'; - $WH.st(a, item['name_' + g_locale.name]); + $WH.st(a, item['name_' + Locale.getName()]); } $WH.ae(td, a); @@ -11245,7 +12194,7 @@ Listview.templates = { buff += 'This'; } else { - buff += g_spells[Math.abs(trigger)]['name_' + g_locale.name]; + buff += g_spells[Math.abs(trigger)]['name_' + Locale.getName()]; } switch (spell.linked[2]) { @@ -11281,7 +12230,7 @@ Listview.templates = { return -1; } else if (trA != trB) { - return $WH.strcmp(g_spells[Math.abs(trA)]['name_' + g_locale.name], g_spells[Math.abs(trB)]['name_' + g_locale.name]); + return $WH.strcmp(g_spells[Math.abs(trA)]['name_' + Locale.getName()], g_spells[Math.abs(trB)]['name_' + Locale.getName()]); } return 0; @@ -11326,7 +12275,7 @@ Listview.templates = { var item = g_spells[Math.abs(effect)]; a.className = 'icontiny tinyspecial'; a.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/tiny/' + item['icon'] + '.gif)'; - $WH.st(a, item['name_' + g_locale.name]); + $WH.st(a, item['name_' + Locale.getName()]); } $WH.ae(td, a); @@ -11350,7 +12299,7 @@ Listview.templates = { buff += 'This'; } else { - buff += g_spells[Math.abs(effect)]['name_' + g_locale.name]; + buff += g_spells[Math.abs(effect)]['name_' + Locale.getName()]; } switch (spell.linked[2]) { @@ -11384,7 +12333,7 @@ Listview.templates = { return -1; } else if (effA != effB) { - return $WH.strcmp(g_spells[Math.abs(effA)]['name_' + g_locale.name], g_spells[Math.abs(effB)]['name_' + g_locale.name]); + return $WH.strcmp(g_spells[Math.abs(effA)]['name_' + Locale.getName()], g_spells[Math.abs(effB)]['name_' + Locale.getName()]); } return 0; @@ -11463,7 +12412,7 @@ Listview.templates = { a.className = zone.subzones[i] == zone.id ? 'q1' : 'q0'; a.style.whiteSpace = 'nowrap'; a.href = '?zone=' + zone.subzones[i]; - $WH.st(a, g_gatheredzones[zone.subzones[i]]['name_' + g_locale.name]); + $WH.st(a, g_gatheredzones[zone.subzones[i]]['name_' + Locale.getName()]); $WH.ae(d, a); } @@ -12996,7 +13945,7 @@ Listview.templates = { var spells = ''; for (var i = 0, len = pet.spells.length; i < len; ++i) { if (pet.spells[i]) { - spells += g_spells[pet.spells[i]]['name_' + g_locale.name]; + spells += g_spells[pet.spells[i]]['name_' + Locale.getName()]; } } return spells; @@ -13233,7 +14182,7 @@ Listview.templates = { a.href = '?item=' + itemrewards[i]; a.className = 'q' + item.quality + ' icontiny tinyspecial'; a.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/tiny/' + item.icon.toLowerCase() + '.gif)'; - $WH.ae(a, $WH.ct(item['name_' + g_locale.name])); + $WH.ae(a, $WH.ct(item['name_' + Locale.getName()])); var span = $WH.ce('span'); $WH.ae(span, a); $WH.ae(td, span); @@ -13251,7 +14200,7 @@ Listview.templates = { a.href = '?spell=' + spellrewards[i]; a.className = 'q8 icontiny tinyspecial'; a.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/tiny/' + item.icon.toLowerCase() + '.gif)'; - $WH.ae(a, $WH.ct(item['name_' + g_locale.name])); + $WH.ae(a, $WH.ct(item['name_' + Locale.getName()])); var span = $WH.ce('span'); $WH.ae(span, a); $WH.ae(td, span); @@ -13264,7 +14213,7 @@ Listview.templates = { return; } - var title = g_titles[titlerewards[i]]['name_' + g_locale.name]; + var title = g_titles[titlerewards[i]]['name_' + Locale.getName()]; title = title.replace('%s', '<' + LANG.name + '>'); var span = $WH.ce('a'); span.className = 'q1'; @@ -13287,13 +14236,13 @@ Listview.templates = { if (achievement.rewards) { for (var i = 0; i < achievement.rewards.length; i++) { if (achievement.rewards[i][0] == 11) { - buff += ' ' + g_titles[achievement.rewards[i][1]]['name_' + g_locale.name].replace('%s', '<' + LANG.name + '>'); + buff += ' ' + g_titles[achievement.rewards[i][1]]['name_' + Locale.getName()].replace('%s', '<' + LANG.name + '>'); } else if (achievement.rewards[i][0] == 3) { - buff += ' ' + g_items[achievement.rewards[i][1]]['name_' + g_locale.name]; + buff += ' ' + g_items[achievement.rewards[i][1]]['name_' + Locale.getName()]; } else if (achievement.rewards[i][0] == 6) { - buff += ' ' + g_spells[achievement.rewards[i][1]]['name_' + g_locale.name]; + buff += ' ' + g_spells[achievement.rewards[i][1]]['name_' + Locale.getName()]; } } } @@ -14678,7 +15627,7 @@ var Menu = new function() x.modifyUrl = json; }); - // uncomment with breadcrumbs PageTemplate.updateBreadcrumb(); + PageTemplate.updateBreadcrumb(); }; self.fixUrls = function(menu, url, opt) @@ -14911,9 +15860,6 @@ var Menu = new function() .delegate('a', 'mouseenter', { depth: depth }, menuItemOver) .delegate('a', 'click', menuItemClick); - if($WH.isset('g_thottbot') && g_thottbot) - $div.hide(); - $div.appendTo(document.body); divCache[depth] = $div; @@ -15464,10 +16410,6 @@ $(document).ready(function() // Locale is only known later }); var g_dev = false; -var g_locale = { - id: 0, - name: "enus" -}; var g_localTime = new Date(); var g_user = { id: 0, @@ -15475,14 +16417,6 @@ var g_user = { roles: 0 }; -var g_locales = { - 0: 'enus', - 2: 'frfr', - 3: 'dede', - 6: 'eses', - 8: 'ruru' -}; - /* Global Profiler-related functions */ @@ -15657,7 +16591,7 @@ var Icon = { displayIcon: function(icon) { if (!Dialog.templates.icondisplay) { var w = 364; - switch (g_locale.id) { + switch (Locale.getId()) { case 6: w = 380; break; @@ -15924,11 +16858,11 @@ var LiveSearch = new function() { function colorDiv(div, fromOver) { if (lastDiv) { - lastDiv.className = lastDiv.className.replace("live-search-selected", ""); + lastDiv.className = lastDiv.className.replace('live-search-selected', ''); } lastDiv = div; - lastDiv.className += " live-search-selected"; + lastDiv.className += ' live-search-selected'; selection = div.i; if (!fromOver) { @@ -15947,7 +16881,7 @@ var LiveSearch = new function() { return false; } - return container.style.display != "none"; + return container.style.display != 'none'; } function adjust(fromResize) { @@ -15972,30 +16906,30 @@ var LiveSearch = new function() { prepared = 1; - container = $WH.ce("div"); - container.className = "live-search"; - container.style.display = "none"; + container = $WH.ce('div'); + container.className = 'live-search'; + container.style.display = 'none'; - $WH.ae($WH.ge("layers"), container); - $WH.aE(window, "resize", adjust.bind(0, 1)); - $WH.aE(document, "click", hide); + $WH.ae($WH.ge('layers'), container); + $WH.aE(window, 'resize', adjust.bind(0, 1)); + $WH.aE(document, 'click', hide); } function show() { if (container && !isVisible()) { adjust(); - container.style.display = ""; + container.style.display = ''; } } function hide() { if (container) { - container.style.display = "none"; + container.style.display = 'none'; } } function highlight(match) { - return "" + match + ""; + return '' + match + ''; } function display(textbox, search, suggz, dataz) { @@ -16010,18 +16944,18 @@ var LiveSearch = new function() { } if (!$WH.Browser.ie6) { - $WH.ae(container, $WH.ce("em")); - $WH.ae(container, $WH.ce("var")); - $WH.ae(container, $WH.ce("strong")); + $WH.ae(container, $WH.ce('em')); + $WH.ae(container, $WH.ce('var')); + $WH.ae(container, $WH.ce('strong')); } - search = search.replace(/[^a-z0-9\-]/i, " "); - search = $WH.trim(search.replace(/\s+/g, " ")); + search = search.replace(/[^a-z0-9\-]/i, ' '); + search = $WH.trim(search.replace(/\s+/g, ' ')); var regex = g_createOrRegex(search); for (var i = 0, len = suggz.length; i < len; ++i) { - var pos = suggz[i].lastIndexOf("("); + var pos = suggz[i].lastIndexOf('('); if (pos != -1) { suggz[i] = suggz[i].substr(0, pos - 1); } @@ -16031,15 +16965,15 @@ var LiveSearch = new function() { typeId = dataz[i][1], param1 = dataz[i][2], param2 = dataz[i][3], - a = $WH.ce("a"), - sp = $WH.ce("i"), - sp2 = $WH.ce("span"), - div = $WH.ce("div"), - div2 = $WH.ce("div"); + a = $WH.ce('a'), + sp = $WH.ce('i'), + sp2 = $WH.ce('span'), + div = $WH.ce('div'), + div2 = $WH.ce('div'); div.i = i; a.onmouseover = aOver; - a.href = "?" + g_types[type] + "=" + typeId; + a.href = '?' + g_types[type] + '=' + typeId; if (textbox._append) { a.rel += textbox._append; @@ -16049,21 +16983,21 @@ var LiveSearch = new function() { div.className += ' live-search-icon-boss'; } if (type == 3 && param2 != null) { - a.className += " q" + param2; + a.className += ' q' + param2; } else if (type == 4 && param1 != null) { - a.className += " q" + param1; + a.className += ' q' + param1; } else if (type == 13) { a.className += ' c' + typeId; } if ((type == 3 || type == 6 || type == 9 || type == 10 || type == 13 || type == 14 || type == 15 || type == 17) && param1) { - div.className += " live-search-icon"; - div.style.backgroundImage = "url(" + g_staticUrl + "/images/wow/icons/small/" + param1.toLowerCase() + ".jpg)"; + div.className += ' live-search-icon'; + div.style.backgroundImage = 'url(' + g_staticUrl + '/images/wow/icons/small/' + param1.toLowerCase() + '.jpg)'; } else if ((type == 5 || type == 11) && param1 >= 1 && param1 <= 2) { - div.className += " live-search-icon-quest-" + (param1 == 1 ? "alliance" : "horde"); + div.className += ' live-search-icon-quest-' + (param1 == 1 ? 'alliance' : 'horde'); } $WH.ae(sp, $WH.ct(LANG.types[type][0])); @@ -16080,7 +17014,7 @@ var LiveSearch = new function() { $WH.ae(a, sp2); if (type == 6 && param2) { - $WH.ae(a, $WH.ct(" (" + param2 + ")")); + $WH.ae(a, $WH.ct(' (' + param2 + ')')); } $WH.ae(div2, a); @@ -16091,7 +17025,7 @@ var LiveSearch = new function() { function receive(xhr, opt) { var text = xhr.responseText; - if (text.charAt(0) != "[" || text.charAt(text.length - 1) != "]") { + if (text.charAt(0) != '[' || text.charAt(text.length - 1) != ']') { return; } @@ -16109,13 +17043,13 @@ var LiveSearch = new function() { } function fetch(textbox, search) { - var url = "?search=" + $WH.urlencode(search); + var url = '?search=' + $WH.urlencode(search); if (textbox._type) { - url += "&json&type=" + textbox._type; + url += '&json&type=' + textbox._type; } else { - url += "&opensearch"; + url += '&opensearch'; } new Ajax(url, { @@ -16182,7 +17116,7 @@ var LiveSearch = new function() { break; } - var search = $WH.trim(textbox.value.replace(/\s+/g, " ")); + var search = $WH.trim(textbox.value.replace(/\s+/g, ' ')); if (search == lastSearch[textbox.id]) { return; } @@ -16223,19 +17157,27 @@ var LiveSearch = new function() { } this.attach = function(textbox) { - if (textbox.getAttribute("autocomplete") == "off") { + textbox = $(textbox); + if (!textbox.length) { return; } - textbox.setAttribute("autocomplete", "off"); - $WH.aE(textbox, "focus", onFocus); - $WH.aE(textbox, "keyup", onKeyUp); - $WH.aE(textbox, "keydown", onKeyDown); + textbox = textbox[0]; + + if (textbox.getAttribute('autocomplete') == 'off') { + return; + } + + textbox.setAttribute('autocomplete', 'off'); + + $WH.aE(textbox, 'focus', onFocus); + $WH.aE(textbox, 'keyup', onKeyUp); + $WH.aE(textbox, 'keydown', onKeyDown); }; this.reset = function(textbox) { lastSearch[textbox.id] = null; - textbox.value = ""; + textbox.value = ''; hasData = 0; hide(); }; @@ -16411,8 +17353,7 @@ var LOCALE_ENUS = 0; var LOCALE_FRFR = 2; var LOCALE_DEDE = 3; var LOCALE_ESES = 6; -var LOCALE_RURU = 7; -var LOCALE_PTBR = 8; +var LOCALE_RURU = 8; var Locale = { @@ -16423,31 +17364,31 @@ var Locale = { 0: { // English id: LOCALE_ENUS, name: 'enus', - // domain: 'www.wowhead.com', + domain: 'www', description: 'English' }, 2: { // French id: LOCALE_FRFR, name: 'frfr', - // domain: 'fr.wowhead.com', + domain: 'fr', description: 'Fran' + String.fromCharCode(231) + 'ais' }, 3: { // German id: LOCALE_DEDE, name: 'dede', - // domain: 'de.wowhead.com', + domain: 'de', description: 'Deutsch' }, 6: { // Spanish id: LOCALE_ESES, name: 'eses', - // domain: 'es.wowhead.com', + domain: 'es', description: 'Espa' + String.fromCharCode(241) + 'ol' }, 8: { // Russian id: LOCALE_RURU, name: 'ruru', - // domain: 'ru.wowhead.com', + domain: 'ru', description: String.fromCharCode(1056, 1091, 1089, 1089, 1082, 1080, 1081) } }, @@ -16455,7 +17396,7 @@ var Locale = { getAll: function() { var result = []; - for(var id in Locale.locales) { + for (var id in Locale.locales) { result.push(Locale.locales[id]); } @@ -16494,8 +17435,7 @@ var Locale = { }; -// Locale.set(LOCALE_ENUS); // Default -Locale.set(g_locale.id); // Default +Locale.set(LOCALE_ENUS); // Default var ModelViewer = new function() { this.validSlots = [1,3,4,5,6,7,8,9,10,13,14,15,16,17,19,20,21,22,23,25,26]; @@ -17097,530 +18037,6 @@ var ModelViewer = new function() { DomContentLoaded.addEvent(this.checkPound) }; - -var g_screenshots = {}; -var ScreenshotViewer = new function() { - var - screenshots, - pos, - imgWidth, - imgHeight, - scale, - desiredScale, - oldHash, - mode = 0, - collectionId, - container, - screen, - imgDiv, - aPrev, - aNext, - aCover, - aOriginal, - divFrom, - divCaption, - loadingImage, - lightboxComponents; - - function computeDimensions(captionExtraHeight) { - var screenshot = screenshots[pos]; - - var availHeight = Math.max(50, Math.min(618, $WH.g_getWindowSize().h - 72 - captionExtraHeight)); - - if (mode != 1 || screenshot.id || screenshot.resize) { - desiredScale = Math.min(772 / screenshot.width, 618 / screenshot.height); - scale = Math.min(772 / screenshot.width, availHeight / screenshot.height); - } - else { - desiredScale = scale = 1; - } - - if (desiredScale > 1) { - desiredScale = 1; - } - - if (scale > 1) { - scale = 1; - } - - imgWidth = Math.round(scale * screenshot.width); - imgHeight = Math.round(scale * screenshot.height); - var lbWidth = Math.max(480, imgWidth); - - Lightbox.setSize(lbWidth + 20, imgHeight + 52 + captionExtraHeight); - - if ($WH.Browser.ie6) { - screen.style.width = lbWidth + 'px'; - if (screenshots.length > 1) { - aPrev.style.height = aNext.style.height = imgHeight + 'px' - } else { - aCover.style.height = imgHeight + 'px' - } - } - if (captionExtraHeight) { - imgDiv.firstChild.width = imgWidth; - imgDiv.firstChild.height = imgHeight; - } - } - - function getPound(pos) { - var - screenshot = screenshots[pos], - buff = '#screenshots:'; - - if (mode == 0) { - buff += 'id=' + screenshot.id; - } - else { - buff += collectionId + ':' + (pos + 1); - } - return buff; - } - - function render(resizing) { - if (resizing && (scale == desiredScale) && $WH.g_getWindowSize().h > container.offsetHeight) { - return; - } - container.style.visibility = 'hidden'; - var - screenshot = screenshots[pos], - resized = (screenshot.width > 772 || screenshot.height > 618); - - computeDimensions(0); - - var url = (screenshot.url ? screenshot.url: g_staticUrl + '/uploads/screenshots/' + (resized ? 'resized/': 'normal/') + screenshot.id + '.jpg'); - - var html = - ' 1); - - if (hasFrom1) { - var - postedOn = new Date(screenshot.date), - elapsed = (g_serverTime - postedOn) / 1000; - var a = divFrom.firstChild.childNodes[1]; - a.href = '?user=' + screenshot.user; - a.innerHTML = screenshot.user; - - var s = divFrom.firstChild.childNodes[3]; - $WH.ee(s); - Listview.funcBox.coFormatDate(s, elapsed, postedOn); - - divFrom.firstChild.style.display = ''; - } - else { - divFrom.firstChild.style.display = 'none'; - } - - var s = divFrom.childNodes[1]; - $WH.ee(s); - if (screenshot.user) { - if (hasFrom1) { - $WH.ae(s, $WH.ct(' ' + LANG.dash + ' ')); - } - var a = $WH.ce('a'); - a.href = 'javascript:;'; - a.onclick = ContactTool.show.bind(ContactTool, { - mode: 3, - screenshot: screenshot - }); - a.className = 'icon-report' - g_addTooltip(a, LANG.report_tooltip, 'q2'); - $WH.ae(a, $WH.ct(LANG.report)); - $WH.ae(s, a); - } - - s = divFrom.childNodes[2]; - - if (hasFrom2) { - var buff = ''; - if (screenshot.user) { - buff = LANG.dash; - } - buff += (pos + 1) + LANG.lvpage_of + screenshots.length; - - s.innerHTML = buff; - s.style.display = ''; - } - else { - s.style.display = 'none'; - } - - divFrom.style.display = (hasFrom1 || hasFrom2 ? '': 'none'); - - var hasCaption = (screenshot.caption != null && screenshot.caption.length); - var hasSubject = (screenshot.subject != null && screenshot.subject.length && screenshot.type && screenshot.typeId); - - if (hasCaption || hasSubject) { - var html = ''; - - if (hasSubject) { - html += LANG.types[screenshot.type][0] + LANG.colon; - html += ''; - html += screenshot.subject; - html += ''; - } - - if (hasCaption) { - if (hasSubject) { - html += LANG.dash; - } - html += (screenshot.noMarkup ? screenshot.caption : Markup.toHtml(screenshot.caption, { mode: Markup.MODE_SIGNATURE })); - } - - divCaption.innerHTML = html; - divCaption.style.display = ''; - } - else { - divCaption.style.display = 'none'; - } - - if (screenshots.length > 1) { - aPrev.href = getPound(peekPos(-1)); - aNext.href = getPound(peekPos(1)); - - aPrev.style.display = aNext.style.display = ''; - aCover.style.display = 'none'; - } - else { - aPrev.style.display = aNext.style.display = 'none'; - aCover.style.display = ''; - } - - location.replace(getPound(pos)); - } - - Lightbox.reveal(); - - if (divCaption.offsetHeight > 18) { - computeDimensions(divCaption.offsetHeight - 18); - } - container.style.visibility = 'visible'; - } - - function peekPos(change) { - var foo = pos; - foo += change; - - if (foo < 0) { - foo = screenshots.length - 1; - } - else if (foo >= screenshots.length) { - foo = 0; - } - - return foo; - } - - function prevScreenshot() { - pos = peekPos(-1); - onRender(); - - return false; - } - - function nextScreenshot() { - pos = peekPos(1); - onRender(); - - return false; - } - - function onKeyUp(e) { - e = $WH.$E(e); - switch (e.keyCode) { - case 37: // Left - prevScreenshot(); - break; - case 39: // Right - nextScreenshot(); - break; - } - } - - function onResize() { - render(1); - } - - function onHide() { - cancelImageLoading(); - - if (screenshots.length > 1) { - $WH.dE(document, 'keyup', onKeyUp); - } - - if (oldHash && mode == 0) { - if (oldHash.indexOf(':id=') != -1) { - oldHash = '#screenshots'; - } - location.replace(oldHash); - } - else { - location.replace('#.'); - } - } - - function onShow(dest, first, opt) { - if (typeof opt.screenshots == 'string') { - screenshots = g_screenshots[opt.screenshots]; - mode = 1; - collectionId = opt.screenshots; - } - else { - screenshots = opt.screenshots; - mode = 0; - collectionId = null; - } - container = dest; - - pos = 0; - if (opt.pos && opt.pos >= 0 && opt.pos < screenshots.length) { - pos = opt.pos; - } - - if (first) { - dest.className = 'screenshotviewer'; - - screen = $WH.ce('div'); - - screen.className = 'screenshotviewer-screen'; - - aPrev = $WH.ce('a'); - aNext = $WH.ce('a'); - aPrev.className = 'screenshotviewer-prev'; - aNext.className = 'screenshotviewer-next'; - aPrev.href = 'javascript:;'; - aNext.href = 'javascript:;'; - - var foo = $WH.ce('span'); - $WH.ae(foo, $WH.ce('b')); - // var b = $WH.ce('b'); - // $WH.ae(b, $WH.ct(LANG.previous)); - // $WH.ae(foo, b); - $WH.ae(aPrev, foo); - var foo = $WH.ce('span'); - $WH.ae(foo, $WH.ce('b')); - // var b = $WH.ce('b'); - // $WH.ae(b, $WH.ct(LANG.next)); - // $WH.ae(foo, b); - $WH.ae(aNext, foo); - - aPrev.onclick = prevScreenshot; - aNext.onclick = nextScreenshot; - - aCover = $WH.ce('a'); - aCover.className = 'screenshotviewer-cover'; - aCover.href = 'javascript:;'; - aCover.onclick = Lightbox.hide; - var foo = $WH.ce('span'); - $WH.ae(foo, $WH.ce('b')); - // var b = $WH.ce('b'); - // $WH.ae(b, $WH.ct(LANG.close)); - // $WH.ae(foo, b); - $WH.ae(aCover, foo); - if ($WH.Browser.ie6) { - $WH.ns(aPrev); - $WH.ns(aNext); - aPrev.onmouseover = aNext.onmouseover = aCover.onmouseover = function() { - this.firstChild.style.display = 'block'; - }; - aPrev.onmouseout = aNext.onmouseout = aCover.onmouseout = function() { - this.firstChild.style.display = ''; - }; - - } - $WH.ae(screen, aPrev); - $WH.ae(screen, aNext); - $WH.ae(screen, aCover); - - imgDiv = $WH.ce('div'); - $WH.ae(screen, imgDiv); - - $WH.ae(dest, screen); - - var aClose = $WH.ce('a'); - aClose.className = 'screenshotviewer-close'; - // aClose.className = 'dialog-x'; - aClose.href = 'javascript:;'; - aClose.onclick = Lightbox.hide; - $WH.ae(aClose, $WH.ce('span')); - // $WH.ae(aClose, $WH.ct(LANG.close)); - $WH.ae(dest, aClose); - - aOriginal = $WH.ce('a'); - aOriginal.className = 'screenshotviewer-original'; - // aOriginal.className = 'dialog-arrow'; - aOriginal.href = 'javascript:;'; - aOriginal.target = '_blank'; - $WH.ae(aOriginal, $WH.ce('span')); - // $WH.ae(aOriginal, $WH.ct(LANG.original)); - $WH.ae(dest, aOriginal); - - divFrom = $WH.ce('div'); - divFrom.className = 'screenshotviewer-from'; - var sp = $WH.ce('span'); - $WH.ae(sp, $WH.ct(LANG.lvscreenshot_from)); - $WH.ae(sp, $WH.ce('a')); - $WH.ae(sp, $WH.ct(' ')); - $WH.ae(sp, $WH.ce('span')); - $WH.ae(divFrom, sp); - $WH.ae(divFrom, $WH.ce('span')); - $WH.ae(divFrom, $WH.ce('span')); - $WH.ae(dest, divFrom); - - divCaption = $WH.ce('div'); - divCaption.className = 'screenshotviewer-caption'; - $WH.ae(dest, divCaption); - var d = $WH.ce('div'); - d.className = 'clear'; - $WH.ae(dest, d); - } - - oldHash = location.hash; - - if (screenshots.length > 1) { - $WH.aE(document, 'keyup', onKeyUp); - } - - onRender(); - } - - function onRender() { - var screenshot = screenshots[pos]; - if (!screenshot.width || !screenshot.height) { - if (loadingImage) { - loadingImage.onload = null; - loadingImage.onerror = null; - } - else { - container.className = ''; - lightboxComponents = []; - while (container.firstChild) { - lightboxComponents.push(container.firstChild); - $WH.de(container.firstChild); - } - } - - var lightboxTimer = setTimeout(function() { - screenshot.width = 126; - screenshot.height = 22; - computeDimensions(0); - screenshot.width = null; - screenshot.height = null; - - var div = $WH.ce('div'); - div.style.margin = '0 auto'; - div.style.width = '126px'; - var img = $WH.ce('img'); - img.src = g_staticUrl + '/images/ui/misc/progress-anim.gif'; - img.width = 126; - img.height = 22; - $WH.ae(div, img); - $WH.ae(container, div); - - Lightbox.reveal(); - container.style.visiblity = 'visible'; - }, 150); - - loadingImage = new Image(); - loadingImage.onload = (function(screen, timer) { - clearTimeout(timer); - screen.width = this.width; - screen.height = this.height; - loadingImage = null; - restoreLightbox(); - render(); - }).bind(loadingImage, screenshot, lightboxTimer); - loadingImage.onerror = (function(timer) { - clearTimeout(timer); - loadingImage = null; - Lightbox.hide(); - restoreLightbox(); - }).bind(loadingImage, lightboxTimer); - loadingImage.src = (screenshot.url ? screenshot.url : g_staticUrl + '/uploads/screenshots/normal/' + screenshot.id + '.jpg'); - } - else { - render(); - } - } - - function cancelImageLoading() { - if (!loadingImage) { - return; - } - - loadingImage.onload = null; - loadingImage.onerror = null; - loadingImage = null; - - restoreLightbox(); - } - - function restoreLightbox() { - if (!lightboxComponents) { - return; - } - - $WH.ee(container); - container.className = 'screenshotviewer'; - for (var i = 0; i < lightboxComponents.length; ++i) - $WH.ae(container, lightboxComponents[i]); - lightboxComponents = null; - } - - this.checkPound = function() { - if (location.hash && location.hash.indexOf('#screenshots') == 0) { - if (!g_listviews['screenshots']) { // Standalone screenshot viewer - var parts = location.hash.split(':'); - if (parts.length == 3) { - var - collection = g_screenshots[parts[1]], - p = parseInt(parts[2]); - - if (collection && p >= 1 && p <= collection.length) { - ScreenshotViewer.show({ - screenshots: parts[1], - pos: p - 1 - }); - } - } - } - } - } - - this.show = function(opt) { - Lightbox.show('screenshotviewer', { - onShow: onShow, - onHide: onHide, - onResize: onResize - }, opt); - } - - DomContentLoaded.addEvent(this.checkPound) -}; - // TODO: Create a "Cookies" object function g_cookiesEnabled() { @@ -17654,6 +18070,11 @@ function g_setWowheadCookie(name, data, browser) { } } +// Display a warning if a user attempts to leave the page and he has started writing a message +$(document).ready(function() { + g_setupChangeWarning($("form[name=addcomment]"), [$("textarea[name=commentbody]")], LANG.message_startedpost); +}); + var ContactTool = new function() { this.general = 0; this.comment = 1; diff --git a/static/js/petcalc.js b/static/js/petcalc.js index 6ce32dc4..4f7f1d0a 100644 --- a/static/js/petcalc.js +++ b/static/js/petcalc.js @@ -10,7 +10,7 @@ function pc_init() { _, clear; - g_initPath([1, 2]); + // PageTemplate.set({ breadcrumb: [1, 2] }); $WH.ge('pc-classes').className = 'choose'; @@ -97,7 +97,7 @@ function pc_onChange(tc, info, data) { _ = pc_classIcons[pc_classId]; _.className += ' iconmedium-gold-selected'; - g_initPath([1, 2, pc_classId]); + PageTemplate.set({ breadcrumb: [1, 2, pc_classId] }); } pc_build = tc.getWhBuild(); diff --git a/static/js/profile.js b/static/js/profile.js index 3c8ba614..ed5d49bd 100644 --- a/static/js/profile.js +++ b/static/js/profile.js @@ -582,20 +582,13 @@ function pr_addEquipButton(id, itemId) function pr_onBreadcrumbUpdate() // Add character lookup textbox to the breadcrumb { - // var breadcrumb = PageTemplate.get('breadcrumb'); - var breadcrumb = temp_path; - // end - + var breadcrumb = PageTemplate.get('breadcrumb'); if(!breadcrumb || breadcrumb.length != 6) // Realm is required return; var path = Menu.getFullPath(mn_path, breadcrumb); var menuItem = path[path.length - 1]; - - // var span = PageTemplate.expandBreadcrumb()[0]; - $('.path').children('span:last').addClass('breadcrumb-arrow'); - var span = ($('').appendTo($('.path')))[0]; - // end + var span = PageTemplate.expandBreadcrumb()[0]; var f = $WH.ce('form'), i = $WH.ce('input'), @@ -797,10 +790,5 @@ if($WH.isset('mn_profiles')) Menu.findItem(mn_path, [1,5,2])[MENU_IDX_SUB] = mn_guilds; Menu.findItem(mn_path, [1,5,3])[MENU_IDX_SUB] = mn_arenateams; - - // todo (low): understand and use pageTemplate - // PageTemplate.getBreadcrumb().bind('update', pr_onBreadcrumbUpdate); - DomContentLoaded.addEvent(function() { - pr_onBreadcrumbUpdate(); - }); + PageTemplate.getBreadcrumb().bind('update', pr_onBreadcrumbUpdate); } \ No newline at end of file diff --git a/static/js/talent.js b/static/js/talent.js index c1a216ad..c5a052d0 100644 --- a/static/js/talent.js +++ b/static/js/talent.js @@ -11,7 +11,7 @@ function tc_init() { _, clear; - g_initPath([1, 0]); + // PageTemplate.set({ breadcrumb: [1, 0] }); $WH.ge('tc-classes').className = 'choose'; @@ -88,7 +88,7 @@ function tc_onChange(tc, info, data) { _ = tc_classIcons[tc_classId]; _.className += ' iconmedium-gold-selected'; - g_initPath([1, 0, tc_classId]); + PageTemplate.set({ breadcrumb: [1, 0, tc_classId] }); } tc_build = tc.getWhBuild(); diff --git a/static/js/user.js b/static/js/user.js index fbb05901..ed047569 100644 --- a/static/js/user.js +++ b/static/js/user.js @@ -1,541 +1,541 @@ function us_isOwnProfile() { - return (typeof g_pageInfo == "object" && g_user.name == g_pageInfo.username) + return (typeof g_pageInfo == "object" && g_user.name == g_pageInfo.username) } function us_addDescription() { - var e = $WH.ge("description"); - var c = us_isOwnProfile(); - var f = (e.childNodes.length == 0); - if (f) { - if (c) { - $WH.ae(e, $WH.ct(LANG.user_nodescription2)) - } else { - $WH.ae(e, $WH.ct(LANG.user_nodescription)) - } - } - if (c) { - var a = $WH.ce("button"), - g = $WH.ce("div"); - g.className = "pad"; - a.onclick = function () { - location.href = "?account#community" - }; - if (f) { - $WH.ae(a, $WH.ct(LANG.user_composeone)) - } else { - $WH.ae(a, $WH.ct(LANG.user_editdescription)) - } - $WH.ae(e, g); - $WH.ae(e, a) - } + var e = $WH.ge("description"); + var c = us_isOwnProfile(); + var f = (e.childNodes.length == 0); + if (f) { + if (c) { + $WH.ae(e, $WH.ct(LANG.user_nodescription2)) + } else { + $WH.ae(e, $WH.ct(LANG.user_nodescription)) + } + } + if (c) { + var a = $WH.ce("button"), + g = $WH.ce("div"); + g.className = "pad"; + a.onclick = function () { + location.href = "?account#community" + }; + if (f) { + $WH.ae(a, $WH.ct(LANG.user_composeone)) + } else { + $WH.ae(a, $WH.ct(LANG.user_editdescription)) + } + $WH.ae(e, g); + $WH.ae(e, a) + } } function us_addCharactersTab(e) { - var c = (us_isOwnProfile() || g_user.roles & U_GROUP_MODERATOR); - if (!c) { - var b = []; - for (var d = 0, a = e.length; d < a; ++d) { - e[d].pinned = false; - if (e[d].published && !e[d].deleted) { - b.push(e[d]) - } - } - e = b - } - if (e.length) { - new Listview({ - template: "profile", - id: "characters", - name: LANG.tab_characters, - tabs: tabsRelated, - parent: "listview-generic", - onBeforeCreate: Listview.funcBox.beforeUserCharacters, - sort: [ - 11], - visibleCols: ["race", "classs", "level", "talents", "gearscore", "achievementpoints"], - data: e - }) - } + var c = (us_isOwnProfile() || g_user.roles & U_GROUP_MODERATOR); + if (!c) { + var b = []; + for (var d = 0, a = e.length; d < a; ++d) { + e[d].pinned = false; + if (e[d].published && !e[d].deleted) { + b.push(e[d]) + } + } + e = b + } + if (e.length) { + new Listview({ + template: "profile", + id: "characters", + name: LANG.tab_characters, + tabs: tabsRelated, + parent: "listview-generic", + onBeforeCreate: Listview.funcBox.beforeUserCharacters, + sort: [ - 11], + visibleCols: ["race", "classs", "level", "talents", "gearscore", "achievementpoints"], + data: e + }) + } } function us_addProfilesTab(e) { - var c = (us_isOwnProfile() || g_user.roles & U_GROUP_MODERATOR); - if (!c) { - var b = []; - for (var d = 0, a = e.length; d < a; ++d) { - if (e[d].published && !e[d].deleted) { - b.push(e[d]) - } - } - e = b - } - if (e.length) { - new Listview({ - template: "profile", - id: "profiles", - name: LANG.tab_profiles, - tabs: tabsRelated, - parent: "listview-generic", - onBeforeCreate: Listview.funcBox.beforeUserProfiles, - sort: [ - 11], - visibleCols: ["race", "classs", "level", "talents", "gearscore"], - hiddenCols: ["location", "guild"], - data: e - }) - } + var c = (us_isOwnProfile() || g_user.roles & U_GROUP_MODERATOR); + if (!c) { + var b = []; + for (var d = 0, a = e.length; d < a; ++d) { + if (e[d].published && !e[d].deleted) { + b.push(e[d]) + } + } + e = b + } + if (e.length) { + new Listview({ + template: "profile", + id: "profiles", + name: LANG.tab_profiles, + tabs: tabsRelated, + parent: "listview-generic", + onBeforeCreate: Listview.funcBox.beforeUserProfiles, + sort: [ - 11], + visibleCols: ["race", "classs", "level", "talents", "gearscore"], + hiddenCols: ["location", "guild"], + data: e + }) + } } Listview.funcBox.beforeUserComments = function () { - if (g_user.roles & U_GROUP_COMMENTS_MODERATOR) { - this.mode = 1; - this.createCbControls = function (b) { - var a = $WH.ce("input"); - a.type = "button"; - a.value = "Delete"; - a.onclick = (function () { - var e = this.getCheckedRows(); - if (!e.length) { - alert("No comments selected.") - } else { - if (confirm("Are you sure that you want to delete " + (e.length == 1 ? "this comment": "these " + e.length + " comments") + "?")) { - var c = ""; - var d = 0; - $WH.array_walk(e, function (f) { - if (!f.purged && !f.deleted) { - f.deleted = 1; - if (f.__tr != null) { - f.__tr.__status.innerHTML = LANG.lvcomment_deleted - } - c += f.id + "," - } else { - if (f.purged == 1) {++d - } - } - }); - c = $WH.rtrim(c, ","); - if (c != "") { - new Ajax("?comment=delete&id=" + c + "&username=" + g_pageInfo.username) - } (Listview.cbSelect.bind(this, false))(); - if (d > 0) { - alert("Purged comments cannot be deleted.\n\nA purged comment is a comment that has been\nautomatically removed from the site due to a negative rating.") - } - } - } - }).bind(this); - $WH.ae(b, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = "Undelete"; - a.onclick = (function () { - var d = this.getCheckedRows(); - if (!d.length) { - alert("No comments selected.") - } else { - var c = ""; - $WH.array_walk(d, function (e) { - if (e.deleted) { - e.deleted = 0; - if (e.__tr != null) { - e.__tr.__status.innerHTML = "" - } - c += e.id + "," - } - }); - c = $WH.rtrim(c, ","); - if (c != "") { - new Ajax("?comment=undelete&id=" + c + "&username=" + g_pageInfo.username) - } (Listview.cbSelect.bind(this, false))() - } - }).bind(this); - $WH.ae(b, a) - } - } - this.customFilter = function (b, a) { - return (g_user.roles & U_GROUP_COMMENTS_MODERATOR ? a < 250 : !(b.deleted || b.purged || b.removed)) - }; - this.onAfterCreate = function () { - if (this.nRowsVisible == 0) { - if (this.tabs.tabs.length == 1) { - $("#related, #tabs-related, #listview-generic").remove() - } else { - if (!this.tabs.tabs[this.tabIndex].hidden) { - this.tabs.hide(this.tabIndex, 0) - } - } - } else { - this.updateTabName() - } - } + if (g_user.roles & U_GROUP_COMMENTS_MODERATOR) { + this.mode = 1; + this.createCbControls = function (b) { + var a = $WH.ce("input"); + a.type = "button"; + a.value = "Delete"; + a.onclick = (function () { + var e = this.getCheckedRows(); + if (!e.length) { + alert("No comments selected.") + } else { + if (confirm("Are you sure that you want to delete " + (e.length == 1 ? "this comment": "these " + e.length + " comments") + "?")) { + var c = ""; + var d = 0; + $WH.array_walk(e, function (f) { + if (!f.purged && !f.deleted) { + f.deleted = 1; + if (f.__tr != null) { + f.__tr.__status.innerHTML = LANG.lvcomment_deleted + } + c += f.id + "," + } else { + if (f.purged == 1) {++d + } + } + }); + c = $WH.rtrim(c, ","); + if (c != "") { + new Ajax("?comment=delete&id=" + c + "&username=" + g_pageInfo.username) + } (Listview.cbSelect.bind(this, false))(); + if (d > 0) { + alert("Purged comments cannot be deleted.\n\nA purged comment is a comment that has been\nautomatically removed from the site due to a negative rating.") + } + } + } + }).bind(this); + $WH.ae(b, a); + var a = $WH.ce("input"); + a.type = "button"; + a.value = "Undelete"; + a.onclick = (function () { + var d = this.getCheckedRows(); + if (!d.length) { + alert("No comments selected.") + } else { + var c = ""; + $WH.array_walk(d, function (e) { + if (e.deleted) { + e.deleted = 0; + if (e.__tr != null) { + e.__tr.__status.innerHTML = "" + } + c += e.id + "," + } + }); + c = $WH.rtrim(c, ","); + if (c != "") { + new Ajax("?comment=undelete&id=" + c + "&username=" + g_pageInfo.username) + } (Listview.cbSelect.bind(this, false))() + } + }).bind(this); + $WH.ae(b, a) + } + } + this.customFilter = function (b, a) { + return (g_user.roles & U_GROUP_COMMENTS_MODERATOR ? a < 250 : !(b.deleted || b.purged || b.removed)) + }; + this.onAfterCreate = function () { + if (this.nRowsVisible == 0) { + if (this.tabs.tabs.length == 1) { + $("#related, #tabs-related, #listview-generic").remove() + } else { + if (!this.tabs.tabs[this.tabIndex].hidden) { + this.tabs.hide(this.tabIndex, 0) + } + } + } else { + this.updateTabName() + } + } }; Listview.funcBox.beforeUserCharacters = function () { - var a = (us_isOwnProfile() || (g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU))); - if (a) { - this.mode = 1; - this.createCbControls = function (e, c) { - if (!c && this.data.length < 15) { - return - } - var b = $WH.ce("input"); - b.type = "button"; - b.value = LANG.button_remove; - b.onclick = (function () { - var f = this.getCheckedRows(); - if (!f.length) { - alert(LANG.message_nocharacterselected) - } else { - if (confirm(LANG.confirm_unlinkcharacter)) { - var d = ""; - $WH.array_walk(f, function (g) { - d += g.id + "," - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?profile=unlink&id=" + d + "&user=" + g_pageInfo.username) - } - this.deleteRows(f) - } - } - }).bind(this); - $WH.ae(e, b); - var b = $WH.ce("input"); - b.type = "button"; - b.value = LANG.button_makepub; - b.onclick = (function () { - var f = this.getCheckedRows(); - if (!f.length) { - alert(LANG.message_noprofileselected) - } else { - if (confirm(LANG.confirm_publicprofile)) { - var d = ""; - $WH.array_walk(f, function (g) { - if (!g.published) { - g.published = 1; - if (g.__tr != null) { - g.__tr.__status.innerHTML = "" - } - d += g.id + "," - } - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?profile=public&id=" + d + "&user=" + g_pageInfo.username + "&bookmarked") - } (Listview.cbSelect.bind(this, false))() - } - } - }).bind(this); - $WH.ae(e, b); - var b = $WH.ce("input"); - b.type = "button"; - b.value = LANG.button_makepriv; - b.onclick = (function () { - var f = this.getCheckedRows(); - if (!f.length) { - alert(LANG.message_noprofileselected) - } else { - if (confirm(LANG.confirm_privateprofile)) { - var d = ""; - $WH.array_walk(f, function (g) { - if (g.published) { - g.published = 0; - if (g.__tr != null) { - g.__tr.__status.innerHTML = LANG.privateprofile - } - d += g.id + "," - } - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?profile=private&id=" + d + "&user=" + g_pageInfo.username + "&bookmarked") - } (Listview.cbSelect.bind(this, false))() - } - } - }).bind(this); - $WH.ae(e, b); - var b = $WH.ce("input"); - b.type = "button"; - b.value = LANG.button_pin; - b.onclick = (function () { - var f = this.getCheckedRows(); - if (!f.length) { - alert(LANG.message_nocharacterselected) - } else { - if (f.length > 1) { - alert(LANG.message_toomanycharacters) - } else { - if (confirm(LANG.confirm_pincharacter)) { - var d = []; - $WH.array_walk(f, function (g) { - d.push(g.id) - }); - $WH.array_walk(this.data, function (g) { - g.pinned = ($WH.in_array(d, g.id) != -1); - if (g.__tr != null) { - var h = $WH.gE(g.__tr, "a")[1]; - h.className = (g.pinned ? "icon-star-right": "") - } - }); - d = d.join(","); - if (d != "") { - new Ajax("?profile=pin&id=" + d + "&user=" + g_pageInfo.username) - } (Listview.cbSelect.bind(this, false))() - } - } - } - }).bind(this); - $WH.ae(e, b); - var b = $WH.ce("input"); - b.type = "button"; - b.value = LANG.button_unpin; - b.onclick = (function () { - var f = this.getCheckedRows(); - if (!f.length) { - alert(LANG.message_nocharacterselected) - } else { - if (confirm(LANG.confirm_unpincharacter)) { - var d = []; - $WH.array_walk(f, function (g) { - d.push(g.id) - }); - $WH.array_walk(this.data, function (g) { - g.pinned = ($WH.in_array(d, g.id) == -1); - if (g.__tr != null) { - var h = $WH.gE(g.__tr, "a")[1]; - h.className = (g.pinned ? "icon-star-right": "") - } - }); - d = d.join(","); - if (d != "") { - new Ajax("?profile=unpin&id=" + d + "&user=" + g_pageInfo.username) - } (Listview.cbSelect.bind(this, false))() - } - } - }).bind(this); - $WH.ae(e, b); - if (g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU)) { - var b = $WH.ce("input"); - b.type = "button"; - b.value = LANG.button_resync; - b.onclick = (function () { - var f = this.getCheckedRows(); - if (!f.length) { - alert(LANG.message_nocharacterselected) - } else { - var d = ""; - $WH.array_walk(f, function (h) { - d += h.id + "," - }); - d = $WH.rtrim(d, ","); - if (d != "") { - var g = $WH.ge("roster-status"); - g.innerHTML = LANG.pr_queue_addqueue; - g.style.display = ""; - new Ajax("?profile=resync&id=" + d, { - method: "POST", - onSuccess: function (j, h) { - var i = parseInt(j.responseText); - if (isNaN(i)) { - alert(LANG.message_resyncerror + i) - } else { - if (i < 0 && i != -102) { - alert(LANG.message_resyncerror + "#" + i) - } - } - pr_updateStatus("profile", g, d, true) - } - }) - } (Listview.cbSelect.bind(this, false))() - } - }).bind(this); - $WH.ae(e, b) - } - } - } + var a = (us_isOwnProfile() || (g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU))); + if (a) { + this.mode = 1; + this.createCbControls = function (e, c) { + if (!c && this.data.length < 15) { + return + } + var b = $WH.ce("input"); + b.type = "button"; + b.value = LANG.button_remove; + b.onclick = (function () { + var f = this.getCheckedRows(); + if (!f.length) { + alert(LANG.message_nocharacterselected) + } else { + if (confirm(LANG.confirm_unlinkcharacter)) { + var d = ""; + $WH.array_walk(f, function (g) { + d += g.id + "," + }); + d = $WH.rtrim(d, ","); + if (d != "") { + new Ajax("?profile=unlink&id=" + d + "&user=" + g_pageInfo.username) + } + this.deleteRows(f) + } + } + }).bind(this); + $WH.ae(e, b); + var b = $WH.ce("input"); + b.type = "button"; + b.value = LANG.button_makepub; + b.onclick = (function () { + var f = this.getCheckedRows(); + if (!f.length) { + alert(LANG.message_noprofileselected) + } else { + if (confirm(LANG.confirm_publicprofile)) { + var d = ""; + $WH.array_walk(f, function (g) { + if (!g.published) { + g.published = 1; + if (g.__tr != null) { + g.__tr.__status.innerHTML = "" + } + d += g.id + "," + } + }); + d = $WH.rtrim(d, ","); + if (d != "") { + new Ajax("?profile=public&id=" + d + "&user=" + g_pageInfo.username + "&bookmarked") + } (Listview.cbSelect.bind(this, false))() + } + } + }).bind(this); + $WH.ae(e, b); + var b = $WH.ce("input"); + b.type = "button"; + b.value = LANG.button_makepriv; + b.onclick = (function () { + var f = this.getCheckedRows(); + if (!f.length) { + alert(LANG.message_noprofileselected) + } else { + if (confirm(LANG.confirm_privateprofile)) { + var d = ""; + $WH.array_walk(f, function (g) { + if (g.published) { + g.published = 0; + if (g.__tr != null) { + g.__tr.__status.innerHTML = LANG.privateprofile + } + d += g.id + "," + } + }); + d = $WH.rtrim(d, ","); + if (d != "") { + new Ajax("?profile=private&id=" + d + "&user=" + g_pageInfo.username + "&bookmarked") + } (Listview.cbSelect.bind(this, false))() + } + } + }).bind(this); + $WH.ae(e, b); + var b = $WH.ce("input"); + b.type = "button"; + b.value = LANG.button_pin; + b.onclick = (function () { + var f = this.getCheckedRows(); + if (!f.length) { + alert(LANG.message_nocharacterselected) + } else { + if (f.length > 1) { + alert(LANG.message_toomanycharacters) + } else { + if (confirm(LANG.confirm_pincharacter)) { + var d = []; + $WH.array_walk(f, function (g) { + d.push(g.id) + }); + $WH.array_walk(this.data, function (g) { + g.pinned = ($WH.in_array(d, g.id) != -1); + if (g.__tr != null) { + var h = $WH.gE(g.__tr, "a")[1]; + h.className = (g.pinned ? "icon-star-right": "") + } + }); + d = d.join(","); + if (d != "") { + new Ajax("?profile=pin&id=" + d + "&user=" + g_pageInfo.username) + } (Listview.cbSelect.bind(this, false))() + } + } + } + }).bind(this); + $WH.ae(e, b); + var b = $WH.ce("input"); + b.type = "button"; + b.value = LANG.button_unpin; + b.onclick = (function () { + var f = this.getCheckedRows(); + if (!f.length) { + alert(LANG.message_nocharacterselected) + } else { + if (confirm(LANG.confirm_unpincharacter)) { + var d = []; + $WH.array_walk(f, function (g) { + d.push(g.id) + }); + $WH.array_walk(this.data, function (g) { + g.pinned = ($WH.in_array(d, g.id) == -1); + if (g.__tr != null) { + var h = $WH.gE(g.__tr, "a")[1]; + h.className = (g.pinned ? "icon-star-right": "") + } + }); + d = d.join(","); + if (d != "") { + new Ajax("?profile=unpin&id=" + d + "&user=" + g_pageInfo.username) + } (Listview.cbSelect.bind(this, false))() + } + } + }).bind(this); + $WH.ae(e, b); + if (g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU)) { + var b = $WH.ce("input"); + b.type = "button"; + b.value = LANG.button_resync; + b.onclick = (function () { + var f = this.getCheckedRows(); + if (!f.length) { + alert(LANG.message_nocharacterselected) + } else { + var d = ""; + $WH.array_walk(f, function (h) { + d += h.id + "," + }); + d = $WH.rtrim(d, ","); + if (d != "") { + var g = $WH.ge("roster-status"); + g.innerHTML = LANG.pr_queue_addqueue; + g.style.display = ""; + new Ajax("?profile=resync&id=" + d, { + method: "POST", + onSuccess: function (j, h) { + var i = parseInt(j.responseText); + if (isNaN(i)) { + alert(LANG.message_resyncerror + i) + } else { + if (i < 0 && i != -102) { + alert(LANG.message_resyncerror + "#" + i) + } + } + pr_updateStatus("profile", g, d, true) + } + }) + } (Listview.cbSelect.bind(this, false))() + } + }).bind(this); + $WH.ae(e, b) + } + } + } }; Listview.funcBox.beforeUserProfiles = function () { - if (us_isOwnProfile()) { - this.mode = 1; - this.createCbControls = function (c, b) { - if (!b && this.data.length < 15) { - return - } - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_new; - a.onclick = function () { - document.location.href = "?profile&new" - }; - $WH.ae(c, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_delete; - a.onclick = (function () { - var e = this.getCheckedRows(); - if (!e.length) { - alert(LANG.message_noprofileselected) - } else { - if (confirm(LANG.confirm_deleteprofile)) { - var d = ""; - $WH.array_walk(e, function (f) { - d += f.id + "," - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?profile=delete&id=" + d) - } - this.deleteRows(e) - } - } - }).bind(this); - $WH.ae(c, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_makepub; - a.onclick = (function () { - var e = this.getCheckedRows(); - if (!e.length) { - alert(LANG.message_noprofileselected) - } else { - if (confirm(LANG.confirm_publicprofile)) { - var d = ""; - $WH.array_walk(e, function (f) { - if (!f.published) { - f.published = 1; - if (f.__tr != null) { - f.__tr.__status.innerHTML = "" - } - d += f.id + "," - } - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?profile=public&id=" + d) - } (Listview.cbSelect.bind(this, false))() - } - } - }).bind(this); - $WH.ae(c, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_makepriv; - a.onclick = (function () { - var e = this.getCheckedRows(); - if (!e.length) { - alert(LANG.message_noprofileselected) - } else { - if (confirm(LANG.confirm_privateprofile)) { - var d = ""; - $WH.array_walk(e, function (f) { - if (f.published) { - f.published = 0; - if (f.__tr != null) { - f.__tr.__status.innerHTML = LANG.privateprofile - } - d += f.id + "," - } - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?profile=private&id=" + d) - } (Listview.cbSelect.bind(this, false))() - } - } - }).bind(this); - $WH.ae(c, a) - } - } + if (us_isOwnProfile()) { + this.mode = 1; + this.createCbControls = function (c, b) { + if (!b && this.data.length < 15) { + return + } + var a = $WH.ce("input"); + a.type = "button"; + a.value = LANG.button_new; + a.onclick = function () { + document.location.href = "?profile&new" + }; + $WH.ae(c, a); + var a = $WH.ce("input"); + a.type = "button"; + a.value = LANG.button_delete; + a.onclick = (function () { + var e = this.getCheckedRows(); + if (!e.length) { + alert(LANG.message_noprofileselected) + } else { + if (confirm(LANG.confirm_deleteprofile)) { + var d = ""; + $WH.array_walk(e, function (f) { + d += f.id + "," + }); + d = $WH.rtrim(d, ","); + if (d != "") { + new Ajax("?profile=delete&id=" + d) + } + this.deleteRows(e) + } + } + }).bind(this); + $WH.ae(c, a); + var a = $WH.ce("input"); + a.type = "button"; + a.value = LANG.button_makepub; + a.onclick = (function () { + var e = this.getCheckedRows(); + if (!e.length) { + alert(LANG.message_noprofileselected) + } else { + if (confirm(LANG.confirm_publicprofile)) { + var d = ""; + $WH.array_walk(e, function (f) { + if (!f.published) { + f.published = 1; + if (f.__tr != null) { + f.__tr.__status.innerHTML = "" + } + d += f.id + "," + } + }); + d = $WH.rtrim(d, ","); + if (d != "") { + new Ajax("?profile=public&id=" + d) + } (Listview.cbSelect.bind(this, false))() + } + } + }).bind(this); + $WH.ae(c, a); + var a = $WH.ce("input"); + a.type = "button"; + a.value = LANG.button_makepriv; + a.onclick = (function () { + var e = this.getCheckedRows(); + if (!e.length) { + alert(LANG.message_noprofileselected) + } else { + if (confirm(LANG.confirm_privateprofile)) { + var d = ""; + $WH.array_walk(e, function (f) { + if (f.published) { + f.published = 0; + if (f.__tr != null) { + f.__tr.__status.innerHTML = LANG.privateprofile + } + d += f.id + "," + } + }); + d = $WH.rtrim(d, ","); + if (d != "") { + new Ajax("?profile=private&id=" + d) + } (Listview.cbSelect.bind(this, false))() + } + } + }).bind(this); + $WH.ae(c, a) + } + } }; Listview.funcBox.beforeUserSignatures = function () { - if (us_isOwnProfile()) { - this.mode = 1; - this.createCbControls = function (c, b) { - if (!b && this.data.length < 15) { - return - } - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_delete; - a.onclick = (function () { - var e = this.getCheckedRows(); - if (!e.length) { - alert(LANG.message_nosignatureselected) - } else { - if (confirm(LANG.confirm_deletesignature)) { - var d = ""; - $WH.array_walk(e, function (f) { - d += f.id + "," - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?signature=delete&id=" + d) - } - this.deleteRows(e); - this.resetCheckedRows(); - this.refreshRows() - } - } - }).bind(this); - $WH.ae(c, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_edit; - a.onclick = (function () { - var d = this.getCheckedRows(); - if (!d.length) { - alert(LANG.message_nosignatureselected) - } else { - if (d.length > 1) { - alert(LANG.message_toomanysignatures) - } else { - document.location.href = "?signature=" + d[0].id - } - } - }).bind(this); - $WH.ae(c, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_markup; - a.onclick = (function () { - var d = this.getCheckedRows(); - if (!d.length) { - alert(LANG.message_nosignatureselected) - } else { - if (d.length > 1) { - alert(LANG.message_toomanysignatures) - } else { - prompt(LANG.prompt_signaturemarkup, "[url=" + this.getItemLink(d[0]) + "][sig=" + d[0].id + "][/url]") - } - } - }).bind(this); - $WH.ae(c, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_link; - a.onclick = (function () { - var d = this.getCheckedRows(); - if (!d.length) { - alert(LANG.message_nosignatureselected) - } else { - if (d.length > 1) { - alert(LANG.message_toomanysignatures) - } else { - prompt(LANG.prompt_signaturedirect, "http://" + location.host + "?signature=generate&id=" + d[0].id + ".png") - } - } - }).bind(this); - $WH.ae(c, a) - } - } + if (us_isOwnProfile()) { + this.mode = 1; + this.createCbControls = function (c, b) { + if (!b && this.data.length < 15) { + return + } + var a = $WH.ce("input"); + a.type = "button"; + a.value = LANG.button_delete; + a.onclick = (function () { + var e = this.getCheckedRows(); + if (!e.length) { + alert(LANG.message_nosignatureselected) + } else { + if (confirm(LANG.confirm_deletesignature)) { + var d = ""; + $WH.array_walk(e, function (f) { + d += f.id + "," + }); + d = $WH.rtrim(d, ","); + if (d != "") { + new Ajax("?signature=delete&id=" + d) + } + this.deleteRows(e); + this.resetCheckedRows(); + this.refreshRows() + } + } + }).bind(this); + $WH.ae(c, a); + var a = $WH.ce("input"); + a.type = "button"; + a.value = LANG.button_edit; + a.onclick = (function () { + var d = this.getCheckedRows(); + if (!d.length) { + alert(LANG.message_nosignatureselected) + } else { + if (d.length > 1) { + alert(LANG.message_toomanysignatures) + } else { + document.location.href = "?signature=" + d[0].id + } + } + }).bind(this); + $WH.ae(c, a); + var a = $WH.ce("input"); + a.type = "button"; + a.value = LANG.button_markup; + a.onclick = (function () { + var d = this.getCheckedRows(); + if (!d.length) { + alert(LANG.message_nosignatureselected) + } else { + if (d.length > 1) { + alert(LANG.message_toomanysignatures) + } else { + prompt(LANG.prompt_signaturemarkup, "[url=" + this.getItemLink(d[0]) + "][sig=" + d[0].id + "][/url]") + } + } + }).bind(this); + $WH.ae(c, a); + var a = $WH.ce("input"); + a.type = "button"; + a.value = LANG.button_link; + a.onclick = (function () { + var d = this.getCheckedRows(); + if (!d.length) { + alert(LANG.message_nosignatureselected) + } else { + if (d.length > 1) { + alert(LANG.message_toomanysignatures) + } else { + prompt(LANG.prompt_signaturedirect, "http://" + location.host + "?signature=generate&id=" + d[0].id + ".png") + } + } + }).bind(this); + $WH.ae(c, a) + } + } }; Listview.extraCols.signature = { - id: "signature", - name: LANG.signature, - before: "name", - align: "left", - compute: function (d, e, c) { - var b = $WH.ce("a"); - b.style.fontFamily = "Verdana, sans-serif"; - b.href = this.getItemLink(d); - b.rel = "np"; - $WH.ae(b, $WH.ce("img", { - src: "?signature=generate&id=" + d.id + ".png", - height: 60, - width: 468 - })); - $WH.ae(e, b) - } + id: "signature", + name: LANG.signature, + before: "name", + align: "left", + compute: function (d, e, c) { + var b = $WH.ce("a"); + b.style.fontFamily = "Verdana, sans-serif"; + b.href = this.getItemLink(d); + b.rel = "np"; + $WH.ae(b, $WH.ce("img", { + src: "?signature=generate&id=" + d.id + ".png", + height: 60, + width: 468 + })); + $WH.ae(e, b) + } }; \ No newline at end of file diff --git a/template/bricks/announcement.tpl.php b/template/bricks/announcement.tpl.php index 81ae4f68..4bc35f00 100644 --- a/template/bricks/announcement.tpl.php +++ b/template/bricks/announcement.tpl.php @@ -1,19 +1,19 @@ announcements as $_): ?> -
    - + }); + \ No newline at end of file diff --git a/template/bricks/community.tpl.php b/template/bricks/community.tpl.php deleted file mode 100644 index 4f51e84f..00000000 --- a/template/bricks/community.tpl.php +++ /dev/null @@ -1,3 +0,0 @@ - var lv_comments = community['co'], JSON_NUMERIC_CHECK); ?>; - var lv_screenshots = community['sc'], JSON_NUMERIC_CHECK); ?>; - var lv_videos = community['vi'], JSON_NUMERIC_CHECK); ?>; diff --git a/template/bricks/head.tpl.php b/template/bricks/head.tpl.php index 2a953425..dc805910 100644 --- a/template/bricks/head.tpl.php +++ b/template/bricks/head.tpl.php @@ -44,6 +44,5 @@ foreach ($this->js as $js): endforeach; ?> diff --git a/template/bricks/header.tpl.php b/template/bricks/header.tpl.php index 6f95665c..d19fb61c 100644 --- a/template/bricks/header.tpl.php +++ b/template/bricks/header.tpl.php @@ -31,8 +31,6 @@ +| diff --git a/template/bricks/pageTemplate.tpl.php b/template/bricks/pageTemplate.tpl.php new file mode 100644 index 00000000..a3f78c4e --- /dev/null +++ b/template/bricks/pageTemplate.tpl.php @@ -0,0 +1,32 @@ + + diff --git a/template/pages/acc-dashboard.tpl.php b/template/pages/acc-dashboard.tpl.php index 3e43b50c..e8cababa 100644 --- a/template/pages/acc-dashboard.tpl.php +++ b/template/pages/acc-dashboard.tpl.php @@ -4,7 +4,11 @@
    -brick('announcement'); ?> +brick('announcement'); + + $this->brick('pageTemplate'); +?> diff --git a/template/pages/acc-recover.tpl.php b/template/pages/acc-recover.tpl.php index ce55ce68..56965225 100644 --- a/template/pages/acc-recover.tpl.php +++ b/template/pages/acc-recover.tpl.php @@ -3,6 +3,7 @@
    +brick('pageTemplate'); ?>
    text)): ?>
    diff --git a/template/pages/acc-signIn.tpl.php b/template/pages/acc-signIn.tpl.php index 9fdbe85d..dd8685b5 100644 --- a/template/pages/acc-signIn.tpl.php +++ b/template/pages/acc-signIn.tpl.php @@ -3,6 +3,7 @@
    +brick('pageTemplate'); ?>
    + $this->brick('announcement'); -brick('infobox', ['series' => $this->series]); ?> + $this->brick('pageTemplate'); + + $this->brick('infobox'); +?>
    filter; // shorthand
    -brick('announcement'); ?> - -
    diff --git a/template/pages/compare.tpl.php b/template/pages/compare.tpl.php index 7f7bf87a..054392fe 100644 --- a/template/pages/compare.tpl.php +++ b/template/pages/compare.tpl.php @@ -4,9 +4,12 @@
    -brick('announcement'); ?> +brick('announcement'); + + $this->brick('pageTemplate'); +?> -
    + $this->brick('announcement'); -brick('infobox'); ?> + $this->brick('pageTemplate'); + + $this->brick('infobox'); +?>
    -brick('announcement'); ?> - - + $this->brick('announcement'); -brick('infobox'); ?> + $this->brick('pageTemplate'); + + $this->brick('infobox'); +?>
    brick('redButtons'); ?> diff --git a/template/pages/items.tpl.php b/template/pages/items.tpl.php index 5017a2b3..9b322fb1 100644 --- a/template/pages/items.tpl.php +++ b/template/pages/items.tpl.php @@ -7,16 +7,11 @@ $f = $this->filter; // shorthand
    -brick('announcement'); ?> - -
    diff --git a/template/pages/itemset.tpl.php b/template/pages/itemset.tpl.php index 45533e00..8dab5951 100644 --- a/template/pages/itemset.tpl.php +++ b/template/pages/itemset.tpl.php @@ -4,17 +4,13 @@
    -brick('announcement'); ?> - - + $this->brick('announcement'); -brick('infobox'); ?> + $this->brick('pageTemplate'); + + $this->brick('infobox'); +?>
    filter; // shorthand
    -brick('announcement'); ?> - -
    diff --git a/template/pages/list-page-generic.tpl.php b/template/pages/list-page-generic.tpl.php index 437231e5..c112abc5 100644 --- a/template/pages/list-page-generic.tpl.php +++ b/template/pages/list-page-generic.tpl.php @@ -8,13 +8,9 @@ $this->brick('announcement'); $this->brick('mapper'); -?> - + $this->brick('pageTemplate'); -name) || !empty($this->h1Links)): echo '
    ' . (!empty($this->h1Links) ? '' : null) . diff --git a/template/pages/main.tpl.php b/template/pages/main.tpl.php index bf5c91d5..9681e201 100644 --- a/template/pages/main.tpl.php +++ b/template/pages/main.tpl.php @@ -52,6 +52,7 @@ endif; +brick('pageTemplate'); ?>