Team:TU Delft/header2

From 2010.igem.org

(Difference between revisions)
Line 32: Line 32:
<script type="text/javascript">
<script type="text/javascript">
//Global Vars
//Global Vars
-
var activePage = "</html>{{{contentpage|home}}}<html>";
+
var activePage = "</html>{{{contentpage|home}}}<html>";
//On page load this function is called
//On page load this function is called
-
$(function() {
+
$(function() {
-
// Initialize history plugin.
+
// Initialize history plugin.
-
$.history.init(pageload);
+
$.history.init(pageload);
-
if(activePage == "home") {
+
if(activePage == "home") {
-
$.history.load("pages/home");
+
$.history.load("pages/home");
-
rewriteLinks($("#load"));
+
rewriteLinks($("#load"));
-
}
+
}
-
+
-
// set onlick event for menu buttons
+
// set onlick event for menu buttons
-
$("#wrapper a").click(function(){
+
$("#wrapper a").click(function(){
-
//
+
var hash = this.href;
-
var hash = this.href;
+
hash = hash.replace(/^.*#/, '');
-
hash = hash.replace(/^.*#/, '');
+
$.history.load(hash);
-
// moves to a new page.
+
return false;
-
// pageload is called at once.
+
});
-
$.history.load(hash);
+
-
return false;
+
-
});
+
-
  // setup hovering
+
// setup hovering
-
$(".menu_button").hover(
+
$(".menu_button").hover(
-
 
+
function () { $(this).addClass("hover"); },
-
function () {
+
function () { $(this).removeClass("hover"); }
-
    $(this).addClass("hover");
+
);
-
  },
+
-
  function () {
+
-
    $(this).removeClass("hover");
+
-
  }
+
-
);
+
-
 
+
});
});
function pageload(hash) {
function pageload(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/" +hash+ "?action=render";
-
var url = wgServer + "/Team:TU_Delft/" +hash+ "?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
+
$("#load").empty();
-
$("#load").empty();
+
-
}
+
}
}
 +
}
function rewriteLinks(elem) {
function rewriteLinks(elem) {
-
$("a",elem).each(function(){
+
$("a",elem).each(function() {
-
 
+
if($(this).text() != "edit")  
-
if($(this).text() != "edit") this.href = this.href.replace("Team:TU_Delft/", wgPageName+ "#");
+
this.href = this.href.replace("Team:TU_Delft/", wgPageName+ "#");
-
 
+
});
-
});
+
}
}

Revision as of 15:56, 21 July 2010