From dd62e9fc02f7803fd27351d71ed4e4a5f9a0b4a7 Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Thu, 4 Jan 2018 10:35:26 +0000 Subject: [PATCH] Travis build: 1020 --- README.md | 10 +++++++--- docs/index.html | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 13cd4ac68..b2c01c305 100644 --- a/README.md +++ b/README.md @@ -2012,15 +2012,19 @@ Redirects the page to HTTPS if its currently in HTTP. Also, pressing the back bu 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. -
-Examples - ```js const httpsRedirect = () => { if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]); }; ``` +
+Examples + +```js +httpsRedirect(); // If you are on http://mydomain.com, you are redirected to https://mydomain.com +``` +

[⬆ Back to top](#table-of-contents) diff --git a/docs/index.html b/docs/index.html index 9ade1490e..40c83695c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -381,6 +381,7 @@ console.log<

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.

const httpsRedirect = () => {
   if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]);
 };
+
httpsRedirect(); // If you are on http://mydomain.com, you are redirected to https://mydomain.com
 

onUserInputChange

Run the callback whenever the user input type changes (mouse or touch). Useful for enabling/disabling code depending on the input device. This process is dynamic and works with hybrid devices (e.g. touchscreen laptops).

Use two event listeners. Assume mouse input initially and bind a touchstart event listener to the document. On touchstart, add a mousemove event listener to listen for two consecutive mousemove events firing within 20ms, using performance.now(). Run the callback with the input type as an argument in either of these situations.

const onUserInputChange = callback => {
   let type = 'mouse',
     lastTime = 0;