From 2a63f17a14858a4fa15ab1ec1bb37513275107d7 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 3 Dec 2022 14:58:06 +0800 Subject: [PATCH] fix(web): show_mode cookie --- web/app/controllers/list.php | 15 +++++++++------ web/app/controllers/lists.php | 11 +++++++---- web/app/controllers/problem_set.php | 15 +++++++++------ 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/web/app/controllers/list.php b/web/app/controllers/list.php index c116d6c..6fee16a 100644 --- a/web/app/controllers/list.php +++ b/web/app/controllers/list.php @@ -166,11 +166,12 @@ $pag = new Paginator($pag_config); $('#input-show_tags_mode').click(function() { if (this.checked) { $.cookie('show_tags_mode', '', { - path: '/' + path: '/list', + expires: 365, }); } else { $.removeCookie('show_tags_mode', { - path: '/' + path: '/list', }); } location.reload(); @@ -178,11 +179,12 @@ $pag = new Paginator($pag_config); $('#input-show_submit_mode').click(function() { if (this.checked) { $.cookie('show_submit_mode', '', { - path: '/' + path: '/list', + expires: 365, }); } else { $.removeCookie('show_submit_mode', { - path: '/' + path: '/list', }); } location.reload(); @@ -190,11 +192,12 @@ $pag = new Paginator($pag_config); $('#input-show_difficulty').click(function() { if (this.checked) { $.cookie('show_difficulty', '', { - path: '/' + path: '/list', + expires: 365, }); } else { $.removeCookie('show_difficulty', { - path: '/' + path: '/list', }); } location.reload(); diff --git a/web/app/controllers/lists.php b/web/app/controllers/lists.php index 96babbf..2e81ef3 100644 --- a/web/app/controllers/lists.php +++ b/web/app/controllers/lists.php @@ -45,8 +45,10 @@ function getListTR($info) { if ($list->info['is_hidden']) { $html .= ' ' . UOJLocale::get('hidden') . ' '; } - foreach ($list->queryTags() as $tag) { - $html .= ' ' . HTML::escape($tag) . ' '; + if (isset($_COOKIE['show_tags_mode'])) { + foreach ($list->queryTags() as $tag) { + $html .= ' ' . HTML::escape($tag) . ' '; + } } $html .= HTML::tag('td', [], max(0, $accepted)); $html .= HTML::tag('td', [], count($problems)); @@ -121,11 +123,12 @@ $pag = new Paginator([ $('#input-show_tags_mode').click(function() { if (this.checked) { $.cookie('show_tags_mode', '', { - path: '/' + path: '/lists', + expires: 365, }); } else { $.removeCookie('show_tags_mode', { - path: '/' + path: '/lists', }); } location.reload(); diff --git a/web/app/controllers/problem_set.php b/web/app/controllers/problem_set.php index dcad8b0..0de0224 100644 --- a/web/app/controllers/problem_set.php +++ b/web/app/controllers/problem_set.php @@ -288,11 +288,12 @@ $pag = new Paginator([ $('#input-show_tags_mode').click(function() { if (this.checked) { $.cookie('show_tags_mode', '', { - path: '/' + path: '/problems', + expires: 365, }); } else { $.removeCookie('show_tags_mode', { - path: '/' + path: '/problems', }); } location.reload(); @@ -300,11 +301,12 @@ $pag = new Paginator([ $('#input-show_submit_mode').click(function() { if (this.checked) { $.cookie('show_submit_mode', '', { - path: '/' + path: '/problems', + expires: 365, }); } else { $.removeCookie('show_submit_mode', { - path: '/' + path: '/problems' }); } location.reload(); @@ -312,11 +314,12 @@ $pag = new Paginator([ $('#input-show_difficulty').click(function() { if (this.checked) { $.cookie('show_difficulty', '', { - path: '/' + path: '/problems', + expires: 365, }); } else { $.removeCookie('show_difficulty', { - path: '/' + path: '/problems' }); } location.reload();