Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last of the inline JS removed #873

Merged
merged 1 commit into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
15 changes: 15 additions & 0 deletions public/js/controllers/ticketwindow_controller.js
Original file line number Diff line number Diff line change
@@ -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
)
}
}
10 changes: 4 additions & 6 deletions views/extras.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
{{end}}

{{define "navbar"}}
<header class="top-nav">
<header class="top-nav"
id="navBar"
data-blocktime="{{.BlockTimeUnix}}"
data-poolsize="{{.ChainParams.TicketPoolSize}}">
<div class="container">
<div class="d-flex align-items-center flex-wrap">
<div class="d-flex align-items-center">
Expand Down Expand Up @@ -89,11 +92,6 @@
</nav>
</div>
</div>
<script data-turbolinks-eval="false">
var DCRThings = {};
DCRThings.targetBlockTime = {{$.BlockTimeUnix}};
DCRThings.ticketPoolSize = {{$.ChainParams.TicketPoolSize}};
</script>
</header>
<div id="watermark">HODL<br>HODL<br>HODL</div>
{{end}}
Expand Down
20 changes: 6 additions & 14 deletions views/statistics.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,23 @@
<div width="45%" class="card">
<div class="card-header proof-of-stake">Tickets In Mempool</div>
<div class="card-body card-body-padding-top">
<span class="stat-data" id="bsubsidy_total">{{.TicketsInMempool}}</span>
<span class="stat-data">{{.TicketsInMempool}}</span>
</br>
<span class="stat-details unit">Ticket{{if gt .TicketsInMempool 1}}s{{end}}</span>
</div>
</div>
<div width="45%" class="card">
<div class="card-header proof-of-stake">Votes In Mempool</div>
<div class="card-body card-body-padding-top">
<span class="stat-data" id="bsubsidy_total">{{.VotesInMempool}}</span>
<span class="stat-data">{{.VotesInMempool}}</span>
</br>
<span class="stat-details unit">Vote{{if gt .VotesInMempool 1}}s{{end}}</span>
</div>
</div>
<div width="45%" class="card">
<div class="card-header proof-of-stake">Ticket Price</div>
<div class="card-body card-body-padding-top">
<span class="stat-data" id="bsubsidy_total">{{template "decimalParts" (float64AsDecimalParts .TicketPrice 8 false)}}</span>
<span class="stat-data">{{template "decimalParts" (float64AsDecimalParts .TicketPrice 8 false)}}</span>
</br>
<span class="stat-details unit">DCR</span>
</div>
Expand Down Expand Up @@ -177,7 +177,7 @@
<div width="45%" class="card">
<div class="card-header proof-of-stake">Ticket Rewards</div>
<div class="card-body card-body-padding-top">
<span class="stat-data" id="bsubsidy_total"
<span class="stat-data"
data-toggle="tooltip"
title="Price based on continous re-staking and variable ticket price.">
+{{printf "%.2f" .TicketsROI}}%
Expand All @@ -197,7 +197,7 @@
<div width="45%" class="card">
<div class="card-header proof-of-stake">Ticket Pool Size</div>
<div class="card-body card-body-padding-top">
<span class="stat-data" id="bsubsidy_total">{{intComma .TicketPoolSize}}</span>
<span class="stat-data">{{intComma .TicketPoolSize}}</span>
</br>
{{if ge .TicketPoolSizePerToTarget 100.0}}
<span class="stat-details">+{{printf "%.2f" (floatsubtract .TicketPoolSizePerToTarget 100.0)}}% above target 40,960</span>
Expand All @@ -209,7 +209,7 @@
<div width="45%" class="card">
<div class="card-header proof-of-stake">Ticket Pool Value</div>
<div class="card-body card-body-padding-top">
<span class="stat-data no-decimal" id="bsubsidy_total">{{template "decimalParts" (float64AsDecimalParts .TicketPoolValue 8 true)}}</span>
<span class="stat-data no-decimal">{{template "decimalParts" (float64AsDecimalParts .TicketPoolValue 8 true)}}</span>
</br>
<span class="stat-details unit">DCR</span>
</br>
Expand All @@ -221,14 +221,6 @@
</div>
{{end}}
{{template "footer" . }}

<script>
// enable tool tips
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});

</script>
</body>
</html>
{{end}}
29 changes: 8 additions & 21 deletions views/windows.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<html lang="en">

{{template "html-head" "Decred Windows List"}}
<body class="{{ theme }}">
<body class="{{ theme }}" data-controller="ticketwindow">
{{template "navbar" . }}
<div class="container main" data-controller="time">
<div class="container main">
<h4>Ticket Price Windows</h4><h6>The ticket price and mining difficulty are adjusted every {{$.WindowSize}} blocks on {{toLowerCase .NetName}} (~12 hours).</h6>

{{block "windowsPagination" .}}
Expand All @@ -19,10 +19,13 @@
{{template "listViewRouting" "windows"}}

<span class="fs12 nowrap text-right">
<label class="mb-0 mr-1" for="windows-pagesize">Page Size</label>
<label class="mb-0 mr-1" for="windowsPagesize">Page Size</label>
<select
name="windows-pagesize"
id="windows-pagesize"
data-target="ticketwindow.pagesize"
data-action="change->ticketwindow#setPageSize"
data-offset="{{$.OffsetWindow}}"
id="windowsPagesize"
class="form-control-sm mb-2 mr-sm-2 mb-sm-0 {{if lt $pendingWindows 20}}disabled{{end}}"
{{if lt $pendingWindows 20}}disabled="disabled"{{end}}
>
Expand Down Expand Up @@ -112,7 +115,7 @@
<td>{{.FormattedSize}}</td>
<td class="text-right">{{template "decimalParts" (float64AsDecimalParts .Difficulty 0 true)}}</td>
<td class="text-right">{{printf "%.2f" (toFloat64Amount .TicketPrice)}}</td>
<td class="text-right jsonly" data-target="time.age" data-age="{{.StartTime}}"></td>
<td class="text-right jsonly" data-controller="time" data-target="time.age" data-age="{{.StartTime}}"></td>
<td>{{.StartTime}}</td>
</tr>
{{end}}
Expand All @@ -129,22 +132,6 @@

{{ template "footer" . }}

<script>
$("#windows-pagesize").change(function(ev) {
var pagesize = "20"
var offset = {{$.OffsetWindow}}
if (ev.currentTarget.id.indexOf("windows-pagesize") != -1){
pagesize = $("#windows-pagesize option:selected").val()
}

Turbolinks.visit(
window.location.pathname
+ "?offset="+ offset
+ "&rows=" + pagesize
)
})
</script>

</body>
</html>
{{ end }}