Team:TU Delft/pieter/loadtest
From 2010.igem.org
(Difference between revisions)
(24 intermediate revisions not shown) | |||
Line 1: | Line 1: | ||
<html> | <html> | ||
- | <script type="text/javascript" src=" | + | <script type="text/javascript" src="https://2010.igem.org/Team:TU_Delft/files/jquery_hashchange_min?action=raw&gen=js"></script> |
- | + | ||
- | function | + | <script type="text/javascript" src="http://github.com/cowboy/jquery-hashchange/raw/v1.3/jquery.ba-hashchange.js"></script> |
+ | |||
+ | <script type="text/javascript"> | ||
+ | |||
+ | |||
+ | |||
+ | function rewriteLinks(elem) { | ||
+ | |||
+ | $("a", elem).each(function(){ | ||
+ | |||
+ | var isFound = $( this ).attr( 'href' ).toString().search( new RegExp( /Team:TU_Delft/i ) ); | ||
+ | |||
+ | if(isFound > 0) { | ||
+ | this.href = this.href.replace("Team:TU_Delft/", wgPageName+ "#"); | ||
+ | } | ||
+ | |||
+ | }); | ||
+ | |||
+ | } | ||
+ | |||
+ | function hashchangecb() { | ||
+ | var hash=location.hash; | ||
// hash doesn't contain the first # character. | // hash doesn't contain the first # character. | ||
if(hash) { | if(hash) { | ||
- | var url = wgServer+"/Team:TU_Delft/pieter/loadtest/"+hash+"?action=render | + | var url = wgServer + "/Team:TU_Delft/pieter/loadtest/" +hash.substring(1)+ "?action=render"; |
- | $.get(url, function(data) { | + | $.get(url, function(data) { |
- | $("#load").html(data).fadeIn(200); | + | $("#load").html(data).fadeIn(200); |
- | rewriteLinks($("#load")); | + | // rewriteLinks($("#load")); |
- | } | + | }); |
- | + | ||
} else { | } else { | ||
// start page | // start page | ||
Line 18: | Line 38: | ||
} | } | ||
} | } | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
$(function() { | $(function() { | ||
- | + | $(window).hashchange(hashchangecb); | |
- | + | ||
- | + | // set click event for buttons | |
- | $. | + | |
- | + | ||
- | // set | + | |
$("a.menu").click(function(){ | $("a.menu").click(function(){ | ||
// | // | ||
var hash = this.href; | var hash = this.href; | ||
hash = hash.replace(/^.*#/, ''); | hash = hash.replace(/^.*#/, ''); | ||
- | + | location.hash=hash; | |
- | + | ||
- | + | ||
return false; | return false; | ||
}); | }); |
Latest revision as of 17:47, 22 July 2010
Ajax load
load 1
load 2
load 3
Loaded html: