replaced localstorage cache with ram cache
This commit is contained in:
parent
c9321dc7e5
commit
6dc312d156
2
db.js
2
db.js
|
@ -1,6 +1,6 @@
|
|||
const mysql = require('mysql');
|
||||
const vars = require('./vars');
|
||||
const db_host = "localhost";
|
||||
const db_host = "db";
|
||||
|
||||
const admin = mysql.createConnection({
|
||||
host: db_host,
|
||||
|
|
|
@ -2,6 +2,7 @@ window.dragMoveListener = dragMoveListener;
|
|||
let root = document.getElementById("drags");
|
||||
let objs = { height:"2",width:"4"};
|
||||
let objs_store = {};
|
||||
let objs_imgs = {};
|
||||
let proj_from = "cloud";
|
||||
|
||||
function create(clas,x,y,body,id,size){
|
||||
|
@ -32,19 +33,19 @@ function create(clas,x,y,body,id,size){
|
|||
}
|
||||
else if (db_data != null){
|
||||
if ($.cookie("cache") == "true"){
|
||||
if (localStorage.getItem(`${main_clas}`) == null){
|
||||
if (objs_imgs[main_clas] == null){
|
||||
load_obj(main_clas,"`img`",(odata)=>{
|
||||
localStorage.setItem(main_clas,odata["img"]);
|
||||
objs_imgs[main_clas] = odata["img"];
|
||||
make(odata["img"]);
|
||||
})
|
||||
}
|
||||
else{
|
||||
make(localStorage.getItem(main_clas))
|
||||
make(objs_imgs[main_clas])
|
||||
}
|
||||
}
|
||||
else{
|
||||
load_obj(main_clas,"`img`",(odata)=>{
|
||||
localStorage.setItem(main_clas,odata["img"]);
|
||||
objs_imgs[main_clas] = odata["img"];
|
||||
make(odata["img"]);
|
||||
})
|
||||
}
|
||||
|
|
|
@ -49,14 +49,14 @@
|
|||
<label for="obj_height"><%= lang("height") %> </label>
|
||||
<div id="obj_height_value">100см</div>
|
||||
</div>
|
||||
<input style="width: 100%;" type="range" step="0.5" min="1" max="100" id="obj_height" value="100" oninput="obj_size_change('height')">
|
||||
<input style="width: 100%;" type="range" step="1" min="1" max="100" id="obj_height" value="100" oninput="obj_size_change('height')">
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: flex;width: 100%;justify-content: space-between;">
|
||||
<label for="obj_width"><%= lang("width") %></label>
|
||||
<div id="obj_width_value">100см</div>
|
||||
</div>
|
||||
<input style="width: 100%;" type="range" step="0.5" min="1" max="100" id="obj_width" value="100" oninput="obj_size_change('width')">
|
||||
<input style="width: 100%;" type="range" step="1" min="1" max="100" id="obj_width" value="100" oninput="obj_size_change('width')">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
@ -162,6 +162,9 @@
|
|||
setTimeout(()=>{
|
||||
edit_get_objs();
|
||||
},1000)
|
||||
setTimeout(()=>{
|
||||
document.getElementById("obj_resp").innerHTML = "";
|
||||
},3000)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -42,27 +42,11 @@
|
|||
document.getElementById("objs_in_group").innerHTML = "";
|
||||
edit_load_objs((data)=>{
|
||||
data.forEach(value => {
|
||||
console.log(value);
|
||||
// console.log(value);
|
||||
// // console.log($.cookie("cache"));
|
||||
// console.log(localStorage.getItem(`${value["name"]}`));
|
||||
if ($.cookie("cache") == "true"){
|
||||
if (localStorage.getItem(`${value["name"]}`) == null){
|
||||
edit_load_obj(value["name"],"`img`",(odata)=>{
|
||||
localStorage.setItem(value["name"],odata["img"]);
|
||||
make(odata["img"]);
|
||||
})
|
||||
}
|
||||
else{
|
||||
make(localStorage.getItem(value["name"]))
|
||||
}
|
||||
}
|
||||
else{
|
||||
$.cookie("cache","true",{path:"/;SameSite=Strict"})
|
||||
edit_load_obj(value["name"],"`img`",(odata)=>{
|
||||
localStorage.setItem(value["name"],odata["img"]);
|
||||
make(odata["img"]);
|
||||
})
|
||||
}
|
||||
function make(img){
|
||||
let obj_list = document.getElementById("objs_in_group");
|
||||
let obj = document.createElement('div');
|
||||
|
@ -107,7 +91,6 @@
|
|||
img : document.querySelector('#img_prev').src
|
||||
}
|
||||
let changes = {}
|
||||
localStorage.removeItem((cur_atts["name"]+"/g/"+select.options[select.selectedIndex].value).replace(" ","$"));
|
||||
attributes.forEach(element => {
|
||||
// console.log(cur_atts[element],menu.getAttribute(`obj_${element}`));
|
||||
if(element != attributes.at(-1)){
|
||||
|
@ -145,6 +128,9 @@
|
|||
document.getElementById("obj_resp").innerHTML = ("name was not changed because its taken");
|
||||
}
|
||||
},1000)
|
||||
setTimeout(()=>{
|
||||
document.getElementById("obj_resp").innerHTML = "";
|
||||
},3000)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user