correção de xss e mais uma porrada coisas '-'
This commit is contained in:
Binary file not shown.
@@ -11,29 +11,45 @@ type Table struct {
|
|||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type plyInv struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
ItemName string `json:"itemname"`
|
||||||
|
ItemQuantidade int `json:"itemquantidade"`
|
||||||
|
ItemPeso int `json:"itempeso"`
|
||||||
|
}
|
||||||
|
type plyPwr struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Desc string `json:"desc"`
|
||||||
|
}
|
||||||
|
|
||||||
type logEntry struct {
|
type logEntry struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Log string `json:"log"`
|
Log string `json:"log"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type resp_json struct {
|
type resp_json struct {
|
||||||
Status string `json:"Status"`
|
Status string `json:"Status"`
|
||||||
Message string `json:"Message,omitempty"`
|
Message string `json:"Message,omitempty"`
|
||||||
Logs []logEntry `json:"Logs,omitempty"`
|
Logs []logEntry `json:"Logs,omitempty"`
|
||||||
Foto string `json:"Foto,omitempty"`
|
InvPeso int `json:"invPeso,omitempty"`
|
||||||
PlayerName string `json:"PlayerName,omitempty"`
|
InvItems []plyInv `json:"InvItems,omitempty"`
|
||||||
Conhecimento *int64 `json:"Conhecimento,omitempty"`
|
InvPws []plyPwr `json:"InvPws,omitempty"`
|
||||||
Level *int64 `json:"Level,omitempty"`
|
Foto string `json:"Foto,omitempty"`
|
||||||
Idade *int64 `json:"Idade,omitempty"`
|
PlayerName string `json:"PlayerName,omitempty"`
|
||||||
Altura *float64 `json:"Altura,omitempty"`
|
Conhecimento *int64 `json:"Conhecimento,omitempty"`
|
||||||
Vida string `json:"Vida,omitempty"`
|
Level *int64 `json:"Level,omitempty"`
|
||||||
Destresa *int64 `json:"Destresa,omitempty"`
|
Idade *int64 `json:"Idade,omitempty"`
|
||||||
Inteligencia *int64 `json:"Inteligencia,omitempty"`
|
Altura *float64 `json:"Altura,omitempty"`
|
||||||
Força *int64 `json:"Força,omitempty"`
|
Vida string `json:"Vida,omitempty"`
|
||||||
Constituição *int64 `json:"Constituição,omitempty"`
|
VidaPorcentagem *float64 `json:"VidaPorcentagem,omitempty"`
|
||||||
Cárisma *int64 `json:"Cárisma,omitempty"`
|
Destresa *int64 `json:"Destresa,omitempty"`
|
||||||
Inventario *int64 `json:"Inventario,omitempty"`
|
Inteligencia *int64 `json:"Inteligencia,omitempty"`
|
||||||
Descrição string `json:"Descrição,omitempty"`
|
Força *int64 `json:"Força,omitempty"`
|
||||||
|
Constituição *int64 `json:"Constituição,omitempty"`
|
||||||
|
Cárisma *int64 `json:"Cárisma,omitempty"`
|
||||||
|
Inventario *int64 `json:"Inventario,omitempty"`
|
||||||
|
Descrição string `json:"Descrição,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ func main() {
|
|||||||
e.POST("login", login, timeoutMiddleware, rateLimit)
|
e.POST("login", login, timeoutMiddleware, rateLimit)
|
||||||
e.GET("login", badreq)
|
e.GET("login", badreq)
|
||||||
e.GET("player", player_data)
|
e.GET("player", player_data)
|
||||||
|
e.GET("player/inv", inv_get)
|
||||||
e.POST("player/update", player_updateInputs)
|
e.POST("player/update", player_updateInputs)
|
||||||
e.PATCH("player/:atb/:updown", player_update)
|
e.PATCH("player/:atb/:updown", player_update)
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ func registrar(c echo.Context) error {
|
|||||||
}
|
}
|
||||||
log.Printf("tabela invPower_%s foi criada.\n", player)
|
log.Printf("tabela invPower_%s foi criada.\n", player)
|
||||||
|
|
||||||
query = fmt.Sprintf(`CREATE TABLE inv_%s (id INT NOT NULL , item_nome VARCHAR(30) NOT NULL , quantidade INT NOT NULL DEFAULT '1' , item_peso INT NOT NULL DEFAULT '1' , item_durabilit BOOLEAN NOT NULL DEFAULT FALSE ) ENGINE = InnoDB;`, player)
|
query = fmt.Sprintf(`CREATE TABLE inv_%s (id INT NOT NULL AUTO_INCREMENT, item_nome VARCHAR(30) NOT NULL , quantidade INT NOT NULL DEFAULT '1' , item_peso INT NOT NULL DEFAULT '1' , item_durabilit BOOLEAN NOT NULL DEFAULT FALSE ) ENGINE = InnoDB;`, player)
|
||||||
newInv, err := db.Query(query)
|
newInv, err := db.Query(query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, resp_json{
|
return c.JSON(http.StatusInternalServerError, resp_json{
|
||||||
@@ -322,22 +322,24 @@ func player_data(c echo.Context) error {
|
|||||||
err = db.QueryRow("SELECT foto, nome, conhecimento, level, idade, altura, vida, vida_maxima, destresa, inteligencia, força, constituição, cárisma, inventario, descrição FROM players WHERE id=? LIMIT 1;", userSession["user_id"]).Scan(&foto, &playername, &conhecimento, &level, &idade, &altura, &vd, &vdm, &destresa, &inteligencia, &força, &constituição, &cárisma, &inventario, &descrição)
|
err = db.QueryRow("SELECT foto, nome, conhecimento, level, idade, altura, vida, vida_maxima, destresa, inteligencia, força, constituição, cárisma, inventario, descrição FROM players WHERE id=? LIMIT 1;", userSession["user_id"]).Scan(&foto, &playername, &conhecimento, &level, &idade, &altura, &vd, &vdm, &destresa, &inteligencia, &força, &constituição, &cárisma, &inventario, &descrição)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
vida = fmt.Sprintf("%v/%v", vd, vdm)
|
vida = fmt.Sprintf("%v/%v", vd, vdm)
|
||||||
|
porcentagem := (float64(vd) / float64(vdm)) * 100
|
||||||
return c.JSON(http.StatusOK, resp_json{
|
return c.JSON(http.StatusOK, resp_json{
|
||||||
Status: "Success",
|
Status: "Success",
|
||||||
Foto: foto,
|
Foto: foto,
|
||||||
PlayerName: playername,
|
PlayerName: playername,
|
||||||
Conhecimento: &conhecimento,
|
Conhecimento: &conhecimento,
|
||||||
Level: &level,
|
Level: &level,
|
||||||
Idade: &idade,
|
Idade: &idade,
|
||||||
Altura: &altura,
|
Altura: &altura,
|
||||||
Vida: vida,
|
Vida: vida,
|
||||||
Destresa: &destresa,
|
VidaPorcentagem: &porcentagem,
|
||||||
Inteligencia: &inteligencia,
|
Destresa: &destresa,
|
||||||
Força: &força,
|
Inteligencia: &inteligencia,
|
||||||
Constituição: &constituição,
|
Força: &força,
|
||||||
Cárisma: &cárisma,
|
Constituição: &constituição,
|
||||||
Inventario: &inventario,
|
Cárisma: &cárisma,
|
||||||
Descrição: descrição,
|
Inventario: &inventario,
|
||||||
|
Descrição: descrição,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return c.JSON(http.StatusBadRequest, resp_json{
|
return c.JSON(http.StatusBadRequest, resp_json{
|
||||||
@@ -419,6 +421,7 @@ func player_updateInputs(c echo.Context) error {
|
|||||||
nome := c.FormValue("nome")
|
nome := c.FormValue("nome")
|
||||||
altura := c.FormValue("altura")
|
altura := c.FormValue("altura")
|
||||||
inv := c.FormValue("inventario")
|
inv := c.FormValue("inventario")
|
||||||
|
lore := c.FormValue("lore")
|
||||||
|
|
||||||
if vida != "" {
|
if vida != "" {
|
||||||
_, err = db.Exec("UPDATE players SET vida=?, vida_maxima=? WHERE id=?;", vida, vida, userSession["user_id"])
|
_, err = db.Exec("UPDATE players SET vida=?, vida_maxima=? WHERE id=?;", vida, vida, userSession["user_id"])
|
||||||
@@ -468,6 +471,18 @@ func player_updateInputs(c echo.Context) error {
|
|||||||
lista = append(lista, "inventario")
|
lista = append(lista, "inventario")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if lore != "" {
|
||||||
|
_, err = db.Exec("UPDATE players SET descrição=? WHERE id=?;", lore, userSession["user_id"])
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
return c.JSON(http.StatusInternalServerError, resp_json{
|
||||||
|
Status: "Error",
|
||||||
|
Message: "algo deu errado ao alterar a sua historia.",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
lista = append(lista, "lore")
|
||||||
|
}
|
||||||
|
|
||||||
if len(lista) <= 0 {
|
if len(lista) <= 0 {
|
||||||
return c.JSON(http.StatusUnauthorized, resp_json{
|
return c.JSON(http.StatusUnauthorized, resp_json{
|
||||||
Status: "Error",
|
Status: "Error",
|
||||||
@@ -479,3 +494,56 @@ func player_updateInputs(c echo.Context) error {
|
|||||||
Message: fmt.Sprintf("você mudou as seguintes informaçôes: %s", lista),
|
Message: fmt.Sprintf("você mudou as seguintes informaçôes: %s", lista),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func inv_get(c echo.Context) error {
|
||||||
|
userSession, err := ValidSession(c)
|
||||||
|
if err != nil {
|
||||||
|
return c.JSON(http.StatusUnauthorized, resp_json{
|
||||||
|
Status: "Error",
|
||||||
|
Message: err.Error(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
row, err := db.Query(fmt.Sprintf("SELECT id, item_nome, quantidade, item_peso FROM inv_%s ORDER BY id DESC;", userSession["playerName"]))
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
log.Println("Erro ao consultar inventario do inventario.")
|
||||||
|
return c.JSON(http.StatusInternalServerError, resp_json{
|
||||||
|
Status: "Error",
|
||||||
|
Message: "Erro ao consultar inventario do inventario.",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
var peso_total int = 0
|
||||||
|
var lista []plyInv
|
||||||
|
|
||||||
|
for row.Next() {
|
||||||
|
var id int
|
||||||
|
var nome string
|
||||||
|
var quantidade int
|
||||||
|
var peso int
|
||||||
|
if err := row.Scan(&id, &nome, &quantidade, &peso); err != nil {
|
||||||
|
return c.JSON(http.StatusInternalServerError, resp_json{
|
||||||
|
Status: "Error",
|
||||||
|
Message: "algo deu errado ao inventario",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
lista = append(lista, plyInv{ID: id, ItemName: nome, ItemQuantidade: quantidade, ItemPeso: peso})
|
||||||
|
peso_total = peso_total + peso
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(lista, func(i, j int) bool {
|
||||||
|
return lista[i].ID < lista[j].ID
|
||||||
|
})
|
||||||
|
|
||||||
|
if len(lista) <= 0 {
|
||||||
|
return c.JSON(http.StatusNotFound, resp_json{
|
||||||
|
Status: "NoDB",
|
||||||
|
Message: "o Inventario ainda esta vazio",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return c.JSON(http.StatusOK, resp_json{
|
||||||
|
Status: "Success",
|
||||||
|
InvPeso: peso_total,
|
||||||
|
InvItems: lista,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,3 +31,16 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 1080px) {
|
||||||
|
#login_form {
|
||||||
|
width: 80%;
|
||||||
|
ul {
|
||||||
|
padding-top: 0;
|
||||||
|
justify-content: center;
|
||||||
|
li {
|
||||||
|
margin-top: 3vw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -40,3 +40,16 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 1080px) {
|
||||||
|
#register_form {
|
||||||
|
width: 80%;
|
||||||
|
ul {
|
||||||
|
padding-top: 0;
|
||||||
|
justify-content: center;
|
||||||
|
li {
|
||||||
|
margin-top: 3vw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -351,7 +351,12 @@
|
|||||||
#text_lore {
|
#text_lore {
|
||||||
ul {
|
ul {
|
||||||
position: relative;
|
position: relative;
|
||||||
#btn {
|
width: 100%;
|
||||||
|
min-height: 20dvw;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
a {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 1dvh;
|
top: 1dvh;
|
||||||
right: 1dvh;
|
right: 1dvh;
|
||||||
@@ -369,6 +374,35 @@
|
|||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
padding: 1vw;
|
padding: 1vw;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 45dvw;
|
||||||
|
}
|
||||||
|
textarea {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 45dvw;
|
||||||
|
resize: none;
|
||||||
|
border: none;
|
||||||
|
background-color: transparent;
|
||||||
|
font-family: arial;
|
||||||
|
font-size: 1.5em;
|
||||||
|
padding: 1vw;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
.lore_edit {
|
||||||
|
border: none;
|
||||||
|
margin: 1dvw 0 1dvw 0;
|
||||||
|
padding: 0.5dvh;
|
||||||
|
width: 99%;
|
||||||
|
background-color: var(--btncolor);
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
font-size: 2em;
|
||||||
|
border-radius: 1dvw;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: 0.3s;
|
||||||
|
}
|
||||||
|
.lore_edit:hover {
|
||||||
|
background-color: var(--lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -435,4 +469,15 @@
|
|||||||
width: 30%;
|
width: 30%;
|
||||||
transform: translateY(50px) translateX(-50px);
|
transform: translateY(50px) translateX(-50px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#box_2 {
|
||||||
|
#text_lore {
|
||||||
|
a {
|
||||||
|
height: 200dvw;
|
||||||
|
}
|
||||||
|
textarea {
|
||||||
|
height: 200dvw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -333,17 +333,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="inv">
|
<div id="inv">
|
||||||
<h1>Inventario</h1>
|
<h1>Inventario</h1>
|
||||||
<ul>
|
<ul></ul>
|
||||||
<li>
|
|
||||||
<label>item_name</label>
|
|
||||||
<label>quantidade</label>
|
|
||||||
<a id="DelBTN">
|
|
||||||
<span class="material-symbols-outlined">
|
|
||||||
close
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<hgroup>
|
<hgroup>
|
||||||
<input type="text" placeholder="item name" />
|
<input type="text" placeholder="item name" />
|
||||||
<select name="durabilite">
|
<select name="durabilite">
|
||||||
@@ -355,7 +345,7 @@
|
|||||||
<input type="number" placeholder="quantidade" max="100" />
|
<input type="number" placeholder="quantidade" max="100" />
|
||||||
<a id="btn">add</a>
|
<a id="btn">add</a>
|
||||||
<label>
|
<label>
|
||||||
<p>0</p>
|
<p id="invPA">0</p>
|
||||||
/
|
/
|
||||||
<p id="mip">0</p>
|
<p id="mip">0</p>
|
||||||
<a id="btn" class="editbtn inventario">
|
<a id="btn" class="editbtn inventario">
|
||||||
@@ -377,12 +367,20 @@
|
|||||||
<h1>Texto do Player</h1>
|
<h1>Texto do Player</h1>
|
||||||
<div id="text_lore">
|
<div id="text_lore">
|
||||||
<ul>
|
<ul>
|
||||||
<a id="btn">
|
<a id="btn" class="lore">
|
||||||
<span class="material-symbols-outlined btn-right">
|
<span class="material-symbols-outlined btn-right">
|
||||||
edit
|
edit
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<p id="lore"></p>
|
<p id="lore"></p>
|
||||||
|
<textarea id="lore_edit" style="display: none"></textarea>
|
||||||
|
<input
|
||||||
|
type="submit"
|
||||||
|
id="btn"
|
||||||
|
class="lore_edit"
|
||||||
|
style="display: none"
|
||||||
|
value="atualizar"
|
||||||
|
/>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,18 +1,25 @@
|
|||||||
let img;
|
let img;
|
||||||
let update;
|
let update;
|
||||||
|
let invUpdate;
|
||||||
|
|
||||||
|
function delitem(id) {
|
||||||
|
alert(id);
|
||||||
|
}
|
||||||
|
function useItem(id) {
|
||||||
|
alert(id);
|
||||||
|
}
|
||||||
|
|
||||||
function load_ficha() {
|
function load_ficha() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: window.api + "player",
|
url: window.api + "player",
|
||||||
type: "GET",
|
type: "GET",
|
||||||
xhrFields: {
|
xhrFields: { withCredentials: true },
|
||||||
withCredentials: true,
|
|
||||||
},
|
|
||||||
success: function (resp) {
|
success: function (resp) {
|
||||||
if (img === undefined) {
|
if (img === undefined) {
|
||||||
img = resp.Foto;
|
img = resp.Foto;
|
||||||
$("#hero").attr("src", `data:image/*;base64,${resp.Foto}`);
|
$("#hero").attr("src", `data:image/*;base64,${resp.Foto}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#vdp").text(resp.Vida);
|
$("#vdp").text(resp.Vida);
|
||||||
$("#nmp").text(resp.PlayerName);
|
$("#nmp").text(resp.PlayerName);
|
||||||
$("#lvp").text(resp.Level);
|
$("#lvp").text(resp.Level);
|
||||||
@@ -26,8 +33,13 @@ function load_ficha() {
|
|||||||
$("#cárisma").text(resp.Cárisma);
|
$("#cárisma").text(resp.Cárisma);
|
||||||
$("#mip").text(resp.Inventario);
|
$("#mip").text(resp.Inventario);
|
||||||
$("#lore").text(resp.Descrição);
|
$("#lore").text(resp.Descrição);
|
||||||
|
|
||||||
|
if ($("#lore_edit").attr("placeholder") !== resp.Descrição) {
|
||||||
|
$("#lore_edit").attr("placeholder", resp.Descrição);
|
||||||
|
$("#lore_edit").val(resp.Descrição);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: function (resp, status, jqXHR) {
|
error: function () {
|
||||||
window.location.href = "login.html";
|
window.location.href = "login.html";
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -37,21 +49,25 @@ function roll_load() {
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
url: window.api + "roll",
|
url: window.api + "roll",
|
||||||
type: "GET",
|
type: "GET",
|
||||||
xhrFields: {
|
xhrFields: { withCredentials: true },
|
||||||
withCredentials: true,
|
|
||||||
},
|
|
||||||
success: function (resp) {
|
success: function (resp) {
|
||||||
switch (update) {
|
switch (update) {
|
||||||
case undefined:
|
case undefined:
|
||||||
resp.Logs.forEach(function (item) {
|
resp.Logs.forEach(function (item) {
|
||||||
$("#log").append(`<li> <label>${item.log}</label></li>`);
|
const $li = $("<li>");
|
||||||
|
const $label = $("<label>").text(item.log);
|
||||||
|
$li.append($label);
|
||||||
|
$("#log").append($li);
|
||||||
update = item.id;
|
update = item.id;
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
resp.Logs.forEach(function (item) {
|
resp.Logs.forEach(function (item) {
|
||||||
if (item.id > update) {
|
if (item.id > update) {
|
||||||
$("#log").append(`<li> <label>${item.log}</label></li>`);
|
const $li = $("<li>");
|
||||||
|
const $label = $("<label>").text(item.log);
|
||||||
|
$li.append($label);
|
||||||
|
$("#log").append($li);
|
||||||
update = item.id;
|
update = item.id;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -59,12 +75,6 @@ function roll_load() {
|
|||||||
}
|
}
|
||||||
$("#log").scrollTop($("#log")[0].scrollHeight);
|
$("#log").scrollTop($("#log")[0].scrollHeight);
|
||||||
},
|
},
|
||||||
error: function (resp, status, jqXHR) {
|
|
||||||
/*msg(
|
|
||||||
resp.responseJSON?.Status || "Erro",
|
|
||||||
resp.responseJSON?.Message || "Algo deu errado.",
|
|
||||||
);*/
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +83,6 @@ function roll(d) {
|
|||||||
url: window.api + "roll",
|
url: window.api + "roll",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: { roll: d },
|
data: { roll: d },
|
||||||
|
|
||||||
xhrFields: { withCredentials: true },
|
xhrFields: { withCredentials: true },
|
||||||
success: function (resp) {
|
success: function (resp) {
|
||||||
msg(resp.Status, resp.Message);
|
msg(resp.Status, resp.Message);
|
||||||
@@ -81,7 +90,49 @@ function roll(d) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function invPlayer() {
|
||||||
|
$.ajax({
|
||||||
|
url: window.api + "player/inv",
|
||||||
|
type: "GET",
|
||||||
|
xhrFields: { withCredentials: true },
|
||||||
|
success: function (resp) {
|
||||||
|
const buildItem = function (item) {
|
||||||
|
const $li = $("<li>");
|
||||||
|
$li.append($("<label>").text(item.itemname));
|
||||||
|
$li.append($("<label>").text(`tem: ${item.itemquantidade}`));
|
||||||
|
$li.append($("<label>").text(`peso: ${item.itempeso}`));
|
||||||
|
|
||||||
|
const $delBtn = $("<a>")
|
||||||
|
.attr("id", "DelBTN")
|
||||||
|
.append(
|
||||||
|
$("<span>").addClass("material-symbols-outlined").text("close"),
|
||||||
|
);
|
||||||
|
|
||||||
|
$li.on("click", () => useItem(item.id));
|
||||||
|
$delBtn.on("click", (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
delitem(item.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
$li.append($delBtn);
|
||||||
|
return $li;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (invUpdate === undefined || resp.invPeso !== invUpdate) {
|
||||||
|
$("#inv ul").empty();
|
||||||
|
resp.InvItems.forEach((item) => {
|
||||||
|
$("#inv ul").append(buildItem(item));
|
||||||
|
});
|
||||||
|
invUpdate = resp.invPeso;
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#invPA").text(resp.invPeso);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
load_ficha();
|
load_ficha();
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$(".updown").click(function () {
|
$(".updown").click(function () {
|
||||||
const atb = $(this).data("atb");
|
const atb = $(this).data("atb");
|
||||||
@@ -90,10 +141,8 @@ $(document).ready(function () {
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
url: `${window.api}player/${atb}/${updown}`,
|
url: `${window.api}player/${atb}/${updown}`,
|
||||||
type: "PATCH",
|
type: "PATCH",
|
||||||
xhrFields: {
|
xhrFields: { withCredentials: true },
|
||||||
withCredentials: true,
|
error: function (resp) {
|
||||||
},
|
|
||||||
error: function (resp, status, jqXHR) {
|
|
||||||
msg(
|
msg(
|
||||||
resp.responseJSON?.Status || "Erro",
|
resp.responseJSON?.Status || "Erro",
|
||||||
resp.responseJSON?.Message || "Algo deu errado.",
|
resp.responseJSON?.Message || "Algo deu errado.",
|
||||||
@@ -105,5 +154,6 @@ $(document).ready(function () {
|
|||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
load_ficha();
|
load_ficha();
|
||||||
roll_load();
|
roll_load();
|
||||||
|
invPlayer();
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
var $inp;
|
var $inp;
|
||||||
|
|
||||||
|
let lore = false;
|
||||||
let cordX = 0;
|
let cordX = 0;
|
||||||
let cordY = 0;
|
let cordY = 0;
|
||||||
|
|
||||||
@@ -78,4 +79,34 @@ $(document).ready(function () {
|
|||||||
? editInput(reqbtn[1], cordX, cordY)
|
? editInput(reqbtn[1], cordX, cordY)
|
||||||
: msg("Error", "erro, ainda não foi definido a classe desse botão");
|
: msg("Error", "erro, ainda não foi definido a classe desse botão");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".lore").on("click", function (e) {
|
||||||
|
switch (lore) {
|
||||||
|
case false:
|
||||||
|
$(".lore span").text("close");
|
||||||
|
$("#lore").hide();
|
||||||
|
$("#lore_edit").show();
|
||||||
|
$(".lore_edit").css("display", "block");
|
||||||
|
lore = true;
|
||||||
|
break;
|
||||||
|
case true:
|
||||||
|
$(".lore span").text("edit");
|
||||||
|
$("#lore").show();
|
||||||
|
$("#lore_edit").hide();
|
||||||
|
$(".lore_edit").css("display", "none");
|
||||||
|
lore = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(".lore_edit").on("click", function (e) {
|
||||||
|
data_update("lore", $("#lore_edit").val()).then((result) => {
|
||||||
|
if (result) {
|
||||||
|
$(".lore span").text("edit");
|
||||||
|
$("#lore").show();
|
||||||
|
$("#lore_edit").hide();
|
||||||
|
$(".lore_edit").css("display", "none");
|
||||||
|
lore = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user