给所有tag上色
This commit is contained in:
@@ -19,14 +19,32 @@
|
||||
];
|
||||
|
||||
// 生成标签地图
|
||||
// 定义颜色主题数组
|
||||
$color_theme = array("primary", "secondary", "positive", "negative", "orange", "yellow", "olive", "green", "teal", "blue", "violet", "purple", "pink", "brown", "grey", "black");
|
||||
|
||||
// 为标签添加颜色样式
|
||||
function colorize_tag($tag) {
|
||||
global $color_theme;
|
||||
$hash_num = hexdec(substr(md5($tag), 0, 7));
|
||||
$label_theme = $color_theme[$hash_num % count($color_theme)];
|
||||
|
||||
if ($label_theme == "")
|
||||
$label_theme = "default";
|
||||
|
||||
return $label_theme;
|
||||
}
|
||||
|
||||
foreach ($tag_map as $level => $tags): ?>
|
||||
<h3>分类 <?php echo $level; ?></h3>
|
||||
<h3><a href="problemset.php?search=难度<?php echo $level; ?>">难度 <?php echo $level; ?></a></h3>
|
||||
<div class="tag-cloud">
|
||||
<?php foreach ($tags as $tag): ?>
|
||||
<a href="problemset.php?search=<?php echo urlencode($tag); ?>" class="ui label"><?php echo $tag; ?></a>
|
||||
<?php foreach ($tags as $tag):
|
||||
$label_theme = colorize_tag($tag);
|
||||
?>
|
||||
<a href="problemset.php?search=<?php echo urlencode($tag); ?>" class="ui <?php echo $label_theme; ?> label"><?php echo $tag; ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach;
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
|
||||
// 显示剩余未分类标签
|
||||
$all_mapped_tags = array_merge(...array_values($tag_map));
|
||||
|
||||
Reference in New Issue
Block a user