diff --git a/models.py b/models.py index a4cc74c..3eb00a4 100644 --- a/models.py +++ b/models.py @@ -1,5 +1,6 @@ from django.db import models from django.contrib.auth.models import User +from datetime import datetime class CoreProtectUser(User): @@ -287,3 +288,43 @@ class CoWorld(models.Model): def __str__(self): return self.world + + +class CoResult(models.Model): + type = models.TextField() + unix = models.TextField() + player = models.TextField() + action = models.TextField() + data = models.TextField() + x = models.TextField() + y = models.TextField() + z = models.TextField() + world = models.TextField() + + @property + def display_time(self): + dt = datetime.fromtimestamp(float(self.unix)) + return dt.strftime("%b %d, %Y at %I:%M:%S %p") + + @property + def display_action(self): + if self.type == "block": + return "Block Break" if self.action == 0 else "Block Place" if self.action == 1 else "Interact/Used" + if self.type == "chat": + return "Chat" + if self.type == "command": + return "Command" + if self.type == "container": + return "Took from Container" if self.action == 0 else "Placed in Container" + return self.action + + @property + def display_data(self): + if self.type == "block": + material = self.data.replace("minecraft:", "") + parts = material.split("_") + return " ".join([part.capitalize() for part in parts]) + return self.data + + class Meta: + managed = False diff --git a/static/coreprotect/js/main.js b/static/coreprotect/js/main.js index d318292..a8406a3 100644 --- a/static/coreprotect/js/main.js +++ b/static/coreprotect/js/main.js @@ -2,8 +2,30 @@ flatpickr('[type="date"]', { altInput: true, altFormat: "F j, Y at H:i", - dateFormat: "Y-m-d H:i", + dateFormat: "U", enableTime: true, }); })(); +function ajax(method, url, callback) { + let xmlhttp = new XMLHttpRequest(); + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState === XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4 + callback(xmlhttp.status, xmlhttp.responseText); + } + }; + xmlhttp.open(method, url, true); + xmlhttp.send(); +} + +function formURI(formData) { + let pairs = []; + for (let data of formData.entries()) { + pairs.push(encodeURIComponent(data[0]) + '=' + encodeURIComponent(data[1])) + } + return pairs.join("&").replace(/%20/g, '+'); +} + +function elementHTML(id, html) { + document.getElementById(id).innerHTML = html +} \ No newline at end of file diff --git a/templates/coreprotect/coreprotect.html b/templates/coreprotect/coreprotect.html index 2e3f387..988335e 100644 --- a/templates/coreprotect/coreprotect.html +++ b/templates/coreprotect/coreprotect.html @@ -22,7 +22,7 @@
-
+

@@ -68,8 +68,8 @@

{% for world in form.worlds %}
- - + +
{% endfor %} @@ -142,8 +142,8 @@

Blocks

-
- +
+

@@ -166,7 +166,7 @@

- +

@@ -175,7 +175,7 @@

-
+
@@ -183,6 +183,16 @@