Added TAGS to string & code structure improvements

- Used tags for bold writing.
- change no_"action" to just "action" to make it easier to understand.
This commit is contained in:
Milo 2019-08-12 17:45:13 +01:00 committed by Starbeamrainbowlabs
parent 016bd03362
commit 77a776caeb
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -18,7 +18,7 @@ class Tour {
this.tour.addStep("welcome", { this.tour.addStep("welcome", {
text: "Welcome to the air quality web interface! Press next to get a short tour.", text: "Welcome to the air quality web interface! Press next to get a short tour.",
buttons: this.get_buttons(false, true) buttons: this.get_buttons(true, false)
}); });
this.tour.addStep("map", { this.tour.addStep("map", {
@ -39,14 +39,13 @@ class Tour {
}); });
this.tour.addStep("reading-type", { this.tour.addStep("reading-type", {
text: "Devices report multiple types of measurement." text: "Devices report multiple types of measurement. <strong>Change to another reading type now.</strong>",
+ " Change to another reading type now.".bold(),
attachTo: { attachTo: {
element: document.querySelector("select").parentNode, element: document.querySelector("select").parentNode,
on: "top" on: "top"
}, },
advanceOn: { selector: "select", event: "change" }, advanceOn: { selector: "select", event: "change" },
buttons: this.get_buttons(true) buttons: this.get_buttons(false)
}); });
this.tour.addStep("reading-type-complete", { this.tour.addStep("reading-type-complete", {
text: "Hey, the map changed! Some devices only report certain types of measurement, and different measurements have different colour scales.", text: "Hey, the map changed! Some devices only report certain types of measurement, and different measurements have different colour scales.",
@ -72,13 +71,12 @@ class Tour {
}); });
this.tour.addStep("device-graph", { this.tour.addStep("device-graph", {
text: "By clicking a blue marker, you can view additional information about that device. Not all device are actively reporting data." text: "By clicking a blue marker, you can view additional information about that device. Not all device are actively reporting data. <strong>Try clicking one now.</strong>",
+ " Try clicking one now.".bold(),
attachTo: { attachTo: {
element: "#map", element: "#map",
on: "top" on: "top"
}, },
buttons: this.get_buttons(true) buttons: this.get_buttons(false)
}).on("show", (() => { }).on("show", (() => {
this.map_manager.device_markers.once("marker-popup-opened", this.tour.next.bind(this.tour)); this.map_manager.device_markers.once("marker-popup-opened", this.tour.next.bind(this.tour));
@ -93,14 +91,13 @@ class Tour {
buttons: this.get_buttons() buttons: this.get_buttons()
}); });
this.tour.addStep("device-graph-b", { this.tour.addStep("device-graph-b", {
text: "By clicking here, you can see the specification of the device, including its software, sensor models, exact location, more." text: "By clicking here, you can see the specification of the device, including its software, sensor models, exact location, more. <strong>Click this now.</strong>",
+ " Click this now.".bold(),
attachTo: { attachTo: {
element: ".tabs :first-child", element: ".tabs :first-child",
on: "left" on: "left"
}, },
advanceOn: { selector: ".tabs :first-child a", event: "click" }, advanceOn: { selector: ".tabs :first-child a", event: "click" },
buttons: this.get_buttons(true) buttons: this.get_buttons(false)
}); });
@ -124,7 +121,7 @@ class Tour {
this.tour.addStep("complete", { this.tour.addStep("complete", {
text: "Tour complete!\nIf you need any additional assistance, let us know :-)", text: "Tour complete!\nIf you need any additional assistance, let us know :-)",
buttons: this.get_buttons(true, false, false) buttons: this.get_buttons(false, true, true)
}); });
} }
@ -146,29 +143,27 @@ class Tour {
window.localStorage.setItem("completed_tour", (new Date()).toISOString()); window.localStorage.setItem("completed_tour", (new Date()).toISOString());
} }
get_buttons(no_continue = false, no_prev = false, no_end = true) { get_buttons(isContinue = true, isPrev = true, isEnd = false) {
let next = { text: "Next", action: this.tour.next }, let next = { text: "Next", action: this.tour.next },
prev = { text: "Previous", action: this.tour.back }, prev = { text: "Previous", action: this.tour.back },
exit = { text: "Exit", action: () => exit = { text: "Exit", action: () => {
{
this.completed_tour(); this.completed_tour();
this.tour.cancel(); this.tour.cancel();
} }, } },
end = { text: "Done", action: () => end = { text: "Done", action: () => {
{
this.completed_tour(); this.completed_tour();
this.tour.next(); this.tour.next();
} } } }
let result = []; let result = [];
if(!no_prev) result.push(prev); if(isPrev) result.push(prev);
if(!no_continue) { if(isContinue) {
result.push(next); result.push(next);
result.push(exit); result.push(exit);
} }
if(!no_end) result.push(end); if(isEnd) result.push(end);
return result; return result;
} }