From 28907231605d0d04fb8b318de91c0f51e76ca246 Mon Sep 17 00:00:00 2001 From: lesleyjanenorton Date: Tue, 26 Jun 2018 10:33:33 -0500 Subject: [PATCH] removing exampleBreach + nits Removes the --createExampleBreach and --help args from load-breaches.js and updates README. Tweaks to monitor.js for event handling. --- README.md | 2 +- public/img/logos/ExampleBreach.svg | 1 - public/js/monitor.js | 17 ++++++++++------- scripts/load-breaches.js | 22 ---------------------- 4 files changed, 11 insertions(+), 31 deletions(-) delete mode 100644 public/img/logos/ExampleBreach.svg diff --git a/README.md b/README.md index 39cb1f10039..f0e57de6583 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ To populate the database with test data, use these scripts in `scripts/`: * `node scripts/add-breached-emails.js` adds some breached email records for `test[1-3]@test.com` users -Both scripts have `--help` arguments for usage help. +* `node scripts/add-breached-email.sjs --help` for usage help. #### Emails diff --git a/public/img/logos/ExampleBreach.svg b/public/img/logos/ExampleBreach.svg deleted file mode 100644 index 3390e86b5d9..00000000000 --- a/public/img/logos/ExampleBreach.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/public/js/monitor.js b/public/js/monitor.js index 6f714760f40..1b2302fb868 100644 --- a/public/js/monitor.js +++ b/public/js/monitor.js @@ -105,6 +105,11 @@ function enableBtnIfInputEmpty(e) { } } +function hideFalseDoor() { + addClass("#false-door", "hidden"); + document.body.style.overflow = "scroll"; +} + function showFalseDoor() { handleEvents("SignUp"); removeClass("#false-door", "hidden"); @@ -114,17 +119,13 @@ function showFalseDoor() { if (e.code !== "Enter" && e.code !== "Escape") { return; } - addClass("#false-door", "hidden"); - document.body.style.overflow = "scroll"; + hideFalseDoor(); window.removeEventListener("keydown", listener); - falseDoor.removeEventListener("click", listener); }); falseDoor.addEventListener("click", function listener (e) { if (e.target === falseDoor || e.target === document.getElementById("close-false-door")) { - addClass("#false-door", "hidden"); - document.body.style.overflow = "scroll"; + hideFalseDoor(); falseDoor.removeEventListener("click", listener); - window.removeEventListener("keydown", listener); } }); } @@ -147,7 +148,7 @@ async function sha1(message) { async function hashEmailAndSend(emailFormSubmitEvent) { emailFormSubmitEvent.preventDefault(); const emailForm = emailFormSubmitEvent.target; - if (emailForm.querySelector("input[name=email]").value === "") { + if (!emailForm.querySelector("input[name=email]").value) { emailForm.querySelector("input[type=submit]").disabled = true; addInvalidMessage(); return; @@ -174,11 +175,13 @@ if (document.querySelector(".email-scan")) { removeInvalidMessage(); }); } + window.addEventListener("pageshow", function() { if (document.getElementById("no-breaches") || document.getElementById("found-breaches")) { handleEvents("Pageview"); } }); + if (document.getElementById("sign-up")) { document.getElementById("sign-up").addEventListener("click", showFalseDoor); } diff --git a/scripts/load-breaches.js b/scripts/load-breaches.js index 3a59056877a..a1b568c7719 100644 --- a/scripts/load-breaches.js +++ b/scripts/load-breaches.js @@ -1,6 +1,5 @@ "use strict"; -const arg = require("arg"); const got = require("got"); const createDOMPurify = require("dompurify"); const { JSDOM } = require("jsdom"); @@ -14,17 +13,6 @@ const HIBP_USER_AGENT = `${pkg.name}/${pkg.version}`; const DOMPurify = createDOMPurify((new JSDOM("")).window); -const args = arg({ - "--createExampleBreach": Boolean, - "--help": Boolean, -}); - -if (args["--help"]) { - console.log("Usage: node load-breaaches.js [--createExampleBreach]"); - console.log("--createExampleBreach creates the 'ExampleBreach' test fixture breach."); - process.exit(); -} - async function handleBreachesResponse(response) { try { const breachesJSON = JSON.parse(response.body); @@ -41,16 +29,6 @@ async function handleBreachesResponse(response) { } (async () => { - if (args["--createExampleBreach"]) { - await DBUtils.createBreach("ExampleBreach", { - Title: "Example", - BreachDate: "2015-12-06", - DataClasses: ["Email addresses", "IP addresses", "Passwords", "Usernames", "Website activity"], - PwnCount: 1436486, - LogoType: "svg", - Description: "This is an example of the data available for each breach. Compromised Data classes are not limited to the classes listed above.", - }); - } try { const breachesResponse = await got( `${AppConstants.HIBP_API_ROOT}/breaches`,