Browse Source

Fix problems tag show is hidden, hidden is show

master
Menci 8 years ago
parent
commit
549ce0077e
  1. 13
      views/problems.ejs

13
views/problems.ejs

@ -4,7 +4,6 @@
let tagIDs = [];
if (typeof tags !== 'undefined') tagIDs = tags.map(x => x.id);
%>
<script src="//cdn.bootcss.com/js-cookie/2.1.4/js.cookie.min.js"></script>
<div class="padding">
<div class="ui grid" style="margin-bottom: 10px; ">
<div class="row" style="white-space: nowrap; ">
@ -38,12 +37,12 @@ if (typeof tags !== 'undefined') tagIDs = tags.map(x => x.id);
<div class="ui toggle checkbox" id="show_tag">
<style id="show_tag_style"></style>
<script>
if (Cookies.get('show_tag') === '1') {
if (localStorage.getItem('show_tag') === '1') {
document.write('<input type="checkbox" checked>');
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { width: 0; white-space: nowrap; overflow: hidden; }';
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { white-space: nowrap; overflow: hidden; }';
} else {
document.write('<input type="checkbox">');
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { white-space: nowrap; overflow: hidden; }';
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { width: 0; white-space: nowrap; overflow: hidden; }';
}
</script>
@ -51,11 +50,11 @@ if (typeof tags !== 'undefined') tagIDs = tags.map(x => x.id);
$(function () {
$('#show_tag').checkbox('setting', 'onChange', function () {
let checked = $('#show_tag').checkbox('is checked');
Cookies.set('show_tag', checked ? '1' : '0');
localStorage.setItem('show_tag', checked ? '1' : '0');
if (checked) {
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { width: 0; white-space: nowrap; overflow: hidden; }';
} else {
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { white-space: nowrap; overflow: hidden; }';
} else {
document.getElementById('show_tag_style').innerHTML = '.show_tag_controled { width: 0; white-space: nowrap; overflow: hidden; }';
}
});
});

Loading…
Cancel
Save