From faabdee2a6083587788b20e716e4e8a251a0aac8 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sun, 20 Jan 2013 00:06:34 +0100 Subject: [PATCH] minor beautifications for compare --- pages/compare.php | 24 +++++++++++--------- template/bricks/announcement.tpl | 35 ++++++++++++++-------------- template/compare.tpl | 39 ++++++++++++++++---------------- 3 files changed, 51 insertions(+), 47 deletions(-) diff --git a/pages/compare.php b/pages/compare.php index 98a20177..0e70b8ac 100644 --- a/pages/compare.php +++ b/pages/compare.php @@ -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) diff --git a/template/bricks/announcement.tpl b/template/bricks/announcement.tpl index fd0b230d..aa596534 100644 --- a/template/bricks/announcement.tpl +++ b/template/bricks/announcement.tpl @@ -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"} - -
- \ No newline at end of file +{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} +
+ diff --git a/template/compare.tpl b/template/compare.tpl index 0ec3850a..5c664c3c 100644 --- a/template/compare.tpl +++ b/template/compare.tpl @@ -1,25 +1,26 @@ {include file='header.tpl'} -
-
-
- {if !empty($announcements)} - {foreach from=$announcements item=item} - {include file='bricks/announcement.tpl' an=$item} - {/foreach} - {/if} - -
-
- +
+
+
+ {if !empty($announcements)} + {foreach from=$announcements item=item} + {include file='bricks/announcement.tpl' an=$item} + {/foreach} + {/if} + + +
+
+ +
+
-
-
{include file='footer.tpl'}