Git Product home page Git Product logo

hyf-javascript3's People

Contributors

mahmutkaya avatar

Watchers

 avatar

Forkers

elmira202003

hyf-javascript3's Issues

hey man

hey, bro, your code is good and everything works fine, only remove the console.logs and everything will be perfect. good job.

uncomplete

hey, Mahmut please complete your code and if you need any help let me know I have finally understood it.

Feedback final homework

Hi Mahmut,

Here is my feedback on your final homework.

Overall, you code seems to work fine. As potential employer I would probably offer you an internship on this basis this work. Well done!

I'll now go through the individual criteria that I defined for this assignment:

  1. Your code must run without errors.

    Requirement is met.

  2. Your web page must be fit-for-purpose and well-designed. Place yourself in the role of an end-user: is the web page attractive and useful, or will you quickly click away?

    It would have been nice if you included images (avatars) for the repo contributers.

    Apart from that you web page looks fine.

  3. Your code must be well-formatted.

    Requirement is met.

  4. Your repo must contain an .eslintrc.json file. There should be no avoidable ESLint warnings in your code. If you can fix the warning, do so. Please be prepared to account for any remaining warnings.

    Requirement is met.

  5. There should be no spelling errors in variable and function names, text strings and comments. If the VSCode spelling checker flags certain words as incorrect (and sometimes that is inevitable) you should be able to explain why that is. If you are uncertain about some word, consult an English dictionary.

    Requirement is met.

  6. Variable and function names must conform to these naming conventions.

    There is no reason to use abbreviated variable and function names. The abbreviation contr is far less obvious than the full word contributor.

    Same for bttn. There is no real advantage over using the full word button.

    myFoot -> myFooter or just footer
    The variable names below do not describe their purpose:

    const users = "/users";
    const hyf = "/hackyourfuture";
    const repos = "/repos";
    const contr = "/contributors";

    I would probably opt for:

    const usersSegment = "/users";
    const hyfSegment = "/hackyourfuture";
    const reposSegment = "/repos";
    const contributersSegment = "/contributors";

    These functions do not 'get' anything. They render HTML.

    function getContr(data)
    function getOneRepo(data)
    function getAllRepos(data)
    function getUsers(data)

    The should probably be called renderXXX, where XXX is what you want to render.

  7. Consider blank lines to convey a meaning, similar to using blank lines to separate paragraphs in a piece of written text. A blank line between function/method definitions is fine. A blank line that breaks up a piece of code that actually belongs together is wrong. Whenever you add a blank line, carefully consider whether the blank line helps or hurts readability. Keep it in only if it helps.

    Requirement is met.

  8. There should be no commented out code in your final homework. (Just like you wouldn't leave crossed out text in your CV).

    Requirement is met.

  9. There should be no unnecessary console.log statements in your final code. These statements are fine when developing and debugging, but not in your final product (and, as per point 8 above, don't just comment them out).

    Line 54 contains a console.log which should not be there in final code.

  10. Review your own code as if you were an employer yourself. Would you offer yourself an internship or job when running and looking at the code?

    I would probably say: yes.

I have refactored your code a bit to use more meaningful names for some variables and functions, introducing fat arrow functions and chained .then methods. However, functionality-wise the code does the same thing.

I added the createAndAppend utility function that we used in class.

"use strict";
{
  const apiPath = "https://api.github.com";
  const usersSegment = "/users";
  const hyfSegment = "/hackyourfuture";
  const reposSegment = "/repos";

  function renderPage() {
    const mainContainer = createAndAppend("div", document.body);
    mainContainer.id = "container";

    createAndAppend("footer", document.body);

    const header = createAndAppend("div", mainContainer);
    header.id = "header";

    createAndAppend("h1", header, "Repositories");

    const srcInput = createAndAppend("input", header);

    const searchButton = createAndAppend("button", header, "hyf-repos search");
    const fullListButton = createAndAppend("button", header, "hyf-repos full list");
    const usersReposButton = createAndAppend("button", header, "users repos");

    const reposContainer = createAndAppend("div", mainContainer);
    reposContainer.id = "repos-container";

    const contributorsContainer = createAndAppend("div", mainContainer);
    contributorsContainer.id = "contributors-container";

    const clearContainers = () => {
      reposContainer.innerHTML = "";
      contributorsContainer.innerHTML = "";
    };

    searchButton.addEventListener("click", () => {
      clearContainers();
      const url = apiPath + reposSegment + hyfSegment + "/" + srcInput.value;
      getData("GET", url)
        .then(data => {
          renderHyfRepo(data, reposContainer);
          return getData("GET", data.contributors_url);
        })
        .then(data => renderContributors(data, contributorsContainer))
        .catch(console.error);
    });

    fullListButton.addEventListener("click", () => {
      clearContainers();
      const url = apiPath + usersSegment + hyfSegment + reposSegment;
      getData("GET", url)
        .then(data => renderAllHyfRepos(data, reposContainer))
        .catch(console.error);
    });

    usersReposButton.addEventListener("click", () => {
      clearContainers();
      const url = apiPath + usersSegment + "/" + srcInput.value + reposSegment;
      getData("GET", url)
        .then(data => renderUserRepos(data, reposContainer))
        .catch(console.error);
    });
  }

  function renderContributors(data, container) {
    let htmlString = "";
    htmlString = "<h4> contributors: </h4>";
    for (const item of data) {
      htmlString +=
        "<div class='div4'>" +
        "<p>" +
        "<em>" +
        item.login +
        "</em>" +
        "</p>" +
        "</div>";
    }
    container.insertAdjacentHTML("beforeEnd", htmlString);
  }

  function renderHyfRepo(data, container) {
    const htmlString =
      "<div class='repo'>" +
      "<li><a target='_blank' href=" +
      data.html_url +
      ">" +
      data.name +
      "</a></li>" +
      "<p>" +
      " created date: " +
      data.created_at +
      "</p>" +
      "<p>" +
      " fork: " +
      data.forks +
      " star: " +
      data.stargazers_count +
      " watch: " +
      data.watchers +
      "</p>" +
      "<h3>" +
      " Description: " +
      data.description +
      "</h3>" +
      "</div>";
    container.insertAdjacentHTML("beforeEnd", htmlString);
  }

  function renderAllHyfRepos(data, container) {
    let htmlString = "";
    for (const item of data) {
      htmlString +=
        "<div class='repo'>" +
        "<li><a target='_blank' href=" +
        item.html_url +
        ">" +
        item.name +
        "</a></li>" +
        "<p>" +
        " created date: " +
        item.created_at +
        "</p>" +
        "<p>" +
        " fork: " +
        item.forks +
        " star: " +
        item.stargazers_count +
        " watch: " +
        item.watchers +
        "</p>" +
        "<h3>" +
        " Description: " +
        item.description +
        "</h3>" +
        "</div>";
    }
    container.insertAdjacentHTML("beforeEnd", htmlString);
  }

  function renderUserRepos(data, container) {
    let htmlString =
      "<div class='imgDiv'>" +
      "<img src='" +
      data[0].owner.avatar_url +
      "'>" +
      "<br>" +
      "<h3>" +
      data[0].owner.login +
      " repositories: " +
      "</h3>" +
      "</div>";
    for (const item of data) {
      htmlString +=
        "<div class='repo'>" +
        "<li><a target='_blank' href=" +
        item.html_url +
        ">" +
        item.name +
        "</a></li>" +
        "<p>" +
        " created date: " +
        item.created_at +
        "</p>" +
        "<p>" +
        " fork: " +
        item.forks +
        " star: " +
        item.stargazers_count +
        " watch: " +
        item.watchers +
        "<p>" +
        "<h3>" +
        " Description: " +
        item.description +
        "</h3>" +
        "</div>";
    }
    container.insertAdjacentHTML("beforeEnd", htmlString);
  }

  function getData(method, url) {
    return new Promise(function (resolve, reject) {
      const xhr = new XMLHttpRequest();
      xhr.open(method, url);
      xhr.onload = () => {
        if (xhr.status >= 200 && xhr.status < 300) {
          resolve(JSON.parse(xhr.response));
        } else {
          reject(new Error(xhr.statusText));
        }
      };
      xhr.onerror = () => reject(new Error(xhr.statusText));
      xhr.send();
    });
  }

  function createAndAppend(name, append, innerHTML) {
    const child = document.createElement(name);
    append.appendChild(child);
    if (innerHTML !== undefined) {
      child.innerHTML = innerHTML;
    }
    return child;
  }

  renderPage();
}

Feedback Homework JS3 Week 2

@mahmutkaya Hey, colleague, you did a really fantastic job, I really appreciate your XMLHttpRequest function, also your DOM, that is really nice, your code is really understandable and so neat.I hope little bit improve your CSS file rest is an amazing job.

Feedback Homework JS3 Week 1

Hi Mahmut, here is my feedback on your homework.

  1. Stars, writers and ratings are arrays. Their names should indicate 'plural': stars, writers, ratings.
  2. The getAverageRating() method is missing.
  3. The dateOfBirth parameter of a StaffMember constructor expects a date, not just a year.
  4. The director should be a StaffMember, for instance:
    const myMovie = new Movie("Concussion", new StaffMember("Peter Landesman", "director", 1965));
  5. I'm missing this code from the assignment:
    console.log(myMovie.getStars().map(actor => `${actor.getName()} ${actor.getAge()}`));
    const director = myMovie.getDirector();
    console.log(`Director: ${director.getName()}`);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.