From 2a0ee4d809765e60b02bef25876ca5c656672c6c Mon Sep 17 00:00:00 2001 From: buck54321 Date: Sun, 9 Dec 2018 16:05:10 -0600 Subject: [PATCH] inline js moved from extras.tmpl to index.js. removed errors in statistics.tmpl. moved windows.tmpl inline js to stimulus. --- public/index.js | 7 +++++ .../js/controllers/ticketwindow_controller.js | 15 ++++++++++ views/extras.tmpl | 10 +++---- views/statistics.tmpl | 20 ++++--------- views/windows.tmpl | 29 +++++-------------- 5 files changed, 40 insertions(+), 41 deletions(-) create mode 100644 public/js/controllers/ticketwindow_controller.js diff --git a/public/index.js b/public/index.js index d8ec348b2..a868fac62 100644 --- a/public/index.js +++ b/public/index.js @@ -27,6 +27,13 @@ $.ajaxSetup({ cache: true }) +{ + let navBar = document.getElementById('navBar') + window.DCRThings = {} + window.DCRThings.targetBlockTime = navBar.dataset.blocktime + window.DCRThings.ticketPoolSize = navBar.dataset.poolsize +} + function getSocketURI (loc) { var protocol = (loc.protocol === 'https:') ? 'wss' : 'ws' return protocol + '://' + loc.host + '/ws' diff --git a/public/js/controllers/ticketwindow_controller.js b/public/js/controllers/ticketwindow_controller.js new file mode 100644 index 000000000..3930f0e6a --- /dev/null +++ b/public/js/controllers/ticketwindow_controller.js @@ -0,0 +1,15 @@ +/* global Turbolinks */ +import { Controller } from 'stimulus' + +export default class extends Controller { + static get targets () { + return ['pagesize'] + } + + setPageSize () { + Turbolinks.visit( + window.location.pathname + '?offset=' + this.pagesizeTarget.dataset.offset + + '&rows=' + this.pagesizeTarget.selectedOptions[0].value + ) + } +} diff --git a/views/extras.tmpl b/views/extras.tmpl index 45eff673a..54d671594 100644 --- a/views/extras.tmpl +++ b/views/extras.tmpl @@ -29,7 +29,10 @@ {{end}} {{define "navbar"}} -
+
HODL
HODL
HODL
{{end}} diff --git a/views/statistics.tmpl b/views/statistics.tmpl index 1ddcc4ed2..4f3c64ff9 100644 --- a/views/statistics.tmpl +++ b/views/statistics.tmpl @@ -116,7 +116,7 @@
Tickets In Mempool
- {{.TicketsInMempool}} + {{.TicketsInMempool}}
Ticket{{if gt .TicketsInMempool 1}}s{{end}}
@@ -124,7 +124,7 @@
Votes In Mempool
- {{.VotesInMempool}} + {{.VotesInMempool}}
Vote{{if gt .VotesInMempool 1}}s{{end}}
@@ -132,7 +132,7 @@
Ticket Price
- {{template "decimalParts" (float64AsDecimalParts .TicketPrice 8 false)}} + {{template "decimalParts" (float64AsDecimalParts .TicketPrice 8 false)}}
DCR
@@ -177,7 +177,7 @@
Ticket Rewards
- +{{printf "%.2f" .TicketsROI}}% @@ -197,7 +197,7 @@
Ticket Pool Size
- {{intComma .TicketPoolSize}} + {{intComma .TicketPoolSize}}
{{if ge .TicketPoolSizePerToTarget 100.0}} +{{printf "%.2f" (floatsubtract .TicketPoolSizePerToTarget 100.0)}}% above target 40,960 @@ -209,7 +209,7 @@
Ticket Pool Value
- {{template "decimalParts" (float64AsDecimalParts .TicketPoolValue 8 true)}} + {{template "decimalParts" (float64AsDecimalParts .TicketPoolValue 8 true)}}
DCR
@@ -221,14 +221,6 @@
{{end}} {{template "footer" . }} - - {{end}} diff --git a/views/windows.tmpl b/views/windows.tmpl index a65fcf182..0cf777f60 100644 --- a/views/windows.tmpl +++ b/views/windows.tmpl @@ -3,9 +3,9 @@ {{template "html-head" "Decred Windows List"}} - + {{template "navbar" . }} -
+

Ticket Price Windows

The ticket price and mining difficulty are adjusted every {{$.WindowSize}} blocks on {{toLowerCase .NetName}} (~12 hours).
{{block "windowsPagination" .}} @@ -19,10 +19,13 @@ {{template "listViewRouting" "windows"}} - +