-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoverview.html
More file actions
380 lines (358 loc) · 12.5 KB
/
overview.html
File metadata and controls
380 lines (358 loc) · 12.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<!DOCTYPE html>
<html lang="en">
<head>
<title>Exposed: who knows what about you</title>
<meta charset="utf-8" />
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' https://unpkg.com/">
<script src="https://unpkg.com/react@latest/umd/react.development.js" crossorigin="anonymous"></script>
<script src="https://unpkg.com/react-dom@latest/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@material-ui/core@latest/umd/material-ui.development.js" crossorigin="anonymous"></script>
<script src="https://unpkg.com/babel-standalone@latest/babel.min.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel="stylesheet" href="background.css"/>
<link rel="icon" type="image/png" sizes="32x32" href="images/icon32.png">
<link rel="icon" type="image/png" sizes="16x16" href="images/icon16.png">
</head>
<body>
<div id="root"></div>
<script type="text/babel">
const {
colors,
CssBaseline,
ThemeProvider,
Typography,
Container,
makeStyles,
createMuiTheme,
Box,
SvgIcon,
Link,
Card,
CardContent,
Table,
TableBody,
TableCell,
TableContainer,
TableFooter,
TableHead,
TablePagination,
TableRow,
TableSortLabel,
Paper,
FormControlLabel,
IconButton,
} = MaterialUI;
// Create a theme instance.
const theme = createMuiTheme({
palette: {
primary: {
main: '#556cd6',
},
secondary: {
main: '#19857b',
},
error: {
main: colors.red.A400,
},
background: {
default: '#fff',
},
},
});
const useStyles = makeStyles(theme => ({
root: {
margin: theme.spacing(6, 0, 3),
},
paper: {
width: '100%',
marginBottom: theme.spacing(2),
},
table: {
minWidth: 750,
},
visuallyHidden: {
border: 0,
clip: 'rect(0 0 0 0)',
height: 1,
margin: -1,
overflow: 'hidden',
padding: 0,
position: 'absolute',
top: 20,
width: 1,
},
}));
function createData(name, email, phone, address, payment) {
return { name, email, phone, address, payment };
}
let rows = [];
const localStorageKeys = Object.keys(localStorage);
for (var i = 0; i < localStorageKeys.length; i++) {
const key = localStorageKeys[0];
const content = JSON.parse(window.localStorage.getItem(key));
console.log(content);
const email = content.email;
const phone = content.phone;
const address = content.address;
const payment = content.payment;
const newData = createData(key, email, phone, address, payment);
rows.push(newData);
}
// dummy data
const dummyData = [
createData('https://www.amazon.com/', true, true, true, false),
createData('https://www.leetcode.com', true, false, false, false),
createData('https://www.onshape.com/', true, false, false, true),
createData('https://www.bmo.com/', true, true, true, true),
createData('https://www.everlane.com/', false, false, true, true),
createData('https://www.eventbrite.ca/', false, true, true, false),
createData('https://www.nwhacks.com', true, true, false, false),
];
rows = rows.concat(dummyData);
function desc(a, b, orderBy) {
if (b[orderBy] < a[orderBy]) {
return -1;
}
if (b[orderBy] > a[orderBy]) {
return 1;
}
return 0;
}
function stableSort(array, cmp) {
const stabilizedThis = array.map((el, index) => [el, index]);
stabilizedThis.sort((a, b) => {
const order = cmp(a[0], b[0]);
if (order !== 0) return order;
return a[1] - b[1];
});
return stabilizedThis.map(el => el[0]);
}
function getSorting(order, orderBy) {
return order === 'desc' ? (a, b) => desc(a, b, orderBy) : (a, b) => -desc(a, b, orderBy);
}
const headCells = [
{ id: 'name', numeric: false, disablePadding: true, label: 'Entity Name' },
{ id: 'email', numeric: true, disablePadding: false, label: 'Email' },
{ id: 'phone', numeric: true, disablePadding: false, label: 'Phone' },
{ id: 'address', numeric: true, disablePadding: false, label: 'Address' },
{ id: 'payment', numeric: true, disablePadding: false, label: 'Payment Info' },
];
function EntityTable() {
const classes = useStyles();
const [order, setOrder] = React.useState('asc');
const [orderBy, setOrderBy] = React.useState('name');
const [selected, setSelected] = React.useState([]);
const [page, setPage] = React.useState(0);
const [dense, setDense] = React.useState(false);
const [rowsPerPage, setRowsPerPage] = React.useState(5);
const handleRequestSort = (event, property) => {
const isAsc = orderBy === property && order === 'asc';
setOrder(isAsc ? 'desc' : 'asc');
setOrderBy(property);
};
const handleSelectAllClick = event => {
if (event.target.checked) {
const newSelecteds = rows.map(n => n.name);
setSelected(newSelecteds);
return;
}
setSelected([]);
};
const handleClick = (event, name) => {
const selectedIndex = selected.indexOf(name);
let newSelected = [];
if (selectedIndex === -1) {
newSelected = newSelected.concat(selected, name);
} else if (selectedIndex === 0) {
newSelected = newSelected.concat(selected.slice(1));
} else if (selectedIndex === selected.length - 1) {
newSelected = newSelected.concat(selected.slice(0, -1));
} else if (selectedIndex > 0) {
newSelected = newSelected.concat(
selected.slice(0, selectedIndex),
selected.slice(selectedIndex + 1),
);
}
setSelected(newSelected);
};
const handleChangePage = (event, newPage) => {
setPage(newPage);
};
const handleChangeRowsPerPage = event => {
setRowsPerPage(parseInt(event.target.value, 10));
setPage(0);
};
const handleChangeDense = event => {
setDense(event.target.checked);
};
const isSelected = name => selected.indexOf(name) !== -1;
const emptyRows = rowsPerPage - Math.min(rowsPerPage, rows.length - page * rowsPerPage);
const createSortHandler = property => event => {
handleRequestSort(event, property);
};
return (
<div style={{width:800, marginLeft:-100}}>
<Paper className={classes.paper}>
<TableContainer style={{ paddingRight:20, paddingLeft:20}}>
<Table
className={classes.table}
aria-labelledby="tableTitle"
size={'medium'}
aria-label="enhanced table"
>
<TableHead>
<TableRow>
{headCells.map(headCell => (
<TableCell
key={headCell.id}
align="left"
padding={headCell.disablePadding ? 'none' : 'default'}
sortDirection={orderBy === headCell.id ? order : false}
>
<TableSortLabel
active={orderBy === headCell.id}
direction={orderBy === headCell.id ? order : 'asc'}
onClick={createSortHandler(headCell.id)}
>
{headCell.label}
{orderBy === headCell.id ? (
<span className={classes.visuallyHidden}>
{order === 'desc' ? 'sorted descending' : 'sorted ascending'}
</span>
) : null}
</TableSortLabel>
</TableCell>
))}
</TableRow>
</TableHead>
<TableBody>
{stableSort(rows, getSorting(order, orderBy))
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
.map((row, index) => {
const isItemSelected = isSelected(row.name);
const labelId = `enhanced-table-checkbox-${index}`;
return (
<TableRow
hover
onClick={event => handleClick(event, row.name)}
role="checkbox"
aria-checked={isItemSelected}
tabIndex={-1}
key={row.name}
selected={isItemSelected}
>
<TableCell component="th" id={labelId} scope="row" padding="none">
{row.name}
</TableCell>
<TableCell align="left">{row.email ? "\u2705" : "\u2716"}</TableCell>
<TableCell align="left">{row.phone ? "\u2705": "\u2716"}</TableCell>
<TableCell align="left">{row.address ? "\u2705": "\u2716"}</TableCell>
<TableCell align="left">{row.payment ? "\u2705": "\u2716"}</TableCell>
</TableRow>
);
})}
{emptyRows > 0 && (
<TableRow style={{ height: (53) * emptyRows }}>
<TableCell colSpan={6} />
</TableRow>
)}
</TableBody>
</Table>
</TableContainer>
<TablePagination
rowsPerPageOptions={[5]}
component="div"
count={rows.length}
rowsPerPage={5}
page={page}
onChangePage={handleChangePage}
onChangeRowsPerPage={handleChangeRowsPerPage}
/>
</Paper>
</div>
);
}
function About() {
return (
<div style={{width:576}}>
<Typography variant="h5" style={{marginTop: 64}}>
💡 About
</Typography>
<br/>
<Typography variant="body2">
<strong>Exposed</strong> keeps track of <strong>who</strong> knows <strong>what </strong>about you.
By keeping track of where your information is shared, we hope to give you more control over your online footprint and to help you reflect on your online privacy.
<strong>None of this information leaves your computer.</strong>
</Typography>
</div>
);
}
function Copyright() {
return (
<Typography variant="body2" color="textSecondary" align="center" style={{marginTop: 64, marginBottom: 32}}>
{'Copyright © '}
<Link color="inherit" href="https://nwhacks2020.devpost.com/">
Exposed
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}
function App() {
const classes = useStyles();
return (
<Container maxWidth="sm">
<div style={{ marginTop: 48, }}>
<Typography variant="h4" component="h1" className="slide-down" gutterBottom>
<img src="images/icon48.png" style={{width:48, marginBottom:-10}}/>
Exposed
</Typography>
<span className="fade-in">
<Typography variant="body2" display="inline" gutterBottom>
We're keeping track of
</Typography>
<Typography variant="h5" display="inline" style={{color: '#75BBB6'}} gutterBottom>
{rows.length}
</Typography>
<Typography variant="body2" display="inline" gutterBottom>
entities that have information about you.
</Typography>
</span>
<br/><br/><br/>
<EntityTable/>
{/* <div style={{display:'inline-block'}}>
<Card>
<CardContent>
<Typography variant="h6" gutterBottom>
Amazon
</Typography>
<div id="card-body">
<div className="card-body-item">
<Typography variant="h5" component="h2">
Credit card
</Typography>
</div>
</div>
</CardContent>
</Card>
</div> */}
<About />
<Copyright />
</div>
</Container>
);
}
ReactDOM.render(
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<App />
</ThemeProvider>,
document.querySelector('#root'),
);
</script>
</body>
</html>