1/** 2 * JNews Auto-Load Next Post â queue driver 3 * 4 * Patches the base jautoload plugin so it navigates a pre-built, server-side 5 * ordered sequence (tag â category â sequence) instead of following a lazy 6 * per-post data-prev chain. 7 * 8 * Activation: the PHP side stamps data-autoload-queue (a JSON array of 9 * { id, url } objects) onto the first .post-autoload element only when the 10 * "tag_category" mode is active and the request is NOT an autoload AJAX call. 11 * This script is only enqueued when that mode is selected, so there is zero 12 * overhead for sites using any other mode. 13 * 14 * How the index works: 15 * - Initially 1 post (.post-autoload) is in the DOM â we want queue[0] 16 * - After the 1st AJAX post loads, count = 2 â we want queue[1] 17 * - After the 2nd AJAX post loads, count = 3 â we want queue[2] 18 * index = $(content_class).length - 1 19 * 20 * This is stateless (no shift/pop) and naturally self-corrects even if 21 * change_url fires multiple times for the same scroll event, because the 22 * existing check_loaded() guard in auto_load_prev_post prevents double-loading. 23 */ 24( function ( $ ) { 25 'use strict'; 26 27 var Constructor = $.fn.jautoload && $.fn.jautoload.Constructor; 28 if ( ! Constructor ) { return; } 29 30 var _init = Constructor.prototype.init; 31 var _get_previous_url = Constructor.prototype.get_previous_url; 32 33 /** 34 * Override init â read the pre-built queue from the first post's attribute 35 * and store it on the instance before waypoints are initialised. 36 */ 37 Constructor.prototype.init = function () { 38 var queueData = $( this.content_class ).first().data( 'autoload-queue' ); 39 this.autoload_queue = Array.isArray( queueData ) ? queueData : null; 40 _init.call( this ); 41 }; 42 43 /** 44 * Override get_previous_url â return the next URL from the pre-built queue 45 * when one is present, otherwise fall through to the original behaviour. 46 */ 47 Constructor.prototype.get_previous_url = function ( e, n ) { 48 if ( this.autoload_queue ) { 49 // Number of .post-autoload elements currently in the DOM tells us 50 // exactly which queue entry to serve next. 51 var loaded = $( this.content_class ).length; 52 var nextIndex = loaded - 1; 53 54 if ( nextIndex < this.autoload_queue.length ) { 55 return this.autoload_queue[ nextIndex ].url; 56 } 57 58 return null; // queue exhausted â stop loading 59 } 60 61 return _get_previous_url.call( this, e, n ); 62 }; 63 64}( jQuery ) );
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.