PageSourceSearch

https://bgradio.bg/theme_assets/commons/js/compression/facebook.js

js bgradio.bg collected 2026-10-02 12:40:39 UTC 9,945 bytes, 302 lines download raw bytes

1var loveRadioId;
2var FB
3var isLogin = ''
4function getUserId() {
5    $.cookie.json = true;
6    var userId = null;
7    if (loveRadioId != null) {
8        userId = loveRadioId;
9        return userId;
10    }
11    else {
12        var loginId = (FB.getAuthResponse() || {}).userID
13        if ((typeof $.cookie('userFb_' + loginId) === 'undefined') ||
14            (typeof $.cookie('userFb_' + loginId).userId === 'undefined')) {
15            loveRadioId = null;
16        }
17        else {
18            loveRadioId = $.cookie('userFb_' + loginId).userId;
19        }
20        return loginId
21    }
22}
23
24function getLastLikeDate(userId, songs, loginId) {
25    var additionalParameters = '/radio-lover/get-user-last-like-date?userId=' + userId;
26    if (typeof loginId != 'undefined' && parseInt(loginId, 10) &&
27        parseInt(userId, 10)) {
28        $.ajax({
29            url: detectIE() ? 'http://' + window.location.hostname + additionalParameters
30                : location.origin + additionalParameters,
31            type: 'POST',
32            dataType: 'json',
33            success: function (data) {
34                if (data.error == null) {
35                    var lastLikeDate = data.LastLikeDate;
36                    if (lastLikeDate != songs.LastLike) {
37                        updateLikedSongsIds(userId, loginId, lastLikeDate);
38                    }
39                }
40            }
41        });
42    }
43}
44
45function updateLikedSongsIds(userId, loginId, lastLikeDate) {
46    var additionalParameters = '/radio-lover/get-all-liked-songs-ids?userId=' + userId + '&loginId=' + loginId;
47    if (typeof loginId != 'undefined' && typeof lastLikeDate != 'undefined') {
48        $.ajax({
49            url: detectIE() ? 'http://' + window.location.hostname + additionalParameters
50                : location.origin + additionalParameters,
51            type: 'POST',
52            dataType: 'json',
53            success: function (data) {
54                if (data.error == null &&
55                    data.success == 1) {
56                    updateAllLikedSongs(userId, data.songIds, lastLikeDate);
57                }
58            }
59        });
60    }
61}
62
63function setRadioCoins(userId, coins) {
64    userId = getUserId();
65    if (userId) {
66        var additionalParameters = '/radio-lover/set-user-coins?userId=' + userId + '&coins=' + coins
67        var url = detectIE() ? 'http://' + window.location.hostname + additionalParameters
68            : location.origin + additionalParameters;
69        $.ajax({
70            url: url,
71            type: 'POST',
72            dataType: 'json',
73            success: function (data) {
74                console.log(data);
75            }
76        });
77    }
78}
79
80function getRadioCoins() {
81    var radioLoad = radio.helper.load()
82    var userId = getUserId();
83    if (userId) {
84        var additionalParameters = '/radio-lover/get-user-coins?userId=' + userId
85
86        var url = detectIE() ? 'http://' + window.location.hostname + additionalParameters
87            : location.origin + additionalParameters;
88        $.get(url)
89            .done(function (data) {
90                radioLoad.SetListenTime(data.replace(/\r\n/g, '\n').split('\n'))
91            })
92    } else {
93        radioLoad.SetListenTime(0)
94    }
95}
96
97var userLogin = (function () {
98    function saveUser(loginId) {
99        var additionalParameters = '?loginId=' + loginId;
100        $.ajax({
101            url: detectIE() ? 'http://' + window.location.hostname + '/radio-lover/login' + additionalParameters
102                : location.origin + '/radio-lover/login' + additionalParameters,
103            type: 'POST',
104            dataType: "json",
105            success: function (data) {
106                if (data.error == null) {
107                    var user = {userId: data.id, login: 1};
108                    $.cookie.json = true;
109                    $.cookie('userFb_' + loginId, user, {expires: 15 * 365});
110                    loveRadioId = data.id;
111                }
112            }
113        });
114    }
115
116    function setUserId(loginId) {
117        $.cookie.json = true;
118        if ((typeof $.cookie('userFb_' + loginId) === 'undefined') ||
119            (typeof $.cookie('userFb_' + loginId).userId === 'undefined')) {
120            saveUser(loginId);
121        }
122        else {
123            loveRadioId = $.cookie('userFb_' + loginId).userId;
124        }
125    }
126
127    return {
128        "afterLoginRequests": function () {
129            FB.api('/me', {fields: 'first_name, last_name, picture'}, function (response) {
130                $('.fb-image').attr('src', response.picture.data.url);
131                $('#profile-name').html(response.first_name + ' ' + response.last_name);
132                var loginId = response.id;
133                setUserId(loginId);
134                var songs = getLikedSongs();
135                var userId = getUserId();
136                if (Modernizr.localstorage) {
137                    if (songs == null) {
138                        updateLikedSongsIds(userId, loginId, null);
139                    }
140                    else {
141                        getLastLikeDate(userId, songs, loginId);
142                    }
143                }
144                refreshPlaylist();
145                setupCurrentSongLike();
146                loadUserFavoriteSongs();
147            });
148        }
149    };
150}());
151
152function statusChangeCallback(response) {
153    // The response object is returned with a status field that lets the
154    // app know the current login status of the person.
155    // Full docs on the response object can be found in the documentation
156    // for FB.getLoginStatus().
157    if (response.status === 'connected') {
158        // Logged into your app and Facebook.
159        hideLogin();
160        userLogin.afterLoginRequests();
161
162        if (location.pathname === '/chart/city-bylgarskite-5') {
163            themeAssistant.cityReplaceLinks()
164        }
165    } else {
166        showLogin();
167        if (response.status === 'not_authorized') {
168            // The person is logged into Facebook, but not your app.
169            /*document.getElementById('status').innerHTML = 'Please log ' +
170             'into this app.';*/
171        } else {
172            // The person is not logged into Facebook, so we're not sure if
173            // they are logged into this app or not.
174            /*document.getElementById('status').innerHTML = 'Please log ' +
175             'into Facebook.';*/
176        }
177    }
178}
179
180function fb_reentered() {
181    setTimeout(function () {
182        hideLogin();
183        userLogin.afterLoginRequests();
184    }, 500);
185}
186
187function fb_login() {
188    FB.login(function (response) {
189        statusChangeCallback(response);
190    });
191}
192
193function fb_logout() {
194    /*showLogin();
195     var loginButton = $('.login-button');
196     loginButton.prop('onclick',null).off('click');
197     loginButton.click(function() {
198     fb_reentered();
199     });*/
200
201    FB.logout(function (response) {
202        // user is now logged out
203        afterLogoutRequests();
204    });
205}
206
207function onChangeFocusLogout() {
208    FB.api('/me', function (response) {
209        if (response.error != null) {
210            afterLogoutRequests();
211        }
212    });
213}
214
215function afterLogoutRequests() {
216    showLogin();
217    loveRadioId = null;
218    setupCurrentSongLike();
219    removeFavoriteSongs();
220    if (location.pathname === '/chart/city-bylgarskite-5') {
221        themeAssistant.cityReplaceLinks()
222    }
223}
224
225// This function is called when someone finishes with the Login
226// Button.  See the onlogin handler attached to it in the sample
227// code below.
228function checkLoginState() {
229    if (typeof FB == 'undefined') {
230        setTimeout(checkLoginState, 1000);
231    } else {
232        return true
233    }
234}
235
236function showLogin() {
237    $('.profile-button').hide();
238    $('.login-button').show();
239}
240
241function hideLogin() {
242    $('.profile-button').show();
243    $('.login-button').hide();
244}
245
246function shareOnFacebook(obj) {
247    FB.ui(obj);
248}
249
250window.onload = function () {
251	
252		// window.fbAsyncInit = function () {
253
254				FB.init({
255					appId: $("meta[property='fb:app_id']").attr("content"),
256					cookie: true,  // enable cookies to allow the server to access
257								   // the session
258					xfbml: true,  // parse social plugins on this page
259					//version: 'v4.0' // use graph api version 4.0
260					 version: 'v2.7' // use graph api version 2.10
261					 //version: 'v11.0' // use graph api version v11.0
262				});
263
264				// Now that we've initialized the JavaScript SDK, we call
265				// FB.getLoginStatus().  This function gets the state of the
266				// person visiting this page and can return one of three states to
267				// the callback you provide.  They can be:
268				//
269				// 1. Logged into your app ('connected')
270				// 2. Logged into Facebook, but not your app ('not_authorized')
271				// 3. Not logged into Facebook and can't tell if they are logged into
272				//    your app or not.
273				//
274				// These three cases are handled in the callback function.
275				//FB.AppEvents.logPageView()
276				FB.getLoginStatus(function (response) {
277					isLogin = statusChangeCallback(response);
278			});
279			
280		// }
281
282    // Load the SDK asynchronously
283	try {
284		(function (d, s, id) {
285			var js, fjs = d.getElementsByTagName(s)[0];
286			if (d.getElementById(id)) return;
287			js = d.createElement(s);
288			js.id = id;
289			js.src = "https://connect.facebook.net/bg_BG/sdk.js";
290			fjs.parentNode.insertBefore(js, fjs);
291		}(document, 'script', 'facebook-jssdk'));
292		//(function(d, s, id){
293		// var js, fjs = d.getElementsByTagName(s)[0];
294		// if (d.getElementById(id)) {return;}
295		// js = d.createElement(s); js.id = id;
296		// js.src = "https://connect.facebook.net/en_US/sdk.js";
297		// fjs.parentNode.insertBefore(js, fjs);
298	   //(document, 'script', 'facebook-jssdk'));
299	} catch (e) {
300            console.log(e)
301	}
302}

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.