sort lists in frontend, remove some print statements
This commit is contained in:
parent
018dbc525e
commit
9d2f442c30
3 changed files with 19 additions and 6 deletions
|
@ -238,10 +238,6 @@ func (self *GameTableServer) writeToDB(tableMsg *models.TableMessage) error {
|
||||||
rand.Read(r)
|
rand.Read(r)
|
||||||
for i, d := range r {
|
for i, d := range r {
|
||||||
r[i] = d%tableMsg.DiceRoll.Faces + 1
|
r[i] = d%tableMsg.DiceRoll.Faces + 1
|
||||||
fmt.Println(d)
|
|
||||||
}
|
|
||||||
for _, d := range r {
|
|
||||||
fmt.Println(d)
|
|
||||||
}
|
}
|
||||||
tableMsg.DiceRoll.Roll = r
|
tableMsg.DiceRoll.Roll = r
|
||||||
err := self.dbAdapter.InsertDiceRoll(key, *tableMsg.DiceRoll)
|
err := self.dbAdapter.InsertDiceRoll(key, *tableMsg.DiceRoll)
|
||||||
|
|
|
@ -49,7 +49,7 @@ async function rebindUi(name, pass) {
|
||||||
infoHtml += "<input id='map_img_upload' type='file'/><button onclick='uploadMapImg()'>Upload Map</button><br/>"
|
infoHtml += "<input id='map_img_upload' type='file'/><button onclick='uploadMapImg()'>Upload Map</button><br/>"
|
||||||
if (mapImgs.ok) {
|
if (mapImgs.ok) {
|
||||||
infoHtml += "<label>Available Maps</label>";
|
infoHtml += "<label>Available Maps</label>";
|
||||||
const imgs = await mapImgs.json();
|
const imgs = (await mapImgs.json()).sort();
|
||||||
infoHtml += "<ul class='two_btn_list'>";
|
infoHtml += "<ul class='two_btn_list'>";
|
||||||
for (const i of imgs) {
|
for (const i of imgs) {
|
||||||
const parts = i.split("/");
|
const parts = i.split("/");
|
||||||
|
@ -64,7 +64,7 @@ async function rebindUi(name, pass) {
|
||||||
let tokenListHTML = "<input id='token_img_upload' type='file'/><button onclick='uploadTokenImg()'>Upload Sprite</button><br/>";
|
let tokenListHTML = "<input id='token_img_upload' type='file'/><button onclick='uploadTokenImg()'>Upload Sprite</button><br/>";
|
||||||
if (tokenImgs.ok) {
|
if (tokenImgs.ok) {
|
||||||
tokenListHTML += "<label>Available Sprites</label>";
|
tokenListHTML += "<label>Available Sprites</label>";
|
||||||
const tokens = await tokenImgs.json();
|
const tokens = (await tokenImgs.json()).sort();
|
||||||
tokenListHTML += "<ul class='single_btn_list'>";
|
tokenListHTML += "<ul class='single_btn_list'>";
|
||||||
for (const t of tokens) {
|
for (const t of tokens) {
|
||||||
const parts = t.split("/");
|
const parts = t.split("/");
|
||||||
|
@ -89,6 +89,7 @@ async function rebindUi(name, pass) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillSpriteDropdown(tokens) {
|
function fillSpriteDropdown(tokens) {
|
||||||
|
tokens = tokens.sort();
|
||||||
let options = "<option value=''>select</option>";
|
let options = "<option value=''>select</option>";
|
||||||
for (const t of tokens) {
|
for (const t of tokens) {
|
||||||
const parts = t.split("/");
|
const parts = t.split("/");
|
||||||
|
@ -401,6 +402,14 @@ async function getTables() {
|
||||||
});
|
});
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
const tableList = await res.json();
|
const tableList = await res.json();
|
||||||
|
tableList.sort((a,b)=>{
|
||||||
|
if (a.name < b.name) {
|
||||||
|
return -1;
|
||||||
|
} else if (a.name > b.name) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
let tableListHTML = "<ul>\n";
|
let tableListHTML = "<ul>\n";
|
||||||
for (const t of tableList) {
|
for (const t of tableList) {
|
||||||
tableListHTML += `<li><a href="#" onclick="rebindUi('${t.name}','${t.passcode}');return false;">${t.name}</a></li>\n`
|
tableListHTML += `<li><a href="#" onclick="rebindUi('${t.name}','${t.passcode}');return false;">${t.name}</a></li>\n`
|
||||||
|
|
|
@ -59,6 +59,14 @@ function processTokens(tokenChanges) {
|
||||||
if (t.x != null && t.y != null) {
|
if (t.x != null && t.y != null) {
|
||||||
const self = NewToken(t);
|
const self = NewToken(t);
|
||||||
tokens.push(self);
|
tokens.push(self);
|
||||||
|
tokens.sort((a,b)=>{
|
||||||
|
if (a.t.name < b.t.name) {
|
||||||
|
return -1;
|
||||||
|
} else if (a.t.name > b.t.name) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
if (t.active) {
|
if (t.active) {
|
||||||
self.m.addTo(map);
|
self.m.addTo(map);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue