PageSourceSearch

https://lawis.at/profile/scripts/basic/views.js?v=2.3.5-HF1

js lawis.at collected 2026-10-02 10:29:40 UTC 12,174 bytes, 280 lines download raw bytes

1var ProfileTableView = DatabaseTableView.extend({
2     el:'.profileViewer',
3     model: null,
4
5     initialize: function() {
6        if (KGISUrlParams.get('id') === undefined) {
7            KGISUrlParams.set('focus', false);
8        } else {
9            KGISUrlParams.set('focus', true);
10		}    	 
11		var that = this;
12    	 var tableHeader = $('#tableSpace .fixedHeader');
13    	 
14    	 this._initialize('profil_id', '#profile_tbl',
15   			 function(row, className) {
16    		 	var country = KGISMapper.mapCountry(row['country_id']);
17    	    	var exposition = (row['exposition_id']) ? KGISMapper.mapDirection(row['exposition_id']) : ' ';
18    	    	var date = KGISMapper.mapDate(row['datum']); // do not show seconds -> substrs
19    	    	var created_date = row['loggedon'].substr(0, 16); // do not show seconds -> substrs
20				var title = created_date + ' in ' + KGISMapper.mapSubregion(row['subregion_id']) + ' / ' + row['ort'];
21    	    					
22				if(row['active']==0){
23					className = "inactive";
24				}
25				
26				return '<tr id="' + row['profil_id'] + '" class="' + className + '" data-orig-title="' + title + '" title="' + lbl['lbl_start_created'] + title + '" data-aspect-id="' + row['exposition_id'] + '"><td><div class="date">' 
27    	    		+ '<span class="long">' + date.asString + '</span><span class="short">' + date.asShortString + '</span></div></td><td><div>' 
28    	    		+ row['ort'] + '</div></td><td>'
29    	    		+ '<div class="country '+ country['class'] +'\"><span>'+ country.name +'<span></div></td><td><div>'
30    	    		+ KGISMapper.mapRegion(row['region_id']) + '</div></td><td><div>'
31    	    		+ row['seehoehe'] + 'm' + '</div></td><td><div>'
32    	    		+ exposition + '</div></td>'
33				    + '</tr>';
34    	 }, function(id) {
35    		 if(that.model) {
36    			 var m = that.model.get(id);
37    			 if(m) {
38    				 return m.get('datum').substr(0,16) + ' ' + m.get('ort'); 
39    			 }
40    		 }
41    		 return '';
42    	 }, new ProfileDetail(), new ProfileDetailView());
43    	 
44    	 // cluster list-plugin ordering 
45    	 that.setSortFunction(function(id1, id2) {
46    		 if(that.model) {
47    			 // order descending by date
48    			 var m1 = that.model.get(id1);
49    			 var m2 = that.model.get(id2);
50    			 if(m1 && m2) {
51    				 var d1 = m1.get('datum');
52    				 var d2 = m2.get('datum');
53    				 if(d1 < d2) {
54    					 return 1;
55    				 } else if(d1 > d2) {
56    					 return -1;
57    				 } else {
58    					 // same date -> ascending alphabetic ordering
59    					 return (m1.get('ort') < m2.get('ort')) ? -1 : 1;
60    				 }
61    			 }
62    		 }
63    		 return (id1 < id2) ? -1 : 1;
64    	 });
65     },
66     
67     render: function (profilesCollection) {
68    	 this.setModel(profilesCollection);
69    	 var that = this;
70    	 var tableBody = $('#profile_tbl tbody');
71    	 
72    	 KGISapp.addEventHandler("keyEvent:enter",function(){
73    		 var selected = tableBody.find('.selected');
74    		 if(selected.length > 0) {
75				let profile = that.model.get(selected.attr('id'));
76    			 that._open(profile,selected.attr('id'));
77    		 }
78    	 });
79    	 
80    	 KGISapp.addEventHandler('quickglance:profileSelected', function(model) {
81    		 KGISUrlParams.set('last_pid', model.get(that.idField));
82    	 });
83    	 
84          
85    	 profilesCollection.fetch({
86    		 cache: false,                        
87    		 success: function (profilList) {
88
89				if (KGISUrlParams.has('debug') && KGISUrlParams.get('debug') == 'true')
90    				console.log(" successful loaded profile metaData");
91
92    	    	//  that.parseUrlParams(['id','country', 'region', 'subregion', 'zeit', 'hoehe', 'exposition']);
93				//  todo filter 
94				 that.parseUrlParams(['id', 'season','country', 'region', 'subregion', 'zeit', 'hoehe', 'exposition']);
95    			 that.setFilters(that.getFilterValues());
96    			 that.setOrder([[0, 'desc']]);
97    			 
98    			 var id = false;
99    			 if(KGISUrlParams.has('id')) {
100    				 id = parseInt(KGISUrlParams.get('id'));
101    			 } else if( !KGISviewState.isMobileView() &&
102    			     KGISUrlParams.has('table') && KGISUrlParams.get('table') == 'true') {
103    				 
104    				 if(KGISUrlParams.has('last_pid') && $.isNumeric(KGISUrlParams.get('last_pid'))) {
105    					 id = parseInt(KGISUrlParams.get('last_pid'));
106    				 } else if(profilesCollection.length > 0) {
107    					 // get most recent one - but wait for filter update first
108    					 KGISapp.addSingleEventHandler('table:filtersSet', function() {
109    						 if(that.activeRecords.length > 0) {
110        						 var latest = that.activeRecords[0];
111            					 that.currentlySelected = latest[that.idField];
112    						 }
113    					 });
114    				 }
115    			 } else if(!KGISviewState.isMobileView()) {
116                    KGISapp.addSingleEventHandler('table:filtersSet', function() {
117                        if (that.activeRecords.length > 0) {
118                            var latest = that.activeRecords[0];
119                            that.currentlySelected = latest[that.idField];
120                        }
121                    });                
122                }
123    			 that.populateView(false, id);
124    			 
125    		 },
126    		 error: function(e) {
127
128				if (KGISUrlParams.has('debug') && KGISUrlParams.get('debug') == 'true')
129    				console.log("unable to load profiles :-\,  cause: " + e);
130    		 }
131    	 });
132     },
133     
134     _open: function(profile,id) {
135		 //check if profile region id is in editable regions od lawis admin
136		 let profile_region_id = profile['attributes']['region_id'];
137		 let profile_country_id = profile['attributes']['country_id'];
138		 if(KGISConfig.isRoot 
139			|| (KGISConfig.lwd_admin && KGISConfig['editable_regions'].includes(profile_region_id))
140		 	|| (KGISConfig.lwd_admin && KGISConfig['editable_countries'].includes(profile_country_id))) {
141    		 var params = KGISUrlParams.toQueryString();
142    		 if(params) {
143    			 params = params + '&id=' + id;
144    		 } else {
145    			 params = '?id=' + id;
146    		 }
147    		 window.location.href = 'edit.php' + params;
148    	 }
149     },
150     
151     events: function(){
152    	 var parentEvents = DatabaseTableView.prototype.events;
153    	 if(_.isFunction(parentEvents)){
154    		 parentEvents = parentEvents();
155    	 }
156    	 return _.extend({},parentEvents,{
157    	'click .tableSpace thead #class_named option' : function(e) {
158    		// IE hack (not needed in other browsers).
159    		$(e.target).closest('select').trigger('blur');
160    	},
161    	'click .tableSpace thead #class_named' : function(e) {
162    		e.stopPropagation();
163    	},
164    	'mouseenter .tableSpace thead #class_named' : function(e) {
165    		$(e.target).addClass('active');
166    	},
167    	'mouseleave .tableSpace thead #class_named' : function(e) {
168    		$(e.target).removeClass('active');
169    		document.getSelection().removeAllRanges();
170    	},
171        'dblclick #profile_tbl tbody tr' :function(event){
172
173			if (KGISUrlParams.has('debug') && KGISUrlParams.get('debug') == 'true')
174				console.log($(event.currentTarget));
175			
176			let profile = this.model.get($(event.currentTarget).attr('id'));
177			this._open(profile,$(event.currentTarget).attr('id'));
178        },		
179    	});
180    },
181    
182    attachKGISEventHandler:function(event){
183        
184    },
185});
186
187var ProfileDetailView = Backbone.View.extend({
188	initialize: function() {
189		this.setElement($('<div class="content"></div>'));
190	},
191	
192	template: function(callback) {
193		_.templateFromUrl('templates/info.tpl.php', {}, {}, callback); 
194	},
195
196	render: function(model) {
197		var that = this;
198
199		this.template(function(html) {
200			that.$el.html(html);
201
202			window.setTimeout(function() {
203				// outer accordion
204				that.$el.cartoAccordion({
205					openInitial: 0,
206				});				
207				that.populate(model);
208				// inner accordion
209				that.$el.find('>.accordion-content .accordion').cartoAccordion({
210					stayOpen: true,
211					openInitial: 0
212				});
213				that.$el.find('>.accordion-content').perfectScrollbar();
214			}, 0);
215		});
216
217		return this;
218	},
219
220	populate: function(model) {
221		var that = this;
222		
223		var title = model.get('ort');
224		this.$el.find('.info_title').html(title);
225		var url = KGISConfig.apiRoot + '/' + model.get('files').png + '?v=' + model.get('revision');
226
227		this.$el.find('#info_id')
228			.attr('href', 'mailto:?to=&subject=' + encodeURIComponent('Lawis ' + lbl['lbl_mobil_profile_si'] + ' ' + title) + '&body=' + encodeURIComponent('https://lawis.at/profile/?intro=false#' + model.get('id')))
229			.html(model.get('id'));
230		this.$el.find('#info_export_caaml')
231			.attr('href', KGISConfig.publicApi + '/profile/' + model.get('id') + '?format=xml')
232			.attr('download', 'LawisProfile' + model.get('id') + '.xml')
233			.on('click', function(e) {
234				e.stopPropagation();
235			});
236		//FK-ML: 2023-05-03 Start
237		this.$el.find('#info_export_json')
238			.attr('href', KGISConfig.publicApi + '/profile/' + model.get('id') + '?format=json')
239			.attr('download', 'LawisProfile' + model.get('id') + '.json')
240			.on('click', function(e) {
241				e.stopPropagation();
242			});
243		//FK-ML: 2023-05-03 End
244		this.$el.find('#info_date, #info_date_summary').html(model.has('profildatum') ? KGISMapper.mapDate(model.get('profildatum')).asString : '');
245		this.$el.find('#info_reporting_date').html(model.has('loggedon') ? KGISMapper.mapD
245ate(model.get('loggedon')).asString : '');
246		this.$el.find('#info_email').html(model.has('email') ? model.get('email') : '');
247		this.$el.find('#info_revision').html(model.has('revision') ? `[${model.get('revision')}]` : '');
248		this.$el.find('#info_location, #info_location_summary').html(model.has('ort') ? model.get('ort') : '');
249		this.$el.find('#info_country').html(model.has('country_id') ? KGISMapper.mapCountryLocation(model.get('country_id')) : '');
250		this.$el.find('#info_region').html(model.has('region_id') ? KGISMapper.mapRegion(model.get('region_id')) : '');
251		this.$el.find('#info_subregion').html(model.has('subregion_id') ? KGISMapper.mapSubregion(model.get('subregion_id')) : '');
252		this.$el.find('#info_latitude').html(model.has('latitude') ? KGISMapper.mapKoordinates(model.get('latitude')) : '');
253		this.$el.find('#info_longitude').html(model.has('longitude') ? KGISMapper.mapKoordinates(model.get('longitude')) : '');
254		this.$el.find('#info_name').html(model.has('name') ? model.get('name') : '');
255		this.$el.find('#info_seehoehe').html(model.has('seehoehe') ? (model.get('seehoehe') + 'm') : '');
256		this.$el.find('#info_incline').html(model.has('hangneigung') ? (model.get('hangneigung') + '&deg;') : '');
257		this.$el.find('#info_aspect').html(model.has('exposition_id') ? KGISMapper.mapDirection(model.get('exposition_id')) : '');
258		this.$el.find('#info_wind').html(model.has('windgeschwindigkeit_id') ? KGISMapper.mapWindspeed(model.get('windgeschwindigkeit_id')) : '');
259		this.$el.find('#info_wind_dir').html((model.has('windrichtung_id') && model.get('windrichtung_id')) ? KGISMapper.mapDirection(model.get('windrichtung_id')) : '');
260		this.$el.find('#info_air_temp').html((model.has('lufttemperatur') && model.get('lufttemperatur')) ? (model.get('lufttemperatur') + '&deg;C') : '');
261		this.$el.find('#info_precip, #info_precip_summary').html((model.has('niederschlag_id') && model.get('niederschlag_id')) ? KGISMapper.mapPrecipitation(model.get('niederschlag_id')) : '');
262		this.$el.find('#info_intensity').html((model.has('intensity_id') && model.get('intensity_id')) ? KGISMapper.mapIntensity(model.get('intensity_id')): '');
263		this.$el.find('#info_sky_cond').html((model.has('bewoelkung_id') && model.get('bewoelkung_id')) ? KGISMapper.mapSkyCondition(model.get('bewoelkung_id')) : '');
264		this.$el.find('#info_comments').html((model.has('bemerkungen') && model.get('bemerkungen')) ? model.get('bemerkungen') : '');
265		this.$el.find('img.snowProfile')
266			.attr('src', url)
267			.on('load', function() {
268				if(that.$el.find('div.pinch-zoom-container').length == 0) {
269					new RTP.PinchZoom(that.$el.find('img.snowProfile'), {});
270				}
271				window.setTimeout(function() {
272					that.$el.find('.profileContainer').perfectScrollbar();
273					that.$el.find('div.pinch-zoom-container').css('height', '100%');
274					$(window).trigger('resize'); /* or otherwise perfect scrollbar is not working */
275				}, 100);
276			}
277		);
278		this.$el.find('a.snowProfileLink').attr('href', KGISConfig.apiRoot + '/' + model.get('files').pdf);
279	}
280});

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.