Browse Source

Fix problems tag show is hidden, hidden is show

pull/6/head
Menci 8 years ago
parent
commit
549ce0077e
  1. 13
      views/problems.ejs

13
views/problems.ejs

@ -4,7 +4,6 @@
let tagIDs = []; let tagIDs = [];
if (typeof tags !== 'undefined') tagIDs = tags.map(x => x.id); 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="padding">
<div class="ui grid" style="margin-bottom: 10px; "> <div class="ui grid" style="margin-bottom: 10px; ">
<div class="row" style="white-space: nowrap; "> <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"> <div class="ui toggle checkbox" id="show_tag">
<style id="show_tag_style"></style> <style id="show_tag_style"></style>
<script> <script>
if (Cookies.get('show_tag') === '1') { if (localStorage.getItem('show_tag') === '1') {
document.write('<input type="checkbox" checked>'); 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 { } else {
document.write('<input type="checkbox">'); 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> </script>
@ -51,11 +50,11 @@ if (typeof tags !== 'undefined') tagIDs = tags.map(x => x.id);
$(function () { $(function () {
$('#show_tag').checkbox('setting', 'onChange', function () { $('#show_tag').checkbox('setting', 'onChange', function () {
let checked = $('#show_tag').checkbox('is checked'); let checked = $('#show_tag').checkbox('is checked');
Cookies.set('show_tag', checked ? '1' : '0'); localStorage.setItem('show_tag', checked ? '1' : '0');
if (checked) { 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; }'; 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