-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
372 lines (315 loc) · 14.5 KB
/
script.js
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
// Obere Reihe der buttons "Patent", "Marke", "Muster"
function setActiveButton(buttonIndex) {
// Get all buttons
const buttons = document.getElementsByClassName("top-row");
// Remove the 'active' class from all buttons
for (let i = 0; i < buttons.length; i++) {
buttons[i].classList.remove("active");
}
// Add the 'active' class to the clicked button
buttons[buttonIndex].classList.add("active");
}
// Nach Klick auf top-row button entsprechende Elemente ein/ausblenden
// Nicht schön, aber funktioniert...
function toggleVisibility(IPType) {
if (IPType == "patent") {
var elements = document.getElementsByClassName("patent");
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
if (element.nodeName.toLowerCase() === 'a' || element.nodeName.toLowerCase() === 'button' || element.nodeName.toLowerCase() === 'h3') {
// Check if inside a span = inside a dropdown:
var isInSpan = element.closest('span');
if (isInSpan || element.nodeName.toLowerCase() === 'h3') {
element.style.display = 'block';
} else {
element.style.display = 'inline';
}
}
else {
element.style.display = 'flex';
}
}
var elements = document.getElementsByClassName("marke");
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
element.style.display = 'none';
}
var elements = document.getElementsByClassName("muster");
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
element.style.display = 'none';
}
}
if (IPType == "marke") {
var elements = document.getElementsByClassName("patent");
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
element.style.display = 'none';
}
var elements = document.getElementsByClassName("marke");
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
if (element.nodeName.toLowerCase() === 'a' || element.nodeName.toLowerCase() === 'button') {
element.style.display = 'inline';
}
else {
element.style.display = 'flex';
}
}
var elements = document.getElementsByClassName("muster");
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
element.style.display = 'none';
}
}
if (IPType == "muster") {
var elements = document.getElementsByClassName("patent");
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
element.style.display = 'none';
}
var elements = document.getElementsByClassName("marke");
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
element.style.display = 'none';
}
var elements = document.getElementsByClassName("muster");
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
if (element.nodeName.toLowerCase() === 'a' || element.nodeName.toLowerCase() === 'button') {
element.style.display = 'inline';
}
else {
element.style.display = 'flex';
}
}
}
}
// Function to get URL parameter by name
function getQueryParam(param) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param);
}
// Initialize page based on URL parameter on page load
document.addEventListener('DOMContentLoaded', () => {
// Get the 'tab' parameter from the URL, default to 'patent' if not provided
const tab = getQueryParam('tab') || 'patent';
// Mapping of tab names to button indices
const tabToIndex = { 'patent': 0, 'marke': 1, 'muster': 2 };
// Show the corresponding section and set the active button
toggleVisibility(tab);
setActiveButton(tabToIndex[tab]);
});
function jumpToEPC() {
x = prompt("Artikel: a87\nAusfO: r12a\nGebO: g2");
if(/[aA][1-9][0-9]{0,2}[a-z]{0,1}/.test(x)) {
window.location = "https://www.epo.org/de/legal/epc/2020/a" + x.substring(1) + ".html"
}
else if(/[rR][1-9][0-9]{0,2}[a-z]{0,1}/.test(x)) {
window.location = "https://www.epo.org/de/legal/epc/2020/r" + x.substring(1) + ".html"
}
else if(/[fFgG][1-9][0-9]{0,1}[a-z]{0,1}/.test(x)) {
window.location = "https://www.epo.org/de/legal/epc/2020/f" + x.substring(1) + ".html"
}
//else {
// window.location = "https://www.epo.org//law-practice/legal-texts/html/epc/2020/d/index.html"
//}
}
function jumpToPCT() {
x = prompt("Artikel: a19\nAusfO: r13bis\nVerwV: v104");
if(/[aA][1-9][0-9]{0,2}[a-z]{0,9}/.test(x)){
window.location = "https://www.wipo.int/pct/de/texts/articles/a" + x.substring(1) + ".html"
}
else if(/[rR][1-9][0-9]{0,2}[a-z]{0,9}/.test(x)){
window.location = "https://www.wipo.int/pct/en/texts/rules/r" + x.substring(1) + ".html"
}
else if(/[sSvV][1-9][0-9]{2}[a-z]{0,9}/.test(x)){
window.location = "https://www.wipo.int/pct/en/texts/ai/s" + x.substring(1) + ".html"
}
//else {
// window.location = "https://www.wipo.int/pct/de/texts/index.html"
//}
}
function jumpToPatG() {
x = prompt("PatG 1970, bitte gewünschten Paragraphen eingeben:");
if(/[1-9][0-9]{0,2}[a-z]{0,1}/.test(x)) {
window.location = "http://www.ris.bka.gv.at/Ergebnis.wxe?Abfrage=Bundesnormen&Index=&Titel=Patentgesetz&VonParagraf=" + x + "&BisParagraf=" + x + "&SkipToDocumentPage=true"
}
//else {
// window.location = "https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=10002181"
//}
}
function jumpToRL() {
a = prompt("EPA Prüfungsrichtlinien 2023, Teil und Kapitel (zB d3) eingeben:");
if(a.substring(1) == "1") {x = "i";}
else if(a.substring(1) == "2") {x = "ii"}
else if(a.substring(1) == "3") {x = "iii"}
else if(a.substring(1) == "4") {x = "iv"}
else if(a.substring(1) == "5") {x = "v"}
else if(a.substring(1) == "6") {x = "vi"}
else if(a.substring(1) == "7") {x = "vii"}
else if(a.substring(1) == "8") {x = "viii"}
else if(a.substring(1) == "9") {x = "ix"}
else if(a.substring(1) == "10") {x = "x"}
else if(a.substring(1) == "11") {x = "xi"}
else if(a.substring(1) == "12") {x = "xii"}
else if(a.substring(1) == "13") {x = "xiii"}
else if(a.substring(1) == "14") {x = "xiv"}
window.location = "https://www.epo.org/de/legal/guidelines-epc/2023/" + a.substring(0,1).toLowerCase() + "_" + x + ".html";
}
function jumpToRIS() {
x = prompt("Bitte Abkürzung des Gesetzes eingeben:");
a = "";
if(["abgb"].includes(x.toLowerCase())) {a = "10001622"}
else if(["patg"].includes(x.toLowerCase())) {a = "10002181"}
else if(["schzg"].includes(x.toLowerCase())) {a = "10003470"}
else if(["hlschg"].includes(x.toLowerCase())) {a = "10002876"}
else if(["sortschg"].includes(x.toLowerCase())) {a = "20001503"}
else if(["ppg"].includes(x.toLowerCase())) {a = "20010791"}
else if(["urhg"].includes(x.toLowerCase())) {a = "10001848"}
else if(["uwg"].includes(x.toLowerCase())) {a = "10002665"}
else if(["pag"].includes(x.toLowerCase())) {a = "20003819"}
else if(["gmg"].includes(x.toLowerCase())) {a = "10003230"}
else if(["patawg"].includes(x.toLowerCase())) {a = "10002093"}
else if(["bvg", "b-vg"].includes(x.toLowerCase())) {a = "10000138"}
else if(["patv-eg", "patveg", "patv eg"].includes(x.toLowerCase())) {a = "10002458"}
else if(["stgb"].includes(x.toLowerCase())) {a = "10002296"}
else if(["fagg"].includes(x.toLowerCase())) {a = "20008847"}
else if(["kschg"].includes(x.toLowerCase())) {a = "10002462"}
else if(["zpo"].includes(x.toLowerCase())) {a = "10001699"}
else if(["ug"].includes(x.toLowerCase())) {a = "20002128"}
else if(["stvo"].includes(x.toLowerCase())) {a = "10011336"}
if(a.length > 0) {
window.location = "https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=" + a;
}
}
// swipe gestures
document.addEventListener('DOMContentLoaded', function() {
var startX;
document.addEventListener('touchstart', function(event) {
startX = event.touches[0].clientX;
});
document.addEventListener('touchend', function(event) {
var endX = event.changedTouches[0].clientX;
var deltaX = endX - startX;
// get currently active top-row button
var allButtons = Array.from(document.getElementsByClassName("top-row"));
if (deltaX > 100) {
// Right swipe -> move selected button to the left
if (allButtons[1].classList.contains("active")) {
toggleVisibility('patent');
setActiveButton(0);
history.replaceState(null, '', `?tab=patent`);
}
else if (allButtons[2].classList.contains("active")) {
toggleVisibility('marke');
setActiveButton(1);
history.replaceState(null, '', `?tab=marke`);
}
} else if (deltaX < -100) {
// Left swipe -> move selected button to the right
if (allButtons[1].classList.contains("active")) {
toggleVisibility('muster');
setActiveButton(2);
history.replaceState(null, '', `?tab=muster`);
}
else if (allButtons[0].classList.contains("active")) {
toggleVisibility('marke');
setActiveButton(1);
history.replaceState(null, '', `?tab=marke`);
}
}
});
});
// left/right arrow keys
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('keydown', function(event) {
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
var allButtons = Array.from(document.getElementsByClassName("top-row"));
if (allButtons[0].classList.contains("active") && event.key === 'ArrowRight') {
toggleVisibility('marke');
setActiveButton(1);
history.replaceState(null, '', `?tab=marke`);
}
else if (allButtons[1].classList.contains("active") && event.key === 'ArrowRight') {
toggleVisibility('muster');
setActiveButton(2);
history.replaceState(null, '', `?tab=muster`);
}
else if (allButtons[1].classList.contains("active") && event.key === 'ArrowLeft') {
toggleVisibility('patent');
setActiveButton(0);
history.replaceState(null, '', `?tab=patent`);
}
else if (allButtons[2].classList.contains("active") && event.key === 'ArrowLeft') {
toggleVisibility('marke');
setActiveButton(1);
history.replaceState(null, '', `?tab=marke`);
}
}
});
});
document.addEventListener('DOMContentLoaded', function() {
// Font Awesome icon as HTML
const symbol = '  <span class="fa-solid fa-file-text"></span>';
// Select all <a> elements with an href attribute ending in .pdf
document.querySelectorAll('a[href$=".pdf"]').forEach(function(link) {
// Get the corresponding button inside the link, if it exists
const button = link.querySelector('button');
if (button) {
// Append the Font Awesome icon to the button text using innerHTML
button.innerHTML += symbol; // Use innerHTML to add HTML content
} else {
// Get the button element that is outside the <a> tag (if <a> is inside a <button>)
const parentButton = link.closest('button');
if (parentButton) {
// Append the Font Awesome icon to the <a> element's text content using innerHTML
link.innerHTML += symbol; // Use innerHTML to add HTML content
}
}
});
});
document.addEventListener('DOMContentLoaded', function() {
let navigationUrl = ""; // Variable to store the clicked URL
document.querySelectorAll('a, .dropdown-content a').forEach(link => {
link.addEventListener('click', function (e) {
// Check if Ctrl key is held or if it's a middle mouse click (button 1)
if (e.ctrlKey) {
return; // Skip overlay and allow normal behavior: open in new tab
}
// Check if href is empty
if (!link.href) {
return; // Skip overlay and allow normal behavior: open in new tab
}
// Store the clicked link URL
navigationUrl = link.href;
// Check if the link ends with .pdf and skip overlay if it does
if (link.href.endsWith('.pdf')) {
return; // Exit the event handler without further actions
}
e.preventDefault(); // Prevent navigation temporarily for non-PDF links
const overlay = document.getElementById('loadingOverlay');
overlay.style.display = 'flex';
// Save state in sessionStorage to detect back navigation
sessionStorage.setItem('overlayShown', 'true');
// Trigger actual navigation after showing overlay
window.location.href = link.href;
});
});
// Show overlay on page unload if not a .pdf link and not a reload
window.addEventListener('beforeunload', function () {
// Only show the overlay if the navigation URL does not end with .pdf and it's not a reload
if (!navigationUrl.endsWith('.pdf') && performance.navigation.type !== 1) {
const overlay = document.getElementById('loadingOverlay');
overlay.style.display = 'flex';
}
});
// Hide overlay if navigating back
window.addEventListener('pageshow', function (event) {
const overlay = document.getElementById('loadingOverlay');
if (sessionStorage.getItem('overlayShown') === 'true' && event.persisted) {
overlay.style.display = 'none'; // Hide overlay if returning to the page
sessionStorage.removeItem('overlayShown'); // Clear the flag for the next session
}
});
});