Skip to content

Commit d06d36b

Browse files
committed
[REFACTOR] main.js
changes comment method
1 parent b934ec9 commit d06d36b

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

assets/js/main.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,17 @@ function fetchRepos(force = false) {
9191
function updateRepos(data){
9292
const repoContainer = document.querySelector(".repo-container");
9393
data.forEach((val) => {
94-
// Creating Repo card
94+
/* Creating Repo card */
9595
let repoItem = createElement("div", {class: "col-md-6 col-lg-4 repo-item"});
9696
let box = createElement("div", {class: "box"});
9797
let icon = createElement("div", {class: "icon"});
9898

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

103103
if (iconImg === "website") {
104-
// For devcans website repo
104+
/* For devcans website repo */
105105
imgSource = "assets/img/icon.png"
106106
} else {
107107
if (iconImg === "web") {
@@ -123,7 +123,7 @@ function updateRepos(data){
123123
repoContainer.appendChild(repoItem);
124124
});
125125

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

235-
// Slider
235+
/* Slider */
236236
let index = 1;
237237
let slideContainer;
238238
let slider;
@@ -363,43 +363,42 @@ class TypeWriter {
363363
this.type();
364364
}
365365

366-
// Type method
366+
/* Type method */
367367
type() {
368-
// current index of word
368+
/* current index of word */
369369
const current = this.wordIndex % this.words.length;
370-
// Get full text of current word
370+
/* Get full text of current word */
371371
const fullText = this.words[current];
372372

373-
// Check if deleting
373+
/* Check if deleting */
374374
if (this.isDeleting) {
375-
// Remove char
375+
/* Remove char */
376376
this.text = fullText.substring(0, this.text.length - 1);
377377
} else {
378-
// Add char
378+
/* Add char */
379379
this.text = fullText.substring(0, this.text.length + 1);
380380
}
381381

382-
// Insert text into element
382+
/* Insert text into element */
383383
this.textElement.innerHTML = this.text;
384384

385-
// Initial type Speed
385+
/* Initial type Speed */
386386
let typeSpeed = 250;
387387

388388
if (this.isDeleting) {
389389
typeSpeed /= 2;
390390
}
391391

392-
// If word is complete
392+
/* If word is complete */
393393
if (!this.isDeleting && this.text === fullText) {
394-
// Make pause at end
394+
/* Make pause at end */
395395
typeSpeed = this.wait;
396-
// Set delete to true
396+
/* Set delete to true */
397397
this.isDeleting = true;
398398
} else if (this.isDeleting && this.text === "") {
399399
this.isDeleting = false;
400-
//
401400
this.wordIndex++;
402-
// Pause before start typing
401+
/* Pause before start typing */
403402
typeSpeed = 500;
404403
}
405404
setTimeout(() => this.type(), typeSpeed);
@@ -450,7 +449,7 @@ function init() {
450449
const textElement = document.querySelector(".txt-type");
451450
const words = JSON.parse(textElement.getAttribute("data-words"));
452451
const wait = textElement.getAttribute("data-wait");
453-
// init TypeWriter
452+
/* init TypeWriter */
454453

455454
new TypeWriter(textElement, words, wait);
456455
}

0 commit comments

Comments
 (0)