Team:Heidelberg/js/toolboxguide

From 2014.igem.org

(Difference between revisions)
Line 1: Line 1:
"use strict";jQuery.base64=(function($){var _PADCHAR="=",_ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_VERSION="1.0";function _getbyte64(s,i){var idx=_ALPHA.indexOf(s.charAt(i));if(idx===-1){throw"Cannot decode base64"}return idx}function _decode(s){var pads=0,i,b10,imax=s.length,x=[];s=String(s);if(imax===0){return s}if(imax%4!==0){throw"Cannot decode base64"}if(s.charAt(imax-1)===_PADCHAR){pads=1;if(s.charAt(imax-2)===_PADCHAR){pads=2}imax-=4}for(i=0;i<imax;i+=4){b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12)|(_getbyte64(s,i+2)<<6)|_getbyte64(s,i+3);x.push(String.fromCharCode(b10>>16,(b10>>8)&255,b10&255))}switch(pads){case 1:b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12)|(_getbyte64(s,i+2)<<6);x.push(String.fromCharCode(b10>>16,(b10>>8)&255));break;case 2:b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12);x.push(String.fromCharCode(b10>>16));break}return x.join("")}function _getbyte(s,i){var x=s.charCodeAt(i);if(x>255){throw"INVALID_CHARACTER_ERR: DOM Exception 5"}return x}function _encode(s){if(arguments.length!==1){throw"SyntaxError: exactly one argument required"}s=String(s);var i,b10,x=[],imax=s.length-s.length%3;if(s.length===0){return s}for(i=0;i<imax;i+=3){b10=(_getbyte(s,i)<<16)|(_getbyte(s,i+1)<<8)|_getbyte(s,i+2);x.push(_ALPHA.charAt(b10>>18));x.push(_ALPHA.charAt((b10>>12)&63));x.push(_ALPHA.charAt((b10>>6)&63));x.push(_ALPHA.charAt(b10&63))}switch(s.length-imax){case 1:b10=_getbyte(s,i)<<16;x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt((b10>>12)&63)+_PADCHAR+_PADCHAR);break;case 2:b10=(_getbyte(s,i)<<16)|(_getbyte(s,i+1)<<8);x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt((b10>>12)&63)+_ALPHA.charAt((b10>>6)&63)+_PADCHAR);break}return x.join("")}return{decode:_decode,encode:_encode,VERSION:_VERSION}}(jQuery));
"use strict";jQuery.base64=(function($){var _PADCHAR="=",_ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_VERSION="1.0";function _getbyte64(s,i){var idx=_ALPHA.indexOf(s.charAt(i));if(idx===-1){throw"Cannot decode base64"}return idx}function _decode(s){var pads=0,i,b10,imax=s.length,x=[];s=String(s);if(imax===0){return s}if(imax%4!==0){throw"Cannot decode base64"}if(s.charAt(imax-1)===_PADCHAR){pads=1;if(s.charAt(imax-2)===_PADCHAR){pads=2}imax-=4}for(i=0;i<imax;i+=4){b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12)|(_getbyte64(s,i+2)<<6)|_getbyte64(s,i+3);x.push(String.fromCharCode(b10>>16,(b10>>8)&255,b10&255))}switch(pads){case 1:b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12)|(_getbyte64(s,i+2)<<6);x.push(String.fromCharCode(b10>>16,(b10>>8)&255));break;case 2:b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12);x.push(String.fromCharCode(b10>>16));break}return x.join("")}function _getbyte(s,i){var x=s.charCodeAt(i);if(x>255){throw"INVALID_CHARACTER_ERR: DOM Exception 5"}return x}function _encode(s){if(arguments.length!==1){throw"SyntaxError: exactly one argument required"}s=String(s);var i,b10,x=[],imax=s.length-s.length%3;if(s.length===0){return s}for(i=0;i<imax;i+=3){b10=(_getbyte(s,i)<<16)|(_getbyte(s,i+1)<<8)|_getbyte(s,i+2);x.push(_ALPHA.charAt(b10>>18));x.push(_ALPHA.charAt((b10>>12)&63));x.push(_ALPHA.charAt((b10>>6)&63));x.push(_ALPHA.charAt(b10&63))}switch(s.length-imax){case 1:b10=_getbyte(s,i)<<16;x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt((b10>>12)&63)+_PADCHAR+_PADCHAR);break;case 2:b10=(_getbyte(s,i)<<16)|(_getbyte(s,i+1)<<8);x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt((b10>>12)&63)+_ALPHA.charAt((b10>>6)&63)+_PADCHAR);break}return x.join("")}return{decode:_decode,encode:_encode,VERSION:_VERSION}}(jQuery));
 +
 +
ko.bindingHandlers.fadeVisible = {
 +
    init: function(element, valueAccessor) {
 +
        // Initially set the element to be instantly visible/hidden depending on the value
 +
        var value = valueAccessor();
 +
        $(element).toggle(ko.unwrap(value)); // Use "unwrapObservable" so we can handle values that may or may not be observable
 +
    },
 +
    update: function(element, valueAccessor) {
 +
        // Whenever the value subsequently changes, slowly fade the element in or out
 +
        var value = valueAccessor();
 +
        ko.unwrap(value) ? $(element).fadeIn() : $(element).fadeOut();
 +
    }
 +
};
 +
$(document).ready(function() {
$(document).ready(function() {

Revision as of 06:41, 15 October 2014

"use strict";jQuery.base64=(function($){var _PADCHAR="=",_ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_VERSION="1.0";function _getbyte64(s,i){var idx=_ALPHA.indexOf(s.charAt(i));if(idx===-1){throw"Cannot decode base64"}return idx}function _decode(s){var pads=0,i,b10,imax=s.length,x=[];s=String(s);if(imax===0){return s}if(imax%4!==0){throw"Cannot decode base64"}if(s.charAt(imax-1)===_PADCHAR){pads=1;if(s.charAt(imax-2)===_PADCHAR){pads=2}imax-=4}for(i=0;i<imax;i+=4){b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12)|(_getbyte64(s,i+2)<<6)|_getbyte64(s,i+3);x.push(String.fromCharCode(b10>>16,(b10>>8)&255,b10&255))}switch(pads){case 1:b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12)|(_getbyte64(s,i+2)<<6);x.push(String.fromCharCode(b10>>16,(b10>>8)&255));break;case 2:b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12);x.push(String.fromCharCode(b10>>16));break}return x.join("")}function _getbyte(s,i){var x=s.charCodeAt(i);if(x>255){throw"INVALID_CHARACTER_ERR: DOM Exception 5"}return x}function _encode(s){if(arguments.length!==1){throw"SyntaxError: exactly one argument required"}s=String(s);var i,b10,x=[],imax=s.length-s.length%3;if(s.length===0){return s}for(i=0;i<imax;i+=3){b10=(_getbyte(s,i)<<16)|(_getbyte(s,i+1)<<8)|_getbyte(s,i+2);x.push(_ALPHA.charAt(b10>>18));x.push(_ALPHA.charAt((b10>>12)&63));x.push(_ALPHA.charAt((b10>>6)&63));x.push(_ALPHA.charAt(b10&63))}switch(s.length-imax){case 1:b10=_getbyte(s,i)<<16;x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt((b10>>12)&63)+_PADCHAR+_PADCHAR);break;case 2:b10=(_getbyte(s,i)<<16)|(_getbyte(s,i+1)<<8);x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt((b10>>12)&63)+_ALPHA.charAt((b10>>6)&63)+_PADCHAR);break}return x.join("")}return{decode:_decode,encode:_encode,VERSION:_VERSION}}(jQuery));

ko.bindingHandlers.fadeVisible = {

   init: function(element, valueAccessor) {
       // Initially set the element to be instantly visible/hidden depending on the value
       var value = valueAccessor();
       $(element).toggle(ko.unwrap(value)); // Use "unwrapObservable" so we can handle values that may or may not be observable
   },
   update: function(element, valueAccessor) {
       // Whenever the value subsequently changes, slowly fade the element in or out
       var value = valueAccessor();
       ko.unwrap(value) ? $(element).fadeIn() : $(element).fadeOut();
   }

};


$(document).ready(function() { $('#pagename').text(wgPageName); $('#copy-to-clip').click(function() { window.prompt("Copy to clipboard: Ctrl+C, Enter", $('#comebackurl').text()); });

});

function CircularizationViewModel(hash) { var self = this; self.RFCnumber = '[???]'; self.softwareName = '[hoffentlich nicht LinkIT]'; self.availableExteins = [ { N: 'RGK', C: 'CWE', comment: , notes: ['Efficient, tested by us', 'Large scar'] }, { N: 'RGT', C: 'CWE', comment: , notes: ['Efficient, tested by us', 'Large scar'] }, { N: 'AEY', C: 'CFN' , comment: , notes: ['Efficient, native extein', 'Large scar'] }, { N: 'XXX', C: 'CXX', comment: 'X = native amino acids of the protein', notes: ['Probably less efficient (depends on the protein)', 'Small scar'] }, ];

var data = hash && $.parseJSON($.base64.decode(hash.substr(1))); self.data = { comingBack: data ? data.comingBack : false, q0A: ko.observable(data ? data.q0A : false), hasBsaI: ko.observable(data && data.hasBsaI), q1A: ko.observable(data ? data.q1A : false), useSortase: ko.observable(data && data.useSortase), q2A: ko.observable(data ? data.q2A : false), needsSmt3: ko.observable(data && data.needsSmt3), q3A: ko.observable(data ? data.q3A : false), exteins: ko.observable(data && data.exteins), q4A: ko.observable(data ? data.q4A : false), endsAreClose: ko.observable(data && data.endsAreClose), q5A: ko.observable(data ? data.q5A : false), linkerLength: ko.observable(data && data.linkerLength), q6A: ko.observable(data ? data.q6A : false), testSeveral: ko.observable(data && data.testSeveral), };

self.hash = ko.computed(function () { self.data.q0A(); self.data.q1A(); self.data.q2A(); self.data.q3A(); self.data.q4A(); self.data.q5A(); self.data.q6A(); self.data.hasBsaI(); self.data.useSortase(); self.data.needsSmt3(); self.data.exteins(); self.data.endsAreClose(); self.data.linkerLength(); self.data.testSeveral();

window.location.hash = $.base64.encode(ko.toJSON(self.data)); console.log(window.location.hash, ko.toJSON(self.data)); return window.location.hash;

});

self.comeBackHash = ko.computed(function () { var tmp = self.data.comingBack; self.data.comingBack = true; var hash = $.base64.encode(ko.toJSON(self.data)); self.data.comingBack = tmp; return hash; }); }

var vm = new CircularizationViewModel(window.location.hash); ko.applyBindings(vm);