diff --git a/src/main/browser.cljs b/src/main/browser.cljs index 0947c40..41e8873 100644 --- a/src/main/browser.cljs +++ b/src/main/browser.cljs @@ -2,10 +2,33 @@ (:require [re-frame.core :as rf] [reagent.core :as r] [reagent.dom :as dom] - [ajax.core :refer [GET json-response-format]] - [cljs.core.async :refer [chan timeout put! clj %)) + (put! c %)) + :error-handler #(do + (js/console.error "Error occurred:" %) + (put! c nil))}) + (go-loop [] + (let [response ( % .-target .-value))}] - [:button {:on-click #(rf/dispatch [:search-movies @query])} "Search"]]))) + :on-change #(reset! query (-> % .-target .-value)) + :on-key-down #(when (= (.-key %) "Enter") + (rf/dispatch [:search-movies @query]))}] + [:button {:class "search-button small" + :on-click #(rf/dispatch [:search-movies @query])} "Search"]]))) (defn vid-src-handle [props] (let [tv? (= "tv" (:media_type props))] (str (env :vid-src) (if tv? "tv" "movie") "/" (:id props) (if tv? "/1/1" "")))) + +(rf/reg-sub + :provider + (fn [db _] + (:provider db))) + +(rf/reg-event-db + :load-provider + (fn [db [_ provider]] + (assoc db :provider provider))) + +(def iframe-ref (r/atom nil)) + (defn expanded-interface [props] - [:div - {:style {:position "fixed" :top 0 :left 0 :width "100%" :height "100%" :background-color "white" :z-index 1000 :overflow "auto"}} - [:button {:on-click #(rf/dispatch [:collapse-item])} "Close"] - [:h3 (:title props)] - [:iframe {:allowFullScreen true - :autoPlay true - :src (vid-src-handle props) - :style {:width "100%" - :height "85%"}}]]) + (let [vidya @(rf/subscribe [:provider])] + [:div + {:style {:position "fixed" + :bottom 0 + :left 0 + :width "100%" + :height "100%" + :background-color "black" + :z-index 1000 + :overflow "auto"}} + [:button.close {:on-click #(rf/dispatch [:collapse-item])} "Back"] + [:iframe {:allowFullScreen true + :autoPlay true + :src (vid-src-handle props) + :ref #(reset! iframe-ref %) + :style {:width "100%" + :height "100%" + :z-index 1000} + :on-load #((go (