Team:TU Delft/pieter/loadtest

From 2010.igem.org

(Difference between revisions)
 
(34 intermediate revisions not shown)
Line 1: Line 1:
<html>
<html>
-
<script type="text/javascript" src="http://nix.lv/history/jquery.history.js"></script>
+
<script type="text/javascript" src="https://2010.igem.org/Team:TU_Delft/files/jquery_hashchange_min?action=raw&gen=js"></script>
-
<script type="text/javascript">
+
 
-
function pageload(hash) {
+
<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) {
-
// restore ajax loaded state
+
var url = wgServer + "/Team:TU_Delft/pieter/loadtest/" +hash.substring(1)+ "?action=render";
-
$("#load").load(hash + ".html");
+
$.get(url, function(data) {
 +
$("#load").html(data).fadeIn(200);
 +
// rewriteLinks($("#load"));
 +
});
} else {
} else {
// start page
// start page
Line 15: Line 39:
}
}
-
$(function() {
 
-
// Initialize history plugin.
+
$(function() {
-
// The callback is called at once by present location.hash.
+
$(window).hashchange(hashchangecb);
-
$.history.init(pageload);
+
-
+
// set click event for buttons
-
// set onlick event for buttons
+
$("a.menu").click(function(){
-
$("a").click(function(){
+
//  
//  
var hash = this.href;
var hash = this.href;
-
// hash = hash.replace(/^.*#/, '');
+
hash = hash.replace(/^.*#/, '');
-
// moves to a new page.  
+
location.hash=hash;
-
// pageload is called at once.
+
return false;
-
// $.history.load(hash);
+
-
// return false;
+
});
});
Line 38: Line 58:
Ajax load<br>
Ajax load<br>
-
<a href="#1" rel="history">load 1</a><br>
+
<a href="#1" class="menu">load 1</a><br>
-
<a href="#2" rel="history">load 2</a><br>
+
<a href="#2" class="menu">load 2</a><br>
-
<a href="#3" rel="history">load 3</a><br>
+
<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: