PageSourceSearch

https://www.mosel-inside.de/templates/shaper_helixultimate/js/favorites.js

js mosel-inside.de collected 2026-10-08 23:37:24 UTC 14,006 bytes, 161 lines download raw bytes

1function InitFavorites() {
2	(function ($) {
3		// document.getElementById('clicka').click();
4
5		// get favorites from local storage or empty array
6		var favorites = JSON.parse(localStorage.getItem('favorites')) || [];
7
8
9
10		// add class 'fav' to each favorite
11		setTimeout(function () {
12			favorites.forEach(function (favorite) {
13				var Item = $("#" + favorite);
14				if (Item) {
15					$(Item).addClass('fav');
16					if (document.documentElement.lang == "en-gb") {
17						$("#" + favorite).attr("data-original-title", "<b>Travel planner</b><br />Entry saved!");
18					} else {
19
20						$("#" + favorite).attr("data-original-title", "<b>Reiseplaner</b><br />Eintrag gespeichert!");
21					}
22				}
23			});
24		}, 300);
25
26		// register click event listener
27		$(".reiseplaner").on("click", function (e) {
28			var id = e.target.id,
29				item = e.target,
30				index = favorites.indexOf(id);
31			// return if target doesn't have an id (shouldn't happen)
32			if (!id) return;
33			// item is not favorite
34			if (index == -1) {
35				favorites.push(id);
36				item.className = 'fav';
37				$(item).tooltip('hide')
38				if (document.documentElement.lang == "en-gb") {
39					$(item).attr("data-original-title", "<b>Travel planner</b><br />Entry saved!");
40				} else {
41					$(item).attr("data-original-title", "<b>Reiseplaner</b><br />Eintrag gespeichert!");
42				}
43				$(item).tooltip('show');
44
45				// item is already favorite
46			} else {
47				favorites.splice(index, 1);
48				item.className = '';
49				$(item).tooltip('hide')
50				if (document.documentElement.lang == "en-gb") {
51					$(item).attr("data-original-title", "<b>Travel planner</b><br />Save entry in travel planner?");
52				} else {
53					$(item).attr("data-original-title", "<b>Reiseplaner</b><br />Eintrag im Reiseplaner speichern?");
54				}
55				$(item).tooltip('show');
56				if ($(".itemid-815").length) {
57					document.getElementById(id).className = 'd-none';
58				}
59			}
60
61			// store array in local storage
62			localStorage.setItem('favorites', JSON.stringify(favorites));
63			writetolink();
64		});
65
66
67		if (document.documentElement.lang == "en-gb") {
68			var menupunkt = "/travelplaner";
69		} else {
70			var menupunkt = "/reiseplaner";
71		}
72
73		function writetolink() {
74			var urlparameters = "?";
75			favorites.forEach(function (favorite, index) {
76				if (index != 0) {
77					urlparameters = urlparameters + "&id[]=" + favorite;
78				} else {
79					urlparameters = urlparameters + "id[]=" + favorite;
80				}
81			});
82			document.getElementById("reiseplanerlink").href = menupunkt // + urlparameters;
83			document.getElementById("counterbadge").innerHTML = length(favorites);
84			if (document.querySelector('.itemid-815')) {
85				
86				if (document.documentElement.lang == "en-gb") {
87					var lang = "en";
88				} else {
89					var lang = "de";
90				}
91				var url = "https://www.mosel-inside.de/" + lang + menupunkt + urlparameters;
92				document.getElementById("facebook").href = "https://www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(url);
93				document.getElementById("twitter").href = "https://twitter.com/home?status=" + encodeURIComponent(url);
94				document.getElementById("whatsapp").href = "whatsapp://send?text=" + url;
95				document.getElementById("PreparePdf").href = menupunkt + urlparameters;
96				if (window.location.href.indexOf('?id[]=') > 0) {
97    				$('#printPdf').show();
98					$('#PreparePdf').hide();
99					} else {
100						$('#printPdf').hide();
101						$('#PreparePdf').show();
102					}
103			}
104		}
105
106		function length(obj) {
107			return Object.keys(obj).length;
108		}
109		writetolink();
110
111		if (document.querySelector('.itemid-815')) { // Steuerung der Reiseplaner-Seite
112			var oldLocation = location.href;
113			if (oldLocation.indexOf("?id[]=") > -1) { // wenn IDs in URL vorhanden sind, in Favorites schreiben
114				var urlIDs = oldLocation.split("?id[]=")
115				var urlIDs = urlIDs[1].split("&id[]=")
116
117
118
119				urlIDs.forEach(function (id) {
120					if (favorites.indexOf(id) > -1) {} else {
121						favorites.push(id);
122					}
123
124				});
125			}
126			if (favorites.length == 0) {
127				if (document.documentElement.lang == "en-gb") {
128					$("#itemListSecondary").html('<div class="col-12"><div class="noentries"><p>You have not yet added any tips to the travel planner.</p></div></div><div class="itemList noitems"><div class="row"><div class="col-md-4 itemContainer"><figure class="" itemprop="blogPost" itemscope="itemscope" itemtype="https://schema.org/BlogPosting"><div class="article-body"><div class="article-introtext"><div class="wrp"><img src="/images/stories/teaserbilder/unterkuenfte.jpg" class="itemimage"> <a class="itemlink" href="/en/hosts/accommodations.html" title="Accomodations along the Mosel">Read more</a><div class="figcaption"><h3 itemprop="name">Accomodations</h3><h4 class="ort">The best accomodations along the Mosel</h4><p>As diverse as the Mosel is, so diverse are the accommo&shy;dations. Around 50.000 guest beds are avail&shy;able through&shy;out the Mosel region.</p></div></div></div></div></figure></div><div class="col-md-4 itemContainer"><figure class="" itemprop="blogPost" itemscope="itemscope" itemtype="https://schema.org/BlogPosting"><div class="article-body"><div class="article-introtext"><div class="wrp"><img src="/images/stories/teaserbilder/essen-trinken.jpg" alt="Food &amp; Drinks at the Mosel" class="itemimage"> <a class="itemlink" href="/en/hosts/food-drinks.html" title="Food &amp; Drinks along the Mosel">Read more</a><div class="figcaption"><h3 itemprop="name">Food &amp; Drinks</h3><h4 class="ort">The best restaurants &amp; bars along the Mosel</h4><p>You will find a variety of restau&shy;rants, from the gourmet restau&shy;rant to the typical Mosel cuisine on the Mosel.</p></div></div></div></div></figure></div><div class="col-md-4 itemContainer"><figure class="" itemprop="blogPost" itemscope="itemscope" itemtype="https://schema.org/BlogPosting"><div class="article-body"><div class="article-introtext"><div class="wrp"><img src="/images/stories/teaserbilder/wein.jpg" alt="Wine hosts at the Mosel" class="itemimage"> <a class="itemlink" href="/en/hosts/wine.html" title="Wine hosts along the Mosel">Read more</a><div class="figcaption"><h3 itemprop="name">Wine - Hosts</h3><h4 class="ort">The best wine&shy;ries along the Mosel</h4><p>As you know, every&shy;thing revolves around wine on the Mosel - here you will find the best wineries along the Mosel.</p></div></div></div></div></figure></div><div class="col-md-4 itemContainer"><figure class="" itemprop="blogPost" itemscope="itemscope" itemtype="https://schema.org/BlogPosting"><div class="article-body"><div class="article-introtext"><div class="wrp"><img src="/images/stories/teaserbilder/sehenswertes.jpg" alt="Attractions at the Mosel" class="itemimage"> <a class="itemlink" href="/en/activities/attractions.html" title="Attractions along the Mosel">Read more</a><div class="figcaption"><h3 itemprop="name">Attractions</h3><h4 class="ort">The most beauti&shy;ful sights of the Mosel valley</h4><p>No matter on which bank or on which vineyard you are stan&shy;ding right now - the Mosel always surprises with new breath&shy;taking views and buil&shy;dings.</p></div></div></div></div></figure></div><div class="col-md-4 itemContainer"><figure class="" itemprop="blogPost" itemscope="itemscope" itemtype="https://schema.org/BlogPosting"><div class="article-body"><div class="article-introtext"><div class="wrp"><img src="/images/stories/teaserbilder/kultur.jpg" alt="Leisure &amp; Culture at the Mosel" class="itemimage"> <a class="itemlink" href="/en/activities/leisure-culture.html" title="Leisure &amp; Culture along the Mosel">Read more</a><div class="figcaption"><h3 itemprop="name">Leisure &amp; Culture</h3><h4 class="ort">
128Learn to love the Mosel cosiness</h4><p>Hardly any other landscape is as charac&shy;terized by cultural diver&shy;sity as the Mosel.</p></div></div></div></div></figure></div><div class="col-md-4 itemContainer"><figure class="" itemprop="blogPost" itemscope="itemscope" itemtype="https://schema.org/BlogPosting"><div class="article-body"><div class="article-introtext"><div class="wrp"><img src="/images/stories/teaserbilder/freizeit.jpg" alt="Exercise &amp; Sport at the Mosel" class="itemimage"> <a class="itemlink" href="/en/activities/exercise-sport.html" title="Exercise &amp; Sport along the Mosel">Read more</a><div class="figcaption"><h3 itemprop="name">Exercise &amp; Sport</h3><h4 class="ort">The best activities at the Mosel</h4><p>The beauti&shy;ful Mosel valley with all its scenic attrac&shy;tions offers its guests a wide range of activi&shy;ties.</p></div></div></div></div></figure></div></div></div>');
129				} else {
130					$("#itemListSecondary").html('<div class="col-12"><div class="noentries"><p>Sie haben bisher keine Tipps zum Reiseplaner hinzugefügt.</p></div></div><div class="itemList noitems"><div class="row"><div class="col-md-4 itemContainer"><figure class="animated fadeInUp vcard "><div class="wrp"><img class="itemimage" src="/images/stories/teaserbilder/unterkuenfte.jpg" alt="Unterkünfte an der Mosel" itemprop="image"> <a class="itemlink" href="/de/gastgeber/unterkuenfte.html"></a><div class="figcaption"><a href="/de/gastgeber/unterkuenfte.html"><div class="CatItemHeader"><h3 itemprop="name">Unterkünfte</h3><h4 class="ort">Die besten Unter&shy;künfte entlang der Mosel</h4></div><div class="CatItemIntroText">So viel&shy;fältig die Mosel ist, so viel&shy;fältig sind auch die Unter&shy;künfte. Rund 50.000 Gäste&shy;betten stehen Ihnen in der gesamten Mosel&shy;region zu Auswahl.</div></a></div></div></figure></div><div class="col-md-4 itemContainer"><figure class="animated fadeInUp vcard "><div class="wrp"><img class="itemimage" src="/images/stories/teaserbilder/essen-trinken.jpg" alt="Essen &amp; Trinken an der Mosel" itemprop="image"> <a class="itemlink" href="/de/gastgeber/essen-trinken.html"></a><div class="figcaption"><a href="/de/gastgeber/essen-trinken.html"><div class="CatItemHeader"><h3 itemprop="name">Essen &amp; Trinken</h3><h4 class="ort">Die besten Restaurants &amp; Bars an der Mosel</h4></div><div class="CatItemIntroText">Viel&shy;fältige Gastro&shy;nomie, vom Gourmet&shy;restau&shy;rant bis hin zur typisch mosel&shy;ländisch&shy;en Küche, ist an der Mosel zu finden.</div></a></div></div></figure></div><div class="col-md-4 itemContainer"><figure class="animated fadeInUp vcard "><div class="wrp"><img class="itemimage" src="/images/stories/teaserbilder/wein.jpg" alt="Wein Gastgeber an der Mosel" itemprop="image"> <a class="itemlink" href="/de/gastgeber/wein.html"></a><div class="figcaption"><a href="/de/gastgeber/wein.html"><div class="CatItemHeader"><h3 itemprop="name">Wein - Gastgeber</h3><h4 class="ort">Die besten Wein&shy;güter entlang der Mosel</h4></div><div class="CatItemIntroText">An der Mosel dreht sich bekannt&shy;lich alles um den Wein - hier finden Sie die besten Wein&shy;güter entlang der Mosel.</div></a></div></div></figure></div><div class="col-md-4 itemContainer"><figure class="animated fadeInUp vcard "><div class="wrp"><img class="itemimage" src="/images/stories/teaserbilder/sehenswertes.jpg" alt="Sehenswertes an der Mosel" itemprop="image"> <a class="itemlink" href="/de/aktivitaeten/sehenswertes.html"></a><div class="figcaption"><a href="/de/aktivitaeten/sehenswertes.html"><div class="CatItemHeader"><h3 itemprop="name">Sehenswertes</h3><h4 class="ort">Die schönsten Sehens&shy;würdig&shy;keiten des Mosel&shy;tals</h4></div><div class="CatItemIntroText">Egal an welchem Ufer oder auf wel&shy;chem Wein&shy;hang Sie gerade stehen – die Mosel über&shy;rascht immer wieder mit neuen atem&shy;berauben&shy;den Aus&shy;blicken und Bauwerken.</div></a></div></div></figure></div><div class="col-md-4 itemContainer"><figure class="animated fadeInUp vcard "><div class="wrp"><img class="itemimage" src="/images/stories/teaserbilder/kultur.jpg" alt="Freizeit &amp; Kultur an der Mosel" itemprop="image"> <a class="itemlink" href="/de/aktivitaeten/freizeit-kultur.html"></a><div class="figcaption"><a href="/de/aktivitaeten/freizeit-kultur.html"><div class="CatItemHeader"><h3 itemprop="name">Freizeit &amp; Kultur</h3><h4 class="ort">Lernen Sie die mosel&shy;ländische Gemüt&shy;lich&shy;keit lieben</h4></div><div class="CatItemIntroText">Kaum eine andere Land&shy;schaft wird so durch kultu&shy;relle Vielfalt geprägt wie die Mosel.</div></a></div></div></figure></div><div class="col-md-4 itemContainer"><figure class="animated fadeInUp vcard "><div class="wrp"><img class="itemimage" src="/images/stories/teaserbilder/freizeit.jpg" alt="Bewegung &amp; Sport an der Mosel" itemprop="image">
130 <a class="itemlink" href="/de/aktivitaeten/bewegung-sport.html"></a><div class="figcaption"><a href="/de/aktivitaeten/bewegung-sport.html"><div class="CatItemHeader"><h3 itemprop="name">Bewegung &amp; Sport</h3><h4 class="ort">Die besten Aktiv&shy;angebote der Mosel</h4></div><div class="CatItemIntroText">Das wunder&shy;schöne Mosel&shy;tal mit all seinen land&shy;schaft&shy;lichen Reizen bietet seinen Gästen ein breit&shy;gefächer&shy;tes Aktiv&shy;angebot.</div></a></div></div></figure></div></div></div>');
131				}
132			} else {
133				favorites.forEach(function (favorite) {
134
135					var Item = document.querySelector('.itemid-' + favorite);
136					if (Item) {
137						document.getElementById(favorite).className = 'fav';
138						document.querySelector('[id="' + favorite + '"] .reiseplaner a').className = 'fav';
139						$('#' + favorite + ' .itemimage').attr("src",$('#' + favorite + ' .itemimage').attr("data-src"));
140						
141					}
142				});
143				$('#k2Container').css('background-image', 'none');
144			}
145			writetolink();
146			localStorage.setItem('favorites', JSON.stringify(favorites));
147
148
149		};
150		document.querySelectorAll('.reiseplaner .fav').forEach(function (actelem) {
151			if (document.documentElement.lang == "en-gb") {
152				$(actelem).attr("data-original-title", "<b>Travel planner</b><br />Click to remove");
153			} else {
154				$(actelem).attr("data-original-title", "<b>Reiseplaner</b><br />zum Löschen klicken");
155			}
156
157		});
158	})(jQuery);
159
160}
161InitFavorites();

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.