auxMsg is working

This commit is contained in:
Iris Lightshard 2023-05-12 22:33:14 -06:00
parent 42bb254d84
commit 7ad9d76f78
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
5 changed files with 36 additions and 18 deletions

View file

@ -232,10 +232,10 @@ func (self *GameTableServer) writeToDB(tableMsg models.TableMessage) error {
}
}
if tableMsg.AuxMsg != nil {
err := self.dbAdapter.SetAuxMessage(key, *tableMsg.AuxMsg)
if err != nil {
return err
}
err := self.dbAdapter.SetAuxMessage(key, *tableMsg.AuxMsg)
if err != nil {
return err
}
}
}
}

View file

@ -17,23 +17,22 @@ type DiceRoll struct {
Timestamp time.Time `json:"timestamp"`
}
type Token struct {
Id string `json:"id"`
Name string `json:"name"`
SpriteUri string `json:"spriteUrl"`
X *int `json:"x"`
Y *int `json:"y"`
X *int `json:"x"`
Y *int `json:"y"`
}
type Table struct {
Name string `json:"name"`
Passcode string `json:"passcode"`
MapImageUrl string `json:"mapImageUrl"`
MapImageUrl string `json:"mapImg"`
DiceRolls []DiceRoll `json:"diceRolls"`
Tokens []Token `json:"tokens"`
AvailableTokens []Token `json:"availableTokens"`
AuxMessage string `json:"auxMessage"`
AuxMessage string `json:"auxMsg"`
}
type TableMessage struct {

View file

@ -57,9 +57,10 @@
</select>
<input id="dice_note"><button id="dice_submit" onclick="rollDice()">Roll</button>
<div id="dice_log"></div>
<div id="aux"></div>
<div id="map"></div>
</main>
<div id="adminWrapper" style="display:none;">
<div id="adminWrapper" style="display:none;">
<div id="adminCtrl">
<button onclick="setTableCreateFormVisible(true)">New Table</button>
<form onsubmit="return false" id="createTableForm" style="display:none;">

View file

@ -39,13 +39,26 @@ function logDice(dice, many) {
}
}
function setAuxMsg(msg) {
const auxDiv = document.getElementById("aux");
if (auxDiv) {
console.log("eeee");
auxDiv.innerText = msg;
}
}
function makeUpToDate(table) {
if (table) {
if (table.diceRolls) {
logDice(table.diceRolls, true);
} else if (table.diceRoll) {
logDice(table.diceRoll, false);
}
if (table.mapImageUrl) {
setMapImg(table.mapImageUrl);
if (table.mapImg) {
setMapImg(table.mapImg);
}
if (table.auxMsg) {
setAuxMsg(table.auxMsg);
}
}
}
@ -101,13 +114,9 @@ function dial() {
table = data;
makeUpToDate(table);
} else {
if (data.diceRoll) {
logDice(data.diceRoll);
}
if (data.mapImageUrl) {
setMapImg(data.mapImageUrl);
}
makeUpToDate(data);
}
console.log(data);
});
}

View file

@ -77,4 +77,13 @@ button:hover {
#dice_log p:not(:last-child) {
border-bottom: solid 1px gray;
}
#aux {
display: block;
background: #fff;
color: #000;
height: auto;
width: auto;
border: solid 1px dimgray;
}