Team:TU Delft/pieter/loadtest

From 2010.igem.org

(Difference between revisions)
 
(17 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" src="http://github.com/cowboy/jquery-hashchange/raw/v1.3/jquery.ba-hashchange.js"></script>
 +
 
 +
<script type="text/javascript">
 +
 
-
<script type="text/javascript">
 
function rewriteLinks(elem) {
function rewriteLinks(elem) {
-
$("a[href^=Team:TU_Delft/]", elem).each(function(){
+
$("a", elem).each(function(){
-
alert("test");
+
var isFound = $( this ).attr( 'href' ).toString().search( new RegExp( /Team:TU_Delft/i ) );
-
//this.href = this.href.replace("Team:TU_Delft/", wgPageName+ "#/");
+
if(isFound > 0) {
 +
this.href = this.href.replace("Team:TU_Delft/", wgPageName+ "#");
 +
}
});
});
Line 17: Line 24:
}
}
-
function pageload(hash) {
+
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"));
-
});
+
});
-
//$("#load").load(wgServer+"/Team:TU_Delft/pieter/loadtest/"+hash+"?action=render");
+
} else {
} else {
// start page
// start page
Line 34: Line 41:
$(function() {
$(function() {
-
 
+
$(window).hashchange(hashchangecb);
-
// Initialize history plugin.
+
-
// The callback is called at once by present location.hash.
+
// set click event for buttons
-
$.history.init(pageload);
+
-
+
-
// set onlick event for buttons
+
$("a.menu").click(function(){
$("a.menu").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.
+
-
$.history.load(hash);
+
return false;
return false;
});
});

Latest revision as of 17:47, 22 July 2010

Ajax load
load 1
load 2
load 3


Loaded html: