|
33 | 33 | this.node = outer.appendChild(doc.createElement("div"))
|
34 | 34 | this.node.style.cssText = "position: relative; line-height: 0.1; margin-left: 10px"
|
35 | 35 | this.map = this.node.appendChild(doc.createElement("img"))
|
36 |
| - let imgPath = "img/" |
37 |
| - if (/\/code($|\/)/.test(outer.ownerDocument.defaultView.location)) imgPath = "../" + imgPath |
38 |
| - console.log(outer.ownerDocument.defaultView.location.toString(), /\/code($|\/)/.test(outer.ownerDocument.defaultView.localation), imgPath) |
39 |
| - this.map.src = imgPath + "village2x.png" |
| 36 | + this.imgPath = "img/" |
| 37 | + if (/\/code($|\/)/.test(outer.ownerDocument.defaultView.location)) this.imgPath = "../" + this.imgPath |
| 38 | + console.log(outer.ownerDocument.defaultView.location.toString(), /\/code($|\/)/.test(outer.ownerDocument.defaultView.localation), this.imgPath) |
| 39 | + this.map.src = this.imgPath + "village2x.png" |
40 | 40 | this.map.style.cssText = "vertical-align: -8px"
|
41 | 41 | this.robotElt = this.node.appendChild(doc.createElement("div"))
|
42 | 42 | this.robotElt.style.cssText = `position: absolute; transition: left ${0.8 / speed}s, top ${0.8 / speed}s;`
|
43 | 43 | let robotPic = this.robotElt.appendChild(doc.createElement("img"))
|
44 |
| - robotPic.src = imgPath + "robot_moving2x.gif" |
| 44 | + robotPic.src = this.imgPath + "robot_moving2x.gif" |
45 | 45 | this.parcels = []
|
46 | 46 |
|
47 | 47 | this.text = this.node.appendChild(doc.createElement("span"))
|
|
75 | 75 | heights[place] += 14
|
76 | 76 | let node = document.createElement("div")
|
77 | 77 | let offset = placeKeys.indexOf(address) * 16
|
78 |
| - node.style.cssText = "position: absolute; height: 16px; width: 16px; background-image: url(img/parcel2x.png); background-position: 0 -" + offset + "px"; |
| 78 | + node.style.cssText = `position: absolute; height: 16px; width: 16px; background-image: url(${this.imgPath}parcel2x.png); background-position: 0 -${offset}px`; |
79 | 79 | if (place == this.worldState.place) {
|
80 | 80 | node.style.left = "25px"
|
81 | 81 | node.style.bottom = (20 + height) + "px"
|
|
99 | 99 | if (this.worldState.parcels.length == 0) {
|
100 | 100 | this.button.remove()
|
101 | 101 | this.text.textContent = ` Finished after ${this.turn} turns`
|
102 |
| - this.robotElt.firstChild.src = "img/robot_idle2x.png" |
| 102 | + this.robotElt.firstChild.src = this.imgPath + "robot_idle2x.png" |
103 | 103 | } else {
|
104 | 104 | this.schedule()
|
105 | 105 | }
|
|
113 | 113 | if (this.timeout == null) {
|
114 | 114 | this.schedule()
|
115 | 115 | this.button.textContent = "Stop"
|
116 |
| - this.robotElt.firstChild.src = "img/robot_moving2x.gif" |
| 116 | + this.robotElt.firstChild.src = this.imgPath + "robot_moving2x.gif" |
117 | 117 | } else {
|
118 | 118 | clearTimeout(this.timeout)
|
119 | 119 | this.timeout = null
|
120 | 120 | this.button.textContent = "Start"
|
121 |
| - this.robotElt.firstChild.src = "img/robot_idle2x.png" |
| 121 | + this.robotElt.firstChild.src = this.imgPath + "robot_idle2x.png" |
122 | 122 | }
|
123 | 123 | }
|
124 | 124 | }
|
|
0 commit comments