reading-notes

Class 11 - Audio and Video in HTML; Domain Modeling Revisited

Lab 11 - Odd Duck Products Pt. 1

Setup

  1. As a user, I would like to display three unique products by chance so that the viewers can pick a favorite.

    • Create a constructor function that creates an object associated with each product, and has the following properties:

      • Name of the product
      • File path of image
      • Times the image has been shown
    • Create an algorithm that will randomly generate three unique product images from the images directory and display them side-by-side-by-side in the browser window.
    • For each of the three images, increment its property of times it has been shown by one.
    • Attach an event listener to the section of the HTML page where the images are going to be displayed.
    • Once the users ‘clicks’ a product, generate three new products for the user to pick from.
  2. As a user, I would like to track the selections made by viewers so that I can determine which products to begin production on.

    • In the constructor function define a property to hold the number of times a product has been clicked.

    • After every selection by the viewer, update the newly added property to reflect if it was clicked.

  3. As a user, I would like to control the number of rounds a user is presented with so that I can control the voting session duration.

    • By default, the user should be presented with 25 rounds of voting before ending the session.

    • Keep the number of rounds in a variable to allow the number to be easily changed for debugging and testing purposes.

  4. As a user, I would like to view a report of results after all rounds of voting have concluded so that I can evaluate which products were the most popular.

    • Create a property attached to the constructor function itself that keeps track of all the products that are currently being considered.

    • After voting rounds have been completed, remove the event listeners on the product.

    • Add a button with the text View Results, which when clicked displays the list of all the products followed by the votes received, and number of times seen for each. Example: banana had 3 votes, and was seen 5 times.

      • NOTE: Displayed product names should match the file name for the product. Example: the product represented with dog-duck.jpg should be displayed to the user as exactly “dog-duck” when the results are shown.
  5. Using Lighthouse in the Chrome DevTools, analyze the accessibility of your application.

    • In this module, try for a score higher than 80. Make necessary adjustments based on the report to achieve that score.

    • Add a screenshot of your score to your README.md file.

  6. Developer Style Guide

    • Create a new repo for this multi-lab project called odd-duck.

    • Scaffold your repo with the usual README, CSS, JS, and HTML files, plus a img/ directory.

    • Include in your repository a .eslintrc.json file whose contents are copied from the eslintrc.json file in the class repository.

    • Retrieve the assets from the assets/ directory and place them in your image directory.

    • Do today’s work on a branch called lab11.

This is an individual assignment today, but you are free to collaborate with classmates if you want. Just be sure that if you do, be sure to make note of that collaboration in your README file.

Written Class Notes

// Global Variables
// elements, and counters, and state
const goatsContainer = document.getElementById("goats");
const reportContainer = document.getElementById("report");
// querySelectorAll = list of elements
// querySelector = 1 element
const image1 = document.querySelector('#goats img:first-child');
const image2 = document.querySelector('#goats img:nth-child(2)');

const button = document.getElementById("showResults");

// variable way:
// let numClicksSoFAr = 0;
// let numClicksAllowed = 5;
// let allGoats = [];

// The global "State" of the application
let state = {
  numClicksSoFar: 0,
  numClicksAllowed: 5,
  allGoats: [],
};


// Constructor
function Goat( name, image ) {
  this.name = name;
  this.imageFile = image;
  this.votes = 0;
  this.views = 0;
  state.allGoats.push(this);
}


// Helper Functions

function renderGoats() {
  // pick 2 random goats from our array

  function pickRandomGoat() {
    return Math.floor( Math.random() * state.allGoats.length );
  }

  let goat1 = pickRandomGoat(); // 4
  let goat2 = pickRandomGoat(); // 6

  // If they are different to start with
  while( goat1 === goat2 ) {
    goat2 = pickRandomGoat();
  }

  // put the goats on screen
  // <img src="" alt="" />
  image1.src = state.allGoats[goat1].imageFile;
  image1.alt = state.allGoats[goat1].name;

  image2.src = state.allGoats[goat2].imageFile;
  image2.alt = state.allGoats[goat2].name;

  state.allGoats[goat1].views++;
  state.allGoats[goat2].views++;

}

function renderResultsButton() {
  button.style.display = "block";
}

function renderResults() {
  console.log("Showing the results");
}

function handleClick(event) {
// Get the name from the alt tage of the image
let goatName = event.target.alt;

// Loop the array and find that goat, update the vote and stop
for ( let i = 0; i < state.allGoats.length; i++ ) {
  if( goatName === state.allGoats[i].name ) {
    state.allGoats[i].votes++;
    break;
  }
}

state.numClicksSoFar++;

if(state.numClicksSoFar >= state. numClicksAllowed) {
  // remove the event handler
  removeListener();
  // show the button which would let you render the results
  renderResultsButton();
} else {
  renderGoats();
}

}

function setupListeners() {
  // Old way = inline function
  // goatsContainer.addEventListener('click", function(event) { });

  // Better way: named callback
goatsContainer.addEventListener("click", handleClick);
button.addEventListener("click", renderResults)

// Alternatively: have an event listener oneach images
// image1.addEventListener("click", handleClick);
// image2.addEventListener("click", handleClick);
}

function removeListener() {
goatsContainer.removeEventListener("click", handleClick);
}

// Do I need to make these into variables????
// If not (hint), how can I do it without making them variables?
new Goat("Cruisin Goat", "images/cruisin-goat.jpg");
new Goat("Float Your Goat", "images/float-your-goat.jpg");
new Goat("Goat out of Hand", "images/goat-out-of-hand.jpg");
new Goat("Kissing Goat", "images/kissing-goat.jpg");
new Goat("Sassy!", "images/sassy-goat.jpg");
new Goat("Smiling Goat", "images/smiling-goat.jpg");
new Goat("Sweater Goat", "images/sweater-goat.jpg");

renderGoats();
setupListeners();a

// debugger;

Describe and Define

Answer

  1. What is Object-Oriented Programming?

  2. To use CSS Grid, the parent element (container) must have the display property set to what value?

    • display: grid
  3. The Array method of push() adds one or more elements to the end of an array.

  4. The Array method of pop() removes the last element from an array.

  5. The Array method of shift() removes the first element from an array.

  6. The Array method of unshift() adds one or more elements to the beginning of an array.

  7. The Array method of splice() changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.

Read 11 - Audio, Video, Images

Resources Link/Pages

Bookmark and Review: Images in HTML and Other Embedding Technologies

Video and Audio Content

  1. Video and Audio Content

A Complete Guide To Grid

  1. A Complete Guide To Grid

Responsive Images

  1. Responsive Images

Answer

Statement on why this topic matter as it relates to what I’m studying in this module:

Video and Audio Content

  1. Explain how the ability to use video and audio on the web has evolved since the early 2000s.
  1. Describe the use of the src and controls attributes in the <video> element.
  1. Why is it important to have fallback content inside the <video> element?
  1. Write a very short story where <audio> and <video> are characters.

There were two siblings who both grew up to have incredible artistic talent. Audi was a singer and vidi was a painter and filmmaker but honestly whatever she could image she could visually create. They both worked together on projects and artwork that created an immersive experience with imagery from vidi and sound from audi.

A Complete Guide To Grid

  1. How does Grid layout differ from Flex?

Grid Layout: you can create complex layouts by defining rows and columns, and placing items into specific grid cells versus… Flexbox: a method to layout items in rows or columns by distributing space along an axis or in containers

-

  1. Grid container, grid item, and grid line are a few important terms to understand when using Grid. Please describe these terms in a few sentences.

Responsive Images

  1. Besides making a site visually appealing across different screen sizes, why should developers make images responsive?
  1. Define the following <img> attributes srcset and sizes. Write an example of how they are used.
  1. How is srcset more helpful for responsive images than CSS or JavaScript?

Things I want to know more about

Career 11 - Give Your 60 Second Professional Pitch

  1. Use these resources to learn how to create your personal-professional pitch. Aim for your pitch to be 30 to 60 seconds. Submit a written version.

    • Effective public speaking

      • Rate of speech, strategic pauses
      • Body language : hands, pacing
      • Eye contact w/ audience
      • Practice
      • Don’t write text but bullet points
      • Film yourself
      • Know who your audience is
      • Focus more on the topic and less on the aspect of your speech
      • Good first impression
      • Breathe, don’t focus on perfection
    • How to create a professional pitch: Guide I and Guide II

      • Summary:
  1. Be prepared to utilize your personal pitch on project demo day when introducing yourself. Use these questions to guide you as you write.

    • What were you doing before you decided to change careers?

      • Before deciding to change careers, I had graduated from college with a degree in environmental science. However, I realized that this field wasn’t aligning with my long-term goals and aspirations. Feeling uncertain about my career path, I took the first job opportunity that came my way, working as a receptionist at a veterinary clinic. I quickly moved up the ranks to become the lead receptionist, and I’ve worked there for over two years. Despite the promotion, I felt stagnant and knew I needed a change to pursue a more fulfilling and stable career.
    • Why did you decide to learn Software Development?

      • I decided to learn software development because I recognized the growing demand for tech-related skills in the job market. Seeing the potential for stable career opportunities and financial growth, I chose to venture into the field of software development. I was drawn to the idea of working in a dynamic and ever-evolving industry, where creativity and problem-solving skills are highly valued.
    • Why did you pick this specific skill?
      • I specifically chose software development because of its versatility and the wide range of applications it offers. I was intrigued by the ability to create innovative solutions, whether it’s developing user-friendly applications, designing impactful websites, or contributing to cutting-edge technology. The prospect of building something meaningful and tangible through coding appealed to my desire for creative expression and intellectual challenge.
    • Ideal environment you’d use this skill?

      • My ideal environment to apply my software development skills would be in a collaborative and innovative tech company. I envision working in a team-oriented setting where creativity is encouraged, and where I can contribute to projects that have a positive impact on society or the environment. I am particularly interested in roles that allow for continuous learning and growth, where I can collaborate with diverse professionals and contribute to the development of impactful software solutions.
    • Previous experiences that give a boost to your new career in tech?
      • My previous experiences as a lead receptionist have equipped me with valuable transferable skills that are highly applicable in the tech industry. Working in a fast-paced veterinary clinic honed my ability to multitask, solve problems on the spot, and communicate effectively, both with team members and clients. These skills are crucial in software development, where teamwork, adaptability, and clear communication are essential for project success. Additionally, my experience in a client-facing role has given me a unique perspective on user experience, which I believe will be valuable when creating user-friendly software applications.
  2. Written Version

Hi there, I’m Xin Deng, and I’m starting an exciting journey from veterinary clinic team management to the forward-thinking world of software development. While working as a lead receptionist, I honed my multitasking and problem-solving skills. But, I felt stagnant and knew I needed a change to pursue a more fulfilling and stable career path that involved a lot more creativity and impact. I entered this field because it merges creativity with the potentials of technology. But what really motivates me is the opportunity to design user-friendly applications and be a part of pioneering innovations. I excel in environments where collaboration is central, and where progressive ideas come to life. My advantage lies in my background in client-facing roles, where I’ve come to understand the importance of seamless user interactions. I’m excited to apply this expertise in the tech industry. With strong problem-solving skills and effective communication abilities, I’m looking forward to making a valuable contribution to any software development team.

Learning Journal

Write a brief reflection on your learning today, or use the prompt below to get started.

There’s an old saying: “Experience is what you get when you didn’t get what you wanted.” What strategies do you use for learning from disappointments (both big and small) so that the net experience becomes productive and positive?