loadGameWindow->ADD("Go Back Button",MenuComponent)(geom2d::rect<float>{{72,148},{48,12}},"Back",[](MenuFuncDatamenu){Menu::CloseMenu();returntrue;})END;
#ifdef __EMSCRIPTEN__
autoofflineCharacterTab=loadGameWindow->ADD("Offline Character Tab",MenuComponent)(geom2d::rect<float>{{-8,4},{102,16}},"Offline Characters",[](MenuFuncDatadata){
autoonlineCharacterTab=loadGameWindow->ADD("Online Character Tab",MenuComponent)(geom2d::rect<float>{{96,4},{102,16}},"Online Characters",[](MenuFuncDatadata){
description:"**"+req.body.username+"** "+(req.body.operation==="FINISH"?" has finished "+(req.body.finalcraft===true?"crafting ":"collecting ")+req.body.required+" __"+req.body.item_name+"__!":
req.body.operation==="INCREASE"?" has collected "+req.body.obtained+" / "+req.body.required+" __"+req.body.item_name+"__ (+"+(req.body.obtained-req.body.previous_amt)+")"
:" has set __"+req.body.item_name+"__ to "+req.body.obtained+" / "+req.body.required)+"\n\n[Sig Planner - Sig crafts all the things](http://projectdivar.com:3001)",
returndb.query("insert into audit_log(username,obtained,required,item_name,operation,date,previous_amt) values($1,$2,$3,$4,$5,$6,$7)",[req.body.username,req.body.obtained,req.body.required,req.body.item_name,req.body.operation==="FINISH"&&req.body.finalcraft===true?"FINISH_CRAFT":req.body.operation,req.body.last_modified,req.body.previous_amt])
db.query("update crafting_list set timer_start=$1,timer_end=$2 where id=$3 returning *",[req.body.timer_start,req.body.timer_end,req.body.id])
.then((data)=>{
itemIcon="https://xivapi.com"+data.rows[0].icon
returndb.query("update site_data set last_modified=$1",[req.body.last_modified])
})
.then((data)=>{
res.status(200).send("Yay!")
})
.catch((err)=>{
console.log(err.message)
res.status(500).send(err.message)
})
}else{
res.status(500).send("Invalid input!")
}
})
app.post('/setItem',async(req,res)=>{
awaitdb.query('select * from crafting_list where itemid=$1',[req.body.itemid])
.then((data)=>{
if(data.rows.length==0){
db.query('insert into crafting_list(itemid,name,obtained,required,icon) values($1,$2,$3,$4,$5)',[req.body.itemid,req.body.name,req.body.obtained,req.body.required,req.body.icon])
.then((data)=>{
res.status(200).send("Yay!")
})
.catch((err)=>{
res.status(500).send(err.message)
})
}else{
db.query('update crafting_list set required=$1 where itemid=$2',[Number(data.rows[0].required)+Number(req.body.required),req.body.itemid])
.then((data)=>{
res.status(200).send("Yayay!")
})
.catch((err)=>{
res.status(500).send(err.message)
})
}
})
})
app.post('/addItem',async(req,res)=>{
awaitdb.query('select * from crafting_list where itemid=$1',[req.body.itemid])
.then((data)=>{
if(data.rows.length>0){
db.query('update crafting_list set obtained=$1 where itemid=$2',[Math.min(data.rows[0].required,Number(data.rows[0].obtained)+Number(req.body.obtained)),req.body.itemid])
.then((data)=>{
res.status(200).send("AYAYA")
})
.catch((err)=>{
res.status(500).send(err.message)
})
}else{
res.status(200).send("Nothing to do!")
}
})
})
functionConvertIssues(str,repoURL){
str+=' '//Hack to fix issues with not finding a space after links.
name:"Issue #"+req.body.number+" opened by "+req.body?.issue?.user?.username,
icon_url:req.body.issue.user.avatar_url
},
color:11731199,
description:"**"+req.body.issue.title+":**\n\n"+ConvertIssues(ParseAttachments(ParseMentions(req.body.issue.body)),req.body.repository?.html_url)+"\n\n[Link to Issue]("+req.body.issue?.html_url+")",
},...embedItems];
embeds.push({embeds:embedItems});
}break;
case"reopened":{
embeds.push({
embeds:[{
author:{
name:"Issue #"+req.body.number+" re-opened by "+req.body.issue.user.username,
icon_url:req.body.issue.user.avatar_url
},
color:13789695,
description:"**"+req.body.issue.title+":**\n\n"+ConvertIssues(req.body.issue.body,req.body.repository?.html_url)+"\n\n[Link to Issue]("+req.body.issue?.html_url+")",
}]
});
}break;
case"assigned":{
varassignedList=""
for(assigneeofreq.body.issue.assignees){
if(assignedList.length==0){
assignedList+=assignee.username
}else{
assignedList+=","+assignee.username
}
}
embeds.push({
embeds:[{
author:{
name:"Assigned users to Issue #"+req.body.number,
icon_url:req.body.issue.user.avatar_url
},
color:50363,
description:"Assigned **"+assignedList+"** to Issue **"+req.body.issue.title+"**\n\n[Link to Issue]("+req.body.issue.html_url+")",
}]
});
}break;
case"label_updated":{
varlabelsList=""
for(labelofreq.body.issue.labels){
if(labelsList.length==0){
labelsList+="- **"+label.name+"**"
}else{
labelsList+="\n- **"+label.name+"**"
}
}
embeds.push({
embeds:[{
author:{
name:"Assigned labels to Issue #"+req.body.number,
icon_url:req.body.issue.user.avatar_url
},
color:365568,
description:"Labels set for Issue **"+req.body.issue.title+"**:\n"+labelsList+"\n\n[Link to Issue]("+req.body.issue.html_url+")",
}]
})
}break;
case"created":{
embeds.push({
embeds:[{
author:{
name:"Comment posted on Issue #"+req.body.issue.number,
icon_url:req.body.comment.user.avatar_url
},
color:11731199,
description:"__**"+req.body.issue.title+"**__\nCommented by **"+req.body.comment.user.username+":**\n"+ConvertIssues(ParseAttachments(ParseMentions(req.body.comment.body)),req.body.repository.html_url)+"\n\n[Link to Comment]("+req.body.comment.html_url+")",
}]
})
}break;
case"edited":{
if(req.body.comment){
embedItems=[{
author:{
name:"Comment edited on Issue #"+req.body.issue.number,
icon_url:req.body.comment.user.avatar_url
},
color:11731199,
description:"__**"+req.body.issue.title+"**__\nCommented by **"+req.body.comment.user.username+":**\n"+ConvertIssues(ParseAttachments(ParseMentions(req.body.comment.body)),req.body.repository.html_url)+"\n\n[Link to Comment]("+req.body.comment.html_url+")",
},...embedItems]
embeds.push({embeds:embedItems})
}else{
embedItems=[{
author:{
name:"Edit on Issue #"+req.body.issue.number,
icon_url:req.body.issue.user.avatar_url
},
color:11731199,
description:"__**"+req.body.issue.title+"**__\nEdited by **"+req.body.issue.user.username+":**\n"+ConvertIssues(ParseAttachments(ParseMentions(req.body.issue.body)),req.body.repository.html_url)+"\n\n[Link to Issue]("+req.body.issue.html_url+")",
},...embedItems]
embeds.push({embeds:embedItems});
}
}break;
case"deleted":{
embeds.push({
embeds:[{
author:{
name:"Comment deleted on Issue #"+req.body.issue.number,
icon_url:req.body.comment.user.avatar_url
},
color:11731199,
description:"__**"+req.body.issue.title+"**__\nCommented by **"+req.body.comment.user.username+":**\n~~"+ConvertIssues(req.body.comment.body,req.body.repository.html_url)+"~~\n\n[Link to Comment]("+req.body.comment.html_url+")",
}]
})
}break;
case"closed":{
embeds.push({
embeds:[{
author:{
name:"Issue #"+req.body.number+" closed by "+req.body.issue.user.username,
icon_url:req.body.issue.user.avatar_url
},
color:9502805,
description:"**"+req.body.issue.title+":**\n\n"+ConvertIssues(req.body.issue.body,req.body.repository.html_url)+"\n\n[Link to Issue]("+req.body.issue.html_url+")",
description:"**"+req.body.username+"** "+(req.body.operation==="FINISH"?" has finished "+(req.body.finalcraft===true?"crafting ":"collecting ")+req.body.required+" __"+req.body.item_name+"__!":
req.body.operation==="INCREASE"?" has collected "+req.body.obtained+" / "+req.body.required+" __"+req.body.item_name+"__ (+"+(req.body.obtained-req.body.previous_amt)+")"
:" has set __"+req.body.item_name+"__ to "+req.body.obtained+" / "+req.body.required)+"\n\n[Sig Planner - Sig crafts all the things](http://projectdivar.com:3001)",