-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
97 lines (90 loc) · 3.27 KB
/
index.js
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
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
// Adds style.css to the document <head>
window.addEventListener(
'load',
(e) => {
const site1 = {
id: 'id1',
name: '4501 DSA Cracker',
url: 'https://450dsa.com/',
}
const site2 = {
id: 'id2',
name: 'Algorithm Examples',
url: 'https://algorithmexamples.com/',
}
const site3 = {
id: 'id3',
name: 'Codesmith',
url: 'https://codesmith.io',
}
// const site4 = {
// id: id4,
// name: 'Github',
// url: 'https://github.com/',
// }
// const site5 = {
// id: id5,
// name: 'Gists',
// url: 'https://gist.github.com/',
// }
// const site6 = {
// id: id6,
// name: 'Immersive Prep Plan',
// url: 'https://codesmithdocs.s3-us-west-1.amazonaws.com/Codesmith+Documents/Immersive-Prep-Plan.pdf',
// }
const blockedSite = {
id: 'idBlocked',
url: 'https://youtube.com',
}
// Add link to style.css
console.log('using indexDev.js')
var link = document.createElement('link')
link.rel = 'stylesheet'
link.type = 'text/css'
link.href = './style.css'
document.head.appendChild(link)
// Logic for replacing website body with our app
var body = document.querySelector('body')
var main = document.createElement('main')
body.innerHTML = ''
document.body.appendChild(main)
main.innerHTML = `
<div id=${site1.id} class="btn btn-primary">${site1.name}</div>
<div id=${site2.id} class="btn btn-primary">${site2.name}</div>
<div id=${site3.id} class="btn btn-primary">${site3.name}</div>
<div id=${blockedSite.id} class="btn btn-wide">Continue to Page</div>`
// Query Selectors
// select divs by id
const site1Div = document.querySelector(`#${site1.id}`)
const site2Div = document.querySelector(`#${site2.id}`)
const site3Div = document.querySelector(`#${site3.id}`)
const blockedSiteDiv = document.querySelector(`#${blockedSite.id}`)
// Event Handlers
// add onclick event to query selected div
site1Div.addEventListener('click', () => {
window.location.href = site1.url
})
site2Div.addEventListener('click', () => {
window.location.href = site2.url
})
site3Div.addEventListener('click', () => {
window.location.href = site3.url
})
blockedSiteDiv.addEventListener('click', () => {
window.location.href = blockedSite.url
})
// // Add background image
// const getRandom = async (req, res) => {
// const imageData = await fetch(`https://api.unsplash.com/photos/random?client_id=${UNSPLASH_PUBLIC_KEY}&content_filter=high`).json()
// if (imageData) {
// res.json(imageData)
// } else {
// res.status(404)
// throw new Error('Image not found')
// }
// }
},
false
)
},{}]},{},[1]);