-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.js
48 lines (48 loc) · 1.13 KB
/
view.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
try{
var hmUI={}
function setLocation(ele, obj){
ele.style.position="absolute";
ele.style.top=`${obj.x}px`;
ele.style.left=`${obj.y}px`;
return ele
}
hmUI.widget={
"TEXT":{
view: (obj) => {
let para = document.createElement("p")
let text=document.createTextNode(obj.text)
para.appendChild(text)
para=setLocation(para, obj)
para.style.color=obj.color || "white"
para.style["font-size"]=obj["text_size"]
document.body.appendChild(para)
},
params: ["x", "y", "text"]
},
"IMG":{
view:(obj) => {
let img = document.createElement('img');
img.src = obj.src;
img=setLocation(img, obj)
document.body.appendChild(img)
},
params: ["x", "y", "src"]
}
}
hmUI.createWidget=(id, obj)=>{
id.view(obj)
}
hmUI.createWidget(hmUI.widget.TEXT, {
x: 100,
y: 200,
text: 'a',
text_size: 30
})
hmUI.createWidget(hmUI.widget.IMG, {
x: 45,
y: 200,
src: 'logo.png',
})
} catch(e){
document.write(e.toString())
}