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']))
@@ -19,7 +17,7 @@ else if (!empty($_COOKIE['compare_groups']))
if ($compareString)
{
$sets = explode(";", $compareString);
$sets = explode(";", $compareString);
$items = array();
foreach ($sets as $set)
{
@@ -27,10 +25,10 @@ if ($compareString)
$outString = array();
foreach ($itemsting as $substring)
{
$params = explode(".", $substring);
$params = explode(".", $substring);
$items[] = (int)$params[0];
while (sizeof($params) < 7)
$params[] = 0;
$params[] = 0;
$outString[] = "[".implode(',', $params)."]";
@@ -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)
@@ -55,18 +53,22 @@ if ($compareString)
$item->getJsonStats();
$stats = array();
foreach ($item->json as $k => $v)
$stats[] = is_numeric($v) || $v[0] == "{" ? '"'.$k.'":'.$v.'' : '"'.$k.'":"'.$v.'"';
$stats[] = is_numeric($v) || $v[0] == "{" ? '"'.$k.'":'.$v.'' : '"'.$k.'":"'.$v.'"';
foreach ($item->itemMods as $k => $v)
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,17 +1,18 @@
{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"}
<div id="announcement-{$pId}"></div>
<script type="text/javascript">
new Announcement({ldelim}
parent: 'announcement-{$pId}',
id: {$an.Id},
text: {if $jsVar}{$an.text}{else}'{$an.text}'{/if},
name: '{$an.name}',
style: '{$an.style}',
status: {$status},
mode: {$mode}
{rdelim});
</script>
{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}
parent: 'announcement-{$pId}',
id: {$an.Id},
text: {if $jsVar}{$an.text}{else}'{$an.text}'{/if},
name: '{$an.name}',
style: '{$an.style}',
status: {$status},
mode: {$mode}
{rdelim});
</script>

View File

@@ -1,25 +1,26 @@
{include file='header.tpl'}
<div id="main">
<div id="main-precontents"></div>
<div id="main-contents" class="main-contents">
{if !empty($announcements)}
{foreach from=$announcements item=item}
{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}
{/foreach}
{$data.summary}
//]]></script>
<div id="main">
<div id="main-precontents"></div>
<div id="main-contents" class="main-contents">
{if !empty($announcements)}
{foreach from=$announcements item=item}
{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}
g_items.add({$curr[0]}, {ldelim}name_{$user.language}:'{$curr[1]}', quality:{$curr[2]}, icon:'{$curr[3]}', jsonequip:{$curr[4]}{rdelim});
{/foreach}
new Summary({ldelim}template:'compare',id:'compare',parent:'compare-generic',groups:{$data.summary}{rdelim});
//]]></script>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</div>
{include file='footer.tpl'}