-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
186 lines (157 loc) · 6.86 KB
/
Copy pathscript.js
File metadata and controls
186 lines (157 loc) · 6.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// bgImages
const bgImages = [
'url("images/milky-way.jpg")',
'url("images/matrix-bg.gif")',
'url("images/result_AI.png")',
'url("images/Satellite_1_.jpg")',
'url("images/Big-SAT.jpg")'
];
// Може да е МИКС – Vimeo ID, Vimeo URL, YouTube, Drive preview, .mp4/.webm:
const videos = [
'1103921662', // Vimeo (само ID) – твоят дефолтен
'1126968160', // Viemo Invideo 2
'https://youtu.be/ozfdYn97QFs',
'https://player.vimeo.com/video/355087337',
// 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
'https://www.youtube.com/watch?v=SZRXy_jfWU0&list=PL4B1948130C2A7468',
// 'https://youtu.be/dQw4w9WgXcQ',
// 'https://drive.google.com/file/d/FILE_ID/preview',
//'https://drive.google.com/file/d/177Wsg30E4tMZ2HYYA_iaRxAhEwgn6LZK/view?usp=sharing',
// 'videos/demo.mp4'
];
let currentBgIndex = -1;
let currentVideoIdx = -1;
let originalHeaderContent = null;
function buildEmbedHTML(input) {
const s = String(input).trim();
// Vimeo: чисто числов ID (минимум 6 цифри счита се за ID)
const isNumericId = /^\d{6,}$/.test(s);
// Vimeo URL
const vimeoMatch = s.match(/vimeo\.com\/(?:video\/)?(\d+)/i);
if (isNumericId || vimeoMatch) {
const id = isNumericId ? s : vimeoMatch[1];
const src = `https://player.vimeo.com/video/${id}?autoplay=1&loop=1&muted=0&background=1&playsinline=1`;
return `<iframe src="${src}" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>`;
}
// YouTube
if (/youtu\.be\/|youtube\.com\/watch\?v=|youtube\.com\/embed\//i.test(s)) {
let videoId = '';
const m1 = s.match(/youtube\.com\/watch\?v=([^&]+)/i);
const m2 = s.match(/youtu\.be\/([^?&]+)/i);
const m3 = s.match(/youtube\.com\/embed\/([^?&]+)/i);
if (m1) videoId = m1[1];
else if (m2) videoId = m2[1];
else if (m3) videoId = m3[1];
if (!videoId) throw new Error('YouTube-Link ohne Video-ID.');
const src = `https://www.youtube.com/embed/${videoId}?autoplay=1&mute=0&loop=1&playlist=${videoId}&playsinline=1&modestbranding=1&controls=0`;
return `<iframe src="${src}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>`;
}
// Google Drive (/preview е задължителен)
if (/drive\.google\.com\/file\/.*\/(preview|view)/i.test(s)) {
const preview = s.replace(/\/view(\?[^"]*)?$/i, '/preview');
return `<iframe src="${preview}" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>`;
}
// Директни файлове
if (/\.(mp4|webm)(\?.*)?$/i.test(s)) {
const type = s.toLowerCase().endsWith('.webm') ? 'webm' : 'mp4';
return `
<video controls autoplay muted loop playsinline>
<source src="${s}" type="video/${type}">
Ihr Browser unterstützt dieses Video nicht.
</video>`;
}
// Фолбек – приемаме iframe
return `<iframe src="${s}" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>`;
}
function activateSmartHome() {
const header = document.getElementById('header');
const main = document.getElementById('main-content');
if (!header) { console.error('#header nicht gefunden'); return; }
if (originalHeaderContent === null) {
originalHeaderContent = header.innerHTML;
}
// следващо видео
currentVideoIdx = (currentVideoIdx + 1) % videos.length;
const embed = buildEmbedHTML(videos[currentVideoIdx]);
header.innerHTML = `
<div class="video-crop-container">
${embed}
<div class="video-overlay" id="video-overlay">
<h1>SMART HOME – Willkommen in der Zukunft!!!</h1>
</div>
</div>
<button onclick="restoreWelcomeText()" class="video-close-btn" aria-label="Close">×</button>
`;
// overlay hide след 4 секунди
const overlay = document.getElementById('video-overlay');
if (overlay) {
overlay.style.opacity = '1';
setTimeout(() => {
let o = 1;
const step = setInterval(() => {
o -= 0.05;
overlay.style.opacity = String(o);
if (o <= 0) { clearInterval(step); overlay.style.display = 'none'; }
}, 100);
}, 4000);
}
// завърти background-а
if (main) {
currentBgIndex = (currentBgIndex + 1) % bgImages.length;
main.style.backgroundImage = bgImages[currentBgIndex];
}
}
function restoreWelcomeText() {
const header = document.getElementById('header');
if (!header) return;
if (originalHeaderContent !== null) {
header.innerHTML = originalHeaderContent;
}
currentVideoIdx = -1;
}
/* ===========================
ДОБАВЕНО: старт от точни индекси
(ползва стандартното activateSmartHome и цикъла му)
=========================== */
function showTopVideoInfo(msg, ms = 3500) {
// updateStatus() е в index.html долу
if (typeof updateStatus === "function") {
updateStatus(msg);
clearTimeout(window.__statusTimer);
window.__statusTimer = setTimeout(() => updateStatus(""), ms);
}
}
function startPreset(videoIndex0, bgIndex0, msg) {
// activateSmartHome() прави +1 първо => задаваме една стъпка назад
currentVideoIdx = videoIndex0 - 1;
currentBgIndex = bgIndex0 - 1;
activateSmartHome(); // стандартното (цикълът си остава)
showTopVideoInfo(msg);
}
document.addEventListener("DOMContentLoaded", () => {
// Хващаме картите по точните им H3 заглавия от index.html
const h3s = Array.from(document.querySelectorAll("h3"));
const smartH3 = h3s.find(h => (h.textContent || "").trim() === "🏡 SMART HOME Lösungen");
const ivanH3 = h3s.find(h => (h.textContent || "").trim() === "🔧 Handwerkspartner-Netzwerk");
// Карта = най-близкия div.bg-white (точно твоите cards)
const smartCard = smartH3 ? smartH3.closest("div.bg-white") : null;
const ivanCard = ivanH3 ? ivanH3.closest("div.bg-white") : null;
// SMART HOME: 2-ри клип (videos[1]) + 2-ри фон (bgImages[1] = matrix)
if (smartCard) {
smartCard.style.cursor = "pointer";
smartCard.addEventListener("click", (e) => {
// ако потребителят клика линк вътре, не му пречим
if (e.target && e.target.closest && e.target.closest("a")) return;
startPreset(1, 1, "🎬 Видео пример е отворено горе (SMART HOME).");
// Ако искаш сателит фон вместо matrix: startPreset(1, 3, "..."); // bgImages[3]
});
}
// Handwerkspartner / Ivan: 4-ти клип (videos[3]) + звезди (bgImages[0] = milky-way)
if (ivanCard) {
ivanCard.style.cursor = "pointer";
ivanCard.addEventListener("click", (e) => {
if (e.target && e.target.closest && e.target.closest("a")) return;
startPreset(3, 0, "🎬 Видео пример е отворено горе (Handwerkspartner / Ivan).");
});
}
});