Fix: Gitroll scanned code smells
This commit is contained in:
12
dev/main.js
12
dev/main.js
@@ -1,4 +1,4 @@
|
||||
var fs = require('fs')
|
||||
const fs = require('fs')
|
||||
|
||||
const goodFortunes = [
|
||||
{
|
||||
@@ -167,9 +167,9 @@ const goodLen = goodFortunes.length;
|
||||
let num = null;
|
||||
const dates = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 30];
|
||||
const statusLen = 8;
|
||||
var buckets = {};
|
||||
let buckets = {};
|
||||
let day = 0;
|
||||
var run_cnt = 0;
|
||||
let run_cnt = 0;
|
||||
|
||||
while (run_cnt != 2000) {
|
||||
let n1 = parseInt(Math.random() * 255 + 1);
|
||||
@@ -180,7 +180,6 @@ while (run_cnt != 2000) {
|
||||
if (!check_ip_valid(n1, n2, n3, n4)) continue;
|
||||
|
||||
let index = `${n1}.${n2}.${n3}.${n4}`;
|
||||
// buckets[`${n1}.${n2}.${n3}.${n4}`] = [0, 0, 0, 0, 0, 0, 0, 0];
|
||||
buckets[index] = [0, 0, 0, 0];
|
||||
for (let i = 1; i <= 12; i++) {
|
||||
for (let j = 1; j <= dates[i - 1]; j++) {
|
||||
@@ -248,11 +247,6 @@ function run(year, month, date, day, ip) {
|
||||
let seed1 = (num[0] >> hashDate) * (num[1] >> Math.min(hashDate, 2)) + (num[2] << 1) * (num[3] >> 3) + (date << 3) * (month << hashDate) + ((year * day) >> 2);
|
||||
let seed2 = (num[0] << (hashDate + 2)) * (num[1] << hashDate) + (num[2] << 1) * (num[3] << 3) + (date << (hashDate - 1)) * (month << 4) + (year >> hashDate) + ((date * day) >> 1);
|
||||
|
||||
// decide the status
|
||||
let status_index = ((seed1 + seed2) % statusLen + statusLen) % statusLen;
|
||||
// buckets[index][Math.max(status_index - parseInt(day / Math.PI), 0)]++; // old hash
|
||||
// buckets[index][status_index]++; // current hash
|
||||
|
||||
// make sure the events won't collide
|
||||
let set = new Set();
|
||||
let l1 = (seed1 % goodLen + goodLen) % goodLen;
|
||||
|
||||
@@ -26,7 +26,7 @@ fetch("https://api.ipify.org?format=json").then(response => {
|
||||
let goodFortunes = [];
|
||||
let badFortunes = [];
|
||||
let special_events = [];
|
||||
var fortune_generated = false;
|
||||
let fortune_generated = false;
|
||||
|
||||
// using async and await to prevent fetching the data too late...
|
||||
async function fetch_data() {
|
||||
@@ -165,7 +165,7 @@ function Appear() {
|
||||
let seed1 = -1;
|
||||
let seed2 = -1;
|
||||
|
||||
if (fortune_generated == false) {
|
||||
if (!fortune_generated) {
|
||||
// transform ip to four numbers
|
||||
let num = ip.split(".").map(num => parseInt(num));
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ const context = canvas.getContext("2d")
|
||||
canvas.height = window.innerHeight + 100;
|
||||
canvas.width = window.innerWidth + 5;
|
||||
|
||||
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./*-+#$%^@!~?><:;[]{}\」=_αβΓγΔδεζηΘθικΛλμΞξΠπρΣσςτυΦφχΨψΩω×≦≧≠∞≒≡~∩∠∪∟⊿∫∮∵∴$¥〒¢£℃€℉╩◢ⅩⅨⅧⅦⅥⅤⅣⅢⅡⅠあいうえおがぎぐげござじずぜぞだぢつでづどにぬのばひぴぶへぺぼみゃょァゐゎè";
|
||||
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./*-+#$%^@!~?><:;[]{}=_αβΓγΔδεζηΘθικΛλμΞξΠπρΣσςτυΦφχΨψΩω×≦≧≠∞≒≡~∩∠∪∟⊿∫∮∵∴$¥〒¢£℃€℉╩◢ⅩⅨⅧⅦⅥⅤⅣⅢⅡⅠあいうえおがぎぐげござじずぜぞだぢつでづどにぬのばひぴぶへぺぼみゃょァゐゎè";
|
||||
|
||||
const fontSize = 16;
|
||||
const columns = canvas.width / fontSize;
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
<div class="col-md-6">
|
||||
<div class="card mb-3 border-0">
|
||||
<img class="card-img-top" src="./images/fortune_generator_example.png" alt="fortune generator example">
|
||||
<!-- <video src="#" autoplay></video> -->
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">Fortune Generator</h4>
|
||||
<p class="card-text">Get your daily fortune with just a click.</p>
|
||||
@@ -40,7 +39,6 @@
|
||||
<div class="col-md-6">
|
||||
<div class="card mb-3 border-0">
|
||||
<img class="card-img-top" src="./images/quote_generator_example_(2).png" alt="quote generator example">
|
||||
<!-- <video src="#" autoplay></video> -->
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">Quote Generator</h4>
|
||||
<p class="card-text">Generate inspiring and thought-provoking quotes effortlessly.</p>
|
||||
|
||||
@@ -4,7 +4,7 @@ const context = canvas.getContext("2d")
|
||||
canvas.height = window.innerHeight + 100;
|
||||
canvas.width = window.innerWidth + 5;
|
||||
|
||||
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./*-+#$%^@!~?><:;[]{}\」=_αβΓγΔδεζηΘθικΛλμΞξΠπρΣσςτυΦφχΨψΩω×≦≧≠∞≒≡~∩∠∪∟⊿∫∮∵∴$¥〒¢£℃€℉╩◢ⅩⅨⅧⅦⅥⅤⅣⅢⅡⅠあいうえおがぎぐげござじずぜぞだぢつでづどにぬのばひぴぶへぺぼみゃょァゐゎè";
|
||||
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./*-+#$%^@!~?><:;[]{}=_αβΓγΔδεζηΘθικΛλμΞξΠπρΣσςτυΦφχΨψΩω×≦≧≠∞≒≡~∩∠∪∟⊿∫∮∵∴$¥〒¢£℃€℉╩◢ⅩⅨⅧⅦⅥⅤⅣⅢⅡⅠあいうえおがぎぐげござじずぜぞだぢつでづどにぬのばひぴぶへぺぼみゃょァゐゎè";
|
||||
|
||||
const fontSize = 16;
|
||||
const columns = canvas.width / fontSize;
|
||||
|
||||
@@ -6,19 +6,16 @@ async function fetch_folders() {
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
folderPaths = data.folder_paths;
|
||||
// console.log(folderPaths);
|
||||
})
|
||||
}
|
||||
|
||||
async function get_generator_card_footer() {
|
||||
await fetch_folders()
|
||||
// console.log(folderPaths);
|
||||
const repoOwner = 'LifeAdventurer';
|
||||
const repoName = 'generators';
|
||||
for (let folderIndex = 1; folderIndex <= folderPaths.length; folderIndex++) {
|
||||
let folderPath = folderPaths[folderIndex - 1];
|
||||
const apiUrl = `https://api.github.com/repos/${repoOwner}/${repoName}/commits?path=${folderPath}`;
|
||||
console.log(apiUrl);
|
||||
|
||||
fetch(apiUrl)
|
||||
.then(response => response.json())
|
||||
@@ -29,7 +26,6 @@ async function get_generator_card_footer() {
|
||||
const currentTimeStamp = Math.floor(new Date().getTime() / 1000);
|
||||
const timeDifference = currentTimeStamp - commitTimeStamp;
|
||||
|
||||
// console.log(timeSinceLastUpdate);
|
||||
$(`#last-update-${folderIndex}`).html(`Last updated ${format_time_difference(timeDifference)} ago`)
|
||||
})
|
||||
// .catch(error => console.error('Error fetching data:', error));
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
|
||||
.btn:hover {
|
||||
background-color: var(--button-hover-color);
|
||||
/* color: var(--button-text-color); */
|
||||
}
|
||||
|
||||
body {
|
||||
|
||||
Reference in New Issue
Block a user