some fixes
This commit is contained in:
parent
0b1b498b7d
commit
b8725f33af
3
db.js
3
db.js
|
@ -59,7 +59,8 @@ module.exports.gv = (table,key,value,callback) => {
|
|||
|
||||
// set_in
|
||||
module.exports.sv = (table,key,value,ekey,evalue,callback) => {
|
||||
logcon.query('UPDATE `'+table+'` SET `'+key+'` = "'+value+'" WHERE `'+ekey+'` = "'+evalue+'"', (err , res) => {
|
||||
logcon.query("UPDATE `"+table+"` SET `"+key+"` = '"+value+"' WHERE `"+ekey+"` = '"+evalue+"'", (err , res) => {
|
||||
// console.log("UPDATE `"+table+"` SET `"+key+"` = '"+value+"' WHERE `"+ekey+"` = '"+evalue+"'");
|
||||
if (err) {
|
||||
console.log("sql err");
|
||||
throw err;
|
||||
|
|
96
index.js
96
index.js
|
@ -9,6 +9,7 @@ const {
|
|||
} = require('express');
|
||||
const { escapeSelector } = require('jquery');
|
||||
const { name } = require('ejs');
|
||||
const { stringify } = require('uuid');
|
||||
const app = express();
|
||||
|
||||
// const {
|
||||
|
@ -41,7 +42,7 @@ app.post('/back_login', (req, res) => {
|
|||
db.gv("users","login",`'${ilogin}'`,(udata)=>{udata = udata[0];
|
||||
if(ipass == udata["pass"]){
|
||||
console.log(udata["uuid"]+" logged in by login & pass from "+cook["sid"]);
|
||||
res.cookie("uuid",udata["uuid"],{maxAge:1000000,path:"/;SameSite=Strict"});
|
||||
res.cookie("uuid",udata["uuid"],{maxAge:1000000,path:"/;SameSite=Lax"});
|
||||
|
||||
// db.sv("users","sids",sids += inp["sid"]+";","uuid",udata["uuid"],()=>{});
|
||||
db.nr("sids",'`sid`,`uid`',`'${cook["sid"]}','${udata["id"]}'`);
|
||||
|
@ -150,7 +151,7 @@ app.post("/get_sid" , (req,res) =>{
|
|||
let inp = req.body;
|
||||
let sid = func.get_uuid(inp["name"]);
|
||||
var week = 7 * 24 * 3600 * 1000;
|
||||
res.cookie("sid",sid,{maxAge:(week),path:"/;SameSite=Strict"});
|
||||
res.cookie("sid",sid,{maxAge:(week),path:"/;SameSite=Lax"});
|
||||
res.send({out:"good"});
|
||||
});
|
||||
|
||||
|
@ -159,12 +160,13 @@ app.post("/clear_sid" , (req,res) =>{
|
|||
let inp = req.body;
|
||||
let cook = req.cookies;
|
||||
|
||||
if(cook["uuid"] != null && cook["sid"] != null){
|
||||
res.send({out:"good"});
|
||||
db.dl("sids","sid",`'${cook["sid"]}'`,() =>{
|
||||
console.log(cook["uuid"] + "logged out from "+cook["sid"]);
|
||||
});
|
||||
// console.log(cook["uuid"],cook["sid"]);
|
||||
if(cook["sid"] != null){
|
||||
// res.send({out:"good"});
|
||||
console.log(cook["uuid"] + " logged out from "+cook["sid"]);
|
||||
db.dl("sids","sid",`'${cook["sid"]}'`,() =>{});
|
||||
}
|
||||
res.send({out:"good"});
|
||||
});
|
||||
|
||||
app.post("/get_cr_uuid", (req,res) => {
|
||||
|
@ -190,6 +192,75 @@ app.post("/get_cr_uuid", (req,res) => {
|
|||
}
|
||||
})
|
||||
|
||||
app.post("/save_proj", (req,res) => {
|
||||
let inp = req.body;
|
||||
let cook = req.cookies;
|
||||
let proj = inp["proj"];
|
||||
let pname = inp["name"];
|
||||
db.gv("users","uuid",`'${cook["uuid"]}'`, (udata)=>{ udata = udata[0]
|
||||
db.gv("projects","uid",udata["id"],(pdata)=>{
|
||||
let projin = null;
|
||||
// console.log(pdata);
|
||||
pdata.forEach(projt => {
|
||||
if(projt["name"] == pname && projt["uid"] == udata["id"]){
|
||||
projin = projt;
|
||||
return;
|
||||
}
|
||||
})
|
||||
if(projin == null){
|
||||
// console.log("proj not in");
|
||||
// console.log(pname,udata["id"],proj);
|
||||
db.nr("projects","`uid`,`name`,`body`",`'${udata["id"]}','${pname}','${proj}'`);
|
||||
} else if (projin != null){
|
||||
db.sv("projects","body",proj,"id",projin["id"],()=>{});
|
||||
// console.log("proj in");
|
||||
}
|
||||
console.log(`${udata["uuid"]} saved project ${projin["name"]} from ${cook["sid"]}`);
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
app.post("/load_proj", (req,res) => {
|
||||
let inp = req.body;
|
||||
let cook = req.cookies;
|
||||
if(cook['sid'] != null && cook['uuid'] != null){
|
||||
db.gv("users","uuid",`'${cook["uuid"]}'`,(udata)=>{ udata = udata[0];
|
||||
db.gv("projects","uid",udata["id"],(pdata)=>{
|
||||
let projt = null;
|
||||
// console.log(inp["name"]);
|
||||
pdata.forEach(proj => {
|
||||
if(proj["name"] == inp["name"]){
|
||||
projt = proj;
|
||||
}
|
||||
})
|
||||
if (projt != null){
|
||||
console.log(`${udata["uuid"]} loaded project ${projt["name"]} from ${cook["sid"]}`);
|
||||
res.send({out:"good",body:projt["body"]});
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
else{
|
||||
res.send({out:"bad"});
|
||||
}
|
||||
})
|
||||
|
||||
app.post("/get_projs", (req,res) => {
|
||||
let inp = req.body;
|
||||
let cook = req.cookies;
|
||||
if(cook['sid'] != null && cook['uuid'] != null){
|
||||
db.gv("users","uuid",`'${cook["uuid"]}'`,(udata)=>{ udata = udata[0];
|
||||
db.gv("projects","uid",udata["id"],(pdata)=>{
|
||||
res.send({out:"good",body:pdata});
|
||||
})
|
||||
})
|
||||
}
|
||||
else{
|
||||
res.send({out:"bad"});
|
||||
}
|
||||
})
|
||||
|
||||
// app.post("/set_cr_uuid", (req,res) => {
|
||||
// let inp = req.body;
|
||||
// if(inp["uuid"] != null && inp["sid"] != null){
|
||||
|
@ -230,6 +301,11 @@ app.get("/reg" , (req,res) =>{
|
|||
res.render('reg');
|
||||
})
|
||||
|
||||
app.get("/proj/:name" , (req,res) =>{
|
||||
// res.cookie
|
||||
res.render('project',{proj_name:req.params["name"]});
|
||||
})
|
||||
|
||||
app.get("/login" , (req,res) =>{
|
||||
res.render('login');
|
||||
})
|
||||
|
@ -238,6 +314,10 @@ app.get("/main", (req,res) =>{
|
|||
res.render('main');
|
||||
});
|
||||
|
||||
// app.get("/main/:id", (req,res) =>{
|
||||
// res.render('main');
|
||||
// });
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
if(req.cookies["uuid"] != null){
|
||||
res.redirect('main');
|
||||
|
@ -248,7 +328,7 @@ app.get('/', (req, res) => {
|
|||
});
|
||||
|
||||
app.all('*', (req, res) => {
|
||||
res.status(404).send('<h1>404! Page not</h1>');
|
||||
res.status(404).send('<h1>404! Page not</h1> <br> <a href="/">go to main page</a>');
|
||||
});
|
||||
|
||||
app.listen(process.env.PORT || 3002, () => console.log("started"));
|
106
public/lib/fn.js
106
public/lib/fn.js
|
@ -23,28 +23,28 @@ function log(nlogin,npass){
|
|||
});
|
||||
}
|
||||
|
||||
// function get_from_uuid(callback){
|
||||
// const uid = $.cookie("uuid");
|
||||
// const sid = $.cookie("sid");
|
||||
// $.post( "/get_cr_uuid", { uuid:uid,sid:sid })
|
||||
// .done(function( res ) {
|
||||
// if (res["out"] == "good"){
|
||||
// callback(res["body"])
|
||||
// }
|
||||
// else if (res["out"] == bad){
|
||||
// if (res["body"] == "expired"){
|
||||
// clear_ck();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
function get_from_uuid(callback){
|
||||
const uid = $.cookie("uuid");
|
||||
const sid = $.cookie("sid");
|
||||
$.post( "/get_cr_uuid", { uuid:uid,sid:sid })
|
||||
.done(function( res ) {
|
||||
if (res["out"] == "good"){
|
||||
callback(res["body"])
|
||||
}
|
||||
else if (res["out"] == bad){
|
||||
if (res["body"] == "expired"){
|
||||
clear_ck();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function get_from_uuid(callback){
|
||||
const uid = $.cookie("uuid");
|
||||
const sid = $.cookie("sid");
|
||||
$.post( "/get_cr_uuid", { uuid:uid,sid:sid })
|
||||
.done(function( res ) {
|
||||
if (res["out"] == "good"){
|
||||
console.log("good");
|
||||
// console.log("good");
|
||||
callback(res["body"])
|
||||
}
|
||||
else if (res["out"] == bad){
|
||||
|
@ -59,10 +59,10 @@ function log_by_sid() {
|
|||
// const uuid = $.cookie("uuid");
|
||||
// const sid = $.cookie("sid");
|
||||
// console.log("log");
|
||||
if($.cookie('sid') == null){
|
||||
if($.cookie('uuid') == null && $.cookie('sid') == null){
|
||||
// get_sid(location.hostname);
|
||||
clear_ck(false);
|
||||
}else{
|
||||
get_sid(location.hostname);
|
||||
}else if ($.cookie('sid') != null && $.cookie('uuid') != null){
|
||||
$.post( "/sid_log")
|
||||
.done(function( res ) {
|
||||
console.log("ping");
|
||||
|
@ -70,57 +70,59 @@ function log_by_sid() {
|
|||
goto(res["url"]);
|
||||
}
|
||||
else if (res["out"] == "bad"){
|
||||
clear_ck();
|
||||
clear_ck(false);
|
||||
}
|
||||
})}
|
||||
}
|
||||
|
||||
function clear_ck(redirect = true){
|
||||
console.log("sid");
|
||||
$.cookie("uuid",null);
|
||||
$.cookie("sid",null);
|
||||
get_sid(location.hostname);
|
||||
if (redirect) goto("login");
|
||||
$.post( "/clear_sid")
|
||||
.done(function( res ) {
|
||||
console.log("sid");
|
||||
$.cookie("uuid",null);
|
||||
$.cookie("sid",null);
|
||||
$.removeCookie("uuid");
|
||||
$.removeCookie('sid');
|
||||
console.log("clear");
|
||||
get_sid(location.hostname);
|
||||
if(res["out"] == "good"){
|
||||
if (redirect) goto("/login");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function check_sid(){
|
||||
|
||||
function check_sid(redirect = true){
|
||||
console.log("checking sid");
|
||||
if($.cookie('sid') == null || $.cookie('uuid') == null){
|
||||
clear_ck();
|
||||
clear_ck(redirect);
|
||||
}
|
||||
else{
|
||||
$.post( "/sid_log")
|
||||
.done(function( res ) {
|
||||
if(res["out"] == "bad"){
|
||||
clear_ck();
|
||||
clear_ck(redirect);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function logout(quet = false) {
|
||||
if (!quet)
|
||||
{
|
||||
let dialog = confirm("logout?");
|
||||
if(dialog){
|
||||
$.post( "/clear_sid")
|
||||
.done(function( res ) {
|
||||
if(res["out"] == "good"){
|
||||
clear_ck();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
else{
|
||||
$.post( "/clear_sid")
|
||||
.done(function( res ) {
|
||||
if(res["out"] == "good"){
|
||||
clear_ck();
|
||||
}
|
||||
})
|
||||
function logout(redirect = true) {
|
||||
let dialog = confirm("logout?");
|
||||
if(dialog){
|
||||
clear_ck(redirect);
|
||||
}
|
||||
}
|
||||
|
||||
function goto_proj(name){
|
||||
$.post( "/proj/"+name, { name:hostname })
|
||||
.done(function( res ) {
|
||||
// if(res["out"] == "good"){
|
||||
// console.log(res["body"]);
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
function get_sid(hostname){
|
||||
$.post( "/get_sid", { name:hostname })
|
||||
|
@ -131,7 +133,15 @@ function get_sid(hostname){
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
function load_projs(callback){
|
||||
$.post( "/get_projs")
|
||||
.done(function( res ) {
|
||||
if(res["out"] == "good"){
|
||||
// console.log(res["body"]);
|
||||
callback(res["body"]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// redirect
|
||||
function goto(url) {
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
window.dragMoveListener = dragMoveListener
|
||||
let root = document.getElementById("drags");
|
||||
var objs = {};
|
||||
if ($.cookie("objs") != null){
|
||||
load_local();
|
||||
}
|
||||
|
||||
|
||||
function add(obj){
|
||||
if (objs[obj] == null) objs[obj] = {};
|
||||
|
@ -13,7 +9,7 @@ function add(obj){
|
|||
// console.log(obj,objs[obj+"_count"],objs[obj+"_s"]);
|
||||
root.innerHTML += "<div class='"+obj+" drag' id="+obj+"_"+count+">"+obj+"</div>";
|
||||
objs[obj][obj+"_"+count] = {};
|
||||
objs[obj]["count"]+=1;
|
||||
// objs[obj]["count"]+=1;
|
||||
console.log(objs);
|
||||
}
|
||||
|
||||
|
@ -21,12 +17,14 @@ function create(clas,obj,x,y,inside){
|
|||
if (inside == null || inside == "") inside = "[]";
|
||||
root.innerHTML += "<div class='"+clas+" drag' id="+obj+">"+inside+"</div>";
|
||||
let obj_doc = document.getElementById(obj);
|
||||
console.log(obj_doc.classList);
|
||||
set_pos(obj_doc,x,y);
|
||||
}
|
||||
|
||||
function load_local(){
|
||||
objs = JSON.parse($.cookie("objs"));
|
||||
// console.log(objs);
|
||||
function load_local(objs){
|
||||
// objs = JSON.parse($.cookie("objs"));
|
||||
console.log(objs);
|
||||
globalThis.objs = objs;
|
||||
Object.entries(objs).forEach(([keys, values]) => {
|
||||
// console.log(keys,values);
|
||||
Object.entries(values).forEach(([key, value]) => {
|
||||
|
@ -38,8 +36,30 @@ function load_local(){
|
|||
});
|
||||
}
|
||||
|
||||
function load_proj(){
|
||||
$.post( "/load_proj",{name:proj_name})
|
||||
.done(function( res ) {
|
||||
if(res["out"] == "good"){
|
||||
console.log("good");
|
||||
// console.log(JSON.parse(`'${res["body"]}'`));
|
||||
// console.log(JSON.parse(res["body"]));
|
||||
// $.cookie("objs",res["body"]);
|
||||
load_local(JSON.parse(res["body"]));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function save(){
|
||||
$.cookie("objs",JSON.stringify(objs),{path:"/;SameSite=Strict"});
|
||||
// let proj_name = document.getElementById("proj_name").value;
|
||||
// $.cookie("objs",JSON.stringify(objs));
|
||||
console.log(objs);
|
||||
// // console.log(objs);
|
||||
$.post( "/save_proj", {proj:JSON.stringify(objs),name:proj_name})
|
||||
.done(function( res ) {
|
||||
if(res["out"] == "good"){
|
||||
console.log("good");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function set_pos(obj,x,y){
|
||||
|
|
|
@ -1,96 +1,2 @@
|
|||
/**
|
||||
* Cookie plugin
|
||||
*
|
||||
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a cookie with the given name and value and other optional parameters.
|
||||
*
|
||||
* @example $.cookie('the_cookie', 'the_value');
|
||||
* @desc Set the value of a cookie.
|
||||
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
|
||||
* @desc Create a cookie with all available options.
|
||||
* @example $.cookie('the_cookie', 'the_value');
|
||||
* @desc Create a session cookie.
|
||||
* @example $.cookie('the_cookie', null);
|
||||
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
|
||||
* used when the cookie was set.
|
||||
*
|
||||
* @param String name The name of the cookie.
|
||||
* @param String value The value of the cookie.
|
||||
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
|
||||
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
|
||||
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
|
||||
* If set to null or omitted, the cookie will be a session cookie and will not be retained
|
||||
* when the the browser exits.
|
||||
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
|
||||
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
|
||||
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
|
||||
* require a secure protocol (like HTTPS).
|
||||
* @type undefined
|
||||
*
|
||||
* @name $.cookie
|
||||
* @cat Plugins/Cookie
|
||||
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the value of a cookie with the given name.
|
||||
*
|
||||
* @example $.cookie('the_cookie');
|
||||
* @desc Get the value of a cookie.
|
||||
*
|
||||
* @param String name The name of the cookie.
|
||||
* @return The value of the cookie.
|
||||
* @type String
|
||||
*
|
||||
* @name $.cookie
|
||||
* @cat Plugins/Cookie
|
||||
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
||||
*/
|
||||
jQuery.cookie = function(name, value, options) {
|
||||
if (typeof value != 'undefined') { // name and value given, set cookie
|
||||
options = options || {};
|
||||
if (value === null) {
|
||||
value = '';
|
||||
options.expires = -1;
|
||||
}
|
||||
var expires = '';
|
||||
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
|
||||
var date;
|
||||
if (typeof options.expires == 'number') {
|
||||
date = new Date();
|
||||
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
|
||||
} else {
|
||||
date = options.expires;
|
||||
}
|
||||
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
|
||||
}
|
||||
// CAUTION: Needed to parenthesize options.path and options.domain
|
||||
// in the following expressions, otherwise they evaluate to undefined
|
||||
// in the packed version for some reason...
|
||||
var path = options.path ? '; path=' + (options.path) : '';
|
||||
var domain = options.domain ? '; domain=' + (options.domain) : '';
|
||||
var secure = options.secure ? '; secure' : '';
|
||||
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
|
||||
} else { // only name given, get cookie
|
||||
var cookieValue = null;
|
||||
if (document.cookie && document.cookie != '') {
|
||||
var cookies = document.cookie.split(';');
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = jQuery.trim(cookies[i]);
|
||||
// Does this cookie string begin with the name we want?
|
||||
if (cookie.substring(0, name.length + 1) == (name + '=')) {
|
||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookieValue;
|
||||
}
|
||||
};
|
||||
/*! jquery.cookie v1.4.1 | MIT */
|
||||
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?a(require("jquery")):a(jQuery)}(function(a){function b(a){return h.raw?a:encodeURIComponent(a)}function c(a){return h.raw?a:decodeURIComponent(a)}function d(a){return b(h.json?JSON.stringify(a):String(a))}function e(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(g," ")),h.json?JSON.parse(a):a}catch(b){}}function f(b,c){var d=h.raw?b:e(b);return a.isFunction(c)?c(d):d}var g=/\+/g,h=a.cookie=function(e,g,i){if(void 0!==g&&!a.isFunction(g)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[b(e),"=",d(g),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=e?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=c(p.shift()),r=p.join("=");if(e&&e===q){l=f(r,g);break}e||void 0===(r=f(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}});
|
96
public/lib/jquery.cookie.js.old
Normal file
96
public/lib/jquery.cookie.js.old
Normal file
|
@ -0,0 +1,96 @@
|
|||
/**
|
||||
* Cookie plugin
|
||||
*
|
||||
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a cookie with the given name and value and other optional parameters.
|
||||
*
|
||||
* @example $.cookie('the_cookie', 'the_value');
|
||||
* @desc Set the value of a cookie.
|
||||
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
|
||||
* @desc Create a cookie with all available options.
|
||||
* @example $.cookie('the_cookie', 'the_value');
|
||||
* @desc Create a session cookie.
|
||||
* @example $.cookie('the_cookie', null);
|
||||
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
|
||||
* used when the cookie was set.
|
||||
*
|
||||
* @param String name The name of the cookie.
|
||||
* @param String value The value of the cookie.
|
||||
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
|
||||
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
|
||||
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
|
||||
* If set to null or omitted, the cookie will be a session cookie and will not be retained
|
||||
* when the the browser exits.
|
||||
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
|
||||
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
|
||||
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
|
||||
* require a secure protocol (like HTTPS).
|
||||
* @type undefined
|
||||
*
|
||||
* @name $.cookie
|
||||
* @cat Plugins/Cookie
|
||||
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the value of a cookie with the given name.
|
||||
*
|
||||
* @example $.cookie('the_cookie');
|
||||
* @desc Get the value of a cookie.
|
||||
*
|
||||
* @param String name The name of the cookie.
|
||||
* @return The value of the cookie.
|
||||
* @type String
|
||||
*
|
||||
* @name $.cookie
|
||||
* @cat Plugins/Cookie
|
||||
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
||||
*/
|
||||
jQuery.cookie = function(name, value, options) {
|
||||
if (typeof value != 'undefined') { // name and value given, set cookie
|
||||
options = options || {};
|
||||
if (value === null) {
|
||||
value = '';
|
||||
options.expires = -1;
|
||||
}
|
||||
var expires = '';
|
||||
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
|
||||
var date;
|
||||
if (typeof options.expires == 'number') {
|
||||
date = new Date();
|
||||
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
|
||||
} else {
|
||||
date = options.expires;
|
||||
}
|
||||
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
|
||||
}
|
||||
// CAUTION: Needed to parenthesize options.path and options.domain
|
||||
// in the following expressions, otherwise they evaluate to undefined
|
||||
// in the packed version for some reason...
|
||||
var path = options.path ? '; path=' + (options.path) : '';
|
||||
var domain = options.domain ? '; domain=' + (options.domain) : '';
|
||||
var secure = options.secure ? '; secure' : '';
|
||||
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
|
||||
} else { // only name given, get cookie
|
||||
var cookieValue = null;
|
||||
if (document.cookie && document.cookie != '') {
|
||||
var cookies = document.cookie.split(';');
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = jQuery.trim(cookies[i]);
|
||||
// Does this cookie string begin with the name we want?
|
||||
if (cookie.substring(0, name.length + 1) == (name + '=')) {
|
||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookieValue;
|
||||
}
|
||||
};
|
|
@ -9,9 +9,11 @@
|
|||
}
|
||||
#top_panel_right{
|
||||
float: right;
|
||||
display: flex;
|
||||
}
|
||||
#top_panel_left{
|
||||
float: left;
|
||||
display: flex;
|
||||
}
|
||||
/* button{
|
||||
/* margin-inline: 5px; */
|
||||
|
@ -24,7 +26,8 @@
|
|||
let right = document.getElementById("top_panel_right");
|
||||
let left = document.getElementById("top_panel_left");
|
||||
|
||||
left.innerHTML += res["login"];
|
||||
if(document.title != "main") left.innerHTML += `<button onclick="goto('/');">main page</button>`;
|
||||
left.innerHTML += `<div id="user_name">${res["login"]}</div>`;
|
||||
|
||||
if (res["admin"] == true){
|
||||
right.innerHTML += "<button>admin panel</button>";
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<script>
|
||||
// console.log($.cookie("uuid"));
|
||||
log_by_sid();
|
||||
// log_by_sid();
|
||||
|
||||
var input = document.getElementById("pass");
|
||||
input.addEventListener("keypress", function(event) {
|
||||
|
|
|
@ -42,16 +42,21 @@
|
|||
|
||||
<%- include('./static/start.ejs',{name:'main',async: true}) %>
|
||||
<%- include('./header.ejs') %>
|
||||
<script src="/lib/interact.min.js"></script>
|
||||
<!-- <script src="/lib/interact.min.js"></script> -->
|
||||
|
||||
<div id="drags"></div>
|
||||
<div id="projs_div"></div>
|
||||
|
||||
<div class="dropzone"></div>
|
||||
<div class="trash"></div>
|
||||
<button >new project</button>
|
||||
|
||||
<button onclick="add('cube')">add</button>
|
||||
<button onclick="save()">save</button>
|
||||
<script>
|
||||
load_projs((projs)=>{
|
||||
projs.forEach(proj => {
|
||||
// console.log(proj);
|
||||
let div = document.getElementById("projs_div");
|
||||
div.innerHTML += `<button id='proj_${proj["name"]}' class='proj' onclick="goto('/proj/${proj["name"]}')">${proj["name"]}</button>`;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script src="/lib/inter.js"></script>
|
||||
<!-- <script src="/lib/inter.js"></script> -->
|
||||
<%- include('./static/end.ejs') %>
|
64
views/project.ejs
Normal file
64
views/project.ejs
Normal file
|
@ -0,0 +1,64 @@
|
|||
<style>
|
||||
.drag{
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dropzone {
|
||||
background-color: #bfe4ff;
|
||||
border: dashed 4px transparent;
|
||||
border-radius: 4px;
|
||||
height: 140px;
|
||||
margin: 10px auto 30px;
|
||||
padding: 10px;
|
||||
width: 80%;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.trash {
|
||||
background-color: #bfe4ff;
|
||||
border: dashed 4px transparent;
|
||||
border-radius: 4px;
|
||||
margin: 10px auto 30px;
|
||||
padding: 10px;
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
transition: background-color 0.3s;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.drop-active {
|
||||
border-color: #aaa;
|
||||
}
|
||||
|
||||
.drop-target {
|
||||
background-color: #29e;
|
||||
border-color: #fff;
|
||||
border-style: solid;
|
||||
}
|
||||
</style>
|
||||
|
||||
<%- include('./static/start.ejs',{name:proj_name,async: true}) %>
|
||||
<%- include('./header.ejs') %>
|
||||
<script src="/lib/interact.min.js"></script>
|
||||
|
||||
<input id="proj_name"></input>
|
||||
<div id="drags"></div>
|
||||
|
||||
<div class="dropzone"></div>
|
||||
<div class="trash"></div>
|
||||
|
||||
<button onclick="add('cube')">add</button>
|
||||
<button onclick="save()">save</button>
|
||||
|
||||
|
||||
<script src="/lib/inter.js"></script>
|
||||
<script>
|
||||
let proj_name = "<%= proj_name %>";
|
||||
load_proj();
|
||||
// console.log(proj_name);
|
||||
document.getElementById("proj_name").value = proj_name;
|
||||
</script>
|
||||
<%- include('./static/end.ejs') %>
|
|
@ -10,8 +10,15 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title> <%= name %> </title>
|
||||
<script>
|
||||
if(document.title == "login"){
|
||||
console.log(document.title);
|
||||
log_by_sid();
|
||||
}else if(document.title != "login"){
|
||||
check_sid(true);
|
||||
console.log("check");
|
||||
}
|
||||
</script>
|
||||
<!-- <script> document.querySelector("title").innerHTML += $.cookie("uuid"); </script> -->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script>if("<%= name %>" != "login") check_sid();</script>
|
||||
|
|
Loading…
Reference in New Issue
Block a user