PageSourceSearch

https://www.comunitatvalenciana.com/o/main-theme/js/webcam-refresh.js

js comunitatvalenciana.com collected 2026-10-01 10:34:09 UTC 2,993 bytes, 99 lines download raw bytes

1(function() {
2	"use strict";
3
4	const selectors = {
5		webcam : "img.is-webcam",
6		webcam1 : "img.is-webcam-1",
7		webcam2 : "img.is-webcam-2",
8		webcam3 : "img.is-webcam-3"
9	};
10	let lastWebcam = "img.is-webcam-3";
11	
12	function refreshWebCam() {
13		setTimeout(function(){
14			refreshWebcamInTime().then(function(){				
15					refreshWebCam();						
16			}.bind(this));
17		}.bind(this),1500);
18
19	}
20
21	var refreshWebcamInTime = function(){
22		return new Promise(function(resolve, reject) {
23			var webcam = $(selectors.webcam1);
24			if(lastWebcam == selectors.webcam1){
25				webcam = $(selectors.webcam2);
26				lastWebcam = selectors.webcam2;
27			}else if(lastWebcam == selectors.webcam2){
28				webcam = $(selectors.webcam3);
29				lastWebcam = selectors.webcam3;
30			}else{
31				lastWebcam = selectors.webcam1;
32			}
33			
34			//var webcam = $(selectors.webcam);		
35			webcam.each(function(index) {
36				setTimeout(function(){					
37					webcam[index].getAttribute("src")
38					var url = webcam[index].getAttribute("src").split("?")[0];
39					webcam[index].setAttribute("src", url.concat("?")
40							.concat(Date.now()));					
41					/*var parentWebcam=webcam[index].parentElement;
42					if(!parentWebcam.classList.contains("position-relative")){
43						//add
44						parentWebcam.classList.add("position-relative");
45						var div = document.createElement("div");
46						div.style.bottom=0;
47						div.style.right=0;
48						div.classList.add("position-absolute","mb-0","mr-0","text-right");												
49						var p = document.createElement("p");
50						p.classList.add("bg-white","m-0","pl-1","pr-1","font-weight-normal");											
51						p.innerText = new Date().toLocaleString();
52						div.append(p);
53						parentWebcam.append(div);
54					}else{
55						//refresh						
56						parentWebcam.querySelector("div p").innerText = new Date().toLocaleString();	
57					}*/
58					webcam[index].style.zIndex = parseInt(webcam[index].style.zIndex)+3;
59					if((index + 1) == webcam.length){
60						resolve();
61					}
62				}.bind(this),1500);
63				
64				
65			}.bind(this));
66		});
67	}	
68	var addTimeInWebcam = function(){
69		var webcam = $(selectors.webcam);
70		webcam.each(function(index) {
71				var url = webcam[index].getAttribute("src").split("?")[0];
72				webcam[index].setAttribute("src", url.concat("?")
73						.concat(Date.now()));				
74				/*var parentWebcam=webcam[index].parentElement;
75				if(!parentWebcam.classList.contains("position-relative")){
76					//add
77					parentWebcam.classList.add("position-relative");
78					var div = document.createElement("div");
79					div.style.bottom=0;
80					div.style.right=0;
81					//div.style.zIndex=999999999999999;
82					div.classList.add("position-absolute","mb-0","mr-0","text-right");												
83					var p = document.createElement("p");
84					p.classList.add("bg-white","m-0","pl-1","pr-1");					
85					p.innerText = new Date().toLocaleString();
86					div.append(p);
87					parentWebcam.append(div);
88				}*/
89				
90			
91			
92		}.bind(this));
93	}
94	$(window).ready(function() {
95		refreshWebCam();
96		addTimeInWebcam();
97	});
98
99})($)

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.