Difference between revisions of "Template:UCAS-China/igemUCAS.js"

(Created page with "! * igemUCAS JavaScript Library v0.18.17 * Copyright UCAS iGEM team: ( function( global, factory ) { var iU = global.iU = factory(global); iU(); } ) (window, function(...")
 
m
Line 3: Line 3:
 
  * Copyright UCAS iGEM team
 
  * Copyright UCAS iGEM team
 
  */
 
  */
 
+
(function(c,a){var b=c.iU=a(c);b()})(window,function(d){var f=d.document,j=(function(){var n="",o=1,p=function(q,r){n=n.concat(o," ",q,": ",r,"\n");o++},m=function(q){var r={string:function(t){if((!t)||typeof t!="string"){p(q,"parameter should be of .")}return r},number:function(t){if((!t)||typeof t!="number"){p(q,"parameter should be of number type.")}return r},keyUnused:function(t,s){if(t[s]){p(q,"key "+s+" has been used.")}return r},assert:function(t,s){if(!t){p(q,s)}return r}};return r};m.displayErrors=function(){if(n.length==0){alert("No errors, Congrats!")}else{alert(n)}};return m})(),e={SEGW:24,INF:2000000},i={merge:function(n,o){for(var m in o){if(n[m]){if(typeof n[m]=="object"&&typeof o[m]=="object"){n[m]=i.merge(n[m],o[m])}else{n[m]=o[m]}}else{n[m]=o[m]}}return n},getUid:(function(){var m=-1;return function(){m++;return(function(o){return"_"+o+"_"})(m)}})(),realWidth:function(m){return m*d.innerWidth/e.SEGW}};var b={general:{"font-family":"Georgia","font-size":"25px"},span:{},a:{"text-decoration":"none","mouseover":function(){},"mouseleave":function(){}}};function k(n,o,m){this.elem=(typeof n=="string")?f.createElement(n):n;this.elem.id=o||i.getUid();this.elem.style.visibility="hidden";this.span=m;this.styles={};this.iU_base.appendChild(this.elem);this.state="unused"}k.prototype={constructor:k,adaptWidth:function(){var o=i.realWidth(this.span);if(o==this.elem.clientWidth){return this.elem.clientHeight}var n=(this.elem.height||this.elem.clientHeight)/(this.elem.width||this.elem.clientWidth),m=o*n;this.css({width:o+"px",height:m+"px"});return this.elem.clientHeight},updataSchema:function(){this.css(b.general);for(var m in this.elem.childNodes){var o=this.elem.childNodes[m],n=b[(o.tagName||"").toLowerCase()];if(n){k.prototype.css.call(o,n)}}},css:function(p){var o=this.elem||this;if(this.styles){for(var r in this.styles){o.style[r]=this.styles[r]}}for(var r in p){var n="",q=false;for(var m=0;m<r.length;m++){if(r[m]=="-"){q=true}else{n+=q?r[m].toUpperCase():r[m];q=false}}if(typeof p[r]=="function"){o.addEventListener(n,p[r])}else{o.style[n]=p[r]}if(this.styles){this.styles[n]=p[r]}}},render:function(m){this.adaptWidth();this.css({"position":"absolute","left":(m+this.left)+"px","top":this.top+"px","visibility":"visible"})},toString:function(){return"["+this.elem.tagName.toLowerCase()+"] "+this.elem.innerHTML.substr(0,50)+"\n"}};var l={textAdapt:function(){this.css({"width":i.realWidth(this.span)+"px"});return this.elem.clientHeight},upgradeText:function(){for(var n=0,m=this.elem.childNodes.length;n<m;n++){var o=this.elem.childNodes[n];if(!o.attributes){var p=f.createElement("span");p.innerHTML=o.textContent;this.elem.replaceChild(p,o)}}}};function c(m){this.span=m.span;this.padding=m.padding;this.spacing=m.spacing;this.marginCross=m.marginCross;this.marginTop=m.marginTop;this.height=d.innerHeight-m.marginTop-m.marginBottom;this.page=0;this.frontier=0;this.reserve=0;this.usedW=0;this.comps=[];this.buffer=[];this.isVisible=true}c.prototype={constructor:c,operate:function(){var o=false;while(!o&&this.buffer.length>0){switch(this.buffer[0].state){case"wait":o=true;break;case"dispose":this.buffer.shift();break;case"unused":var m=this.buffer.shift(),n=m.adaptWidth();if(this.page==0){this.page=1}else{if(this.usedW==0||this.usedW+m.span>this.span){if(this.frontier+n>this.height){this.page+=1;this.frontier=0}else{this.frontier+=this.spacing}this.reserve=this.frontier;this.usedW=0}}m.left=i.realWidth(this.span*(this.page-1)+this.usedW+this.page*this.padding);m.top=this.reserve+this.marginTop;m.state="used";this.usedW+=m.span;this.frontier=Math.max(this.frontier,this.reserve+n);this.comps.push(m)}}},script:function(o){var n=o["span"]?o["span"].value:this.span;n=(n<0)?(n+this.span):Math.min(n,this.span);var m=new k(o,o["name"],n);l.upgradeText.call(m);m.updataSchema();m.adaptWidth=l.textAdapt;m.adaptWidth();this.buffer.push(m)},hide:function(){if(this.isVisible){for(var n=0,m=this.comps.length;n<m;n++){this.comps[n].elem.style["visibility"]="hidden"}}},getBreadth:function(){return this.page*this.span+(this.page+1)*this.marginCross},render:function(m){this.isVisible=true;for(var o=0,n=this.comps.length;o<n;o++){this.comps[o].render(m)}}};function a(m){this.flows=[]}a.prototype={constructor:a,render:function(r){var v=0,t=[];for(var q=0,u=this.flows.length;q<u;q++){var n=this.flows[q],s=r-v,m=n.getBreadth(),o=d.innerWidth;n.operate();if(s<-m||s>o){n.hide()}else{t.push([n,s])}v+=m}for(var p in t){t[p][0].render(-t[p][1])}return v}};var g={initRoot:function(o){var m=f.getElementById("igemUCAS");if(!m){return null}m.style.visibility="hidden";m.style["z-index"]="-100";if(o){var n=f.getElementsByTagName("html")[0];n.style.overflowX="hidden";n.style.overflowY="hidden";n.style.padding="0px";n.style.margin="0px"}j("fn.initRoot").assert(m,"");return m},initWebGL:function(n){var m=f.createElement("canvas");m.id="bgCanvas";m.width=d.innerWidth;m.height=d.innerHeight;
( function( global, factory ) { var iU = global.iU = factory(global); iU(); } ) (window, function( window ) {
+
n.parentNode.appendChild(m);var o=m.getContext("webgl")||m.getContext("experimental-webgl");if(o){k.prototype.css.call(m,{"position":"absolute","top":"0","left":"0","z-index":"-90","overflow":"hidden","visibility":"visible"})}return o},initBase:function(m){var n=f.createElement("div");n.id="UCASigem";n.style.position="absolute";m.parentNode.appendChild(n);return n},root_not_found:function(){},gl_not_supported:function(){},defaultConfig:{overflow:true,webgl:true}};function h(){p=i.merge(p,d.schema||{});var s=g.initRoot((d.configs||g.defaultConfig).overflow);if(!s){return g.root_not_found()}var w=g.initBase(s);k.prototype.iU_base=w;var r=(d.configs||g.defaultConfig).webgl||g.initWebGL(s);if(!r){g.gl_not_supported()}var p=i.merge(g.defaultSchema,d.schema||{});c.prototype.schema=p;var v=new a(d.innerHeight);while(s.children.length>0){var t=s.children[0];if((t.tagName||"").toLowerCase()=="div"){var u=t["spacing"]?t["spacing"].value.split(/\t/):"",m=new c({span:t["span"]?t["span"].value:8,padding:t["padding"]?t["padding"].value:1,spacing:parseInt(u[0])||40,marginTop:parseInt(u[1])||100,marginBottom:u[2]?parseInt(u[2]):(parseInt(u[1])||100)});v.flows.push(m);while(t.children.length>0){var o=t.children[0];switch(((o||{}).tagName||"").toLowerCase()){case"p":m.script(o);break;default:t.removeChild(o);break}}}s.removeChild(t)}s.parentNode.removeChild(s);var q=0;var n=function(x){x=x||d.event;q+=x.wheelDelta||x.detail;q=q<0?0:q;v.render(q)};v.render(q);d.onmousewheel=f.onmousewheel=n}h.displayErrors=j.displayErrors;return h});
var  
+
document = window.document,
+
inspect = (function(){
+
var
+
strErr = "",
+
nextseq = 1,
+
error = function( location, desc ){
+
strErr = strErr.concat(nextseq, " ", location, ": ", desc, '\n');
+
nextseq ++;
+
},
+
garrison = function( name ){
+
var f = {
+
string: function( s ){
+
if( (!s) || typeof s != 'string' )
+
error(name, "parameter should be of .");
+
return f;
+
},
+
number: function( s ){
+
if( (!s) || typeof s != 'number' )
+
error(name, "parameter should be of number type.");
+
return f;
+
},
+
keyUnused: function(obj, key){
+
if( obj[key] )
+
error(name, "key "+key+" has been used.");
+
return f;
+
},
+
assert: function( val, desc ){
+
if( !val )
+
error(name, desc );
+
return f;
+
}
+
};
+
return f;
+
};
+
 
+
garrison.displayErrors = function(){
+
if(strErr.length == 0 )
+
alert("No errors, Congrats!")
+
else
+
alert( strErr );
+
};
+
return garrison;
+
})(),
+
 
+
 
+
consts = {
+
SEGW: 24,
+
INF: 2000000
+
},
+
 
+
utils = {
+
merge: function( t, c){
+
for(var i in c){
+
if( t[i] ){
+
if( typeof t[i] == 'object' && typeof c[i] == 'object')
+
t[i] = utils.merge(t[i],c[i]);
+
else
+
t[i] = c[i];
+
}
+
else
+
t[i] = c[i];
+
}
+
return t;
+
},
+
getUid: (function(){
+
var now = -1;
+
return function(){
+
now ++;
+
return (function(n){
+
return '_'+n+'_';
+
})(now);
+
};
+
})(),
+
realWidth: function( span ){
+
return span * window.innerWidth / consts.SEGW;
+
}
+
};
+
 
+
var
+
schema = {
+
general: {
+
"font-family": "Georgia",
+
"font-size": "25px"
+
},
+
span: {
+
 
+
},
+
a: {
+
"text-decoration": "none",
+
"mouseover": function(){
+
+
},
+
"mouseleave": function(){
+
 
+
}
+
}
+
}
+
 
+
function Component( node, id, span ){
+
this.elem = (typeof node == "string") ? document.createElement(node) : node;
+
this.elem.id = id || utils.getUid();
+
this.elem.style.visibility = "hidden";
+
 
+
this.span = span;
+
this.styles = {};
+
 
+
this.iU_base.appendChild(this.elem);
+
this.state = "unused";
+
}
+
Component.prototype = {
+
constructor: Component,
+
adaptWidth: function(){
+
var
+
width = utils.realWidth(this.span);
+
 
+
if( width == this.elem.clientWidth )
+
return this.elem.clientHeight;
+
 
+
var
+
ratio = (this.elem.height || this.elem.clientHeight) / (this.elem.width || this.elem.clientWidth),
+
height= width*ratio;
+
+
this.css({
+
width: width  + "px",
+
height: height + "px"
+
});
+
return this.elem.clientHeight;
+
},
+
updataSchema: function(){
+
this.css( schema.general );
+
for(var i in this.elem.childNodes){
+
var
+
child = this.elem.childNodes[i],
+
s = schema[ (child.tagName||"").toLowerCase() ];
+
if(s)
+
Component.prototype.css.call( child, s );
+
}
+
},
+
css: function( styles ){
+
var
+
elem = this.elem || this;//maybe a component or DOM Element
+
if(this.styles){
+
for(var prop in this.styles)
+
elem.style[prop] = this.styles[ prop ];
+
}
+
 
+
for(var prop in styles){
+
var  
+
key = "",
+
change = false;
+
 
+
for(var j = 0; j < prop.length; j ++){
+
if( prop[j] == '-' )
+
change = true;
+
else{
+
key += change ? prop[j].toUpperCase() : prop[j];
+
change = false;
+
}
+
}
+
 
+
if( typeof styles[ prop ] == "function" )
+
elem.addEventListener(key, styles[prop]);
+
else
+
elem.style[ key ] = styles[ prop ];
+
 
+
if(this.styles)
+
this.styles[ key ] = styles[ prop ];
+
}
+
},
+
render: function( offsetX ){
+
this.adaptWidth();
+
 
+
this.css({
+
"position": "absolute",
+
"left": (offsetX+this.left) +"px",
+
"top": this.top +"px",
+
"visibility": "visible"
+
});
+
},
+
toString: function(){
+
return "["+this.elem.tagName.toLowerCase() +"] "+ this.elem.innerHTML.substr(0,50)+"\n";
+
}
+
};
+
 
+
var
+
Supp = {
+
textAdapt: function(){
+
this.css({"width":utils.realWidth(this.span)+ "px"});
+
return this.elem.clientHeight;
+
},
+
upgradeText: function(){
+
for(var i = 0, i_len = this.elem.childNodes.length; i < i_len; i ++){
+
var
+
node = this.elem.childNodes[i];
+
if( !node.attributes ){
+
var
+
child = document.createElement("span");
+
child.innerHTML = node.textContent;
+
this.elem.replaceChild(child, node);
+
}
+
}
+
}
+
};
+
 
+
function Flow( configs ){
+
this.span = configs.span;
+
this.padding = configs.padding;
+
 
+
this.spacing = configs.spacing;
+
this.marginCross= configs.marginCross;
+
this.marginTop = configs.marginTop;
+
this.height = window.innerHeight - configs.marginTop - configs.marginBottom;
+
 
+
this.page = 0;
+
this.frontier = 0;
+
this.reserve = 0;
+
this.usedW = 0;
+
 
+
this.comps = [];
+
this.buffer = [];
+
this.isVisible = true;
+
}
+
Flow.prototype = {
+
constructor: Flow,
+
operate: function(){
+
var
+
wait = false;
+
while( !wait && this.buffer.length > 0 ){
+
switch( this.buffer[0].state ){
+
case "wait": wait = true; break;
+
case "dispose": this.buffer.shift(); break;
+
case "unused":  
+
var
+
comp = this.buffer.shift(),
+
h = comp.adaptWidth();
+
 
+
if( this.page == 0 )
+
this.page = 1;
+
else if( this.usedW == 0 || this.usedW + comp.span > this.span ){
+
//alert(this.frontier+" "+h+" "+this.height);
+
if( this.frontier + h > this.height ){
+
this.page += 1;
+
this.frontier = 0;
+
}
+
else
+
this.frontier+= this.spacing;
+
 
+
this.reserve = this.frontier;
+
this.usedW   = 0;
+
}
+
 
+
comp.left = utils.realWidth( this.span * (this.page-1) + this.usedW + this.page*this.padding );
+
comp.top = this.reserve + this.marginTop;
+
comp.state = "used";
+
 
+
this.usedW   += comp.span;
+
this.frontier = Math.max( this.frontier, this.reserve+h );
+
 
+
this.comps.push( comp );
+
}
+
}
+
},
+
script: function( node ){
+
var
+
s = node["span"] ? node["span"].value : this.span;
+
s = (s < 0) ? (s + this.span) : Math.min(s, this.span);
+
 
+
var
+
t = new Component( node, node["name"], s );
+
Supp.upgradeText.call(t);
+
t.updataSchema();
+
t.adaptWidth = Supp.textAdapt;
+
t.adaptWidth();
+
 
+
this.buffer.push( t );
+
},
+
hide: function(){
+
if( this.isVisible ){
+
for(var i = 0, i_len = this.comps.length; i < i_len; i ++)
+
this.comps[ i ].elem.style["visibility"] = "hidden";
+
}
+
},
+
getBreadth: function(){
+
return this.page * this.span + (this.page+1) * this.marginCross;
+
},
+
render: function( offsetX ){
+
this.isVisible = true;
+
 
+
for(var i = 0, i_len = this.comps.length; i < i_len; i ++)
+
this.comps[ i ].render( offsetX );
+
}
+
};
+
 
+
function Scroll( height ){
+
this.flows = [];
+
}
+
Scroll.prototype = {
+
constructor: Scroll,
+
render: function( position ){
+
var  
+
accum = 0,
+
d = [];
+
 
+
for(var i = 0, i_len = this.flows.length; i < i_len; i ++){
+
var
+
flow = this.flows[i],
+
offsetX = position - accum,
+
breadth = flow.getBreadth(),
+
width = window.innerWidth ;
+
 
+
flow.operate();
+
if( offsetX < -breadth || offsetX > width )
+
flow.hide();
+
else
+
d.push( [flow, offsetX] );
+
 
+
accum += breadth;
+
}
+
for(var j in d)
+
d[j][0].render( -d[j][1] );
+
 
+
return accum;
+
}
+
};
+
 
+
var
+
fn = {
+
initRoot: function( overflow ){
+
var  
+
iU_root = document.getElementById("igemUCAS");
+
 
+
if( !iU_root )
+
return null;
+
 
+
iU_root.style.visibility = "hidden";
+
iU_root.style["z-index"] = "-100";
+
 
+
if( overflow ){
+
var
+
webpage = document.getElementsByTagName("html")[0];
+
webpage.style.overflowX = "hidden";
+
webpage.style.overflowY = "hidden";
+
webpage.style.padding = "0px";
+
webpage.style.margin = "0px";
+
}
+
 
+
inspect("fn.initRoot").assert(iU_root, "");
+
return iU_root;
+
},
+
initWebGL: function( iU_root ){
+
var
+
canvas    = document.createElement("canvas");
+
 
+
canvas.id = "bgCanvas";
+
canvas.width = window.innerWidth;
+
canvas.height = window.innerHeight;
+
iU_root.parentNode.appendChild(canvas);
+
+
var
+
gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
+
 
+
if(gl)
+
Component.prototype.css.call(canvas, {
+
"position":"absolute",
+
"top":"0",
+
"left":"0",
+
"z-index":"-90",
+
"overflow":"hidden",
+
"visibility":"visible"
+
});
+
+
return gl;
+
},
+
initBase: function( iU_root ){
+
var
+
iU_base = document.createElement("div");
+
iU_base.id = "UCASigem";
+
iU_base.style.position   = "absolute";
+
 
+
iU_root.parentNode.appendChild(iU_base);
+
return iU_base;
+
},
+
 
+
root_not_found: function(){
+
 
+
},
+
gl_not_supported: function(){
+
 
+
},
+
defaultConfig: {
+
overflow: true,
+
webgl: true
+
}
+
}
+
 
+
function igemUCAS(){
+
schema = utils.merge( schema, window.schema||{} );
+
 
+
var
+
iU_root = fn.initRoot( (window.configs||fn.defaultConfig).overflow );
+
if( !iU_root )
+
return fn.root_not_found();
+
 
+
var
+
iU_base = fn.initBase( iU_root );
+
Component.prototype.iU_base = iU_base;
+
 
+
var
+
gl = (window.configs||fn.defaultConfig).webgl || fn.initWebGL( iU_root );
+
if( !gl )
+
fn.gl_not_supported();
+
 
+
var
+
schema = utils.merge( fn.defaultSchema, window.schema||{} );  
+
Flow.prototype.schema = schema;
+
 
+
var
+
scroll = new Scroll( window.innerHeight );
+
while( iU_root.children.length > 0 ){
+
var
+
page = iU_root.children[0];
+
 
+
if( (page.tagName||"").toLowerCase() == "div" ){
+
var
+
spacing = page["spacing"] ? page["spacing"].value.split(/\t/): "",
+
flow = new Flow({
+
span: page["span"] ? page["span"].value : 8,
+
padding: page["padding"] ? page["padding"].value : 1,
+
spacing: parseInt(spacing[0]) || 40,  
+
marginTop: parseInt(spacing[1]) || 100,
+
marginBottom: spacing[2] ? parseInt(spacing[2]) : (parseInt(spacing[1]) || 100)
+
});
+
 
+
scroll.flows.push(flow);
+
 
+
while( page.children.length > 0 ){
+
var
+
node = page.children[0];
+
switch( ((node||{}).tagName||"").toLowerCase() ){
+
case "p": flow.script(node); break;
+
default: page.removeChild(node); break;
+
}
+
}
+
}
+
iU_root.removeChild( page );
+
}
+
iU_root.parentNode.removeChild(iU_root);
+
 
+
var
+
offset = 0;
+
 
+
var scrollHandler = function( ev ){
+
ev = ev || window.event;
+
offset += ev.wheelDelta || ev.detail;
+
offset  = offset < 0 ? 0 : offset;
+
scroll.render( offset );
+
};
+
 
+
scroll.render( offset );
+
//document.addEventListener("DOMMouseScroll", scrollHandler , false);
+
window.onmousewheel = document.onmousewheel = scrollHandler;
+
}
+
igemUCAS.displayErrors = inspect.displayErrors;
+
 
+
return igemUCAS;
+
});
+

Revision as of 13:49, 8 October 2018

/*!

* igemUCAS JavaScript Library v0.18.17
* Copyright UCAS iGEM team
*/

(function(c,a){var b=c.iU=a(c);b()})(window,function(d){var f=d.document,j=(function(){var n="",o=1,p=function(q,r){n=n.concat(o," ",q,": ",r,"\n");o++},m=function(q){var r={string:function(t){if((!t)||typeof t!="string"){p(q,"parameter should be of .")}return r},number:function(t){if((!t)||typeof t!="number"){p(q,"parameter should be of number type.")}return r},keyUnused:function(t,s){if(t[s]){p(q,"key "+s+" has been used.")}return r},assert:function(t,s){if(!t){p(q,s)}return r}};return r};m.displayErrors=function(){if(n.length==0){alert("No errors, Congrats!")}else{alert(n)}};return m})(),e={SEGW:24,INF:2000000},i={merge:function(n,o){for(var m in o){if(n[m]){if(typeof n[m]=="object"&&typeof o[m]=="object"){n[m]=i.merge(n[m],o[m])}else{n[m]=o[m]}}else{n[m]=o[m]}}return n},getUid:(function(){var m=-1;return function(){m++;return(function(o){return"_"+o+"_"})(m)}})(),realWidth:function(m){return m*d.innerWidth/e.SEGW}};var b={general:{"font-family":"Georgia","font-size":"25px"},span:{},a:{"text-decoration":"none","mouseover":function(){},"mouseleave":function(){}}};function k(n,o,m){this.elem=(typeof n=="string")?f.createElement(n):n;this.elem.id=o||i.getUid();this.elem.style.visibility="hidden";this.span=m;this.styles={};this.iU_base.appendChild(this.elem);this.state="unused"}k.prototype={constructor:k,adaptWidth:function(){var o=i.realWidth(this.span);if(o==this.elem.clientWidth){return this.elem.clientHeight}var n=(this.elem.height||this.elem.clientHeight)/(this.elem.width||this.elem.clientWidth),m=o*n;this.css({width:o+"px",height:m+"px"});return this.elem.clientHeight},updataSchema:function(){this.css(b.general);for(var m in this.elem.childNodes){var o=this.elem.childNodes[m],n=b[(o.tagName||"").toLowerCase()];if(n){k.prototype.css.call(o,n)}}},css:function(p){var o=this.elem||this;if(this.styles){for(var r in this.styles){o.style[r]=this.styles[r]}}for(var r in p){var n="",q=false;for(var m=0;m<r.length;m++){if(r[m]=="-"){q=true}else{n+=q?r[m].toUpperCase():r[m];q=false}}if(typeof p[r]=="function"){o.addEventListener(n,p[r])}else{o.style[n]=p[r]}if(this.styles){this.styles[n]=p[r]}}},render:function(m){this.adaptWidth();this.css({"position":"absolute","left":(m+this.left)+"px","top":this.top+"px","visibility":"visible"})},toString:function(){return"["+this.elem.tagName.toLowerCase()+"] "+this.elem.innerHTML.substr(0,50)+"\n"}};var l={textAdapt:function(){this.css({"width":i.realWidth(this.span)+"px"});return this.elem.clientHeight},upgradeText:function(){for(var n=0,m=this.elem.childNodes.length;n<m;n++){var o=this.elem.childNodes[n];if(!o.attributes){var p=f.createElement("span");p.innerHTML=o.textContent;this.elem.replaceChild(p,o)}}}};function c(m){this.span=m.span;this.padding=m.padding;this.spacing=m.spacing;this.marginCross=m.marginCross;this.marginTop=m.marginTop;this.height=d.innerHeight-m.marginTop-m.marginBottom;this.page=0;this.frontier=0;this.reserve=0;this.usedW=0;this.comps=[];this.buffer=[];this.isVisible=true}c.prototype={constructor:c,operate:function(){var o=false;while(!o&&this.buffer.length>0){switch(this.buffer[0].state){case"wait":o=true;break;case"dispose":this.buffer.shift();break;case"unused":var m=this.buffer.shift(),n=m.adaptWidth();if(this.page==0){this.page=1}else{if(this.usedW==0||this.usedW+m.span>this.span){if(this.frontier+n>this.height){this.page+=1;this.frontier=0}else{this.frontier+=this.spacing}this.reserve=this.frontier;this.usedW=0}}m.left=i.realWidth(this.span*(this.page-1)+this.usedW+this.page*this.padding);m.top=this.reserve+this.marginTop;m.state="used";this.usedW+=m.span;this.frontier=Math.max(this.frontier,this.reserve+n);this.comps.push(m)}}},script:function(o){var n=o["span"]?o["span"].value:this.span;n=(n<0)?(n+this.span):Math.min(n,this.span);var m=new k(o,o["name"],n);l.upgradeText.call(m);m.updataSchema();m.adaptWidth=l.textAdapt;m.adaptWidth();this.buffer.push(m)},hide:function(){if(this.isVisible){for(var n=0,m=this.comps.length;n<m;n++){this.comps[n].elem.style["visibility"]="hidden"}}},getBreadth:function(){return this.page*this.span+(this.page+1)*this.marginCross},render:function(m){this.isVisible=true;for(var o=0,n=this.comps.length;o<n;o++){this.comps[o].render(m)}}};function a(m){this.flows=[]}a.prototype={constructor:a,render:function(r){var v=0,t=[];for(var q=0,u=this.flows.length;q<u;q++){var n=this.flows[q],s=r-v,m=n.getBreadth(),o=d.innerWidth;n.operate();if(s<-m||s>o){n.hide()}else{t.push([n,s])}v+=m}for(var p in t){t[p][0].render(-t[p][1])}return v}};var g={initRoot:function(o){var m=f.getElementById("igemUCAS");if(!m){return null}m.style.visibility="hidden";m.style["z-index"]="-100";if(o){var n=f.getElementsByTagName("html")[0];n.style.overflowX="hidden";n.style.overflowY="hidden";n.style.padding="0px";n.style.margin="0px"}j("fn.initRoot").assert(m,"");return m},initWebGL:function(n){var m=f.createElement("canvas");m.id="bgCanvas";m.width=d.innerWidth;m.height=d.innerHeight; n.parentNode.appendChild(m);var o=m.getContext("webgl")||m.getContext("experimental-webgl");if(o){k.prototype.css.call(m,{"position":"absolute","top":"0","left":"0","z-index":"-90","overflow":"hidden","visibility":"visible"})}return o},initBase:function(m){var n=f.createElement("div");n.id="UCASigem";n.style.position="absolute";m.parentNode.appendChild(n);return n},root_not_found:function(){},gl_not_supported:function(){},defaultConfig:{overflow:true,webgl:true}};function h(){p=i.merge(p,d.schema||{});var s=g.initRoot((d.configs||g.defaultConfig).overflow);if(!s){return g.root_not_found()}var w=g.initBase(s);k.prototype.iU_base=w;var r=(d.configs||g.defaultConfig).webgl||g.initWebGL(s);if(!r){g.gl_not_supported()}var p=i.merge(g.defaultSchema,d.schema||{});c.prototype.schema=p;var v=new a(d.innerHeight);while(s.children.length>0){var t=s.children[0];if((t.tagName||"").toLowerCase()=="div"){var u=t["spacing"]?t["spacing"].value.split(/\t/):"",m=new c({span:t["span"]?t["span"].value:8,padding:t["padding"]?t["padding"].value:1,spacing:parseInt(u[0])||40,marginTop:parseInt(u[1])||100,marginBottom:u[2]?parseInt(u[2]):(parseInt(u[1])||100)});v.flows.push(m);while(t.children.length>0){var o=t.children[0];switch(((o||{}).tagName||"").toLowerCase()){case"p":m.script(o);break;default:t.removeChild(o);break}}}s.removeChild(t)}s.parentNode.removeChild(s);var q=0;var n=function(x){x=x||d.event;q+=x.wheelDelta||x.detail;q=q<0?0:q;v.render(q)};v.render(q);d.onmousewheel=f.onmousewheel=n}h.displayErrors=j.displayErrors;return h});