Advertisement
diddlside

Untitled

Jul 3rd, 2011
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var RLoad = {};
  2.     RLoad.LoadCount = 0;
  3.     RLoad.Scripts = [
  4.         'js/rajax/Rajax.Type.Identifier.js',
  5.         'js/rajax/jquery.rajax.transition.js',
  6.         'js/rajax/jquery.rajax.ajax.js',
  7.         'js/rajax/jquery.rajax.navi.js',
  8.         'js/rajax/jquery.rajax.watch.js'
  9.     ];
  10. $(function() {
  11.     //$.ajaxSetup({ cache: true });
  12.    
  13.     RLoad.PreloadView = $('<div style="position:absolute; top:7px; left:7px; border:1px solid black; background:white; padding:3px; font-size:10pt; font-family:\'courier\'" />').appendTo($('body'));
  14.    
  15.     function autoloadScripts(url)
  16.     {
  17.         if(RLoad.LoadCount <= RLoad.Scripts.length)
  18.         {
  19.             $.ajax({
  20.                 url: url,
  21.                 dataType: 'script',
  22.                 success: function() {  
  23.                     $(RLoad.PreloadView).html('Loading: ' + Math.round(RLoad.LoadCount + 1 / RLoad.Scripts.length * 100) + '% / 100%');
  24.                     autoloadScripts(RLoad.Scripts[RLoad.LoadCount]);
  25.                 },
  26.                 error : function() {
  27.                     $('body').append('<br />File in ' + url + ' could not be loaded.');
  28.                 }
  29.             });
  30.             RLoad.LoadCount += 1;
  31.         }
  32.         else
  33.         {
  34.             $(PreloadView).remove();
  35.         }
  36.     }
  37.    
  38.     autoloadScripts(RLoad.Scripts[0]);
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement