mirror of
https://github.com/FAUSheppy/open-web-leaderboard.git
synced 2025-12-11 01:18:33 +01:00
tabs -> spaces
This commit is contained in:
@@ -3,248 +3,248 @@ acceptedParser = [ "top", "jungle", "mid", "sup" , "bot", "adc", "support", "bot
|
|||||||
sides = [ "left", "right"]
|
sides = [ "left", "right"]
|
||||||
|
|
||||||
var checkPlayerFunc = function checkPlayer() {
|
var checkPlayerFunc = function checkPlayer() {
|
||||||
if(this.value == ""){
|
if(this.value == ""){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
url = "/player?id=" + this.value
|
url = "/player?id=" + this.value
|
||||||
fetch(url).then(r => {
|
fetch(url).then(r => {
|
||||||
if(r.status == 200){
|
if(r.status == 200){
|
||||||
this.style.background = "#74bb74"
|
this.style.background = "#74bb74"
|
||||||
}else{
|
}else{
|
||||||
//this.style.background = "#d25252"
|
//this.style.background = "#d25252"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var fastPosChangedFunc = function fastPosChanged() {
|
var fastPosChangedFunc = function fastPosChanged() {
|
||||||
|
|
||||||
accepted = [ "top", "jungle", "mid", "sup" , "bot" ]
|
accepted = [ "top", "jungle", "mid", "sup" , "bot" ]
|
||||||
uniqArr = []
|
uniqArr = []
|
||||||
prioArray = [5, 5, 5, 5, 5]
|
prioArray = [5, 5, 5, 5, 5]
|
||||||
|
|
||||||
/* commence cleanup */
|
/* commence cleanup */
|
||||||
clean = this.value.replaceAll(" ", "").toLocaleLowerCase()
|
clean = this.value.replaceAll(" ", "").toLocaleLowerCase()
|
||||||
clean = clean.replace("support", "sup")
|
clean = clean.replace("support", "sup")
|
||||||
clean = clean.replace("adc", "bot")
|
clean = clean.replace("adc", "bot")
|
||||||
clean = clean.replace("bottom", "bot")
|
clean = clean.replace("bottom", "bot")
|
||||||
|
|
||||||
retVal = true
|
retVal = true
|
||||||
if(clean.includes("<")){
|
if(clean.includes("<")){
|
||||||
console.log("Not accepted (includes <)")
|
console.log("Not accepted (includes <)")
|
||||||
retVal = false
|
retVal = false
|
||||||
}
|
}
|
||||||
|
|
||||||
list = clean.split(">")
|
list = clean.split(">")
|
||||||
cur = 1
|
cur = 1
|
||||||
list.forEach(el => {
|
list.forEach(el => {
|
||||||
if(el.includes("=")){
|
if(el.includes("=")){
|
||||||
listEq = el.split("=")
|
listEq = el.split("=")
|
||||||
listEq.forEach(sub => {
|
listEq.forEach(sub => {
|
||||||
if(accepted.includes(sub) && !uniqArr.includes(sub)){
|
if(accepted.includes(sub) && !uniqArr.includes(sub)){
|
||||||
prioArray[accepted.indexOf(sub)] = cur
|
prioArray[accepted.indexOf(sub)] = cur
|
||||||
uniqArr += [sub]
|
uniqArr += [sub]
|
||||||
}else{
|
}else{
|
||||||
console.log("Not accepted (=): " + sub)
|
console.log("Not accepted (=): " + sub)
|
||||||
retVal = false
|
retVal = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
cur++
|
cur++
|
||||||
}else{
|
}else{
|
||||||
if(accepted.includes(el) && !uniqArr.includes(el)){
|
if(accepted.includes(el) && !uniqArr.includes(el)){
|
||||||
prioArray[accepted.indexOf(el)] = cur
|
prioArray[accepted.indexOf(el)] = cur
|
||||||
uniqArr += [el]
|
uniqArr += [el]
|
||||||
cur++
|
cur++
|
||||||
}else{
|
}else{
|
||||||
console.log("Not accepted (>): " + el)
|
console.log("Not accepted (>): " + el)
|
||||||
retVal = false
|
retVal = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
for(i = 0; i<5; i++){
|
for(i = 0; i<5; i++){
|
||||||
arr = this.id.split("-")
|
arr = this.id.split("-")
|
||||||
pNr = arr[arr.length-1]
|
pNr = arr[arr.length-1]
|
||||||
side = this.id.includes("left") ? "left" : "right"
|
side = this.id.includes("left") ? "left" : "right"
|
||||||
|
|
||||||
roleSubmission = document.getElementById("fastpos-submission")
|
roleSubmission = document.getElementById("fastpos-submission")
|
||||||
if(roleSubmission){
|
if(roleSubmission){
|
||||||
string = "prio_" + accepted[i]
|
string = "prio_" + accepted[i]
|
||||||
}else {
|
}else {
|
||||||
string = "prio-" + side + "-" + accepted[i] + "-" + pNr
|
string = "prio-" + side + "-" + accepted[i] + "-" + pNr
|
||||||
}
|
}
|
||||||
|
|
||||||
string = string.replace("top","Top")
|
string = string.replace("top","Top")
|
||||||
string = string.replace("jungle","Jungle")
|
string = string.replace("jungle","Jungle")
|
||||||
string = string.replace("mid","Mid")
|
string = string.replace("mid","Mid")
|
||||||
string = string.replace("sup","Support")
|
string = string.replace("sup","Support")
|
||||||
string = string.replace("bot","Bottom")
|
string = string.replace("bot","Bottom")
|
||||||
|
|
||||||
selector = document.getElementById(string)
|
selector = document.getElementById(string)
|
||||||
selector.value = prioArray[i]
|
selector.value = prioArray[i]
|
||||||
selector.style.background = "lightblue"
|
selector.style.background = "lightblue"
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allow some basic shit */
|
/* allow some basic shit */
|
||||||
if(clean == "*" || clean == ""){
|
if(clean == "*" || clean == ""){
|
||||||
retVal = true
|
retVal = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if(retVal){
|
if(retVal){
|
||||||
this.style.background = "#74bb74"
|
this.style.background = "#74bb74"
|
||||||
}else{
|
}else{
|
||||||
this.style.background = "#d25252"
|
this.style.background = "#d25252"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function balance(){
|
function balance(){
|
||||||
|
|
||||||
cont = document.getElementById("response-container")
|
cont = document.getElementById("response-container")
|
||||||
cont.innerHTML = ""
|
cont.innerHTML = ""
|
||||||
sides = ["left", "right"]
|
sides = ["left", "right"]
|
||||||
|
|
||||||
blue = [ "", "", "", "", ""]
|
blue = [ "", "", "", "", ""]
|
||||||
red = [ "", "", "", "", ""]
|
red = [ "", "", "", "", ""]
|
||||||
|
|
||||||
dictToBeSorted = {
|
dictToBeSorted = {
|
||||||
0 : [],
|
0 : [],
|
||||||
1 : [],
|
1 : [],
|
||||||
2 : [],
|
2 : [],
|
||||||
3 : [],
|
3 : [],
|
||||||
4 : []
|
4 : []
|
||||||
}
|
}
|
||||||
filler = []
|
filler = []
|
||||||
impossible = []
|
impossible = []
|
||||||
|
|
||||||
dictAll = {}
|
dictAll = {}
|
||||||
for(sid = 0; sid < 2; sid++){
|
for(sid = 0; sid < 2; sid++){
|
||||||
for(id = 0; id < 5; id++){
|
for(id = 0; id < 5; id++){
|
||||||
|
|
||||||
var pname = "undef"
|
var pname = "undef"
|
||||||
var prioList = [5, 5, 5, 5, 5]
|
var prioList = [5, 5, 5, 5, 5]
|
||||||
|
|
||||||
stringPid = `playername-${sides[sid]}-${id}`
|
stringPid = `playername-${sides[sid]}-${id}`
|
||||||
pnameObj = document.getElementById(stringPid)
|
pnameObj = document.getElementById(stringPid)
|
||||||
pname = pnameObj.value
|
pname = pnameObj.value
|
||||||
for(acc = 0; acc < 5; acc++){
|
for(acc = 0; acc < 5; acc++){
|
||||||
stringSelectorId = `prio-${sides[sid]}-${positions[acc]}-${id}`
|
stringSelectorId = `prio-${sides[sid]}-${positions[acc]}-${id}`
|
||||||
selObj = document.getElementById(stringSelectorId)
|
selObj = document.getElementById(stringSelectorId)
|
||||||
prioList[acc] = selObj.value
|
prioList[acc] = selObj.value
|
||||||
}
|
}
|
||||||
|
|
||||||
dictAll[pname] = prioList
|
dictAll[pname] = prioList
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonData = JSON.stringify(dictAll, null, 4);
|
jsonData = JSON.stringify(dictAll, null, 4);
|
||||||
|
|
||||||
/* transmitt */
|
/* transmitt */
|
||||||
spinner = document.getElementById("loading")
|
spinner = document.getElementById("loading")
|
||||||
spinner.style.display = "block";
|
spinner.style.display = "block";
|
||||||
fetch(window.location.href, {
|
fetch(window.location.href, {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json, text/plain, */*',
|
'Accept': 'application/json, text/plain, */*',
|
||||||
'Content-Type': 'application/json' },
|
'Content-Type': 'application/json' },
|
||||||
body: jsonData
|
body: jsonData
|
||||||
}).then(r => r.json()).then(j => {
|
}).then(r => r.json()).then(j => {
|
||||||
spinner.style.display = "none";
|
spinner.style.display = "none";
|
||||||
cont.innerHTML = j["content"]
|
cont.innerHTML = j["content"]
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseMultiline(){
|
function parseMultiline(){
|
||||||
|
|
||||||
var names = []
|
var names = []
|
||||||
var prioStrings = []
|
var prioStrings = []
|
||||||
|
|
||||||
field = document.getElementById("multi-line-copy")
|
field = document.getElementById("multi-line-copy")
|
||||||
lines = field.value.split("\n")
|
lines = field.value.split("\n")
|
||||||
lines.forEach(l => {
|
lines.forEach(l => {
|
||||||
|
|
||||||
lowestIndex = 100
|
lowestIndex = 100
|
||||||
|
|
||||||
acceptedParser.forEach( p => {
|
acceptedParser.forEach( p => {
|
||||||
i = l.indexOf(" " + p)
|
i = l.indexOf(" " + p)
|
||||||
if(i >= 3 && i < lowestIndex){
|
if(i >= 3 && i < lowestIndex){
|
||||||
lowestIndex = i
|
lowestIndex = i
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if(lowestIndex != 100){
|
if(lowestIndex != 100){
|
||||||
name = l.substring(0, lowestIndex)
|
name = l.substring(0, lowestIndex)
|
||||||
prioStr = l.substring(lowestIndex)
|
prioStr = l.substring(lowestIndex)
|
||||||
names.push(name)
|
names.push(name)
|
||||||
prioStrings.push(prioStr)
|
prioStrings.push(prioStr)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
sides.forEach(s => {
|
sides.forEach(s => {
|
||||||
for(i = 0; i<5; i++){
|
for(i = 0; i<5; i++){
|
||||||
|
|
||||||
pObjField = document.getElementById("playername-" + s + "-" + i)
|
pObjField = document.getElementById("playername-" + s + "-" + i)
|
||||||
prObjField = document.getElementById("check-" + s + "-fastpos-" + i)
|
prObjField = document.getElementById("check-" + s + "-fastpos-" + i)
|
||||||
|
|
||||||
if(count >= names.length){
|
if(count >= names.length){
|
||||||
pObjField.value = ""
|
pObjField.value = ""
|
||||||
prObjField.value = ""
|
prObjField.value = ""
|
||||||
}else{
|
}else{
|
||||||
pObjField.value = names[count]
|
pObjField.value = names[count]
|
||||||
prObjField.value = prioStrings[count]
|
prObjField.value = prioStrings[count]
|
||||||
}
|
}
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const focusEvent = new Event("focus")
|
const focusEvent = new Event("focus")
|
||||||
fastPosFields.forEach(el => el.dispatchEvent(focusEvent))
|
fastPosFields.forEach(el => el.dispatchEvent(focusEvent))
|
||||||
balance()
|
balance()
|
||||||
}
|
}
|
||||||
|
|
||||||
function queryForPlayerData(){
|
function queryForPlayerData(){
|
||||||
ident = document.getElementById("ident-field").innerHTML
|
ident = document.getElementById("ident-field").innerHTML
|
||||||
fetch("/balance-tool-data?id=" + ident).then(r => r.json()).then(j => {
|
fetch("/balance-tool-data?id=" + ident).then(r => r.json()).then(j => {
|
||||||
if("no-data" in j){
|
if("no-data" in j){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
j["submissions"].forEach(el => {
|
j["submissions"].forEach(el => {
|
||||||
console.log(el)
|
console.log(el)
|
||||||
breakToSubmissions = false
|
breakToSubmissions = false
|
||||||
for(sid = 0; sid < 2; sid++){
|
for(sid = 0; sid < 2; sid++){
|
||||||
if(breakToSubmissions){
|
if(breakToSubmissions){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for(id = 0; id < 5; id++){
|
for(id = 0; id < 5; id++){
|
||||||
stringPid = `playername-${sides[sid]}-${id}`
|
stringPid = `playername-${sides[sid]}-${id}`
|
||||||
pnameObj = document.getElementById(stringPid)
|
pnameObj = document.getElementById(stringPid)
|
||||||
if(pnameObj.value == "" || pnameObj.value == el["name"]){
|
if(pnameObj.value == "" || pnameObj.value == el["name"]){
|
||||||
pnameObj.value = el["name"]
|
pnameObj.value = el["name"]
|
||||||
for(acc = 0; acc < 5; acc++){
|
for(acc = 0; acc < 5; acc++){
|
||||||
stringSelectorId = `prio-${sides[sid]}-${positions[acc]}-${id}`
|
stringSelectorId = `prio-${sides[sid]}-${positions[acc]}-${id}`
|
||||||
selObj = document.getElementById(stringSelectorId)
|
selObj = document.getElementById(stringSelectorId)
|
||||||
selObj.value = el[positions[acc]]
|
selObj.value = el[positions[acc]]
|
||||||
}
|
}
|
||||||
breakToSubmissions = true
|
breakToSubmissions = true
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function copy() {
|
function copy() {
|
||||||
|
|
||||||
ident = document.getElementById("ident-field").innerHTML
|
ident = document.getElementById("ident-field").innerHTML
|
||||||
path = "/role-submission?id="
|
path = "/role-submission?id="
|
||||||
copyText = window.location.protocol + window.location.hostname + path + ident
|
copyText = window.location.protocol + window.location.hostname + path + ident
|
||||||
|
|
||||||
navigator.clipboard.writeText(copyText)
|
navigator.clipboard.writeText(copyText)
|
||||||
document.getElementById("copyLink").innerHTML = "Copied!"
|
document.getElementById("copyLink").innerHTML = "Copied!"
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.getElementById("copyLink").innerHTML = "Copy Submission Link" }, 500);
|
document.getElementById("copyLink").innerHTML = "Copy Submission Link" }, 500);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,7 +259,7 @@ fastPosFields.forEach(el => el.addEventListener('input', fastPosChangedFunc));
|
|||||||
|
|
||||||
fastposSubmission = document.getElementById("fastpos-submission")
|
fastposSubmission = document.getElementById("fastpos-submission")
|
||||||
if(fastposSubmission){
|
if(fastposSubmission){
|
||||||
fastposSubmission.addEventListener("input", fastPosChangedFunc)
|
fastposSubmission.addEventListener("input", fastPosChangedFunc)
|
||||||
fastposSubmission.addEventListener("focus", fastPosChangedFunc)
|
fastposSubmission.addEventListener("focus", fastPosChangedFunc)
|
||||||
}
|
}
|
||||||
setInterval(queryForPlayerData(), 3000)
|
setInterval(queryForPlayerData(), 3000)
|
||||||
|
|||||||
Reference in New Issue
Block a user