Template:Virginia/scripts/seqsJS

var currentSeq;

function disableScroll() {

 html=document.getElementsByTagName('html')[0];
 body=document.getElementsByTagName('body')[0];
 html.style.height = "200%";
 body.style.overflow = "hidden";
 body.style.height = "200%";  
 html.style.padding = "0px 10px 0px 0px"

}

function enableScroll() {

 html=document.getElementsByTagName('html')[0];
 body=document.getElementsByTagName('body')[0];
 html.style.height = "auto";
 body.style.overflow = "auto";
 body.style.height = "auto";
 html.style.padding = "0px"

}

fixSeqScroll = function(){

 //Remove Event Listener
 holder.removeEventListener("mouseover",fixSeqScroll);
 //Grab the plasmid viewer
 plasmidViewer = document.getElementsByClassName('la-vz-viewer-event-router')[0];
 //Disable page scroll on mouse over
 plasmidViewer.addEventListener("mouseover",disableScroll)
 //Re-Enable scroll when mouse leaves 
 plasmidViewer.addEventListener("mouseout",enableScroll)

}

//seqType takes values "linear", "circular", "both", or "both_flip" seqChange = function(seq){

 currentSeq = seq;
 document.getElementById("seqTitle").innerHTML = seq.name;
 seqViewer = document.getElementById('seqVizViewer');
 options =  {
   file: seq.data,
   style: {width: "100%", height: "100%"},
   copyEvent: (event => event.key === "c" && (event.metaKey || event.ctrlKey)),
   viewer: seq.seqType
 }
 var viewer = seqviz.Viewer(seqViewer, options);
 viewer.render();

}

loadSeqViz = function(){

 seqChange(sequences.roligoFlipper)

}

eventListeners = function(){

 if(!mobileCheck()){
   holder = document.getElementById("seqVizViewer");
   holder.addEventListener("mouseover",fixSeqScroll);
 }
 document.getElementsByClassName('download')[0].addEventListener("click",function(){
   var blob = new Blob([currentSeq.data],{ type: "text/plain;charset=utf-8" });
   saveAs(blob, currentSeq.name+".gb");
 })

} startupFunctions.push(eventListeners)

//Make first function to run on page load startupFunctions.unshift(loadSeqViz)