1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-09 01:44:25 +03:00
ifhub.club/templates/skin/developer/js/userfeed.js
2011-07-04 10:01:14 +00:00

89 lines
4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function lsUserfeedClass() {
this.isBusy = false;
this.subscribe = function (sType, iId) {
new Request.JSON({
url: aRouter['feed']+'subscribe',
data: {'type':sType, 'id':iId, 'security_ls_key':LIVESTREET_SECURITY_KEY},
onSuccess: function(data) { // запрос выполнен уcпешно
if (!data.bStateError) {
msgNoticeBox.alert(data.sMsgTitle,data.sMsg);
}
}
}).send();
}
this.unsubscribe = function (sType, iId) {
new Request.JSON({
url: aRouter['feed']+'unsubscribe',
data: {'type':sType, 'id':iId, 'security_ls_key':LIVESTREET_SECURITY_KEY},
onSuccess: function(data) { // запрос выполнен уcпешно
if (!data.bStateError) {
msgNoticeBox.alert(data.sMsgTitle,data.sMsg);
}
}
}).send();
}
this.appendUser = function() {
sLogin = $('userfeed_users_complete').get('value');
if (!sLogin) return;
new Request.JSON({
url: aRouter['feed']+'subscribeByLogin',
data: {'login':sLogin, 'security_ls_key':LIVESTREET_SECURITY_KEY},
onSuccess: function(data) { // запрос выполнен уcпешно
$('userfeed_no_subscribed_users').dispose();
if (!data.bStateError) {
checkbox = $('usf_u_'+data.uid);
if (checkbox) {
if ($(checkbox).get('checked')) {
msgErrorBox.alert(data.lang_error_title,data.lang_error_msg);
} else {
$(checkbox).set('checked', 'on');
msgNoticeBox.alert(data.sMsgTitle,data.sMsg);
}
} else {
var liElement = new Element('li');
var checkboxElement = new Element('input', {
'type':'checkbox',
'class':'userfeedUserCheckbox',
'id':'usf_u_'+data.uid,
'checked':'checked',
'onClick':'if ($(this).get(\'checked\')) {lsUserfeed.subscribe(\'users\','+data.uid+')} else {lsUserfeed.unsubscribe(\'users\','+data.uid+')}'
});
checkboxElement.inject(liElement);
var linkElement = new Element('a', {
'href':data.user_web_path,
'html':data.user_login
});
linkElement.inject(liElement);
liElement.inject($('userfeed_block_users_list'));
msgNoticeBox.alert(data.sMsgTitle,data.sMsg);
}
}
}
}).send();
}
this.getMore = function () {
if (this.isBusy) {
return;
}
lastId = $('userfeed_last_id').get('value');
if (!lastId) return;
$('userfeed_get_more').addClass('userfeed_loading');
this.isBusy = true;
new Request.JSON({
url: aRouter['feed']+'get_more',
data: {'last_id':lastId, 'security_ls_key':LIVESTREET_SECURITY_KEY},
onSuccess: function(data) { // запрос выполнен уcпешно
if (!data.bStateError && data.topics_count) {
$('userfeed_loaded_topics').set('html', $('userfeed_loaded_topics').get('html')+data.result);
$('userfeed_last_id').set('value', data.iUserfeedLastId);
}
if (!data.topics_count) {
$('userfeed_get_more').setStyles({'display':'none'});
}
$('userfeed_get_more').removeClass('userfeed_loading');
lsUserfeed.isBusy = false;
}
}).send();
}
}
var lsUserfeed = new lsUserfeedClass;