diff --git a/index.js b/index.js index f86d510..14c84c7 100644 --- a/index.js +++ b/index.js @@ -201,6 +201,9 @@ app.get("/admin", (req,res) =>{ func.log("router admin page error - "+error); } }); +app.get("/home", (req,res) =>{ + res.render('home'); +}); // app.get("/admin/edit/:edit" , (req,res) =>{ // try { // let inp = req.body; diff --git a/object.js b/object.js index 218683c..d4f4916 100644 --- a/object.js +++ b/object.js @@ -4,7 +4,10 @@ const vars = require('./vars'); module.exports.loads = (inp,cook,res)=>{ try { - db.ggv("objects","`name`,`id`,`height`,`width`,`description`,`cost`,`gid`","gid",`${inp["gid"]}`,(odata)=>{ + let gin + if (typeof inp["gid"] == 'undefined' || inp["gid"] == null) gin = "1 OR 1=1" + else gin = inp["gid"] + db.ggv("objects","`name`,`id`,`height`,`width`,`description`,`cost`,`gid`","gid",`${gin}`,(odata)=>{ // func.log(odata); res.send({out:"good",body:odata}); }) diff --git a/project.js b/project.js index 78222ee..d89a539 100644 --- a/project.js +++ b/project.js @@ -1,5 +1,6 @@ const db = require('./db'); const func = require('./func'); +const moment = require("moment"); const vars = require('./vars'); module.exports.load = (inp,cook,res)=>{ @@ -70,8 +71,10 @@ module.exports.save = (inp,cook,res)=>{ if(projin == null){ // func.log("proj not in"); // func.log(pname,udata["id"],proj); + var date = moment().format('YYYY-MM-DD'); + var time = moment().format('hh:mm:ss'); func.log(`good boy ${udata["uuid"]} created project ${inp["name"]} from ${cook["sid"]}`); - db.nr("projects","`uid`,`name`,`body`,`img`",`'${udata["id"]}','${inp["name"]}','${inp["proj"]}','${inp["img"]}'`); + db.nr("projects","`uid`,`name`,`body`,`img`,creation_date",`'${udata["id"]}','${inp["name"]}','${inp["proj"]}','${inp["img"]}','${date+"T"+time}'`); res.send({out:"good"}); } else if (projin != null){ db.sv("projects","body",inp["proj"],"id",projin["id"],()=>{}); diff --git a/public/img/background/photo_2023-06-06_08-53-47 1.png b/public/img/background/photo_2023-06-06_08-53-47 1.png new file mode 100644 index 0000000..5bd7433 Binary files /dev/null and b/public/img/background/photo_2023-06-06_08-53-47 1.png differ diff --git a/public/img/icon/copy.svg b/public/img/icon/copy.svg new file mode 100644 index 0000000..09067ed --- /dev/null +++ b/public/img/icon/copy.svg @@ -0,0 +1,4 @@ + + + + diff --git a/public/img/icon/download.svg b/public/img/icon/download.svg new file mode 100644 index 0000000..9f9faaa --- /dev/null +++ b/public/img/icon/download.svg @@ -0,0 +1,4 @@ + + + + diff --git a/public/img/icon/edit.svg b/public/img/icon/edit.svg new file mode 100644 index 0000000..042867f --- /dev/null +++ b/public/img/icon/edit.svg @@ -0,0 +1,4 @@ + + + + diff --git a/public/img/icon/save.svg b/public/img/icon/save.svg new file mode 100644 index 0000000..8980757 --- /dev/null +++ b/public/img/icon/save.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/public/img/icon/trash.svg b/public/img/icon/trash.svg new file mode 100644 index 0000000..0ea5c98 --- /dev/null +++ b/public/img/icon/trash.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/public/img/new_proj.png b/public/img/new_proj.png new file mode 100644 index 0000000..0feed5c Binary files /dev/null and b/public/img/new_proj.png differ diff --git a/public/img/ok.svg b/public/img/ok.svg new file mode 100644 index 0000000..861cc74 --- /dev/null +++ b/public/img/ok.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/public/img/telegram.svg b/public/img/telegram.svg new file mode 100644 index 0000000..e61a279 --- /dev/null +++ b/public/img/telegram.svg @@ -0,0 +1,4 @@ + + + + diff --git a/public/img/vk.svg b/public/img/vk.svg new file mode 100644 index 0000000..cffcfdb --- /dev/null +++ b/public/img/vk.svg @@ -0,0 +1,4 @@ + + + + diff --git a/public/img/youtube.svg b/public/img/youtube.svg new file mode 100644 index 0000000..ff97238 --- /dev/null +++ b/public/img/youtube.svg @@ -0,0 +1,4 @@ + + + + diff --git a/public/img/Умничка лого с обводкой-02 1.png b/public/img/Умничка лого с обводкой-02 1.png new file mode 100644 index 0000000..75887e3 Binary files /dev/null and b/public/img/Умничка лого с обводкой-02 1.png differ diff --git a/public/lib/fn.js b/public/lib/fn.js index 678d282..1aba624 100644 --- a/public/lib/fn.js +++ b/public/lib/fn.js @@ -10,6 +10,12 @@ function get_from_uuid(callback){ }); } +function set_pos(obj,x,y){ + obj.style.transform = 'translate(' + x + 'px, ' + y + 'px)'; + obj.setAttribute('data-x', x) + obj.setAttribute('data-y', y) +} + function log_by_sid() { // const uuid = $.cookie("uuid"); // const sid = $.cookie("sid"); @@ -18,17 +24,17 @@ function log_by_sid() { // get_sid(location.hostname); get_sid(); } - // else if ($.cookie('sid') != null && $.cookie('uuid') != null){ - // $.post( "/sid_log") - // .done(function( res ) { - // console.log("ping"); - // if(res["out"] == "good"){ - // goto(res["url"]); - // } - // else if (res["out"] == "bad"){ - // clear_ck(false); - // } - // })} + else if ($.cookie('sid') != null && $.cookie('uuid') != null){ + $.post( "/sid_log") + .done(function( res ) { + // console.log("ping"); + if(res["out"] == "good"){ + goto(res["url"]); + } + else if (res["out"] == "bad"){ + clear_ck(false); + } + })} } function clear_ck(redirect = true){ @@ -115,7 +121,10 @@ function load_groups(callback){ // redirect function goto(url) { - location.href = url; + loading(); + setTimeout(()=>{ + location.href = url; + },1000) } function postForm(path, params, method) { diff --git a/public/lib/inter.js b/public/lib/inter.js index 700ebb0..645ccd0 100644 --- a/public/lib/inter.js +++ b/public/lib/inter.js @@ -65,25 +65,25 @@ function resize_drags(){ drag_start(); } -function wall_size_change(type,value){ +function wall_size_change(type,value = null){ let wall = document.getElementsByClassName("wall")[0]; let scroll; if(type != null && type == "width") { - if (value == null) scroll = document.getElementById("wall_width").value; - else scroll = value; + if (value == null) scroll = parseFloat(document.getElementById("wall_width").value); + else if (value != null) scroll = value; // document.getElementById("wall_width_value").innerHTML = (Math.ceil((parseFloat(scroll)+0.1)*10)/ 10); - document.getElementById("wall_width_value").innerHTML = `${scroll}м`; + // document.getElementById("wall_width_value").innerHTML = `${scroll}м`; // console.log(scroll); wall.style.width = `${scroll * 200}px`; objs["width"] = scroll; } if(type != null && type == "height") { - if (value == null) scroll = document.getElementById("wall_height").value; - else scroll = value; + if (value == null) scroll = parseFloat(document.getElementById("wall_height").value); + else if (value != null) scroll = value; // document.getElementById("wall_height_value").innerHTML = (Math.ceil((parseFloat(scroll)+0.1)*10)/ 10); - document.getElementById("wall_height_value").innerHTML = `${scroll}м`; - + // document.getElementById("wall_height_value").innerHTML = `${scroll}м`; + // console.log(scroll); wall.style.height = `${scroll * 200}px`; objs["height"] = scroll; @@ -129,6 +129,10 @@ function load(objss){ wall_size_change(keys,values); // document.getElementById("drags").style.left = $(".dropzone")[0].getBoundingClientRect().x; } + + if (keys == Object.keys(objs).at(-1)){ + loaded(); + } }); resize_drags(); calc_total() @@ -137,7 +141,7 @@ function load(objss){ function load_proj_cloud(){ proj_from = "cloud"; document.getElementById("drags").innerHTML = ""; - document.getElementById("top_panel_center").innerText = `загрузка ${proj_name} из облака`; + // document.getElementById("top_panel_center").innerText = `загрузка ${proj_name} из облака`; $.post( "/load_proj",{name:proj_name}) .done(function( res ) { if(res["out"] == "good"){ @@ -146,7 +150,7 @@ function load_proj_cloud(){ // console.log(JSON.parse(res["body"])); // $.cookie("objs",res["body"]); load(JSON.parse(res["body"])); - document.getElementById("top_panel_center").innerText = `${proj_name} (облако)`; + // document.getElementById("top_panel_center").innerText = `${proj_name} (облако)`; } else if(res["out"] == "bad proj"){ console.log("bad"); @@ -163,7 +167,7 @@ function load_proj_local(){ if(localStorage.getItem(proj_name) == null){ save_local() } - document.getElementById("top_panel_center").innerText = `${proj_name} (локальное хранилище)`; + // document.getElementById("top_panel_center").innerText = `${proj_name} (локальное хранилище)`; document.getElementById("drags").innerHTML = ""; load(JSON.parse(localStorage.getItem(proj_name))); } @@ -204,9 +208,10 @@ function save(callback,with_pic = true){ } } -function load_objs(callback){ - let select = document.getElementById("group_select"); - $.post( "/get_objs",{gid:select.options[select.selectedIndex].getAttribute("gid")}) +function load_objs(callback,group){ + // let select = document.getElementById("group_select"); + console.log(group); + $.post( "/get_objs",{gid:group}) .done(function( res ) { if(res["out"] == "good"){ // console.log(res["body"]); @@ -239,12 +244,6 @@ function load_obj(name,key,callback){ }); } -function set_pos(obj,x,y){ - obj.style.transform = 'translate(' + x + 'px, ' + y + 'px)'; - obj.setAttribute('data-x', x) - obj.setAttribute('data-y', y) -} - function dragMoveListener (event) { var drag = event.target var x = (parseFloat(drag.getAttribute('data-x')) || 0) + event.dx diff --git a/user.js b/user.js index a71ed74..66483ca 100644 --- a/user.js +++ b/user.js @@ -61,7 +61,7 @@ module.exports.clear_sid = (inp,cook,res)=>{ if(inp["sid"] != null){ // res.send({out:"good"}); db.dl("sids","sid",`'${inp["sid"]}'`,() =>{ - func.log("good boy "+inp["uuid"] + " logged out from "+inp["sid"]); + // func.log("good boy "+inp["uuid"] + " logged out from "+inp["sid"]); }); // db.ggv("sids","id","sid",`'${cook["sid"]}'`,(sids)=>{ // Object.entries(sids).forEach(([key,value])=>{ diff --git a/views/admin.ejs b/views/admin.ejs index a646cfd..8a72041 100644 --- a/views/admin.ejs +++ b/views/admin.ejs @@ -28,4 +28,9 @@ -<%- include('./static/end.ejs') %> \ No newline at end of file +<%- include('./static/end.ejs') %> + \ No newline at end of file diff --git a/views/header.ejs b/views/header.ejs index 09f7c25..f50cdce 100644 --- a/views/header.ejs +++ b/views/header.ejs @@ -1,3 +1,4 @@ +<%- include('./load.ejs') %>
-
-
-
+
+
+ + + + + + +
+
+ + + + +
+ \ No newline at end of file diff --git a/views/login.ejs b/views/login.ejs index 53242af..d89d56c 100644 --- a/views/login.ejs +++ b/views/login.ejs @@ -1,34 +1,145 @@ <%- include('./static/start.ejs',{name:'login',async: true}) %> +<%- include('./load.ejs') %> + -
-
- - -
-
- - -
- -
+
+
+ +
+ +
+ +
+ +
+
+
+
-<%- include('./static/end.ejs') %> \ No newline at end of file +<%- include('./static/end.ejs',{soc:true}) %> \ No newline at end of file diff --git a/views/old/project.ejs b/views/old/project.ejs new file mode 100644 index 0000000..40f7134 --- /dev/null +++ b/views/old/project.ejs @@ -0,0 +1,224 @@ +<%- include('./static/start.ejs',{name:proj_name,async:true}) %> +<%- include('./header.ejs') %> + + + + + +
+
+
+
+
+
+
+ + + + +
+
+
+
+
группа товаров
+ +
+

+
+
+ +
0
+
+ +
+
+
+ +
0
+
+ +
+
+
+ чёрная дыра +
+ +
+
+
+
+ +
цена проекта:
 руб.
+ + + +<%- include('./static/end.ejs') %> \ No newline at end of file diff --git a/views/project.ejs b/views/project.ejs index 2bd0882..1efad93 100644 --- a/views/project.ejs +++ b/views/project.ejs @@ -107,61 +107,144 @@ padding-bottom: 0px; margin-top: 50px; } + #group{ + display: none; + position: absolute; + padding: 0px; + margin: 0px; + width: 200px; + }

-
-
-
-
+ + +
-
-
-
-
группа товаров
- -
-

-
-
- -
0
-
- +
+
+ +
-
-
- -
0
-
- +
+ +
+
+ + +
+
-
- чёрная дыра +
-
+
-
цена проекта:
 руб.
+
 руб.
+ +
+
+ + +
    +
    +
    +
    copy
    +
    back
    +
    forw
    +
    del
    +
    +
    +
    +
    load
    +
    +
    +
    + -<%- include('./static/end.ejs') %> \ No newline at end of file +<%- include('./static/end.ejs',{soc:true}) %> \ No newline at end of file diff --git a/views/static/end.ejs b/views/static/end.ejs index 9a65b6f..b3fda01 100644 --- a/views/static/end.ejs +++ b/views/static/end.ejs @@ -1,3 +1,11 @@ +<% if (typeof soc !== 'undefined') {%> +
    + + + + +
    +<%}%> \ No newline at end of file diff --git a/views/static/start.ejs b/views/static/start.ejs index 05c181a..fc6eea6 100644 --- a/views/static/start.ejs +++ b/views/static/start.ejs @@ -23,13 +23,35 @@ }