Team:WITS-CSIR SA/client/CalendarModel.js

From 2011.igem.org

Revision as of 09:03, 21 September 2011 by Sashrez (Talk | contribs)

/// <reference path="../../js/lib/backbone.js" /> /// <reference path="../../js/lib/underscore.js" /> /// <reference path="../../js/lib/jlayout.border.js" /> /// <reference path="../../js/lib/jquery-1.5.1.min.js" /> /// <reference path="../../js/lib/jquery-ui-1.8.14.custom.min.js" /> /// <reference path="../../js/lib/jQuery.BlockUI.js" /> /// <reference path="../../js/lib/jquery.fling.js" /> /// <reference path="../../js/lib/jquery.jlayout.js" /> /// <reference path="../../js/lib/jquery.sizes.js" /> /// <reference path="../../js/lib/modernizr-1.7.min.js" /> /// <reference path="../../js/lib/sammy-latest.min.js" /> /// <reference path="../../js/common.js" />

$(function () {

   var Day = Backbone.Model.extend({
       name: null,
       content: null
   });
   var Days = Backbone.Collection.extend({
       initialize: function (models, options) {
           this.opts = options;
       },
       hasContent: function () { return this.length > 0; }
   });
   var Week = Backbone.Model.extend({
       initialize: function () {
           this.days = new Days(null, { Week: this });
       },
       name: null,
       hasContent: function () { return this.days.hasContent(); }
   });
   var Weeks = Backbone.Collection.extend({
       initialize: function (models, options) {
           this.opts = options;
       },
       hasContent: function () {
           for (var i = 0; i < this.length; i++)
               if (this.models[i].hasContent()) { return true; }
           return false;
       }
   });
   var Month = Backbone.Model.extend({
       initialize: function () {
           this.weeks = new Weeks(null, { Month: this });
       },
       name: null,
       hasContent: function () {
           return this.weeks.hasContent();
       }
   });
   var Months = Backbone.Collection.extend({
       initialize: function (models, options) {
           this.opts = options;
       }
   });
   var Year = Backbone.Model.extend({
       initialize: function () {
           this.months = new Months(null, { Year: this });
           this.months.add(new Month({ name: 'February' }));
           this.months.add(new Month({ name: 'March' }));
           this.months.add(new Month({ name: 'April' }));
           this.months.add(new Month({ name: 'May' }));
           this.months.add(new Month({ name: 'June' }));
           this.months.add(new Month({ name: 'July' }));
           this.months.add(new Month({ name: 'August' }));
           this.months.add(new Month({ name: 'September' }));


       },
       year: null,
       getMonth: function (name) {
           var caller = this;
           var m = $.grep(caller.months.models, function (n, i) {
               return n.get('name').toLowerCase() == name.toLowerCase();
           });
           return m.length > 0 ? m[0] : null;
       },
       hasContent: function () { return this.months.hasContent(); }
   });
   var Calendar = Backbone.View.extend({
       el: $('div.calendar'),
       initialize: function () {
           this.year = new Year({ year: 2011 });
this.template = '' + ' ' + ' ' + ' ' + ' ' + '</table>'; }, render: function () { var html = _.template(this.template, this); this.el.html(html); var caller = this; $('div.month', this.el).tabs().hide(); $('ul.months input:button', this.el).unbind('click').bind('click', function () { var month = $(this).attr('data-month'); $('ul.months input:button', this.el).removeClass('ui-state-highlight'); $(this).addClass('ui-state-highlight'); $('div.month', caller.el).hide(); $('div.' + month, caller.el).slideDown(500); }); FormatButtons(); $('ul.months input:button', this.el).eq(0).click(); } }); $.fling('subscribe', 'ready', function () { var calendar = new Calendar(), week = null, month = null; month = calendar.year.getMonth('february'); week = new Week({ name: 'Week 2' }); week.days.add(new Day({ name: 'Monday', content: '

This is a test

' })); week.days.add(new Day({ name: 'Wednesday', content: '

This is a test

' })); week.days.add(new Day({ name: 'Friday', content: '

This is a test

' }));
       month.weeks.add(week);
       month = calendar.year.getMonth('march');
       week = new Week({ name: 'Week 2' });
week.days.add(new Day({ name: 'Monday', content: '

This is a test

' })); week.days.add(new Day({ name: 'Wednesday', content: '

This is a test

' })); week.days.add(new Day({ name: 'Friday', content: '

This is a test

' }));
       month.weeks.add(week);
       month = calendar.year.getMonth('april');
       week = new Week({ name: 'Week 2' });
week.days.add(new Day({ name: 'Wednesday', content: '

This is a test

' })); week.days.add(new Day({ name: 'Friday', content: '

This is a test

' }));
       month.weeks.add(week);
       month = calendar.year.getMonth('may');
       week = new Week({ name: 'Week 2' });
week.days.add(new Day({ name: 'Monday', content: '

This is a test

' })); week.days.add(new Day({ name: 'Friday', content: '

This is a test

' }));
       month.weeks.add(week);
       month = calendar.year.getMonth('june');
       week = new Week({ name: 'Week 4' });
week.days.add(new Day({ name: 'Saturday', content: '
  • To obtain CheZ gene for later PCR reactions:</li>' + '
  • Standard PCR of CheZ from genomic DNA</li>' + '
  • Ran 1% gel – no PCR product --> try gradient PCR</li>' })); month.weeks.add(week); month = calendar.year.getMonth('june'); week = new Week({ name: 'Week 5' }); week.days.add(new Day({ name: 'Monday', content: '
  • Primer extension PCR of lox66 (Part:BBa_K537019) and lox71 (Part:BBa_K537020) - PCR product verified on 1% gel (worked)</li>' })); week.days.add(new Day({ name: 'Tuesday', content: '
  • Gradient PCR of CheZ from genomic DNA: worked at all temperatures</li>' + '
  • Digested lox66(Part:BBa_K537019) and lox71(Part:BBa_K537020) --> ligated into the PSB1C3 backbone (Did not work) </li>' + '
  • Round one ThRS1-CheZ (Part:BBa_K537001), ThRS2-CheZ(Part:BBa_K537002), ThRS1-venus(Part:BBa_K537003) and ThRS2-venus(Part:BBa_K537004) standard PCR (ThRS1-venus(Part:BBa_K537003) did not work </li>' + '
  • Round one AtRS-CheZ (Part:BBa_K537000) standard PCR (Worked) </li>' + '
  • Round one AtRS-mRFP1(Part:BBa_K537008) standard PCR (Did not work)</li>' + '
  • mRFP1(Part:BBa_K537005) C-Fusion standard PCR (Did not work)</li>' + '
  • Venus(Part:BBa_K537006) C-Fusion PCR (Did not work)</li>' })); week.days.add(new Day({ name: 'Wednesday', content: ‘
  • Round two AtRS-CheZ(Part:BBa_K537000) standard PCR (Did not work) </li>‘ + '
  • Round one AtRS-mRFP1(Part:BBa_K537008) standard PCR (Did not work) </li>‘ + ‘
  • Round one mRFP1(Part:BBa_K537005) standard PCR (Worked) </li>‘+ ‘
  • Second round ThRS1-CheZ (Part:BBa_K537001), ThRS2-CheZ(Part:BBa_K537002), ThRS1-venus(Part:BBa_K537003) and ThRS1-venus(Part:BBa_K537003) PCR (ThRS2-venus(Part:BBa_K537004) did not work) </li>‘ + ‘
  • Repeat round one PCR of ThRS1-venus(Part:BBa_K537003) (Worked) </li>‘ })); week.days.add(new Day({ name: 'Thursday', content: '
  • Round two AtRS-CheZ (Part:BBa_K537000) (Part:BBa_K537000) standard PCR (Did not work) </li>' + '
  • Round two mRFP1(Part:BBa_K537005) standard PCR (Worked) </li>'+ '
  • Round one AtRS-mRFP1(Part:BBa_K537008) standard PCR (Did not work) </li>'+ '
  • Ligation of ThRS1-CheZ (Part:BBa_K537001) and ThRS2-CheZ(Part:BBa_K537002) into pSB1C3 backbone (did not work) </li>'+ '
  • Venus(Part:BBa_K537006) C-Fusion PCR (worked)</li>'+ '
  • Second round ThRS1-venus(Part:BBa_K537003) and ThRS2-venus(Part:BBa_K537004) (ThRS1-venus did not work) </li>' })); month.weeks.add(week); month = calendar.year.getMonth('july'); week = new Week({ name: 'Week 1' }); week.days.add(new Day({ name: 'Friday', content: '

    This is a test

    ' })); week.days.add(new Day({ name: 'Saturday', content: '

    This is a test

    ' }));
           month.weeks.add(week);
    
           week = new Week({ name: 'Week 2' });
    
    week.days.add(new Day({ name: 'Monday', content: '
  • Ligation of ThRS1-venus(Part:BBa_K537003) and ThRS2-venus(Part:BBa_K537004) (did not work) </li>' + '
  • Ligation of gel extracted AtRS-CheZ (Part:BBa_K537000), AtRS-mRFP1(Part:BBa_K537008) and mRFP1(Part:BBa_K537005) C-Fusion into pSB1C3 backbone (Did not work) – repeat tomorrow </li>' })); week.days.add(new Day({ name: 'Tuesday', content: '
  • Ligation of gel extracted AtRS-CheZ (Part:BBa_K537000), AtRS-mRFP1(Part:BBa_K537008) and mRFP1(Part:BBa_K537005) C-Fusion into pSB1A3 backbone (Worked) </li>'+ '
  • Verification of ThRS1-CheZ (Part:BBa_K537001), ThRS2-CheZ(Part:BBa_K537002), ThRS1-venus(Part:BBa_K537003) , ThRS2-venus(Part:BBa_K537004) and Venus(Part:BBa_K537006) C-Fusion on agarose gel </li>' })); week.days.add(new Day({ name: 'Wednesday', content: '
  • Plasmid prep CheZ, AtRS-mRFP1(Part:BBa_K537008) and mRFP1(Part:BBa_K537005) C-Fusion in pSB1C3 backbone, digested and verified on 1% agarose gel</li>'+ '
  • Digest the IPTG inducible promoter (obtained from kit)</li>' })); week.days.add(new Day({ name: 'Thursday', content: '
  • Plasmid prep, digested and gel extracted Cre recombinase, Lox promoter, RBS and double terminator</li>'+ '
  • Ligation of gel extracted AtRS-CheZ (Part:BBa_K537000), AtRS-mRFP1(Part:BBa_K537008), mRFP1(Part:BBa_K537005) C-Fusion and Venus(Part:BBa_K537006) C-Fusion into pSB1C3 backbone</li>'+ '
  • Ligation of digested and column-purified ThRS1-CheZ (Part:BBa_K537001), ThRS1-venus(Part:BBa_K537003), ThRS2-CheZ(Part:BBa_K537002) , ThRS2-venus(Part:BBa_K537004) and Venus(Part:BBa_K537006) C-Fusion PCR products into pSB1C3 backbone</li>' })); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 3' }); week.days.add(new Day({ name: 'Monday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Tuesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Wednesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Thursday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 4' }); week.days.add(new Day({ name: 'Monday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Tuesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Wednesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Thursday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 5' }); week.days.add(new Day({ name: 'Monday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Tuesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Wednesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Thursday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 6' }); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); month = calendar.year.getMonth('august'); week = new Week({ name: 'Week 1' }); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 2' }); week.days.add(new Day({ name: 'Monday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Tuesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Wednesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Thursday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 3' }); week.days.add(new Day({ name: 'Monday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Tuesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Wednesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Thursday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 4' }); week.days.add(new Day({ name: 'Monday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Tuesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Wednesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Thursday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 5' }); week.days.add(new Day({ name: 'Monday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Tuesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Wednesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Thursday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 6' }); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); month = calendar.year.getMonth('september'); week = new Week({ name: 'Week 1' }); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 2' }); week.days.add(new Day({ name: 'Monday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Tuesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Wednesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Thursday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 3' }); week.days.add(new Day({ name: 'Monday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Tuesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Wednesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Thursday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 4' }); week.days.add(new Day({ name: 'Monday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Tuesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Wednesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Thursday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 5' }); week.days.add(new Day({ name: 'Monday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Tuesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Wednesday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Thursday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Friday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Saturday', content: '
  • This is a test</li>' })); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); week = new Week({ name: 'Week 6' }); week.days.add(new Day({ name: 'Sunday', content: '
  • This is a test</li>' })); month.weeks.add(week); calendar.render(); }); });
  • ' + '
      ' + ' <% _.forEach(year.months.models, function(month) { %>' + ' <% if(month.hasContent()){ %>' + '
    • <input type="button" data-month="<%= month.get(\'name\') %>" value="<%= month.get(\'name\') + \' \' + year.get(\'year\') %>" style="width:95%;" />
    • ' +
                                 '               <% } %>' +
                                 '               <% }); %>' +
      
      '
    ' + '
    ' +
                               '            <% _.forEach(year.months.models, function(month) { %>' +
                               '            <% if(month.hasContent()){ %>' +
                               '               <div class="month <%= month.get(\'name\') %>" id="<%= month.get(\'name\') + \'_\' + month.cid %>">' +
    
    '
      ' + ' <% _.forEach(month.weeks.models, function(week) { %>' + '
    • <a href="#<%= month.get(\'name\') + \'_week_\' + week.cid %>"><%= week.get(\'name\') %></a>
    • ' +
                                 '                   <% }); %>' +
      
      '
    ' +
                               '                   <% _.forEach(month.weeks.models, function(week) { %>' +
                               '                       <div id="<%= month.get(\'name\') + \'_week_\' + week.cid %>">' +
                               '                       <% _.forEach(week.days.models, function(day) { %>' +
    
    '

    <%= day.get(\'name\') %>

    ' +
                               '                           <%= day.get(\'content\') %>' +
                               '                       <% }); %>' +
                               '                       </div>' +
                               '                   <% }); %>' +
                               '               </div>' +
                               '            <% } %>' +
                               '            <% }); %>' +
    
    '