Commit 037954a7 authored by Cédric F.'s avatar Cédric F.

Stop tracking mouse position

We won't need it.
parent 1145a739
......@@ -13,7 +13,6 @@
"elm-lang/html": "2.0.0 <= v < 3.0.0",
"elm-lang/http": "1.0.0 <= v < 2.0.0",
"elm-lang/keyboard": "1.0.1 <= v < 2.0.0",
"elm-lang/mouse": "1.0.1 <= v < 2.0.0",
"elm-lang/navigation": "2.1.0 <= v < 3.0.0",
"elm-lang/virtual-dom": "2.0.4 <= v < 3.0.0",
"elm-lang/window": "1.0.1 <= v < 2.0.0"
......
......@@ -78,9 +78,9 @@
<script src="https://cdn.jsdelivr.net/npm/particles.js@2.0.0/particles.min.js"></script>
<script>
particlesJS.load('particles-js', 'assets/js/particles.json', function() {
console.log('callback - particles.js config loaded');
});
//particlesJS.load('particles-js', 'assets/js/particles.json', function() {
// console.log('callback - particles.js config loaded');
//});
window.addEventListener('load', () => {
const elmAppDiv = document.querySelector('#elm-app');
......
......@@ -56,15 +56,16 @@ modelFromJson jsonModel =
, confirmations = jsonModel.confirmations
, blockHash = jsonModel.blockHash
, time = Maybe.map timestampToTime jsonModel.time
, vIn = jsonModel.vIn
, vOut = jsonModel.vOut
, vIn = List.sortBy .amountIn jsonModel.vIn |> List.reverse
, vOut = List.sortBy .value jsonModel.vOut |> List.reverse
, fetching = False
, error = Nothing
}
type alias VIn =
{ txId : String
{ txId : Maybe String
, coinbase : Maybe String
, amountIn : Float
, blockHeight : Int
}
......@@ -87,6 +88,21 @@ timestampToTime int =
Time.second * (toFloat int)
totalSpent : Model -> Float
totalSpent model =
List.map .amountIn model.vIn |> List.foldr (+) 0
dcrAmount : Float -> String
dcrAmount float =
let
rounded =
-- remove any floating point arithmetic errors
float * 1.0e8 |> round |> toFloat |> (flip (/)) 1.0e8
in
(toString rounded) ++ " DCR"
type Msg
= GetRawTransaction String
| GetRawTransactionResult (Result Http.Error JsonModel)
......@@ -125,6 +141,8 @@ view model =
, dd [ class "col-9" ] [ formatBlock model.blockHash ]
, dt [ class "col-3 text-right" ] [ text "size" ]
, dd [ class "col-9" ] [ text <| toString model.size ++ " bytes" ]
, dt [ class "col-3 text-right" ] [ text "total spent" ]
, dd [ class "col-9" ] [ text <| dcrAmount (totalSpent model) ]
]
]
]
......@@ -136,7 +154,16 @@ view model =
List.map
(\vIn ->
li [ class "list-group-item bg-primary" ]
[ text <| toString vIn.amountIn ]
[ span [ class "badge badge-info" ]
[ text
(if vIn.coinbase /= Nothing then
"coinbase"
else
""
)
]
, span [] [ text <| dcrAmount vIn.amountIn ]
]
)
model.vIn
]
......@@ -146,7 +173,9 @@ view model =
List.map
(\vOut ->
li [ class "list-group-item bg-success" ]
[ text <| toString vOut.value ]
[ span [ class "badge badge-info" ] [ text vOut.scriptPubKey.type_ ]
, span [] [ text <| dcrAmount vOut.value ]
]
)
model.vOut
]
......@@ -211,7 +240,9 @@ decodeGetRawTransaction =
decodeVIn : Decode.Decoder VIn
decodeVIn =
Pipeline.decode VIn
|> Pipeline.requiredAt [ "txid" ] Decode.string
-- no txid for coinbase txs
|> Pipeline.optionalAt [ "txid" ] (Decode.maybe Decode.string) Nothing
|> Pipeline.optionalAt [ "coinbase" ] (Decode.maybe Decode.string) Nothing
|> Pipeline.requiredAt [ "amountin" ] Decode.float
|> Pipeline.requiredAt [ "blockheight" ] Decode.int
......
module Trappisto.Model exposing (..)
import Navigation
import Mouse
import Window
import Keyboard
import Time exposing (Time)
......@@ -19,7 +18,6 @@ type Template
type alias Model =
{ keys : Keys
, mouse : Mouse.Position
, window : Window.Size
, statusModel : StatusComponent.Model
, blockModel : BlockComponent.Model
......@@ -34,7 +32,6 @@ type alias Model =
initialModel : Model
initialModel =
{ keys = Keys False False False False
, mouse = Mouse.Position 0 0
, window = Window.Size 0 0
, statusModel = StatusComponent.initialModel
, blockModel = BlockComponent.initialModel
......@@ -55,7 +52,6 @@ type Msg
| Query String
| KeyChange Bool Keyboard.KeyCode
| Resize Window.Size
| MouseMove Mouse.Position
| Tick Time
| FetchStatus
......
......@@ -2,7 +2,6 @@ port module Trappisto.Update exposing (init, update, subscriptions)
import Navigation
import Keyboard
import Mouse
import Task exposing (Task)
import Time exposing (Time)
import Window
......@@ -44,7 +43,6 @@ subscriptions _ =
Sub.batch
[ Keyboard.downs (KeyChange True)
, Keyboard.ups (KeyChange False)
, Mouse.moves MouseMove
, Window.resizes Resize
, Time.every (Time.second * 60) Tick
, jsToElm JsMsg
......@@ -173,9 +171,6 @@ update action model =
else
update (Query updatedModel.query) updatedModel
MouseMove position ->
( { model | mouse = position }, Cmd.none )
Resize size ->
( { model | window = size }, Cmd.none )
......
......@@ -16,7 +16,6 @@
"elm-lang/html": "2.0.0 <= v < 3.0.0",
"elm-lang/http": "1.0.0 <= v < 2.0.0",
"elm-lang/keyboard": "1.0.1 <= v < 2.0.0",
"elm-lang/mouse": "1.0.1 <= v < 2.0.0",
"elm-lang/navigation": "2.1.0 <= v < 3.0.0",
"elm-lang/virtual-dom": "2.0.4 <= v < 3.0.0",
"elm-lang/window": "1.0.1 <= v < 2.0.0"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment