mirror of
https://github.com/FAUSheppy/open-web-leaderboard.git
synced 2025-12-06 07:01:36 +01:00
implement multiline input copy
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
positions = [ "Top", "Jungle", "Mid", "Support" , "Bottom" ]
|
||||
acceptedParser = [ "top", "jungle", "mid", "sup" , "bot", "adc", "support", "bottom" ]
|
||||
|
||||
function checkPlayer() {
|
||||
if(this.value == ""){
|
||||
@@ -77,7 +78,6 @@ function fastPosChanged() {
|
||||
|
||||
/* allow some basic shit */
|
||||
if(clean == "*" || clean == ""){
|
||||
console.log("lol")
|
||||
retVal = true
|
||||
}
|
||||
|
||||
@@ -180,6 +180,57 @@ function balance(){
|
||||
|
||||
}
|
||||
|
||||
function parseMultiline(){
|
||||
|
||||
var names = []
|
||||
var prioStrings = []
|
||||
|
||||
field = document.getElementById("multi-line-copy")
|
||||
lines = field.value.split("\n")
|
||||
lines.forEach(l => {
|
||||
|
||||
lowestIndex = 100
|
||||
|
||||
acceptedParser.forEach( p => {
|
||||
i = l.indexOf(" " + p)
|
||||
if(i > 3 && i < lowestIndex){
|
||||
lowestIndex = i
|
||||
}
|
||||
})
|
||||
|
||||
if(lowestIndex != 100){
|
||||
name = l.substring(0, lowestIndex)
|
||||
prioStr = l.substring(lowestIndex)
|
||||
names.push(name)
|
||||
prioStrings.push(prioStr)
|
||||
}
|
||||
})
|
||||
|
||||
sides = [ "left", "right"]
|
||||
count = 0
|
||||
sides.forEach(s => {
|
||||
for(i = 0; i<5; i++){
|
||||
|
||||
pObjField = document.getElementById("playername-" + s + "-" + i)
|
||||
prObjField = document.getElementById("check-" + s + "-fastpos-" + i)
|
||||
|
||||
if(count >= names.length){
|
||||
pObjField.value = ""
|
||||
prObjField.value = ""
|
||||
}else{
|
||||
pObjField.value = names[count]
|
||||
prObjField.value = prioStrings[count]
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
})
|
||||
|
||||
const focusEvent = new Event("focus")
|
||||
fastPosFields.forEach(el => el.dispatchEvent(focusEvent))
|
||||
balance()
|
||||
}
|
||||
|
||||
fastPosFields = document.getElementsByClassName("fastpos")
|
||||
playerNameFields = document.getElementsByClassName("pname")
|
||||
|
||||
|
||||
@@ -23,6 +23,15 @@
|
||||
|
||||
<hr>
|
||||
|
||||
<textarea type="text" id="multi-line-copy" rows="10"
|
||||
placeholder="Have everybody write their roles in the form of 'top > mid = sup = jungle >adc' in the chat and then copy it in here and hit 'Use Multiline Input' :)"
|
||||
class="form-control md-textarea"></textarea>
|
||||
<button type="button" class="mb-3 btn btn-secondary" onclick="parseMultiline()">
|
||||
Use Multiline Input..
|
||||
</button>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="row">
|
||||
{% for side in sides %}
|
||||
<div class="col-sm">
|
||||
|
||||
Reference in New Issue
Block a user