From e9d7dabd6d71c9d27ff1a920ad6a3353eabc5e60 Mon Sep 17 00:00:00 2001 From: neroduckale Date: Sun, 17 Mar 2024 04:39:37 +0500 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D1=85=D1=83=D1=8F=20=D1=81=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nrdkwebsite/Extensions/API.cs | 45 ------- nrdkwebsite/Extensions/DatabaseHandler.cs | 32 ----- nrdkwebsite/Extensions/User.cs | 26 ---- nrdkwebsite/Pages/about.cshtml | 10 +- nrdkwebsite/Pages/index.cshtml | 2 +- nrdkwebsite/Pages/layout.cshtml | 2 +- nrdkwebsite/Pages/minecraftia.cshtml | 15 ++- nrdkwebsite/Pages/ygolek.cshtml | 7 +- nrdkwebsite/wwwroot/css/style.css | 5 + nrdkwebsite/wwwroot/favicon.ico | Bin 5430 -> 0 bytes nrdkwebsite/wwwroot/img/icon.svg | 11 ++ nrdkwebsite/wwwroot/img/neroduck.svg | 19 +++ nrdkwebsite/wwwroot/{ => img}/ygolek.jpg | Bin nrdkwebsite/wwwroot/js/admin.js | 41 ------ nrdkwebsite/wwwroot/js/inventory.js | 0 nrdkwebsite/wwwroot/js/md5.min.js | 2 - nrdkwebsite/wwwroot/js/minecraft.js | 149 ++++++++++++++++------ 17 files changed, 166 insertions(+), 200 deletions(-) delete mode 100644 nrdkwebsite/Extensions/API.cs delete mode 100644 nrdkwebsite/Extensions/DatabaseHandler.cs delete mode 100644 nrdkwebsite/Extensions/User.cs delete mode 100644 nrdkwebsite/wwwroot/favicon.ico create mode 100644 nrdkwebsite/wwwroot/img/icon.svg create mode 100644 nrdkwebsite/wwwroot/img/neroduck.svg rename nrdkwebsite/wwwroot/{ => img}/ygolek.jpg (100%) delete mode 100644 nrdkwebsite/wwwroot/js/admin.js create mode 100644 nrdkwebsite/wwwroot/js/inventory.js delete mode 100644 nrdkwebsite/wwwroot/js/md5.min.js diff --git a/nrdkwebsite/Extensions/API.cs b/nrdkwebsite/Extensions/API.cs deleted file mode 100644 index 07bb038..0000000 --- a/nrdkwebsite/Extensions/API.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace nrdkwebsite; - -public static class API -{ - public static async Task PostNewUser(NewUser newuser, DatabaseHandler db) - { - User user = new User(newuser.nickname, db.users.OrderBy(p => p.id).Last().id + 1, newuser.mast); - await db.users.AddAsync(user); - await db.SaveChangesAsync(); - return user; - } - public static async Task DeleteUser(int id, DatabaseHandler db) - { - User? user = db.users.FirstOrDefault(u => u.id == id); - if (user == null) return Results.NotFound(new { message = "Пользователь не найден" }); - db.users.Remove(user); - await db.SaveChangesAsync(); - return Results.Json(user); - } - public static IResult GetUserByName(string name, DatabaseHandler db) - { - var users = db.users.ToList(); - User? user = users.FirstOrDefault(u => u.nickname == name); - // если не найден, отправляем статусный код и сообщение об ошибке - if (user == null) return Results.NotFound(new { message = "Пользователь не найден" }); - - // если пользователь найден, отправляем его - return Results.Json(user); - } - public static IResult GetUserById(int id, DatabaseHandler db) - { - var users = db.users.ToList(); - User? user = users.FirstOrDefault(u => u.id == id); - // если не найден, отправляем статусный код и сообщение об ошибке - if (user == null) return Results.NotFound(new { message = "Пользователь не найден" }); - - // если пользователь найден, отправляем его - return Results.Json(user); - } - public static List GetUsers(DatabaseHandler db) - { - return db.users.OrderBy(u => u.id).ToList(); - } - -} \ No newline at end of file diff --git a/nrdkwebsite/Extensions/DatabaseHandler.cs b/nrdkwebsite/Extensions/DatabaseHandler.cs deleted file mode 100644 index d8f16d6..0000000 --- a/nrdkwebsite/Extensions/DatabaseHandler.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.AspNetCore.Identity; -using Microsoft.EntityFrameworkCore; - -namespace nrdkwebsite; - -public sealed class DatabaseHandler : DbContext -{ - public DbSet users { get; set; } = null!; - public DatabaseHandler(DbContextOptions options) : base(options) - { - - } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity(entity => - { - entity.Property(u => u.nickname) - .HasColumnName("nickname") - .HasColumnType("varchar(100)") - .ValueGeneratedOnAdd(); - entity.Property(u => u.id) - .HasColumnName("id") - .HasColumnType("int") - .ValueGeneratedOnAdd(); - entity.Property(u => u.mast) - .HasColumnName("mast") - .HasColumnType("varchar(20)") - .ValueGeneratedOnAdd(); - }); - } -} \ No newline at end of file diff --git a/nrdkwebsite/Extensions/User.cs b/nrdkwebsite/Extensions/User.cs deleted file mode 100644 index 5c22109..0000000 --- a/nrdkwebsite/Extensions/User.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace nrdkwebsite; - -public class User -{ - public string nickname { get; set; } - public int id { get; set; } - public string mast { get; set; } - - public User(string nickname, int id, string mast) - { - this.nickname = nickname; - this.id = id; - this.mast = mast; - } -} -public class NewUser -{ - public string nickname { get; set; } - public string mast { get; set; } - - public NewUser(string nickname, string mast) - { - this.nickname = nickname; - this.mast = mast; - } -} \ No newline at end of file diff --git a/nrdkwebsite/Pages/about.cshtml b/nrdkwebsite/Pages/about.cshtml index 93561fb..a6de110 100644 --- a/nrdkwebsite/Pages/about.cshtml +++ b/nrdkwebsite/Pages/about.cshtml @@ -1,7 +1,9 @@ @page @model About +@ViewData["Title"] = about +
+

neroduckale.

+

telegram

+
+nero's logo - -
- neroduckale. -
\ No newline at end of file diff --git a/nrdkwebsite/Pages/index.cshtml b/nrdkwebsite/Pages/index.cshtml index 0f7b1f1..0207270 100644 --- a/nrdkwebsite/Pages/index.cshtml +++ b/nrdkwebsite/Pages/index.cshtml @@ -6,4 +6,4 @@

Привет, это сайт neroduckale

Мой никнейм читается по разному - неродакля, неродукель, неродакале, но одно в нем остается неизменным - неро.

-спасибо мактайлорс за помощь с созданием сайта. version: 0.3 +спасибо мактайлорс за помощь с созданием сайта. version: 0.7 diff --git a/nrdkwebsite/Pages/layout.cshtml b/nrdkwebsite/Pages/layout.cshtml index 9478acc..bf9fd08 100644 --- a/nrdkwebsite/Pages/layout.cshtml +++ b/nrdkwebsite/Pages/layout.cshtml @@ -35,6 +35,6 @@ - + \ No newline at end of file diff --git a/nrdkwebsite/Pages/minecraftia.cshtml b/nrdkwebsite/Pages/minecraftia.cshtml index 36d533c..5dcd7b3 100644 --- a/nrdkwebsite/Pages/minecraftia.cshtml +++ b/nrdkwebsite/Pages/minecraftia.cshtml @@ -2,8 +2,11 @@ @model Minecraftia @{ViewData["Title"] = "minecraft";} -Статистика игрока neroduckale - +Статистика игрока + + + +
Сюда внесены первые десять позиций по количеству, типо какого предмета я скрафтил в больших количествах и так далее
@@ -40,6 +43,14 @@
+
+
+ + + +
+
+ \ No newline at end of file diff --git a/nrdkwebsite/Pages/ygolek.cshtml b/nrdkwebsite/Pages/ygolek.cshtml index 95ca1ba..03f0927 100644 --- a/nrdkwebsite/Pages/ygolek.cshtml +++ b/nrdkwebsite/Pages/ygolek.cshtml @@ -1,6 +1,5 @@ @page -@model nrdkwebsite.Pages.Ygolek +@model Ygolek +@ViewData["Title"] = ygolek - - - \ No newline at end of file +YGOLEK'S PHOTO \ No newline at end of file diff --git a/nrdkwebsite/wwwroot/css/style.css b/nrdkwebsite/wwwroot/css/style.css index 09c0bd8..c0e56f6 100644 --- a/nrdkwebsite/wwwroot/css/style.css +++ b/nrdkwebsite/wwwroot/css/style.css @@ -66,3 +66,8 @@ a { justify-content: center; flex-wrap: wrap; } + +.stats { + margin-bottom: 100px; + margin-top: 30px; +} \ No newline at end of file diff --git a/nrdkwebsite/wwwroot/favicon.ico b/nrdkwebsite/wwwroot/favicon.ico deleted file mode 100644 index 63e859b476eff5055e0e557aaa151ca8223fbeef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5430 zcmc&&Yj2xp8Fqnv;>&(QB_ve7>^E#o2mu=cO~A%R>DU-_hfbSRv1t;m7zJ_AMrntN zy0+^f&8be>q&YYzH%(88lQ?#KwiCzaCO*ZEo%j&v;<}&Lj_stKTKK>#U3nin@AF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ebsite/wwwroot/img/neroduck.svg new file mode 100644 index 0000000..7346e32 --- /dev/null +++ b/nrdkwebsite/wwwroot/img/neroduck.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/nrdkwebsite/wwwroot/ygolek.jpg b/nrdkwebsite/wwwroot/img/ygolek.jpg similarity index 100% rename from nrdkwebsite/wwwroot/ygolek.jpg rename to nrdkwebsite/wwwroot/img/ygolek.jpg diff --git a/nrdkwebsite/wwwroot/js/admin.js b/nrdkwebsite/wwwroot/js/admin.js deleted file mode 100644 index 688019c..0000000 --- a/nrdkwebsite/wwwroot/js/admin.js +++ /dev/null @@ -1,41 +0,0 @@ -function admin() { - let person = prompt("Введите пинкод", "1234") - if (md5(person) !== "3d65eea6270a01922434000ca578b198") { - return; - } - document.body.style.background = "black"; - -} -async function deleteUser(id) { - const response = await fetch(`/api/users/${id}`, { - method: "DELETE", - headers: { "Accept": "application/json" } - }); - if (response.ok === true) { - const user = await response.json(); - document.getElementById(user.id).remove(); - } - else { - const error = await response.json(); - console.log(error.message); - } -} -async function createUser(nickname, mast) { - - const response = await fetch("api/users", { - method: "POST", - headers: { "Accept": "application/json", "Content-Type": "application/json" }, - body: JSON.stringify({ - nickname: nickname, - mast: mast - }) - }); - if (response.ok === true) { - const user = await response.json(); - //добавлять юзера - } - else { - const error = await response.json(); - console.log(error.message); - } -} \ No newline at end of file diff --git a/nrdkwebsite/wwwroot/js/inventory.js b/nrdkwebsite/wwwroot/js/inventory.js new file mode 100644 index 0000000..e69de29 diff --git a/nrdkwebsite/wwwroot/js/md5.min.js b/nrdkwebsite/wwwroot/js/md5.min.js deleted file mode 100644 index f414e7c..0000000 --- a/nrdkwebsite/wwwroot/js/md5.min.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(n){"use strict";function d(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function f(n,t,r,e,o,u){return d((u=d(d(t,n),d(e,u)))<>>32-o,r)}function l(n,t,r,e,o,u,c){return f(t&r|~t&e,n,t,o,u,c)}function g(n,t,r,e,o,u,c){return f(t&e|r&~e,n,t,o,u,c)}function v(n,t,r,e,o,u,c){return f(t^r^e,n,t,o,u,c)}function m(n,t,r,e,o,u,c){return f(r^(t|~e),n,t,o,u,c)}function c(n,t){var r,e,o,u;n[t>>5]|=128<>>9<<4)]=t;for(var c=1732584193,f=-271733879,i=-1732584194,a=271733878,h=0;h>5]>>>e%32&255);return t}function a(n){var t=[];for(t[(n.length>>2)-1]=void 0,e=0;e>5]|=(255&n.charCodeAt(e/8))<>>4&15)+r.charAt(15&t);return e}function r(n){return unescape(encodeURIComponent(n))}function o(n){return i(c(a(n=r(n)),8*n.length))}function u(n,t){return function(n,t){var r,e=a(n),o=[],u=[];for(o[15]=u[15]=void 0,16 { + return response.json(); + }) + .then((data) => { + a = data; + }); + return a; +} + +async function getJsons() { + await getJson("nrdk.json").then((a) => { + nrdkstats = a; + }); + await getJson("ygolek.json").then((a) => { + ygolekstats = a; + }); + await getJson("ru_edited.json").then((a) => { + locale = a; + }); +} async function parseStats(stats) { let values = { valuedropped: [], @@ -38,6 +70,7 @@ async function parseStats(stats) { ); } }); + //parsing keysToSort.forEach((key) => { let statistic = stats["stats"][key]; @@ -50,39 +83,18 @@ async function parseStats(stats) { createPie(values["value" + keyy], values["datas" + keyy], keyy); }); } - -async function getStats() { - const responsetranslate = await fetch("https://neroduck.ru/ru_edited.json", { - method: "GET", - headers: { Accept: "application/json" }, - }); - console.log(responsetranslate.ok); - // если запрос прошел нормально - if (responsetranslate.ok === true) { - // получаем данные - - window.translatejson = await responsetranslate.json(); - } - // отправляет запрос и получаем ответ - const response = await fetch("https://neroduck.ru/nrdk.json", { - method: "GET", - headers: { Accept: "application/json" }, - }); - // если запрос прошел нормально - if (response.ok === true) { - // получаем данные - const stats = await response.json(); - await parseStats(stats); - } +async function createPie(items, datas, idcanvas) { + + await charts.forEach((chart) => { + chart.destroy(); + }) -} - -function createPie(items, datas, idcanvas) { let bgcol = palette("tol-rainbow", items.length); for (let i = 0; i < bgcol.length; i++) { bgcol[i] = "#" + bgcol[i]; } bgcol = bgcol.reverse(); + const data = { labels: items, datasets: [ @@ -108,9 +120,50 @@ function createPie(items, datas, idcanvas) { }, }; let canvas = document.getElementById(idcanvas); - let chart = new Chart(canvas, config); + charts.push(new Chart(canvas, config)) } +async function createBar() { + + + + + + const data = { + labels: ["Смерти"], + datasets: [ + { + label: "neroduckale", + data: [nrdkstats["stats"]["minecraft:custom"]["minecraft:deaths"]], + backgroundColor: "#34b8e9", + borderColor: "#ffffff", + hoverOffset: 6, + }, + { + label: "ygolek", + data: [ygolekstats["stats"]["minecraft:custom"]["minecraft:deaths"]], + backgroundColor: "#e00000", + borderColor: "#ffffff", + hoverOffset: 6, + }, + ], + }; + const config = { + type: "bar", + data: data, + options: { + plugins: { + legend: { + labels: { + color: "white", + }, + }, + }, + }, + }; + let canvas = document.getElementById("sravn"); + let chart = new Chart(canvas, config) +} function translate(item, type) { if (item.includes("minecraft:") === false) { return item; @@ -119,43 +172,55 @@ function translate(item, type) { switch (type) { case "minecraft:killed_by": - r = window.translatejson["entity." + item]; + r = locale["entity." + item]; return r; case "minecraft:broken": - r = window.translatejson["item." + item] + r = locale["item." + item] return r case "minecraft:used": - r = window.translatejson["item." + item] + r = locale["item." + item] if (r === undefined) { - r = window.translatejson["block." + item]; + r = locale["block." + item]; } return r case "minecraft:killed": - r = window.translatejson["entity." + item] + r = locale["entity." + item] return r case "minecraft:dropped": - r = window.translatejson["item." + item]; + r = locale["item." + item]; if (r === undefined) { - r = window.translatejson["block." + item]; + r = locale["block." + item]; } return r case "minecraft:crafted": - r = window.translatejson["item." + item] + r = locale["item." + item] if (r === undefined) { - r = window.translatejson["block." + item]; + r = locale["block." + item]; } return r case "minecraft:picked_up": - r = window.translatejson["item." + item] + r = locale["item." + item] if (r === undefined) { - r = window.translatejson["block." + item]; + r = locale["block." + item]; } return r case "minecraft:mined": - r = window.translatejson["block." + item] + r = locale["block." + item] return r } } +$('#ygolek').change(async function () { + await parseStats(ygolekstats); + return false; +}); -getStats(); \ No newline at end of file +$('#nrdk').change(async function () { + await parseStats(nrdkstats); + return false; +}); + + +await getJsons(); +await parseStats(nrdkstats); +await createBar(); \ No newline at end of file