Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function loadAvatar(o)
- {
- var s = {}
- $.extend(s,o);
- var current = $('<li class="ul_ava_wr">'
- +'<div class="ul_ava'+((s.data[s.i].avatar) ? ' ' : ' unknown')+'" id="cl_'+s.data[s.i].client_id+'" client_id="'+s.data[s.i].client_id+'">'
- +'<span class="add_i" style="visibility:hidden;"><img src="../images/plus.png" /></span>'
- +'</div>'
- +'</li>').appendTo(s.ul);
- if(s.data[s.i].avatar)
- {
- // setTimeout(function(u){
- var img = new Image();
- img.onload = function(u){
- return function()
- {
- $(this).appendTo(users_table.find('#cl_'+u.data.client_id)); // .removeClass('ajax')).hide().fadeIn(300,function(){
- bindInvite({ref: $(this).parents('*[client_id]'), filter:'.add_i'});
- // console.log(u.counter + 1);
- // console.log(u.overall);
- // console.log((u.counter + 1) == u.overall);
- /* If the last image is loaded successfully, only then we proceed to next ajax call */
- if((u.i + 1) == u.overall)
- {
- /* Hiding upper photos for performance gain*/
- // if($(document).scrollTop() > $(window).height())
- // {
- // var all_avatars = users_table.find('.ul_ava_wr').length;
- // var hidden = users_table.find('.ul_ava_wr:lt('+(all_avatars - images_fit_page)+')');
- // hidden.hide();
- // // console.log(hidden);
- // }
- /* Setting ajax flag, to allow next ajax call */
- processing_users = false;
- /* If after ajax request conditions still doesn't meet, we loop ajax until it does */
- var to_top = $(document).scrollTop();
- var height = $(document).height();
- var to_bottom = height - to_top;
- // console.log(to_top);
- // console.log(height);
- // console.log(to_bottom);
- // console.log($(window).height());
- // console.log(Math.round(((to_bottom - $(window).height()) / height) * 100));
- // console.log(to_top);
- // console.log(Math.round(((to_bottom - $(window).height()) / height) * 100));
- if(Math.round(((to_bottom - $(window).height()) / height) * 100) == 0)
- {
- listUsers({start_from:users_start_from});
- }
- }
- else
- {
- s.i++;
- loadAvatar(s);
- }
- // });
- // console.log($(document).scrollTop());
- }
- }({data:s.data[s.i], i:s.i, overall:s.overall});
- img.src = u.data.avatar;
- // console.log($(document).scrollTop());
- // },s.timer,{data:s.data[s.i], i:s.i, overall:s.overall});
- // s.timer += 10;
- }
- else
- {
- bindInvite({ref: current.find('*[client_id]'), filter:'.add_i'});
- s.i++;
- loadAvatar(s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement