Skip to content

Commit

Permalink
Added a mechanism to configure the HTML page title from the server co…
Browse files Browse the repository at this point in the history
…nfiguration

Created a general.js setup page and move the analytics configuration there as well.
  • Loading branch information
Adi Eyal authored and milafrerichs committed Mar 24, 2021
1 parent fd78a1f commit 46961b7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ export default class Controller extends Observable {
// self.registerWebflowEvents();
}
}, 600)
document.title = dataBundle.overview.name;
})
}

Expand Down
9 changes: 2 additions & 7 deletions src/js/load.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import {select as d3select} from 'd3-selection';
import Controller from './controller';
import ProfileLoader from "./profile/profile_loader";
import {MapControl} from './map/maps';
import {numFmt} from './utils';
import {Profile} from './profile';
import {onProfileLoaded as onProfileLoadedSearch, Search} from './elements/search';
import {MapChip} from './elements/mapchip';
import {LocationInfoBox} from './elements/location_info_box';
import {PointData} from "./map/point_data";
import {ZoomToggle} from "./mapmenu/zoomtoggle";
import {PreferredChildToggle} from "./mapmenu/preferred_child_toggle";
import {PointDataTray} from './elements/point_tray/tray';
import {API} from './api';
import Analytics from './analytics';
import {BoundaryTypeBox} from "./map/boundary_type_box";
import {MapDownload} from "./map/map_download";
import {Tutorial} from "./elements/tutorial";
Expand All @@ -36,15 +31,14 @@ import {configureBoundaryEvents} from "./setup/boundaryevents";
import {configureMapDownloadEvents} from "./setup/mapdownload";
import {configureTutorialEvents} from "./setup/tutorial";
import {configureTabNoticeEvents} from "./setup/tabnotice";
import {configurePage} from "./setup/general";


export default function configureApplication(profileId, config) {
const serverUrl = config.baseUrl;

const api = config.api;
const controller = new Controller(api, config, profileId);
if (config.analytics)
config.analytics.registerEvents(controller);

let defaultFormattingConfig = {
decimal: ",.1f",
Expand Down Expand Up @@ -87,6 +81,7 @@ export default function configureApplication(profileId, config) {
configureMapDownloadEvents(mapDownload);
configureTutorialEvents(controller, tutorial, config.config.tutorial);
configureTabNoticeEvents(controller, tabNotice);
configurePage(controller, config);

controller.on('profile.loaded', payload => {
// there seems to be a bug where menu items close if this is not set
Expand Down
7 changes: 7 additions & 0 deletions src/js/setup/general.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function configurePage(controller, config) {
if (config.config.page_title)
$('title').text(config.config.page_title);

if (config.analytics)
config.analytics.registerEvents(controller);
}

0 comments on commit 46961b7

Please sign in to comment.