1/* 2Plugin Name: Advanced AJAX Page Loader 3Version: 2.7.3 4Plugin URI: http://software.resplace.net/WordPress/AjaxPageLoader.php 5Description: Load pages within blog without reloading page, shows loading bar and updates the browsers URL so that the user can bookmark or share the url as if they had loaded a page normally. Also updates there history so they have a track of there browsing habbits on your blog! 6Author URI: http://dean.resplace.net 7Author: Dean Williams 8*/ 9 10//Set this to true if your getting some javascript problems 11var AAPL_reloadDocumentReady = false; 12 13//Dont mess with these... 14var AAPL_isLoad = false; 15var AAPL_started = false; 16var AAPL_searchPath = null; 17var AAPL_ua = jQuery.browser; 18 19 20//The holy grail... 21jQuery(document).ready(function() { 22 if (AAPL_warnings == true) { 23 alert("DEBUG MODE! \nThanks for downloading AAPL - you are currently in DEBUG MODE, once you are confident AAPL is working as you require please disable DEBUG MODE from the AAPL options in wordpress."); 24 } 25 if (AAPL_warnings == true) { 26 AAPL_jqVersion = jQuery().jquery; 27 if (AAPL_jqVersion.substr(0,3) != "1.8" && AAPL_warnings == true) { 28 alert("INFORMATION: \njQuery may be outdated! This plugin was made using 1.8, I can see version: " + AAPL_jqVersion); 29 } 30 } 31 32 AAPL_loadPageInit(""); 33}); 34 35 36window.onpopstate = function(event) { 37 //We now have a smart multi-ignore feature controlled by the admin panel 38 if (AAPL_started === true && AAPL_check_ignore(document.location.toString()) == true) { 39 AAPL_loadPage(document.location.toString(),1); 40 } 41}; 42 43function AAPL_loadPageInit(scope){ 44 jQuery(scope + "a").on( "click", function(event) { 45 //if its not an admin url, or doesnt contain # 46 if (this.href.indexOf(AAPLhome) >= 0 && AAPL_check_ignore(this.href) == true){ 47 // stop default behaviour 48 event.preventDefault(); 49 50 // remove click border 51 this.blur(); 52 53 // get caption: either title or name attribute 54 var caption = this.title || this.name || ""; 55 56 // get rel attribute for image groups 57 var group = this.rel || false; 58 59 //Load click code - pass reference. 60 try { 61 AAPL_click_code(this); 62 } catch(err) { 63 if (AAPL_warnings == true) { 64 txt="ERROR: \nThere was an error with click_code.\n"; 65 txt+="Error description: " + err.message; 66 alert(txt); 67 } 68 } 69 70 // display the box for the elements href 71 AAPL_loadPage(this.href); 72 } 73 }); 74 75 jQuery('.' + AAPL_search_class).each(function(index) { 76 if (jQuery(this).attr("action")) { 77 //Get the current action so we know where to submit to 78 AAPL_searchPath = jQuery(this).attr("action"); 79 console.log(AAPL_searchPath); 80 81 //bind our code to search submit, now we can load everything through ajax :) 82 //jQuery('#searchform').name = 'searchform'; 83 jQuery(this).submit(function() { 84 submitSearch(jQuery(this).serialize()); 85 return false; 86 }); 87 } else { 88 if (AAPL_warnings == true) { 89 alert("WARNING: \nSearch form found but attribute 'action' missing!?!?! This may mean search form doesn't work with AAPL!"); 90 } 91 } 92 }); 93 94 if (jQuery('.' + AAPL_search_class).attr("action")) {} else { 95 if (AAPL_warnings == true) { 96 alert("WARNING: \nCould not bind to search form...\nCould not find <form> tag with class='" + AAPL_search_class + "' or action='' missing. This may mean search form doesnt work with AAPL!"); 97 } 98 } 99} 100 101function AAPL_loadPage(url, push, getData){ 102 103 if (!AAPL_isLoad){ 104 if (AAPL_scroll_top == true) { 105 //Nicer Scroll to top - thanks Bram Perry 106 jQuery('html,body').animate({scrollTop: 0}, 1500); 107 } 108 AAPL_isLoad = true; 109 110 //enable onpopstate 111 AAPL_started = true; 112 113 //AJAX Load page and update address bar url! :) 114 //get domain name... 115 nohttp = url.replace("http://","").replace("https://",""); 116 firstsla = nohttp.indexOf("/"); 117 pathpos = url.indexOf(nohttp); 118 path = url.substring(pathpos + firstsla); 119 120 //Only do a history state if clicked on the page. 121 if (push != 1) { 122 //TODO: implement a method for IE 123 if (typeof window.history.pushState == "function") { 124 var stateObj = { foo: 1000 + Math.random()*1001 }; 125 history.pushState(stateObj, "ajax page loaded...", path); 126 } else { 127 if (AAPL_warnings == true) { 128 alert("BROWSER COMPATIBILITY: \n'pushState' method not supported in this browser, sorry about that!"); 129 } 130 } 131 } 132 133 if (!jQuery('#' + AAPL_content)) { 134 if (AAPL_warnings == true) { 135 alert("ERROR: \nAAPL could not find your content, you need to set an ID to a div that surrounds all the content of the page (excluding menu, heading and footer) - AAPL was looking for id='" + AAPL_content + "'"); 136 return false;
137 } 138 } 139 140 //start changing the page content. 141 jQuery('#' + AAPL_content).fadeOut(0, function() { 142 //See peakaboo below - NEVER TRUST jQuery to sort ALL your problems - this breaks Ie7 + 8 :o 143 //jQuery('#' + AAPL_content).html(AAPL_loading_code); 144 145 //Nothing like good old pure JavaScript... 146 document.getElementById(AAPL_content).innerHTML = AAPL_loading_code; 147 148 jQuery('#' + AAPL_content).fadeIn(0, function() { 149 jQuery.ajax({ 150 type: "GET", 151 url: url, 152 data: getData, 153 cache: false, 154 dataType: "html", 155 success: function(data) { 156 AAPL_isLoad = false; 157 158 //get title attribute 159 datax = data.split('<title>'); 160 titlesx = data.split('</title>'); 161 162 if (datax.length == 2 || titlesx.length == 2) { 163 data = data.split('<title>')[1]; 164 titles = data.split('</title>')[0]; 165 166 //set the title? 167 //after several months, I think this is the solution to fix & issues 168 jQuery(document).attr('title', (jQuery("<div/>").html(titles).text())); 169 } else { 170 if (AAPL_warnings == true) { 171 alert("WARNING: \nYou seem to have more than one <title> tag on the page, this is going to cause some major problems so page title changing is disabled."); 172 } 173 } 174 175 //body Classes 176 //var matches = data.match(/<body.*class=["']([^"']*)["'].*>/), 177 // classes = matches && matches[1];
178 //jQuery("body").removeClass().addClass(classes); 179 180 //GOOGLE ANALYTICS TRACKING 181 if (AAPL_track_analytics == true) { 182 if(typeof _gaq != "undefined") { 183 if (typeof getData == "undefined") { 184 getData = ""; 185 } else { 186 getData = "?" + getData; 187 } 188 _gaq.push(['_trackPageview', path + getData]); 189 } else { 190 if (AAPL_warnings == true) { 191 alert("WARNING: \nAnalytics does not seem to be initialized! Could not track this page for google."); 192 } 193 } 194 } 195 196 197 //TRY TO RUN DATA CODE 198 try { 199 AAPL_data_code(data); 200 } catch(err) { 201 if (AAPL_warnings == true) { 202 txt="ERROR: \nThere was an error with data_code.\n"; 203 txt+="Error description: " + err.message; 204 alert(txt); 205 } 206 } 207 208 209 //GET PAGE CONTENT 210 data = data.split('id="' + AAPL_content + '"')[1]; 211 data = data.substring(data.indexOf('>') + 1); 212 var depth = 1; 213 var output = ''; 214 215 while(depth > 0) { 216 temp = data.split('</div>')[0]; 217 218 //count occurrences 219 i = 0; 220 pos = temp.indexOf("<div"); 221 while (pos != -1) { 222 i++; 223 pos = temp.indexOf("<div", pos + 1); 224 } 225 //end count 226 depth=depth+i-1; 227 output=output+data.split('</div>')[0] + '</div>'; 228 data = data.substring(data.indexOf('</div>') + 6); 229 } 230 231 //put the resulting html back into the page! 232 233 //See peakaboo below - NEVER TRUST jQuery to sort ALL your problems - this breaks Ie7 + 8 :o 234 //jQuery('#' + AAPL_content).html(output); 235 236 //Nothing like good old pure JavaScript... 237 document.getElementById(AAPL_content).innerHTML = output; 238 239 //move content area so we cant see it. 240 jQuery('#' + AAPL_content).css("position", "absolute"); 241 jQuery('#' + AAPL_content).css("left", "20000px"); 242 243 //show the content area 244 jQuery('#' + AAPL_content).show(); 245 246 //recall loader so that new URLS are captured. 247 AAPL_loadPageInit("#" + AAPL_content + " "); 248 249 if (AAPL_reloadDocumentReady == true) { 250 jQuery(document).trigger("ready"); 251 } 252 253 254 //TRY TO RUN RELOAD CODE 255 try { 256 AAPL_reload_code(); 257 } catch(err) { 258 if (AAPL_warnings == true) { 259 txt="ERROR: \nThere was an error with reload_code.\n"; 260 txt+="Error description: " + err.message; 261 alert(txt); 262 } 263 } 264 265 //now hide it again and put the position back! 266 jQuery('#' + AAPL_content).hide(); 267 jQuery('#' + AAPL_content).css("position", ""); 268 jQuery('#' + AAPL_content).css("left", ""); 269 270 jQuery('#' + AAPL_content).fadeIn(0, function() {}); 271 }, 272 error: function(jqXHR, textStatus, errorThrown) { 273 //Would append this, but would not be good if this fired more than once!! 274 AAPL_isLoad = false; 275 document.title = "Error loading requested page!"; 276 277 if (AAPL_warnings == true) { 278 txt="ERROR: \nThere was an error with AJAX.\n"; 279 txt+="Error status: " + textStatus + "\n"; 280 txt+="Error: " + errorThrown; 281 alert(txt); 282 } 283 284 //See peakaboo below - NEVER TRUST jQuery to sort ALL your problems - this breaks Ie7 + 8 :o 285 //jQuery('#' + AAPL_content).html(AAPL_loading_error_code); 286 287 //Nothing like good old pure JavaScript... 288 document.getElementById(AAPL_content).innerHTML = AAPL_loading_error_code; 289 } 290 }); 291 }); 292 }); 293 } 294} 295 296function submitSearch(param){ 297 if (!AAPL_isLoad){ 298 AAPL_loadPage(AAPL_searchPath, 0, param); 299 //Keep Search Parameters - need to test? 300 //https://wordpress.org/support/topic/keep-search-query-parameters/ 301 //AAPL_loadPage(AAPL_searchPath + "?" + param, 0, param); 302 } 303} 304 305function AAPL_check_ignore(url) { 306 for (var i in AAPL_ignore) { 307 if (url.indexOf(AAPL_ignore[i]) >= 0) { 308 return false; 309 } 310 } 311 312 /*___ ____ __ __ _ __ ____ __ __ 313 ( _ \( __) / _\ ( / ) / _\ ( _ \ / \ / \ 314 ) __/ ) _) / \ ) ( / \ ) _ (( O )( O ) 315 (__) (____)\_/\_/(__\_)\_/\_/(____/ \__/ \__/ 316 ____ __ _ _ ____ ____ ____ __ __ _ __ __ __ _ _ _ 317 ( __)( )( \/ )( __)( \ ( __)( )( ( \ / _\ ( ) ( ) ( \/ )/ \ 318 ) _) )( ) ( ) _) ) D ( ) _) )( / // \/ (_/\/ (_/\ ) / \_/ 319 (__) (__)(_/\_)(____)(____/ (__) (__)\_)__)\_/\_/\____/\____/(__/ (_) 320 */ 321 322 //AHHHGGRRR!! Long story short, IE is a nightmare and this plagued me for many nights :( 323 //The problem was actually down to jQuery, once I decided to replace the code commented out above (labelled peakaboo) with native JS it worked perfectly! 324 325 return true; 326}
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.