From 8f523f70fa18214f3bbaf5f8ee0ffe5922ce9654 Mon Sep 17 00:00:00 2001 From: sk337 Date: Thu, 25 Jan 2024 22:17:59 +0000 Subject: [PATCH] much changes --- README.md | 2 +- index.html | 4 +- package-lock.json | 142 +++++++++++++++++++++++++++++++++++++++++++ package.json | 2 + src/Stats.jsx | 70 ++++++++++++++++++--- src/utils/jsutils.js | 46 ++++++++++++++ vite.config.js | 4 +- 7 files changed, 258 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 62c2454..d47a0cb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > **100% client sided Sword Battle account manager written in react** -Use Now [here](https://sk337.github.io/SwordManager) +**Use Now [here](https://sword-manager.replit.app)** ## Run Locally diff --git a/index.html b/index.html index 39285a9..cc26c17 100644 --- a/index.html +++ b/index.html @@ -8,9 +8,7 @@ -
- -
+
diff --git a/package-lock.json b/package-lock.json index dc44a46..c5f6681 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,7 @@ "node-fetch": "^3.2.6", "prettier": "^3.2.4", "react": "^18.2.0", + "react-chartjs-2": "^5.2.0", "react-dom": "^18.2.0", "react-redux": "^9.1.0", "react-router-dom": "^6.21.3", @@ -37,6 +38,7 @@ "tailwind-merge": "^2.2.1", "tailwindcss-animate": "^1.0.7", "typescript": "^5.3.3", + "unplugin-inject-preload": "^2.0.0", "vite": "^5.0.12", "vite-plugin-plain-text": "^1.4.2" }, @@ -1117,6 +1119,12 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@kurkle/color": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz", + "integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw==", + "peer": true + }, "node_modules/@napi-rs/magic-string": { "version": "0.3.4", "resolved": "https://registry.npmjs.org/@napi-rs/magic-string/-/magic-string-0.3.4.tgz", @@ -2427,6 +2435,17 @@ "node": ">= 0.6" } }, + "node_modules/acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/agent-base": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", @@ -2927,6 +2946,18 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/chart.js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.4.1.tgz", + "integrity": "sha512-C74QN1bxwV1v2PEujhmKjOZ7iUM4w6BWs23Md/6aOZZSlwMzeCIDGuZay++rBgChYru7/+QFeoQW0fQoP534Dg==", + "peer": true, + "dependencies": { + "@kurkle/color": "^0.3.0" + }, + "engines": { + "pnpm": ">=7" + } + }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -4856,6 +4887,15 @@ "node": ">=0.10.0" } }, + "node_modules/react-chartjs-2": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/react-chartjs-2/-/react-chartjs-2-5.2.0.tgz", + "integrity": "sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA==", + "peerDependencies": { + "chart.js": "^4.1.1", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/react-dom": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", @@ -5823,6 +5863,38 @@ "node": ">= 10.0.0" } }, + "node_modules/unplugin": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-1.6.0.tgz", + "integrity": "sha512-BfJEpWBu3aE/AyHx8VaNE/WgouoQxgH9baAiH82JjX8cqVyi3uJQstqwD5J+SZxIK326SZIhsSZlALXVBCknTQ==", + "dependencies": { + "acorn": "^8.11.2", + "chokidar": "^3.5.3", + "webpack-sources": "^3.2.3", + "webpack-virtual-modules": "^0.6.1" + } + }, + "node_modules/unplugin-inject-preload": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unplugin-inject-preload/-/unplugin-inject-preload-2.0.0.tgz", + "integrity": "sha512-n9r/2kAaxt0LnecJ9IS3uwX+aK10+MJjaUbusvxfIq4f2tz1YbeSkzuHP0eUTzC78UJnaGud2IQZeufGSuvDLg==", + "dependencies": { + "mime-types": "^2.1.35", + "unplugin": "^1.5.1", + "webpack-sources": "^3.2.3" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "html-webpack-plugin": ">=5.0.0" + }, + "peerDependenciesMeta": { + "html-webpack-plugin": { + "optional": true + } + } + }, "node_modules/update-browserslist-db": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", @@ -6063,6 +6135,19 @@ "node": ">= 8" } }, + "node_modules/webpack-sources": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", + "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==", + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/webpack-virtual-modules": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/webpack-virtual-modules/-/webpack-virtual-modules-0.6.1.tgz", + "integrity": "sha512-poXpCylU7ExuvZK8z+On3kX+S8o/2dQ/SVYueKA0D4WEMXROXgY8Ez50/bQEUmvoSMMrWcrJqCHuhAbsiwg7Dg==" + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -6880,6 +6965,12 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "@kurkle/color": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz", + "integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw==", + "peer": true + }, "@napi-rs/magic-string": { "version": "0.3.4", "resolved": "https://registry.npmjs.org/@napi-rs/magic-string/-/magic-string-0.3.4.tgz", @@ -7595,6 +7686,11 @@ "negotiator": "0.6.3" } }, + "acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==" + }, "agent-base": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", @@ -7897,6 +7993,15 @@ } } }, + "chart.js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.4.1.tgz", + "integrity": "sha512-C74QN1bxwV1v2PEujhmKjOZ7iUM4w6BWs23Md/6aOZZSlwMzeCIDGuZay++rBgChYru7/+QFeoQW0fQoP534Dg==", + "peer": true, + "requires": { + "@kurkle/color": "^0.3.0" + } + }, "chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -9154,6 +9259,12 @@ "loose-envify": "^1.1.0" } }, + "react-chartjs-2": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/react-chartjs-2/-/react-chartjs-2-5.2.0.tgz", + "integrity": "sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA==", + "requires": {} + }, "react-dom": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", @@ -9800,6 +9911,27 @@ "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==" }, + "unplugin": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-1.6.0.tgz", + "integrity": "sha512-BfJEpWBu3aE/AyHx8VaNE/WgouoQxgH9baAiH82JjX8cqVyi3uJQstqwD5J+SZxIK326SZIhsSZlALXVBCknTQ==", + "requires": { + "acorn": "^8.11.2", + "chokidar": "^3.5.3", + "webpack-sources": "^3.2.3", + "webpack-virtual-modules": "^0.6.1" + } + }, + "unplugin-inject-preload": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unplugin-inject-preload/-/unplugin-inject-preload-2.0.0.tgz", + "integrity": "sha512-n9r/2kAaxt0LnecJ9IS3uwX+aK10+MJjaUbusvxfIq4f2tz1YbeSkzuHP0eUTzC78UJnaGud2IQZeufGSuvDLg==", + "requires": { + "mime-types": "^2.1.35", + "unplugin": "^1.5.1", + "webpack-sources": "^3.2.3" + } + }, "update-browserslist-db": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", @@ -9937,6 +10069,16 @@ "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==" }, + "webpack-sources": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", + "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==" + }, + "webpack-virtual-modules": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/webpack-virtual-modules/-/webpack-virtual-modules-0.6.1.tgz", + "integrity": "sha512-poXpCylU7ExuvZK8z+On3kX+S8o/2dQ/SVYueKA0D4WEMXROXgY8Ez50/bQEUmvoSMMrWcrJqCHuhAbsiwg7Dg==" + }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index 47a34b3..3b5f2d4 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "node-fetch": "^3.2.6", "prettier": "^3.2.4", "react": "^18.2.0", + "react-chartjs-2": "^5.2.0", "react-dom": "^18.2.0", "react-redux": "^9.1.0", "react-router-dom": "^6.21.3", @@ -42,6 +43,7 @@ "tailwind-merge": "^2.2.1", "tailwindcss-animate": "^1.0.7", "typescript": "^5.3.3", + "unplugin-inject-preload": "^2.0.0", "vite": "^5.0.12", "vite-plugin-plain-text": "^1.4.2" }, diff --git a/src/Stats.jsx b/src/Stats.jsx index 4e22c48..f03e869 100644 --- a/src/Stats.jsx +++ b/src/Stats.jsx @@ -1,12 +1,29 @@ import React, { useState, useEffect } from "react"; import { getPubInfo } from "@/utils/login"; -import { prettyNum } from "@/utils/jsutils"; +import { prettyNum, id2skin, dateParse, parseDailyStats } from "@/utils/jsutils"; import cosmetics from "@/../cosmetics.json"; import Nav from "@/components/nav"; +import { + HoverCard, + HoverCardContent, + HoverCardTrigger, +} from "@/components/ui/hover-card"; +import { + Chart as ChartJS, + CategoryScale, + LinearScale, + PointElement, + LineElement, + Title, + Tooltip, + Legend, +} from "chart.js"; +import { Line } from 'react-chartjs-2'; + export default function Stats() { const urlData = new URL("https://" + window.location.hash.replace("#", "q/")); - console.log(urlData); + if (!urlData.searchParams.get("user")) { return (
@@ -28,26 +45,65 @@ export default function Stats() { }, []); if (user && !user.error) { + let stats = parseDailyStats(user.dailyStats) + // console.log(user); + console.log(stats) return (