From 950cab1bafe91aad0ccd8a492c017829270576f7 Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Thu, 7 Jan 2021 12:28:01 -0500 Subject: [PATCH] Remove react --- src/App.css | 38 ------ src/App.js | 152 ---------------------- src/index.js | 13 -- static/app.js | 121 +++++++++++++++++ static/components.js | 72 ++++++++++ static/css/main.5c7015b9.chunk.css | 2 - static/css/main.5c7015b9.chunk.css.map | 1 - {src => static}/index.css | 72 +++++----- static/index.html | 91 +++++++++++++ static/js/2.55237e37.chunk.js | 3 - static/js/2.55237e37.chunk.js.LICENSE.txt | 41 ------ static/js/2.55237e37.chunk.js.map | 1 - static/js/main.a24cc14e.chunk.js | 2 - static/js/main.a24cc14e.chunk.js.map | 1 - static/js/runtime-main.e8303b2e.js | 2 - static/js/runtime-main.e8303b2e.js.map | 1 - tools/unban.go | 38 ++++++ 17 files changed, 361 insertions(+), 290 deletions(-) delete mode 100644 src/App.css delete mode 100644 src/App.js delete mode 100644 src/index.js create mode 100644 static/app.js create mode 100644 static/components.js delete mode 100644 static/css/main.5c7015b9.chunk.css delete mode 100644 static/css/main.5c7015b9.chunk.css.map rename {src => static}/index.css (51%) create mode 100644 static/index.html delete mode 100644 static/js/2.55237e37.chunk.js delete mode 100644 static/js/2.55237e37.chunk.js.LICENSE.txt delete mode 100644 static/js/2.55237e37.chunk.js.map delete mode 100644 static/js/main.a24cc14e.chunk.js delete mode 100644 static/js/main.a24cc14e.chunk.js.map delete mode 100644 static/js/runtime-main.e8303b2e.js delete mode 100644 static/js/runtime-main.e8303b2e.js.map create mode 100644 tools/unban.go diff --git a/src/App.css b/src/App.css deleted file mode 100644 index 74b5e05..0000000 --- a/src/App.css +++ /dev/null @@ -1,38 +0,0 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/src/App.js b/src/App.js deleted file mode 100644 index e75bba8..0000000 --- a/src/App.js +++ /dev/null @@ -1,152 +0,0 @@ - -import React from "react"; -import './App.css'; - -class Card extends React.Component{ - state = { - data: {}, - details: {}, - expand: false - } - - constructor(props) { - super(props); - this.state.data = props; - this.state.details = {}; - this.state.expand = false; - this.onClick = this.onClick.bind(this); - } - onClick(e) { - fetch( - `https://thanos.nightmare.haus/api/user?userID=${this.state.data.UserID}` - ) - .then(res => res.json()) - .then(response => { - this.setState({data: this.state.data, expand: !this.state.expand, details: response}); - }) - .catch(error => console.log(error)); - } - render() { - if (this.state.expand) { - if (this.state.details != null) { - return ( -
- -
- - ) - } else { - var details = {}; - details.Nick = this.state.data.Username + " (Invalid)"; - details.user = {}; - details.user.id = this.state.data.UserID; - details.joined_at = this.state.data.Closed; - return ( -
- -
- ) - } - - } - return ( -
-

{this.state.data.Username}{this.state.details == null ? " (Invalid)" : ""}

-
-

{this.state.data.Closed}

-

{this.state.data.UserID}

-

Verification Photo

-
-
- ); -} -} - - function CardImg(data) { - return ( -
-

Pend: {data.Username}

- Avatar -
-

{data.UserID}

-
-
- ) - } - -function UserDetail(data, verification) { - console.log(data); - verification = data.verification - data = data.data; - return ( -
-

{data.Nick !== null ? data.Nick : data.user.Username}

- Avatar - -
- - Avatar -

{data.joined_at}

-

{data.user.id}

-
-
- ); -} - -class Pending extends React.Component { - state = { - pending: [] - } - componentDidMount() { - const apiUrl = 'https://thanos.nightmare.haus/api/pending'; - fetch(apiUrl) - .then((response) => response.json()) - .then((data) => this.setState({pending: Object.values(data)})); - } - render() { - return ( -
- -

-
- ); - } -} - - - -class Verification extends React.Component { - state = { - verifications: [] - } - componentDidMount() { - const apiUrl = 'https://thanos.nightmare.haus/api/verifications'; - fetch(apiUrl) - .then((response) => response.json()) - .then((data) => this.setState({verifications: data})); - } - - render() { - return ( -
- -
    - {this.state.verifications.map((data, i) => ( -
  • - ))} -
-
- ); - } -} - -export { - Pending, - Verification, -} - -export default Verification; \ No newline at end of file diff --git a/src/index.js b/src/index.js deleted file mode 100644 index 51fde59..0000000 --- a/src/index.js +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import './index.css'; -import Verification from './App'; -import Pending from './App'; - -ReactDOM.render( - - - - , - document.getElementById('react_app') -); diff --git a/static/app.js b/static/app.js new file mode 100644 index 0000000..bc4a018 --- /dev/null +++ b/static/app.js @@ -0,0 +1,121 @@ + +// Get the modal +const modal = document.getElementById("myModal"); + +// Get the button that opens the modal +const btn = document.getElementById("myBtn"); + +// Get the element that closes the modal +const span = document.getElementsByClassName("close")[0]; +const mode = new URLSearchParams(window.location.search).get("mode"); + +const archiveLink = document.querySelector("#archive-link") +const pendingLink = document.querySelector("#pending-link") +const statusLink = document.querySelector("#status-link") + +function main() { + archiveLink.classList.remove("active"); + pendingLink.classList.remove("active"); + statusLink.classList.remove("active"); + switch (mode) { + case "status": + statusLink.classList.add("active"); + return; + case "pending": + pendingLink.classList.add("active"); + break; + case "verifications": + archiveLink.classList.add("active"); + break; + default: + console.log("No mode"); + mode = "verifications" + archiveLink.classList.add("active"); + break; + } + document.getElementById("main-app").innerHTML = ''; + fetch(`https://thanos.nightmare.haus/api/${mode}`) + .then(response => response.json()) + .then(data => processData(data)); + +} + +function searchPage() { + var search = document.getElementById("search-bar"); + fetch('https://thanos.nightmare.haus/api/verifications') + .then(response => response.json()) + .then(data => { + var searchData = []; + for (user of data) { + var match = false; + + if (user.Username.toLowerCase().includes(search.value.toLowerCase())) { + match = true; + } + if (new Date(user.Closed).toLocaleString().includes(search.value)) { + match = true; + } + if (user.UserID.includes(search.value)) { + match = true; + } + if (match) { + searchData.push(user); + } + } + processData(searchData); + }); +} + +function processData(data) { + document.getElementById("main-app").innerHTML = ''; + if (data.length == 0) { + alert("No data."); + return; + } + data = Object.values(data); + for (user of data) { + var node = document.createElement("user-card"); + var nameSlot = document.createElement("div"); + nameSlot.setAttribute("slot", "username"); + nameSlot.innerText = user.Username; + node.appendChild(nameSlot); + + var joinDate = document.createElement("div"); + joinDate.setAttribute("slot", "join-date"); + joinDate.innerText = mode == "pending" ? new Date(user.Submitted).toLocaleString() : new Date(user.Closed).toLocaleString(); + node.appendChild(joinDate); + + var discordSlot = document.createElement("div"); + discordSlot.setAttribute("slot", "discord-id"); + discordSlot.innerText = user.UserID; + node.appendChild(discordSlot); + + var picSlot = document.createElement("div"); + picSlot.setAttribute("slot", "pic-link"); + var aNode = document.createElement("a"); + + aNode.setAttribute("href", mode == "pending" ? user.Photo : `https://thanos.nightmare.haus/${user.Photo}`); + aNode.innerText = "Verification Photo"; + + picSlot.appendChild(aNode); + node.appendChild(picSlot); + document.getElementById("main-app").appendChild(node); + } +} + +// When the user clicks on (x), close the modal +span.onclick = function () { + modal.style.display = "none"; +} + +// When the user clicks anywhere outside of the modal, close it +window.onclick = function (event) { + if (event.target == modal) { + modal.style.display = "none"; + } +} +var form = document.getElementById("search-form"); +function handleForm(event) { event.preventDefault(); } +form.addEventListener('submit', handleForm); + +main(); \ No newline at end of file diff --git a/static/components.js b/static/components.js new file mode 100644 index 0000000..b8defe6 --- /dev/null +++ b/static/components.js @@ -0,0 +1,72 @@ +const basicCard = document.createElement('basic-card'); +basicCard.innerHTML = ` + +
+
+

+
+

+

+

+
+
+
+`; + + +class UserCard extends HTMLElement { + constructor() { + super(); + this.attachShadow({ mode: 'open' }); + this.shadowRoot.appendChild(basicCard.cloneNode(true)); + } + connectedCallback() { + this.shadowRoot.querySelector('#card-container').addEventListener('click', () => this.showModal()); + } + + showModal() { + const userID = this.shadowRoot.querySelector('#discord-id').assignedNodes()[0].textContent; + const userPic = this.shadowRoot.querySelector("#pic-link").assignedNodes()[0].querySelector("a").getAttribute("href"); + fetch('https://thanos.nightmare.haus/api/user?userID=' + userID) + .then(response => response.json()) + .then(data => { + if (data === undefined || data === null) { + alert("User not found."); + return; + } + document.querySelector("#myModal").style.display = "block"; + document.querySelector('#modal-join').textContent = new Date(data.joined_at).toLocaleString(); + document.querySelector('#modal-userID').textContent = data.user.username; + document.querySelector('#modal-avatar').src = `https://cdn.discordapp.com/avatars/${data.user.id}/${data.user.avatar}.png?size=256`; + document.querySelector('#modal-verification').src = userPic; + document.querySelector('#modal-verification').style = "max-height: 500px;"; + }); + } + +} +window.customElements.define('user-card', UserCard); diff --git a/static/css/main.5c7015b9.chunk.css b/static/css/main.5c7015b9.chunk.css deleted file mode 100644 index a8d10aa..0000000 --- a/static/css/main.5c7015b9.chunk.css +++ /dev/null @@ -1,2 +0,0 @@ -body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}code{font-family:source-code-pro,Menlo,Monaco,Consolas,"Courier New",monospace}.card{height:200px}.card,.card-img{box-shadow:0 4px 8px 0 rgba(0,0,0,.137);border-radius:3%;transition:.3s;position:relative;width:300px;padding:10px;background-color:#282c34;color:#fff}.card-img{height:450px}.card:hover{box-shadow:0 8px 16px 0 rgba(0,0,0,.795)}.container{padding:6px 16px}ul{list-style-type:none;margin:4;padding:20px;overflow:hidden;display:table;width:100%;list-style:none}li{float:left;display:table-cell;text-align:center;margin:5px}ul li div{display:block}.App{text-align:center}.App-logo{height:40vmin;pointer-events:none}@media (prefers-reduced-motion:no-preference){.App-logo{-webkit-animation:App-logo-spin 20s linear infinite;animation:App-logo-spin 20s linear infinite}}.App-header{background-color:#282c34;min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:calc(10px + 2vmin);color:#fff}.App-link{color:#61dafb}@-webkit-keyframes App-logo-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes App-logo-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}} -/*# sourceMappingURL=main.5c7015b9.chunk.css.map */ \ No newline at end of file diff --git a/static/css/main.5c7015b9.chunk.css.map b/static/css/main.5c7015b9.chunk.css.map deleted file mode 100644 index 400da80..0000000 --- a/static/css/main.5c7015b9.chunk.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["webpack://src/index.css","webpack://src/App.css"],"names":[],"mappings":"AAAA,KACI,QAAS,CACT,mJAEY,CACZ,kCAAmC,CACnC,iCACF,CAEA,KACE,yEAEF,CACA,MAOE,YAIF,CACA,gBAVE,uCAA4C,CAC5C,gBAAiB,CACjB,cAAgB,CAChB,iBAAkB,CAClB,WAAY,CAEZ,YAAa,CACb,wBAAyB,CACzB,UAaF,CAXA,UAOE,YAIF,CAGA,YACE,wCACF,CAGA,WACE,gBACF,CAEA,GACE,oBAAqB,CACrB,QAAS,CACT,YAAa,CACb,eAAgB,CACd,aAAc,CACd,UAAW,CACX,eACJ,CAEA,GACE,UAAW,CACX,kBAAmB,CACnB,iBAAkB,CAClB,UACF,CACA,UACE,aACF,CClEF,KACE,iBACF,CAEA,UACE,aAAc,CACd,mBACF,CAEA,8CACE,UACE,mDAA4C,CAA5C,2CACF,CACF,CAEA,YACE,wBAAyB,CACzB,gBAAiB,CACjB,YAAa,CACb,qBAAsB,CACtB,kBAAmB,CACnB,sBAAuB,CACvB,4BAA6B,CAC7B,UACF,CAEA,UACE,aACF,CAEA,iCACE,GACE,sBACF,CACA,GACE,uBACF,CACF,CAPA,yBACE,GACE,sBACF,CACA,GACE,uBACF,CACF","file":"main.5c7015b9.chunk.css","sourcesContent":["body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n \n code {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n }\n .card {\n /* Add shadows to create the \"card\" effect */\n box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.137);\n border-radius: 3%;\n transition: 0.3s;\n position: relative;\n width: 300px;\n height: 200px;\n padding: 10px;\n background-color: #282c34;\n color: #FFFFFF;\n }\n .card-img {\n /* Add shadows to create the \"card\" effect */\n box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.137);\n border-radius: 3%;\n transition: 0.3s;\n position: relative;\n width: 300px;\n height: 450px;\n padding: 10px;\n background-color: #282c34;\n color: #FFFFFF;\n }\n \n /* On mouse-over, add a deeper shadow */\n .card:hover {\n box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.795);\n }\n \n /* Add some padding inside the card container */\n .container {\n padding: 6px 16px;\n }\n \n ul {\n list-style-type: none;\n margin: 4;\n padding: 20px;\n overflow: hidden;\n display: table;\n width: 100%;\n list-style: none;\n }\n \n li {\n float: left;\n display: table-cell;\n text-align: center;\n margin: 5px;\n }\n ul li div {\n display: block;\n }",".App {\n text-align: center;\n}\n\n.App-logo {\n height: 40vmin;\n pointer-events: none;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n .App-logo {\n animation: App-logo-spin infinite 20s linear;\n }\n}\n\n.App-header {\n background-color: #282c34;\n min-height: 100vh;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n font-size: calc(10px + 2vmin);\n color: white;\n}\n\n.App-link {\n color: #61dafb;\n}\n\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n"]} \ No newline at end of file diff --git a/src/index.css b/static/index.css similarity index 51% rename from src/index.css rename to static/index.css index c0a84b4..0eb0240 100644 --- a/src/index.css +++ b/static/index.css @@ -23,19 +23,7 @@ body { background-color: #282c34; color: #FFFFFF; } - .card-img { - /* Add shadows to create the "card" effect */ - box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.137); - border-radius: 3%; - transition: 0.3s; - position: relative; - width: 300px; - height: 450px; - padding: 10px; - background-color: #282c34; - color: #FFFFFF; - } - + /* On mouse-over, add a deeper shadow */ .card:hover { box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.795); @@ -45,23 +33,41 @@ body { .container { padding: 6px 16px; } - - ul { - list-style-type: none; - margin: 4; - padding: 20px; - overflow: hidden; - display: table; - width: 100%; - list-style: none; - } - - li { - float: left; - display: table-cell; - text-align: center; - margin: 5px; - } - ul li div { - display: block; - } \ No newline at end of file + + /* The Modal (background) */ +.modal { + display: none; /* Hidden by default */ + position: fixed; /* Stay in place */ + z-index: 1; /* Sit on top */ + left: 0; + top: 0; + width: 100%; /* Full width */ + height: 100%; /* Full height */ + overflow: auto; /* Enable scroll if needed */ + background-color: rgb(0,0,0); /* Fallback color */ + background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ +} + +/* Modal Content/Box */ +.modal-content { + background-color: #282c34; + margin: 15% auto; /* 15% from the top and centered */ + padding: 20px; + border: 1px solid #888; + width: 80%; /* Could be more or less, depending on screen size */ + color: white; +} + +.close { + color: #aaa; + float: right; + font-size: 28px; + font-weight: bold; +} + +.close:hover, +.close:focus { + color: black; + text-decoration: none; + cursor: pointer; +} \ No newline at end of file diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..30deda0 --- /dev/null +++ b/static/index.html @@ -0,0 +1,91 @@ + + + + + + + + + + + Thanos2 + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/static/js/2.55237e37.chunk.js b/static/js/2.55237e37.chunk.js deleted file mode 100644 index 086efc9..0000000 --- a/static/js/2.55237e37.chunk.js +++ /dev/null @@ -1,3 +0,0 @@ -/*! For license information please see 2.55237e37.chunk.js.LICENSE.txt */ -(this.webpackJsonpthanos=this.webpackJsonpthanos||[]).push([[2],[function(e,t,n){"use strict";e.exports=n(10)},function(e,t,n){"use strict";e.exports=n(11)},function(e,t,n){"use strict";function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";function r(e,t){for(var n=0;n