Team:Vanderbilt/Page

From 2014.igem.org

Revision as of 21:10, 25 January 2015 by Hwangas (Talk | contribs)

/**

* Created by Anna Hwang on 1/15/2015.
*/

var leftPage = document.getElementById("left_page");

var rightPage = document.getElementById("right_page");

/**@class Page

* @description A class in charge of creating, updating, and destroying pages between page turns.
* @param pageNum: the page number of the page (e.g. Home = 1, Team = 2, ...)
* **/

function Page(myBuilder) {

   var subPageNum = 1;
   var builder = myBuilder; //defined in script of page
   var maxSubPage = builder.getMaxSubPage();
   this.destroyPage = function() {
       while(leftPage.hasChildNodes()) {
           leftPage.removeChild(leftPage.childNodes[0]);
       }
       while(rightPage.hasChildNodes()) {
           rightPage.removeChild(rightPage.childNodes[0]);
       }
   };
   this.turnPage = function(dir) {
       subPageNum += dir;
       this.destroyPage();
       builder.createSubPage(subPageNum);
   };
   this.getSubPageNum = function () {
       return subPageNum;
   };
   this.getMaxSubPage = function() {
       return maxSubPage;
   };

}