Team:Heidelberg/js/notebook

From 2014.igem.org

(Difference between revisions)
Line 1: Line 1:
-
var projects = {
 
-
DNMT1: "DNMT1 description",
 
-
LOV: "LOV Domain description",
 
-
Lyso: "Lysozyme description",
 
-
Xyla: "Xylanase description",
 
-
Toolbox: "Toolbox description",
 
-
General: "General description",
 
-
};
 
-
 
scrollToElement = function(id){
scrollToElement = function(id){
$('#outerWrapper').animate({scrollTop: $('#'+id).offset().top - $('#innerWrapper').offset().top}, 1500, "easeInOutCubic");
$('#outerWrapper').animate({scrollTop: $('#'+id).offset().top - $('#innerWrapper').offset().top}, 1500, "easeInOutCubic");
}
}
-
updateToTimestamp = function(timestamp) {
+
updateToTimestamp = function(timestamp, updateGraph) {
console.log("Updating to Timestamp: ", timestamp);
console.log("Updating to Timestamp: ", timestamp);
-
var $week = $('#innerWrapper .'+selectedProject).filter(function(){
+
var $week = $('#innerWrapper .'+selectedSubproject).filter(function(){
return ($(this).data("timestamp") <= timestamp) && (timestamp < $(this).data("timestamp")+604800);
return ($(this).data("timestamp") <= timestamp) && (timestamp < $(this).data("timestamp")+604800);
}).first();
}).first();
-
$('#innerWrapper .'+selectedProject).removeClass('active');
+
$('#innerWrapper .'+selectedSubproject).removeClass('active');
$('#outerWrapper').stop(true);
$('#outerWrapper').stop(true);
$week.addClass('active');
$week.addClass('active');
Line 27: Line 18:
$month.addClass('active');
$month.addClass('active');
-
setDate(timestamp);
+
if (updateGraph) setDate(timestamp);
}
}
var viewModel = new (function () {
var viewModel = new (function () {
var self = this;
var self = this;
-
self.projects = ['DNMT1', 'LOV', 'Lyso', 'Xyla', 'Toolbox', 'General']
 
-
self.selected = ko.observable('General');
 
-
 
self.loading = ko.observable(true);
self.loading = ko.observable(true);
self.experiment = ko.observable();
self.experiment = ko.observable();
Line 45: Line 33:
$('.titles span').removeClass("active");
$('.titles span').removeClass("active");
$(event.target).addClass("active");
$(event.target).addClass("active");
-
$('#project-description').html(projects[event.target.id]);
+
selectSubproject(event.target.id);
-
selectedProject = event.target.id;
+
selectedSubproject = event.target.id;
-
console.log(selectedProject);
+
$('#innerWrapper > :not(.'+selectedSubproject).fadeOut();
-
$('#innerWrapper > :not(.'+selectedProject).fadeOut();
+
$('#innerWrapper > .'+selectedSubproject).fadeIn();
-
$('#innerWrapper > .'+selectedProject).fadeIn();
+
});
-
});
+
$(".month").click(function(event){
$(".month").click(function(event){

Revision as of 23:01, 17 October 2014

scrollToElement = function(id){ $('#outerWrapper').animate({scrollTop: $('#'+id).offset().top - $('#innerWrapper').offset().top}, 1500, "easeInOutCubic"); }

updateToTimestamp = function(timestamp, updateGraph) { console.log("Updating to Timestamp: ", timestamp); var $week = $('#innerWrapper .'+selectedSubproject).filter(function(){ return ($(this).data("timestamp") <= timestamp) && (timestamp < $(this).data("timestamp")+604800); }).first(); $('#innerWrapper .'+selectedSubproject).removeClass('active'); $('#outerWrapper').stop(true); $week.addClass('active'); $('#outerWrapper').animate({scrollTop: ($week.offset().top - $('#innerWrapper').offset().top)-20}, 1500, "easeInOutCubic"); var $month = $('.month').filter(function(){ return $(this).data("timestamp") <= timestamp; }).last(); $('.month').removeClass('active'); $month.addClass('active');

if (updateGraph) setDate(timestamp); }

var viewModel = new (function () { var self = this; self.loading = ko.observable(true); self.experiment = ko.observable(); self.protocols = protocols; })();

var $viewExperimentModal; $(function () { $(".titles span").click(function(event){ $('.titles span').removeClass("active"); $(event.target).addClass("active"); selectSubproject(event.target.id); selectedSubproject = event.target.id; $('#innerWrapper > :not(.'+selectedSubproject).fadeOut(); $('#innerWrapper > .'+selectedSubproject).fadeIn(); });

$(".month").click(function(event){ event.preventDefault(); updateToTimestamp($(this).data("timestamp"), true); return false; });

$(".weekentry").click(function() { updateToTimestamp($(this).data("timestamp"), true); });

ko.applyBindings(viewModel); $viewExperimentModal = $('#viewExperimentModal'); });

var detailedJSON, detailedJSONName; function showExperiment(date, id) { viewModel.loading(true); $viewExperimentModal.modal();

var file = getJSONForDate(date).detailedFile; if (file == detailedJSONName) { viewModel.experiment(detailedJSON[id]); viewModel.loading(false); } else { (function (file) { $.getJSON(file, function (data) { detailedJSON = data; detailedJSONName = file; viewModel.experiment(data[id]); viewModel.loading(false); }); })(file); } }