trying to fix spawners
This commit is contained in:
parent
a5ef0206c4
commit
997dc5466d
|
@ -11,21 +11,14 @@ function get_count(clas){
|
||||||
function create(clas,x,y,body,id){
|
function create(clas,x,y,body,id){
|
||||||
let main_clas = clas.split(" ")[0];
|
let main_clas = clas.split(" ")[0];
|
||||||
// if (body == null || body == "") body = "[]";
|
// if (body == null || body == "") body = "[]";
|
||||||
load_obj(main_clas,(db_data)=>{
|
|
||||||
// let data = db_data;
|
|
||||||
// body = data["img"];
|
|
||||||
// console.log(data["img"].toString());
|
|
||||||
// console.log(db_data[0]);
|
|
||||||
// console.log(clas,x,y,body,parent);
|
|
||||||
// console.log(id);
|
|
||||||
// root.innerHTML += "<div class='"+clas+" drag' id="+obj+">"+body+"</div>";
|
|
||||||
// let img = document.createElement("img");
|
|
||||||
let obj = document.createElement("img");
|
let obj = document.createElement("img");
|
||||||
obj.id = id;
|
obj.id = id;
|
||||||
|
obj.alt = id;
|
||||||
clas= clas.split(" ");
|
clas= clas.split(" ");
|
||||||
clas.forEach(cl => {
|
clas.forEach(cl => {
|
||||||
obj.classList.add(cl);
|
obj.classList.add(cl);
|
||||||
});
|
});
|
||||||
|
load_obj(main_clas,(db_data)=>{
|
||||||
if (db_data == null) {
|
if (db_data == null) {
|
||||||
delete objs[main_clas][id];
|
delete objs[main_clas][id];
|
||||||
save(()=>{
|
save(()=>{
|
||||||
|
@ -36,14 +29,10 @@ function create(clas,x,y,body,id){
|
||||||
obj.src = db_data["img"];
|
obj.src = db_data["img"];
|
||||||
obj.title = `${db_data["name"]} \n ${db_data["description"]}`;
|
obj.title = `${db_data["name"]} \n ${db_data["description"]}`;
|
||||||
}
|
}
|
||||||
// obj.innerHTML = body;
|
})
|
||||||
// parent.append(obj);
|
|
||||||
obj.setAttribute("max-width","100px");
|
obj.setAttribute("max-width","100px");
|
||||||
root.append(obj);
|
root.append(obj);
|
||||||
set_pos(obj,x,y);
|
set_pos(obj,x,y);
|
||||||
// let obj_doc = document.getElementById(obj);
|
|
||||||
// console.log(obj_doc.classList);
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function wall_size_change(type,value){
|
function wall_size_change(type,value){
|
||||||
|
@ -96,13 +85,13 @@ function load_local(objss){
|
||||||
function load_proj(){
|
function load_proj(){
|
||||||
$.post( "/load_proj",{name:proj_name})
|
$.post( "/load_proj",{name:proj_name})
|
||||||
.done(function( res ) {
|
.done(function( res ) {
|
||||||
|
drag_start();
|
||||||
if(res["out"] == "good"){
|
if(res["out"] == "good"){
|
||||||
// console.log("good");
|
// console.log("good");
|
||||||
// console.log(JSON.parse(`'${res["body"]}'`));
|
// console.log(JSON.parse(`'${res["body"]}'`));
|
||||||
// console.log(JSON.parse(res["body"]));
|
// console.log(JSON.parse(res["body"]));
|
||||||
// $.cookie("objs",res["body"]);
|
// $.cookie("objs",res["body"]);
|
||||||
load_local(JSON.parse(res["body"]));
|
load_local(JSON.parse(res["body"]));
|
||||||
drag_start();
|
|
||||||
}
|
}
|
||||||
else if(res["out"] == "bad proj"){
|
else if(res["out"] == "bad proj"){
|
||||||
console.log("bad");
|
console.log("bad");
|
||||||
|
|
|
@ -59,8 +59,10 @@
|
||||||
let name = document.getElementById("nobj_name").value;
|
let name = document.getElementById("nobj_name").value;
|
||||||
let description = document.getElementById("nobj_description").value;
|
let description = document.getElementById("nobj_description").value;
|
||||||
var img = document.querySelector('img').src;
|
var img = document.querySelector('img').src;
|
||||||
|
name = name.replace(" ","_");
|
||||||
if (img != "http://n0rsrv2:3002/admin"){
|
if (img != "http://n0rsrv2:3002/admin"){
|
||||||
new_obj(name,img,0,0,description,(res)=>{
|
new_obj(name,img,0,0,description,(res)=>{
|
||||||
|
document.getElementById("obj_resp").innerHTML = "creating object";
|
||||||
if(res["out"] == "bad" && res["err"] == "name"){
|
if(res["out"] == "bad" && res["err"] == "name"){
|
||||||
document.getElementById("obj_resp").innerHTML = "object already exist";
|
document.getElementById("obj_resp").innerHTML = "object already exist";
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<script src="/lib/ejs.js"></script>
|
<script src="/lib/ejs.js"></script>
|
||||||
<script src="/lib/aes.js"></script>
|
<script src="/lib/aes.js"></script>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
<!-- <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> -->
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title> <%= name %> </title>
|
<title> <%= name %> </title>
|
||||||
<!-- <script> document.querySelector("title").innerHTML += $.cookie("uuid"); </script> -->
|
<!-- <script> document.querySelector("title").innerHTML += $.cookie("uuid"); </script> -->
|
||||||
|
@ -17,7 +18,7 @@
|
||||||
margin: auto;
|
margin: auto;
|
||||||
padding-block: 20px;
|
padding-block: 20px;
|
||||||
}
|
}
|
||||||
body{
|
html{
|
||||||
background-color:aliceblue;
|
background-color:aliceblue;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user