|
|
(4 intermediate revisions not shown) |
Line 2: |
Line 2: |
| {{:Team:TU_Delft/header2}} | | {{:Team:TU_Delft/header2}} |
| <html> | | <html> |
- |
| |
- | <!-- Datepicker for blog -->
| |
- | <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
| |
- | <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
| |
- |
| |
| | | |
| <!-- Scripting - START /--> | | <!-- 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" src="http://github.com/cowboy/jquery-hashchange/raw/v1.3/jquery.ba-hashchange.js"></script> |
| | | |
- | <script type="text/javascript"> | + | <script type="text/javascript" src="https://2010.igem.org/Team:TU_Delft/files/main_test.js?action=raw&ctype=text/javascript"></script> |
- | //Global Vars
| + | |
- | var activePage;
| + | |
- | | + | |
- | // 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 setHash(page, kvmap) {
| + | |
- | var str = '#page=' + page;
| + | |
- | var i;
| + | |
- | for(i in kvmap) {
| + | |
- | str += "\&" + i + '=' + kvmap[i];
| + | |
- | }
| + | |
- | location.hash = str;
| + | |
- | }
| + | |
- | | + | |
- | function processPage()
| + | |
- | {
| + | |
- | $(window).trigger('page_init');
| + | |
- | rewriteLinks($("#load"));
| + | |
- | }
| + | |
- | | + | |
- | function loadPage(page)
| + | |
- | {
| + | |
- | activePage = page;
| + | |
- | var url = wgServer + "/Team:TU_Delft/" + page + "?action=render";
| + | |
- | $(window).trigger('page_close');
| + | |
- | $("#load").fadeOut(200);
| + | |
- |
| + | |
- | $.get(url, function(data) {
| + | |
- | alert('page downloaded: ' + page);
| + | |
- | $("#load").html(data).fadeIn(200).queue(processPage);
| + | |
- | });
| + | |
- | }
| + | |
- | | + | |
- | function historyCallback() {
| + | |
- | var hash = location.hash;
| + | |
- | if(hash) {
| + | |
- | hash = hash.substring(1);
| + | |
- | if(hash.split('=').length > 1) {
| + | |
- | var kvmap = splitHash(hash);
| + | |
- | var changepage;
| + | |
- | | + | |
- | // looks a little clumsy, but js AND operator conflicts with mediawiki markup
| + | |
- | if (kvmap.page) if(kvmap.page != activePage) changepage = kvmap.page;
| + | |
- | | + | |
- | if (changepage) {
| + | |
- | loadPage(changepage);
| + | |
- | } else
| + | |
- | $(window).trigger('hashupdate', [ kvmap ]);
| + | |
- | }
| + | |
- | } 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 /--> | | <!-- Scripting - END /--> |