|
|
(11 intermediate revisions not shown) |
Line 27: |
Line 27: |
| <!-- Internet Explorer PNG fix - END /--> | | <!-- Internet Explorer PNG fix - END /--> |
| | | |
- | <!-- Scripting - START /-->
| |
- | <script type="text/javascript" src="http://github.com/cowboy/jquery-hashchange/raw/v1.3/jquery.ba-hashchange.js"></script>
| |
| | | |
- | <script type="text/javascript">
| |
- | //Global Vars
| |
- |
| |
- | // Set document ready callback
| |
- | $(function() {
| |
- | // Initialize history plugin.
| |
- | $(window).hashchange(historyCallback);
| |
- | rewriteLinks($("#navlist"));
| |
- |
| |
- | historyCallback();
| |
- |
| |
- | // setup hovering
| |
- | $(".menu_button").hover(
| |
- | function () { $(this).addClass("hover"); },
| |
- | function () { $(this).removeClass("hover"); }
| |
- | );
| |
- | });
| |
- |
| |
- |
| |
- | function isDefined(variable)
| |
- | {
| |
- | return typeof(window[variable]) != "undefined";
| |
- | }
| |
- |
| |
- | function splitHash(hash) {
| |
- | var kvpairs = hash.split('&');
| |
- | var i;
| |
- | var kvmap = {};
| |
- | for(i=0;i<kvpairs.length;i++) {
| |
- | var s = kvpairs[i].split('=');
| |
- | kvmap[s[0]] = s[1];
| |
- | }
| |
- | return kvmap;
| |
- | }
| |
- |
| |
- | function loadPage(page)
| |
- | {
| |
- | var url = wgServer + "/Team:TU_Delft/" + page + "?action=render";
| |
- | $("#load").fadeOut(200);
| |
- | if (isDefined('page_init'))
| |
- | delete page_init;
| |
- |
| |
- | $.get(url, function(data) {
| |
- | $("#load").html(data).fadeIn(200).queue(function() {
| |
- | if(isDefined('page_init')) page_init();
| |
- | rewriteLinks($("#load"));
| |
- | });
| |
- | });
| |
- | }
| |
- |
| |
- | function historyCallback() {
| |
- | var hash = location.hash;
| |
- | if(hash) {
| |
- | hash = hash.substring(1);
| |
- | if(hash.split('=').length > 1) {
| |
- | var kvmap = splitHash(hash);
| |
- | if (kvmap.page) {
| |
- | loadPage(kvmap.page);
| |
- | }
| |
- | }
| |
- | } else {
| |
- | loadPage('pages/home');
| |
- | }
| |
- | }
| |
- |
| |
- |
| |
- | function rewriteLinks(elem) {
| |
- | $("a",elem).each(function() {
| |
- | var txt = $(this).text();
| |
- |
| |
- | if(this.hash)
| |
- | this.href = this.hash;
| |
- | else if(txt != "edit")
| |
- | this.href = this.href.replace("https://2010.igem.org/Team:TU_Delft/", "#page=");
| |
- | });
| |
- | }
| |
- |
| |
- | </script>
| |
- |
| |
- | <!-- Scripting - END /-->
| |
| | | |
| <!-- Main CSS - START /--> | | <!-- Main CSS - START /--> |