Team:Hong Kong-CUHK/home.html

From 2014.igem.org

(Difference between revisions)
m (formatting and pics link updated)
m
Line 240: Line 240:
};
};
-
function makelink(picset, wrapper, isAnimated, callbackClick, callbackHover) {
+
function makelink(picset, wrapper, defaultPage, isAnimated, callbackClick, callbackHover) {
-
 
+
     var deferreds = [];
     var deferreds = [];
     $.each(picset, function(index, value) {
     $.each(picset, function(index, value) {
Line 295: Line 294:
             wrapper.append(link);
             wrapper.append(link);
 +
 +
            if(value['id'] == defaultPage) {
 +
                callbackClick(value);
 +
            }
         });
         });
     });
     });
 +
}
 +
 +
function getQueryString(key) {
 +
    var query = window.location.search.substring(1);
 +
    var vars = query.split("&");
 +
    for (var i = 0; i < vars.length; i++) {
 +
        var pair = vars[i].split("=");
 +
        console.log(pair);
 +
        if (pair[0] == key) {
 +
            return pair[1];
 +
        }
 +
    }
 +
    return null;
}
}
$(document).ready(function() {
$(document).ready(function() {
 +
    var page = getQueryString('page');
-
     makelink(wikiContent, $('#train-link'), false, function(value) {
+
     makelink(wikiContent, $('#train-link'), page, false, function(value) {
         if (value['loadedContent'] != null)
         if (value['loadedContent'] != null)
             $('#wiki-content').html(value['loadedContent']);
             $('#wiki-content').html(value['loadedContent']);

Revision as of 08:50, 17 October 2014