Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complete coding challenge #324

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

#header{
display:block;
justify-self: center;
background-size: 20px;
background-position-x: right;
background-position-y: center;
background-color: cornflowerblue;
border-radius: 20px;
border: 1px solid black;
}
.messageHeader{
border-top: 1px solid black;
border-left: 1px solid black;
border-right: 1px solid black;
display: block;
background-color: teal;
font-family: 'Press Start 2P', cursive;
font-size: 20px;
margin-left: 25%;
}
.newHead{
border-top: 1px solid black;
border-left: 1px solid black;
border-right: 1px solid black;
display: block;
background-color: cornflowerblue;
font-family: 'Press Start 2P', cursive;
font-size: 20px;
margin-left: 25%;
}
body{
background-color: rgba(56, 185, 105, 0.534);
background-image: url('https://i.kym-cdn.com/photos/images/original/001/331/213/35a.jpg');
background-repeat: no-repeat;
background-size: 350px;
background-position-x: 200px;
background-position-y: 20px;
background-attachment: fixed;
}

.content{
border-bottom: 1px solid black;
border-left: 1px solid black;
border-right: 1px solid black;
display: block;
margin-bottom: 10px;
background-color: grey;
font-family: 'Press Start 2P', cursive;
margin-left: 25%;
}
.newContent{
border-bottom: 1px solid black;
border-left: 1px solid black;
border-right: 1px solid black;
display: block;
margin-bottom: 10px;
background-color: teal;
font-family: 'Press Start 2P', cursive;
margin-left: 25%;
}
.newMessageContent{
display: none;
}
.messageContent{
display: none;
}
143 changes: 135 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,144 @@
<head>
<script src="js/mail-generator.js"></script>
<link href="css/style.css" rel="stylesheet" media="screen">
<script>
<script>
window.onload = function(){
// ALL OF YOUR JAVASCRIPT CODE SHOULD GO HERE.
// ALL OF YOUR JAVASCRIPT CODE SHOULD GO HERE.
// We have to use window.onload so your JavaScript doesn't execute until the page has loaded and all HTML has been downloaded to your browser

};
</script>
// container for header

let inbox = window.geemails;

function showHide2(){
let newContentMessage = this.querySelectorAll('.newMessageContent')[0];
if (newContentMessage.style.display === 'block'){
newContentMessage.style.display = 'none';
} else {
newContentMessage.style.display = 'block';
}
}

let intervalID = setInterval(newMessage, 400);

function newMessage(){
let nuNuNews = getNewMessage();
newCount++
newBod = nuNuNews.body;
newSub = nuNuNews.subject
newDate = nuNuNews.date
newSend = nuNuNews.sender


let newMessageHeader = document.createElement('div');
newMessageHeader.className = 'newHead';
document.body.appendChild(newMessageHeader)

let newDateElem = document.createElement('div');
newDateElem.className = 'newDate';
newDateElem.innerHTML = 'Date: ' + newDate;
newMessageHeader.appendChild(newDateElem);

let newSendElem = document.createElement('div');
newSendElem.className = 'newSend';
newSendElem.innerHTML = 'From: ' + newSend;
newMessageHeader.appendChild(newSendElem);

let newSubElem = document.createElement('div');
newSubElem.className = 'newSub';
newSubElem.innerHTML = 'Subject: ' + newSub;
newMessageHeader.appendChild(newSubElem);

let newContentButton = document.createElement('div');
newContentButton.className = 'newContent';
newContentButton.innerHTML = 'Show';
newContentButton.addEventListener('click', showHide2)
document.body.appendChild(newContentButton);

let newMessageElem = document.createElement('div');
newMessageElem.className = 'newMessageContent';
newContentButton.appendChild(newMessageElem);

let newBodyElem = document.createElement('div');
newBodyElem.className = 'newBody';
newBodyElem.innerHTML = 'Body: ' + newBod;
newMessageElem.appendChild(newBodyElem);

inboxCounter.innerHTML = 'Inbox: ' + newCount;
console.log(newCount)
stop();
}

let pageTitle = document.createElement('title');
pageTitle.innerHTML = 'Gee-Mail';
document.body.appendChild(pageTitle)

let headerBox = document.createElement('h1');
headerBox.id = 'header';
headerBox.innerHTML = 'Knw D Waz';
document.body.appendChild(headerBox);

for (i=0;i<inbox.length;i++){
let message = inbox[i];
let messageSubj = message.subject;
let messageSender = message.sender;
let messageBody = message.body;
let messageDate = message.date;

let messageHeader = document.createElement('div');
messageHeader.className = 'messageHeader';
document.body.appendChild(messageHeader)

let dateElem = document.createElement('div');
dateElem.className = 'date';
dateElem.innerHTML = 'Date: ' + messageDate;
messageHeader.appendChild(dateElem);

let senderElem = document.createElement('div');
senderElem.className = 'sender';
senderElem.innerHTML = 'From: ' + messageSender;
messageHeader.appendChild(senderElem)

let subjectElem = document.createElement('div');
subjectElem.className = 'subject';
subjectElem.innerHTML = 'Subject: ' + messageSubj;
messageHeader.appendChild(subjectElem)

let contentButton = document.createElement('div');
contentButton.className = 'content';
contentButton.innerHTML = 'Show';
document.body.appendChild(contentButton);

let messageElem = document.createElement('div');
messageElem.className = 'messageContent';
contentButton.appendChild(messageElem);

let bodyElem = document.createElement('div');
bodyElem.className = 'body';
bodyElem.innerHTML = 'Body: ' + messageBody;
messageElem.appendChild(bodyElem);
}
let contentButton = document.getElementsByClassName('content')
for(i=0;i<inbox.length;i++){
contentButton[i].addEventListener('click', showHide);
}

function showHide(){
let contentMessage = this.querySelectorAll('.messageContent')[0];
if (contentMessage.style.display === 'block'){
contentMessage.style.display = 'none';
} else {
contentMessage.style.display = 'block';
}
}

let newCount = inbox.length;
let inboxCounter = document.createElement('h4');
inboxCounter.innerHTML = 'inbox: ' + newCount;
headerBox.appendChild(inboxCounter)

}
</script>
</head>
<body>
<div class="container" id="main">
Build Me!
</div>
</body>
</html>
1 change: 1 addition & 0 deletions js/mail-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@
window.getNewMessage = getNewMessage;
loadGeeMails();
})();