Skip to content

Commit

Permalink
site: set zoom buttons in DepthChart ctor
Browse files Browse the repository at this point in the history
The zoom buttons were not being initialized in the constructor as
indended. This calls setZoomBttns directly from the constructor of the
inheriting class, DepthChart.

This also fixes a missing ws.deregisterRoute for updateRemainingRoute.
  • Loading branch information
chappjc committed Aug 19, 2022
1 parent 6a6b9ad commit 07a74fa
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion client/webserver/site/src/html/bodybuilder.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
{{end}}

{{define "bottom"}}
<script src="/js/entry.js?v=GHTDEG56"></script>
<script src="/js/entry.js?v=YKVNRn4"></script>
</body>
</html>
{{end}}
Expand Down
8 changes: 1 addition & 7 deletions client/webserver/site/src/js/charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ class Chart {
this.ctx = ctx
this.ctx.textAlign = 'center'
this.ctx.textBaseline = 'middle'
this.setZoomBttns()
// Mouse handling
this.mousePos = null
bind(this.canvas, 'mousemove', (e: MouseEvent) => {
Expand Down Expand Up @@ -206,12 +205,6 @@ class Chart {
this.render()
}

// setZoomBttns is run before drawing and should be used for setup of zoom
// buttons.
setZoomBttns () {
// should be implemented by inheriting class.
}

/* click is the handler for a click event on the canvas. */
click (e: MouseEvent) {
this.report.click(e)
Expand Down Expand Up @@ -410,6 +403,7 @@ export class DepthChart extends Chart {
buys: [],
sells: []
}
this.setZoomBttns() // can't wait for requestAnimationFrame -> resized
this.resize(parent.clientHeight)
}

Expand Down
10 changes: 6 additions & 4 deletions client/webserver/site/src/js/markets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,11 @@ export default class MarketsPage extends BasePage {
ws.registerRoute(updateRemainingRoute, (data: BookUpdate) => { this.handleUpdateRemainingRoute(data) })
// Handle the new order for the order book on the 'epoch_order' route.
ws.registerRoute(epochOrderRoute, (data: BookUpdate) => { this.handleEpochOrderRoute(data) })
// Handle the intial candlestick data on the 'candles' route.
ws.registerRoute(candleUpdateRoute, (data: BookUpdate) => { this.handleCandleUpdateRoute(data) })
// Handle the candles update on the 'candles' route.
// Handle the initial candlestick data on the 'candles' route.
ws.registerRoute(candlesRoute, (data: BookUpdate) => { this.handleCandlesRoute(data) })
// Handle the candles update on the 'candles' route.
ws.registerRoute(candleUpdateRoute, (data: BookUpdate) => { this.handleCandleUpdateRoute(data) })

// Bind the wallet unlock form.
this.unlockForm = new UnlockWalletForm(page.unlockWalletForm, async () => { this.openFunc() })
// Create a wallet
Expand Down Expand Up @@ -2221,9 +2222,10 @@ export default class MarketsPage extends BasePage {
unload () {
ws.request(unmarketRoute, {})
ws.deregisterRoute(bookRoute)
ws.deregisterRoute(epochOrderRoute)
ws.deregisterRoute(bookOrderRoute)
ws.deregisterRoute(unbookOrderRoute)
ws.deregisterRoute(updateRemainingRoute)
ws.deregisterRoute(epochOrderRoute)
ws.deregisterRoute(candlesRoute)
ws.deregisterRoute(candleUpdateRoute)
this.depthChart.unattach()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
{{end}}

{{define "bottom"}}
<script src="/js/entry.js?v=GHTDEG56"></script>
<script src="/js/entry.js?v=YKVNRn4"></script>
</body>
</html>
{{end}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
{{end}}

{{define "bottom"}}
<script src="/js/entry.js?v=GHTDEG56"></script>
<script src="/js/entry.js?v=YKVNRn4"></script>
</body>
</html>
{{end}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
{{end}}

{{define "bottom"}}
<script src="/js/entry.js?v=GHTDEG56"></script>
<script src="/js/entry.js?v=YKVNRn4"></script>
</body>
</html>
{{end}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
{{end}}

{{define "bottom"}}
<script src="/js/entry.js?v=GHTDEG56"></script>
<script src="/js/entry.js?v=YKVNRn4"></script>
</body>
</html>
{{end}}
Expand Down

0 comments on commit 07a74fa

Please sign in to comment.