PageSourceSearch

https://www.1091.tv/js/controllers/watch.js

js 1091.tv collected 2026-10-02 10:31:08 UTC 7,987 bytes, 179 lines download raw bytes

1/*globals bowser*/
2
3angular.module('orchard').controller('WatchController',['authService', '$rootScope', '$scope', '$interval', '$route', '$routeParams', '$location','$http', '$cookies','flash', 'Global', 'MyListService',
4    function(authService, $rootScope, $scope, $interval, $route, $routeParams, $location, $http, $cookies, flash, Global, MyListService){
5        var CMS_URL = window.cmsUrl;
6        $scope.backUrl = window.location.pathname.replace('/watch', '');
7        $scope.global = Global;
8        $scope.videoTitle = "";
9        $scope.videoAspect = {width: "16", height:"9"};
10        $('#player').height($('#player').width()/$scope.videoAspect.width*$scope.videoAspect.height);
11        $(window).resize(function() {
12            $('#player').height($('#player').width()/$scope.videoAspect.width*$scope.videoAspect.height);
13        });
14        $scope.showUpdateBrowserMessage = false;
15
16        var checkLoggedInInterval;
17
18        $scope.addToMyList = function() {
19            MyListService.addToMyList($scope.filmId).then(function (result) {
20                if(result.statusText === "OK") {
21                    $scope.showRemove = true;
22                    $rootScope.$broadcast('video-ref');
23                }
24            });
25        };
26
27        $scope.removeFromMyList = function () {
28            MyListService.removeFromMyList($scope.filmId).then(function (result) {
29                if(result.statusText === "OK") {
30                    $scope.showRemove = false;
31                    $rootScope.$broadcast('video-ref');
32                }
33            });
34        };
35
36        $scope.initWatch = function(){
37            $scope.showRemove = false;
38            browserVersionDetection(bowser);
39
40            checkVideoInfo();
41        };
42
43        function browserVersionDetection() {
44            console.log("About to check for browser version", bowser);
45            if (bowser.chrome && parseInt(bowser.version) < 29) {
46                $scope.showUpdateBrowserMessage = true;
47                console.warn('Update your chrome version');
48            }
49            if (bowser.safari && bowser.mac && !bowser.iphone && (parseFloat(bowser.version) < 9.1) ){
50                $scope.showUpdateBrowserMessage = true;
51                console.warn('Update your safari version');
52            }
53            if (bowser.firefox && parseInt(bowser.version) < 45) {
54                $scope.showUpdateBrowserMessage = true;
55                console.warn('Update your firefox browser');
56            }
57            if (bowser.opera && parseInt(bowser.version) < 37) {
58                $scope.showUpdateBrowserMessage = true;
59                console.warn('Update your opera browser');
60            }
61            if (bowser.opera && parseInt(bowser.version) < 37) {
62                $scope.showUpdateBrowserMessage = true;
63                console.warn('Update your opera browser');
64            }
65            if (bowser.android && bowser.chrome && parseInt(bowser.version) < 50) {
66                $scope.showUpdateBrowserMessage = true;
67                console.warn('Update your chrome android mobile version');
68            }
69            if (bowser.msie && parseInt(bowser.version) < 11) {
70                $scope.showUpdateBrowserMessage = true;
71                console.warn('Update your ie explorer');
72            }
73            if (bowser.msedge && parseInt(bowser.version) < 13) {
74                $scope.showUpdateBrowserMessage = true;
75                console.warn('Update your edge browser');
76            }
77
78        }
79
80        function checkVideoInfo() {
81            if (!$routeParams.film_title_or_upc) {
82                return;
83            }
84
85            $http({
86                method: 'GET',
87                url: window.cmsUrl + '/api/video-entitlements-video/' + $routeParams.film_title_or_upc +'/info',
88                withCredentials:true
89            }).success(function(data, status, headers, config) {
90                    $scope.playsLeft = data.feature.playsLeft;
91                    $scope.filmId = data.videoId;
92                    $scope.filmTitle = data.videoTitle;
93
94                    if ($scope.global.user && $scope.filmId) {
95                        $scope.hasEntitlements = _.some($scope.global.user.entitledVideos, function(video) {
96                            return video._id === $scope.filmId;
97                        });
98
99                        $scope.showRemove = _.some($scope.global.user.videoRefs, function(video) {
100                            return video._id === $scope.filmId;
101                        });
102                    }
103
104                    console.log("Allowed to see? : ", data.feature.allowedToSee);
105
106                    if (data.feature.allowedToSee) {
107                        $scope.notAllowedMessage = undefined;
108                        $('#player').attr('src', data.feature.embedUrl);
109                        if (!angular.isDefined(checkLoggedInInterval)) {
110                            checkLoggedInInterval = $interval(checkStillLoggedIn, 3000);
111                        }
112                    } else {
113                        $scope.notAllowedMessage = data.feature.info;
114                        if ($scope.notAllowedMessage === "You must log in to screen films.") {
115                            console.log('about to set redirect_to_after_signin cookie to value: ' + $location.path());
116                            $cookies.redirect_to_after_signin = $location.path();
117                            $location.path('/login');
118                            return;
119                        }
120                    }
121                    setTimeout(updatePlaysLeft, 10000);
122                }).error(function(data, status, headers, config) {
123                    console.log('ERROR:'  + data);
124                });
125        }
126
127        function checkStillLoggedIn() {
128            if (!$routeParams.film_title_or_upc) {
129                return;
130            }
131
132            console.log('Checking still logged in');
133            $http({
134                method: 'GET',
135                url: window.cmsUrl + '/api/video-entitlements-video/' + $routeParams.film_title_or_upc + '/info',
136                withCredentials:true
137            }).success(function(data, status, headers, config) {
138                    $scope.playsLeft = data.feature.playsLeft;
139                    if (!data.feature.allowedToSee) {
140                        if ($location.path() === '/login') {
141                            return;
142                        }
143                        $scope.notAllowedMessage = data.feature.info;
144                        if ($scope.notAllowedMessage === "You must log in to screen films.") {
145                            stopCheckingLoggedIn();
146                            console.log('about to set redirect_to_after_signin cookie to value: ' + $location.path());
147                            $cookies.redirect_to_after_signin = $location.path();
148                            $location.path('/login');
149                            return;
150                        }
151                    }
152                }).error(function(data, status, headers, config) {
153                    console.log('ERROR:'  + data);
154                });
155        }
156
157        function stopCheckingLoggedIn() {
158            if (angular.isDefined(checkLoggedInInterval)) {
159                $interval.cancel(checkLoggedInInterval);
160                checkLoggedInInterval = undefined;
161            }
162        }
163
164        $scope.$on('$destroy', function() {
165            stopCheckingLoggedIn();
166        });
167
168        function updatePlaysLeft() {
169            $http({
170                method: 'GET',
171                url: window.cmsUrl + '/api/video-entitlements-video/' + $routeParams.film_title_or_upc + '/info',
172                withCredentials:true
173            }).success(function(data, status, headers, config) {
174                    $scope.playsLeft = data.feature.playsLeft;
175                }).error(function(data, status, headers, config) {
176                    console.log('ERROR:'  + data);
177                });
178        }
179    }]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.