• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / #11898

pending completion
#11898

push

circleci

web-flow
Merge pull request #2770 from mozilla/license

Add license headers in source files

282 of 1138 branches covered (24.78%)

Branch coverage included in aggregate %.

959 of 3049 relevant lines covered (31.45%)

2.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/client/js/partials/breaches.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
const breachesPartial = document.querySelector("[data-partial='breaches']")
×
6
const state = new Proxy({
×
7
  selectedEmail: null,
8
  selectedStatus: 'unresolved'
9
}, {
10
  set (target, key, value) {
11
    if (target[key] !== value) {
×
12
      target[key] = value
×
13
      render()
×
14
    }
15

16
    return true
×
17
  }
18
})
19

20
let breachRows, emailSelect, statusFilter, resolvedCountOutput, unresolvedCountOutput
21

22
function init () {
23
  breachRows = breachesPartial.querySelectorAll('.breach-row')
×
24
  emailSelect = breachesPartial.querySelector('.breaches-header custom-select')
×
25
  statusFilter = breachesPartial.querySelector('.breaches-filter')
×
26
  resolvedCountOutput = statusFilter.querySelector("label[for='breaches-resolved'] output")
×
27
  unresolvedCountOutput = statusFilter.querySelector("label[for='breaches-unresolved'] output")
×
28

29
  state.selectedEmail = emailSelect.value
×
30
  emailSelect.addEventListener('change', handleEvent)
×
31
  statusFilter.addEventListener('change', handleEvent)
×
32
  render()
×
33
}
34

35
function handleEvent (e) {
36
  switch (e.currentTarget) {
×
37
    case emailSelect:
38
      state.selectedEmail = e.target.value
×
39
      break
×
40
    case statusFilter:
41
      state.selectedStatus = e.target.value
×
42
      break
×
43
  }
44
}
45

46
function render () {
47
  let delay = 0
×
48
  let hidden
49

50
  resolvedCountOutput.textContent = breachesPartial.querySelectorAll(`[data-status='resolved'][data-email='${state.selectedEmail}']`).length
×
51
  unresolvedCountOutput.textContent = breachesPartial.querySelectorAll(`[data-status='unresolved'][data-email='${state.selectedEmail}']`).length
×
52

53
  breachRows.forEach(breach => {
×
54
    hidden = (breach.dataset.email !== state.selectedEmail) || (breach.dataset.status !== state.selectedStatus)
×
55
    breach.toggleAttribute('hidden', hidden)
×
56
    if (!hidden) {
×
57
      breach.style.setProperty('--delay', `${delay}ms`)
×
58
      delay += 50
×
59
    }
60
  })
61
}
62

63
if (breachesPartial) init()
×
64

65
// TODO: REMOVE -- this is just an example of updating breach resolution
66
// update button
67
const b = document.getElementById('update-breaches')
×
68
if (b) {
×
69
  console.log('breaches update test')
×
70
  b.addEventListener('click', async _ => {
×
71
    try {
×
72
      const resp = await fetch('api/v1/user/breaches', {
×
73
        method: 'PUT',
74
        headers: {
75
          'Content-Type': 'application/json'
76
        },
77
        body: JSON.stringify({
78
          affectedEmail: 'affected@email.com',
79
          recencyIndex: '13',
80
          resolutionsChecked: ['passwords',
81
            'dates-of-birth', 'email-addresses']
82
        })
83
      })
84

85
      console.log('completed: ', resp.json())
×
86
    } catch (err) {
87
      console.error(`Error: ${err}`)
×
88
    }
89
  })
90
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc