Guest User

Untitled

a guest
Sep 21st, 2011
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function ajaxPageChange() {
  2.     // Indsætter en loading.gif
  3.     content = '<div class="loading" style="float: left; margin: -2px 10px; padding: 5px; position: relative; width: 330px;"><p><img src="http://d9projects.com/loading.gif" /> Weeeeeeeeee.</p></div>';
  4.     $(content).insertAfter('.pagination');
  5.     $(".loading").ajaxStart(function(){
  6.         $('.pagination').hide();
  7.         $(this).show();
  8.     }).ajaxStop(function(){
  9.         $(this).hide();
  10.         $('.pagination').show();
  11.     }).hide();
  12.    
  13.     $('.pagination a').click(function(){
  14.         $.ajax({
  15.             url: $(this).attr('href'),
  16.             success: function (data) {
  17.                 //window.testa = data; // debug
  18.                
  19.                 // Henter title (side og titel på tråd), som indsættes i <title> og <h1>
  20.                 // newz.dk sætter normalt kun side ind i <h1>, når man skifter side, tsk tsk
  21.                 re = /<title>(.+)&raquo;.+&raquo;.+<\/title>/;
  22.                 a = re.exec(data)[1];
  23.                 $("#container div h1").html(a);
  24.                 $("title").html(a);
  25.                 $("#postcontainer").html($(data).find("#postcontainer").html());
  26.                
  27.                 // Sætter hash til første indlæg, så man kan kopiere link til den rette side
  28.                 window.location.hash = $("#comments > div:first-child h2 a:first-child").attr('name');
  29.                
  30.                 // (Gen)aktiverer js for "Yderligere information", etc. ved at sætte event handlers igen (newz.dk-funktion)
  31.                 UpdatePosts();
  32.                
  33.                 // Opdaterer newz.dk's variable, så den kun henter nye indlæg, når man er på sidste side
  34.                 re = /_pageId = (\d);/;
  35.                 _pageId = re.exec(data)[1];
  36.                 re = /_lastPage = (\d);/;
  37.                 _lastPage = re.exec(data)[1];
  38.                 if (_pageId != _lastPage)
  39.                     PauseAutoUpdate()
  40.                 else
  41.                     StartAutoUpdate();
  42.                
  43.                 // Sætter event handles for de nye knapper
  44.                 ajaxPageChange();
  45.             }
  46.         });
  47.         return false;
  48.     });
  49. } ajaxPageChange();
Advertisement
Add Comment
Please, Sign In to add comment