From 1298abd3377cc79d8883bb6e38b65bca46f0c8d7 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 29 Oct 2023 01:30:19 +0800 Subject: all space -> tab --- src/js/getrepo.js | 310 ++++++++++++++++++++++++++--------------------------- src/js/hacktype.js | 66 ++++++------ src/js/header.js | 18 ++-- src/js/rbg.js | 52 ++++----- 4 files changed, 223 insertions(+), 223 deletions(-) (limited to 'src/js') diff --git a/src/js/getrepo.js b/src/js/getrepo.js index 2912427c..d34104a2 100644 --- a/src/js/getrepo.js +++ b/src/js/getrepo.js @@ -8,190 +8,190 @@ const filterInput = document.querySelector('.filter-repos'); // get information from github profile const getProfile = async () => { - const res = await fetch( - `https://api.github.com/users/${username}`, - { - headers: { - Accept: 'application/vnd.github+json', - Authorization: //'token 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' - `Basic ${btoa(`${clientId}:${clientSecret}`)}` - } - } - ); - const profile = await res.json(); - displayProfile(profile); + const res = await fetch( + `https://api.github.com/users/${username}`, + { + headers: { + Accept: 'application/vnd.github+json', + Authorization: //'token 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' + `Basic ${btoa(`${clientId}:${clientSecret}`)}` + } + } + ); + const profile = await res.json(); + displayProfile(profile); }; getProfile(); // display infomation from github profile const displayProfile = (profile) => { - const userInfo = document.querySelector('.user-info'); - userInfo.innerHTML = ` -
- user avatar -
-
- -

${profile.name}

- -

${profile.bio}

-

- Mail: ${profile.email} -

-

- Location: ${profile.location} -

-

- @${profile.login} - Repos: ${profile.public_repos} - Gists: ${profile.public_gists} -

-
- `; + const userInfo = document.querySelector('.user-info'); + userInfo.innerHTML = ` +
+ user avatar +
+
+ +

${profile.name}

+ +

${profile.bio}

+

+ Mail: ${profile.email} +

+

+ Location: ${profile.location} +

+

+ @${profile.login} + Repos: ${profile.public_repos} + Gists: ${profile.public_gists} +

+
+ `; }; // get list of user's public repos const getRepos = async () => { - let repos = []; - let res; - res = await fetch( - `https://api.github.com/users/${username}/repos?&sort=pushed`, - { - headers: { - Accept: 'application/vnd.github+json', - Authorization: - `Basic ${btoa(`${clientId}:${clientSecret}`)}` - // 'token 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' - } - } - ); - let data = await res.json(); - repos = repos.concat(data); - repos.sort((a, b) => b.forks_count - a.forks_count); - repos.sort((a, b) => b.stargazers_count - a.stargazers_count); - displayRepos(repos); + let repos = []; + let res; + res = await fetch( + `https://api.github.com/users/${username}/repos?&sort=pushed`, + { + headers: { + Accept: 'application/vnd.github+json', + Authorization: + `Basic ${btoa(`${clientId}:${clientSecret}`)}` + // 'token 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' + } + } + ); + let data = await res.json(); + repos = repos.concat(data); + repos.sort((a, b) => b.forks_count - a.forks_count); + repos.sort((a, b) => b.stargazers_count - a.stargazers_count); + displayRepos(repos); }; getRepos(); // display list of all user's public repos const displayRepos = (repos) => { - const userHome = `https://github.com/${username}` - filterInput.classList.remove('hide'); - for (const repo of repos) { - if (repo.fork && hideForks) { - continue; - } + const userHome = `https://github.com/${username}` + filterInput.classList.remove('hide'); + for (const repo of repos) { + if (repo.fork && hideForks) { + continue; + } - const langUrl = `${userHome}?tab=repositories&q=&language=${repo.language}` - const starsUrl = `${userHome}/${repo.name}/stargazers` - const forksUrl = `${userHome}/${repo.name}/network/members` + const langUrl = `${userHome}?tab=repositories&q=&language=${repo.language}` + const starsUrl = `${userHome}/${repo.name}/stargazers` + const forksUrl = `${userHome}/${repo.name}/network/members` - let listItem = document.createElement('li'); - listItem.classList.add('repo'); - listItem.innerHTML = ` -

${repo.name}

- ${repo.description ? `${repo.description}` : ''}

` + let listItem = document.createElement('li'); + listItem.classList.add('repo'); + listItem.innerHTML = ` +

${repo.name}

+ ${repo.description ? `${repo.description}` : ''}

` - if (repo.stargazers_count > 0) { - listItem.innerHTML += ` - ⭐ ${repo.stargazers_count}` - } + if (repo.stargazers_count > 0) { + listItem.innerHTML += ` + ⭐ ${repo.stargazers_count}` + } - if (repo.language) { - listItem.innerHTML += ` - ${devicons[repo.language]}` - } + if (repo.language) { + listItem.innerHTML += ` + ${devicons[repo.language]}` + } - if (repo.forks_count > 0) { - listItem.innerHTML += ` - ${devicons["Git"]} ${repo.forks_count}` - } + if (repo.forks_count > 0) { + listItem.innerHTML += ` + ${devicons["Git"]} ${repo.forks_count}` + } - if (repo.homepage && repo.homepage !== "") { - listItem.innerHTML += `

- Code ${devicons["Github"]} - Live ${devicons["Chrome"]}
`; - } else { - listItem.innerHTML += `

- View Project ${devicons["Github"]}
`; - } + if (repo.homepage && repo.homepage !== "") { + listItem.innerHTML += `

+ Code ${devicons["Github"]} + Live ${devicons["Chrome"]}
`; + } else { + listItem.innerHTML += `

+ View Project ${devicons["Github"]}
`; + } - repoList.append(listItem); - } + repoList.append(listItem); + } }; // dynamic search filterInput.addEventListener('input', (e) => { - const search = e.target.value; - const repos = document.querySelectorAll('.repo'); - const searchLowerText = search.toLowerCase(); + const search = e.target.value; + const repos = document.querySelectorAll('.repo'); + const searchLowerText = search.toLowerCase(); - for (const repo of repos) { - const lowerText = repo.innerText.toLowerCase(); - if (lowerText.includes(searchLowerText)) { - repo.classList.remove('hide'); - } else { - repo.classList.add('hide'); - } - } + for (const repo of repos) { + const lowerText = repo.innerText.toLowerCase(); + if (lowerText.includes(searchLowerText)) { + repo.classList.remove('hide'); + } else { + repo.classList.add('hide'); + } + } }); // for programming language icons const devicons = { - Git: '', - Github: '', - Chrome: '', - Assembly: ' Assembly', - 'C#': ' C#', - 'C++': ' C++', - C: ' C', - Clojure: ' C', - CoffeeScript: - ' CoffeeScript', - Crystal: ' Crystal', - CSS: ' CSS', - Dart: ' Dart', - Dockerfile: ' Docker', - Elixir: ' Elixir', - Elm: ' Elm', - Erlang: ' Erlang', - 'F#': ' F#', - Go: ' Go', - Groovy: ' Groovy', - HTML: ' HTML', - Haskell: ' Haskell', - Java: ' Java', - JavaScript: ' JavaScript', - Julia: ' Julia', - 'Jupyter Notebook': ' Jupyter', - Kotlin: ' Kotlin', - Latex: ' Latex', - Lua: ' Lua', - Matlab: ' Matlab', - Nim: ' Nim', - Nix: ' Nix', - ObjectiveC: ' ObjectiveC', - OCaml: ' OCaml', - Perl: ' Perl', - PHP: ' PHP', - PLSQL: ' PLSQL', - Processing: - ' Processing', - Python: ' Python', - R: ' R', - Ruby: ' Ruby', - Rust: ' Rust', - Sass: ' Sass', - Scala: ' Scala', - Shell: ' Shell', - Solidity: ' Solidity', - Stylus: ' Stylus', - Svelte: ' Svelte', - Swift: ' Swift', - Terraform: ' Terraform', - TypeScript: ' TypeScript', - 'Vim Script': ' Vim Script', - Vue: ' Vue', - Mail: '', + Git: '', + Github: '', + Chrome: '', + Assembly: ' Assembly', + 'C#': ' C#', + 'C++': ' C++', + C: ' C', + Clojure: ' C', + CoffeeScript: + ' CoffeeScript', + Crystal: ' Crystal', + CSS: ' CSS', + Dart: ' Dart', + Dockerfile: ' Docker', + Elixir: ' Elixir', + Elm: ' Elm', + Erlang: ' Erlang', + 'F#': ' F#', + Go: ' Go', + Groovy: ' Groovy', + HTML: ' HTML', + Haskell: ' Haskell', + Java: ' Java', + JavaScript: ' JavaScript', + Julia: ' Julia', + 'Jupyter Notebook': ' Jupyter', + Kotlin: ' Kotlin', + Latex: ' Latex', + Lua: ' Lua', + Matlab: ' Matlab', + Nim: ' Nim', + Nix: ' Nix', + ObjectiveC: ' ObjectiveC', + OCaml: ' OCaml', + Perl: ' Perl', + PHP: ' PHP', + PLSQL: ' PLSQL', + Processing: + ' Processing', + Python: ' Python', + R: ' R', + Ruby: ' Ruby', + Rust: ' Rust', + Sass: ' Sass', + Scala: ' Scala', + Shell: ' Shell', + Solidity: ' Solidity', + Stylus: ' Stylus', + Svelte: ' Svelte', + Swift: ' Swift', + Terraform: ' Terraform', + TypeScript: ' TypeScript', + 'Vim Script': ' Vim Script', + Vue: ' Vue', + Mail: '', }; diff --git a/src/js/hacktype.js b/src/js/hacktype.js index b5542377..eb5595c0 100644 --- a/src/js/hacktype.js +++ b/src/js/hacktype.js @@ -5,46 +5,46 @@ const special = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; let interval = null; function hackType() { - const elements = document.querySelectorAll(".hacktype"); - let intervals = []; - - elements.forEach((element) => { - let iteration = 0; - - intervals.push( - setInterval(() => { - element.innerText = element.innerText - .split("") - .map((letter, index) => { - if (index < iteration) { - return element.dataset.value[index]; - } - - return letters[Math.floor(Math.random() * 26)]; - }) - .join(""); - - if (iteration >= element.dataset.value.length) { - clearInterval(intervals.shift()); - } - - iteration += 1 / 5; - }, 20) - ); - }); +const elements = document.querySelectorAll(".hacktype"); +let intervals = []; + +elements.forEach((element) => { + let iteration = 0; + + intervals.push( + setInterval(() => { + element.innerText = element.innerText + .split("") + .map((letter, index) => { + if (index < iteration) { + return element.dataset.value[index]; + } + + return letters[Math.floor(Math.random() * 26)]; + }) + .join(""); + + if (iteration >= element.dataset.value.length) { + clearInterval(intervals.shift()); + } + + iteration += 1 / 5; + }, 20) + ); +}); } hackType(); // Call hackType initially setInterval(() => { - const intervals = document.querySelectorAll(".hacktype-interval"); - intervals.forEach((interval) => clearInterval(interval)); // Clear existing intervals - hackType(); // Call hackType again +const intervals = document.querySelectorAll(".hacktype-interval"); +intervals.forEach((interval) => clearInterval(interval)); // Clear existing intervals +hackType(); // Call hackType again }, 10000); // Repeat every 5 seconds // Check if the document becomes visible again document.addEventListener("visibilitychange", () => { - if (!document.hidden) { - hackType(); // Call hackType when the user comes back from being away - } +if (!document.hidden) { + hackType(); // Call hackType when the user comes back from being away +} }); diff --git a/src/js/header.js b/src/js/header.js index f8e53d5a..6189bc1c 100644 --- a/src/js/header.js +++ b/src/js/header.js @@ -6,15 +6,15 @@ let page = header.getAttribute('page'); newElement.innerHTML = ` `; diff --git a/src/js/rbg.js b/src/js/rbg.js index 40f0dadd..fa6b11a6 100644 --- a/src/js/rbg.js +++ b/src/js/rbg.js @@ -1,38 +1,38 @@ document.body.style.transition = "background 1s ease-in-out"; function getRandomColor() { - const letters = "0123456789ABCDEF"; - let color = "#"; - for (let i = 0; i < 6; i++) { - color += letters[Math.floor(Math.random() * 16)]; - } - return color; +const letters = "0123456789ABCDEF"; +let color = "#"; +for (let i = 0; i < 6; i++) { + color += letters[Math.floor(Math.random() * 16)]; +} +return color; } function setRandomGradient() { - const rand3 = Math.floor(Math.random() * 3) + 1; - if (rand3 === 1) { - document.body.style.background = `linear-gradient(${Math.floor( - Math.random() * 180 - )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()})`; - } else if (rand3 === 2) { - document.body.style.background = `linear-gradient(${Math.floor( - Math.random() * 180 - )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}), +const rand3 = Math.floor(Math.random() * 3) + 1; +if (rand3 === 1) { + document.body.style.background = `linear-gradient(${Math.floor( + Math.random() * 180 + )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()})`; +} else if (rand3 === 2) { + document.body.style.background = `linear-gradient(${Math.floor( + Math.random() * 180 + )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}), linear-gradient(${Math.floor( - Math.random() * 180 - )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()})`; - } else { - document.body.style.background = `linear-gradient(${Math.floor( - Math.random() * 180 - )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}), + Math.random() * 180 + )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()})`; +} else { + document.body.style.background = `linear-gradient(${Math.floor( + Math.random() * 180 + )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}), linear-gradient(${Math.floor( - Math.random() * 180 - )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}), + Math.random() * 180 + )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}), linear-gradient(${Math.floor( - Math.random() * 180 - )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()})`; - } + Math.random() * 180 + )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()})`; +} } setRandomGradient(); -- cgit v1.2.3