Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.

Commit 4cbe9e6

Browse files
committed
Add Cookies For Settings
1 parent 0d36e91 commit 4cbe9e6

File tree

1 file changed

+53
-40
lines changed

1 file changed

+53
-40
lines changed

‎index.html

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,39 @@
22
<html>
33

44
<head>
5-
<!-- COMMON TAGS -->
6-
<meta charset="utf-8">
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8-
<title>Git Cheats - Cheatsheet For Git Commands</title>
9-
<!-- Search Engine -->
10-
<meta name="description" content="Git Cheats is an open source project which aims to save you time from searching for git commands through the web by filtering and categorizing.">
11-
<meta name="image" content="https://raw.githubusercontent.com/excalith/Git-Cheats/master/images/card.png">
12-
<meta name="keywords" content="git,cheatsheet,commands,github,bitbucket,gitlab,open,source">
13-
<meta name="robots" content="index, nofollow">
14-
<!-- Schema.org for Google -->
15-
<meta itemprop="name" content="Git Cheats - Cheatsheet For Git Commands">
16-
<meta itemprop="description" content="Git Cheats is an open source project which aims to save you time from searching for git commands through the web by filtering and categorizing.">
17-
<meta itemprop="image" content="https://raw.githubusercontent.com/excalith/Git-Cheats/master/images/card.png">
18-
<!-- Twitter -->
19-
<meta name="twitter:card" content="summary">
20-
<meta name="twitter:title" content="Git Cheats - Cheatsheet For Git Commands">
21-
<meta name="twitter:description" content="Git Cheats is an open source project which aims to save you time from searching for git commands through the web by filtering and categorizing.">
22-
<meta name="twitter:image:src" content="http://gitcheats.com/">
23-
<!-- Open Graph general (Facebook, Pinterest & Google+) -->
24-
<meta name="og:title" content="Git Cheats - Cheatsheet For Git Commands">
25-
<meta name="og:description" content="Git Cheats is an open source project which aims to save you time from searching for git commands through the web by filtering and categorizing.">
26-
<meta name="og:image" content="https://raw.githubusercontent.com/excalith/Git-Cheats/master/images/card.png">
27-
<meta name="og:url" content="http://gitcheats.com/">
28-
<meta name="og:site_name" content="Git Cheats - Cheatsheet For Git Commands">
29-
<meta name="og:type" content="website">
30-
31-
<link rel="shortcut icon" type="image/png" href="images/favicon.png" />
32-
<link rel="stylesheet" href="css/master.css" />
33-
<script src="js/jquery-3.3.1.min.js"></script>
34-
<script src="js/isotope.pkgd.min.js"></script>
35-
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.10/css/all.css" integrity="sha384-+d0P83n9kaQMCwj8F4RJB66tzIwOKmrdb46+porD/OvrJ+37WqIM7UoBtwHO6Nlg"
36-
crossorigin="anonymous">
5+
<!-- COMMON TAGS -->
6+
<meta charset="utf-8">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<title>Git Cheats - Cheatsheet For Git Commands</title>
9+
<!-- Search Engine -->
10+
<meta name="description" content="Git Cheats is an open source project which aims to save you time from searching for git commands through the web by filtering and categorizing.">
11+
<meta name="image" content="https://raw.githubusercontent.com/excalith/Git-Cheats/master/images/card.png">
12+
<meta name="keywords" content="git,cheatsheet,commands,github,bitbucket,gitlab,open,source">
13+
<meta name="robots" content="index, nofollow">
14+
<!-- Schema.org for Google -->
15+
<meta itemprop="name" content="Git Cheats - Cheatsheet For Git Commands">
16+
<meta itemprop="description" content="Git Cheats is an open source project which aims to save you time from searching for git commands through the web by filtering and categorizing.">
17+
<meta itemprop="image" content="https://raw.githubusercontent.com/excalith/Git-Cheats/master/images/card.png">
18+
<!-- Twitter -->
19+
<meta name="twitter:card" content="summary">
20+
<meta name="twitter:title" content="Git Cheats - Cheatsheet For Git Commands">
21+
<meta name="twitter:description" content="Git Cheats is an open source project which aims to save you time from searching for git commands through the web by filtering and categorizing.">
22+
<meta name="twitter:image:src" content="http://gitcheats.com/">
23+
<!-- Open Graph general (Facebook, Pinterest & Google+) -->
24+
<meta name="og:title" content="Git Cheats - Cheatsheet For Git Commands">
25+
<meta name="og:description" content="Git Cheats is an open source project which aims to save you time from searching for git commands through the web by filtering and categorizing.">
26+
<meta name="og:image" content="https://raw.githubusercontent.com/excalith/Git-Cheats/master/images/card.png">
27+
<meta name="og:url" content="http://gitcheats.com/">
28+
<meta name="og:site_name" content="Git Cheats - Cheatsheet For Git Commands">
29+
<meta name="og:type" content="website">
30+
31+
<link rel="shortcut icon" type="image/png" href="images/favicon.png" />
32+
<link rel="stylesheet" href="css/master.css" />
33+
<script src="js/jquery-3.3.1.min.js"></script>
34+
<script src="js/isotope.pkgd.min.js"></script>
35+
<script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>
36+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.10/css/all.css" integrity="sha384-+d0P83n9kaQMCwj8F4RJB66tzIwOKmrdb46+porD/OvrJ+37WqIM7UoBtwHO6Nlg"
37+
crossorigin="anonymous">
3738
</head>
3839

3940
<body>
@@ -59,7 +60,7 @@
5960
<div class="dropdown-content">
6061
<label class="checkbox">
6162
<span class="advanced-label"></span>
62-
<input id="ShowAdvanced" type="checkbox" checked="checked">
63+
<input id="ShowAdvanced" type="checkbox">
6364
<span class="checkmark"></span>
6465
</label>
6566
<hr>
@@ -73,17 +74,24 @@
7374
</div>
7475

7576
<script>
76-
// init isotope
77+
// Cookies
78+
var isAdvanced = false;
7779
var lang = "en";
80+
81+
if (Cookies.get('language'))
82+
lang = Cookies.get('language');
83+
84+
if (Cookies.get('showAdvanced')) {
85+
isAdvanced = Cookies.get('showAdvanced') == "true" ? true : false;
86+
$('#ShowAdvanced').prop('checked', isAdvanced);
87+
};
88+
89+
// init isotope
7890
var qsRegex;
7991
var $grid = $('.grid').isotope({
8092
itemSelector: '.grid-item',
8193
layoutMode: 'fitRows',
8294
filter: function () {
83-
// This allows user to find all text within grid-items. Disabled for request
84-
//return qsRegex ? $(this).text().match(qsRegex) : true;
85-
86-
// This allows user to find only keywords within keywords attribute.
8795
return qsRegex ? $(this).attr('keywords').match(qsRegex) : true;
8896
}
8997
});
@@ -132,13 +140,15 @@
132140

133141
$('input[name="lang"]').change(function () {
134142
lang = $('input[name=lang]:checked').val();
143+
Cookies.set('language', lang);
144+
135145
refreshList();
136146
});
137147

138148
// commands (skip first index for ui localization)
139149
for (i = 1; i < json.length; i++) {
140150
// if command is advanced check ShowAdvanced
141-
if (json[i].advanced == true && $('#ShowAdvanced').prop('checked') || json[i].advanced == false) {
151+
if (json[i].advanced == true && isAdvanced || json[i].advanced == false) {
142152
var $item = $(
143153
"<div class='grid-item " + json[i].category + "' keywords='" + json[i].keywords + "'>" +
144154
"<p class='title'>" + json[i].title + "</p>" +
@@ -149,7 +159,7 @@
149159
// command options
150160
for (j = 0; j < json[i].options.length; j++) {
151161
// if command option is advanced check ShowAdvanced
152-
if (json[i].options[j].advanced == true && $('#ShowAdvanced').prop('checked') || json[i].options[j].advanced == false) {
162+
if (json[i].options[j].advanced == true && isAdvanced || json[i].options[j].advanced == false) {
153163
$item.append("<p class='code'>" + json[i].options[j].code + "</p>");
154164
$item.append("<p class='desc'>" + json[i].options[j].desc[!json[i].options[j].desc[lang].length ? "en" : lang] + "</p>");
155165
}
@@ -190,9 +200,12 @@
190200
});
191201

192202
$('#ShowAdvanced').change(function () {
203+
isAdvanced = $('#ShowAdvanced').prop('checked');
204+
Cookies.set('showAdvanced', isAdvanced);
193205
refreshList();
194206
});
195207

208+
196209
</script>
197210

198211
</body>

0 commit comments

Comments
 (0)