1var responsive_loading = true; 2var loading = false; 3var page = 1; 4var $stream = $('div[data-stream-url]'); 5var retrievers = $stream.find('[data-content]'); 6var current = 0; 7var dead = false; 8var id_list = {}; 9 10function loadNext() { 11 if (responsive_loading) { // disable auto-loading (on scroll event) in responsive version 12 return false; 13 } 14 15 var wintop = $(window).scrollTop(), docheight = $(document).height(), winheight = $(window).height(); 16 var scrolltrigger = 0.95; // % 17 18 var vpH = $(window).height(); // Viewport Height 19 var st = $(window).scrollTop(); // Scroll Top 20 var y = 0; 21 if ($('#preloader').length > 0) { 22 y = $('#preloader').offset().top; 23 } 24 25 if (dead || loading || $stream.length == 0) { 26 return; 27 } 28 29 var isTriggered = ((y * scrolltrigger) < (vpH + st)); 30 if (isTriggered) { 31 //console.log('ajax - loading next items'); 32 loading = true; 33 34 var method = "GET"; 35 36 var data = { 37 'page': page, 38 'author': $stream.data('stream-author') 39 }; 40 41 var attr = $stream.attr('data-stream-is-homepage'); 42 data['is_homepage'] = (typeof attr !== typeof undefined && attr !== false); 43 44 $.ajax({ 45 type: method, 46 url: $stream.data('stream-url'), 47 data: data, 48 success: function ($response) { 49 var content = $response.get_content || $response.content; 50 if (typeof content == 'string') { 51 content = $.trim(content); 52 } 53 54 if (content.length > 0) { 55 if ($stream.data('stream-split')) { 56 content = $(content).filter($stream.data('stream-split')); 57 } 58 if (typeof content == 'string') { 59 content = new Array(content); 60 } 61 //console.log(content); 62 var doc = document.createElement('div'); 63 64 $.each(content, function (key) { 65 if (current >= retrievers.length) { 66 current = 0; 67 } 68 69 var content = $('<div></div>').html(this); 70 71 content.find('[data-stream-id]').each(function () { 72 var id = $(this).data('stream-id'); 73 if (id in id_list) { 74 $(this).remove(); 75 } 76 id_list[id] = id; 77 }); 78 $(retrievers[current++]).append(content.html()); 79 }); 80 81 $result_obj = $(doc).hide(); 82 $result_obj.fadeIn(); 83 84 if ($response.is_last_page) { 85 $('#preloader').remove(); 86 } 87 88 loading = false; 89 page++; 90 loadNext(); 91 92 recursiveReplace(document.body); 93 } else { 94 $('#preloader').remove(); 95 $('#footer').removeClass('hide'); 96 dead = true; 97 } 98 } 99 }); 100 } 101} 102 103function loadNextResponsive() { 104 if (!responsive_loading) { // disable auto-loading (on scroll event) in responsive version 105 return false; 106 } 107 108 if (dead || loading || $stream.length == 0) { 109 return; 110 } 111 112 loading = true; 113 114 $('.czd-ajax-loader').addClass('loading'); 115 $('#preloader').addClass('loading'); 116 117 var method = "GET"; 118 var data = { 119 'page': page, 120 'author': $stream.data('stream-author') 121 }; 122 123 var attr = $stream.attr('data-stream-is-homepage'); 124 data['is_homepage'] = (typeof attr !== typeof undefined && attr !== false); 125 126 $.ajax({ 127 type: method, 128 url: $stream.data('stream-url'), 129 data: data, 130 success: function ($response) { 131 var content = $response.get_content || $response.content; 132 if (typeof content == 'string') { 133 content = $.trim(content); 134 } 135 136 if ($response.is_last_page) { 137 $('.preloader-center').hide(); 138 } 139 140 if (content.length > 0) { 141 if ($stream.data('stream-split')) { 142 content = $(content).filter($stream.data('stream-split')); 143 } 144 if (typeof content == 'string') { 145 content = new Array(content); 146 } 147 var doc = document.createElement('div'); 148 149 $.each(content, function () { 150 if (current >= retrievers.length) { 151 current = 0; 152 } 153 154 $(retrievers[current++]).append(this); 155 }); 156 157 $result_obj = $(doc).hide(); 158 $result_obj.fadeIn(); 159 160 loading = false;
161 $('.czd-ajax-loader').removeClass('loading'); 162 $('#preloader').removeClass('loading'); 163 page++; 164 165 replaceImgDomain(); 166 167 recursiveReplace(document.body); 168 } else { 169 $('.preloader-center').remove(); 170 $('#footer').removeClass('hide'); 171 dead = true; 172 } 173 } 174 }); 175} 176 177$(document).ready(function () { 178 if (responsive_loading) { // create "loading next" button 179 $('#preloader').on("click", function () { 180 loadNextResponsive(); 181 }); 182 } 183 184 185 $('[data-stream-id]').each(function () { 186 var id = $(this).data('stream-id'); 187 id_list[id] = id; 188 }); 189 190 loadNext(); 191 192 // homepage - ajax pagination 193 if ($stream.length > 0) { 194 $(window).scroll(function () { 195 loadNext(); 196 }); 197 } 198});
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.