diff options
author | Yorhel <git@yorhel.nl> | 2020-04-17 11:17:30 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-04-17 11:17:34 +0200 |
commit | b14d888f17ff189508f6005352b6dafbccefeafa (patch) | |
tree | 52277764cfed1bbdef17964b07f03679cd9210ba /elm | |
parent | 86c0a244fa47a301c43e0750cedff494b0d0ef64 (diff) |
JS: Obtain urlStatic from the DOM rather than embedding it in the JS file
This way I don't have to rebuild the JS file for each deploy - the
generated JS is now the same for dev and prod.
(uglifyjs & zoplfi aren't fast)
Diffstat (limited to 'elm')
-rw-r--r-- | elm/ImageFlagging.elm | 3 | ||||
-rw-r--r-- | elm/Lib/Ffi.elm | 4 | ||||
-rw-r--r-- | elm/Lib/Ffi.js | 5 |
3 files changed, 10 insertions, 2 deletions
diff --git a/elm/ImageFlagging.elm b/elm/ImageFlagging.elm index f7972111..67da2246 100644 --- a/elm/ImageFlagging.elm +++ b/elm/ImageFlagging.elm @@ -16,7 +16,6 @@ import Lib.Util exposing (..) import Lib.Api as Api import Lib.Ffi as Ffi import Gen.Api as GApi -import Gen.Types exposing (urlStatic) import Gen.Images as GI import Gen.ImageVote as GIV @@ -307,7 +306,7 @@ view model = , p [ class "center" ] <| if i.token == Nothing then [] else [ text "Not sure? Read the ", a [ href "/d19" ] [ text "full guidelines" ], text " for more detailed guidance." , if model.myVotes < 100 then text "" else - span [] [ text " (", a [ href <| urlStatic ++ "/f/imgvote-keybindings.svg" ] [ text "keyboard shortcuts" ], text ")" ] + span [] [ text " (", a [ href <| Ffi.urlStatic ++ "/f/imgvote-keybindings.svg" ] [ text "keyboard shortcuts" ], text ")" ] ] , votestats i ] diff --git a/elm/Lib/Ffi.elm b/elm/Lib/Ffi.elm index 05025948..b5601a9b 100644 --- a/elm/Lib/Ffi.elm +++ b/elm/Lib/Ffi.elm @@ -29,3 +29,7 @@ elemCall s = Browser.Dom.focus -- just as well?) fmtFloat : Float -> Int -> String fmtFloat _ _ = "" + +-- Base URL for static files (e.g. "https://s.vndb.org") +urlStatic : String +urlStatic = "" diff --git a/elm/Lib/Ffi.js b/elm/Lib/Ffi.js index c1c9baf8..78d6083a 100644 --- a/elm/Lib/Ffi.js +++ b/elm/Lib/Ffi.js @@ -19,3 +19,8 @@ window.elmFfi_fmtFloat = function(wrap,call) { } } }; + +var urlStatic = document.querySelector('link[rel=stylesheet]').href.replace(/^(https?:\/\/[^/]+)\/.*$/, '$1'); +window.elmFfi_urlStatic = function(wrap,call) { + return urlStatic +}; |