Team:TU Delft/pieter/loadtest
From 2010.igem.org
(Difference between revisions)
(31 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.substring(1)+ "?action=render"; | |
- | + | $.get(url, function(data) { | |
- | + | $("#load").html(data).fadeIn(200); | |
+ | // rewriteLinks($("#load")); | ||
+ | }); | ||
} else { | } else { | ||
// start page | // start page | ||
- | + | $("#load").empty(); | |
} | } | ||
} | } | ||
- | |||
- | + | $(function() { | |
- | + | $(window).hashchange(hashchangecb); | |
- | $. | + | |
- | + | // set click event for buttons | |
- | // set | + | $("a.menu").click(function(){ |
- | $("a").click(function(){ | + | |
// | // | ||
var hash = this.href; | var hash = this.href; | ||
hash = hash.replace(/^.*#/, ''); | hash = hash.replace(/^.*#/, ''); | ||
- | + | location.hash=hash; | |
- | + | ||
- | + | ||
return false; | return false; | ||
}); | }); | ||
Line 39: | Line 58: | ||
Ajax load<br> | Ajax load<br> | ||
- | <a href="#1" | + | <a href="#1" class="menu">load 1</a><br> |
- | <a href="#2" | + | <a href="#2" class="menu">load 2</a><br> |
- | <a href="#3" | + | <a href="#3" class="menu">load 3</a><br> |
<hr> | <hr> | ||
Loaded html:<br> | Loaded html:<br> | ||
<div id="load"></div></html> | <div id="load"></div></html> |
Latest revision as of 17:47, 22 July 2010
Ajax load
load 1
load 2
load 3
Loaded html: