Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- var update_likes = function() {
- $('.post').each(function() {
- var post = $(this);
- $('div#likeBar:not("a")', this).hide();
- var pID = post.attr('id').match(/\d+/g);
- $.ajax({
- type: "GET",
- url: "http://forumotion.96.lt/get_like.php/?post_id="+pID,
- beforeSend: function(xml) {
- $('#likeBar', post).html("Loading...").show();
- },
- complete: function(xml) {
- xmlDoc = xml.responseText;
- $('#likeBar', post).html(xmlDoc);
- var user = "/u"+_userdata.user_id;
- var liked = $('#likeBar a[href="'+ user +'"]', post);
- if(liked.length == 1)
- {
- $('a[id*="like-post"]', post).remove();
- }
- $('#likeBar', post).each(function() {
- var d = $('strong', this).text().match(/\d+/g);
- $('p', this).html($('p a:lt(3)', this));
- $('p', this).prepend("People like's this: ");
- if($('p a', this).length > 3) {
- $('p', this).append(''+ parseInt(d) - 3 +' other people');
- }
- });
- }, error: function(xml) {
- console.log("Failed loading data...");
- }
- });
- });
- };
- setTimeout(function() { update_likes(); }, 50);
- $('.post').each(function() {
- var post = $(this);
- var people = _userdata.username;
- var author = $('.postprofile dt a[href*="/u"]', post);
- if(author.text() === people || _userdata.session_logged_in == 0) {
- $('a[id*="like-post"]', post).remove();
- }
- $('a[id*="like-post"]', this).on('click', function(e) {
- e.preventDefault();
- var id = $(this).attr('post-id').match(/\d+/);
- var people = _userdata.username;
- var author = $('.postprofile dt a[href*="/u"]', post);
- var avatar = $(_userdata.avatar).attr('src');
- var string = "user="+ people +"&post_id="+ id +"&like_count=1&avatars="+ avatar +"&user_id_people="+ _userdata.user_id +"&user_id="+author.attr('href').match(/\d+/g)+"&post_author="+author.text();
- if(author.text() === people) {
- alert("Nu iti poti da like singur la post !");
- } else {
- $.ajax({
- type: "post",
- url: "http://forumotion.96.lt/like.php/?query=post_id="+ id +"&people="+_userdata.username,
- data: string,
- beforeSend: function() {
- $(this).html('Loading...');
- },
- complete: function(response) {
- $('body').after('<div id="ipsGlobalNotification"><div class="popupWrapper"><div class="popupInner"><div class="ipsPad">You have like this </div></div></div></div>');
- console.log("[Like System] "+response.responseText);
- update_likes();
- }
- });
- }
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement