diff --git a/object.js b/object.js index 5e0c177..e95501e 100644 --- a/object.js +++ b/object.js @@ -109,11 +109,13 @@ module.exports.load_colors = (inp,cook,res)=>{ module.exports.save_grouped = (inp,cook,res)=>{ try { db.sv("objects","group_obj",inp["json"],"id",inp["id"],()=>{ - let img = imageDataURI.decode(inp["data"]); - if (!fs.existsSync(`public/img/object/${inp["name"]}`)){fs.mkdirSync(`public/img/object/${inp["name"]}`);} - fs.writeFile(`public/img/object/${inp["name"]}/main.${img.imageType.split("/").at(-1)}`, img.dataBuffer,()=>{ - res.send({body:"good"}) - }); + db.sv("objects","cost",inp["cost"],"id",inp["id"],()=>{ + let img = imageDataURI.decode(inp["data"]); + if (!fs.existsSync(`public/img/object/${inp["name"]}`)){fs.mkdirSync(`public/img/object/${inp["name"]}`);} + fs.writeFile(`public/img/object/${inp["name"]}/main.${img.imageType.split("/").at(-1)}`, img.dataBuffer,()=>{ + res.send({body:"good"}) + }); + },true) },true) } catch (error) { func.log("backend object creating error - "+error); diff --git a/public/lib/fn.js b/public/lib/fn.js index f735a5d..c0173ca 100644 --- a/public/lib/fn.js +++ b/public/lib/fn.js @@ -302,7 +302,7 @@ async function removeImageBackground(image) { } ctx.putImageData(imageData, 0, 0); - return canvas.toDataURL(`image/png`); + return canvas.toDataURL(`image/jpg`); } function downloadImg(url, filename) { diff --git a/public/lib/inter.js b/public/lib/inter.js index 3e69ca6..de72183 100644 --- a/public/lib/inter.js +++ b/public/lib/inter.js @@ -1,6 +1,6 @@ window.dragMoveListener = dragMoveListener; let root = document.getElementById("drags"); -let objs = { height:"2",width:"4",color:"#FFFFFF"}; +let objs = { height:"2",width:"3",color:"#FFFFFF"}; let objs_store = {}; let proj_from = "cloud"; let cur_obj; @@ -19,7 +19,18 @@ function create(clas,x,y,color = null,id,size,layer = 0){ clas.forEach(cl => { obj.classList.add(cl); }); - get_obj(main_clas,(db_data)=>{ + if(objs_store[main_clas] == null){ + load_objs(()=>{ + make_obj(objs_store[main_clas]) + }); + } + else{ + make_obj(objs_store[main_clas]) + } + // get_obj(main_clas,(db_data)=>{ + + // }) + function make_obj(db_data) { // console.log(db_data); // console.log(db_data); // db_data.forEach(db_data => { @@ -60,7 +71,7 @@ function create(clas,x,y,color = null,id,size,layer = 0){ } } calc_total(); - }) + } obj.setAttribute("decoding","async"); obj.setAttribute("loading","lazy"); if(id != "none"){obj.setAttribute("onclick",`obj_click("${id}")`);} diff --git a/public/lib/inter_group_object.js b/public/lib/inter_group_object.js index 12fcde5..165b82b 100644 --- a/public/lib/inter_group_object.js +++ b/public/lib/inter_group_object.js @@ -1,6 +1,6 @@ window.dragMoveListener = dragMoveListener; let root = document.getElementById("drags"); -let objs = { height:"2",width:"4",color:"#FFFFFF"}; +let objs = { height:"2",width:"2",color:"#ffffff",total:0}; let objs_store = {}; let proj_from = "cloud"; let cur_obj; @@ -19,7 +19,18 @@ function create(clas,x,y,color = null,id,size,layer = 0){ clas.forEach(cl => { obj.classList.add(cl); }); - get_obj(main_clas,(db_data)=>{ + if(objs_store[main_clas] == null){ + load_objs(()=>{ + make_obj(objs_store[main_clas]) + }); + } + else{ + make_obj(objs_store[main_clas]) + } + // get_obj(main_clas,(db_data)=>{ + + // }) + function make_obj(db_data) { // console.log(db_data); // console.log(db_data); // db_data.forEach(db_data => { @@ -60,7 +71,7 @@ function create(clas,x,y,color = null,id,size,layer = 0){ } } calc_total(); - }) + } obj.setAttribute("decoding","async"); obj.setAttribute("loading","lazy"); if(id != "none"){obj.setAttribute("onclick",`obj_click("${id}")`);} @@ -219,7 +230,10 @@ function load(objss){ } if (keys == "color"){ + console.log(values); + document.getElementById("trans_checkbox").checked = (values == "#ffffff")? true:false; document.getElementById("wall").style.backgroundColor = values; + wall_color_change() } if (keys == Object.keys(objs).at(-1)){ proj_state = "loaded"; diff --git a/public/lib/inter_temp.js b/public/lib/inter_temp.js index c6f8092..98112e9 100644 --- a/public/lib/inter_temp.js +++ b/public/lib/inter_temp.js @@ -1,6 +1,6 @@ window.dragMoveListener = dragMoveListener; let root = document.getElementById("drags"); -let objs = { height:"2",width:"4",color:"#FFFFFF",total:0}; +let objs = { height:"2",width:"3",color:"#FFFFFF",total:0}; let objs_store = {}; let proj_from = "cloud"; let cur_obj; @@ -19,7 +19,18 @@ function create(clas,x,y,color = null,id,size,layer = 0){ clas.forEach(cl => { obj.classList.add(cl); }); - get_obj(main_clas,(db_data)=>{ + if(objs_store[main_clas] == null){ + load_objs(()=>{ + make_obj(objs_store[main_clas]) + }); + } + else{ + make_obj(objs_store[main_clas]) + } + // get_obj(main_clas,(db_data)=>{ + + // }) + function make_obj(db_data) { // console.log(db_data); // console.log(db_data); // db_data.forEach(db_data => { @@ -60,7 +71,7 @@ function create(clas,x,y,color = null,id,size,layer = 0){ } } calc_total(); - }) + } obj.setAttribute("decoding","async"); obj.setAttribute("loading","lazy"); if(id != "none"){obj.setAttribute("onclick",`obj_click("${id}")`);} diff --git a/views/admin/objects/group_object.ejs b/views/admin/objects/group_object.ejs index eba10a4..ce67a34 100644 --- a/views/admin/objects/group_object.ejs +++ b/views/admin/objects/group_object.ejs @@ -237,6 +237,9 @@ } +
+
+
save
@@ -288,6 +291,7 @@ - +
diff --git a/views/admin/objects/object_edit.ejs b/views/admin/objects/object_edit.ejs index d593e22..a829035 100644 --- a/views/admin/objects/object_edit.ejs +++ b/views/admin/objects/object_edit.ejs @@ -60,9 +60,11 @@ // load_groups(()=>{ // edit_get_objs(); // }); + const get_object_id = new URL(window.location).searchParams.get("object_id"); function set_edit(id){ + window.history.pushState({}, null, `${(new URL(window.location)).toString().split("?")[0]}?object_id=${id}`); let menu = document.getElementById(`object_${id}`); set_obj_edit_params(menu.getAttribute("src"), menu.getAttribute("name").split("~")[0], @@ -81,6 +83,7 @@ function edit_get_objs(by_name = false,callback){ document.getElementById("objs_in_group").innerHTML = ""; + let wait_msg_object_load = (get_object_id != null)? msg("загружаем прошлый объект",{type:"wait"}):null; if (obj_edit_type == "edit") set_obj_edit_params(); edit_load_objs((data)=>{ let wait_msg = msg("Загрузка объектов",{type:"wait"}) @@ -92,9 +95,9 @@ if(data.at(-1)["id"] == value["id"]){ msg_del(wait_msg.id); msg("Объекты загружены") - if(new URL(window.location).searchParams.get("object_id") != null){ - const get_object_id = new URL(window.location).searchParams.get("object_id"); - set_edit(new URL(window.location).searchParams.get("object_id")); + if(get_object_id != null && wait_msg_object_load != null){ + set_edit(get_object_id); + msg_del(wait_msg_object_load.id); } if(callback)callback(true); } diff --git a/views/project.ejs b/views/project.ejs index 509723b..b0d0f6a 100644 --- a/views/project.ejs +++ b/views/project.ejs @@ -349,8 +349,8 @@ y:7, x:2, width:width, - logging:false, - scale:5 + logging:false + // scale:0.99 }).then(canvas => { if(cost == true){ document.getElementById("cost_div").style.marginLeft = `0`;