mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 07:04:53 +09:00
remoteMap placing and removing entities
This commit is contained in:
1 parent
4b286f7b08
commit
f5eef7c1bb
7 files changed
+166
-20
No files matched your search
@@ -0,0 +1,50 @@
|
||||
export class itemSelector {
|
||||
constructor(containerSelector, entities){
|
||||
this.containerSelector = containerSelector;
|
||||
this.container = document.querySelector(containerSelector);
|
||||
if(!this.container) throw new Error("Could not find container "+container);
|
||||
this.entities = entities;
|
||||
|
||||
// populate container
|
||||
let cont = this.container;
|
||||
let HTML = "";
|
||||
HTML += "<div class='header'>";
|
||||
HTML += "<h2>Item selection</h2>";
|
||||
HTML += "</div>";
|
||||
HTML += "<div class='itemSelector'>";
|
||||
HTML += "<span>Name: </span>";
|
||||
HTML += "<select class='blackText'>";
|
||||
this.entities.forEach(entity => HTML += "<option value='"+entity.name+"'>"+entity.name+"</option>");
|
||||
HTML += "</select>";
|
||||
HTML += "</div>";
|
||||
|
||||
// write styles
|
||||
let styles = {
|
||||
".header > h2":{
|
||||
color:"white",
|
||||
},
|
||||
".blackText":{
|
||||
color:"black",
|
||||
},
|
||||
".blackText > option":{
|
||||
color:"black",
|
||||
}
|
||||
}
|
||||
|
||||
// turn style object into style tag
|
||||
HTML += "<style>";
|
||||
for(let style in styles){
|
||||
HTML += containerSelector+" "+style+"{";
|
||||
for(let styleName in styles[style]){
|
||||
let styleValue = styles[style][styleName];
|
||||
HTML += styleName+":"+styleValue+";";
|
||||
}
|
||||
HTML += "}";
|
||||
}
|
||||
cont.innerHTML += HTML + "</style>";
|
||||
}
|
||||
getItem(){
|
||||
let name = document.querySelector(this.containerSelector+" > .itemSelector > select").value;
|
||||
return {name};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user