From 5977cf6bcb123b2f3baf8e130254a381bd942803 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Thu, 28 Dec 2017 23:33:21 +0200 Subject: [PATCH 1/4] Added show/hide snippets --- snippets/hide.md | 13 +++++++++++++ snippets/show.md | 13 +++++++++++++ tag_database | 2 ++ 3 files changed, 28 insertions(+) create mode 100644 snippets/hide.md create mode 100644 snippets/show.md diff --git a/snippets/hide.md b/snippets/hide.md new file mode 100644 index 000000000..e8024ddb9 --- /dev/null +++ b/snippets/hide.md @@ -0,0 +1,13 @@ +### hide + +Hides all the elements specified. + +Use the spread operator (`...`) and `Array.forEach()` to apply `display: none` to each element specified. + +```js +const hide = (...el) => [...el].forEach(e => e.style.display = 'none'); +``` + +```js +hide(document.querySelector('img')); // Hides all elements on the page +``` diff --git a/snippets/show.md b/snippets/show.md new file mode 100644 index 000000000..c5b4e439b --- /dev/null +++ b/snippets/show.md @@ -0,0 +1,13 @@ +### show + +Shows all the elements specified. + +Use the spread operator (`...`) and `Array.forEach()` to clear the `display` property for each element specified. + +```js +const show = (...el) => [...el].forEach(e => e.style.display = ''); +``` + +```js +show(document.querySelector('img')); // Shows all elements on the page +``` diff --git a/tag_database b/tag_database index f170f51d9..f3f640e9c 100644 --- a/tag_database +++ b/tag_database @@ -56,6 +56,7 @@ groupBy:array hammingDistance:math head:array hexToRGB:utility +hide:browser httpsRedirect:browser initial:array initialize2DArray:array @@ -111,6 +112,7 @@ scrollToTop:browser sdbm:utility select:object shallowClone:object +show:browser shuffle:array similarity:array sleep:function From bf99c17371f48f59f3355f22b93c7317c7771590 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Fri, 29 Dec 2017 00:01:19 +0200 Subject: [PATCH 2/4] Update hide.md --- snippets/hide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/hide.md b/snippets/hide.md index e8024ddb9..b19486df4 100644 --- a/snippets/hide.md +++ b/snippets/hide.md @@ -9,5 +9,5 @@ const hide = (...el) => [...el].forEach(e => e.style.display = 'none'); ``` ```js -hide(document.querySelector('img')); // Hides all elements on the page +hide(document.querySelectorAll('img')); // Hides all elements on the page ``` From 5769318dcc5c442c7b42c95065f21908c09ec3f4 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Fri, 29 Dec 2017 00:01:28 +0200 Subject: [PATCH 3/4] Update show.md --- snippets/show.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/show.md b/snippets/show.md index c5b4e439b..2e2302d19 100644 --- a/snippets/show.md +++ b/snippets/show.md @@ -9,5 +9,5 @@ const show = (...el) => [...el].forEach(e => e.style.display = ''); ``` ```js -show(document.querySelector('img')); // Shows all elements on the page +show(document.querySelectorAll('img')); // Shows all elements on the page ``` From 2412feb8e7ddb8af7cbd739169ff300ed1607f5f Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 28 Dec 2017 22:11:31 +0000 Subject: [PATCH 4/4] Travis build: 452 --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ docs/index.html | 16 ++++++++++++++++ snippets/hide.md | 2 +- snippets/show.md | 2 +- 4 files changed, 66 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 46f01c489..bfaf1e8bc 100644 --- a/README.md +++ b/README.md @@ -91,9 +91,11 @@ * [`elementIsVisibleInViewport`](#elementisvisibleinviewport) * [`getScrollPosition`](#getscrollposition) * [`getURLParameters`](#geturlparameters) +* [`hide`](#hide) * [`httpsRedirect`](#httpsredirect) * [`redirect`](#redirect) * [`scrollToTop`](#scrolltotop) +* [`show`](#show) @@ -1762,6 +1764,29 @@ getURLParameters('http://url.com/page?name=Adam&surname=Smith'); // {name: 'Adam [⬆ Back to top](#table-of-contents) +### hide + +Hides all the elements specified. + +Use the spread operator (`...`) and `Array.forEach()` to apply `display: none` to each element specified. + +```js +const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); +``` + +
+Examples + +```js +hide(document.querySelectorAll('img')); // Hides all elements on the page +``` + +
+ + +[⬆ Back to top](#table-of-contents) + + ### httpsRedirect Redirects the page to HTTPS if its currently in HTTP. Also, pressing the back button doesn't take it back to the HTTP page as its replaced in the history. @@ -1835,6 +1860,29 @@ scrollToTop(); +[⬆ Back to top](#table-of-contents) + + +### show + +Shows all the elements specified. + +Use the spread operator (`...`) and `Array.forEach()` to clear the `display` property for each element specified. + +```js +const show = (...el) => [...el].forEach(e => (e.style.display = '')); +``` + +
+Examples + +```js +show(document.querySelectorAll('img')); // Shows all elements on the page +``` + +
+ + [⬆ Back to top](#table-of-contents) ## Date diff --git a/docs/index.html b/docs/index.html index f49e7dd18..8a310ba88 100644 --- a/docs/index.html +++ b/docs/index.html @@ -160,9 +160,11 @@ elementIsVisibleInViewport getScrollPosition getURLParameters +hide httpsRedirect redirect scrollToTop +show

Date

getDaysDiffBetweenDates @@ -859,6 +861,13 @@ Pass location.search as the argument to apply to the current
getURLParameters('http://url.com/page?name=Adam&surname=Smith'); // {name: 'Adam', surname: 'Smith'}
 
+

hide

+

Hides all the elements specified.

+

Use the spread operator (...) and Array.forEach() to apply display: none to each element specified.

+
const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));
+
+
hide(document.querySelectorAll('img')); // Hides all <img> elements on the page
+

httpsRedirect

Redirects the page to HTTPS if its currently in HTTP. Also, pressing the back button doesn't take it back to the HTTP page as its replaced in the history.

Use location.protocol to get the protocol currently being used. If it's not HTTPS, use location.replace() to replace the existing page with the HTTPS version of the page. Use location.href to get the full address, split it with String.split() and remove the protocol part of the URL.

@@ -889,6 +898,13 @@ Scroll by a fraction of the distance from the top. Use window.requestAnima
scrollToTop();
 
+

show

+

Shows all the elements specified.

+

Use the spread operator (...) and Array.forEach() to clear the display property for each element specified.

+
const show = (...el) => [...el].forEach(e => (e.style.display = ''));
+
+
show(document.querySelectorAll('img')); // Shows all <img> elements on the page
+

Date

getDaysDiffBetweenDates

Returns the difference (in days) between two dates.

diff --git a/snippets/hide.md b/snippets/hide.md index b19486df4..82a02a4b0 100644 --- a/snippets/hide.md +++ b/snippets/hide.md @@ -5,7 +5,7 @@ Hides all the elements specified. Use the spread operator (`...`) and `Array.forEach()` to apply `display: none` to each element specified. ```js -const hide = (...el) => [...el].forEach(e => e.style.display = 'none'); +const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); ``` ```js diff --git a/snippets/show.md b/snippets/show.md index 2e2302d19..cf30be9b7 100644 --- a/snippets/show.md +++ b/snippets/show.md @@ -5,7 +5,7 @@ Shows all the elements specified. Use the spread operator (`...`) and `Array.forEach()` to clear the `display` property for each element specified. ```js -const show = (...el) => [...el].forEach(e => e.style.display = ''); +const show = (...el) => [...el].forEach(e => (e.style.display = '')); ``` ```js