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.spell.php');
require_once('includes/class.faction.php'); // items may require a faction to use/own require_once('includes/class.faction.php'); // items may require a faction to use/own
// prefer $_GET over $_COOKIE
$compareString = '';
$doneSummary = '';
$pageData['items'] = array(); $pageData['items'] = array();
// prefer $_GET over $_COOKIE
if (!empty($_GET['compare'])) if (!empty($_GET['compare']))
$compareString = $_GET['compare']; $compareString = $_GET['compare'];
else if (!empty($_COOKIE['compare_groups'])) else if (!empty($_COOKIE['compare_groups']))
@@ -47,7 +45,7 @@ if ($compareString)
} }
$outSet[] = "[".implode(',', $outString)."]"; $outSet[] = "[".implode(',', $outString)."]";
} }
$doneSummary = implode(',', $outSet); $pageData['summary'] = "[".implode(',', $outSet)."]";
$iList = new ItemList(array(['i.entry', $items])); $iList = new ItemList(array(['i.entry', $items]));
foreach ($iList->container as $item) foreach ($iList->container as $item)
@@ -61,12 +59,16 @@ if ($compareString)
if ($v) if ($v)
$stats[] = '"'.Util::$itemMods[$k].'":'.$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
$announcements = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = "compare" OR page = "*")'); $announcements = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = "compare" OR page = "*")');
foreach ($announcements as $k => $v) foreach ($announcements as $k => $v)

View File

@@ -1,10 +1,11 @@
{math equation="abs(x)" x=$an.Id assign="pId"} {strip}
{math equation="(x & 0xF)" x=$an.flags assign="mode"} {math equation="abs(x)" x=$an.Id assign="pId"}
{math equation="(x & 0xF0) >> 4" x=$an.flags assign="status"} {math equation="(x & 0xF)" x=$an.flags assign="mode"}
{math equation="(x & 0xF00) >> 8" x=$an.flags assign="jsVar"} {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> <div id="announcement-{$pId}"></div>
<script type="text/javascript"> <script type="text/javascript">
new Announcement({ldelim} new Announcement({ldelim}
parent: 'announcement-{$pId}', parent: 'announcement-{$pId}',
id: {$an.Id}, id: {$an.Id},
@@ -14,4 +15,4 @@
status: {$status}, status: {$status},
mode: {$mode} mode: {$mode}
{rdelim}); {rdelim});
</script> </script>

View File

@@ -8,14 +8,15 @@
{include file='bricks/announcement.tpl' an=$item} {include file='bricks/announcement.tpl' an=$item}
{/foreach} {/foreach}
{/if} {/if}
<script type="text/javascript">g_initPath([1,3])</script> <script type="text/javascript">g_initPath([1,3])</script>
<div class="text"> <div class="text">
<div id="compare-generic"></div> <div id="compare-generic"></div>
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
{foreach name=cmpItems from=$data.items item=curr} {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} {/foreach}
{$data.summary} new Summary({ldelim}template:'compare',id:'compare',parent:'compare-generic',groups:{$data.summary}{rdelim});
//]]></script> //]]></script>
</div> </div>
<div class="clear"></div> <div class="clear"></div>