minor beautifications for compare

This commit is contained in:
Sarjuuk
2013-01-20 00:06:34 +01:00
parent e67d0a3dae
commit faabdee2a6
3 changed files with 51 additions and 47 deletions

View File

@@ -7,11 +7,9 @@ require_once('includes/class.item.php');
require_once('includes/class.spell.php');
require_once('includes/class.faction.php'); // items may require a faction to use/own
// prefer $_GET over $_COOKIE
$compareString = '';
$doneSummary = '';
$pageData['items'] = array();
// prefer $_GET over $_COOKIE
if (!empty($_GET['compare']))
$compareString = $_GET['compare'];
else if (!empty($_COOKIE['compare_groups']))
@@ -47,7 +45,7 @@ if ($compareString)
}
$outSet[] = "[".implode(',', $outString)."]";
}
$doneSummary = implode(',', $outSet);
$pageData['summary'] = "[".implode(',', $outSet)."]";
$iList = new ItemList(array(['i.entry', $items]));
foreach ($iList->container as $item)
@@ -61,12 +59,16 @@ if ($compareString)
if ($v)
$stats[] = '"'.Util::$itemMods[$k].'":'.$v;
$pageData['items'][] = "g_items.add(".$item->json['id'].", {name_".User::$localeString.":'".Util::jsEscape(Util::localizedString($item->template, 'name'))."', quality:".$item->template['Quality'].", icon:'".$item->template['icon']."', jsonequip:{".implode(",", $stats)."}});";
$pageData['items'][] = [
$item->Id,
Util::jsEscape(Util::localizedString($item->template, 'name')),
$item->template['Quality'],
$item->template['icon'],
"{".implode(",", $stats)."}"
];
}
}
$pageData['summary'] = "new Summary({template:'compare',id:'compare',parent:'compare-generic',groups:[".$doneSummary."]});";
// Announcements
$announcements = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = "compare" OR page = "*")');
foreach ($announcements as $k => $v)

View File

@@ -1,8 +1,9 @@
{strip}
{math equation="abs(x)" x=$an.Id assign="pId"}
{math equation="(x & 0xF)" x=$an.flags assign="mode"}
{math equation="(x & 0xF0) >> 4" x=$an.flags assign="status"}
{math equation="(x & 0xF00) >> 8" x=$an.flags assign="jsVar"}
{/strip}
<div id="announcement-{$pId}"></div>
<script type="text/javascript">
new Announcement({ldelim}

View File

@@ -8,14 +8,15 @@
{include file='bricks/announcement.tpl' an=$item}
{/foreach}
{/if}
<script type="text/javascript">g_initPath([1,3])</script>
<div class="text">
<div id="compare-generic"></div>
<script type="text/javascript">//<![CDATA[
{foreach name=cmpItems from=$data.items item=curr}
{$curr}
g_items.add({$curr[0]}, {ldelim}name_{$user.language}:'{$curr[1]}', quality:{$curr[2]}, icon:'{$curr[3]}', jsonequip:{$curr[4]}{rdelim});
{/foreach}
{$data.summary}
new Summary({ldelim}template:'compare',id:'compare',parent:'compare-generic',groups:{$data.summary}{rdelim});
//]]></script>
</div>
<div class="clear"></div>