some fixes
This commit is contained in:
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;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user