Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions formapp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ def logFile(type, message):
sD.settings['perms']['sfx'] = data[3]
sD.settings['perms']['bgm'] = data[4]
sD.settings['perms']['api'] = data[5]
sD.settings['perms']['tags'] = data[9]
sD.settings['locked'] = data[6]
sD.settings['blind'] = data[7]
sD.settings['showinc'] = data[8]
Expand Down Expand Up @@ -958,7 +957,7 @@ def endpoint_2048():

@app.route('/abcd')
def endpoint_abcd():
loginResult = loginCheck(request.remote_addr, request.path, 'student')
loginResult = loginCheck(request.remote_addr)
if loginResult:
return loginResult
else:
Expand Down Expand Up @@ -3138,7 +3137,9 @@ def endpoint_usermanual():
# This endpoint allows you to see the formbars IP with style and shows different colors.
@app.route('/virtualbar')
def endpoint_virtualbar():
return render_template("virtualbar.html")
type = sD.pollType
print(type)
return render_template("virtualbar.html", type = type)

# ██ ██
# ██ ██
Expand Down
141 changes: 72 additions & 69 deletions formapp/templates/virtualbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,7 @@

<!-- Extra style declarations here -->
{% block style %}
<style>
body {
user-select: none;
background: var(--bg-dark-blue);
}

#virtualBar {
width: calc(100% - 32px);
}

#text {
width: 10ch;
padding: 0 4px;
border: 1px white;
border-style: solid solid none;
background: black;
font: 32px monospace;
text-transform: uppercase;
overflow: hidden;
}

#pixBox {
width: 100%;
height: 64px;
box-sizing: border-box;
border: 1px solid white;
display: flex;
justify-content: space-around;
user-select: none;
}
</style>

{% endblock %}

<!-- Change theme color here -->
Expand All @@ -46,7 +16,6 @@
<!-- Main content here -->
{% block main %}


<div class="container"></div>
<canvas id='virtualbar' style="height:900px; width:969px"></canvas>

Expand All @@ -61,17 +30,13 @@
<script>

var mychart = document.getElementById('virtualbar').getContext("2d");

var doughnutChart = new Chart(mychart, {
type: 'doughnut',
data: {
labels: ["Up", "Wiggle", "Down"],
labels: [],
datasets: [{
backgroundColor: [
"#00ff00",
"#00ffff",
"#ff0000"],
data: [0, 0, 0]
backgroundColor: [],
data: [0, 0, 0, 0]
}]
},
options: {
Expand All @@ -88,59 +53,97 @@


}
pixBox.innerHTML += "<div style='display: inline; flex-grow: 1; overflow: hidden; background-color: #" + pix[i][0] + "" + pix[i][1] + "" + pix[i][2] + ";'>&nbsp;</div>";
}
}
});



let pixRes;

let type = "{{ type }}"

function update() {
// Update the virtual bar
let pixRequest = new XMLHttpRequest();
pixRequest.open("GET", '/api/students');
pixRequest.onload = () => {
pixRes = JSON.parse(pixRequest.responseText);

var up = 0
var wiggle = 0
var down = 0

pixRes = JSON.parse(pixRequest.responseText);

for (const key of Object.keys(pixRes)) {
console.log(pixRes[key].thumb);
if (pixRes[key].thumb == "up") {
up++
console.log('found up');
if (type == 'tutd'){
var up = 0
var wiggle = 0
var down = 0
var none = 0


for (const key of Object.keys(pixRes)) {
console.log(pixRes[key].thumb);
if (pixRes[key].thumb == "up") {
up++
}

if (pixRes[key].thumb == "wiggle") {
wiggle++
}

if (pixRes[key].thumb == "down") {
down++
}
if (pixRes[key].thumb == "") {
none++
}
if (up >= 1 && down == 0 && wiggle == 0 && none == 0){
doughnutChart.data.labels = ['MAX GAMER']
doughnutChart.data.datasets[0].backgroundColor = ['#BF40BF']
doughnutChart.data.datasets[0].data = [up];
} else {
doughnutChart.data.labels = ["Up", "Wiggle", "Down", "Not Submitted"]
doughnutChart.data.datasets[0].backgroundColor = ["#00ff00","#00ffff","#ff0000", "#FFFFFF"]
doughnutChart.data.datasets[0].data = [up, wiggle, down, none];
}

if (pixRes[key].thumb == "wiggle") {
wiggle++
console.log('found wiggle');
}
} else if (type == 'abcd'){
var a = 0
var b = 0
var c = 0
var d = 0


for (const key of Object.keys(pixRes)) {
console.log(pixRes[key].letter);
if (pixRes[key].letter == "a") {
a++
}

if (pixRes[key].letter == "b") {
b++
}

if (pixRes[key].letter == "c") {
c++
}

if (pixRes[key].letter == "d") {
d++
}
doughnutChart.data.datasets[0].data = [a, b, c, d];
doughnutChart.data.labels = ['A', 'B', 'C', 'D'];
doughnutChart.data.datasets[0].backgroundColor = ["#00ff00","#00ffff","#ff0000", "#ffdf40"]
}
} else {
doughnutChart.data.labels = ['No Active Poll'];
}

if (pixRes[key].thumb == "down") {
down++
console.log('found down');
}

}
doughnutChart.data.datasets[0].data = [up, wiggle, down];

doughnutChart.update();
pixRequest.send(null);
}
pixRequest.send(null);




// When the page needs to refresh, send a signal to chat which will then refresh everyone's page
chatSocket.on("sessionUpdate", message => {
console.log(message);
location.reload();
});


update();
setInterval(update, 1000);
</script>
Expand Down