From a29f194ade0b250ef36108a7e20cbc4cd9e78fb2 Mon Sep 17 00:00:00 2001 From: Zhe Li Date: Mon, 26 Nov 2018 15:45:01 +0800 Subject: [PATCH 1/2] qr scanner ui --- css/content.css | 4 ++-- src/content.ts | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/css/content.css b/css/content.css index cb30a6aaa..66ef1aadc 100644 --- a/css/content.css +++ b/css/content.css @@ -4,7 +4,7 @@ left: 0; width: 100%; height: 100%; - background: rgba(0, 0, 0, 0.6); + background: rgba(255, 255, 255, 0.6); z-index: 1000000; display: none; cursor: crosshair; @@ -20,6 +20,6 @@ #__ga_captureBox__ { position: absolute; - border: white 1px dashed; + border: black 1px dashed; display: none; } \ No newline at end of file diff --git a/src/content.ts b/src/content.ts index 35561cc52..7512c6c0b 100644 --- a/src/content.ts +++ b/src/content.ts @@ -207,7 +207,8 @@ function pasteCode(code: string) { } } - const activeInputBox = document.activeElement.tagName === 'INPUT' ? + const activeInputBox = + document.activeElement && document.activeElement.tagName === 'INPUT' ? document.activeElement : null; if (activeInputBox) { @@ -221,3 +222,18 @@ function pasteCode(code: string) { firstInputBox.value = code; return; } + +window.onkeydown = (event) => { + if (event.keyCode === 27) { + event.preventDefault(); + const grayLayout = document.getElementById('__ga_grayLayout__'); + const captureBox = document.getElementById('__ga_captureBox__'); + + if (grayLayout) { + grayLayout.style.display = 'none'; + } + if (captureBox) { + captureBox.style.display = 'none'; + } + } +}; \ No newline at end of file From b382418e3e4ab6ba1f635348db268ccff1aca4e3 Mon Sep 17 00:00:00 2001 From: Zhe Li Date: Mon, 26 Nov 2018 15:54:31 +0800 Subject: [PATCH 2/2] add new line for lint --- src/content.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content.ts b/src/content.ts index 7512c6c0b..943e3719a 100644 --- a/src/content.ts +++ b/src/content.ts @@ -236,4 +236,4 @@ window.onkeydown = (event) => { captureBox.style.display = 'none'; } } -}; \ No newline at end of file +};