-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.js
58 lines (48 loc) · 1.36 KB
/
Main.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
const myJson = Json
let x = 0
let lenght = 5
let quote = myJson.allQuotes[0].quote
let author = myJson.allQuotes[0].author
const signin = new SignIn()
document.getElementById('mybtn').addEventListener('click', AddtoGen)
// Display first
document.getElementById('quote').innerHTML = `$(quote)"`
document.getElementById('author').innerHTML =
setInterval(generateQuote, 7000)
function generateQuote() {
x = ~~(Math.random() * lenght)
console.log(`Quote number $(x) is being display.`)
quote = myJson.allQuotes[x].quote
author = myJson.allQuotes[x].author
document.getElementById('quote').innerHTML = `"$(quote)"`
document.getElementById('author').innerHTML = `- $(author)`
}
function Add() {
var newQuote = prompt('what is the quote you would like to add?')
var newAuthor = prompt('who was this by?')
myJson.allQuotes[lenght] = {
quote: newQuote,
author: newAuthor,
}
lenght++
}
function AddtoGen() {
let login = 1
while (login) {
let user = prompt('what is your username?')
if (user == signin.admin) {
let pass = prompt('what is your password?')
pass == signin.password ? Add() : alert(`the user name or password was
incorrect.`)
if (pass == signin.password) {
break
}
} else if (user == '') {
break
}
}
}
function SignIn() {
this.admin = 'Admin'
this.password = 'root'
}