diff --git a/js/main.js b/js/main.js index 8d4de78..42270cf 100644 --- a/js/main.js +++ b/js/main.js @@ -1,5 +1,5 @@ - +//class to add a student function Student(name, title, email, bio, img){ this.name = name; this.title = title; @@ -8,14 +8,14 @@ function Student(name, title, email, bio, img){ this.img = img; printProfile(this.name, this.title, this.email, this.bio, this.img) } - +//create an image from a source function addImage(src = 'https://www.sparklabs.com/forum/styles/comboot/theme/images/default_avatar.jpg'){ var imgdiv = document.createElement('div'); imgdiv.style.backgroundImage = 'url(' + src + ')'; imgdiv.classList.add('circle'); return imgdiv; } - +//create name function createName(name){ /*classList.push(name)*/ var newh2 = document.createElement('h2'); @@ -23,28 +23,28 @@ function createName(name){ newh2.appendChild(newh2Text); return newh2; } - +//create title function createTitle(title){ var newh3 = document.createElement('h3'); var newh3Text = document.createTextNode(title); newh3.appendChild(newh3Text); return newh3; } - +//create bio function createBio(bio){ var newp = document.createElement('p'); var newpText = document.createTextNode(bio); newp.appendChild(newpText); return newp; } - +//create email function createEmail(email){ var newh4 = document.createElement('h4'); var newh4Text = document.createTextNode(email); newh4.appendChild(newh4Text); return newh4; } - +//bring all the elements together to display them function printProfile(name, title, email, bio, src){ var newDiv = document.createElement('div'); newDiv.classList.add('profile'); @@ -57,10 +57,11 @@ function printProfile(name, title, email, bio, src){ content.appendChild(newDiv); } - +//capitalize input strings function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } +//smile to unlock function (function() { console.log ("huh"); var locker = document.querySelector('smile-to-unlock'); @@ -77,9 +78,9 @@ function capitalizeFirstLetter(string) { }); - +//after page is loaded... document.addEventListener("DOMContentLoaded", function() { - + //if the user smiles, display page. if not, then give them an alert window.addEventListener('userHappy', function(){ document.querySelector("#hide-after-smile").classList.add('hidden'); @@ -88,7 +89,7 @@ document.addEventListener("DOMContentLoaded", function() { document.querySelector("#smile-to-unlock").classList.remove('hidden'); }); - + //adding instances of Student var david = new Student('David Kerr', 'Dork', 'david.m.kerr@uconn.edu', 'I\'m a DMD student at UConn working on a concentration in web design. I like sci-fi robots and spaceships, and enjoy building models of them.', 'https://vignette.wikia.nocookie.net/gundam/images/5/5e/Gundam_Exia_LOL.jpg/revision/latest?cb=20101019165531'); var emilyR = new Student('Emily Ruffell', 'Can you read for the class?', 'reviveVine@vine4ever.com', 'What up, I\'m Emily, I\'m twenty-three and I never fucking learned how to read.', 'https://files.slack.com/files-pri/T040V7VBL-FA9KYBBL4/emilyr.png'); var max = new Student('Max Nonken', 'Adventure Seeker', 'max.nonken@uconn.edu', 'I’m just trying to live everyday to the fullest.', 'https://files.slack.com/files-pri/T040V7VBL-FA9TQ4PQA/max.jpg'); @@ -102,17 +103,14 @@ document.addEventListener("DOMContentLoaded", function() { var tupperware = document.querySelector('#content'); - var smile = document.querySelector('#password'); - - - + //so you can press enter and have the button work submit.addEventListener('click', function(event){ event.preventDefault(); }) - + //put everything in the form together to add a new student submit.addEventListener('click', function(){ var fname = document.querySelector('#userfname').value; var lname = document.querySelector('#userlname').value;