Крупное обновление. Из нового:
чутка переделанный дизайн, вымерший /users, доделанная статистика мира майнкрафт, и еще пара обновок
This commit is contained in:
parent
de1b0ecec5
commit
44a897a4c0
16 changed files with 1844 additions and 169 deletions
8
nrdkwebsite/Pages/errors/302.cshtml
Normal file
8
nrdkwebsite/Pages/errors/302.cshtml
Normal file
|
@ -0,0 +1,8 @@
|
|||
@page
|
||||
@model error302
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "найден";
|
||||
}
|
||||
|
||||
<h1>302! найден, но не в состоянии появиться здесь.</h1>
|
11
nrdkwebsite/Pages/errors/302.cshtml.cs
Normal file
11
nrdkwebsite/Pages/errors/302.cshtml.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace nrdkwebsite.Pages.errors;
|
||||
|
||||
public class error302 : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
HttpContext.Response.StatusCode = 302;
|
||||
}
|
||||
}
|
8
nrdkwebsite/Pages/errors/409.cshtml
Normal file
8
nrdkwebsite/Pages/errors/409.cshtml
Normal file
|
@ -0,0 +1,8 @@
|
|||
@page
|
||||
@model error409
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "conflict";
|
||||
}
|
||||
|
||||
<h1>409! Conflict!</h1>
|
12
nrdkwebsite/Pages/errors/409.cshtml.cs
Normal file
12
nrdkwebsite/Pages/errors/409.cshtml.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace nrdkwebsite.Pages.errors;
|
||||
|
||||
public class error409 : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -8,23 +8,23 @@
|
|||
<title>neroduckale's @ViewBag.Title</title><link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@400;500&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/style.css"/>
|
||||
<link rel="stylesheet" href="~/css/style.css"/>
|
||||
<meta name="viewport" content="initial-scale=0.75 user-scalable=no" />
|
||||
<meta charset="UTF-8"/>
|
||||
@* <meta name="viewport" content="width=device-width, initial-scale=1.5"/> *@
|
||||
<meta name="yandex-verification" content="0f72236b9c9df6c5" />
|
||||
<link rel="icon" href="~/img/icon.svg" type="image/svg+xml">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header class="header">
|
||||
<header class="header" id="header">
|
||||
<nav class="header-links">
|
||||
<a class="mainpage" asp-page="index">neroduckale</a>
|
||||
<div class="header-linkss">
|
||||
<a class="header-link" asp-page="ygolek">ygolek</a>
|
||||
<a class="header-link" asp-page="about">about </a>
|
||||
<a class="header-link" asp-page="users">users </a>
|
||||
<a class="header-link" asp-page="minecraftia">my world stats </a>
|
||||
</div>
|
||||
<button class="mobilenav"></button>
|
||||
</nav>
|
||||
|
||||
|
||||
|
@ -34,5 +34,7 @@
|
|||
@RenderBody()
|
||||
</div>
|
||||
|
||||
<script src="~/js/site.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
45
nrdkwebsite/Pages/minecraftia.cshtml
Normal file
45
nrdkwebsite/Pages/minecraftia.cshtml
Normal file
|
@ -0,0 +1,45 @@
|
|||
@page
|
||||
@model Minecraftia
|
||||
@{ViewData["Title"] = "minecraft";}
|
||||
|
||||
Статистика игрока <a href="https://neroduck.ru" style="color: #00ff9d">neroduckale</a>
|
||||
|
||||
<div>Сюда внесены первые десять позиций по количеству, типо какого предмета я скрафтил в больших количествах и так далее</div>
|
||||
<div class="grid-cards">
|
||||
<div class="card">
|
||||
Дроп вещей
|
||||
<canvas id="dropped"></canvas>
|
||||
</div>
|
||||
<div class="card">
|
||||
Использование вещей
|
||||
<canvas id="used"></canvas>
|
||||
</div>
|
||||
<div class="card">
|
||||
Скрафчено
|
||||
<canvas id="crafted"></canvas>
|
||||
</div>
|
||||
<div class="card">
|
||||
Умер (причина)
|
||||
<canvas id="killed_by"></canvas>
|
||||
</div>
|
||||
<div class="card">
|
||||
Сломано
|
||||
<canvas id="broken"></canvas>
|
||||
</div>
|
||||
<div class="card">
|
||||
Убил (кого)
|
||||
<canvas id="killed"></canvas>
|
||||
</div>
|
||||
<div class="card">
|
||||
Подобрал (предметов)
|
||||
<canvas id="picked_up"></canvas>
|
||||
</div>
|
||||
<div class="card">
|
||||
Вскопал (блок)
|
||||
<canvas id="mined"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="module" src="https://unpkg.com/chart.js@4.2.1/dist/chart.umd.js"></script>
|
||||
<script type="module" src="~/js/minecraft.js"></script>
|
||||
<script type="module" src="~/js/inventory.js"></script>
|
11
nrdkwebsite/Pages/minecraftia.cshtml.cs
Normal file
11
nrdkwebsite/Pages/minecraftia.cshtml.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace nrdkwebsite.Pages;
|
||||
|
||||
public class Minecraftia : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
@page
|
||||
@model Users
|
||||
@{ ViewData["Title"] = "users"; }
|
||||
<style>
|
||||
td, th {
|
||||
padding: 5px 10px;
|
||||
}
|
||||
.center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
font-size: x-large;
|
||||
}
|
||||
table, th, td {
|
||||
border: 3px white solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.admin {
|
||||
margin-top: 50px;
|
||||
border: 5px black solid;
|
||||
background: white;
|
||||
font-size: x-large;
|
||||
}
|
||||
.admin:hover {
|
||||
background: black;
|
||||
border: 5px white solid;
|
||||
color: white;
|
||||
transition: all;
|
||||
transition-duration: 300ms;
|
||||
}
|
||||
.AdminButtons {
|
||||
background-color: white;
|
||||
}
|
||||
.newuser {
|
||||
margin-top: 50px;
|
||||
visibility: hidden;
|
||||
transition-duration: 0.3s;
|
||||
}
|
||||
.margintop {
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
<div id="divine">
|
||||
<table class="center" id="users">
|
||||
<tr>
|
||||
<th>Айди</th><th>Никнейм</th><th>Масть</th>
|
||||
</tr> <!--ряд с ячейками заголовков-->
|
||||
<tr id="loading">
|
||||
<td>Loading...</td><td>Loading...</td><td>Loading...</td>
|
||||
</tr> <!--ряд с ячейками тела таблицы-->
|
||||
</table>
|
||||
<button class="admin" onclick="admin()" id="admin">РЕЖИМ АДМИНА</button>
|
||||
</div>
|
||||
<div class="newuser" id="newuser">
|
||||
<span>
|
||||
<div>nickname</div>
|
||||
<input id="nickname"/>
|
||||
<div class="margintop">масть</div>
|
||||
<input id="mast"/>
|
||||
<div></div>
|
||||
<button class="margintop" onclick="neworupdate()">ТАК ТОЧНО!</button>
|
||||
</span>
|
||||
</div>
|
||||
<script src="~/js/admin.js"></script>
|
||||
<script src="~/js/md5.min.js"></script>
|
||||
<script src="~/js/site.js"></script>
|
|
@ -1,14 +0,0 @@
|
|||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace nrdkwebsite.Pages;
|
||||
|
||||
public class Users : PageModel
|
||||
{
|
||||
public void OnGet(string user)
|
||||
{
|
||||
if (user == "admin")
|
||||
{
|
||||
ViewData["Admin"] = "true";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,11 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using nrdkwebsite;
|
||||
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
|
||||
var connection = builder.Configuration.GetConnectionString("DefaultConnection");
|
||||
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
|
||||
builder.Services.AddDbContext<DatabaseHandler>(options => options.UseMySql(connection, ServerVersion.Create(new Version(8, 0, 35), ServerType.MySql)));
|
||||
var myAllowSpecificOrigins = "_myAllowSpecificOrigins";
|
||||
//builder.Services.AddDbContext<DatabaseHandler>(options => options.UseMySql(connection, ServerVersion.Create(new Version(8, 0, 35), ServerType.MySql)));
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy(name: myAllowSpecificOrigins, policy => { policy.WithOrigins("*"); });
|
||||
});
|
||||
var app = builder.Build();
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
|
@ -17,13 +15,19 @@ if (!app.Environment.IsDevelopment())
|
|||
}
|
||||
app.UseStatusCodePagesWithReExecute("/errors/{0}");
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
app.UseCors(myAllowSpecificOrigins);
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
ServeUnknownFileTypes = true
|
||||
});
|
||||
|
||||
app.MapGet("/api/users", API.GetUsers); //WORKS
|
||||
app.MapGet("/api/users/{id:int}", API.GetUserById); //WORKS
|
||||
app.MapGet("/api/users/nickname/{name}", API.GetUserByName); //WORKS
|
||||
app.MapDelete("/api/users/{id:int}", API.DeleteUser); //WORKS
|
||||
app.MapPost("/api/users", API.PostNewUser); //WORKS
|
||||
// app.MapGet("/api/users", API.GetUsers); //WORKS
|
||||
// app.MapGet("/api/users/{id:int}", API.GetUserById); //WORKS
|
||||
// app.MapGet("/api/users/nickname/{name}", API.GetUserByName); //WORKS
|
||||
// app.MapDelete("/api/users/{id:int}", API.DeleteUser); //WORKS
|
||||
// app.MapPost("/api/users", API.PostNewUser); //WORKS
|
||||
app.MapGet("/mctaylors", (HttpContext aaa) => aaa.Response.Redirect("/errors/302"));
|
||||
app.MapGet("/octol1ttle", (HttpContext aaa) => aaa.Response.Redirect("/errors/409"));
|
||||
|
||||
app.UseRouting();
|
||||
app.UseAuthorization();
|
||||
|
|
37
nrdkwebsite/Properties/launchSettings.json
Normal file
37
nrdkwebsite/Properties/launchSettings.json
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:60434",
|
||||
"sslPort": 44306
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:5196",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7106;http://localhost:5196",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -42,8 +42,27 @@ a {
|
|||
|
||||
|
||||
.header {
|
||||
background-color: #4d4d4d;
|
||||
a {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
border-color: #00ff9d;
|
||||
border-width: 3px;
|
||||
border-style: solid;
|
||||
margin: 10px 10px 0 10px;
|
||||
background-color: #000000;
|
||||
}
|
||||
|
||||
|
||||
.card {
|
||||
width: 30rem;
|
||||
padding: 10px;
|
||||
border: 3px gray solid;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.grid-cards {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
|
|
@ -4,16 +4,7 @@ function admin() {
|
|||
return;
|
||||
}
|
||||
document.body.style.background = "black";
|
||||
document.getElementById("admin").remove();
|
||||
let adminbuttons = document.getElementsByClassName("ADMINBUT");
|
||||
for (let item of adminbuttons) {
|
||||
item.style.display = "";
|
||||
}
|
||||
let createuser = document.createElement("button");
|
||||
createuser.append("НОВЫЙ ПОЛЬЗОВАТЕЛЬ");
|
||||
createuser.className = "admin";
|
||||
createuser.addEventListener("click", createclick);
|
||||
document.getElementById("divine").append(createuser);
|
||||
|
||||
}
|
||||
async function deleteUser(id) {
|
||||
const response = await fetch(`/api/users/${id}`, {
|
||||
|
@ -29,12 +20,6 @@ async function deleteUser(id) {
|
|||
console.log(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
function createclick() {
|
||||
let form = document.getElementById("newuser");
|
||||
form.style.visibility = "visible";
|
||||
}
|
||||
|
||||
async function createUser(nickname, mast) {
|
||||
|
||||
const response = await fetch("api/users", {
|
||||
|
@ -47,18 +32,10 @@ async function createUser(nickname, mast) {
|
|||
});
|
||||
if (response.ok === true) {
|
||||
const user = await response.json();
|
||||
document.getElementById("users").append(createrow(user, false));
|
||||
//добавлять юзера
|
||||
}
|
||||
else {
|
||||
const error = await response.json();
|
||||
console.log(error.message);
|
||||
}
|
||||
}
|
||||
function neworupdate() {
|
||||
let nickname = document.getElementById("nickname");
|
||||
let mast = document.getElementById("mast");
|
||||
|
||||
createUser(nickname.value, mast.value);
|
||||
nickname.value = "";
|
||||
mast.value = "";
|
||||
}
|
161
nrdkwebsite/wwwroot/js/minecraft.js
Normal file
161
nrdkwebsite/wwwroot/js/minecraft.js
Normal file
|
@ -0,0 +1,161 @@
|
|||
import {palette} from "./palette.js";
|
||||
|
||||
const keysToSort = [
|
||||
"minecraft:killed_by",
|
||||
"minecraft:broken",
|
||||
"minecraft:used",
|
||||
"minecraft:killed",
|
||||
"minecraft:dropped",
|
||||
"minecraft:crafted",
|
||||
"minecraft:picked_up",
|
||||
"minecraft:mined",
|
||||
];
|
||||
|
||||
async function parseStats(stats) {
|
||||
let values = {
|
||||
valuedropped: [],
|
||||
datasdropped: [],
|
||||
valueused: [],
|
||||
datasused: [],
|
||||
valuecrafted: [],
|
||||
datascrafted: [],
|
||||
valuekilled_by: [],
|
||||
dataskilled_by: [],
|
||||
valuebroken: [],
|
||||
datasbroken: [],
|
||||
valuepicked_up: [],
|
||||
dataspicked_up: [],
|
||||
valuemined: [],
|
||||
datasmined: [],
|
||||
valuekilled: [],
|
||||
dataskilled: [],
|
||||
};
|
||||
// SORTING
|
||||
keysToSort.forEach((key) => {
|
||||
if (stats["stats"][key] && typeof stats["stats"][key] === "object") {
|
||||
stats["stats"][key] = Object.fromEntries(
|
||||
Object.entries(stats["stats"][key]).sort((a, b) => b[1] - a[1])
|
||||
);
|
||||
}
|
||||
});
|
||||
//parsing
|
||||
keysToSort.forEach((key) => {
|
||||
let statistic = stats["stats"][key];
|
||||
statistic = Object.fromEntries(Object.entries(statistic).slice(0, 10));
|
||||
let keyy = key.replace("minecraft:", "");
|
||||
for (let item in statistic) {
|
||||
values["value" + keyy].push(translate(item, key));
|
||||
values["datas" + keyy].push(statistic[item]);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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: [
|
||||
{
|
||||
label: "количество",
|
||||
data: datas,
|
||||
backgroundColor: bgcol,
|
||||
hoverOffset: 6,
|
||||
},
|
||||
],
|
||||
};
|
||||
const config = {
|
||||
type: "doughnut",
|
||||
data: data,
|
||||
options: {
|
||||
plugins: {
|
||||
legend: {
|
||||
labels: {
|
||||
color: "white",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
let canvas = document.getElementById(idcanvas);
|
||||
let chart = new Chart(canvas, config);
|
||||
}
|
||||
|
||||
function translate(item, type) {
|
||||
if (item.includes("minecraft:") === false) {
|
||||
return item;
|
||||
}
|
||||
let r;
|
||||
switch (type) {
|
||||
|
||||
case "minecraft:killed_by":
|
||||
r = window.translatejson["entity." + item];
|
||||
return r;
|
||||
case "minecraft:broken":
|
||||
r = window.translatejson["item." + item]
|
||||
return r
|
||||
case "minecraft:used":
|
||||
r = window.translatejson["item." + item]
|
||||
if (r === undefined) {
|
||||
r = window.translatejson["block." + item];
|
||||
}
|
||||
return r
|
||||
case "minecraft:killed":
|
||||
r = window.translatejson["entity." + item]
|
||||
return r
|
||||
case "minecraft:dropped":
|
||||
r = window.translatejson["item." + item];
|
||||
if (r === undefined) {
|
||||
r = window.translatejson["block." + item];
|
||||
}
|
||||
return r
|
||||
case "minecraft:crafted":
|
||||
r = window.translatejson["item." + item]
|
||||
if (r === undefined) {
|
||||
r = window.translatejson["block." + item];
|
||||
}
|
||||
return r
|
||||
case "minecraft:picked_up":
|
||||
r = window.translatejson["item." + item]
|
||||
if (r === undefined) {
|
||||
r = window.translatejson["block." + item];
|
||||
}
|
||||
return r
|
||||
case "minecraft:mined":
|
||||
r = window.translatejson["block." + item]
|
||||
return r
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getStats();
|
1503
nrdkwebsite/wwwroot/js/palette.js
Normal file
1503
nrdkwebsite/wwwroot/js/palette.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,45 +1 @@
|
|||
const loading = document.getElementById("loading");
|
||||
let loadingLive = true;
|
||||
async function getUsers() {
|
||||
// отправляет запрос и получаем ответ
|
||||
const response = await fetch("/api/users", {
|
||||
method: "GET",
|
||||
headers: { "Accept": "application/json" }
|
||||
});
|
||||
// если запрос прошел нормально
|
||||
if (response.ok === true) {
|
||||
// получаем данные
|
||||
const users = await response.json();
|
||||
const table = document.getElementById("users");
|
||||
if (loadingLive) {
|
||||
loading.remove();
|
||||
loadingLive = false
|
||||
}
|
||||
users.forEach(user => table.append(createrow(user, true)));
|
||||
return users;
|
||||
}
|
||||
}
|
||||
function createrow(user, hidebut) {
|
||||
let tr = document.createElement("tr");
|
||||
let tdName = document.createElement("td");
|
||||
let tdMast = document.createElement("td");
|
||||
let tdId = document.createElement("td");
|
||||
let tdBut = document.createElement("td");
|
||||
let ButtDel = document.createElement("button");
|
||||
tdId.append(user.id);
|
||||
tdName.append(user.nickname);
|
||||
tdMast.append(user.mast);
|
||||
ButtDel.className = "AdminButtons";
|
||||
ButtDel.append("УДАЛИТЬ");
|
||||
ButtDel.addEventListener("click", async() => await deleteUser(user.id));
|
||||
tdBut.append(ButtDel);
|
||||
tdBut.className = "ADMINBUT";
|
||||
if (hidebut) {
|
||||
tdBut.style.display = "none";
|
||||
}
|
||||
tr.append(tdId, tdName, tdMast, tdBut);
|
||||
tr.id = user.id;
|
||||
return tr;
|
||||
}
|
||||
|
||||
getUsers();
|
||||
|
Loading…
Reference in a new issue