Skip to content

Commit

Permalink
[REFACTOR] main.js
Browse files Browse the repository at this point in the history
changes comment method
  • Loading branch information
Rocker2102 committed Dec 20, 2020
1 parent b934ec9 commit d06d36b
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ function fetchRepos(force = false) {
function updateRepos(data){
const repoContainer = document.querySelector(".repo-container");
data.forEach((val) => {
// Creating Repo card
/* Creating Repo card */
let repoItem = createElement("div", {class: "col-md-6 col-lg-4 repo-item"});
let box = createElement("div", {class: "box"});
let icon = createElement("div", {class: "icon"});

// Fetching image for repository
/* Fetching image for repository */
let iconImg = val.name.split("-")[0].toLowerCase();
let imgSource = "";

if (iconImg === "website") {
// For devcans website repo
/* For devcans website repo */
imgSource = "assets/img/icon.png"
} else {
if (iconImg === "web") {
Expand All @@ -123,7 +123,7 @@ function updateRepos(data){
repoContainer.appendChild(repoItem);
});

// Setting up listener for show more button
/* Setting up listener for show more button */
const button = document.querySelector(".more-btn");
button.addEventListener("click", () => {
button.childNodes[1].classList.toggle("more-btn-inactive");
Expand Down Expand Up @@ -232,7 +232,7 @@ function createElement(tag, options = {}, html = "") {
return e;
}

// Slider
/* Slider */
let index = 1;
let slideContainer;
let slider;
Expand Down Expand Up @@ -363,43 +363,42 @@ class TypeWriter {
this.type();
}

// Type method
/* Type method */
type() {
// current index of word
/* current index of word */
const current = this.wordIndex % this.words.length;
// Get full text of current word
/* Get full text of current word */
const fullText = this.words[current];

// Check if deleting
/* Check if deleting */
if (this.isDeleting) {
// Remove char
/* Remove char */
this.text = fullText.substring(0, this.text.length - 1);
} else {
// Add char
/* Add char */
this.text = fullText.substring(0, this.text.length + 1);
}

// Insert text into element
/* Insert text into element */
this.textElement.innerHTML = this.text;

// Initial type Speed
/* Initial type Speed */
let typeSpeed = 250;

if (this.isDeleting) {
typeSpeed /= 2;
}

// If word is complete
/* If word is complete */
if (!this.isDeleting && this.text === fullText) {
// Make pause at end
/* Make pause at end */
typeSpeed = this.wait;
// Set delete to true
/* Set delete to true */
this.isDeleting = true;
} else if (this.isDeleting && this.text === "") {
this.isDeleting = false;
//
this.wordIndex++;
// Pause before start typing
/* Pause before start typing */
typeSpeed = 500;
}
setTimeout(() => this.type(), typeSpeed);
Expand Down Expand Up @@ -450,7 +449,7 @@ function init() {
const textElement = document.querySelector(".txt-type");
const words = JSON.parse(textElement.getAttribute("data-words"));
const wait = textElement.getAttribute("data-wait");
// init TypeWriter
/* init TypeWriter */

new TypeWriter(textElement, words, wait);
}

1 comment on commit d06d36b

@Rocker2102
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment method (before this commit) may have caused problems during file minifying.

Please sign in to comment.