mudlet-map-browser-script 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.min.js +1 -1
- package/index.js +33 -4
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Translator from "@andreasremdt/simple-translator";
|
|
2
2
|
import bootstrap from "bootstrap";
|
|
3
|
-
import {MapReader,
|
|
3
|
+
import {MapReader, Settings, Renderer} from "mudlet-map-renderer";
|
|
4
4
|
import {Preview} from "./preview";
|
|
5
5
|
import {downloadTags, downloadVersion} from "./versions";
|
|
6
6
|
import convert from "color-convert";
|
|
@@ -211,11 +211,19 @@ class PageControls {
|
|
|
211
211
|
});
|
|
212
212
|
|
|
213
213
|
this.paths = {};
|
|
214
|
+
|
|
215
|
+
this.renderer = new Renderer(this.map, this.reader, this.reader.getColors(), this.settings);
|
|
214
216
|
}
|
|
215
217
|
|
|
216
218
|
init() {
|
|
219
|
+
// Check if version parameter is present
|
|
220
|
+
if (params.version && this.versions) {
|
|
221
|
+
this.replaceVersion(params.version);
|
|
222
|
+
history.replaceState(null, null, url);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
217
226
|
let area = this.reader.getAreas()[0].areaId;
|
|
218
|
-
console.log(area)
|
|
219
227
|
let zIndex = 0;
|
|
220
228
|
if (params.loc) {
|
|
221
229
|
this.findRoom(params.loc);
|
|
@@ -283,7 +291,7 @@ class PageControls {
|
|
|
283
291
|
if (this.renderer) {
|
|
284
292
|
this.renderer.clear();
|
|
285
293
|
}
|
|
286
|
-
this.renderer
|
|
294
|
+
this.renderer.renderArea(area)
|
|
287
295
|
this.select.value = areaId;
|
|
288
296
|
this.populateLevelButtons(area.getLevels(), zIndex);
|
|
289
297
|
this.hideRoomInfo();
|
|
@@ -847,7 +855,28 @@ class PageControls {
|
|
|
847
855
|
downloadVersion(tag, this.versions.getAttribute("data-files")).then(data => {
|
|
848
856
|
this.reader = new MapReader(data, colors);
|
|
849
857
|
this.populateSelectBox();
|
|
850
|
-
|
|
858
|
+
|
|
859
|
+
// Determine which area to render
|
|
860
|
+
let area = this.reader.getAreas()[0].areaId;
|
|
861
|
+
let zIndex = 0;
|
|
862
|
+
|
|
863
|
+
if (params.loc) {
|
|
864
|
+
this.findRoom(params.loc);
|
|
865
|
+
} else if (params.area) {
|
|
866
|
+
area = params.area;
|
|
867
|
+
this.renderArea(area, zIndex);
|
|
868
|
+
} else if (this.areaId !== undefined) {
|
|
869
|
+
// If already initialized, use current area
|
|
870
|
+
this.renderArea(this.areaId, this.zIndex, true).then(() => this.showToast(`Przeładowano wersję na ${tag}`));
|
|
871
|
+
} else {
|
|
872
|
+
// First initialization
|
|
873
|
+
if (position !== null && position.area) {
|
|
874
|
+
area = position.area;
|
|
875
|
+
zIndex = position.zIndex;
|
|
876
|
+
}
|
|
877
|
+
this.renderArea(area, zIndex);
|
|
878
|
+
}
|
|
879
|
+
|
|
851
880
|
this.versionBadge.innerHTML = `v${tag}`;
|
|
852
881
|
this.versionBadge.style.display = "initial";
|
|
853
882
|
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mudlet-map-browser-script",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
7
|
+
"prepublishOnly": "browserify index.js | uglifyjs -cm > dist/bundle.min.js"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@andreasremdt/simple-translator": "^2.0.4",
|