Skip to content
Permalink
ba7f9e2083
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
139 lines (100 sloc) 4.29 KB
function Student(name, title, email, bio, img){
this.name = name;
this.title = title;
this.email = email;
this.bio = bio;
this.img = img;
printProfile(this.name, this.title, this.email, this.bio, this.img)
}
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;
}
function createName(name){
/*classList.push(name)*/
var newh2 = document.createElement('h2');
var newh2Text = document.createTextNode(name);
newh2.appendChild(newh2Text);
return newh2;
}
function createTitle(title){
var newh3 = document.createElement('h3');
var newh3Text = document.createTextNode(title);
newh3.appendChild(newh3Text);
return newh3;
}
function createBio(bio){
var newp = document.createElement('p');
var newpText = document.createTextNode(bio);
newp.appendChild(newpText);
return newp;
}
function createEmail(email){
var newh4 = document.createElement('h4');
var newh4Text = document.createTextNode(email);
newh4.appendChild(newh4Text);
return newh4;
}
function printProfile(name, title, email, bio, src){
var newDiv = document.createElement('div');
newDiv.classList.add('profile');
newDiv.appendChild(addImage(src));
newDiv.appendChild(createName(name));
newDiv.appendChild(createTitle(title));
newDiv.appendChild(createEmail(email));
newDiv.appendChild(createBio(bio));
content.appendChild(newDiv);
}
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
(function() {
console.log ("huh");
var locker = document.querySelector('smile-to-unlock');
locker.start();
locker.addEventListener('userSmiled', function (ev) {
// --> Add the code to show the free content here <--
smile.classList.remove('hidden');
tupperware.classList.add('hidden');
locker.end(); // End the locker so the camera is shutdown
})
});
document.addEventListener("DOMContentLoaded", function() {
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')
var rachel = new Student('Rachel Sarnie', 'Designer', 'rachel.sarnie@uconn.edu', ' I write with my left hand, but do everything else with my right. I’m a fake-lefty.', 'https://icenter.uconn.edu/wp-content/uploads/sites/168/2017/12/Rachel-Rachel-Sarnie-768x768.jpg')
classList = ['Amanda Brickner', 'Daniel Bean', 'David Kerr', 'Emily McAndrew', 'Max Nonken', 'Rachel Sarnie', 'Emily Ruffell'];
var tupperware = document.querySelector('#content');
var smile = document.querySelector('#password');
submit.addEventListener('click', function(event){
event.preventDefault();
})
submit.addEventListener('click', function(){
var fname = document.querySelector('#userfname').value;
var lname = document.querySelector('#userlname').value;
fname = capitalizeFirstLetter(fname);
lname = capitalizeFirstLetter(lname);
var name = (fname + ' ' + lname);
var title = document.querySelector('#usertitle').value;
title = capitalizeFirstLetter(title);
var email = document.querySelector('#useremail').value;
var bio = document.querySelector('#userbio').value;
var img = document.querySelector('#userimg').value;
if (img == ''){
img = 'https://www.sparklabs.com/forum/styles/comboot/theme/images/default_avatar.jpg';
}
if (fname == ''){
alert('Please enter a first name');
}
else if (lname == ''){
alert('Please enter a last name');
}
else{
var newStudent = new Student(name, title, email, bio, img);
}
document.getElementById('addstudent').reset();
});
});