who_to_follow.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php include ('header.php'); ?>
  2. <main id="main">
  3. <div class="article_wrap">
  4. <aside class="left_column">
  5. <?php include dirname(__FILE__).('/widgets/side_current_user.php'); ?>
  6. <?php include dirname(__FILE__).('/widgets/side_footer.php'); ?>
  7. </aside>
  8. <article class="center_column">
  9. <div id="js-follows_profile">
  10. </div>
  11. <footer id="js-follows_footer">
  12. <i class="fa fa-spin fa-circle-o-notch" aria-hidden="true"></i>
  13. </footer>
  14. </article>
  15. </div>
  16. </main>
  17. <script>
  18. $('title').text('Halcyon / Who to follow');
  19. var wtfprofiles = JSON.parse(localStorage.who_to_follow);
  20. var pcount = 0;
  21. var isSyncing = false;
  22. function nextprofiles(displayed) {
  23. if(wtfprofiles.length - displayed < 30) {
  24. fcount = wtfprofiles.length;
  25. }
  26. else {
  27. fcount = 30;
  28. }
  29. for(i=0;i<fcount;i++) {
  30. if(current_following_accts.indexOf(wtfprofiles[displayed+i]) == -1) {
  31. api.get('search',[{name:'q',data:"@"+wtfprofiles[displayed+i]},{name:'resolve',data:'true'}], function(search) {
  32. follows_template(search.accounts[0]).appendTo("#js-follows_profile");
  33. replace_emoji();
  34. if(i = 29) {
  35. isSyncing = false;
  36. }
  37. });
  38. }
  39. }
  40. }
  41. nextprofiles(0);
  42. $(window).scroll(function () {
  43. if($(window).scrollTop()+window.innerHeight >= $(document).height()-700) {
  44. if(!isSyncing) {
  45. isSyncing = true;
  46. pcount++;
  47. nextprofiles(pcount*30);
  48. }
  49. }
  50. });
  51. </script>
  52. <?php include ('footer.php'); ?>