PageSourceSearch

https://www.nebrodinews.it/wp-content/plugins/italpress-video-oop/public/js/class-italpress-video-vrize.js

js nebrodinews.it collected 2026-10-04 11:49:58 UTC 5,849 bytes, 151 lines download raw bytes

1var Italpress_Video_Vrize = function( vast ) {
2    var videoOpt = {
3      muted    : true,
4      autoplay : true,
5    };
6    this.player = videojs('italpress-video-container',videoOpt);
7  
8    // Remove controls from the player on iPad to stop native controls from stealing
9    // our click
10    var contentPlayer =  document.getElementById('italpress-video-container_html5_api');
11    if ((navigator.userAgent.match(/iPad/i) ||
12            navigator.userAgent.match(/Android/i)) &&
13        contentPlayer.hasAttribute('controls')) {
14      contentPlayer.removeAttribute('controls');
15    }
16  
17    // Start ads when the video player is clicked, but only the first time it's
18    // clicked.
19    this.startEvent = 'click';
20    if (navigator.userAgent.match(/iPhone/i) ||
21        navigator.userAgent.match(/iPad/i) ||
22        navigator.userAgent.match(/Android/i)) {
23      this.startEvent = 'touchend';
24    }
25    this.wrapperDiv = document.getElementById('italpress-video-container');
26    this.boundInitFromStart = this.initFromStart.bind(this);
27    this.wrapperDiv.addEventListener(this.startEvent, this.initFromStart.bind(this));
28  
29    this.options = {
30      id: 'italpress-video-container',
31      adTagUrl                 : vast,
32      adsManagerLoadedCallback : this.adsManagerLoadedCallback.bind(this)
33    };
34  
35    this.contents = videoContents;
36    this.posters = videoPosters;
37    this.titles = videoTitles;
38    this.currentContent = 0;
39  
40    this.linearAdPlaying = false;
41    this.initialized = false;
42    this.playlistItemClicked = false;
43  
44    this.playlistDiv = document.getElementById('italpress-video-playlist');
45    if (this.playlistDiv) {
46      this.playlistItems = this.playlistDiv.childNodes;
47      for (var index in this.playlistItems) {
48        if (this.playlistItems[index].tagName == 'DIV') {
49          this.playlistItems[index].addEventListener(
50              'click',
51              this.onPlaylistItemClick.bind(this),
52              false);
53        }
54      }
55    }
56    // this.player.on('ended', function() {
57    //   document.querySelector("#italpress-video-vrize").classList.remove("noop");
58    //   setTimeout(()=>{
59    //     document.querySelector("#italpress-video-vrize").remove();
60    //   },1000);
61      
62    // });
63    this.player.ima(this.options);
64    document.addEventListener('DOMContentLoaded', () => {
65        setTimeout(()=>{
66            document.querySelector("#italpress-video-vrize").classList.add("noop");
67            document.querySelector("#italpress-video-vrize video").play();
68            document.querySelector("#vrize-close").style.display = "block";
69            setTimeout(()=>{
70              document.querySelector("#vrize-close").classList.add("cab");
71            },12000);
72        },2000);
73
74        document.getElementById("vrize-close").addEventListener("click", function(){
75          document.querySelector("#italpress-video-vrize").classList.remove("noop");
76          setTimeout(()=>{
77            document.querySelector("#italpress-video-vrize").remove();
78          },1000);
79        })
80    });
81  }
82  
83  Italpress_Video_Vrize.prototype.initFromStart = function() {
84    if (!this.initialized) {
85      this.init();
86      this.wrapperDiv.removeEventListener(
87          this.startEvent, this.boundInitFromStart);
88    }
89  }
90  
91  Italpress_Video_Vrize.prototype.init = function() {
92    this.initialized = true;
93    this.player.ima.initializeAdDisplayContainer();
94  };
95  
96  Italpress_Video_Vrize.prototype.adsManagerLoadedCallback = function() {
97    var events = [google.ima.AdEvent.Type.ALL_ADS_COMPLETED,
98                  google.ima.AdEvent.Type.CLICK,
99                  google.ima.AdEvent.Type.COMPLETE,
100                  google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,
101                  google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,
102                  google.ima.AdEvent.Type.FIRST_QUARTILE,
103                  google.ima.AdEvent.Type.LOADED,
104                  google.ima.AdEvent.Type.MIDPOINT,
105                  google.ima.AdEvent.Type.PAUSED,
106                  google.ima.AdEvent.Type.STARTED,
107                  google.ima.AdEvent.Type.THIRD_QUARTILE];
108    for (var index = 0; index < events.length; index++) {
109      this.player.ima.addEventListener(
110          events[index],
111          this.onAdEvent.bind(this));
112    }
113  
114    // When the page first loads, don't autoplay. After that, when the user
115    // clicks a playlist item to switch videos, autoplay.
116    if (this.playlistItemClicked) {
117      this.player.play();
118    }
119  };
120  
121  Italpress_Video_Vrize.prototype.onAdEvent = function(event) {
122    if (event.type == google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED) {
123      this.linearAdPlaying = true;
124    } else if (event.type == google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED) {
125      this.linearAdPlaying = false;
126    } 
127    if( event.type == google.ima.AdEvent.Type.COMPLETE ){
128      document.querySelector("#vrize-close").style.display = "block";
129      setTimeout(()=>{
130        document.querySelector("#vrize-close").classList.add("cab");
131      },1000);
132    }
133  };
134  
135  Italpress_Video_Vrize.prototype.onPlaylistItemClick = function(event) {
136    if (!this.linearAdPlaying) {
137      if (!this.initialized) {
138        // Handles the case where the user loads the page, clicks a playlist item
139        // immediately, and never clicks the play button on the player.
140        this.init();
141      }
142      this.player.ima.setContentWithAdTag(
143          this.contents[event.target.id],
144          null);
145      document.querySelector("#italpress-video-fluid h2").innerHTML = this.titles[event.target.id];
146      this.player.poster(this.posters[event.target.id]);
147      this.player.ima.requestAds();
148    }
149    this.playlistItemClicked = true;
150  };
151  

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.