Skip to content

Commit

Permalink
workaround on-page back buttons for proper history navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
rand256 committed Jul 20, 2019
1 parent 88fb082 commit 59ade83
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 4 deletions.
3 changes: 2 additions & 1 deletion client/forbidden-markers-configuration-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

const topPage = fn.getTopPage();
map.initCanvas(topPage.data.map, {metaData: false, noGotoPoints: true});
window.fn.map = map;

document.querySelector("#forbidden-markers-configuration-map-page ons-back-button").onClick = () => fn.popPage(); // case matters!

if (topPage.data.map.no_go_areas)
for (let zone of topPage.data.map.no_go_areas) {
Expand Down
6 changes: 6 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@

window.fn.popPage = function() {
document.getElementById('appNavigator').popPage();
let stateObj = {moveView: (history.state && history.state.moveView || 0)};
if (history.state && history.state.moveSubPage && history.state.moveSubPage.length > 1) {
stateObj.moveSubPage = history.state.moveSubPage.splice(0);
stateObj.moveSubPage.shift();
}
history.pushState(stateObj, "");
}

window.fn.getTopPage = function() {
Expand Down
2 changes: 2 additions & 0 deletions client/settings-access-control.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
var sshKeysTitle = document.getElementById('settings-access-control-ssh-keys-title');
var sshKeysList = document.getElementById('settings-access-control-ssh-keys-list');

document.querySelector("#settings-access-control ons-back-button").onClick = () => fn.popPage(); // case matters!

ons.getScriptPage().onShow = function() {
updateSettingsAccessControlPage();
};
Expand Down
2 changes: 2 additions & 0 deletions client/settings-carpet-mode.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
<script>
var loadingBarSettingsCarpetMode = document.getElementById('loading-bar-settings-carpet-mode');

document.querySelector("#settings-carpet-mode-page ons-back-button").onClick = () => fn.popPage(); // case matters!

ons.getScriptPage().onShow = function () {
updateSettingsCarpetModePage();
};
Expand Down
2 changes: 2 additions & 0 deletions client/settings-cleaning-history-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import { VacuumMap } from "./zone/js-modules/vacuum-map.js"
const map = new VacuumMap(document.getElementById('cleaning-history-map'));

document.querySelector("#settings-cleaning-history-map-page ons-back-button").onClick = () => fn.popPage(); // case matters!

const topPage = fn.getTopPage();
const cleaningDate = topPage.data.cleaningDate;

Expand Down
2 changes: 2 additions & 0 deletions client/settings-cleaning-history.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
var historyArray, timeZone;
var mapDataCached = null;

document.querySelector("#settings-cleaning-history-page ons-back-button").onClick = () => fn.popPage(); // case matters!

ons.getScriptPage().onInit = function () {
updateSettingsCleaningHistoryPage();
};
Expand Down
2 changes: 2 additions & 0 deletions client/settings-consumables.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
var consumableStatisticsHours = document.getElementById('settings-consumables-status-statistics-hours');
var consumableStatisticsCount = document.getElementById('settings-consumables-status-statistics-count');

document.querySelector("#settings-consumables-page ons-back-button").onClick = () => fn.popPage(); // case matters!

ons.getScriptPage().onShow = function () {
updateSettingsConsumablesPage();
};
Expand Down
6 changes: 3 additions & 3 deletions client/settings-info.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@
</ons-list-item>
</ons-list>




<script>
var loadingBarSettingsInfo = document.getElementById('loading-bar-settings-info');

document.querySelector("#settings-info-page ons-back-button").onClick = () => fn.popPage(); // case matters!

ons.getScriptPage().onShow = function() {
updateSettingsInfoPage();
};
Expand Down
2 changes: 2 additions & 0 deletions client/settings-persistent-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
<script>
var loadingBarSettingsPersistentData = document.getElementById('loading-bar-settings-persistent-data');

document.querySelector("#settings-persistent-data-page ons-back-button").onClick = () => fn.popPage(); // case matters!

ons.getScriptPage().onShow = function () {
document.getElementById('lab_mode_enabled').addEventListener("change", function(event) {
disableResetMap(!event.target.checked)
Expand Down
2 changes: 2 additions & 0 deletions client/settings-sound-voice.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
var voicePackUploadButton = document.getElementById('settings-sound-voice-upload-pack-button');
var voicePackFileBrowser = document.getElementById('settings-sound-voice-upload-browser');

document.querySelector("#settings-sound-voice ons-back-button").onClick = () => fn.popPage(); // case matters!

ons.getScriptPage().onShow = function() {
updateSettingsSoundVolumePage();
};
Expand Down
2 changes: 2 additions & 0 deletions client/settings-timers.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@

var zTimers = [];

document.querySelector("#settings-timers-page ons-back-button").onClick = () => fn.popPage(); // case matters!

ons.getScriptPage().onShow = function () {
updateSettingsZonedTimersPage();
updateSettingsTimersPage();
Expand Down
2 changes: 2 additions & 0 deletions client/settings-token.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
var loadingBarSettingsToken = document.getElementById('loading-bar-settings-token');
var settingsTokenLabel = document.getElementById('settings-token-label');

document.querySelector("#settings-token-page ons-back-button").onClick = () => fn.popPage(); // case matters!

ons.getScriptPage().onShow = function () {
updateSettingsTokenPage();
};
Expand Down
1 change: 1 addition & 0 deletions client/settings-wifi.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
wifiInputSSID.addEventListener('input', updateWifiCredentialsSaveButton);
wifiInputPassword.addEventListener('input', updateWifiCredentialsSaveButton);

document.querySelector("#settings-wifi-page ons-back-button").onClick = () => fn.popPage(); // case matters!

ons.getScriptPage().onShow = function() {
updateSettingsWifiPage();
Expand Down
2 changes: 2 additions & 0 deletions client/spot-configuration-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

map.initCanvas(topPage.data.map, {metaData: "forbidden"});

document.querySelector("#spot-configuration-map-page ons-back-button").onClick = () => fn.popPage(); // case matters!

document.getElementById("spot-configuration-map-page-h1").innerText = `Editing spot: ${spotConfig[spotToModify].name}`;

map.addSpot([spotConfig[spotToModify].coordinates[0], spotConfig[spotToModify].coordinates[1]]);
Expand Down
2 changes: 2 additions & 0 deletions client/zones-configuration-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

map.initCanvas(topPage.data.map, {metaData: "forbidden", noGotoPoints: true});

document.querySelector("#zones-configuration-map-page ons-back-button").onClick = () => fn.popPage(); // case matters!

document.getElementById("zones-configuration-map-page-h1").innerText = `Editing zone: ${zonesConfig[zoneToModify].name}`;
for(let zone of zonesConfig[zoneToModify].coordinates) {
map.addZone([zone[0], zone[1], zone[2], zone[3]], true);
Expand Down

0 comments on commit 59ade83

Please sign in to comment.