chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r770000 [11/11] - in /hadoop/chukwa: branches/chukwa-0.1/ branches/chukwa-0.1/src/web/hicc/jsp/ branches/chukwa-0.1/src/web/hicc/lib/ branches/chukwa-0.1/src/web/hicc/lib/timeline/ branches/chukwa-0.1/src/web/hicc/lib/timeline/ext/ branches...
Date Wed, 29 Apr 2009 23:33:56 GMT
Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/graphics.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/graphics.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/graphics.js (added)
+++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/graphics.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,322 @@
+/*==================================================
+ *  Graphics Utility Functions and Constants
+ *==================================================
+ */
+
+Timeline.Graphics = new Object();
+Timeline.Graphics.pngIsTranslucent = (!Timeline.Platform.browser.isIE) || (Timeline.Platform.browser.majorVersion > 6);
+
+Timeline.Graphics.createTranslucentImage = function(doc, url, verticalAlign) {
+    var elmt;
+    if (Timeline.Graphics.pngIsTranslucent) {
+        elmt = doc.createElement("img");
+        elmt.setAttribute("src", url);
+    } else {
+        elmt = doc.createElement("img");
+        elmt.style.display = "inline";
+        elmt.style.width = "1px";  // just so that IE will calculate the size property
+        elmt.style.height = "1px";
+        elmt.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url +"', sizingMethod='image')";
+    }
+    elmt.style.verticalAlign = (verticalAlign != null) ? verticalAlign : "middle";
+    return elmt;
+};
+
+Timeline.Graphics.setOpacity = function(elmt, opacity) {
+    if (Timeline.Platform.browser.isIE) {
+        elmt.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Style=0,Opacity=" + opacity + ")";
+    } else {
+        var o = (opacity / 100).toString();
+        elmt.style.opacity = o;
+        elmt.style.MozOpacity = o;
+    }
+};
+
+Timeline.Graphics._bubbleMargins = {
+    top:      33,
+    bottom:   42,
+    left:     33,
+    right:    40
+}
+
+// pixels from boundary of the whole bubble div to the tip of the arrow
+Timeline.Graphics._arrowOffsets = { 
+    top:      0,
+    bottom:   9,
+    left:     1,
+    right:    8
+}
+
+Timeline.Graphics._bubblePadding = 15;
+Timeline.Graphics._bubblePointOffset = 6;
+Timeline.Graphics._halfArrowWidth = 18;
+
+Timeline.Graphics.createBubbleForPoint = function(doc, pageX, pageY, contentWidth, contentHeight) {
+    function getWindowDims() {
+        if (typeof window.innerWidth == 'number') {
+	    return { w:window.innerWidth, h:window.innerHeight }; // Non-IE
+	} else if (document.documentElement && document.documentElement.clientWidth) {
+	    return { // IE6+, in "standards compliant mode"
+		w:document.documentElement.clientWidth,
+		h:document.documentElement.clientHeight
+	    };
+	} else if (document.body && document.body.clientWidth) {
+	    return { // IE 4 compatible
+		w:document.body.clientWidth,
+		h:document.body.clientHeight
+	    };
+	}
+    }
+
+    var bubble = {
+        _closed:    false,
+        _doc:       doc,
+        close:      function() { 
+            if (!this._closed) {
+                this._doc.body.removeChild(this._div);
+                this._doc = null;
+                this._div = null;
+                this._content = null;
+                this._closed = true;
+            }
+        }
+    };
+
+    var dims = getWindowDims();
+    var docWidth = dims.w;
+    var docHeight = dims.h;
+
+    var margins = Timeline.Graphics._bubbleMargins;
+    contentWidth = parseInt(contentWidth, 10); // harden against bad input bugs
+    contentHeight = parseInt(contentHeight, 10); // getting numbers-as-strings
+    var bubbleWidth = margins.left + contentWidth + margins.right;
+    var bubbleHeight = margins.top + contentHeight + margins.bottom;
+
+    var pngIsTranslucent = Timeline.Graphics.pngIsTranslucent;
+    var urlPrefix = Timeline.urlPrefix;
+    
+    var setImg = function(elmt, url, width, height) {
+        elmt.style.position = "absolute";
+        elmt.style.width = width + "px";
+        elmt.style.height = height + "px";
+        if (pngIsTranslucent) {
+            elmt.style.background = "url(" + url + ")";
+        } else {
+            elmt.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url +"', sizingMethod='crop')";
+        }
+    }
+    var div = doc.createElement("div");
+    div.style.width = bubbleWidth + "px";
+    div.style.height = bubbleHeight + "px";
+    div.style.position = "absolute";
+    div.style.zIndex = 1000;
+    bubble._div = div;
+    
+    var divInner = doc.createElement("div");
+    divInner.style.width = "100%";
+    divInner.style.height = "100%";
+    divInner.style.position = "relative";
+    div.appendChild(divInner);
+    
+    var createImg = function(url, left, top, width, height) {
+        var divImg = doc.createElement("div");
+        divImg.style.left = left + "px";
+        divImg.style.top = top + "px";
+        setImg(divImg, url, width, height);
+        divInner.appendChild(divImg);
+    }
+    
+    createImg(urlPrefix + "images/bubble-top-left.png", 0, 0, margins.left, margins.top);
+    createImg(urlPrefix + "images/bubble-top.png", margins.left, 0, contentWidth, margins.top);
+    createImg(urlPrefix + "images/bubble-top-right.png", margins.left + contentWidth, 0, margins.right, margins.top);
+    
+    createImg(urlPrefix + "images/bubble-left.png", 0, margins.top, margins.left, contentHeight);
+    createImg(urlPrefix + "images/bubble-right.png", margins.left + contentWidth, margins.top, margins.right, contentHeight);
+    
+    createImg(urlPrefix + "images/bubble-bottom-left.png", 0, margins.top + contentHeight, margins.left, margins.bottom);
+    createImg(urlPrefix + "images/bubble-bottom.png", margins.left, margins.top + contentHeight, contentWidth, margins.bottom);
+    createImg(urlPrefix + "images/bubble-bottom-right.png", margins.left + contentWidth, margins.top + contentHeight, margins.right, margins.bottom);
+    
+    var divClose = doc.createElement("div");
+    divClose.style.left = (bubbleWidth - margins.right + Timeline.Graphics._bubblePadding - 16 - 2) + "px";
+    divClose.style.top = (margins.top - Timeline.Graphics._bubblePadding + 1) + "px";
+    divClose.style.cursor = "pointer";
+    setImg(divClose, urlPrefix + "images/close-button.png", 16, 16);
+    Timeline.DOM.registerEventWithObject(divClose, "click", bubble, bubble.close);
+    divInner.appendChild(divClose);
+        
+    var divContent = doc.createElement("div");
+    divContent.style.position = "absolute";
+    divContent.style.left = margins.left + "px";
+    divContent.style.top = margins.top + "px";
+    divContent.style.width = contentWidth + "px";
+    divContent.style.height = contentHeight + "px";
+    divContent.style.overflow = "auto";
+    divContent.style.background = "white";
+    divInner.appendChild(divContent);
+    bubble.content = divContent;
+    
+    (function() {
+        if (pageX - Timeline.Graphics._halfArrowWidth - Timeline.Graphics._bubblePadding > 0 &&
+            pageX + Timeline.Graphics._halfArrowWidth + Timeline.Graphics._bubblePadding < docWidth) {
+            
+            var left = pageX - Math.round(contentWidth / 2) - margins.left;
+            left = pageX < (docWidth / 2) ?
+                Math.max(left, -(margins.left - Timeline.Graphics._bubblePadding)) : 
+                Math.min(left, docWidth + (margins.right - Timeline.Graphics._bubblePadding) - bubbleWidth);
+                
+            if (pageY - Timeline.Graphics._bubblePointOffset - bubbleHeight > 0) { // top
+                var divImg = doc.createElement("div");
+                
+                divImg.style.left = (pageX - Timeline.Graphics._halfArrowWidth - left) + "px";
+                divImg.style.top = (margins.top + contentHeight) + "px";
+                setImg(divImg, urlPrefix + "images/bubble-bottom-arrow.png", 37, margins.bottom);
+                divInner.appendChild(divImg);
+                
+                div.style.left = left + "px";
+                div.style.top = (pageY - Timeline.Graphics._bubblePointOffset - bubbleHeight + 
+                    Timeline.Graphics._arrowOffsets.bottom) + "px";
+                
+                return;
+            } else if (pageY + Timeline.Graphics._bubblePointOffset + bubbleHeight < docHeight) { // bottom
+                var divImg = doc.createElement("div");
+                
+                divImg.style.left = (pageX - Timeline.Graphics._halfArrowWidth - left) + "px";
+                divImg.style.top = "0px";
+                setImg(divImg, urlPrefix + "images/bubble-top-arrow.png", 37, margins.top);
+                divInner.appendChild(divImg);
+                
+                div.style.left = left + "px";
+                div.style.top = (pageY + Timeline.Graphics._bubblePointOffset - 
+                    Timeline.Graphics._arrowOffsets.top) + "px";
+                
+                return;
+            }
+        }
+        
+        var top = pageY - Math.round(contentHeight / 2) - margins.top;
+        top = pageY < (docHeight / 2) ?
+            Math.max(top, -(margins.top - Timeline.Graphics._bubblePadding)) : 
+            Math.min(top, docHeight + (margins.bottom - Timeline.Graphics._bubblePadding) - bubbleHeight);
+                
+        if (pageX - Timeline.Graphics._bubblePointOffset - bubbleWidth > 0) { // left
+            var divImg = doc.createElement("div");
+            
+            divImg.style.left = (margins.left + contentWidth) + "px";
+            divImg.style.top = (pageY - Timeline.Graphics._halfArrowWidth - top) + "px";
+            setImg(divImg, urlPrefix + "images/bubble-right-arrow.png", margins.right, 37);
+            divInner.appendChild(divImg);
+            
+            div.style.left = (pageX - Timeline.Graphics._bubblePointOffset - bubbleWidth +
+                Timeline.Graphics._arrowOffsets.right) + "px";
+            div.style.top = top + "px";
+        } else { // right
+            var divImg = doc.createElement("div");
+            
+            divImg.style.left = "0px";
+            divImg.style.top = (pageY - Timeline.Graphics._halfArrowWidth - top) + "px";
+            setImg(divImg, urlPrefix + "images/bubble-left-arrow.png", margins.left, 37);
+            divInner.appendChild(divImg);
+            
+            div.style.left = (pageX + Timeline.Graphics._bubblePointOffset - 
+                Timeline.Graphics._arrowOffsets.left) + "px";
+            div.style.top = top + "px";
+        }
+    })();
+    
+    doc.body.appendChild(div);
+    
+    return bubble;
+};
+
+Timeline.Graphics.createMessageBubble = function(doc) {
+    var containerDiv = doc.createElement("div");
+    if (Timeline.Graphics.pngIsTranslucent) {
+        var topDiv = doc.createElement("div");
+        topDiv.style.height = "33px";
+        topDiv.style.background = "url(" + Timeline.urlPrefix + "images/message-top-left.png) top left no-repeat";
+        topDiv.style.paddingLeft = "44px";
+        containerDiv.appendChild(topDiv);
+        
+        var topRightDiv = doc.createElement("div");
+        topRightDiv.style.height = "33px";
+        topRightDiv.style.background = "url(" + Timeline.urlPrefix + "images/message-top-right.png) top right no-repeat";
+        topDiv.appendChild(topRightDiv);
+        
+        var middleDiv = doc.createElement("div");
+        middleDiv.style.background = "url(" + Timeline.urlPrefix + "images/message-left.png) top left repeat-y";
+        middleDiv.style.paddingLeft = "44px";
+        containerDiv.appendChild(middleDiv);
+        
+        var middleRightDiv = doc.createElement("div");
+        middleRightDiv.style.background = "url(" + Timeline.urlPrefix + "images/message-right.png) top right repeat-y";
+        middleRightDiv.style.paddingRight = "44px";
+        middleDiv.appendChild(middleRightDiv);
+        
+        var contentDiv = doc.createElement("div");
+        middleRightDiv.appendChild(contentDiv);
+        
+        var bottomDiv = doc.createElement("div");
+        bottomDiv.style.height = "55px";
+        bottomDiv.style.background = "url(" + Timeline.urlPrefix + "images/message-bottom-left.png) bottom left no-repeat";
+        bottomDiv.style.paddingLeft = "44px";
+        containerDiv.appendChild(bottomDiv);
+        
+        var bottomRightDiv = doc.createElement("div");
+        bottomRightDiv.style.height = "55px";
+        bottomRightDiv.style.background = "url(" + Timeline.urlPrefix + "images/message-bottom-right.png) bottom right no-repeat";
+        bottomDiv.appendChild(bottomRightDiv);
+    } else {
+        containerDiv.style.border = "2px solid #7777AA";
+        containerDiv.style.padding = "20px";
+        containerDiv.style.background = "white";
+        Timeline.Graphics.setOpacity(containerDiv, 90);
+        
+        var contentDiv = doc.createElement("div");
+        containerDiv.appendChild(contentDiv);
+    }
+    
+    return {
+        containerDiv:   containerDiv,
+        contentDiv:     contentDiv
+    };
+};
+
+Timeline.Graphics.createAnimation = function(f, from, to, duration) {
+    return new Timeline.Graphics._Animation(f, from, to, duration);
+};
+
+Timeline.Graphics._Animation = function(f, from, to, duration) {
+    this.f = f;
+    
+    this.from = from;
+    this.to = to;
+    this.current = from;
+    
+    this.duration = duration;
+    this.start = new Date().getTime();
+    this.timePassed = 0;
+};
+
+Timeline.Graphics._Animation.prototype.run = function() {
+    var a = this;
+    window.setTimeout(function() { a.step(); }, 100);
+};
+
+Timeline.Graphics._Animation.prototype.step = function() {
+    this.timePassed += 100;
+    
+    var timePassedFraction = this.timePassed / this.duration;
+    var parameterFraction = -Math.cos(timePassedFraction * Math.PI) / 2 + 0.5;
+    var current = parameterFraction * (this.to - this.from) + this.from;
+    
+    try {
+        this.f(current, current - this.current);
+    } catch (e) {
+    }
+    this.current = current;
+    
+    if (this.timePassed < this.duration) {
+        this.run();
+    }
+};

Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/html.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/html.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/html.js (added)
+++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/html.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,274 @@
+/*==================================================
+ *  HTML Utility Functions
+ *==================================================
+ */
+
+Timeline.HTML = new Object();
+
+Timeline.HTML._e2uHash = {};
+(function() {
+    e2uHash = Timeline.HTML._e2uHash;
+    e2uHash['nbsp']= '\u00A0[space]';
+    e2uHash['iexcl']= '\u00A1';
+    e2uHash['cent']= '\u00A2';
+    e2uHash['pound']= '\u00A3';
+    e2uHash['curren']= '\u00A4';
+    e2uHash['yen']= '\u00A5';
+    e2uHash['brvbar']= '\u00A6';
+    e2uHash['sect']= '\u00A7';
+    e2uHash['uml']= '\u00A8';
+    e2uHash['copy']= '\u00A9';
+    e2uHash['ordf']= '\u00AA';
+    e2uHash['laquo']= '\u00AB';
+    e2uHash['not']= '\u00AC';
+    e2uHash['shy']= '\u00AD';
+    e2uHash['reg']= '\u00AE';
+    e2uHash['macr']= '\u00AF';
+    e2uHash['deg']= '\u00B0';
+    e2uHash['plusmn']= '\u00B1';
+    e2uHash['sup2']= '\u00B2';
+    e2uHash['sup3']= '\u00B3';
+    e2uHash['acute']= '\u00B4';
+    e2uHash['micro']= '\u00B5';
+    e2uHash['para']= '\u00B6';
+    e2uHash['middot']= '\u00B7';
+    e2uHash['cedil']= '\u00B8';
+    e2uHash['sup1']= '\u00B9';
+    e2uHash['ordm']= '\u00BA';
+    e2uHash['raquo']= '\u00BB';
+    e2uHash['frac14']= '\u00BC';
+    e2uHash['frac12']= '\u00BD';
+    e2uHash['frac34']= '\u00BE';
+    e2uHash['iquest']= '\u00BF';
+    e2uHash['Agrave']= '\u00C0';
+    e2uHash['Aacute']= '\u00C1';
+    e2uHash['Acirc']= '\u00C2';
+    e2uHash['Atilde']= '\u00C3';
+    e2uHash['Auml']= '\u00C4';
+    e2uHash['Aring']= '\u00C5';
+    e2uHash['AElig']= '\u00C6';
+    e2uHash['Ccedil']= '\u00C7';
+    e2uHash['Egrave']= '\u00C8';
+    e2uHash['Eacute']= '\u00C9';
+    e2uHash['Ecirc']= '\u00CA';
+    e2uHash['Euml']= '\u00CB';
+    e2uHash['Igrave']= '\u00CC';
+    e2uHash['Iacute']= '\u00CD';
+    e2uHash['Icirc']= '\u00CE';
+    e2uHash['Iuml']= '\u00CF';
+    e2uHash['ETH']= '\u00D0';
+    e2uHash['Ntilde']= '\u00D1';
+    e2uHash['Ograve']= '\u00D2';
+    e2uHash['Oacute']= '\u00D3';
+    e2uHash['Ocirc']= '\u00D4';
+    e2uHash['Otilde']= '\u00D5';
+    e2uHash['Ouml']= '\u00D6';
+    e2uHash['times']= '\u00D7';
+    e2uHash['Oslash']= '\u00D8';
+    e2uHash['Ugrave']= '\u00D9';
+    e2uHash['Uacute']= '\u00DA';
+    e2uHash['Ucirc']= '\u00DB';
+    e2uHash['Uuml']= '\u00DC';
+    e2uHash['Yacute']= '\u00DD';
+    e2uHash['THORN']= '\u00DE';
+    e2uHash['szlig']= '\u00DF';
+    e2uHash['agrave']= '\u00E0';
+    e2uHash['aacute']= '\u00E1';
+    e2uHash['acirc']= '\u00E2';
+    e2uHash['atilde']= '\u00E3';
+    e2uHash['auml']= '\u00E4';
+    e2uHash['aring']= '\u00E5';
+    e2uHash['aelig']= '\u00E6';
+    e2uHash['ccedil']= '\u00E7';
+    e2uHash['egrave']= '\u00E8';
+    e2uHash['eacute']= '\u00E9';
+    e2uHash['ecirc']= '\u00EA';
+    e2uHash['euml']= '\u00EB';
+    e2uHash['igrave']= '\u00EC';
+    e2uHash['iacute']= '\u00ED';
+    e2uHash['icirc']= '\u00EE';
+    e2uHash['iuml']= '\u00EF';
+    e2uHash['eth']= '\u00F0';
+    e2uHash['ntilde']= '\u00F1';
+    e2uHash['ograve']= '\u00F2';
+    e2uHash['oacute']= '\u00F3';
+    e2uHash['ocirc']= '\u00F4';
+    e2uHash['otilde']= '\u00F5';
+    e2uHash['ouml']= '\u00F6';
+    e2uHash['divide']= '\u00F7';
+    e2uHash['oslash']= '\u00F8';
+    e2uHash['ugrave']= '\u00F9';
+    e2uHash['uacute']= '\u00FA';
+    e2uHash['ucirc']= '\u00FB';
+    e2uHash['uuml']= '\u00FC';
+    e2uHash['yacute']= '\u00FD';
+    e2uHash['thorn']= '\u00FE';
+    e2uHash['yuml']= '\u00FF';
+    e2uHash['quot']= '\u0022';
+    e2uHash['amp']= '\u0026';
+    e2uHash['lt']= '\u003C';
+    e2uHash['gt']= '\u003E';
+    e2uHash['OElig']= '';
+    e2uHash['oelig']= '\u0153';
+    e2uHash['Scaron']= '\u0160';
+    e2uHash['scaron']= '\u0161';
+    e2uHash['Yuml']= '\u0178';
+    e2uHash['circ']= '\u02C6';
+    e2uHash['tilde']= '\u02DC';
+    e2uHash['ensp']= '\u2002';
+    e2uHash['emsp']= '\u2003';
+    e2uHash['thinsp']= '\u2009';
+    e2uHash['zwnj']= '\u200C';
+    e2uHash['zwj']= '\u200D';
+    e2uHash['lrm']= '\u200E';
+    e2uHash['rlm']= '\u200F';
+    e2uHash['ndash']= '\u2013';
+    e2uHash['mdash']= '\u2014';
+    e2uHash['lsquo']= '\u2018';
+    e2uHash['rsquo']= '\u2019';
+    e2uHash['sbquo']= '\u201A';
+    e2uHash['ldquo']= '\u201C';
+    e2uHash['rdquo']= '\u201D';
+    e2uHash['bdquo']= '\u201E';
+    e2uHash['dagger']= '\u2020';
+    e2uHash['Dagger']= '\u2021';
+    e2uHash['permil']= '\u2030';
+    e2uHash['lsaquo']= '\u2039';
+    e2uHash['rsaquo']= '\u203A';
+    e2uHash['euro']= '\u20AC';
+    e2uHash['fnof']= '\u0192';
+    e2uHash['Alpha']= '\u0391';
+    e2uHash['Beta']= '\u0392';
+    e2uHash['Gamma']= '\u0393';
+    e2uHash['Delta']= '\u0394';
+    e2uHash['Epsilon']= '\u0395';
+    e2uHash['Zeta']= '\u0396';
+    e2uHash['Eta']= '\u0397';
+    e2uHash['Theta']= '\u0398';
+    e2uHash['Iota']= '\u0399';
+    e2uHash['Kappa']= '\u039A';
+    e2uHash['Lambda']= '\u039B';
+    e2uHash['Mu']= '\u039C';
+    e2uHash['Nu']= '\u039D';
+    e2uHash['Xi']= '\u039E';
+    e2uHash['Omicron']= '\u039F';
+    e2uHash['Pi']= '\u03A0';
+    e2uHash['Rho']= '\u03A1';
+    e2uHash['Sigma']= '\u03A3';
+    e2uHash['Tau']= '\u03A4';
+    e2uHash['Upsilon']= '\u03A5';
+    e2uHash['Phi']= '\u03A6';
+    e2uHash['Chi']= '\u03A7';
+    e2uHash['Psi']= '\u03A8';
+    e2uHash['Omega']= '\u03A9';
+    e2uHash['alpha']= '\u03B1';
+    e2uHash['beta']= '\u03B2';
+    e2uHash['gamma']= '\u03B3';
+    e2uHash['delta']= '\u03B4';
+    e2uHash['epsilon']= '\u03B5';
+    e2uHash['zeta']= '\u03B6';
+    e2uHash['eta']= '\u03B7';
+    e2uHash['theta']= '\u03B8';
+    e2uHash['iota']= '\u03B9';
+    e2uHash['kappa']= '\u03BA';
+    e2uHash['lambda']= '\u03BB';
+    e2uHash['mu']= '\u03BC';
+    e2uHash['nu']= '\u03BD';
+    e2uHash['xi']= '\u03BE';
+    e2uHash['omicron']= '\u03BF';
+    e2uHash['pi']= '\u03C0';
+    e2uHash['rho']= '\u03C1';
+    e2uHash['sigmaf']= '\u03C2';
+    e2uHash['sigma']= '\u03C3';
+    e2uHash['tau']= '\u03C4';
+    e2uHash['upsilon']= '\u03C5';
+    e2uHash['phi']= '\u03C6';
+    e2uHash['chi']= '\u03C7';
+    e2uHash['psi']= '\u03C8';
+    e2uHash['omega']= '\u03C9';
+    e2uHash['thetasym']= '\u03D1';
+    e2uHash['upsih']= '\u03D2';
+    e2uHash['piv']= '\u03D6';
+    e2uHash['bull']= '\u2022';
+    e2uHash['hellip']= '\u2026';
+    e2uHash['prime']= '\u2032';
+    e2uHash['Prime']= '\u2033';
+    e2uHash['oline']= '\u203E';
+    e2uHash['frasl']= '\u2044';
+    e2uHash['weierp']= '\u2118';
+    e2uHash['image']= '\u2111';
+    e2uHash['real']= '\u211C';
+    e2uHash['trade']= '\u2122';
+    e2uHash['alefsym']= '\u2135';
+    e2uHash['larr']= '\u2190';
+    e2uHash['uarr']= '\u2191';
+    e2uHash['rarr']= '\u2192';
+    e2uHash['darr']= '\u2193';
+    e2uHash['harr']= '\u2194';
+    e2uHash['crarr']= '\u21B5';
+    e2uHash['lArr']= '\u21D0';
+    e2uHash['uArr']= '\u21D1';
+    e2uHash['rArr']= '\u21D2';
+    e2uHash['dArr']= '\u21D3';
+    e2uHash['hArr']= '\u21D4';
+    e2uHash['forall']= '\u2200';
+    e2uHash['part']= '\u2202';
+    e2uHash['exist']= '\u2203';
+    e2uHash['empty']= '\u2205';
+    e2uHash['nabla']= '\u2207';
+    e2uHash['isin']= '\u2208';
+    e2uHash['notin']= '\u2209';
+    e2uHash['ni']= '\u220B';
+    e2uHash['prod']= '\u220F';
+    e2uHash['sum']= '\u2211';
+    e2uHash['minus']= '\u2212';
+    e2uHash['lowast']= '\u2217';
+    e2uHash['radic']= '\u221A';
+    e2uHash['prop']= '\u221D';
+    e2uHash['infin']= '\u221E';
+    e2uHash['ang']= '\u2220';
+    e2uHash['and']= '\u2227';
+    e2uHash['or']= '\u2228';
+    e2uHash['cap']= '\u2229';
+    e2uHash['cup']= '\u222A';
+    e2uHash['int']= '\u222B';
+    e2uHash['there4']= '\u2234';
+    e2uHash['sim']= '\u223C';
+    e2uHash['cong']= '\u2245';
+    e2uHash['asymp']= '\u2248';
+    e2uHash['ne']= '\u2260';
+    e2uHash['equiv']= '\u2261';
+    e2uHash['le']= '\u2264';
+    e2uHash['ge']= '\u2265';
+    e2uHash['sub']= '\u2282';
+    e2uHash['sup']= '\u2283';
+    e2uHash['nsub']= '\u2284';
+    e2uHash['sube']= '\u2286';
+    e2uHash['supe']= '\u2287';
+    e2uHash['oplus']= '\u2295';
+    e2uHash['otimes']= '\u2297';
+    e2uHash['perp']= '\u22A5';
+    e2uHash['sdot']= '\u22C5';
+    e2uHash['lceil']= '\u2308';
+    e2uHash['rceil']= '\u2309';
+    e2uHash['lfloor']= '\u230A';
+    e2uHash['rfloor']= '\u230B';
+    e2uHash['lang']= '\u2329';
+    e2uHash['rang']= '\u232A';
+    e2uHash['loz']= '\u25CA';
+    e2uHash['spades']= '\u2660';
+    e2uHash['clubs']= '\u2663';
+    e2uHash['hearts']= '\u2665';
+    e2uHash['diams']= '\u2666'; 
+})();
+
+Timeline.HTML.deEntify = function(s) {
+    e2uHash = Timeline.HTML._e2uHash;
+    
+    var re = /&(\w+?);/;
+    while (re.test(s)) {
+        var m = s.match(re);
+        s = s.replace(re, e2uHash[m[1]]);
+    }
+    return s;
+};
\ No newline at end of file

Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/platform.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/platform.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/platform.js (added)
+++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/platform.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,90 @@
+/*==================================================
+ *  Platform Utility Functions and Constants
+ *==================================================
+ */
+
+Timeline.Platform.os = {
+    isMac:   false,
+    isWin:   false,
+    isWin32: false,
+    isUnix:  false
+};
+Timeline.Platform.browser = {
+    isIE:           false,
+    isNetscape:     false,
+    isMozilla:      false,
+    isFirefox:      false,
+    isOpera:        false,
+    isSafari:       false,
+
+    majorVersion:   0,
+    minorVersion:   0
+};
+
+(function() {
+    var an = navigator.appName.toLowerCase();
+	var ua = navigator.userAgent.toLowerCase(); 
+    
+    /*
+     *  Operating system
+     */
+	Timeline.Platform.os.isMac = (ua.indexOf('mac') != -1);
+	Timeline.Platform.os.isWin = (ua.indexOf('win') != -1);
+	Timeline.Platform.os.isWin32 = Timeline.Platform.isWin && (   
+        ua.indexOf('95') != -1 || 
+        ua.indexOf('98') != -1 || 
+        ua.indexOf('nt') != -1 || 
+        ua.indexOf('win32') != -1 || 
+        ua.indexOf('32bit') != -1
+    );
+	Timeline.Platform.os.isUnix = (ua.indexOf('x11') != -1);
+    
+    /*
+     *  Browser
+     */
+    Timeline.Platform.browser.isIE = (an.indexOf("microsoft") != -1);
+    Timeline.Platform.browser.isNetscape = (an.indexOf("netscape") != -1);
+    Timeline.Platform.browser.isMozilla = (ua.indexOf("mozilla") != -1);
+    Timeline.Platform.browser.isFirefox = (ua.indexOf("firefox") != -1);
+    Timeline.Platform.browser.isOpera = (an.indexOf("opera") != -1);
+    //Timeline.Platform.browser.isSafari = (an.indexOf("safari") != -1);
+    
+    var parseVersionString = function(s) {
+        var a = s.split(".");
+        Timeline.Platform.browser.majorVersion = parseInt(a[0]);
+        Timeline.Platform.browser.minorVersion = parseInt(a[1]);
+    };
+    var indexOf = function(s, sub, start) {
+        var i = s.indexOf(sub, start);
+        return i >= 0 ? i : s.length;
+    };
+    
+    if (Timeline.Platform.browser.isMozilla) {
+        var offset = ua.indexOf("mozilla/");
+        if (offset >= 0) {
+            parseVersionString(ua.substring(offset + 8, indexOf(ua, " ", offset)));
+        }
+    }
+    if (Timeline.Platform.browser.isIE) {
+        var offset = ua.indexOf("msie ");
+        if (offset >= 0) {
+            parseVersionString(ua.substring(offset + 5, indexOf(ua, ";", offset)));
+        }
+    }
+    if (Timeline.Platform.browser.isNetscape) {
+        var offset = ua.indexOf("rv:");
+        if (offset >= 0) {
+            parseVersionString(ua.substring(offset + 3, indexOf(ua, ")", offset)));
+        }
+    }
+    if (Timeline.Platform.browser.isFirefox) {
+        var offset = ua.indexOf("firefox/");
+        if (offset >= 0) {
+            parseVersionString(ua.substring(offset + 8, indexOf(ua, " ", offset)));
+        }
+    }
+})();
+
+Timeline.Platform.getDefaultLocale = function() {
+    return Timeline.Platform.clientLocale;
+};
\ No newline at end of file

Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/xmlhttp.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/xmlhttp.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/xmlhttp.js (added)
+++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/scripts/util/xmlhttp.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,133 @@
+/*==================================================
+ *  XmlHttp Utility Functions
+ *==================================================
+ */
+
+Timeline.XmlHttp = new Object();
+
+/**
+ *  Callback for XMLHttp onRequestStateChange.
+ */
+Timeline.XmlHttp._onReadyStateChange = function(xmlhttp, fError, fDone) {
+    switch (xmlhttp.readyState) {
+    // 1: Request not yet made
+    // 2: Contact established with server but nothing downloaded yet
+    // 3: Called multiple while downloading in progress
+    
+    // Download complete
+    case 4:
+        try {
+            if (xmlhttp.status == 0     // file:// urls, works on Firefox
+             || xmlhttp.status == 200   // http:// urls
+            ) {
+                if (fDone) {
+                    fDone(xmlhttp);
+                }
+            } else {
+                if (fError) {
+                    fError(
+                        xmlhttp.statusText,
+                        xmlhttp.status,
+                        xmlhttp
+                    );
+                }
+            }
+        } catch (e) {
+            Timeline.Debug.exception(e);
+        }
+        break;
+    }
+};
+
+/**
+ *  Creates an XMLHttpRequest object. On the first run, this
+ *  function creates a platform-specific function for
+ *  instantiating an XMLHttpRequest object and then replaces
+ *  itself with that function.
+ */
+Timeline.XmlHttp._createRequest = function() {
+    if (Timeline.Platform.browser.isIE) {
+        var programIDs = [
+        "Msxml2.XMLHTTP",
+        "Microsoft.XMLHTTP",
+        "Msxml2.XMLHTTP.4.0"
+        ];
+        for (var i = 0; i < programIDs.length; i++) {
+            try {
+                var programID = programIDs[i];
+                var f = function() {
+                    return new ActiveXObject(programID);
+                };
+                var o = f();
+                
+                // We are replacing the Timeline._createXmlHttpRequest
+                // function with this inner function as we've
+                // found out that it works. This is so that we
+                // don't have to do all the testing over again
+                // on subsequent calls.
+                Timeline.XmlHttp._createRequest = f;
+                
+                return o;
+            } catch (e) {
+                // silent
+            }
+        }
+        throw new Error("Failed to create an XMLHttpRequest object");
+    } else {
+        try {
+            var f = function() {
+                return new XMLHttpRequest();
+            };
+            var o = f();
+            
+            // We are replacing the Timeline._createXmlHttpRequest
+            // function with this inner function as we've
+            // found out that it works. This is so that we
+            // don't have to do all the testing over again
+            // on subsequent calls.
+            Timeline.XmlHttp._createRequest = f;
+            
+            return o;
+        } catch (e) {
+            throw new Error("Failed to create an XMLHttpRequest object");
+        }
+    }
+};
+
+/**
+ *  Performs an asynchronous HTTP GET.
+ *  fError is of the form function(statusText, statusCode, xmlhttp).
+ *  fDone is of the form function(xmlhttp).
+ */
+Timeline.XmlHttp.get = function(url, fError, fDone) {
+    var xmlhttp = Timeline.XmlHttp._createRequest();
+    
+    xmlhttp.open("GET", url, true);
+    xmlhttp.onreadystatechange = function() {
+        Timeline.XmlHttp._onReadyStateChange(xmlhttp, fError, fDone);
+    };
+    xmlhttp.send(null);
+};
+
+/**
+ *  Performs an asynchronous HTTP POST.
+ *  fError is of the form function(statusText, statusCode, xmlhttp).
+ *  fDone is of the form function(xmlhttp).
+ */
+Timeline.XmlHttp.post = function(url, body, fError, fDone) {
+    var xmlhttp = Timeline.XmlHttp._createRequest();
+    
+    xmlhttp.open("POST", url, true);
+    xmlhttp.onreadystatechange = function() {
+        Timeline.XmlHttp._onReadyStateChange(xmlhttp, fError, fDone);
+    };
+    xmlhttp.send(body);
+};
+
+Timeline.XmlHttp._forceXML = function(xmlhttp) {
+    try {
+        xmlhttp.overrideMimeType("text/xml");
+    } catch (e) {
+        xmlhttp.setrequestheader("Content-Type", "text/xml");
+    }
+};
\ No newline at end of file

Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/search.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/search.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/search.js (added)
+++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/search.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,123 @@
+function centerTimeline(date) {
+    tl.getBand(0).setCenterVisibleDate(Timeline.DateTime.parseGregorianDateTime(date));
+}
+
+function setupFilterHighlightControls(div, timeline, bandIndices, theme) {
+    var table = document.createElement("table");
+    var tr = table.insertRow(0);
+    
+    var td = tr.insertCell(0);
+    td.innerHTML = "Filter:";
+    
+    td = tr.insertCell(1);
+    td.innerHTML = "Highlight:";
+    
+    var handler = function(elmt, evt, target) {
+        onKeyPress(timeline, bandIndices, table);
+    };
+    
+    tr = table.insertRow(1);
+    tr.style.verticalAlign = "top";
+    
+    td = tr.insertCell(0);
+    
+    var input = document.createElement("input");
+    input.type = "text";
+    Timeline.DOM.registerEvent(input, "keypress", handler);
+    td.appendChild(input);
+    
+    for (var i = 0; i < theme.event.highlightColors.length; i++) {
+        td = tr.insertCell(i + 1);
+        
+        input = document.createElement("input");
+        input.type = "text";
+        Timeline.DOM.registerEvent(input, "keypress", handler);
+        td.appendChild(input);
+        
+        var divColor = document.createElement("div");
+        divColor.style.height = "0.5em";
+        divColor.style.background = theme.event.highlightColors[i];
+        td.appendChild(divColor);
+    }
+    
+    td = tr.insertCell(tr.cells.length);
+    var button = document.createElement("button");
+    button.innerHTML = "Clear All";
+    Timeline.DOM.registerEvent(button, "click", function() {
+        clearAll(timeline, bandIndices, table);
+    });
+    td.appendChild(button);
+    
+    div.appendChild(table);
+}
+
+var timerID = null;
+function onKeyPress(timeline, bandIndices, table) {
+    if (timerID != null) {
+        window.clearTimeout(timerID);
+    }
+    timerID = window.setTimeout(function() {
+        performFiltering(timeline, bandIndices, table);
+    }, 300);
+}
+function cleanString(s) {
+    return s.replace(/^\s+/, '').replace(/\s+$/, '');
+}
+function performFiltering(timeline, bandIndices, table) {
+    timerID = null;
+    
+    var tr = table.rows[1];
+    var text = cleanString(tr.cells[0].firstChild.value);
+    
+    var filterMatcher = null;
+    if (text.length > 0) {
+        var regex = new RegExp(text, "i");
+        filterMatcher = function(evt) {
+            return regex.test(evt.getText()) || regex.test(evt.getDescription());
+        };
+    }
+    
+    var regexes = [];
+    var hasHighlights = false;
+    for (var x = 1; x < tr.cells.length - 1; x++) {
+        var input = tr.cells[x].firstChild;
+        var text2 = cleanString(input.value);
+        if (text2.length > 0) {
+            hasHighlights = true;
+            regexes.push(new RegExp(text2, "i"));
+        } else {
+            regexes.push(null);
+        }
+    }
+    var highlightMatcher = hasHighlights ? function(evt) {
+        var text = evt.getText();
+        var description = evt.getDescription();
+        for (var x = 0; x < regexes.length; x++) {
+            var regex = regexes[x];
+            if (regex != null && (regex.test(text) || regex.test(description))) {
+                return x;
+            }
+        }
+        return -1;
+    } : null;
+    
+    for (var i = 0; i < bandIndices.length; i++) {
+        var bandIndex = bandIndices[i];
+        timeline.getBand(bandIndex).getEventPainter().setFilterMatcher(filterMatcher);
+        timeline.getBand(bandIndex).getEventPainter().setHighlightMatcher(highlightMatcher);
+    }
+    timeline.paint();
+}
+function clearAll(timeline, bandIndices, table) {
+    var tr = table.rows[1];
+    for (var x = 0; x < tr.cells.length - 1; x++) {
+        tr.cells[x].firstChild.value = "";
+    }
+    
+    for (var i = 0; i < bandIndices.length; i++) {
+        var bandIndex = bandIndices[i];
+        timeline.getBand(bandIndex).getEventPainter().setFilterMatcher(null);
+        timeline.getBand(bandIndex).getEventPainter().setHighlightMatcher(null);
+    }
+    timeline.paint();
+}
\ No newline at end of file

Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/styles/ethers.css
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/styles/ethers.css?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/styles/ethers.css (added)
+++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/styles/ethers.css Wed Apr 29 23:33:50 2009
@@ -0,0 +1,63 @@
+.timeline-ether-marker-bottom {
+    width:          5em; 
+    height:         1.5em; 
+    border-left:    1px solid #aaa; 
+    padding-left:   2px; 
+    color:          #aaa;
+}
+
+.timeline-ether-marker-bottom-emphasized {
+    width:          5em; 
+    height:         2em; 
+    border-left:    1px solid #aaa; 
+    padding-left:   2px; 
+    color:          black;
+}
+
+.timeline-ether-marker-top {
+    width:          5em; 
+    height:         1.5em; 
+    border-left:    1px solid #aaa; 
+    padding-left:   2px; 
+    color:          #aaa;
+}
+
+.timeline-ether-marker-top-emphasized {
+    width:          5em; 
+    height:         2em; 
+    border-left:    1px solid #aaa; 
+    padding-left:   2px; 
+    color:          black;
+}
+
+
+.timeline-ether-marker-right {
+    width:          5em; 
+    height:         1.5em; 
+    border-top:     1px solid #aaa; 
+    padding-top:    2px; 
+    color:          #aaa;
+}
+
+.timeline-ether-marker-right-emphasized {
+    width:          7em; 
+    height:         1.5em; 
+    border-top:     1px solid #aaa; 
+    padding-top:    2px; 
+    color:          black;
+}
+.timeline-ether-marker-left {
+    width:          5em; 
+    height:         1.5em; 
+    border-top:     1px solid #aaa; 
+    padding-top:    2px; 
+    color:          #aaa;
+}
+
+.timeline-ether-marker-left-emphasized {
+    width:          7em; 
+    height:         1.5em; 
+    border-top:     1px solid #aaa; 
+    padding-top:    2px; 
+    color:          black;
+}

Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/styles/events.css
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/styles/events.css?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/styles/events.css (added)
+++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/styles/events.css Wed Apr 29 23:33:50 2009
@@ -0,0 +1,45 @@
+.timeline-duration-event {
+    position: absolute;
+    overflow: hidden;
+    border: 1px solid blue;
+}
+
+.timeline-instant-event2 {
+    position: absolute;
+    overflow: hidden;
+    border-left: 1px solid blue;
+    padding-left: 2px;
+}
+
+.timeline-instant-event {
+    position: absolute;
+    overflow: hidden;
+}
+
+.timeline-event-bubble-title {
+    font-weight: bold;
+    border-bottom: 1px solid #888;
+    margin-bottom: 0.5em;
+}
+
+.timeline-event-bubble-body {
+}
+
+.timeline-event-bubble-wiki {
+    margin:     0.5em;
+    text-align: right;
+    color:      #A0A040;
+}
+.timeline-event-bubble-wiki a {
+    color:      #A0A040;
+}
+
+.timeline-event-bubble-time {
+    color: #aaa;
+}
+
+.timeline-event-bubble-image {
+    float: right;
+    padding-left: 5px;
+    padding-bottom: 5px;
+}
\ No newline at end of file

Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/styles/timeline.css
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/styles/timeline.css?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/styles/timeline.css (added)
+++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/styles/timeline.css Wed Apr 29 23:33:50 2009
@@ -0,0 +1,65 @@
+.timeline-container {
+    position: relative;
+    overflow: hidden;
+}
+
+.timeline-copyright {
+    position: absolute;
+    bottom: 0px;
+    left: 0px;
+    z-index: 1000;
+    cursor: pointer;
+}
+
+.timeline-message-container {
+    position:   absolute;
+    top:        30%;
+    left:       35%;
+    right:      35%;
+    z-index:    1000;
+    display:    none;
+}
+.timeline-message {
+    font-size:      120%;
+    font-weight:    bold;
+    text-align:     center;
+}
+.timeline-message img {
+    vertical-align: middle;
+}
+
+.timeline-band {
+    position:   absolute;
+    background: #eee;
+    z-index:    10;
+}
+
+.timeline-band-inner {
+    position: relative;
+    width: 100%;
+    height: 100%;
+}
+
+.timeline-band-input {
+    position:   absolute;
+    width:      1em;
+    height:     1em;
+    overflow:   hidden;
+    z-index:    0;
+}
+.timeline-band-input input{
+    width:      0;
+}
+
+.timeline-band-layer {
+    position:   absolute;
+    width:      100%;
+    height:     100%;
+}
+
+.timeline-band-layer-inner {
+    position:   relative;
+    width:      100%;
+    height:     100%;
+}
+

Added: hadoop/chukwa/trunk/src/web/hicc/lib/timeline/timeline-api.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/lib/timeline/timeline-api.js?rev=770000&view=auto
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/lib/timeline/timeline-api.js (added)
+++ hadoop/chukwa/trunk/src/web/hicc/lib/timeline/timeline-api.js Wed Apr 29 23:33:50 2009
@@ -0,0 +1,244 @@
+/*==================================================
+ *  Timeline API
+ *
+ *  This file will load all the Javascript files
+ *  necessary to make the standard timeline work.
+ *  It also detects the default locale.
+ *
+ *  Include this file in your HTML file as follows:
+ *
+ *    <script src="http://simile.mit.edu/timeline/api/scripts/timeline-api.js" type="text/javascript"></script>
+ *
+ *==================================================
+ */
+ 
+var Timeline = new Object();
+Timeline.Platform = new Object();
+    /*
+        HACK: We need these 2 things here because we cannot simply append
+        a <script> element containing code that accesses Timeline.Platform
+        to initialize it because IE executes that <script> code first
+        before it loads timeline.js and util/platform.js.
+    */
+
+(function() {
+    var bundle = true;
+    var javascriptFiles = [
+        "timeline.js",
+        
+        "util/platform.js",
+        "util/debug.js",
+        "util/xmlhttp.js",
+        "util/dom.js",
+        "util/graphics.js",
+        "util/date-time.js",
+        "util/data-structure.js",
+        "util/html.js",
+        
+        "units.js",
+        "themes.js",
+        "ethers.js",
+        "ether-painters.js",
+        "labellers.js",
+        "sources.js",
+        "layouts.js",
+        "painters.js",
+        "decorators.js"
+    ];
+    var cssFiles = [
+        "timeline.css",
+        "ethers.css",
+        "events.css"
+    ];
+    
+    var localizedJavascriptFiles = [
+        "timeline.js",
+        "labellers.js"
+    ];
+    var localizedCssFiles = [
+    ];
+    
+    // ISO-639 language codes, ISO-3166 country codes (2 characters)
+    var supportedLocales = [
+        "cs",       // Czech
+        "de",       // German
+        "en",       // English
+        "es",       // Spanish
+        "fr",       // French
+        "it",       // Italian
+        "ru",       // Russian
+        "se",       // Swedish
+        "vi",       // Vietnamese
+        "zh"        // Chinese
+    ];
+    
+    try {
+        var desiredLocales = [ "en" ];
+        var defaultServerLocale = "en";
+        
+        var parseURLParameters = function(parameters) {
+            var params = parameters.split("&");
+            for (var p = 0; p < params.length; p++) {
+                var pair = params[p].split("=");
+                if (pair[0] == "locales") {
+                    desiredLocales = desiredLocales.concat(pair[1].split(","));
+                } else if (pair[0] == "defaultLocale") {
+                    defaultServerLocale = pair[1];
+                } else if (pair[0] == "bundle") {
+                    bundle = pair[1] != "false";
+                }
+            }
+        };
+        
+        (function() {
+            if (typeof Timeline_urlPrefix == "string") {
+                Timeline.urlPrefix = Timeline_urlPrefix;
+                if (typeof Timeline_parameters == "string") {
+                    parseURLParameters(Timeline_parameters);
+                }
+            } else {
+                var heads = document.documentElement.getElementsByTagName("head");
+                for (var h = 0; h < heads.length; h++) {
+                    var scripts = heads[h].getElementsByTagName("script");
+                    for (var s = 0; s < scripts.length; s++) {
+                        var url = scripts[s].src;
+                        var i = url.indexOf("timeline-api.js");
+                        if (i >= 0) {
+                            Timeline.urlPrefix = url.substr(0, i);
+                            var q = url.indexOf("?");
+                            if (q > 0) {
+                                parseURLParameters(url.substr(q + 1));
+                            }
+                            return;
+                        }
+                    }
+                }
+                throw new Error("Failed to derive URL prefix for Timeline API code files");
+            }
+        })();
+        
+        var includeJavascriptFiles;
+        var includeCssFiles;
+        if ("SimileAjax" in window) {
+            includeJavascriptFiles = function(urlPrefix, filenames) {
+                SimileAjax.includeJavascriptFiles(document, urlPrefix, filenames);
+            }
+            includeCssFiles = function(urlPrefix, filenames) {
+                SimileAjax.includeCssFiles(document, urlPrefix, filenames);
+            }
+        } else {
+            var getHead = function() {
+                return document.getElementsByTagName("head")[0];
+            };
+            var includeJavascriptFile = function(url) {
+                if (document.body == null) {
+                    try {
+                        document.write("<script src='" + url + "' type='text/javascript'></script>");
+                        return;
+                    } catch (e) {
+                        // fall through
+                    }
+                }
+                
+                var script = document.createElement("script");
+                script.type = "text/javascript";
+                script.language = "JavaScript";
+                script.src = url;
+                getHead().appendChild(script);
+            };
+            var includeCssFile = function(url) {
+                if (document.body == null) {
+                    try {
+                        document.write("<link rel='stylesheet' href='" + url + "' type='text/css'/>");
+                        return;
+                    } catch (e) {
+                        // fall through
+                    }
+                }
+                
+                var link = document.createElement("link");
+                link.setAttribute("rel", "stylesheet");
+                link.setAttribute("type", "text/css");
+                link.setAttribute("href", url);
+                getHead().appendChild(link);
+            }
+            
+            includeJavascriptFiles = function(urlPrefix, filenames) {
+                for (var i = 0; i < filenames.length; i++) {
+                    includeJavascriptFile(urlPrefix + filenames[i]);
+                }
+            };
+            includeCssFiles = function(urlPrefix, filenames) {
+                for (var i = 0; i < filenames.length; i++) {
+                    includeCssFile(urlPrefix + filenames[i]);
+                }
+            };
+        }
+        
+        /*
+         *  Include non-localized files
+         */
+        if (bundle) {
+            includeJavascriptFiles(Timeline.urlPrefix, [ "bundle.js" ]);
+            includeCssFiles(Timeline.urlPrefix, [ "bundle.css" ]);
+        } else {
+            includeJavascriptFiles(Timeline.urlPrefix + "scripts/", javascriptFiles);
+            includeCssFiles(Timeline.urlPrefix + "styles/", cssFiles);
+        }
+        
+        /*
+         *  Include localized files
+         */
+        var loadLocale = [];
+        loadLocale[defaultServerLocale] = true;
+        
+        var tryExactLocale = function(locale) {
+            for (var l = 0; l < supportedLocales.length; l++) {
+                if (locale == supportedLocales[l]) {
+                    loadLocale[locale] = true;
+                    return true;
+                }
+            }
+            return false;
+        }
+        var tryLocale = function(locale) {
+            if (tryExactLocale(locale)) {
+                return locale;
+            }
+            
+            var dash = locale.indexOf("-");
+            if (dash > 0 && tryExactLocale(locale.substr(0, dash))) {
+                return locale.substr(0, dash);
+            }
+            
+            return null;
+        }
+        
+        for (var l = 0; l < desiredLocales.length; l++) {
+            tryLocale(desiredLocales[l]);
+        }
+        
+        var defaultClientLocale = defaultServerLocale;
+        var defaultClientLocales = ("language" in navigator ? navigator.language : navigator.browserLanguage).split(";");
+        for (var l = 0; l < defaultClientLocales.length; l++) {
+            var locale = tryLocale(defaultClientLocales[l]);
+            if (locale != null) {
+                defaultClientLocale = locale;
+                break;
+            }
+        }
+        
+        for (var l = 0; l < supportedLocales.length; l++) {
+            var locale = supportedLocales[l];
+            if (loadLocale[locale]) {
+                includeJavascriptFiles(Timeline.urlPrefix + "scripts/l10n/" + locale + "/", localizedJavascriptFiles);
+                includeCssFiles(Timeline.urlPrefix + "styles/l10n/" + locale + "/", localizedCssFiles);
+            }
+        }
+        
+        Timeline.Platform.serverLocale = defaultServerLocale;
+        Timeline.Platform.clientLocale = defaultClientLocale;
+    } catch (e) {
+        alert(e);
+    }
+})();
\ No newline at end of file



Mime
View raw message