diff options
author | Yorhel <git@yorhel.nl> | 2022-10-22 16:04:33 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2022-10-22 16:04:35 +0200 |
commit | 138944ced5a32236afa479c418a33dc7ae8cf9b5 (patch) | |
tree | 9b7a820ee1fa9a4fad4bbcca717f95f66d012c44 /elm | |
parent | bc9b1e24b65cf0151a71ade5aa498db528d4b9a3 (diff) |
AdvSearch: Add option to exclude lie tags
https://vndb.org/t18886.24
The compact form encoding is a big ugly mess, I wouldn't be surprised if
there's bugs.
Diffstat (limited to 'elm')
-rw-r--r-- | elm/AdvSearch/Fields.elm | 16 | ||||
-rw-r--r-- | elm/AdvSearch/Tags.elm | 21 |
2 files changed, 24 insertions, 13 deletions
diff --git a/elm/AdvSearch/Fields.elm b/elm/AdvSearch/Fields.elm index 0990ac0d..ac3dbcca 100644 --- a/elm/AdvSearch/Fields.elm +++ b/elm/AdvSearch/Fields.elm @@ -431,13 +431,15 @@ fields = , f V "Language" 1 FMLang (AS.langInit AS.LangVN) (AS.langFromQuery AS.LangVN) , f V "Original language" 2 FMLang (AS.langInit AS.LangVNO) (AS.langFromQuery AS.LangVNO) , f V "Platform" 3 FMVPlatform AS.init AS.platformFromQuery - , f V "Tags" 4 FMTag AG.init (AG.fromQuery -1 True) - , f V "" -4 FMTag AG.init (AG.fromQuery 0 True) - , f V "" -4 FMTag AG.init (AG.fromQuery 1 True) - , f V "" -4 FMTag AG.init (AG.fromQuery 2 True) - , f V "" -4 FMTag AG.init (AG.fromQuery 0 False) - , f V "" -4 FMTag AG.init (AG.fromQuery 1 False) - , f V "" -4 FMTag AG.init (AG.fromQuery 2 False) + , f V "Tags" 4 FMTag AG.init (AG.fromQuery -1 True False) + , f V "" -4 FMTag AG.init (AG.fromQuery 0 True False) + , f V "" -4 FMTag AG.init (AG.fromQuery 1 True False) + , f V "" -4 FMTag AG.init (AG.fromQuery 2 True False) + , f V "" -4 FMTag AG.init (AG.fromQuery 2 True True ) + , f V "" -4 FMTag AG.init (AG.fromQuery 0 False False) + , f V "" -4 FMTag AG.init (AG.fromQuery 1 False False) + , f V "" -4 FMTag AG.init (AG.fromQuery 2 False False) + , f V "" -4 FMTag AG.init (AG.fromQuery 2 False True ) , f V "My Labels" 0 FMLabel AS.init AS.labelFromQuery , l V "My List" 0 [(QInt 65 Eq 1, "On my list"), (QInt 65 Ne 1, "Not on my list")] , f V "Length" 0 FMLength AS.init AS.lengthFromQuery diff --git a/elm/AdvSearch/Tags.elm b/elm/AdvSearch/Tags.elm index 78cb511f..3b2208d9 100644 --- a/elm/AdvSearch/Tags.elm +++ b/elm/AdvSearch/Tags.elm @@ -19,6 +19,7 @@ type alias Model = , search : A.Model GApi.ApiTagResult , spoiler : Int , inherit : Bool + , exclie : Bool } type Msg @@ -26,6 +27,7 @@ type Msg | Level (Int,Int) Int | Spoiler | Inherit Bool + | ExcLie Bool | Search (A.Msg GApi.ApiTagResult) @@ -38,6 +40,7 @@ init dat = , search = A.init "" , spoiler = dat.defaultSpoil , inherit = True + , exclie = False } ) @@ -47,8 +50,9 @@ update dat msg model = case msg of Sel m -> (dat, { model | sel = S.update m model.sel }, Cmd.none) Level (t,ol) nl -> (dat, { model | sel = S.update (S.Sel (t,ol) False) model.sel |> S.update (S.Sel (t,nl) True) }, Cmd.none) - Spoiler -> (dat, { model | spoiler = if model.spoiler < 2 then model.spoiler + 1 else 0 }, Cmd.none) + Spoiler -> (dat, { model | spoiler = if model.spoiler < 2 then model.spoiler + 1 else 0, exclie = False }, Cmd.none) Inherit b -> (dat, { model | inherit = b }, Cmd.none) + ExcLie b -> (dat, { model | exclie = b }, Cmd.none) Search m -> let (nm, c, res) = A.update model.conf m model.search in case res of @@ -61,13 +65,13 @@ update dat msg model = toQuery m = S.toQuery (\o (t,l) -> let id = if m.inherit then 8 else 14 - in if m.spoiler == 0 && l == 0 then QInt id o t else QTuple id o t (l*3+m.spoiler)) m.sel + in if m.spoiler == 0 && not m.exclie && l == 0 then QInt id o t else QTuple id o t ((if m.exclie then 16*3 else 0) + l*3 + m.spoiler)) m.sel -fromQuery spoil inherit dat q = +fromQuery spoil inherit exclie dat q = let id = if inherit then 8 else 14 f qr = case qr of - QInt x op t -> if id == x && spoil == 0 then Just (op, (t,0)) else Nothing - QTuple x op t v -> if id == x && modBy 3 v == spoil then Just (op, (t,v//3)) else Nothing + QInt x op t -> if id == x && spoil == 0 && not exclie then Just (op, (t,0)) else Nothing + QTuple x op t v -> if id == x && modBy 3 v == spoil && exclie == ((v // (16*3)) == 1) then Just (op, (t, modBy 16 (v//3))) else Nothing _ -> Nothing in S.fromQuery f dat q |> Maybe.map (\(ndat,sel) -> @@ -77,6 +81,7 @@ fromQuery spoil inherit dat q = , search = A.init "" , spoiler = spoil , inherit = inherit + , exclie = exclie } )) @@ -100,7 +105,11 @@ view dat model = [ text <| if model.spoiler == 0 then "no spoilers" else if model.spoiler == 1 then "minor spoilers" else "major spoilers" ] , linkRadio model.sel.neg (Sel << S.Neg) [ text "invert" ] ] - , div [ class "opts" ] [ span [] [], linkRadio model.inherit Inherit [ text "child tags" ] ] + , div [ class "opts" ] + [ if model.spoiler < 2 then span [] [] else + linkRadio model.exclie ExcLie [ text "exclude lies" ] + , linkRadio model.inherit Inherit [ text "child tags" ] + ] ] , ul [] <| List.map (\(t,l) -> li [ style "overflow" "hidden", style "text-overflow" "ellipsis" ] |