dynamic char delete + button/create form styling

1. enabled deletion of characters without page reload. now when a user deletes a character, the page will not auto-refresh, but they will be get a message from Chloe instructing them to pick another character to continue.

2. standardized all buttons to use menu_button class instead of individual ID stylings

3. adjusted create_form, making wider range inputs for mobile users.
- moved 'back button' to the bottom of the form next to delete/create/export
- changed the 'back' button on post-creation rm_info to look like a button

4. condensed redundant CSS where possible; removed unused CSS.

5. Fixed the problem of the nav auto-closing when a character is created or when using advanced editing window.

6. made the token counter load when a character is selected. previously it only showed up after edits were made.

7. found some problems with /createcharacter - if a character/PNG with the same name exists, the server won't make a new character, but it doesn't tell the user about the error.  I UI acts as if the character was created. I added some soft console.error messages for this, but couldn't figure out a way to make it give a proper error. probably because fs.existsSync doesn't have a callback.
This commit is contained in:
RossAsscends
2023-03-06 10:58:10 +09:00
parent 6793db967f
commit 2cd6739aaa
3 changed files with 370 additions and 554 deletions

View File

@@ -423,22 +423,24 @@ function charaFormatData(data){
}
app.post("/createcharacter", urlencodedParser, function(request, response){
if(!request.body) return response.sendStatus(400);
if (!fs.existsSync(charactersPath+request.body.ch_name+'.png')){
if(!fs.existsSync(chatsPath+request.body.ch_name) )fs.mkdirSync(chatsPath+request.body.ch_name);
//var sameNameChar = fs.existsSync(charactersPath+request.body.ch_name+'.png');
//if (sameNameChar == true) return response.sendStatus(500);
if(!request.body) return response.sendStatus(400);
console.log('/createcharacter -- looking for -- '+(charactersPath+request.body.ch_name+'.png'));
console.log('Does this file already exists? '+fs.existsSync(charactersPath+request.body.ch_name+'.png'));
if (!fs.existsSync(charactersPath+request.body.ch_name+'.png')){
if(!fs.existsSync(chatsPath+request.body.ch_name) )fs.mkdirSync(chatsPath+request.body.ch_name);
let filedata = request.file;
    //console.log(filedata.mimetype);
var fileType = ".png";
var img_file = "ai";
var img_path = "public/img/";
var char = charaFormatData(request.body);//{"name": request.body.ch_name, "description": request.body.description, "personality": request.body.personality, "first_mes": request.body.first_mes, "avatar": 'none', "chat": Date.now(), "last_mes": '', "mes_example": ''};
char = JSON.stringify(char);
    if(!filedata){
charaWrite('./public/img/fluffy.png', char, request.body.ch_name, response);
}else{
img_path = "./uploads/";
@@ -452,7 +454,9 @@ app.post("/createcharacter", urlencodedParser, function(request, response){
//console.log("The file was saved.");
}else{
console.error("Error: Cannot save file. A character with that name already exists.");
response.send("Error: A character with that name already exists.");
//response.send({error: true});
}
    //console.log(request.body);
    //response.send(request.body.ch_name);