Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ajaxPageChange() {
- // Indsætter en loading.gif
- 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>';
- $(content).insertAfter('.pagination');
- $(".loading").ajaxStart(function(){
- $('.pagination').hide();
- $(this).show();
- }).ajaxStop(function(){
- $(this).hide();
- $('.pagination').show();
- }).hide();
- $('.pagination a').click(function(){
- $.ajax({
- url: $(this).attr('href'),
- success: function (data) {
- //window.testa = data; // debug
- // Henter title (side og titel på tråd), som indsættes i <title> og <h1>
- // newz.dk sætter normalt kun side ind i <h1>, når man skifter side, tsk tsk
- re = /<title>(.+)».+».+<\/title>/;
- a = re.exec(data)[1];
- $("#container div h1").html(a);
- $("title").html(a);
- $("#postcontainer").html($(data).find("#postcontainer").html());
- // Sætter hash til første indlæg, så man kan kopiere link til den rette side
- window.location.hash = $("#comments > div:first-child h2 a:first-child").attr('name');
- // (Gen)aktiverer js for "Yderligere information", etc. ved at sætte event handlers igen (newz.dk-funktion)
- UpdatePosts();
- // Opdaterer newz.dk's variable, så den kun henter nye indlæg, når man er på sidste side
- re = /_pageId = (\d);/;
- _pageId = re.exec(data)[1];
- re = /_lastPage = (\d);/;
- _lastPage = re.exec(data)[1];
- if (_pageId != _lastPage)
- PauseAutoUpdate()
- else
- StartAutoUpdate();
- // Sætter event handles for de nye knapper
- ajaxPageChange();
- }
- });
- return false;
- });
- } ajaxPageChange();
Advertisement
Add Comment
Please, Sign In to add comment