PageSourceSearch

https://sso.uni-corvinus.hu/cas/js/cas.js

js uni-corvinus.hu collected 2026-09-24 08:39:18 UTC 9,246 bytes, 298 lines download raw bytes

1/* global trackGeoLocation, jqueryReady */
2
3/* exported resourceLoadedSuccessfully */
4
5function requestGeoPosition() {
6    // console.log('Requesting GeoLocation data from the browser...');
7    if (navigator.geolocation) {
8        navigator.geolocation.getCurrentPosition(showGeoPosition, logGeoLocationError,
9            {maximumAge: 600000, timeout: 5000, enableHighAccuracy: true});
10    } else {
11        // console.log('Browser does not support Geo Location');
12    }
13}
14
15function logGeoLocationError(error) {
16    switch (error.code) {
17    case error.PERMISSION_DENIED:
18        // console.log('User denied the request for GeoLocation.');
19        break;
20    case error.POSITION_UNAVAILABLE:
21        // console.log('Location information is unavailable.');
22        break;
23    case error.TIMEOUT:
24        // console.log('The request to get user location timed out.');
25        break;
26    default:
27        // console.log('An unknown error occurred.');
28        break;
29    }
30}
31
32function showGeoPosition(position) {
33    $('[name="geolocation"]').val(position.coords.latitude + ','
34        + position.coords.longitude + ',' + position.coords.accuracy + ',' + position.timestamp);
35}
36
37function preserveAnchorTagOnForm() {
38    $('#fm1').submit(function () {
39        var location = self.document.location;
40        var hash = decodeURIComponent(location.hash);
41        
42        if (hash != undefined && hash != '' && hash.indexOf('#') === -1) {
43            hash = '#' + hash;
44        }
45
46        var action = $('#fm1').attr('action');
47        if (action == undefined) {
48            action = location.href;
49        } else {
50            var qidx = location.href.indexOf('?');
51            if (qidx != -1) {
52                var queryParams = location.href.substring(qidx);
53                action += queryParams;
54            }
55        }
56        action += hash;
57        $('#fm1').attr('action', action);
58        
59    });
60}
61
62function areCookiesEnabled() {
63    if ($.cookie == undefined) {
64        return;
65    }
66
67    $.cookie('cookiesEnabled', 'true');
68    var value = $.cookie('cookiesEnabled');
69    $.removeCookie('cookiesEnabled');
70    return value != undefined;
71
72}
73
74function disableEmptyInputFormSubmission() {
75    var fields = $('#fm1 input[name="username"],[name="password"]');
76
77    if (fields.length == 2) {
78        fields.on('input', function (event) {
79            var enableSubmission = $('#fm1 input[name="username"]').val().trim() &&
80                $('#fm1 input[name="password"]').val().trim();
81
82            if (enableSubmission) {
83                $('#fm1 input[name=submit]').removeAttr('disabled');
84                event.stopPropagation();
85            } else {
86                $('#fm1 input[name=submit]').attr('disabled', 'true');
87            }
88        });
89    }
90
91    /**
92     * Handle auto-complete events to the extent possible.
93     */
94/*
95    if ($('#fm1 input[name="username"]').length > 0) {
96        setTimeout(function () {
97            var uid = $('#username').val();
98            if (uid != null && uid != '') {
99                $('#username').change();
100                $('#username').focus();
101                $('#fm1 input[name=submit]').removeAttr('disabled');
102            }
103
104        }, 100);
105    }
106*/
107}
108
109function resourceLoadedSuccessfully() {
110    $(document).ready(function () {
111
112        if (trackGeoLocation) {
113            requestGeoPosition();
114        }
115
116        if ($(':focus').length === 0) {
117            $('input:visible:enabled:first').focus();
118        }
119
120        if (areCookiesEnabled()) {
121            $('#cookiesDisabled').hide();
122        } else {
123            $('#cookiesDisabled').show();
124        }
125
126        $('#capslock-on').hide();
127        $('#fm1 input[name="username"],[name="password"]').trigger('input');
128        $('#fm1 input[name="username"]').focus();
129
130        $('#password').keypress(function (e) {
131            var s = String.fromCharCode(e.which);
132            if (s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey) {
133                $('#capslock-on').show();
134            } else {
135                $('#capslock-on').hide();
136            }
137        });
138
139        $('div.formcontainerdiv input.form-field.uname').keypress(function (e) {
140            var i = e.which;
141            if( i === 13 ){
142              if( ($('div.formcontainerdiv input.form-field.upass').val().trim().length > 0) && ($('div.formcontainerdiv input.form-field.uname').val().trim().length > 0 ) ){
143                setTimeout(userClickEvent, 10);
144              };
145            }
146        });
147
148        $('div.formcontainerdiv input.form-field.upass').keypress(function (e) {
149            var i = e.which;
150            if( i === 13 ){
151              if( ($('div.formcontainerdiv input.form-field.upass').val().trim().length > 0) && ($('div.formcontainerdiv input.form-field.uname').val().trim().length > 0 ) ){
152                setTimeout(userClickEvent, 10);
153              };
154            }
155        });
156
157        if (typeof(jqueryReady) == 'function') {
158            jqueryReady();
159        }
160
161        /* listener for prevent click event on disabled A tag */
162        document.body.addEventListener('click', function (event) {
163          // filter out clicks on any other elements
164          if (event.target.nodeName == 'A' && event.target.getAttribute('aria-disabled') == 'true') {
165            event.preventDefault();
166          }
167        });
168
169        ///////////////////////////////////////////////////////////////////////////////////
170        // errormessage appers above input fields when window height < 720
171        // https://otrs.uni-corvinus.hu/otrs/index.pl?Action=AgentTicketZoom;TicketID=44929
172        // 2020-12-04
173
174        window.addEventListener('orientationchange', function(){
175          moveMessageWindowLocation();
176        });
177
178        jQuery(window).bind("resize", function(){
179          moveMessageWindowLocation();
180        });
181
182        refreshOwnForm();
183        disableEmptyInputOwnFormSubmission();
184        preserveAnchorTagOnForm();
185        moveMessageWindowLocation();
186
187    });
188
189}
190
191function refreshOwnForm(){
192  $('div.formcontainerdiv input.uname').val( $('#fm1 input[name="username"]').val() );
193  $('div.formcontainerdiv input.upass').val( $('#fm1 input[name="password"]').val() );
194
195  if($('#fm1 div.errormessage span').text().trim()){
196    $('div.formcontainerdiv div.errormessage span').html( $('#fm1 div.errormessage span').html() );
197    $('div.formcontainerdiv div.errormessage').removeClass('nodisplay');
198  }
199}
200
201function refreshInputFieldsFromOwnForm(){
202  $('#fm1 input[name="username"]').val( $('div.formcontainerdiv input.uname').val() );
203  $('#fm1 input[name="password"]').val( $('div.formcontainerdiv input.upass').val() );
204}
205
206
207function disableEmptyInputOwnFormSubmission() {
208    var fields = $('div.formcontainerdiv input.uname, div.formcontainerdiv input.upass');
209
210    if (fields.length == 2) {
211        fields.on('input', function (event) {
212            var enableSubmission = $('div.formcontainerdiv input.uname').val().trim().length && $('div.formcontainerdiv input.upass').val().trim().length;
213
214            if (enableSubmission) {
215                enableLink($('a.submitown'));
216            } else {
217                disableLink($('a.submitown'));
218            }
219        });
220        var enable_submission = $('div.formcontainerdiv input.uname').val().trim().length && $('div.formcontainerdiv input.upass').val().trim().length;
221
222        if (enable_submission) {
223            enableLink($('a.submitown'));
224        } else {
225            disableLink($('a.submitown'));
226        }
227
228    }
229
230
231    /**
232     * Handle auto-complete events to the extent possible.
233     */
234    /*
235    if ($('#fm1 input[name="username"]').length > 0) {
236        setTimeout(function () {
237            var uid = $('#username').val();
238            if (uid != null && uid != '') {
239                $('#username').change();
240                $('#username').focus();
241                $('#fm1 input[name=submit]').removeAttr('disabled');
242            }
243
244        }, 100);
245    }
246    */
247} 
248
249
250function disableLink(link) {
251  if(link && link[0]){
252    // 1. Add isDisabled class to parent span
253    link[0].parentElement.classList.add('isDisabled');
254
255    // 2. Store href so we can add it later
256    // link[0].setAttribute('data-href', link.href);
257
258    // 3. Remove href
259    // link[0].href = '';
260
261    // 4. Set aria-disabled to 'true'
262    link[0].setAttribute('aria-disabled', 'true');
263  }
264}
265
266function enableLink(link) {
267  if(link && link[0]){
268    // 1. Remove 'isDisabled' class from parent span
269    link[0].parentElement.classList.remove('isDisabled');
270
271    // 2. Set href
272    // link[0].href = link.getAttribute('data-href');
273
274    // 3. Remove 'aria-disabled', better than setting to false
275    link[0].removeAttribute('aria-disabled');
276  }
277}
278
279function userClickEvent(){
280  refreshInputFieldsFromOwnForm();
281  // SUBMIT
282  $('#fm1 input[name=submit]').trigger('click');
283}
284
285////////////////////////////////////////////////////
286// errormessage appers above input fields
287// https://otrs.uni-corvinus.hu/otrs/index.pl?Action=AgentTicketZoom;TicketID=44929
288// 2020-12-04
289//
290function moveMessageWindowLocation(){
291  try {
292    var h = window.innerHeight;
293    if(h < 720){
294      jQuery("div.formgroupcontainer>div.errormessage").insertAfter("div.formgroupcontainer h3");
295    }
296  } catch(err) {
297  }
298}

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.