summaryrefslogtreecommitdiff
path: root/elm/VNLengthVote.elm
diff options
context:
space:
mode:
Diffstat (limited to 'elm/VNLengthVote.elm')
-rw-r--r--elm/VNLengthVote.elm94
1 files changed, 67 insertions, 27 deletions
diff --git a/elm/VNLengthVote.elm b/elm/VNLengthVote.elm
index 16fd3ff3..ceafe05a 100644
--- a/elm/VNLengthVote.elm
+++ b/elm/VNLengthVote.elm
@@ -31,10 +31,11 @@ type alias Model =
, uid : String
, vid : String
, rid : List String
+ , maycount: Bool
, defrid : String
, hours : Maybe Int
, minutes : Maybe Int
- , speed : Int
+ , speed : Maybe Int
, length : Int -- last saved length
, notes : String
, rels : Maybe (List (String, String))
@@ -48,10 +49,11 @@ init f =
, uid = f.uid
, vid = f.vid
, rid = Maybe.map (\v -> v.rid) f.vote |> Maybe.withDefault []
+ , maycount= f.maycount
, defrid = ""
, hours = Maybe.map (\v -> v.length // 60 ) f.vote
, minutes = Maybe.andThen (\v -> let n = modBy 60 v.length in if n == 0 then Nothing else Just n) f.vote
- , speed = Maybe.map (\v -> v.speed) f.vote |> Maybe.withDefault -1
+ , speed = Maybe.map (\v -> if v.private then Just 8 else v.speed) f.vote |> Maybe.withDefault (Just 9)
, length = Maybe.map (\v -> v.length) f.vote |> Maybe.withDefault 0
, notes = Maybe.map (\v -> v.notes) f.vote |> Maybe.withDefault ""
, rels = Nothing
@@ -64,7 +66,14 @@ encode : Model -> GV.Send
encode m =
{ uid = m.uid
, vid = m.vid
- , vote = if enclen m == 0 then Nothing else Just { rid = m.rid, notes = m.notes, speed = m.speed, length = enclen m }
+ , maycount = m.maycount
+ , vote = if enclen m == 0 then Nothing else Just
+ { rid = m.rid
+ , notes = m.notes
+ , speed = if m.speed == Just 8 then Nothing else m.speed
+ , length = enclen m
+ , private = m.speed == Just 8
+ }
}
type Msg
@@ -73,7 +82,7 @@ type Msg
| Today Date.Date
| Hours (Maybe Int)
| Minutes (Maybe Int)
- | Speed Int
+ | Speed (Maybe Int)
| Release Int String
| ReleaseAdd
| ReleaseDel Int
@@ -114,48 +123,76 @@ update msg model =
RelLoaded e -> ({ model | state = Api.Error e }, Cmd.none)
Delete -> let m = { model | hours = Nothing, minutes = Nothing, rid = [model.defrid], notes = "", state = Api.Loading } in (m, GV.send (encode m) Submitted)
Submit -> ({ model | state = Api.Loading }, GV.send (encode model) Submitted)
- Submitted (GApi.Success) ->
- ({ model | open = False, state = Api.Normal
- , length = (Maybe.withDefault 0 model.hours) * 60 + Maybe.withDefault 0 model.minutes
- }, Cmd.none)
+ Submitted (GApi.Success) -> ({ model | open = False, state = Api.Normal, length = enclen model }, Cmd.none)
Submitted r -> ({ model | state = Api.Error r }, Cmd.none)
view : Model -> Html Msg
view model = div [class "lengthvotefrm"] <|
let
- cansubmit = enclen model > 0 && model.speed /= -1
+ selcounted =
+ [ (Just 9, "-- how do you estimate your read/play speed? --")
+ , (Just 0, "Slow (e.g. low language proficiency or extra time spent on gameplay)")
+ , (Just 1, "Normal (no content skipped, all voices listened to end)")
+ , (Just 2, "Fast (e.g. fast reader or skipping through voices and gameplay)")
+ , (Nothing, "Don't count my play time (public)")
+ , (Just 8, "Don't count my play time (private)")
+ ]
+ seluncounted =
+ [ (Just 9, "-- visibility --")
+ , (Nothing, "Public (everyone can see your vote)")
+ , (Just 8, "Private (for your own administration)")
+ ]
+ cansubmit = enclen model > 0 && model.speed /= Just 9
&& not (List.isEmpty model.rid)
&& not (List.any (\r -> r == "") model.rid)
rels = Maybe.withDefault [] model.rels
frm = [ form_ "" (if cansubmit then Submit else Noop) False
[ br [] []
+ , if model.maycount then text "" else span []
+ [ b [] [ text "This visual novel is still in development." ]
+ , br [] []
+ , text "Which means your vote will not count towards the VN's length statistics."
+ , br_ 2
+ ]
, text "How long did you take to finish this VN?"
, br [] []
- , text "- Only vote if you've completed all normal/true endings."
- , br [] []
- , text "- Exact measurements preferred, but rough estimates are accepted too."
- , br [] []
, text "Play time: "
- , inputNumber "vnlengthhours" model.hours Hours [ Html.Attributes.min "0", Html.Attributes.max "500" ]
+ , inputNumber "vnlengthhours" model.hours Hours [ Html.Attributes.min "0", Html.Attributes.max "435" ]
, text " hours "
, inputNumber "" model.minutes Minutes [ Html.Attributes.min "0", Html.Attributes.max "59" ]
, text " minutes"
, br [] []
- , if model.defrid /= "" then text "" else div [] <| List.indexedMap (\n rid -> div []
- [ inputSelect "" rid (Release n) []
+ , if model.defrid /= "" then text "" else table [] <| List.indexedMap (\n rid -> tr []
+ [ td [] [
+ inputSelect "" rid (Release n) []
<| ("", "-- select release --") :: rels
++ if rid == "" || List.any (\(r,_) -> r == rid) rels then [] else [(rid, "[deleted/moved release: " ++ rid ++ "]")]
- , if n == 0
- then inputButton "+" ReleaseAdd [title "Add release"]
- else inputButton "-" (ReleaseDel n) [title "Remove release"]
+ ]
+ , td []
+ [ if n == 0
+ then inputButton "+" ReleaseAdd [title "Add release"]
+ else inputButton "-" (ReleaseDel n) [title "Remove release"]
+ ]
]) model.rid
- , inputSelect "" model.speed Speed [style "width" "100%"]
- [ (-1, "-- how do you estimate your read/play speed? --")
- , (0, "Slow (e.g. low language proficiency or extra time spent on gameplay)")
- , (1, "Normal (no content skipped, all voices listened to end)")
- , (2, "Fast (e.g. fast reader or skipping through voices and gameplay)")
- ]
+ , inputSelect "" model.speed Speed [] (if model.maycount then selcounted else seluncounted)
+ , case model.speed of
+ Just 9 -> span [] []
+ Just 8 -> span []
+ [ text "Your play time is not counted towards the VN's average and is not visible in the listings."
+ , text " It is only saved for your own administration and counted towards the personal play time displayed on your profile."
+ , br [] []
+ ]
+ Nothing -> span []
+ [ text "Your play time is not counted towards the VN's average, but is still visible in the listings and saved for your own administration."
+ , br [] []
+ ]
+ _ -> span []
+ [ text "- Only vote if you've completed all normal/true endings."
+ , br [] []
+ , text "- Exact measurements preferred, but rough estimates are accepted too."
+ , br [] []
+ ]
, inputTextArea "" model.notes Notes
[rows 2, cols 30, style "width" "100%", placeholder "(Optional) comments that may be helpful. For example, did you complete all the bad endings, how did you measure? etc." ]
, if model.length == 0 then text "" else inputButton "Delete my vote" Delete [style "float" "right"]
@@ -171,6 +208,9 @@ view model = div [class "lengthvotefrm"] <|
++ if modBy 60 model.length /= 0 then String.fromInt (modBy 60 model.length) ++ "m" else "" ]
] ++ case (model.open, model.state) of
(False, _) -> []
- (_, Api.Normal) -> frm
- (_, Api.Error e) -> [ br_ 2, b [ class "standout" ] [ text ("Error: " ++ Api.showResponse e) ] ]
+ (_, Api.Normal) ->
+ if model.length == 0 && List.isEmpty (Maybe.withDefault [] model.rels)
+ then [ br_ 2, b [] [ text "There are no releases eligible for voting." ] ]
+ else frm
+ (_, Api.Error e) -> [ br_ 2, b [] [ text ("Error: " ++ Api.showResponse e) ] ]
(_, Api.Loading) -> [ span [ style "float" "right", class "spinner" ] [] ]