Compare commits

..

2 Commits

Author SHA1 Message Date
pavlov%pavlov.net
33a0a6fec0 update to use ns_quicksort so that this branch builds
git-svn-id: svn://10.0.0.236/branches/FAST-GTK-GFX@31772 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-15 21:56:51 +00:00
(no author)
58b1c92ba4 This commit was manufactured by cvs2svn to create branch 'FAST-GTK-GFX'.
git-svn-id: svn://10.0.0.236/branches/FAST-GTK-GFX@28588 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-22 00:07:41 +00:00
118 changed files with 15501 additions and 14381 deletions

View File

@@ -0,0 +1,53 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
LIBRARY_NAME = gfxgtk
MODULE=raptor
REQUIRES=util img xpcom raptor netlib ps
DEFINES += -D_IMPL_NS_GFXONXP
CXXFLAGS += $(TK_CFLAGS)
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
CPPSRCS = \
nsDrawingSurfaceGTK.cpp \
nsDeviceContextGTK.cpp \
nsDeviceContextSpecFactoryG.cpp \
nsDeviceContextSpecG.cpp \
nsFontMetricsGTK.cpp \
nsGfxFactoryGTK.cpp \
nsRenderingContextGTK.cpp \
nsImageGTK.cpp \
nsRegionGTK.cpp
CSRCS = \
nsPrintdGTK.c
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,375 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <math.h>
#include "nspr.h"
#include "il_util.h"
#include "nsDeviceContextGTK.h"
#include "nsGfxCIID.h"
#include "../ps/nsDeviceContextPS.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#define NS_TO_GDK_RGB(ns) (ns & 0xff) << 16 | (ns & 0xff00) | ((ns >> 16) & 0xff)
#define GDK_COLOR_TO_NS_RGB(c) \
((nscolor) NS_RGB(c.red, c.green, c.blue))
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
nsDeviceContextGTK::nsDeviceContextGTK()
{
NS_INIT_REFCNT();
mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0;
mDepth = 0 ;
mPaletteInfo.isPaletteDevice = PR_FALSE;
mPaletteInfo.sizePalette = 0;
mPaletteInfo.numReserved = 0;
mPaletteInfo.palette = NULL;
mNumCells = 0;
}
nsDeviceContextGTK::~nsDeviceContextGTK()
{
}
NS_IMPL_QUERY_INTERFACE(nsDeviceContextGTK, kDeviceContextIID)
NS_IMPL_ADDREF(nsDeviceContextGTK)
NS_IMPL_RELEASE(nsDeviceContextGTK)
NS_IMETHODIMP nsDeviceContextGTK::Init(nsNativeWidget aNativeWidget)
{
GdkVisual *vis;
GtkRequisition req;
GtkWidget *sb;
mWidget = aNativeWidget;
// Compute dpi of display
float screenWidth = float(::gdk_screen_width());
float screenWidthIn = float(::gdk_screen_width_mm()) / 25.4f;
nscoord dpi = nscoord(screenWidth / screenWidthIn);
// Now for some wacky heuristics.
if (dpi < 84) dpi = 72;
else if (dpi < 108) dpi = 96;
else if (dpi < 132) dpi = 120;
mTwipsToPixels = float(dpi) / float(NSIntPointsToTwips(72));
mPixelsToTwips = 1.0f / mTwipsToPixels;
#if 0
mTwipsToPixels = ( ((float)::gdk_screen_width()) /
((float)::gdk_screen_width_mm()) * 25.4) /
(float)NSIntPointsToTwips(72);
mPixelsToTwips = 1.0f / mTwipsToPixels;
#endif
vis = gdk_rgb_get_visual();
mDepth = vis->depth;
sb = gtk_vscrollbar_new(NULL);
gtk_widget_ref(sb);
gtk_object_sink(GTK_OBJECT(sb));
gtk_widget_size_request(sb,&req);
mScrollbarWidth = req.width;
gtk_widget_destroy(sb);
gtk_widget_unref(sb);
sb = gtk_hscrollbar_new(NULL);
gtk_widget_ref(sb);
gtk_object_sink(GTK_OBJECT(sb));
gtk_widget_size_request(sb,&req);
mScrollbarHeight = req.height;
gtk_widget_destroy(sb);
gtk_widget_unref(sb);
#ifdef DEBUG
static PRBool once = PR_TRUE;
if (once) {
printf("GFX: dpi=%d t2p=%g p2t=%g depth=%d\n", dpi, mTwipsToPixels, mPixelsToTwips,mDepth);
once = PR_FALSE;
}
#endif
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::CreateRenderingContext(nsIRenderingContext *&aContext)
{
nsIRenderingContext *pContext;
nsresult rv;
nsDrawingSurfaceGTK *surf;
// to call init for this, we need to have a valid nsDrawingSurfaceGTK created
pContext = new nsRenderingContextGTK();
if (nsnull != pContext)
{
NS_ADDREF(pContext);
// create the nsDrawingSurfaceGTK
surf = new nsDrawingSurfaceGTK();
if (nsnull != surf)
{
GdkDrawable *win = nsnull;
// FIXME
if (GTK_IS_LAYOUT((GtkWidget*)mWidget))
win = (GdkDrawable*)gdk_window_ref(GTK_LAYOUT((GtkWidget*)mWidget)->bin_window);
else
win = (GdkDrawable*)gdk_window_ref(((GtkWidget*)mWidget)->window);
GdkGC *gc = gdk_gc_new(win);
// init the nsDrawingSurfaceGTK
rv = surf->Init(win,gc);
if (NS_OK == rv)
// Init the nsRenderingContextGTK
rv = pContext->Init(this, surf);
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
if (NS_OK != rv)
{
NS_IF_RELEASE(pContext);
}
aContext = pContext;
return rv;
}
NS_IMETHODIMP nsDeviceContextGTK::SupportsNativeWidgets(PRBool &aSupportsWidgets)
{
//XXX it is very critical that this not lie!! MMP
// read the comments in the mac code for this
aSupportsWidgets = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetScrollBarDimensions(float &aWidth, float &aHeight) const
{
aWidth = mScrollbarWidth * mPixelsToTwips;
aHeight = mScrollbarHeight * mPixelsToTwips;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) const
{
nsresult status = NS_OK;
GtkStyle *style = gtk_style_new(); // get the default styles
switch (anID) {
//---------
// Colors
//---------
case eSystemAttr_Color_WindowBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_WindowForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_WidgetBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_WidgetForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_WidgetSelectBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_SELECTED]);
break;
case eSystemAttr_Color_WidgetSelectForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_SELECTED]);
break;
case eSystemAttr_Color_Widget3DHighlight:
*aInfo->mColor = NS_RGB(0xa0,0xa0,0xa0);
break;
case eSystemAttr_Color_Widget3DShadow:
*aInfo->mColor = NS_RGB(0x40,0x40,0x40);
break;
case eSystemAttr_Color_TextBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_TextForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_TextSelectBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_SELECTED]);
break;
case eSystemAttr_Color_TextSelectForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->text[GTK_STATE_SELECTED]);
break;
//---------
// Size
//---------
case eSystemAttr_Size_ScrollbarHeight:
aInfo->mSize = mScrollbarHeight;
break;
case eSystemAttr_Size_ScrollbarWidth:
aInfo->mSize = mScrollbarWidth;
break;
case eSystemAttr_Size_WindowTitleHeight:
aInfo->mSize = 0;
break;
case eSystemAttr_Size_WindowBorderWidth:
aInfo->mSize = style->klass->xthickness;
break;
case eSystemAttr_Size_WindowBorderHeight:
aInfo->mSize = style->klass->ythickness;
break;
case eSystemAttr_Size_Widget3DBorder:
aInfo->mSize = 4;
break;
//---------
// Fonts
//---------
case eSystemAttr_Font_Caption:
case eSystemAttr_Font_Icon:
case eSystemAttr_Font_Menu:
case eSystemAttr_Font_MessageBox:
case eSystemAttr_Font_SmallCaption:
case eSystemAttr_Font_StatusBar:
case eSystemAttr_Font_Tooltips:
case eSystemAttr_Font_Widget:
status = NS_ERROR_FAILURE;
break;
} // switch
gtk_style_unref(style);
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDrawingSurface(nsIRenderingContext &aContext,
nsDrawingSurface &aSurface)
{
aContext.CreateDrawingSurface(nsnull, 0, aSurface);
return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::ConvertPixel(nscolor aColor,
PRUint32 & aPixel)
{
aPixel = ::gdk_rgb_xpixel_from_rgb (NS_TO_GDK_RGB(aColor));
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::CheckFontExistence(const nsString& aFontName)
{
char **fnames = nsnull;
PRInt32 namelen = aFontName.Length() + 1;
char *wildstring = (char *)PR_Malloc(namelen + 200);
float t2d;
GetTwipsToDevUnits(t2d);
PRInt32 dpi = NSToIntRound(t2d * 1440);
int numnames = 0;
XFontStruct *fonts;
nsresult rv = NS_ERROR_FAILURE;
if (nsnull == wildstring)
return NS_ERROR_UNEXPECTED;
if (abs(dpi - 75) < abs(dpi - 100))
dpi = 75;
else
dpi = 100;
char* fontName = aFontName.ToNewCString();
PR_snprintf(wildstring, namelen + 200,
"*-%s-*-*-normal--*-*-%d-%d-*-*-*",
fontName, dpi, dpi);
delete [] fontName;
fnames = ::XListFontsWithInfo(GDK_DISPLAY(), wildstring, 1, &numnames, &fonts);
if (numnames > 0)
{
::XFreeFontInfo(fnames, fonts, numnames);
rv = NS_OK;
}
PR_Free(wildstring);
return rv;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
{
aWidth = 1;
aHeight = 1;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext)
{
// Create a Postscript device context
aContext = new nsDeviceContextPS();
((nsDeviceContextPS *)aContext)->SetSpec(aDevice);
NS_ADDREF(aDevice);
return((nsDeviceContextPS *) aContext)->Init((nsIDeviceContext*)aContext, (nsIDeviceContext*)this);
}
NS_IMETHODIMP nsDeviceContextGTK::BeginDocument(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::EndDocument(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::BeginPage(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::EndPage(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDepth(PRUint32& aDepth)
{
GdkVisual * rgb_visual = gdk_rgb_get_visual();
gint rgb_depth = rgb_visual->depth;
aDepth = (PRUint32) rgb_depth;
return NS_OK;
}

View File

@@ -0,0 +1,79 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsDeviceContextGTK_h___
#define nsDeviceContextGTK_h___
#include "nsDeviceContext.h"
#include "nsUnitConversion.h"
#include "nsIWidget.h"
#include "nsIView.h"
#include "nsIRenderingContext.h"
#include "nsRenderingContextGTK.h"
class nsDeviceContextGTK : public DeviceContextImpl
{
public:
nsDeviceContextGTK();
virtual ~nsDeviceContextGTK();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsNativeWidget aNativeWidget);
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const;
NS_IMETHOD GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) const;
//get a low level drawing surface for rendering. the rendering context
//that is passed in is used to create the drawing surface if there isn't
//already one in the device context. the drawing surface is then cached
//in the device context for re-use.
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(void);
NS_IMETHOD EndDocument(void);
NS_IMETHOD BeginPage(void);
NS_IMETHOD EndPage(void);
NS_IMETHOD GetDepth(PRUint32& aDepth);
private:
PRUint32 mDepth;
PRBool mWriteable;
nsPaletteInfo mPaletteInfo;
PRUint32 mNumCells;
PRInt16 mScrollbarHeight;
PRInt16 mScrollbarWidth;
};
#endif /* nsDeviceContextGTK_h___ */

View File

@@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsDeviceContextSpecFactoryG.h"
#include "nsDeviceContextSpecG.h"
#include "nsGfxCIID.h"
#include "plstr.h"
/** -------------------------------------------------------
* Constructor
* @update dc 2/16/98
*/
nsDeviceContextSpecFactoryGTK :: nsDeviceContextSpecFactoryGTK()
{
}
/** -------------------------------------------------------
* Destructor
* @update dc 2/16/98
*/
nsDeviceContextSpecFactoryGTK :: ~nsDeviceContextSpecFactoryGTK()
{
}
static NS_DEFINE_IID(kDeviceContextSpecFactoryIID, NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID);
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
static NS_DEFINE_IID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecFactoryGTK, kDeviceContextSpecFactoryIID)
NS_IMPL_ADDREF(nsDeviceContextSpecFactoryGTK)
NS_IMPL_RELEASE(nsDeviceContextSpecFactoryGTK)
/** -------------------------------------------------------
* Initialize the device context spec factory
* @update dc 2/16/98
*/
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: Init(void)
{
return NS_OK;
}
/** -------------------------------------------------------
* Get a device context specification
* @update dc 2/16/98
*/
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: CreateDeviceContextSpec(nsIDeviceContextSpec *aOldSpec,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet)
{
nsresult rv = NS_ERROR_FAILURE;
nsIDeviceContextSpec *devSpec = nsnull;
nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec);
if (nsnull != devSpec){
if (NS_OK == ((nsDeviceContextSpecGTK *)devSpec)->Init(aQuiet)){
aNewSpec = devSpec;
rv = NS_OK;
}
}
return rv;
}

View File

@@ -0,0 +1,41 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsDeviceContextSpecFactoryG_h___
#define nsDeviceContextSpecFactoryG_h___
#include "nsIDeviceContextSpecFactory.h"
#include "nsIDeviceContextSpec.h"
class nsDeviceContextSpecFactoryGTK : public nsIDeviceContextSpecFactory
{
public:
nsDeviceContextSpecFactoryGTK();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(void);
NS_IMETHOD CreateDeviceContextSpec(nsIDeviceContextSpec *aOldSpec,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet);
protected:
virtual ~nsDeviceContextSpecFactoryGTK();
};
#endif

View File

@@ -0,0 +1,197 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsDeviceContextSpecG.h"
#include "prenv.h" /* for PR_GetEnv */
//#include "prmem.h"
//#include "plstr.h"
/** -------------------------------------------------------
* Construct the nsDeviceContextSpecGTK
* @update dc 12/02/98
*/
nsDeviceContextSpecGTK :: nsDeviceContextSpecGTK()
{
NS_INIT_REFCNT();
}
/** -------------------------------------------------------
* Destroy the nsDeviceContextSpecGTK
* @update dc 2/15/98
*/
nsDeviceContextSpecGTK :: ~nsDeviceContextSpecGTK()
{
}
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
static NS_DEFINE_IID(kIDeviceContextSpecPSIID, NS_IDEVICE_CONTEXT_SPEC_PS_IID);
#if 0
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecGTK, kDeviceContextSpecIID)
NS_IMPL_ADDREF(nsDeviceContextSpecGTK)
NS_IMPL_RELEASE(nsDeviceContextSpecGTK)
#endif
NS_IMETHODIMP nsDeviceContextSpecGTK :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(kIDeviceContextSpecIID))
{
nsIDeviceContextSpec* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDeviceContextSpecPSIID))
{
nsIDeviceContextSpecPS* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kISupportsIID))
{
nsIDeviceContextSpec* tmp = this;
nsISupports* tmp2 = tmp;
*aInstancePtr = (void*) tmp2;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsDeviceContextSpecGTK)
NS_IMPL_RELEASE(nsDeviceContextSpecGTK)
/** -------------------------------------------------------
* Initialize the nsDeviceContextSpecGTK
* @update dc 2/15/98
* @update syd 3/2/99
*/
NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
{
char *path;
// XXX these settings should eventually come out of preferences
mPrData.toPrinter = PR_TRUE;
mPrData.fpf = PR_TRUE;
mPrData.grayscale = PR_FALSE;
mPrData.size = NS_LETTER_SIZE;
sprintf( mPrData.command, "lpr" );
// PWD, HOME, or fail
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) NULL )
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) NULL )
strcpy( mPrData.path, "netscape.ps" );
if ( path != (char *) NULL )
sprintf( mPrData.path, "%s/netscape.ps", path );
else
return NS_ERROR_FAILURE;
::UnixPrDialog( &mPrData );
if ( mPrData.cancel == PR_TRUE )
return NS_ERROR_FAILURE;
else
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetToPrinter( PRBool &aToPrinter )
{
aToPrinter = mPrData.toPrinter;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetFirstPageFirst ( PRBool &aFpf )
{
aFpf = mPrData.fpf;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetGrayscale ( PRBool &aGrayscale )
{
aGrayscale = mPrData.grayscale;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetSize ( int &aSize )
{
aSize = mPrData.size;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetTopMargin ( float &value )
{
value = mPrData.top;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetBottomMargin ( float &value )
{
value = mPrData.bottom;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetRightMargin ( float &value )
{
value = mPrData.right;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetLeftMargin ( float &value )
{
value = mPrData.left;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetCommand ( char **aCommand )
{
*aCommand = &mPrData.command[0];
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetPath ( char **aPath )
{
*aPath = &mPrData.path[0];
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetUserCancelled( PRBool &aCancel )
{
aCancel = mPrData.cancel;
return NS_OK;
}
/** -------------------------------------------------------
* Closes the printmanager if it is open.
* @update dc 2/15/98
*/
NS_IMETHODIMP nsDeviceContextSpecGTK :: ClosePrintManager()
{
return NS_OK;
}

View File

@@ -0,0 +1,97 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsDeviceContextSpecG_h___
#define nsDeviceContextSpecG_h___
#include "nsIDeviceContextSpec.h"
#include "nsDeviceContextSpecG.h"
#include "nsIDeviceContextSpecPS.h"
#include "nsPrintdGTK.h"
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec ,
public nsIDeviceContextSpecPS
{
public:
/**
* Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord
* @update dc 12/02/98
*/
nsDeviceContextSpecGTK();
NS_DECL_ISUPPORTS
/**
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
* @update dc 2/16/98
* @param aQuiet if PR_TRUE, prevent the need for user intervention
* in obtaining device context spec. if nsnull is passed in for
* the aOldSpec, this will typically result in getting a device
* context spec for the default output device (i.e. default
* printer).
* @return error status
*/
NS_IMETHOD Init(PRBool aQuiet);
/**
* Closes the printmanager if it is open.
* @update dc 2/13/98
* @update syd 3/20/99
* @return error status
*/
NS_IMETHOD ClosePrintManager();
NS_IMETHOD GetToPrinter( PRBool &aToPrinter );
NS_IMETHOD GetFirstPageFirst ( PRBool &aFpf );
NS_IMETHOD GetGrayscale( PRBool &aGrayscale );
NS_IMETHOD GetSize ( int &aSize );
NS_IMETHOD GetTopMargin ( float &value );
NS_IMETHOD GetBottomMargin ( float &value );
NS_IMETHOD GetLeftMargin ( float &value );
NS_IMETHOD GetRightMargin ( float &value );
NS_IMETHOD GetCommand ( char **aCommand );
NS_IMETHOD GetPath ( char **aPath );
NS_IMETHOD GetUserCancelled( PRBool &aCancel );
protected:
/**
* Destuct a nsDeviceContextSpecMac, this will release the printrecord
* @update dc 2/16/98
*/
virtual ~nsDeviceContextSpecGTK();
protected:
UnixPrData mPrData;
};
#endif

View File

@@ -0,0 +1,367 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#if defined (HAVE_IPC_H) && defined (HAVE_SHM_H) && defined (HAVE_XSHM_H)
#define USE_SHM
#endif
//#define USE_SHM
#include <gdk/gdkx.h>
#include <gdk/gdkprivate.h>
#ifdef USE_SHM
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/extensions/XShm.h>
#endif /* USE_SHM */
#include "nsDrawingSurfaceGTK.h"
static NS_DEFINE_IID(kIDrawingSurfaceIID, NS_IDRAWING_SURFACE_IID);
static NS_DEFINE_IID(kIDrawingSurfaceGTKIID, NS_IDRAWING_SURFACE_GTK_IID);
nsDrawingSurfaceGTK :: nsDrawingSurfaceGTK()
{
NS_INIT_REFCNT();
GdkVisual *v;
mPixmap = nsnull;
mGC = nsnull;
mDepth = 0;
mWidth = mHeight = 0;
mFlags = 0;
mImage = nsnull;
mLockWidth = mLockHeight = 0;
mLockFlags = 0;
mLocked = PR_FALSE;
v = ::gdk_rgb_get_visual();
mPixFormat.mRedMask = v->red_mask;
mPixFormat.mGreenMask = v->green_mask;
mPixFormat.mBlueMask = v->blue_mask;
// FIXME
mPixFormat.mAlphaMask = 0;
mPixFormat.mRedShift = v->red_shift;
mPixFormat.mGreenShift = v->green_shift;
mPixFormat.mBlueShift = v->blue_shift;
// FIXME
mPixFormat.mAlphaShift = 0;
mDepth = v->depth;
}
nsDrawingSurfaceGTK :: ~nsDrawingSurfaceGTK()
{
if (mPixmap)
::gdk_pixmap_unref(mPixmap);
if (mImage)
::gdk_image_destroy(mImage);
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(kIDrawingSurfaceIID))
{
nsIDrawingSurface* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDrawingSurfaceGTKIID))
{
nsDrawingSurfaceGTK* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kISupportsIID))
{
nsIDrawingSurface* tmp = this;
nsISupports* tmp2 = tmp;
*aInstancePtr = (void*) tmp2;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsDrawingSurfaceGTK);
NS_IMPL_RELEASE(nsDrawingSurfaceGTK);
/**
* Lock a rect of a drawing surface and return a
* pointer to the upper left hand corner of the
* bitmap.
* @param aX x position of subrect of bitmap
* @param aY y position of subrect of bitmap
* @param aWidth width of subrect of bitmap
* @param aHeight height of subrect of bitmap
* @param aBits out parameter for upper left hand
* corner of bitmap
* @param aStride out parameter for number of bytes
* to add to aBits to go from scanline to scanline
* @param aWidthBytes out parameter for number of
* bytes per line in aBits to process aWidth pixels
* @return error status
*
**/
NS_IMETHODIMP nsDrawingSurfaceGTK :: Lock(PRInt32 aX, PRInt32 aY,
PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride,
PRInt32 *aWidthBytes, PRUint32 aFlags)
{
#if 0
g_print("nsDrawingSurfaceGTK::Lock() called\n" \
" aX = %i, aY = %i,\n" \
" aWidth = %i, aHeight = %i,\n" \
" aBits, aStride, aWidthBytes,\n" \
" aFlags = %i\n", aX, aY, aWidth, aHeight, aFlags);
#endif
if (mLocked)
{
NS_ASSERTION(0, "nested lock attempt");
return NS_ERROR_FAILURE;
}
mLocked = PR_TRUE;
mLockX = aX;
mLockY = aY;
mLockWidth = aWidth;
mLockHeight = aHeight;
mLockFlags = aFlags;
// Obtain an ximage from the pixmap.
#ifdef USE_SHM
if (gdk_get_use_xshm())
{
mImage = gdk_image_new(GDK_IMAGE_FASTEST,
gdk_rgb_get_visual(),
mLockWidth,
mLockHeight);
XShmGetImage(GDK_DISPLAY(),
GDK_WINDOW_XWINDOW(mPixmap),
GDK_IMAGE_XIMAGE(mImage),
mLockX, mLockY,
0xFFFFFFFF);
gdk_flush();
}
else
{
#endif /* USE_SHM */
mImage = ::gdk_image_get(mPixmap, mLockX, mLockY, mLockWidth, mLockHeight);
#ifdef USE_SHM
}
#endif /* USE_SHM */
*aBits = GDK_IMAGE_XIMAGE(mImage)->data;
*aWidthBytes = GDK_IMAGE_XIMAGE(mImage)->bytes_per_line;
*aStride = GDK_IMAGE_XIMAGE(mImage)->bytes_per_line;
#if 0
int bytes_per_line = GDK_IMAGE_XIMAGE(mImage)->bytes_per_line;
//
// All this code is a an attempt to set the stride width properly.
// Needs to be cleaned up alot. For now, it will only work in the
// case where aWidthBytes and aStride are the same. One is assigned to
// the other.
//
*aWidthBytes = mImage->bpl;
*aStride = mImage->bpl;
int width_in_pixels = *aWidthBytes << 8;
int bitmap_pad = GDK_IMAGE_XIMAGE(mImage)->bitmap_pad;
int depth = GDK_IMAGE_XIMAGE(mImage)->depth;
#define RASWIDTH8(width, bpp) (width)
#define RASWIDTH16(width, bpp) ((((width) * (bpp) + 15) >> 4) << 1)
#define RASWIDTH32(width, bpp) ((((width) * (bpp) + 31) >> 5) << 2)
switch(bitmap_pad)
{
case 8:
*aStride = RASWIDTH8(aWidth,bitmap_pad);
break;
case 16:
*aStride = bytes_per_line;
*aStride = RASWIDTH16(aWidth,bitmap_pad);
break;
case 32:
*aStride = bytes_per_line;
*aStride = RASWIDTH32(aWidth,bitmap_pad);
break;
default:
NS_ASSERTION(nsnull,"something got screwed");
}
*aStride = (*aWidthBytes) + ((bitmap_pad >> 3) - 1);
GDK_IMAGE_XIMAGE(mImage)->bitmap_pad;
*aWidthBytes = mImage->bpl;
#endif
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: Unlock(void)
{
// g_print("nsDrawingSurfaceGTK::UnLock() called\n");
if (!mLocked)
{
NS_ASSERTION(0, "attempting to unlock an DS that isn't locked");
return NS_ERROR_FAILURE;
}
// If the lock was not read only, put the bits back on the pixmap
if (!(mLockFlags & NS_LOCK_SURFACE_READ_ONLY))
{
#if 0
g_print("gdk_draw_image(pixmap=%p,lockx=%d,locky=%d,lockw=%d,lockh=%d)\n",
mPixmap,
mLockX, mLockY,
mLockWidth, mLockHeight);
#endif
gdk_draw_image(mPixmap,
mGC,
mImage,
0, 0,
mLockX, mLockY,
mLockWidth, mLockHeight);
}
// FIXME if we are using shared mem, we shouldn't destroy the image...
if (mImage)
::gdk_image_destroy(mImage);
mImage = nsnull;
mLocked = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight)
{
*aWidth = mWidth;
*aHeight = mHeight;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: IsOffscreen(PRBool *aOffScreen)
{
*aOffScreen = mIsOffscreen;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: IsPixelAddressable(PRBool *aAddressable)
{
// FIXME
*aAddressable = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: GetPixelFormat(nsPixelFormat *aFormat)
{
*aFormat = mPixFormat;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: Init(GdkDrawable *aDrawable, GdkGC *aGC)
{
mGC = aGC;
mPixmap = aDrawable;
// this is definatly going to be on the screen, as it will be the window of a
// widget or something.
mIsOffscreen = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: Init(GdkGC *aGC, PRUint32 aWidth,
PRUint32 aHeight, PRUint32 aFlags)
{
// ::g_return_val_if_fail (aGC != nsnull, NS_ERROR_FAILURE);
// ::g_return_val_if_fail ((aWidth > 0) && (aHeight > 0), NS_ERROR_FAILURE);
mGC = aGC;
mWidth = aWidth;
mHeight = aHeight;
mFlags = aFlags;
// we can draw on this offscreen because it has no parent
mIsOffscreen = PR_TRUE;
mPixmap = ::gdk_pixmap_new(nsnull, mWidth, mHeight, mDepth);
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: GetGC(GdkGC *aGC)
{
aGC = ::gdk_gc_ref(mGC);
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: ReleaseGC(void)
{
::gdk_gc_unref(mGC);
return NS_OK;
}
/* below are utility functions used mostly for nsRenderingContext and nsImage
* to plug into gdk_* functions for drawing. You should not set a pointer
* that might hang around with the return from these. instead use the ones
* above. pav
*/
GdkGC *nsDrawingSurfaceGTK::GetGC(void)
{
return mGC;
}
GdkDrawable *nsDrawingSurfaceGTK::GetDrawable(void)
{
return mPixmap;
}

View File

@@ -0,0 +1,85 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsDrawingSurfaceGTK_h___
#define nsDrawingSurfaceGTK_h___
#include "nsIDrawingSurface.h"
#include "nsIDrawingSurfaceGTK.h"
#include <gtk/gtk.h>
class nsDrawingSurfaceGTK : public nsIDrawingSurface,
public nsIDrawingSurfaceGTK
{
public:
nsDrawingSurfaceGTK();
virtual ~nsDrawingSurfaceGTK();
NS_DECL_ISUPPORTS
//nsIDrawingSurface interface
NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD Unlock(void);
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight);
NS_IMETHOD IsOffscreen(PRBool *aOffScreen);
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable);
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat);
//nsIDrawingSurfaceGTK interface
NS_IMETHOD Init(GdkDrawable *aDrawable, GdkGC *aGC);
NS_IMETHOD Init(GdkGC *aGC, PRUint32 aWidth, PRUint32 aHeight, PRUint32 aFlags);
/* get the GC and manage the GdkGC's refcount */
NS_IMETHOD GetGC(GdkGC *aGC);
NS_IMETHOD ReleaseGC(void);
/* below are utility functions used mostly for nsRenderingContext and nsImage
* to plug into gdk_* functions for drawing. You should not set a pointer
* that might hang around with the return from these. instead use the ones
* above. pav
*/
GdkGC *GetGC(void);
GdkDrawable *GetDrawable(void);
private:
/* general */
GdkPixmap *mPixmap;
GdkGC *mGC;
gint mDepth;
nsPixelFormat mPixFormat;
PRUint32 mWidth;
PRUint32 mHeight;
PRUint32 mFlags;
PRBool mIsOffscreen;
/* for locks */
GdkImage *mImage;
PRInt32 mLockX;
PRInt32 mLockY;
PRUint32 mLockWidth;
PRUint32 mLockHeight;
PRUint32 mLockFlags;
PRBool mLocked;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,162 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsFontMetricsGTK_h__
#define nsFontMetricsGTK_h__
#include "nsIFontMetrics.h"
#include "nsFont.h"
#include "nsString.h"
#include "nsUnitConversion.h"
#include "nsIDeviceContext.h"
#include "nsCRT.h"
#include "nsDeviceContextGTK.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#define FONT_SWITCHING
#ifdef FONT_SWITCHING
#ifdef ADD_GLYPH
#undef ADD_GLYPH
#endif
#define ADD_GLYPH(map, g) (map)[(g) >> 3] |= (1 << ((g) & 7))
#ifdef FONT_HAS_GLYPH
#undef FONT_HAS_GLYPH
#endif
#define FONT_HAS_GLYPH(map, g) (((map)[(g) >> 3] >> ((g) & 7)) & 1)
typedef struct nsFontCharSetInfo nsFontCharSetInfo;
typedef gint (*nsFontCharSetConverter)(nsFontCharSetInfo* aSelf,
const PRUnichar* aSrcBuf, PRUint32 aSrcLen, PRUint8* aDestBuf,
PRUint32 aDestLen);
struct nsFontCharSet;
class nsFontMetricsGTK;
struct nsFontGTK
{
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void LoadFont(nsFontCharSet* aCharSet, nsFontMetricsGTK* aMetrics);
GdkFont* mFont;
PRUint8* mMap;
nsFontCharSetInfo* mCharSetInfo;
char* mName;
PRUint16 mSize;
PRUint16 mActualSize;
PRInt16 mBaselineAdjust;
};
struct nsFontStretch;
struct nsFontFamily;
typedef struct nsFontSearch nsFontSearch;
#endif /* FONT_SWITCHING */
class nsFontMetricsGTK : public nsIFontMetrics
{
public:
nsFontMetricsGTK();
virtual ~nsFontMetricsGTK();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_IMETHOD Init(const nsFont& aFont, nsIDeviceContext* aContext);
NS_IMETHOD Destroy();
NS_IMETHOD GetXHeight(nscoord& aResult);
NS_IMETHOD GetSuperscriptOffset(nscoord& aResult);
NS_IMETHOD GetSubscriptOffset(nscoord& aResult);
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetHeight(nscoord &aHeight);
NS_IMETHOD GetLeading(nscoord &aLeading);
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
#ifdef FONT_SWITCHING
nsFontGTK* FindFont(PRUnichar aChar);
static gint GetWidth(nsFontGTK* aFont, const PRUnichar* aString,
PRUint32 aLength);
static void DrawString(nsDrawingSurfaceGTK* aSurface, nsFontGTK* aFont,
nscoord aX, nscoord aY, const PRUnichar* aString,
PRUint32 aLength);
static void InitFonts(void);
friend void PickASizeAndLoad(nsFontSearch* aSearch, nsFontStretch* aStretch,
nsFontCharSet* aCharSet);
friend void TryCharSet(nsFontSearch* aSearch, nsFontCharSet* aCharSet);
friend void TryFamily(nsFontSearch* aSearch, nsFontFamily* aFamily);
friend struct nsFontGTK;
nsFontGTK **mLoadedFonts;
PRUint16 mLoadedFontsAlloc;
PRUint16 mLoadedFontsCount;
nsString *mFonts;
PRUint16 mFontsAlloc;
PRUint16 mFontsCount;
PRUint16 mFontsIndex;
#endif /* FONT_SWITCHING */
protected:
char *PickAppropriateSize(char **names, XFontStruct *fonts, int cnt, nscoord desired);
void RealizeFont();
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
GdkFont *mFontHandle;
nscoord mHeight;
nscoord mAscent;
nscoord mDescent;
nscoord mLeading;
nscoord mMaxAscent;
nscoord mMaxDescent;
nscoord mMaxAdvance;
nscoord mXHeight;
nscoord mSuperscriptOffset;
nscoord mSubscriptOffset;
nscoord mStrikeoutSize;
nscoord mStrikeoutOffset;
nscoord mUnderlineSize;
nscoord mUnderlineOffset;
#ifdef FONT_SWITCHING
PRUint16 mPixelSize;
PRUint8 mStretchIndex;
PRUint8 mStyleIndex;
#endif /* FONT_SWITCHING */
};
#endif

View File

@@ -0,0 +1,205 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <gtk/gtk.h>
#include "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "nsGfxCIID.h"
#include "nsFontMetricsGTK.h"
#include "nsRenderingContextGTK.h"
#include "nsImageGTK.h"
#include "nsDeviceContextGTK.h"
#include "nsRegionGTK.h"
#include "nsBlender.h"
#include "nsDeviceContextSpecG.h"
#include "nsDeviceContextSpecFactoryG.h"
#include "nsIDeviceContextSpecPS.h"
static NS_DEFINE_IID(kCFontMetrics, NS_FONT_METRICS_CID);
static NS_DEFINE_IID(kCRenderingContext, NS_RENDERING_CONTEXT_CID);
static NS_DEFINE_IID(kCImage, NS_IMAGE_CID);
static NS_DEFINE_IID(kCDeviceContext, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kCRegion, NS_REGION_CID);
static NS_DEFINE_IID(kCBlender, NS_BLENDER_CID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_IID(kCDeviceContextSpec, NS_DEVICE_CONTEXT_SPEC_CID);
static NS_DEFINE_IID(kCDeviceContextSpecFactory, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID);
class nsGfxFactoryGTK : public nsIFactory
{
public:
// nsISupports methods
NS_IMETHOD QueryInterface(const nsIID &aIID,
void **aResult);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
nsGfxFactoryGTK(const nsCID &aClass);
virtual ~nsGfxFactoryGTK();
private:
nsrefcnt mRefCnt;
nsCID mClassID;
};
nsGfxFactoryGTK::nsGfxFactoryGTK(const nsCID &aClass)
{
mRefCnt = 0;
mClassID = aClass;
}
nsGfxFactoryGTK::~nsGfxFactoryGTK()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsGfxFactoryGTK::QueryInterface(const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aResult = NULL;
if (aIID.Equals(kISupportsIID)) {
*aResult = (void *)(nsISupports*)this;
} else if (aIID.Equals(kIFactoryIID)) {
*aResult = (void *)(nsIFactory*)this;
}
if (*aResult == NULL) {
return NS_NOINTERFACE;
}
AddRef(); // Increase reference count for caller
return NS_OK;
}
nsrefcnt nsGfxFactoryGTK::AddRef()
{
return ++mRefCnt;
}
nsrefcnt nsGfxFactoryGTK::Release()
{
if (--mRefCnt == 0) {
delete this;
return 0; // Don't access mRefCnt after deleting!
}
return mRefCnt;
}
nsresult nsGfxFactoryGTK::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL;
nsISupports *inst = nsnull;
if (mClassID.Equals(kCFontMetrics)) {
inst = (nsISupports *)new nsFontMetricsGTK();
}
else if (mClassID.Equals(kCDeviceContext)) {
inst = (nsISupports *)new nsDeviceContextGTK();
}
else if (mClassID.Equals(kCRenderingContext)) {
inst = (nsISupports *)new nsRenderingContextGTK();
}
else if (mClassID.Equals(kCImage)) {
inst = (nsISupports *)new nsImageGTK();
}
else if (mClassID.Equals(kCRegion)) {
inst = (nsISupports *)new nsRegionGTK();
}
else if (mClassID.Equals(kCBlender)) {
inst = (nsISupports *)new nsBlender;
}
else if (mClassID.Equals(kCDeviceContextSpec)) {
nsDeviceContextSpecGTK* dcs;
NS_NEWXPCOM(dcs, nsDeviceContextSpecGTK);
inst = (nsISupports *)((nsIDeviceContextSpecPS *)dcs);
}
else if (mClassID.Equals(kCDeviceContextSpecFactory)) {
nsDeviceContextSpecFactoryGTK* dcs;
NS_NEWXPCOM(dcs, nsDeviceContextSpecFactoryGTK);
inst = (nsISupports *)dcs;
}
if (inst == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult res = inst->QueryInterface(aIID, aResult);
if (res != NS_OK) {
// We didn't get the right interface, so clean up
delete inst;
}
// else {
// inst->Release();
// }
return res;
}
nsresult nsGfxFactoryGTK::LockFactory(PRBool aLock)
{
// Not implemented in simplest case.
return NS_OK;
}
// return the proper factory to the caller
extern "C" NS_GFXNONXP nsresult NSGetFactory(nsISupports* servMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (nsnull == aFactory) {
return NS_ERROR_NULL_POINTER;
}
*aFactory = new nsGfxFactoryGTK(aClass);
if (nsnull == aFactory) {
return NS_ERROR_OUT_OF_MEMORY;
}
return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
}

View File

@@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIDrawingSurfaceGTK_h___
#define nsIDrawingSurfaceGTK_h___
#include "nsIDrawingSurface.h"
#include <gtk/gtk.h>
// windows specific drawing surface method set
#define NS_IDRAWING_SURFACE_GTK_IID \
{ 0x1ed958b0, 0xcab6, 0x11d2, \
{ 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
class nsIDrawingSurfaceGTK : public nsISupports
{
public:
/**
* Initialize a drawing surface using a windows DC.
* aDC is "owned" by the drawing surface until the drawing
* surface is destroyed.
* @param aDC HDC to initialize drawing surface with
* @return error status
**/
NS_IMETHOD Init(GdkDrawable *aDrawable, GdkGC *aGC) = 0;
/**
* Initialize an offscreen drawing surface using a
* windows DC. aDC is not "owned" by this drawing surface, instead
* it is used to create a drawing surface compatible
* with aDC. if width or height are less than zero, aDC will
* be created with no offscreen bitmap installed.
* @param aDC HDC to initialize drawing surface with
* @param aWidth width of drawing surface
* @param aHeight height of drawing surface
* @param aFlags flags used to control type of drawing
* surface created
* @return error status
**/
NS_IMETHOD Init(GdkGC *aGC, PRUint32 aWidth, PRUint32 aHeight,
PRUint32 aFlags) = 0;
/**
* Get a windows DC that represents the drawing surface.
* GetDC() must be paired with ReleaseDC(). Getting a DC
* and Lock()ing are mutually exclusive operations.
* @param aDC out parameter for HDC
* @return error status
**/
NS_IMETHOD GetGC(GdkGC *aGC) = 0;
/**
* Release a windows DC obtained by GetDC().
* ReleaseDC() must be preceded by a call to ReleaseDC().
* @return error status
**/
NS_IMETHOD ReleaseGC(void) = 0;
};
#endif // nsIDrawingSurfaceGTK_h___

View File

@@ -0,0 +1,515 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include "nsImageGTK.h"
#include "nsRenderingContextGTK.h"
#include "nspr.h"
#define IsFlagSet(a,b) (a & b)
#undef CHEAP_PERFORMANCE_MEASURMENT
// Defining this will trace the allocation of images. This includes
// ctor, dtor and update.
#undef TRACE_IMAGE_ALLOCATION
static NS_DEFINE_IID(kIImageIID, NS_IIMAGE_IID);
//------------------------------------------------------------
nsImageGTK::nsImageGTK()
{
NS_INIT_REFCNT();
mImageBits = nsnull;
mWidth = 0;
mHeight = 0;
mDepth = 0;
mAlphaBits = nsnull;
mAlphaPixmap = nsnull;
mImagePixmap = nsnull;
mGC = nsnull;
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::nsImageGTK(this=%p)\n",
this);
#endif
}
//------------------------------------------------------------
nsImageGTK::~nsImageGTK()
{
if(nsnull != mImageBits) {
delete[] (PRUint8*)mImageBits;
mImageBits = nsnull;
}
if (nsnull != mAlphaBits) {
delete[] (PRUint8*)mAlphaBits;
mAlphaBits = nsnull;
}
if (nsnull != mAlphaPixmap) {
gdk_pixmap_unref(mAlphaPixmap);
mAlphaPixmap = nsnull;
}
if (nsnull != mImagePixmap) {
gdk_pixmap_unref(mImagePixmap);
mImagePixmap = nsnull;
}
if (nsnull != mGC) {
gdk_gc_unref(mGC);
mGC = nsnull;
}
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::~nsImageGTK(this=%p)\n",
this);
#endif
}
NS_IMPL_ISUPPORTS(nsImageGTK, kIImageIID);
//------------------------------------------------------------
nsresult nsImageGTK::Init(PRInt32 aWidth, PRInt32 aHeight,
PRInt32 aDepth, nsMaskRequirements aMaskRequirements)
{
g_return_val_if_fail ((aWidth != 0) || (aHeight != 0), NS_ERROR_FAILURE);
if (nsnull != mImageBits) {
delete[] (PRUint8*)mImageBits;
mImageBits = nsnull;
}
if (nsnull != mAlphaBits) {
delete[] (PRUint8*)mAlphaBits;
mAlphaBits = nsnull;
}
if (nsnull != mAlphaPixmap) {
gdk_pixmap_unref(mAlphaPixmap);
mAlphaPixmap = nsnull;
}
if (nsnull != mImagePixmap) {
gdk_pixmap_unref(mImagePixmap);
mImagePixmap = nsnull;
}
if (24 == aDepth) {
mNumBytesPixel = 3;
} else {
NS_ASSERTION(PR_FALSE, "unexpected image depth");
return NS_ERROR_UNEXPECTED;
}
mImageUpdated = PR_TRUE;
mWidth = aWidth;
mHeight = aHeight;
mDepth = aDepth;
mIsTopToBottom = PR_TRUE;
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::Init(this=%p,%d,%d,%d,%d)\n",
this,
aWidth,
aHeight,
aDepth,
aMaskRequirements);
#endif
// create the memory for the image
ComputMetrics();
mImageBits = (PRUint8*) new PRUint8[mSizeImage];
switch(aMaskRequirements)
{
case nsMaskRequirements_kNoMask:
mAlphaBits = nsnull;
mAlphaWidth = 0;
mAlphaHeight = 0;
break;
case nsMaskRequirements_kNeeds1Bit:
mAlphaRowBytes = (aWidth + 7) / 8;
mAlphaDepth = 1;
// 32-bit align each row
mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3;
mAlphaBits = new PRUint8[mAlphaRowBytes * aHeight];
mAlphaWidth = aWidth;
mAlphaHeight = aHeight;
mAlphaPixmap = gdk_pixmap_new(nsnull, aWidth, aHeight,
mAlphaDepth);
break;
case nsMaskRequirements_kNeeds8Bit:
mAlphaBits = nsnull;
mAlphaWidth = 0;
mAlphaHeight = 0;
mAlphaDepth = 8;
g_print("TODO: want an 8bit mask for an image..\n");
mAlphaPixmap = gdk_pixmap_new(nsnull, aWidth, aHeight,
mAlphaDepth);
break;
}
mImagePixmap = gdk_pixmap_new(nsnull, aWidth, aHeight,
gdk_rgb_get_visual()->depth);
mGC = gdk_gc_new(mImagePixmap);
return NS_OK;
}
//------------------------------------------------------------
PRInt32 nsImageGTK::CalcBytesSpan(PRUint32 aWidth)
{
PRInt32 spanbytes;
spanbytes = (aWidth * mDepth) >> 5;
if (((PRUint32)aWidth * mDepth) & 0x1F)
spanbytes++;
spanbytes <<= 2;
return(spanbytes);
}
void nsImageGTK::ComputMetrics()
{
mRowBytes = CalcBytesSpan(mWidth);
mSizeImage = mRowBytes * mHeight;
}
PRInt32 nsImageGTK::GetHeight()
{
return mHeight;
}
PRInt32 nsImageGTK::GetWidth()
{
return mWidth;
}
PRUint8 *nsImageGTK::GetBits()
{
return mImageBits;
}
void *nsImageGTK::GetBitInfo()
{
return nsnull;
}
PRInt32 nsImageGTK::GetLineStride()
{
return mRowBytes;
}
nsColorMap *nsImageGTK::GetColorMap()
{
return nsnull;
}
PRBool nsImageGTK::IsOptimized()
{
return PR_TRUE;
}
PRUint8 *nsImageGTK::GetAlphaBits()
{
return mAlphaBits;
}
PRInt32 nsImageGTK::GetAlphaWidth()
{
return mAlphaWidth;
}
PRInt32 nsImageGTK::GetAlphaHeight()
{
return mAlphaHeight;
}
PRInt32 nsImageGTK::GetAlphaLineStride()
{
return mAlphaRowBytes;
}
nsIImage *nsImageGTK::DuplicateImage()
{
return nsnull;
}
void nsImageGTK::SetAlphaLevel(PRInt32 aAlphaLevel)
{
}
PRInt32 nsImageGTK::GetAlphaLevel()
{
return 0;
}
void nsImageGTK::MoveAlphaMask(PRInt32 aX, PRInt32 aY)
{
}
//------------------------------------------------------------
// set up the palette to the passed in color array, RGB only in this array
void nsImageGTK::ImageUpdated(nsIDeviceContext *aContext,
PRUint8 aFlags,
nsRect *aUpdateRect)
{
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::ImageUpdated(this=%p,%d)\n",
this,
aFlags);
#endif
if (IsFlagSet(nsImageUpdateFlags_kBitsChanged, aFlags)) {
mImageUpdated = PR_TRUE;
// FIXME do something with aUpdateRect
}
}
#ifdef CHEAP_PERFORMANCE_MEASURMENT
static PRTime gConvertTime, gStartTime, gPixmapTime, gEndTime;
#endif
// Draw the bitmap, this method has a source and destination coordinates
NS_IMETHODIMP
nsImageGTK::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
{
g_return_val_if_fail ((aSurface != nsnull), NS_ERROR_FAILURE);
nsDrawingSurfaceGTK *drawing = (nsDrawingSurfaceGTK*)aSurface;
if (mAlphaBits)
g_print("calling nsImageGTK::Draw() with alpha bits\n");
gdk_draw_rgb_image (drawing->GetDrawable(),
mGC,
aDX, aDY, aDWidth, aDHeight,
GDK_RGB_DITHER_MAX,
mImageBits + mRowBytes * aSY + 3 * aDX,
mRowBytes);
return NS_OK;
}
//------------------------------------------------------------
// Draw the bitmap, this draw just has destination coordinates
NS_IMETHODIMP
nsImageGTK::Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight)
{
g_return_val_if_fail ((aSurface != nsnull), NS_ERROR_FAILURE);
// XXX kipp: this is temporary code until we eliminate the
// width/height arguments from the draw method.
if ((aWidth != mWidth) || (aHeight != mHeight)) {
aWidth = mWidth;
aHeight = mHeight;
}
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::Draw(this=%p,x=%d,y=%d,width=%d,height=%d)\n",
this,
aX,
aY,
aWidth,
aHeight);
#endif
nsDrawingSurfaceGTK* drawing = (nsDrawingSurfaceGTK*) aSurface;
XImage *x_image = nsnull;
Pixmap pixmap = 0;
Display *dpy = nsnull;
Visual *visual = nsnull;
GC gc;
XGCValues gcv;
#ifdef CHEAP_PERFORMANCE_MEASURMENT
gStartTime = gPixmapTime = PR_Now();
#endif
// Create gc clip-mask on demand
if ((mAlphaBits) && (mImageUpdated == PR_TRUE))
{
/* get the X primitives */
dpy = GDK_WINDOW_XDISPLAY(mAlphaPixmap);
/* this is the depth of the pixmap that we are going to draw to.
It's always a bitmap. We're doing alpha here folks. */
visual = GDK_VISUAL_XVISUAL(gdk_rgb_get_visual());
// Make an image out of the alpha-bits created by the image library
x_image = XCreateImage(dpy, visual,
1, /* visual depth...1 for bitmaps */
XYPixmap,
0, /* x offset, XXX fix this */
(char *)mAlphaBits, /* cast away our sign. */
aWidth,
aHeight,
32,/* bitmap pad */
mAlphaRowBytes); /* bytes per line */
x_image->bits_per_pixel=1;
/* Image library always places pixels left-to-right MSB to LSB */
x_image->bitmap_bit_order = MSBFirst;
/* This definition doesn't depend on client byte ordering
because the image library ensures that the bytes in
bitmask data are arranged left to right on the screen,
low to high address in memory. */
x_image->byte_order = MSBFirst;
#if defined(IS_LITTLE_ENDIAN)
// no, it's still MSB XXX check on this!!
// x_image->byte_order = LSBFirst;
#elif defined (IS_BIG_ENDIAN)
x_image->byte_order = MSBFirst;
#else
#error ERROR! Endianness is unknown;
#endif
// Write into the pixemap that is underneath gdk's mAlphaPixmap
// the image we just created.
pixmap = GDK_WINDOW_XWINDOW(mAlphaPixmap);
memset(&gcv, 0, sizeof(XGCValues));
gcv.function = GXcopy;
gc = XCreateGC(dpy, pixmap, GCFunction, &gcv);
XPutImage(dpy, pixmap, gc, x_image, 0, 0, 0, 0,
aWidth, aHeight);
XFreeGC(dpy, gc);
// Now we are done with the temporary image
x_image->data = 0; /* Don't free the IL_Pixmap's bits. */
XDestroyImage(x_image);
#ifdef CHEAP_PERFORMANCE_MEASURMENT
gPixmapTime = PR_Now();
#endif
}
// Render unique image bits onto an off screen pixmap only once
// The image bits can change as a result of ImageUpdated() - for
// example: animated GIFs.
if (mImageUpdated == PR_TRUE)
{
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::Draw(this=%p) gdk_pixmap_new(nsnull,width=%d,height=%d,depth=%d)\n",
this,
aWidth,
aHeight,
mDepth);
#endif
gdk_gc_set_clip_origin(mGC, 0, 0);
gdk_gc_set_clip_mask(mGC, nsnull);
// Render the image bits into an off screen pixmap
gdk_draw_rgb_image (mImagePixmap,
mGC,
0, 0, aWidth, aHeight,
GDK_RGB_DITHER_MAX,
mImageBits, mRowBytes);
if (mAlphaPixmap)
{
// Setup gc to use the given alpha-pixmap for clipping
gdk_gc_set_clip_mask(mGC, mAlphaPixmap);
gdk_gc_set_clip_origin(mGC, aX, aY);
}
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::Draw(this=%p) gdk_draw_pixmap(x=%d,y=%d,width=%d,height=%d)\n",
this,
aX,
aY,
aWidth,
aHeight);
#endif
mImageUpdated = PR_FALSE;
}
// copy our offscreen pixmap onto the window.
gdk_window_copy_area(drawing->GetDrawable(), // dest window
mGC, // gc
aX, // xsrc
aY, // ysrc
mImagePixmap, // source window
0, // xdest
0, // ydest
aWidth, // width
aHeight); // height
if (mAlphaBits)
{
// Revert gc to its old clip-mask and origin
gdk_gc_set_clip_origin(mGC, 0, 0);
gdk_gc_set_clip_mask(mGC, nsnull);
}
#ifdef CHEAP_PERFORMANCE_MEASURMENT
gEndTime = PR_Now();
printf("nsImageGTK::Draw(this=%p,w=%d,h=%d) total=%lld pixmap=%lld, cvt=%lld\n",
this,
aWidth, aHeight,
gEndTime - gStartTime,
gPixmapTime - gStartTime,
gConvertTime - gPixmapTime);
#endif
mImageUpdated = PR_FALSE;
return NS_OK;
}
//------------------------------------------------------------
nsresult nsImageGTK::Optimize(nsIDeviceContext* aContext)
{
return NS_OK;
}

View File

@@ -0,0 +1,115 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsImageGTK_h___
#define nsImageGTK_h___
#include "nsIImage.h"
#include "X11/Xlib.h"
#include "X11/Xutil.h"
#include <gdk/gdk.h>
#undef Bool
class nsImageGTK : public nsIImage
{
public:
nsImageGTK();
virtual ~nsImageGTK();
NS_DECL_ISUPPORTS
/**
@see nsIImage.h
*/
virtual PRInt32 GetBytesPix() { return mNumBytesPixel; }
virtual PRInt32 GetHeight();
virtual PRInt32 GetWidth();
virtual PRUint8* GetBits();
virtual void* GetBitInfo();
virtual PRBool GetIsRowOrderTopToBottom() { return mIsTopToBottom; }
virtual PRInt32 GetLineStride();
virtual nsColorMap* GetColorMap();
NS_IMETHOD Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
virtual void ImageUpdated(nsIDeviceContext *aContext,
PRUint8 aFlags, nsRect *aUpdateRect);
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight,
PRInt32 aDepth,
nsMaskRequirements aMaskRequirements);
virtual PRBool IsOptimized();
virtual nsresult Optimize(nsIDeviceContext* aContext);
virtual PRUint8* GetAlphaBits();
virtual PRInt32 GetAlphaWidth();
virtual PRInt32 GetAlphaHeight();
virtual PRInt32 GetAlphaLineStride();
virtual nsIImage* DuplicateImage();
/**
* Calculate the number of bytes spaned for this image for a given width
* @param aWidth is the width to calculate the number of bytes for
* @return the number of bytes in this span
*/
PRInt32 CalcBytesSpan(PRUint32 aWidth);
virtual void SetAlphaLevel(PRInt32 aAlphaLevel);
virtual PRInt32 GetAlphaLevel();
virtual void MoveAlphaMask(PRInt32 aX, PRInt32 aY);
private:
/**
* Calculate the amount of memory needed for the initialization of the image
*/
void ComputMetrics();
void ComputePaletteSize(PRIntn nBitCount);
private:
PRInt32 mWidth;
PRInt32 mHeight;
PRInt32 mDepth; // bits per pixel
PRInt32 mRowBytes;
PRUint8 *mImageBits;
PRUint8 *mConvertedBits;
PRInt32 mSizeImage;
PRBool mIsTopToBottom;
PRBool mImageUpdated;
PRInt8 mNumBytesPixel;
// alpha layer members
PRUint8 *mAlphaBits;
GdkPixmap *mAlphaPixmap;
PRInt8 mAlphaDepth; // alpha layer depth
PRInt16 mAlphaRowBytes; // alpha bytes per row
PRInt16 mAlphaWidth; // alpha layer width
PRInt16 mAlphaHeight; // alpha layer height
nsPoint mLocation; // alpha mask location
GdkPixmap *mImagePixmap;
GdkGC *mGC;
};
#endif

View File

@@ -0,0 +1,452 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* Original Code: Syd Logan (syd@netscape.com) 3/12/99 */
#include <gtk/gtk.h>
#include "nspr.h"
#include "nsPrintdGTK.h"
/* A structure to hold widgets that need to be referenced in callbacks. We
declare this statically in the caller entry point (as a field of
UnixPrOps, below), and pass a pointer to the structure to Gtk+ for each
signal handler registered. This avoids use of globals. */
typedef struct prwidgets {
GtkWidget *toplevel; /* should be set to toplevel window */
GtkWidget *prDialog;
GtkWidget *cmdEntry;
GtkWidget *pathEntry;
GtkWidget *browseButton;
GtkWidget *fpfToggle;
GtkWidget *greyToggle;
GtkWidget *letterToggle;
GtkWidget *legalToggle;
GtkWidget *execToggle;
GtkWidget *topSpinner;
GtkWidget *bottomSpinner;
GtkWidget *leftSpinner;
GtkWidget *rightSpinner;
GtkFileSelection *fsWidget;
} PrWidgets;
typedef struct unixprops {
UnixPrData *prData; /* pointer to caller struct */
PrWidgets widgets;
} UnixPrOps;
/* user clicked cancel. tear things down, and set cancel field in
caller data to PR_TRUE so printing will not happen */
static void
CancelPrint (GtkWidget *widget, UnixPrOps *prOps)
{
gtk_main_quit();
gtk_widget_destroy( GTK_WIDGET(prOps->widgets.prDialog) );
prOps->prData->cancel = PR_TRUE;
}
/* user selected the Print button. Collect any remaining data from the
widgets, and set cancel field in caller data to PR_FALSE so printing
will be performed. Also, tear down dialog and exit inner main loop */
static void
DoPrint (GtkWidget *widget, UnixPrOps *prOps)
{
strcpy( prOps->prData->command,
gtk_entry_get_text( GTK_ENTRY( prOps->widgets.cmdEntry ) ) );
strcpy( prOps->prData->path,
gtk_entry_get_text( GTK_ENTRY( prOps->widgets.pathEntry ) ) );
if ( GTK_TOGGLE_BUTTON( prOps->widgets.fpfToggle )->active == PR_TRUE )
prOps->prData->fpf = PR_TRUE;
else
prOps->prData->fpf = PR_FALSE;
if ( GTK_TOGGLE_BUTTON( prOps->widgets.greyToggle )->active == PR_TRUE )
prOps->prData->grayscale = PR_TRUE;
else
prOps->prData->grayscale = PR_FALSE;
if ( GTK_TOGGLE_BUTTON( prOps->widgets.letterToggle )->active == PR_TRUE )
prOps->prData->size = NS_LETTER_SIZE;
else if ( GTK_TOGGLE_BUTTON( prOps->widgets.legalToggle )->active == PR_TRUE )
prOps->prData->size = NS_LEGAL_SIZE;
else if ( GTK_TOGGLE_BUTTON( prOps->widgets.execToggle )->active == PR_TRUE )
prOps->prData->size = NS_EXECUTIVE_SIZE;
else
prOps->prData->size = NS_A4_SIZE;
/* margins */
prOps->prData->top = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.topSpinner) );
prOps->prData->bottom = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.bottomSpinner) );
prOps->prData->left = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.leftSpinner) );
prOps->prData->right = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.rightSpinner) );
/* we got everything... bring down the dialog and tell caller
it's o.k. to print */
gtk_main_quit();
gtk_widget_destroy( GTK_WIDGET(prOps->widgets.prDialog) );
prOps->prData->cancel = PR_FALSE;
}
/* User hit ok in file selection widget brought up by the browse button.
snarf the selected file, stuff it in caller data */
static void
ModifyPrPath (GtkWidget *widget, UnixPrOps *prOps)
{
strcpy( prOps->prData->path,
gtk_file_selection_get_filename(prOps->widgets.fsWidget) );
gtk_entry_set_text (GTK_ENTRY (prOps->widgets.pathEntry),
prOps->prData->path);
gtk_widget_destroy( GTK_WIDGET(prOps->widgets.fsWidget) );
}
/* user selected print to printer. de-sensitize print to file fields */
static void
SwitchToPrinter (GtkWidget *widget, UnixPrOps *prOps)
{
gtk_widget_set_sensitive( prOps->widgets.cmdEntry, PR_TRUE );
gtk_widget_set_sensitive( prOps->widgets.pathEntry, PR_FALSE );
gtk_widget_set_sensitive( prOps->widgets.browseButton, PR_FALSE );
prOps->prData->toPrinter = PR_TRUE;
}
/* user selected print to file. de-sensitize print to printer fields */
static void
SwitchToFile (GtkWidget *widget, UnixPrOps *prOps)
{
gtk_widget_set_sensitive( prOps->widgets.cmdEntry, PR_FALSE );
gtk_widget_set_sensitive( prOps->widgets.pathEntry, PR_TRUE );
gtk_widget_set_sensitive( prOps->widgets.browseButton, PR_TRUE );
prOps->prData->toPrinter = PR_FALSE;
}
/* user hit the browse button. Pop up a file selection widget and grab
result */
static void
GetPrPath (GtkWidget *widget, UnixPrOps *prOps)
{
GtkWidget *fs;
fs = gtk_file_selection_new("Netscape: File Browser");
gtk_file_selection_set_filename( GTK_FILE_SELECTION(fs),
prOps->prData->path );
gtk_window_set_modal (GTK_WINDOW(fs),PR_TRUE);
#if 0
/* XXX not sure what the toplevel window should be. */
gtk_window_set_transient_for (GTK_WINDOW (fs),
GTK_WINDOW (prOps->widgets.toplevel));
#endif
prOps->widgets.fsWidget = GTK_FILE_SELECTION(fs);
gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
"clicked", GTK_SIGNAL_FUNC(ModifyPrPath), prOps);
gtk_signal_connect_object (GTK_OBJECT(
GTK_FILE_SELECTION(fs)->cancel_button), "clicked",
GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT (fs));
gtk_widget_show(fs);
}
/* create file data dialog. XXX widget should be NULL */
static void
DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
{
GtkWidget *separator, *dialog, *label, *vbox, *entry, *hbox,
*button, *fileButton, *prButton, *table, *spinner1;
GtkAdjustment *adj;
prOps->widgets.prDialog = dialog =
gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_window_set_modal( GTK_WINDOW(dialog), PR_TRUE );
#if 0
/* not yet sure what the toplevel window should be */
gtk_window_set_transient_for (GTK_WINDOW (dialog),
GTK_WINDOW (prOps->widgets.toplevel));
#endif
gtk_window_set_title( GTK_WINDOW(dialog), "Netscape: Print" );
vbox = gtk_vbox_new (PR_FALSE, 0);
gtk_container_add (GTK_CONTAINER (dialog), vbox);
table = gtk_table_new (3, 3, PR_FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_TRUE, 5);
label = gtk_label_new( "Print To:" );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
0, GTK_EXPAND | GTK_FILL, 0, 0);
button = prButton = gtk_radio_button_new_with_label (NULL, "Printer");
if ( prOps->prData->toPrinter == PR_TRUE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = fileButton = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)), "File");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
if ( prOps->prData->toPrinter == PR_FALSE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
label = gtk_label_new( "Print Command:" );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
0, GTK_EXPAND | GTK_FILL, 0, 0);
entry = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (entry), prOps->prData->command);
gtk_table_attach (GTK_TABLE (table), entry, 1, 3, 1, 2,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
if ( prOps->prData->toPrinter == PR_FALSE )
gtk_widget_set_sensitive( entry, PR_FALSE );
prOps->widgets.cmdEntry = entry;
label = gtk_label_new( "File Name:" );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
0, GTK_EXPAND | GTK_FILL, 0, 0);
entry = gtk_entry_new ();
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_entry_set_text (GTK_ENTRY (entry), prOps->prData->path);
if ( prOps->prData->toPrinter == PR_TRUE )
gtk_widget_set_sensitive( entry, PR_FALSE );
prOps->widgets.pathEntry = entry;
button = gtk_button_new_with_label ("Browse...");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (GetPrPath), prOps);
if ( prOps->prData->toPrinter == PR_TRUE )
gtk_widget_set_sensitive( entry, PR_FALSE );
prOps->widgets.browseButton = button;
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
table = gtk_table_new (2, 4, PR_FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_FALSE, 0);
label = gtk_label_new( "Print: " );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (NULL, "First Page First");
if ( prOps->prData->fpf == PR_TRUE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
prOps->widgets.fpfToggle = button;
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Last Page First");
if ( prOps->prData->fpf == PR_FALSE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Print: " );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (NULL, "Greyscale");
prOps->widgets.greyToggle = button;
if ( prOps->prData->grayscale == PR_TRUE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Color");
if ( prOps->prData->grayscale == PR_FALSE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Paper Size: " );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (NULL,
"Letter (8 1/2 x 11 in.)");
prOps->widgets.letterToggle = button;
if ( prOps->prData->size == NS_LETTER_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 3, 4,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Legal (8 1/2 x 14 in.)");
prOps->widgets.legalToggle = button;
if ( prOps->prData->size == NS_LEGAL_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 3, 4,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Executive (7 1/2 x 10 in.)");
prOps->widgets.execToggle = button;
if ( prOps->prData->size == NS_EXECUTIVE_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 4, 5,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"A4 (210 x 297 mm)");
if ( prOps->prData->size == NS_A4_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 4, 5,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
/* margins */
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, PR_FALSE, PR_FALSE, 5);
label = gtk_label_new( "Margins (inches):" );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_FALSE, PR_FALSE, 10);
table = gtk_table_new (1, 2, PR_FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_FALSE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Top: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.topSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
label = gtk_label_new( "Bottom: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.bottomSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Left: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (0.75, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.leftSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
label = gtk_label_new( "Right: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (0.75, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.rightSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, PR_TRUE, PR_FALSE, 5);
button = gtk_button_new_with_label ("Print");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (DoPrint), prOps );
gtk_box_pack_start (GTK_BOX (hbox), button, PR_TRUE, PR_FALSE, 0);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_widget_grab_default (button);
button = gtk_button_new_with_label ("Cancel");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC ( CancelPrint ), prOps);
gtk_box_pack_start (GTK_BOX (hbox), button, PR_TRUE, PR_FALSE, 0);
/* Do this here, otherwise, upon creation the callbacks will be
triggered and the widgets these callbacks set sensitivity on
do not exist yet */
gtk_signal_connect (GTK_OBJECT (prButton), "clicked",
GTK_SIGNAL_FUNC (SwitchToPrinter), prOps);
gtk_signal_connect (GTK_OBJECT (fileButton), "clicked",
GTK_SIGNAL_FUNC (SwitchToFile), prOps);
gtk_widget_show_all( dialog );
gtk_main ();
}
/* public interface to print dialog. Caller passes in preferences using
argument, we return any changes and indication of whether to print
or cancel. */
void
UnixPrDialog( UnixPrData *prData )
{
static UnixPrOps prOps;
prOps.prData = prData;
DoPrintGTK( (GtkWidget *) NULL, &prOps );
}

View File

@@ -0,0 +1,60 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* Original Code: Syd Logan (syd@netscape.com) 3/12/99 */
#ifndef nsPrintdGTK_h___
#define nsPrintdGTK_h___
#include <limits.h>
PR_BEGIN_EXTERN_C
/* stolen from nsPostScriptObj.h. needs to be put somewhere else that
both ps and gtk can see easily */
#ifndef NS_LEGAL_SIZE
#define NS_LETTER_SIZE 0
#define NS_LEGAL_SIZE 1
#define NS_EXECUTIVE_SIZE 2
#define NS_A4_SIZE 3
#endif
#ifndef PATH_MAX
#define PATH_MAX _POSIX_PATH_MAX
#endif
typedef struct unixprdata {
PRBool toPrinter; /* If PR_TRUE, print to printer */
PRBool fpf; /* If PR_TRUE, first page first */
PRBool grayscale; /* If PR_TRUE, print grayscale */
int size; /* Paper size e.g., SizeLetter */
char command[ PATH_MAX ]; /* Print command e.g., lpr */
char path[ PATH_MAX ]; /* If toPrinter = PR_FALSE, dest file */
PRBool cancel; /* If PR_TRUE, user cancelled */
float left; /* left margin */
float right; /* right margin */
float top; /* top margin */
float bottom; /* bottom margin */
} UnixPrData;
void UnixPrDialog(UnixPrData *prData);
PR_END_EXTERN_C
#endif /* nsPrintdGTK_h___ */

View File

@@ -0,0 +1,302 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <gtk/gtk.h>
#include <gdk/gdkprivate.h>
#include "nsRegionGTK.h"
#include "xregion.h"
#include "prmem.h"
static NS_DEFINE_IID(kRegionIID, NS_IREGION_IID);
nsRegionGTK::nsRegionGTK()
{
NS_INIT_REFCNT();
mRegion = nsnull;
mRegionType = eRegionComplexity_empty;
}
nsRegionGTK::~nsRegionGTK()
{
if (mRegion)
::gdk_region_destroy(mRegion);
mRegion = nsnull;
}
NS_IMPL_QUERY_INTERFACE(nsRegionGTK, kRegionIID)
NS_IMPL_ADDREF(nsRegionGTK)
NS_IMPL_RELEASE(nsRegionGTK)
nsresult nsRegionGTK::Init(void)
{
NS_ADDREF_THIS();
mRegion = ::gdk_region_new();
mRegionType = eRegionComplexity_empty;
return NS_OK;
}
void nsRegionGTK::SetTo(const nsIRegion &aRegion)
{
nsRegionGTK * pRegion = (nsRegionGTK *)&aRegion;
SetRegionEmpty();
GdkRegion *nRegion = ::gdk_regions_union(mRegion, pRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::SetTo(const nsRegionGTK *aRegion)
{
SetRegionEmpty();
GdkRegion *nRegion = ::gdk_regions_union(mRegion, aRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
SetRegionEmpty();
GdkRectangle grect;
grect.x = aX;
grect.y = aY;
grect.width = aWidth;
grect.height = aHeight;
GdkRegion *nRegion = ::gdk_region_union_with_rect(mRegion, &grect);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Intersect(const nsIRegion &aRegion)
{
nsRegionGTK * pRegion = (nsRegionGTK *)&aRegion;
GdkRegion *nRegion = ::gdk_regions_intersect(mRegion, pRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
GdkRegion *tRegion = CreateRectRegion(aX, aY, aWidth, aHeight);
GdkRegion *nRegion = ::gdk_regions_intersect(mRegion, tRegion);
::gdk_region_destroy(tRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Union(const nsIRegion &aRegion)
{
nsRegionGTK * pRegion = (nsRegionGTK *)&aRegion;
GdkRegion *nRegion = ::gdk_regions_union(mRegion, pRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
GdkRegion *tRegion = CreateRectRegion(aX, aY, aWidth, aHeight);
GdkRegion *nRegion = ::gdk_regions_union(mRegion, tRegion);
::gdk_region_destroy(mRegion);
::gdk_region_destroy(tRegion);
mRegion = nRegion;
}
void nsRegionGTK::Subtract(const nsIRegion &aRegion)
{
nsRegionGTK * pRegion = (nsRegionGTK *)&aRegion;
GdkRegion *nRegion = ::gdk_regions_subtract(mRegion, pRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
GdkRegion *tRegion = CreateRectRegion(aX, aY, aWidth, aHeight);
GdkRegion *nRegion = ::gdk_regions_subtract(mRegion, tRegion);
::gdk_region_destroy(mRegion);
::gdk_region_destroy(tRegion);
mRegion = nRegion;
}
PRBool nsRegionGTK::IsEmpty(void)
{
return (::gdk_region_empty(mRegion));
}
PRBool nsRegionGTK::IsEqual(const nsIRegion &aRegion)
{
nsRegionGTK *pRegion = (nsRegionGTK *)&aRegion;
return(::gdk_region_equal(mRegion, pRegion->mRegion));
}
void nsRegionGTK::GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight)
{
GdkRectangle rect;
::gdk_region_get_clipbox(mRegion, &rect);
*aX = rect.x;
*aY = rect.y;
*aWidth = rect.width;
*aHeight = rect.height;
}
void nsRegionGTK::Offset(PRInt32 aXOffset, PRInt32 aYOffset)
{
::gdk_region_offset(mRegion, aXOffset, aYOffset);
}
PRBool nsRegionGTK::ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
GdkOverlapType containment;
GdkRectangle rect;
rect.x = aX;
rect.y = aY;
rect.width = aWidth;
rect.height = aHeight;
containment = ::gdk_region_rect_in(mRegion, &rect);
if (containment != GDK_OVERLAP_RECTANGLE_OUT)
return PR_TRUE;
else
return PR_FALSE;
}
NS_IMETHODIMP nsRegionGTK::GetRects(nsRegionRectSet **aRects)
{
nsRegionRectSet *rects;
GdkRegionPrivate *priv = (GdkRegionPrivate *)mRegion;
Region pRegion = priv->xregion;
int nbox;
BOX *pbox;
nsRegionRect *rect;
NS_ASSERTION(!(nsnull == aRects), "bad ptr");
//code lifted from old xfe. MMP
pbox = pRegion->rects;
nbox = pRegion->numRects;
rects = *aRects;
if ((nsnull == rects) || (rects->mRectsLen < (PRUint32)nbox))
{
void *buf = PR_Realloc(rects, sizeof(nsRegionRectSet) + (sizeof(nsRegionRect) * (nbox - 1)));
if (nsnull == buf)
{
if (nsnull != rects)
rects->mNumRects = 0;
return NS_OK;
}
rects = (nsRegionRectSet *)buf;
rects->mRectsLen = nbox;
}
rects->mNumRects = nbox;
rects->mArea = 0;
rect = &rects->mRects[0];
while (nbox--)
{
rect->x = pbox->x1;
rect->width = (pbox->x2 - pbox->x1);
rect->y = pbox->y1;
rect->height = (pbox->y2 - pbox->y1);
rects->mArea += rect->width * rect->height;
pbox++;
rect++;
}
*aRects = rects;
return NS_OK;
}
NS_IMETHODIMP nsRegionGTK::FreeRects(nsRegionRectSet *aRects)
{
if (nsnull != aRects)
PR_Free((void *)aRects);
return NS_OK;
}
NS_IMETHODIMP nsRegionGTK::GetNativeRegion(void *&aRegion) const
{
aRegion = (void *)mRegion;
return NS_OK;
}
NS_IMETHODIMP nsRegionGTK::GetRegionComplexity(nsRegionComplexity &aComplexity) const
{
// cast to avoid const-ness problems on some compilers
if (((nsRegionGTK*)this)->IsEmpty())
aComplexity = eRegionComplexity_empty;
else
aComplexity = eRegionComplexity_complex;
return NS_OK;
}
void nsRegionGTK::SetRegionEmpty()
{
if (!IsEmpty()) {
::gdk_region_destroy(mRegion);
mRegion = ::gdk_region_new();
}
}
GdkRegion *nsRegionGTK::CreateRectRegion(PRInt32 aX,
PRInt32 aY,
PRInt32 aWidth,
PRInt32 aHeight)
{
GdkRegion *tRegion = ::gdk_region_new();
GdkRectangle rect;
rect.x = aX;
rect.y = aY;
rect.width = aWidth;
rect.height = aHeight;
GdkRegion *rRegion = ::gdk_region_union_with_rect(tRegion, &rect);
::gdk_region_destroy(tRegion);
return (rRegion);
}

View File

@@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsRegionGTK_h___
#define nsRegionGTK_h___
#include "nsIRegion.h"
class nsRegionGTK : public nsIRegion
{
public:
nsRegionGTK();
virtual ~nsRegionGTK();
NS_DECL_ISUPPORTS
virtual nsresult Init();
virtual void SetTo(const nsIRegion &aRegion);
virtual void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void SetTo(const nsRegionGTK *aRegion);
virtual void Intersect(const nsIRegion &aRegion);
virtual void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Union(const nsIRegion &aRegion);
virtual void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Subtract(const nsIRegion &aRegion);
virtual void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual PRBool IsEmpty(void);
virtual PRBool IsEqual(const nsIRegion &aRegion);
virtual void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight);
virtual void Offset(PRInt32 aXOffset, PRInt32 aYOffset);
virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD GetRects(nsRegionRectSet **aRects);
NS_IMETHOD FreeRects(nsRegionRectSet *aRects);
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
GdkRegion *CreateRectRegion(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
private:
GdkRegion *mRegion;
nsRegionComplexity mRegionType;
virtual void SetRegionEmpty();
};
#endif // nsRegionGTK_h___

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,173 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsRenderingContextGTK_h___
#define nsRenderingContextGTK_h___
#include "nsIRenderingContext.h"
#include "nsUnitConversion.h"
#include "nsFont.h"
#include "nsIFontMetrics.h"
#include "nsPoint.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsTransform2D.h"
#include "nsIViewManager.h"
#include "nsIWidget.h"
#include "nsRect.h"
#include "nsImageGTK.h"
#include "nsIDeviceContext.h"
#include "nsVoidArray.h"
#include "nsDrawingSurfaceGTK.h"
#include "nsRegionGTK.h"
#include <gtk/gtk.h>
class nsRenderingContextGTK : public nsIRenderingContext
{
public:
nsRenderingContextGTK();
virtual ~nsRenderingContextGTK();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
NS_IMETHOD Reset(void);
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD UnlockDrawingSurface(void);
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
NS_IMETHOD GetHints(PRUint32& aResult);
NS_IMETHOD PushState(void);
NS_IMETHOD PopState(PRBool &aClipEmpty);
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aVisible);
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipValid);
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD GetClipRegion(nsIRegion **aRegion);
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
NS_IMETHOD SetColor(nscolor aColor);
NS_IMETHOD GetColor(nscolor &aColor) const;
NS_IMETHOD SetFont(const nsFont& aFont);
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics);
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics);
NS_IMETHOD Translate(nscoord aX, nscoord aY);
NS_IMETHOD Scale(float aSx, float aSy);
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform);
NS_IMETHOD CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS);
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawRect(const nsRect& aRect);
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillRect(const nsRect& aRect);
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawEllipse(const nsRect& aRect);
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillEllipse(const nsRect& aRect);
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
//locals
NS_IMETHOD CommonInit();
protected:
nsDrawingSurfaceGTK *mOffscreenSurface;
nsDrawingSurfaceGTK *mSurface;
nsIDeviceContext *mContext;
nsIFontMetrics *mFontMetrics;
nsRegionGTK *mClipRegion;
nsTransform2D *mTMatrix;
float mP2T;
GdkWChar* mDrawStringBuf;
PRUint32 mDrawStringSize;
// graphic state stack (GraphicsState)
nsVoidArray *mStateCache;
nscolor mCurrentColor;
GdkFont *mCurrentFont;
nsLineStyle mCurrentLineStyle;
};
#endif /* nsRenderingContextGTK_h___ */

8196
mozilla/gfx/src/gtk/u2j208.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,177 @@
/* $XConsortium: region.h,v 11.13 91/09/10 08:21:49 rws Exp $ */
/************************************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#ifndef _XREGION_H
#define _XREGION_H
typedef struct {
short x1, x2, y1, y2;
} Box, BOX, BoxRec, *BoxPtr;
typedef struct {
short x, y, width, height;
}RECTANGLE, RectangleRec, *RectanglePtr;
#ifdef TRUE
#undef TRUE
#endif
#define TRUE 1
#ifndef FALSE
#define FALSE 0
#endif
#ifndef MAXSHORT
#define MAXSHORT 32767
#endif
#ifndef MINSHORT
#define MINSHORT -MAXSHORT
#endif
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
/*
* clip region
*/
typedef struct _XRegion {
long size;
long numRects;
BOX *rects;
BOX extents;
} REGION;
/* Xutil.h contains the declaration:
* typedef struct _XRegion *Region;
*/
/* 1 if two BOXs overlap.
* 0 if two BOXs do not overlap.
* Remember, x2 and y2 are not in the region
*/
#define EXTENTCHECK(r1, r2) \
((r1)->x2 > (r2)->x1 && \
(r1)->x1 < (r2)->x2 && \
(r1)->y2 > (r2)->y1 && \
(r1)->y1 < (r2)->y2)
/*
* update region extents
*/
#define EXTENTS(r,idRect){\
if((r)->x1 < (idRect)->extents.x1)\
(idRect)->extents.x1 = (r)->x1;\
if((r)->y1 < (idRect)->extents.y1)\
(idRect)->extents.y1 = (r)->y1;\
if((r)->x2 > (idRect)->extents.x2)\
(idRect)->extents.x2 = (r)->x2;\
if((r)->y2 > (idRect)->extents.y2)\
(idRect)->extents.y2 = (r)->y2;\
}
/*
* Check to see if there is enough memory in the present region.
*/
#define MEMCHECK(reg, rect, firstrect){\
if ((reg)->numRects >= ((reg)->size - 1)){\
(firstrect) = (BOX *) Xrealloc \
((char *)(firstrect), (unsigned) (2 * (sizeof(BOX)) * ((reg)->size)));\
if ((firstrect) == 0)\
return(0);\
(reg)->size *= 2;\
(rect) = &(firstrect)[(reg)->numRects];\
}\
}
/* this routine checks to see if the previous rectangle is the same
* or subsumes the new rectangle to add.
*/
#define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\
(!(((Reg)->numRects > 0)&&\
((R-1)->y1 == (Ry1)) &&\
((R-1)->y2 == (Ry2)) &&\
((R-1)->x1 <= (Rx1)) &&\
((R-1)->x2 >= (Rx2))))
/* add a rectangle to the given Region */
#define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\
if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
EXTENTS((r), (reg));\
(reg)->numRects++;\
(r)++;\
}\
}
/* add a rectangle to the given Region */
#define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\
if ((rx1 < rx2) && (ry1 < ry2) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
(reg)->numRects++;\
(r)++;\
}\
}
#define EMPTY_REGION(pReg) pReg->numRects = 0
#define REGION_NOT_EMPTY(pReg) pReg->numRects
#define INBOX(r, x, y) \
( ( ((r).x2 > x)) && \
( ((r).x1 <= x)) && \
( ((r).y2 > y)) && \
( ((r).y1 <= y)) )
/*
* number of points to buffer before sending them off
* to scanlines() : Must be an even number
*/
#define NUMPTSTOBUFFER 200
/*
* used to allocate buffers for points and link
* the buffers together
*/
typedef struct _POINTBLOCK {
XPoint pts[NUMPTSTOBUFFER];
struct _POINTBLOCK *next;
} POINTBLOCK;
#endif

View File

@@ -1,58 +0,0 @@
#!/usr/bin/env python
import cgitb; cgitb.enable()
import sys
import cgi
import time
import re
from pysqlite2 import dbapi2 as sqlite
print "Content-type: text/plain\n\n"
form = cgi.FieldStorage()
# incoming query string has the following parameters:
# user=name
# (REQUIRED) user that made this annotation
# tbox=foopy
# (REQUIRED) name of the tinderbox to annotate
# data=string
# annotation to record
# time=seconds
# time since the epoch in GMT of this test result; if ommitted, current time at time of script run is used
tbox = form.getfirst("tbox")
user = form.getfirst("user")
data = form.getfirst("data")
timeval = form.getfirst("time")
if timeval is None:
timeval = int(time.time())
if (user is None) or (tbox is None) or (data is None):
print "Bad args"
sys.exit()
if re.match(r"[^A-Za-z0-9]", tbox):
print "Bad tbox name"
sys.exit()
db = sqlite.connect("db/" + tbox + ".sqlite")
try:
db.execute("CREATE TABLE test_results (test_name STRING, test_time INTEGER, test_value FLOAT, test_data BLOB);")
db.execute("CREATE TABLE annotations (anno_user STRING, anno_time INTEGER, anno_string STRING);")
db.execute("CREATE INDEX test_name_idx ON test_results.test_name")
db.execute("CREATE INDEX test_time_idx ON test_results.test_time")
db.execute("CREATE INDEX anno_time_idx ON annotations.anno_time")
except:
pass
db.execute("INSERT INTO annotations VALUES (?,?,?)", (user, timeval, data))
db.commit()
print "Inserted."
sys.exit()

View File

@@ -1,59 +0,0 @@
#!/usr/bin/env python
#
# bonsaibouncer
#
# Bounce a request to bonsai.mozilla.org, getting around silly
# cross-domain XMLHTTPRequest deficiencies.
#
import cgitb; cgitb.enable()
import os
import sys
import cgi
import gzip
import urllib
from urllib import quote
import cStringIO
bonsai = "http://bonsai.mozilla.org/cvsquery.cgi";
def main():
#doGzip = 0
#try:
# if string.find(os.environ["HTTP_ACCEPT_ENCODING"], "gzip") != -1:
# doGzip = 1
#except:
# pass
form = cgi.FieldStorage()
treeid = form.getfirst("treeid")
module = form.getfirst("module")
branch = form.getfirst("branch")
mindate = form.getfirst("mindate")
maxdate = form.getfirst("maxdate")
xml_nofiles = form.getfirst("xml_nofiles")
if not treeid or not module or not branch or not mindate or not maxdate:
print "Content-type: text/plain\n\n"
print "ERROR"
return
url = bonsai + "?" + "branchtype=match&sortby=Date&date=explicit&cvsroot=%2Fcvsroot&xml=1"
url += "&treeid=%s&module=%s&branch=%s&mindate=%s&maxdate=%s" % (quote(treeid), quote(module), quote(branch), quote(mindate), quote(maxdate))
if (xml_nofiles):
url += "&xml_nofiles=1"
urlstream = urllib.urlopen(url)
sys.stdout.write("Content-type: text/xml\n\n")
for s in urlstream:
sys.stdout.write(s)
urlstream.close()
main()

View File

@@ -1,216 +0,0 @@
#!/usr/bin/env python
import cgitb; cgitb.enable()
import sys
import cgi
import time
import re
from graphsdb import db
#if var is a valid number returns a value other than None
def checkNumber(var):
if var is None:
return 1
reNumber = re.compile('^[0-9.]*$')
return reNumber.match(var)
#if var is a valid string returns a value other than None
def checkString(var):
if var is None:
return 1
reString = re.compile('^[0-9A-Za-z._()\- ]*$')
return reString.match(var)
print "Content-type: text/plain\n\n"
link_format = "RETURN:%s:%.2f:%sspst=range&spstart=%d&spend=%d&bpst=cursor&bpstart=%d&bpend=%d&m1tid=%d&m1bl=0&m1avg=0\n"
link_str = ""
form = cgi.FieldStorage()
# incoming query string has the following parameters:
# type=discrete|continuous
# indicates discrete vs. continuous dataset, defaults to continuous
# value=n
# (REQUIRED) value to be recorded as the actual test value
# tbox=foopy
# (REQUIRED) name of the tinderbox reporting the value (or rather, the name that is to be given this set of data)
# testname=test
# (REQUIRED) the name of this test
# data=rawdata
# raw data for this test
# time=seconds
# time since the epoch in GMT of this test result; if ommitted, current time at time of script run is used
# date
# date that the test was run - this is for discrete graphs
# branch=1.8.1,1.8.0 or 1.9.0
# name of the branch that the build was generated for
# branchid=id
# date of the build
# http://wiki.mozilla.org/MozillaQualityAssurance:Build_Ids
#takes as input a file for parsing in csv with the format:
# value,testname,tbox,time,data,branch,branchid,type,data
# Create the DB schema if it doesn't already exist
# XXX can pull out dataset_info.machine and dataset_info.{test,test_type} into two separate tables,
# if we need to.
# value,testname,tbox,time,data,branch,branchid,type,data
fields = ["value", "testname", "tbox", "timeval", "date", "branch", "branchid", "type", "data"]
strFields = ["type", "data", "tbox", "testname", "branch", "branchid"]
numFields = ["date", "timeval", "value"]
d_ids = []
all_ids = []
all_types = []
if form.has_key("filename"):
val = form["filename"]
if val.file:
print "found a file"
for line in val.file:
line = line.rstrip("\n\r")
contents = line.split(',')
#clear any previous content in the fields variables - stops reuse of data over lines
for field in fields:
globals()[field] = ''
if len(contents) < 7:
print "Incompatable file format"
sys.exit(500)
for field, content in zip(fields, contents):
globals()[field] = content
for strField in strFields:
if not globals().has_key(strField):
continue
if not checkString(globals()[strField]):
print "Invalid string arg: ", strField, " '" + globals()[strField] + "'"
sys.exit(500)
for numField in numFields:
if not globals().has_key(numField):
continue
if not checkNumber(globals()[numField]):
print "Invalid string arg: ", numField, " '" + globals()[numField] + "'"
sys.exit(500)
#do some checks to ensure that we are enforcing the requirement rules of the script
if (not type):
type = "continuous"
if (not timeval):
timeval = int(time.time())
if (type == "discrete") and (not date):
print "Bad args, need a valid date"
sys.exit(500)
if (not value) or (not tbox) or (not testname):
print "Bad args"
sys.exit(500)
# figure out our dataset id
setid = -1
# Not a big fan of this while loop. If something goes wrong with the select it will insert until the script times out.
while setid == -1:
cur = db.cursor()
cur.execute("SELECT id FROM dataset_info WHERE type <=> ? AND machine <=> ? AND test <=> ? AND test_type <=> ? AND extra_data <=> ? AND branch <=> ? AND date <=> ? limit 1",
(type, tbox, testname, "perf", "branch="+branch, branch, date))
res = cur.fetchall()
cur.close()
if len(res) == 0:
db.execute("INSERT INTO dataset_info (type, machine, test, test_type, extra_data, branch, date) VALUES (?,?,?,?,?,?,?)",
(type, tbox, testname, "perf", "branch="+branch, branch, date))
else:
setid = res[0][0]
db.execute("INSERT INTO dataset_values (dataset_id, time, value) VALUES (?,?,?)", (setid, timeval, value))
db.execute("INSERT INTO dataset_branchinfo (dataset_id, time, branchid) VALUES (?,?,?)", (setid, timeval, branchid))
if data and data != "":
db.execute("INSERT INTO dataset_extra_data (dataset_id, time, data) VALUES (?,?,?)", (setid, timeval, data))
if (type == "discrete"):
if not setid in d_ids:
d_ids.append(setid)
if not setid in all_ids:
all_ids.append(setid)
all_types.append(type)
for setid, type in zip(all_ids, all_types):
cur = db.cursor()
cur.execute("SELECT MIN(time), MAX(time), test FROM dataset_values, dataset_info WHERE dataset_id = ? and id = dataset_id GROUP BY test", (setid,))
res = cur.fetchall()
cur.close()
tstart = res[0][0]
tend = res[0][1]
testname = res[0][2]
if type == "discrete":
link_str += (link_format % (testname, float(-1), "dgraph.html#name=" + testname + "&", tstart, tend, tstart, tend, setid,))
else:
tstart = 0
link_str += (link_format % (testname, float(-1), "graph.html#",tstart, tend, tstart, tend, setid,))
#this code auto-adds a set of continuous data for each series of discrete data sets - creating an overview of the data
# generated by a given test (matched by machine, test, test_type, extra_data and branch)
for setid in d_ids:
cur = db.cursor()
#throw out the largest value and take the average of the rest
cur.execute("SELECT AVG(value) FROM dataset_values WHERE dataset_id = ? and value != (SELECT MAX(value) from dataset_values where dataset_id = ?)", (setid, setid,))
res = cur.fetchall()
cur.close()
avg = res[0][0]
if avg is not None:
cur = db.cursor()
cur.execute("SELECT machine, test, test_type, extra_data, branch, date FROM dataset_info WHERE id = ?", (setid,))
res = cur.fetchall()
cur.close()
tbox = res[0][0]
testname = res[0][1]
test_type = res[0][2]
extra_data = res[0][3]
branch = str(res[0][4])
timeval = res[0][5]
date = ''
cur = db.cursor()
cur.execute("SELECT branchid FROM dataset_branchinfo WHERE dataset_id = ?", (setid,))
res = cur.fetchall()
cur.close()
branchid = res[0][0]
dsetid = -1
while dsetid == -1 :
cur = db.cursor()
cur.execute("SELECT id from dataset_info where type = ? AND machine <=> ? AND test = ? AND test_type = ? AND extra_data = ? AND branch <=> ? AND date <=> ? limit 1",
("continuous", tbox, testname+"_avg", "perf", "branch="+branch, branch, date))
res = cur.fetchall()
cur.close()
if len(res) == 0:
db.execute("INSERT INTO dataset_info (type, machine, test, test_type, extra_data, branch, date) VALUES (?,?,?,?,?,?,?)",
("continuous", tbox, testname+"_avg", "perf", "branch="+branch, branch, date))
else:
dsetid = res[0][0]
cur = db.cursor()
cur.execute("SELECT * FROM dataset_values WHERE dataset_id=? AND time <=> ? limit 1", (dsetid, timeval))
res = cur.fetchall()
cur.close()
if len(res) == 0:
db.execute("INSERT INTO dataset_values (dataset_id, time, value) VALUES (?,?,?)", (dsetid, timeval, avg))
db.execute("INSERT INTO dataset_branchinfo (dataset_id, time, branchid) VALUES (?,?,?)", (dsetid, timeval, branchid))
else:
db.execute("UPDATE dataset_values SET value=? WHERE dataset_id=? AND time <=> ?", (avg, dsetid, timeval))
db.execute("UPDATE dataset_branchinfo SET branchid=? WHERE dataset_id=? AND time <=> ?", (branchid, dsetid, timeval))
cur = db.cursor()
cur.execute("SELECT MIN(time), MAX(time) FROM dataset_values WHERE dataset_id = ?", (dsetid,))
res = cur.fetchall()
cur.close()
tstart = 0
tend = res[0][1]
link_str += (link_format % (testname, float(avg), "graph.html#", tstart, tend, tstart, tend, dsetid,))
db.commit()
print "Inserted."
print link_str
sys.exit()

View File

@@ -1,175 +0,0 @@
#!/usr/bin/env python
import cgitb; cgitb.enable()
import sys
import cgi
import time
import re
from graphsdb import db
#if var is a valid number returns a value other than None
def checkNumber(var):
if var is None:
return 1
reNumber = re.compile('^[0-9.]*$')
return reNumber.match(var)
#if var is a valid string returns a value other than None
def checkString(var):
if var is None:
return 1
reString = re.compile('^[0-9A-Za-z._()\- ]*$')
return reString.match(var)
print "Content-type: text/plain\n\n"
link_format = "RETURN:%.2f:%sspst=range&spstart=%d&spend=%d&bpst=cursor&bpstart=%d&bpend=%d&m1tid=%d&m1bl=0&m1avg=0\n"
link_str = ""
form = cgi.FieldStorage()
# incoming query string has the following parameters:
# type=discrete|continuous
# indicates discrete vs. continuous dataset, defaults to continuous
# value=n
# (REQUIRED) value to be recorded as the actual test value
# tbox=foopy
# (REQUIRED) name of the tinderbox reporting the value (or rather, the name that is to be given this set of data)
# testname=test
# (REQUIRED) the name of this test
# data=rawdata
# raw data for this test
# time=seconds
# time since the epoch in GMT of this test result; if ommitted, current time at time of script run is used
# date
# date that the test was run - this is for discrete graphs
# branch=1.8.1,1.8.0 or 1.9.0
# name of the branch that the build was generated for
# branchid=id
# date of the build
# http://wiki.mozilla.org/MozillaQualityAssurance:Build_Ids
#make sure that we are getting clean data from the user
for strField in ["type", "data", "tbox", "testname", "branch", "branchid"]:
val = form.getfirst(strField)
if not checkString(val):
print "Invalid string arg: ", strField, " '" + val + "'"
sys.exit(500)
globals()[strField] = val
for numField in ["date", "time", "value"]:
val = form.getfirst(numField)
if numField == "time":
numField = "timeval"
if not checkNumber(val):
print "Invalid num arg: ", numField, " '" + val + "'"
sys.exit(500)
globals()[numField] = val
#do some checks to ensure that we are enforcing the requirement rules of the script
if (not type):
type = "continuous"
if (not timeval):
timeval = int(time.time())
if (type == "discrete") and (not date):
print "Bad args, need a valid date"
sys.exit(500)
if (not value) or (not tbox) or (not testname):
print "Bad args"
sys.exit(500)
# Create the DB schema if it doesn't already exist
# XXX can pull out dataset_info.machine and dataset_info.{test,test_type} into two separate tables,
# if we need to.
# figure out our dataset id
setid = -1
while setid == -1:
cur = db.cursor()
cur.execute("SELECT id FROM dataset_info WHERE type <=> ? AND machine <=> ? AND test <=> ? AND test_type <=> ? AND extra_data=? AND branch <=> ? AND date <=> ?",
(type, tbox, testname, "perf", "branch="+branch, branch, date))
res = cur.fetchall()
cur.close()
if len(res) == 0:
db.execute("INSERT INTO dataset_info (type, machine, test, test_type, extra_data, branch, date) VALUES (?,?,?,?,?,?,?)",
(type, tbox, testname, "perf", "branch="+branch, branch, date))
else:
setid = res[0][0]
db.execute("INSERT INTO dataset_values (dataset_id, time, value) VALUES (?,?,?)", (setid, timeval, value))
db.execute("INSERT INTO dataset_branchinfo (dataset_id, time, branchid) VALUES (?,?,?)", (setid, timeval, branchid))
if data and data != "":
db.execute("INSERT INTO dataset_extra_data (dataset_id, time, data) VALUES (?,?,?)", (setid, timeval, data))
cur = db.cursor()
cur.execute("SELECT MIN(time), MAX(time) FROM dataset_values WHERE dataset_id = ?", (setid,))
res = cur.fetchall()
cur.close()
tstart = res[0][0]
tend = res[0][1]
if type == "discrete":
link_str += (link_format % (float(-1), "dgraph.html#name=" + testname + "&", tstart, tend, tstart, tend, setid,))
else:
tstart = 0
link_str += (link_format % (float(-1), "graph.html#",tstart, tend, tstart, tend, setid,))
#this code auto-adds a set of continuous data for each series of discrete data sets - creating an overview of the data
# generated by a given test (matched by machine, test, test_type, extra_data and branch)
# it is not terribly efficient as it updates the tracking number on the continuous set each time a point is added
# to the discrete set. If the efficiency becomes a concern we can re-examine the code - for now it is a good
# solution for generating the secondary, tracking data.
if type == "discrete" :
timeval = date
date = ''
cur = db.cursor()
#throw out the largest value and take the average of the rest
cur.execute("SELECT AVG(value) FROM dataset_values WHERE dataset_id = ? and value != (SELECT MAX(value) from dataset_values where dataset_id = ?)", (setid, setid,))
res = cur.fetchall()
cur.close()
avg = res[0][0]
if avg is not None:
setid = -1
while setid == -1 :
cur = db.cursor()
cur.execute("SELECT id from dataset_info where type <=> ? AND machine <=> ? AND test <=> ? AND test_type <=> ? AND extra_data <=> ? AND branch <=> ? AND date <=> ?",
("continuous", tbox, testname+"_avg", "perf", "branch="+branch, branch, date))
res = cur.fetchall()
cur.close()
if len(res) == 0:
db.execute("INSERT INTO dataset_info (type, machine, test, test_type, extra_data, branch, date) VALUES (?,?,?,?,?,?,?)",
("continuous", tbox, testname+"_avg", "perf", "branch="+branch, branch, date))
else:
setid = res[0][0]
cur = db.cursor()
cur.execute("SELECT * FROM dataset_values WHERE dataset_id=? AND time <=> ?", (setid, timeval))
res = cur.fetchall()
cur.close()
if len(res) == 0:
db.execute("INSERT INTO dataset_values (dataset_id, time, value) VALUES (?,?,?)", (setid, timeval, avg))
db.execute("INSERT INTO dataset_branchinfo (dataset_id, time, branchid) VALUES (?,?,?)", (setid, timeval, branchid))
else:
db.execute("UPDATE dataset_values SET value=? WHERE dataset_id=? AND time <=> ?", (avg, setid, timeval))
db.execute("UPDATE dataset_branchinfo SET branchid=? WHERE dataset_id=? AND time <=> ?", (branchid, setid, timeval))
cur = db.cursor()
cur.execute("SELECT MIN(time), MAX(time) FROM dataset_values WHERE dataset_id = ?", (setid,))
res = cur.fetchall()
cur.close()
tstart = 0
tend = res[0][1]
link_str += (link_format % (float(avg), "graph.html#", tstart, tend, tstart, tend, setid,))
db.commit()
print "Inserted."
print link_str
sys.exit()

View File

@@ -1,20 +0,0 @@
import MySQLdb
from MySQLdb import *
class GraphConnection(MySQLdb.connections.Connection):
def execute(self,query, args):
cur = self.cursor()
result = cur.execute(query,args)
cur.close()
return result
class GraphsCursor(MySQLdb.cursors.Cursor):
def execute(self, query, args=None):
query = query.replace('?','%s')
return MySQLdb.cursors.Cursor.execute(self, query, args)
def connect(*args,**kwargs):
kwargs['cursorclass'] = GraphsCursor
return GraphConnection(*args,**kwargs)

View File

@@ -1,105 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Perf-o-matic-too</title>
<link rel="stylesheet" type="text/css" href="js/graph.css"></link>
<!-- MochiKit -->
<script type="text/javascript" src="js/mochikit/MochiKit.js"></script>
<!-- YUI -->
<script type="text/javascript" src="js/yui/yahoo.js"></script>
<script type="text/javascript" src="js/yui/dom.js"></script>
<script type="text/javascript" src="js/yui/event.js"></script>
<script type="text/javascript" src="js/yui/animation.js"></script>
<script type="text/javascript" src="js/yui/container.js"></script>
<!-- Core -->
<script type="text/javascript" src="js/TinderboxData.js"></script>
<script type="text/javascript" src="js/DataSet.js"></script>
<script type="text/javascript" src="js/GraphCanvas.js"></script>
<script type="text/javascript" src="js/dGraphFormModule.js"></script>
<script type="text/javascript" src="js/graph.js"></script>
<script type="text/javascript" src="js/ResizeGraph.js"></script>
<!-- BonsaiService needs e4x -->
<script type="text/javascript; e4x=1" src="js/BonsaiService.js"></script>
</head>
<body onload="loadingDone(DISCRETE_GRAPH)">
<!--<h1>Graph</h1>-->
<!-- Take your damn divs and floats and clears and shove 'em! -->
<div style="width: 710px; height:20px; margin-left:10px ">
<span id="loading" class="loading"></span>
</div>
<form action="javascript:;">
<table class="graphconfig-no" width="100%">
<tr style="vertical-align: top">
<td class="graphconfig-list">
<div id="graphforms"></div>
</td>
<td class="graphconfig-test-list">
<div id="graphforms-test-list"></div>
</td>
<td class="dgraphconfig">
<!--
<div id="baseline">
<span>Use </span><select id="baselineDropdown"><option value="0">nothing</option></select><span> as a baseline</span><br>
</div>
-->
<br>
<div id="formend">
<input id="graphbutton" type="submit" onclick="onGraph()" value="Graph It!">
<!-- <label for="baseline">No baseline</label><input type="radio" name="baseline" checked onclick="onNoBaseLineClick()"> -->
</br> </br>
<div><a id="linktothis" href="dgraph.html">Link to this graph</a> </div>
</br>
<div><a id="dumptocsv" href="dumpdata.cgi">Dump to csv</a> </div>
</div>
</tr>
</table>
</form>
<!-- small graph -->
<div style="width: 900px; height:20px">
<center><span id="status" class="status"></span></center>
</div>
<div id="container" style="width: 100%">
<!-- these are absolute size, so we wrap them in a div that can overflow -->
<div id="graph-container" style="width: 900px; margin:auto">
<div id="smallgraph-labels-x" style="position: relative; left: 51px; margin-left: 1px; margin-right: 1px; height: 30px; width: 700px"></div>
<div id="smallgraph-labels-y" style="position: relative; left: 0px; top: 0px; float: left; height: 76px; width: 50px;"></div>
<canvas style="clear: left; border: 1px solid #888; padding-top: 1px;" id="smallgraph" height="75" width="650"></canvas>
<br/>
<br/>
<div id="graph-labels-y" style="position: relative; left: 0px; top: 0px; float: left; margin-top: 1px; margin-bottom: 1px; height: 300px; width: 50px;"></div>
<canvas style="clear: left; border: 1px solid #888;" id="graph" height="300" width="650"></canvas>
<div id="graph-labels-x" style="position: relative; left: 50px; margin-left: 1px; margin-right: 1px; height: 50px; width: 700px"></div>
</div>
<div id="graph-label-container" style="float:left;margin-top:30px;">
<span id="graph-label-list" class="graph-label-list-member" align="left"></span>
</div>
</div>
<script>
ResizableBigGraph = new ResizeGraph();
ResizableBigGraph.init('graph');
</script>
</body>
</html>

View File

@@ -1,127 +0,0 @@
#!/usr/bin/env python
import cgitb; cgitb.enable()
import os
import sys
import cgi
import time
import re
import gzip
import minjson as json
import cStringIO
from graphsdb import db
#
# returns a plain text file containing the information for a given dataset in two csv tables
# the first table containing the dataset info (branch, date, etc)
# the second table containing the databaset values
#
# incoming query string:
#
# setid=number
# Where number is a valid setid
#
# starttime=tval
# Start time to return results from, in seconds since GMT epoch
# endtime=tval
# End time, in seconds since GMT epoch
def doError(errCode):
errString = "unknown error"
if errCode == -1:
errString = "bad tinderbox"
elif errCode == -2:
errString = "bad test name"
print "{ resultcode: " + str(errCode) + ", error: '" + errString + "' }"
def esc(val):
delim = '"'
val = delim + str(val).replace(delim, delim + delim) + delim
return val
def dumpData(fo, setid, starttime, endtime):
s1 = ""
s2 = ""
if starttime:
s1 = " AND time >= B." + starttime
if endtime:
s2 = " AND time <= B." + endtime
cur = db.cursor()
setid = ",".join(setid)
fo.write("dataset,machine,branch,test,date\n")
cur.execute("SELECT B.id, B.machine, B.branch, B.test, B.date FROM dataset_info as B WHERE id IN (%s) %s %s ORDER BY id" % (setid, s1, s2,))
for row in cur:
fo.write ('%s,%s,%s,%s,%s\n' % (esc(row[0]), esc(row[1]), esc(row[2]), esc(row[3]), esc(row[4])))
fo.write("dataset,time,value,buildid,data\n")
cur.close()
cur = db.cursor()
#cur.execute("SELECT dataset_id, time, value, branchid, data from ((dataset_values NATURAL JOIN dataset_branchinfo) NATURAL JOIN dataset_extra_data) WHERE dataset_id IN (%s) %s %s ORDER BY dataset_id, time" % (setid, s1, s2,))
cur.execute("SELECT dataset_values.dataset_id, dataset_values.time, dataset_values.value, dataset_branchinfo.branchid, dataset_extra_data.data FROM dataset_values LEFT JOIN dataset_branchinfo ON dataset_values.dataset_id = dataset_branchinfo.dataset_id AND dataset_values.time = dataset_branchinfo.time LEFT JOIN dataset_extra_data ON dataset_values.dataset_id = dataset_extra_data.dataset_id AND dataset_values.time = dataset_extra_data.time WHERE dataset_values.dataset_id IN (%s) %s %s ORDER BY dataset_values.dataset_id, dataset_values.time" % (setid, s1, s2))
for row in cur:
fo.write ('%s,%s,%s,%s,%s\n' % (esc(row[0]), esc(row[1]), esc(row[2]), esc(row[3]), esc(row[4])))
cur.close()
#if var is a number returns a value other than None
def checkNumber(var):
if var is None:
return 1
reNumber = re.compile('^[0-9.]*$')
return reNumber.match(var)
#if var is a string returns a value other than None
def checkString(var):
if var is None:
return 1
reString = re.compile('^[0-9A-Za-z._()\- ]*$')
return reString.match(var)
doGzip = 0
try:
if "gzip" in os.environ["HTTP_ACCEPT_ENCODING"]:
doGzip = 1
except:
pass
form = cgi.FieldStorage()
for numField in ["setid"]:
val = form.getlist(numField)
for v in val:
if not checkNumber(v):
print "Invalid string arg: ", numField, " '" + v + "'"
sys.exit(500)
globals()[numField] = val
for numField in ["starttime", "endtime"]:
val = form.getfirst(numField)
if not checkNumber(val):
print "Invalid string arg: ", numField, " '" + val + "'"
sys.exit(500)
globals()[numField] = val
if not setid:
print "Content-Type: text/plain\n"
print "No data set selected\n"
sys.exit(500)
zbuf = cStringIO.StringIO()
zfile = zbuf
if doGzip == 1:
zfile = gzip.GzipFile(mode = 'wb', fileobj = zbuf, compresslevel = 9)
dumpData(zfile, setid, starttime, endtime)
sys.stdout.write("Content-Type: text/plain\n")
if doGzip == 1:
zfile.close()
sys.stdout.write("Content-Encoding: gzip\n")
sys.stdout.write("\n")
sys.stdout.write(zbuf.getvalue())

View File

@@ -1,105 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Perf-o-matic-too</title>
<link rel="stylesheet" type="text/css" href="js/graph.css"></link>
<!-- MochiKit -->
<script type="text/javascript" src="js/mochikit/MochiKit.js"></script>
<!-- YUI -->
<script type="text/javascript" src="js/yui/yahoo.js"></script>
<script type="text/javascript" src="js/yui/dom.js"></script>
<script type="text/javascript" src="js/yui/event.js"></script>
<script type="text/javascript" src="js/yui/animation.js"></script>
<script type="text/javascript" src="js/yui/container.js"></script>
<!-- Core -->
<script type="text/javascript" src="js/TinderboxData.js"></script>
<script type="text/javascript" src="js/DataSet.js"></script>
<script type="text/javascript" src="js/GraphCanvas.js"></script>
<script type="text/javascript" src="js/edGraphFormModule.js"></script>
<script type="text/javascript" src="js/graph.js"></script>
<script type="text/javascript" src="js/ResizeGraph.js"></script>
<!-- BonsaiService needs e4x -->
<script type="text/javascript; e4x=1" src="js/BonsaiService.js"></script>
</head>
<body onload="loadingDone(DATA_GRAPH)">
<!--<h1>Graph</h1>-->
<!-- Take your damn divs and floats and clears and shove 'em! -->
<div style="width: 710px; height:20px; margin-left:10px ">
<span id="loading" class="loading"></span>
</div>
<form action="javascript:;">
<table class="graphconfig-no" width="100%">
<tr style="vertical-align: top">
<td class="graphconfig-list">
<div id="graphforms"></div>
</td>
<td class="graphconfig-test-list">
<div id="graphforms-test-list"></div>
</td>
<td class="dgraphconfig">
<!--
<div id="baseline">
<span>Use </span><select id="baselineDropdown"><option value="0">nothing</option></select><span> as a baseline</span><br>
</div>
-->
<br>
<div id="formend">
<input id="graphbutton" type="submit" onclick="onGraph()" value="Graph It!">
<!-- <label for="baseline">No baseline</label><input type="radio" name="baseline" checked onclick="onNoBaseLineClick()"> -->
</br> </br>
<div><a id="linktothis" href="edgraph.html">Link to this graph</a> </div>
</br>
<div><a id="dumptocsv" href="dumpdata.cgi">Dump to csv</a> </div>
</div>
</tr>
</table>
</form>
<!-- small graph -->
<div style="width: 900px; height:20px">
<center><span id="status" class="status"></span></center>
</div>
<div id="container" style="width: 100%">
<!-- these are absolute size, so we wrap them in a div that can overflow -->
<div id="graph-container" style="width: 900px; margin:auto">
<div id="smallgraph-labels-x" style="position: relative; left: 51px; margin-left: 1px; margin-right: 1px; height: 30px; width: 700px"></div>
<div id="smallgraph-labels-y" style="position: relative; left: 0px; top: 0px; float: left; height: 76px; width: 50px;"></div>
<canvas style="clear: left; border: 1px solid #888; padding-top: 1px;" id="smallgraph" height="75" width="650"></canvas>
<br/>
<br/>
<div id="graph-labels-y" style="position: relative; left: 0px; top: 0px; float: left; margin-top: 1px; margin-bottom: 1px; height: 300px; width: 50px;"></div>
<canvas style="clear: left; border: 1px solid #888;" id="graph" height="300" width="650"></canvas>
<div id="graph-labels-x" style="position: relative; left: 50px; margin-left: 1px; margin-right: 1px; height: 50px; width: 700px"></div>
</div>
<div id="graph-label-container" style="float:left;margin-top:30px;">
<span id="graph-label-list" class="graph-label-list-member" align="left"></span>
</div>
</div>
<script>
ResizableBigGraph = new ResizeGraph();
ResizableBigGraph.init('graph');
</script>
</body>
</html>

View File

@@ -1,47 +0,0 @@
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
#foreach my $k (keys(%ENV)) {
# print "$k => " . $ENV{$k} . "\n";
#}
my $QS = $ENV{"QUERY_STRING"};
my %query = ();
{
my @qp = split /\&/,$QS;
foreach my $q (@qp) {
my @qp1 = split /=/,$q;
$query{$qp1[0]} = $qp1[1];
}
}
if (defined($query{"setid"})) {
my $testid = $query{"setid"};
print "{ resultcode: 0, results: [";
srand();
my $lv = 200 + rand (100);
foreach my $k (1 .. 500) {
#my $kv = $k;
#my $v = $k;
my $kv = 1148589000 + ($k*60*20);
my $v = $lv;
$lv = $lv + (rand(10) - 5);
print "$kv, $v, ";
}
print "] }";
} else {
print "{ resultcode: 0, results: [
{ id: 1, machine: 'tbox1', test: 'test1', test_type: 'perf', extra_data: null },
{ id: 4, machine: 'tbox2', test: 'test1', test_type: 'perf', extra_data: null },
{ id: 3, machine: 'tbox1', test: 'test3', test_type: 'perf', extra_data: null },
{ id: 6, machine: 'tbox3', test: 'test3', test_type: 'perf', extra_data: null },
{ id: 2, machine: 'tbox1', test: 'test2', test_type: 'perf', extra_data: null },
{ id: 5, machine: 'tbox2', test: 'test2', test_type: 'perf', extra_data: null },
] }";
}

View File

@@ -1,276 +0,0 @@
#!/usr/bin/env python
import cgitb; cgitb.enable()
import os
import sys
import cgi
import time
import re
import gzip
import minjson as json
import cStringIO
from graphsdb import db
#
# All objects are returned in the form:
# {
# resultcode: n,
# ...
# }
#
# The ... is dependant on the result type.
#
# Result codes:
# 0 success
# -1 bad tinderbox
# -2 bad test name
#
# incoming query string:
# tbox=name
# tinderbox name
#
# If only tbox specified, returns array of test names for that tinderbox in data
# If invalid tbox specified, returns error -1
#
# test=testname
# test name
#
# Returns results for that test in .results, in array of [time0, value0, time1, value1, ...]
# Also returns .annotations for that dataset, in array of [time0, string0, time1, string1, ...]
#
# raw=1
# Same as full results, but includes raw data for test in .rawdata, in form [time0, rawdata0, ...]
#
# starttime=tval
# Start time to return results from, in seconds since GMT epoch
# endtime=tval
# End time, in seconds since GMT epoch
#
# getlist=1
# To be combined with branch, machine and testname
# Returns a list of distinct branches, machines or testnames in the database
#
# if neither getlist nor setid are found in the query string the returned results will be a list
# of tests, limited by a given datelimit, branch, machine and testname
# ie) dgetdata?datelimit=1&branch=1.8 will return all tests in the database that are not older than a day and that
# were run on the 1.8 branch
def doError(errCode):
errString = "unknown error"
if errCode == -1:
errString = "bad tinderbox"
elif errCode == -2:
errString = "bad test name"
print "{ resultcode: " + str(errCode) + ", error: '" + errString + "' }"
def doGetList(fo, type, branch, machine, testname):
results = []
s1 = ""
if branch:
s1 = "SELECT DISTINCT branch FROM dataset_info"
if machine:
s1 = "SELECT DISTINCT machine FROM dataset_info"
if testname:
s1 = "SELECT DISTINCT test FROM dataset_info"
cur = db.cursor()
cur.execute(s1 + " WHERE type = ?", (type,))
for row in cur:
results.append({ "value": row[0] })
cur.close()
fo.write(json.write( {"resultcode": 0, "results": results} ))
def doListTests(fo, type, datelimit, branch, machine, testname, graphby):
results = []
s1 = ""
# FIXME: This could be vulnerable to SQL injection! Although it looks like checkstring should catch bad strings.
if branch:
s1 += " AND branch = '" + branch + "' "
if machine:
s1 += " AND machine = '" + machine + "' "
if testname:
s1 += " AND test = '" + testname + "' "
cur = db.cursor()
if graphby and graphby == 'bydata':
cur.execute("SELECT id, machine, test, test_type, dataset_extra_data.data, extra_data, branch FROM dataset_extra_data JOIN dataset_info ON dataset_extra_data.dataset_id = dataset_info.id WHERE type = ? AND test_type != ? and (date >= ?) " + s1 +" GROUP BY machine,test,test_type,dataset_extra_data.data, extra_data, branch", (type, "baseline", datelimit))
else:
cur.execute("SELECT id, machine, test, test_type, date, extra_data, branch FROM dataset_info WHERE type = ? AND test_type != ? and (date >= ?)" + s1, (type, "baseline", datelimit))
for row in cur:
if graphby and graphby == 'bydata':
results.append( {"id": row[0],
"machine": row[1],
"test": row[2],
"test_type": row[3],
"data": row[4],
"extra_data": row[5],
"branch": row[6]})
else:
results.append( {"id": row[0],
"machine": row[1],
"test": row[2],
"test_type": row[3],
"date": row[4],
"extra_data": row[5],
"branch": row[6]})
cur.close()
fo.write (json.write( {"resultcode": 0, "results": results} ))
def getByDataResults(cur,setid,extradata,starttime,endtime):
s1 = ""
s2 = ""
cur.execute("""
SELECT dataset_info.date,avg(dataset_values.value)
FROM dataset_info
JOIN dataset_extra_data
ON dataset_extra_data.dataset_id = dataset_info.id
JOIN dataset_values
ON dataset_extra_data.time = dataset_values.time
AND dataset_info.id = dataset_values.dataset_id
WHERE
(dataset_info.machine,dataset_info.test,dataset_info.test_type,dataset_info.extra_data,dataset_info.branch) = (SELECT machine,test,test_type,extra_data,branch from dataset_info where id = ? limit 1)
AND dataset_extra_data.data = ?
GROUP BY dataset_info.date ORDER BY dataset_info.date
""", (setid,extradata))
def doSendResults(fo, setid, starttime, endtime, raw, graphby, extradata=None):
s1 = ""
s2 = ""
if starttime:
s1 = " AND time >= " + starttime
if endtime:
s2 = " AND time <= " + endtime
fo.write ("{ resultcode: 0,")
cur = db.cursor()
if not graphby or graphby == "time":
cur.execute("SELECT time, value FROM dataset_values WHERE dataset_id = ? " + s1 + s2 + " ORDER BY time", (setid,))
else:
getByDataResults(cur,setid, extradata,starttime,endtime)
fo.write ("results: [")
for row in cur:
if row[1] == 'nan':
continue
fo.write ("%s,%s," % (row[0], row[1]))
cur.close()
fo.write ("],")
cur = db.cursor()
cur.execute("SELECT time, value FROM annotations WHERE dataset_id = ? " + s1 + s2 + " ORDER BY time", (setid,))
fo.write ("annotations: [")
for row in cur:
fo.write("%s,'%s'," % (row[0], row[1]))
cur.close()
fo.write ("],")
cur = db.cursor()
cur.execute("SELECT test FROM dataset_info WHERE id = ?", (setid,))
row = cur.fetchone()
test_name = row[0]
cur.execute("SELECT id, extra_data FROM dataset_info WHERE test = ? and test_type = ?", (test_name, "baseline"))
baselines = cur.fetchall()
fo.write ("baselines: {")
for baseline in baselines:
cur.execute("SELECT value FROM dataset_values WHERE dataset_id = ? LIMIT 1", (baseline[0],))
row = cur.fetchone()
fo.write("'%s': '%s'," % (baseline[1], row[0]))
fo.write("},")
cur.close()
if raw:
cur = db.cursor()
cur.execute("SELECT time, data FROM dataset_extra_data WHERE dataset_id = ? " + s1 + s2 + " ORDER BY time", (setid,))
fo.write ("rawdata: [")
for row in cur:
blob = row[1]
if "\\" in blob:
blob = blob.replace("\\", "\\\\")
if "'" in blob:
blob = blob.replace("'", "\\'")
fo.write("%s,'%s'," % (row[0], blob))
cur.close()
fo.write ("],")
cur = db.cursor()
cur.execute("SELECT avg(value), max(value), min(value) from dataset_values where dataset_id = ? " + s1 + s2 + " GROUP BY dataset_id", (setid,))
fo.write("stats: [")
for row in cur:
fo.write("%s, %s, %s," %(row[0], row[1], row[2]))
cur.close()
fo.write("],")
fo.write ("}")
#if var is a number returns a value other than None
def checkNumber(var):
if var is None:
return 1
reNumber = re.compile('^[0-9.]*$')
return reNumber.match(var)
#if var is a string returns a value other than None
def checkString(var):
if var is None:
return 1
reString = re.compile('^[0-9A-Za-z._()\- ]*$')
return reString.match(var)
doGzip = 0
try:
if "gzip" in os.environ["HTTP_ACCEPT_ENCODING"]:
doGzip = 1
except:
pass
form = cgi.FieldStorage()
#make sure that we are getting clean data from the user
for strField in ["type", "machine", "branch", "test", "graphby","extradata"]:
val = form.getfirst(strField)
if strField == "test":
strField = "testname"
if not checkString(val):
print "Invalid string arg: ", strField, " '" + val + "'"
sys.exit(500)
globals()[strField] = val
for numField in ["setid", "raw", "starttime", "endtime", "datelimit", "getlist"]:
val = form.getfirst(numField)
if not checkNumber(val):
print "Invalid string arg: ", numField, " '" + val + "'"
sys.exit(500)
globals()[numField] = val
if not datelimit:
datelimit = 0
zbuf = cStringIO.StringIO()
zfile = zbuf
if doGzip == 1:
zfile = gzip.GzipFile(mode = 'wb', fileobj = zbuf, compresslevel = 5)
if not setid and not getlist:
doListTests(zfile, type, datelimit, branch, machine, testname, graphby)
elif not getlist:
doSendResults(zfile, setid, starttime, endtime, raw, graphby,extradata)
else:
doGetList(zfile, type, branch, machine, testname)
sys.stdout.write("Content-Type: text/plain\n")
if doGzip == 1:
zfile.close()
sys.stdout.write("Content-Encoding: gzip\n")
sys.stdout.write("\n")
sys.stdout.write(zbuf.getvalue())

View File

@@ -1,115 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Perf-o-matic</title>
<link rel="stylesheet" type="text/css" href="js/graph.css">
<!-- MochiKit -->
<script type="text/javascript" src="js/mochikit/MochiKit.js"></script>
<!-- YUI -->
<script type="text/javascript" src="js/yui/yahoo.js"></script>
<script type="text/javascript" src="js/yui/dom.js"></script>
<script type="text/javascript" src="js/yui/event.js"></script>
<script type="text/javascript" src="js/yui/animation.js"></script>
<script type="text/javascript" src="js/yui/container.js"></script>
<!-- Core -->
<script type="text/javascript" src="js/TinderboxData.js"></script>
<script type="text/javascript" src="js/DataSet.js"></script>
<script type="text/javascript" src="js/GraphCanvas.js"></script>
<script type="text/javascript" src="js/GraphFormModule.js"></script>
<script type="text/javascript" src="js/graph.js"></script>
<script type="text/javascript" src="js/ResizeGraph.js"></script>
<!-- BonsaiService needs e4x -->
<script type="text/javascript; e4x=1" src="js/BonsaiService.js"></script>
</head>
<body onload="loadingDone(CONTINUOUS_GRAPH)">
<!--<h1>Graph</h1>-->
<!-- Take your damn divs and floats and clears and shove 'em! -->
<div style="width: 710px; height:20px; margin-left:10px ">
<span id="loading" class="loading"></span>
</div>
<form action="javascript:;">
<table class="graphconfig-no" width="100%">
<tr style="vertical-align: top">
<td class="graphconfig">
<table>
<tr style="vertical-align: top;">
<td>Show</td>
<td>
<input id="load-all-radio" type="radio" name="dataload" onclick="onDataLoadChanged()" checked>
<label>all data</label><br>
<input id="load-days-radio" type="radio" name="dataload" onclick="onDataLoadChanged()">
<label>previous</label> <input type="text" value="30" id="load-days-entry" size="3" onchange="onDataLoadChanged()"> <label>days</label>
</td>
</tr>
</table>
<div id="baseline">
<span>Use </span><select id="baselineDropdown"><option value="0">nothing</option></select><span> as a baseline</span><br>
</div>
<br>
<div id="formend">
<input type="submit" onclick="onGraph()" value="Graph It!">
</br> </br>
<!-- <label for="baseline">No baseline</label><input type="radio" name="baseline" checked onclick="onNoBaseLineClick()"> -->
<a id="linktothis" href="graph.html">Link to this graph</a>
</br>
<div><a id="dumptocsv" href="dumpdata.cgi">Dump to csv</a> </div>
</div>
<br>
<input style="display:none" id="bonsaibutton" type="button" onclick="onUpdateBonsai()" value="Refresh Bonsai Data">
</td>
<td class="graphconfig-list">
<div id="graphforms"></div>
<div id="addone">
<img src="js/img/plus.png" class="plusminus" onclick="addGraphForm()" alt="Plus">
</div>
</td>
</tr>
</table>
</form>
<!-- small graph -->
<div style="width: 900px; height:20px">
<center><span id="status" class="status"></span></center>
</div>
<!-- these are absolute size, so we wrap them in a div that can overflow -->
<div id="graph-container" style="margin:auto; width:900px;">
<div id="smallgraph-labels-x" style="position: relative; left: 51px; margin-left: 1px; margin-right: 1px; height: 30px; width: 700px"></div>
<div id="smallgraph-labels-y" style="position: relative; left: 0px; top: 0px; float: left; height: 76px; width: 50px;"></div>
<canvas style="clear: left; border: 1px solid #888; padding-top: 1px;" id="smallgraph" height="75" width="700"></canvas>
<br/>
<br/>
<div id="graph-labels-y" style="position: relative; left: 0px; top: 0px; float: left; margin-top: 1px; margin-bottom: 1px; height: 300px; width: 50px;"></div>
<canvas style="clear: left; border: 1px solid #888;" id="graph" height="300" width="700"></canvas>
<div id="graph-labels-x" style="position: relative; left: 50px; margin-left: 1px; margin-right: 1px; height: 50px; width: 700px"></div>
</div>
<script>
ResizableBigGraph = new ResizeGraph();
ResizableBigGraph.init('graph');
</script>
</body>
</html>

View File

@@ -1,6 +0,0 @@
from pysqlite2 import dbapi2 as sqlite
from databases import mysql as MySQLdb
db = MySQLdb.connect("localhost","o","o","o_graphs")

View File

@@ -1,111 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is new-graph code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function BonsaiService() {
}
BonsaiService.prototype = {
// this could cache stuff, so that we only have to request the bookend data
// if we want a wider range, but it's probably not worth it for now.
//
// The callback is called with an object argument which contains:
// {
// times: [ t1, t2, t3, .. ],
// who: [ w1, w2, w3, .. ],
// log: [ l1, l2, l3, .. ],
// files: [ [ r11, f11, r12, f12, r13, f13, .. ], [ r21, f21, r22, f22, r23, f23, .. ], .. ]
// }
//
// r = revision number, as a string, e.g. "1.15"
// f = file, e.g. "mozilla/widget/foo.cpp"
//
// arg1 = callback, arg2 = null
// arg1 = includeFiles, arg2 = callback
requestCheckinsBetween: function (startDate, endDate, arg1, arg2) {
var includeFiles = arg1;
var callback = arg2;
if (arg2 == null) {
callback = arg1;
includeFiles = null;
}
var queryargs = {
treeid: "default",
module: "SeaMonkeyAll",
branch: "HEAD",
mindate: startDate,
maxdate: endDate
};
if (!includeFiles)
queryargs.xml_nofiles = "1";
log ("bonsai request: ", queryString(queryargs));
doSimpleXMLHttpRequest (bonsaicgi, queryargs)
.addCallbacks(
function (obj) {
var result = { times: [], who: [], comment: [], files: null };
if (includeFiles)
result.files = [];
// strip out the xml declaration
var s = obj.responseText.replace(/<\?xml version="1.0"\?>/, "");
var bq = new XML(s);
for (var i = 0; i < bq.ci.length(); i++) {
var ci = bq.ci[i];
result.times.push(ci.@date);
result.who.push(ci.@who);
result.comment.push(ci.log.text().toString());
if (includeFiles) {
var files = [];
for (var j = 0; j < ci.files.f.length(); j++) {
var f = ci.files.f[j];
files.push(f.@rev);
files.push(f.text().toString());
}
result.files.push(files);
}
}
callback.call (window, result);
},
function () { alert ("Error talking to bonsai"); });
},
};

View File

@@ -1,273 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is new-graph code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function TimeDataSet(data) {
this.data = data;
}
TimeDataSet.prototype = {
data: null,
indicesForTimeRange: function (startTime, endTime) {
var startIndex = -1;
var endIndex = -1;
if (this.data[0] > endTime ||
this.data[this.data.length-2] < startTime)
return null;
for (var i = 0; i < this.data.length/2; i++) {
if (startIndex == -1 && this.data[i*2] >= startTime) {
startIndex = i;
} else if (startIndex != -1 && this.data[i*2] > endTime) {
endIndex = i;
return [startIndex, endIndex];
}
}
endIndex = (this.data.length/2) - 1;
return [startIndex, endIndex];
},
};
function TimeValueDataSet(data, color) {
this.data = data;
this.firstTime = data[0];
if (data.length > 2)
this.lastTime = data[data.length-2];
else
this.lastTime = data[0];
if (color) {
this.color = color;
} else {
this.color = "#000000";
}
log ("new tds:", this.firstTime, this.lastTime);
this.relativeToSets = new Array();
}
TimeValueDataSet.prototype = {
__proto__: new TimeDataSet(),
firstTime: 0,
lastTime: 0,
data: null, // array: [time0, value0, time1, value1, ...]
relativeTo: null,
color: "black",
title: '',
minMaxValueForTimeRange: function (startTime, endTime) {
var minValue = Number.POSITIVE_INFINITY;
var maxValue = Number.NEGATIVE_INFINITY;
for (var i = 0; i < this.data.length/2; i++) {
var t = this.data[i*2];
if (t >= startTime && t <= endTime) {
var v = this.data[i*2+1];
if (v < minValue)
minValue = v;
if (v > maxValue)
maxValue = v;
}
}
return [minValue, maxValue];
},
// create a new ds that's the average of this ds's values,
// with the average sampled over the given interval,
// at every avginterval/2
createAverage: function (avginterval) {
if (avginterval <= 0)
throw "avginterval <= 0";
if (this.averageDataSet != null &&
this.averageInterval == avginterval)
{
return this.averageDataSet;
}
var newdata = [];
var time0 = this.data[0];
var val0 = 0;
var count0 = 0;
var time1 = time0 + avginterval/2;
var val1 = 0;
var count1 = 0;
var ns = this.data.length/2;
for (var i = 0; i < ns; i++) {
var t = this.data[i*2];
var v = this.data[i*2+1];
if (t > time0+avginterval) {
newdata.push(time0 + avginterval/2);
newdata.push(count0 ? (val0 / count0) : 0);
// catch up
while (time1 < t) {
time0 += avginterval/2;
time1 = time0;
}
time0 = time1;
val0 = val1;
count0 = count1;
time1 = time0 + avginterval/2;
val1 = 0;
count1 = 0;
}
val0 += v;
count0++;
if (t > time1) {
val1 += v;
count1++;
}
}
if (count0 > 0) {
newdata.push(time0 + avginterval/2);
newdata.push(val0 / count0);
}
var newds = new TimeValueDataSet(newdata, lighterColor(this.color));
newds.averageOf = this;
this.averageDataSet = newds;
this.averageInterval = avginterval;
return newds;
},
// create a new dataset with this ds's data,
// relative to otherds
createRelativeTo: function (otherds, absval) {
if (otherds == this) {
log("error, same ds");
return null;
}
for each (var s in this.relativeToSets) {
if (s.relativeTo == otherds)
return s;
}
var firstTime = this.firstTime;
var lastTime = this.lastTime;
if (otherds.firstTime > firstTime)
firstTime = otherds.firstTime;
if (otherds.lastTime < lastTime)
lastTime = otherds.lastTime;
var newdata = [];
var thisidx = this.indicesForTimeRange (firstTime, lastTime);
var otheridx = this.indicesForTimeRange (firstTime, lastTime);
var o = otheridx[0];
var ov, ov1, ov2, ot1, ot2;
for (var i = thisidx[0]; i < thisidx[1]; i++) {
var t = this.data[i*2];
var tv = this.data[i*2+1];
while (otherds.data[o*2] < t)
o++;
ot1 = otherds.data[o*2];
ov1 = otherds.data[o*2+1];
if (o < otheridx[1]) {
ot2 = otherds.data[o*2+2];
ov2 = otherds.data[o*2+3];
} else {
ot2 = ot1;
ov2 = ov1;
}
var d = (t-ot1)/(ot2-ot1);
ov = (1-d) * ov1 + d * ov2;
newdata.push(t);
//log ("i", i, "tv", tv, "ov", ov, "t", t, "ot1", ot1, "ot2", ot2, "ov1", ov1, "ov2", ov2);
//log ("i", i, "tv", tv, "ov", ov, "tv/ov", tv/ov, "ov/tv", ov/tv);
if (absval) {
newdata.push(tv-ov);
} else {
if (tv > ov)
newdata.push((tv/ov) - 1);
else
newdata.push(-((ov/tv) - 1));
}
}
var newds = new TimeValueDataSet(newdata, this.color);
newds.relativeTo = otherds;
this.relativeToSets.push(newds);
return newds;
},
};
function TimeStringDataSet(data) {
this.data = data;
}
TimeStringDataSet.prototype = {
__proto__: new TimeDataSet(),
data: null,
onDataSetChanged: null,
init: function () {
},
addString: function (time, string) {
},
removeStringAt: function (index) {
},
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,192 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is new-graph code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var GraphFormModules = [];
var GraphFormModuleCount = 0;
function GraphFormModule(userConfig) {
GraphFormModuleCount++;
this.__proto__.__proto__.constructor.call(this, "graphForm" + GraphFormModuleCount, userConfig);
}
GraphFormModule.prototype = {
__proto__: new YAHOO.widget.Module(),
imageRoot: "",
testId: null,
baseline: false,
average: false,
color: "#000000",
onLoadingDone : new YAHOO.util.CustomEvent("onloadingdone"),
onLoading : new YAHOO.util.CustomEvent("onloading"),
init: function (el, userConfig) {
var self = this;
this.__proto__.__proto__.init.call(this, el/*, userConfig*/);
this.cfg = new YAHOO.util.Config(this);
this.cfg.addProperty("testid", { suppressEvent: true });
this.cfg.addProperty("average", { suppressEvent: true });
this.cfg.addProperty("baseline", { suppressEvent: true });
if (userConfig)
this.cfg.applyConfig(userConfig, true);
var form, td, el;
form = new DIV({ class: "graphform-line" });
td = new SPAN();
/*
el = new IMG({ src: "js/img/plus.png", class: "plusminus",
onclick: function(event) { addGraphForm(); } });
td.appendChild(el);
*/
el = new IMG({ src: "js/img/minus.png", class: "plusminus",
onclick: function(event) { self.remove(); } });
td.appendChild(el);
form.appendChild(td);
td = new SPAN();
el = new DIV({ id: "whee", style: "display: inline; border: 1px solid black; height: 15; " +
"padding-right: 15; vertical-align: middle; margin: 3px;" });
this.colorDiv = el;
td.appendChild(el);
form.appendChild(td);
td = new SPAN();
el = new SELECT({ name: "testname",
class: "testname",
onchange: function(event) { self.onChangeTest(); } });
this.testSelect = el;
td.appendChild(el);
form.appendChild(td);
td = new SPAN({ style: "padding-left: 10px;"});
appendChildNodes(td, "Average:");
el = new INPUT({ name: "average",
type: "checkbox",
onchange: function(event) { self.average = event.target.checked; } });
this.averageCheckbox = el;
td.appendChild(el);
form.appendChild(td);
this.setBody (form);
var forceTestId = null;
this.average = false;
if (userConfig) {
forceTestId = this.cfg.getProperty("testid");
avg = this.cfg.getProperty("average");
baseline = this.cfg.getProperty("baseline");
if (avg == 1) {
this.averageCheckbox.checked = true;
this.average = true;
}
if (baseline == 1)
this.onBaseLineRadioClick();
}
Tinderbox.requestTestList(function (tests) {
var opts = [];
// let's sort by machine name
var sortedTests = Array.sort(tests, function (a, b) {
if (a.machine < b.machine) return -1;
if (a.machine > b.machine) return 1;
if (a.test < b.test) return -1;
if (a.test > b.test) return 1;
if (a.test_type < b.test_type) return -1;
if (a.test_type > b.test_type) return 1;
return 0;
});
for each (var test in sortedTests) {
var tstr = test.machine + " - " + test.test + " - " + test.branch;
opts.push(new OPTION({ value: test.id }, tstr));
}
replaceChildNodes(self.testSelect, opts);
if (forceTestId != null) {
self.testSelect.value = forceTestId;
} else {
self.testSelect.value = sortedTests[0].id;
}
setTimeout(function () { self.onChangeTest(forceTestId); }, 0);
self.onLoadingDone.fire();
});
GraphFormModules.push(this);
},
getQueryString: function (prefix) {
return prefix + "tid=" + this.testId + "&" + prefix + "bl=" + (this.baseline ? "1" : "0")
+ "&" + prefix + "avg=" + (this.average? "1" : "0");
},
getDumpString: function () {
return "setid=" + this.testId;
},
onChangeTest: function (forceTestId) {
this.testId = this.testSelect.value;
},
onBaseLineRadioClick: function () {
GraphFormModules.forEach(function (g) { g.baseline = false; });
this.baseline = true;
},
setColor: function (newcolor) {
this.color = newcolor;
this.colorDiv.style.backgroundColor = colorToRgbString(newcolor);
},
remove: function () {
if (GraphFormModules.length == 1)
return;
var nf = [];
for each (var f in GraphFormModules) {
if (f != this)
nf.push(f);
}
GraphFormModules = nf;
this.destroy();
},
};

View File

@@ -1,161 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is new-graph code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jeremiah Orem <oremj@oremj.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function ResizeGraph() {
}
ResizeGraph.prototype = {
margin_right: 25,
margin_bottom: 25,
resizing: false,
active: false,
element: null,
handle: null,
startX: null,
startY: null,
startHeight: null,
startWidth: null,
startTop: null,
startLeft: null,
currentDirection: '',
init: function(elem) {
this.handle = elem;
this.element = getElement(elem);
connect(this.handle,'onmousedown',this, 'mouseDownFunc');
connect(document,'onmouseup',this, 'mouseUpFunc');
connect(this.handle,'onmousemove',this, 'mouseMoveFunc');
connect(document,'onmousemove',this, 'updateElement');
},
directions: function(e) {
var pointer = e.mouse();
var graphPosition = elementPosition(this.handle);
var dimensions = elementDimensions(this.handle);
var dir = '';
if ( pointer.page.x > (graphPosition.x + dimensions.w) - this.margin_right ) {
dir= "e";
}
else if ( pointer.page.y > (graphPosition.y + dimensions.h) - this.margin_bottom ) {
dir = "s";
}
return dir;
},
draw: function(e) {
var pointer = [e.mouse().page.x, e.mouse().page.y];
var style = this.element.style;
if (this.currentDirection.indexOf('s') != -1) {
var newHeight = this.startHeight + pointer[1] - this.startY;
if (newHeight > this.margin_bottom) {
style.height = newHeight + "px";
this.element.height = newHeight;
}
}
if (this.currentDirection.indexOf('e') != -1) {
var newWidth = this.startWidth + pointer[0] - this.startX;
if (newWidth > this.margin_right) {
if (newWidth > 900) {
getElement('graph-container').style.width = (newWidth + 200) + "px";
}
style.width = newWidth + "px";
this.element.width = newWidth;
}
}
},
mouseDownFunc: function(e)
{
var dir = this.directions(e);
pointer = e.mouse();
if (dir.length > 0 ) {
this.active = true;
var dimensions = elementDimensions(this.handle);
var graphPosition = elementPosition(this.handle);
this.startTop = graphPosition.y;
this.startLeft = graphPosition.x;
this.startHeight = dimensions.h;
this.startWidth = dimensions.w;
this.startX = pointer.page.x + document.body.scrollLeft + document.documentElement.scrollLeft;
this.startY = pointer.page.y + document.body.scrollLeft + document.documentElement.scrollLeft;
this.currentDirection = dir;
e.stop();
}
},
mouseMoveFunc: function(e)
{
pointer = e.mouse();
graphPosition = elementPosition(this.handle);
dimensions = elementDimensions(this.handle);
dir = this.directions(e);
if(dir.length > 0) {
getElement(this.handle).style.cursor = dir + "-resize";
}
else {
getElement(this.handle).style.cursor = '';
}
},
updateElement: function(e)
{
if( this.active ) {
if ( ! this.resizing ) {
var style = getElement(this.handle).style;
this.resizing = true;
style.position = "relative";
}
this.draw(e);
e.stop()
return false;
}
},
finishResize: function(e,success) {
this.active = false;
this.resizing = false;
},
mouseUpFunc: function(e)
{
if(this.active && this.resizing) {
this.finishResize(e,true);
BigPerfGraph.resize();
e.stop();
}
this.active = false;
this.resizing = false;
},
};

View File

@@ -1,417 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is new-graph code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com> (Original Author)
* Alice Nodelman <anodelman@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//const getdatacgi = "getdata-fake.cgi?";
//const getdatacgi = "http://localhost:9050/getdata.cgi?";
const getdatacgi = "getdata.cgi?"
function checkErrorReturn(obj) {
if (!obj || obj.resultcode != 0) {
alert ("Error: " + (obj ? (obj.error + "(" + obj.resultcode + ")") : "(nil)"));
return false;
}
return true;
}
function TinderboxData() {
this.onTestListAvailable = new YAHOO.util.CustomEvent("testlistavailable");
this.onDataSetAvailable = new YAHOO.util.CustomEvent("datasetavailable");
this.testList = null;
this.testData = {};
}
TinderboxData.prototype = {
testList: null,
testData: null,
onTestListAvailable: null,
onDataSetAvailable: null,
defaultLoadRange: null,
raw: 0,
init: function () {
var self = this;
//netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")
loadJSONDoc(getdatacgi + "type=continuous")
.addCallbacks(
function (obj) {
if (!checkErrorReturn(obj)) return;
self.testList = obj.results;
//log("default test list" + self.testList);
self.onTestListAvailable.fire(self.testList);
},
function () {alert ("Error talking to " + getdatacgi + ""); });
},
requestTestList: function (callback) {
//log("requestTestList default");
var self = this;
if (this.testList != null) {
callback.call (window, this.testList);
} else {
var cb =
function (type, args, obj) {
self.onTestListAvailable.unsubscribe(cb, obj);
obj.call (window, args[0]);
};
this.onTestListAvailable.subscribe (cb, callback);
}
},
// arg1 = startTime, arg2 = endTime, arg3 = callback
// arg1 = callback, arg2/arg3 == null
requestDataSetFor: function (testId, arg1, arg2, arg3) {
var self = this;
var startTime = arg1;
var endTime = arg2;
var callback = arg3;
if (arg1 && arg2 == null && arg3 == null) {
callback = arg1;
if (this.defaultLoadRange) {
startTime = this.defaultLoadRange[0];
endTime = this.defaultLoadRange[1];
//log ("load range using default", startTime, endTime);
} else {
startTime = null;
endTime = null;
}
}
if (testId in this.testData) {
var ds = this.testData[testId];
//log ("Can maybe use cached?");
if ((ds.requestedFirstTime == null && ds.requestedLastTime == null) ||
(ds.requestedFirstTime <= startTime &&
ds.requestedLastTime >= endTime))
{
//log ("Using cached ds");
callback.call (window, testId, ds);
return;
}
// this can be optimized, if we request just the bookend bits,
// but that's overkill
if (ds.firstTime < startTime)
startTime = ds.firstTime;
if (ds.lastTime > endTime)
endTime = ds.lastTime;
}
var cb =
function (type, args, obj) {
if (args[0] != testId ||
args[2] > startTime ||
args[3] < endTime)
{
// not useful for us; there's another
// outstanding request for our time range, so wait for that
return;
}
self.onDataSetAvailable.unsubscribe(cb, obj);
obj.call (window, args[0], args[1]);
};
this.onDataSetAvailable.subscribe (cb, callback);
//netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")
var reqstr = getdatacgi + "setid=" + testId;
if (startTime)
reqstr += "&starttime=" + startTime;
if (endTime)
reqstr += "&endtime=" + endTime;
//raw data is the extra_data column
if (this.raw)
reqstr += "&raw=1";
//log (reqstr);
loadJSONDoc(reqstr)
.addCallbacks(
function (obj) {
if (!checkErrorReturn(obj)) return;
var ds = new TimeValueDataSet(obj.results);
//this is the the case of a discrete graph - where the entire test run is always requested
//so the start and end points are the first and last entries in the returned data set
if (!startTime && !endTime) {
startTime = ds.data[0];
endTime = ds.data[ds.data.length -2];
}
ds.requestedFirstTime = startTime;
ds.requestedLastTime = endTime;
self.testData[testId] = ds;
if (obj.annotations)
ds.annotations = new TimeStringDataSet(obj.annotations);
if (obj.baselines)
ds.baselines = obj.baselines;
if (obj.rawdata)
ds.rawdata = obj.rawdata;
if (obj.stats)
ds.stats = obj.stats;
self.onDataSetAvailable.fire(testId, ds, startTime, endTime);
},
function (obj) {alert ("Error talking to " + getdatacgi + " (" + obj + ")"); log (obj.stack); });
},
clearValueDataSets: function () {
//log ("clearvalueDatasets");
this.tinderboxTestData = {};
},
};
function DiscreteTinderboxData() {
};
DiscreteTinderboxData.prototype = {
__proto__: new TinderboxData(),
init: function () {
},
requestTestList: function (limitDate, branch, machine, testname, callback) {
var self = this;
//netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")
var limiters = "";
var tDate = 0;
if (limitDate != null) {
tDate = new Date().getTime();
tDate -= limitDate * 86400 * 1000;
//log ("returning test lists greater than this date" + (new Date(tDate)).toGMTString());
//TODO hack hack hack
tDate = Math.floor(tDate/1000)
}
if (branch != null) limiters += "&branch=" + branch;
if (machine != null) limiters += "&machine=" + machine;
if (testname != null) limiters += "&test=" + testname;
//log("drequestTestList: " + getdatacgi + "type=discrete&datelimit=" + tDate + limiters);
loadJSONDoc(getdatacgi + "type=discrete&datelimit=" + tDate + limiters)
.addCallbacks(
function (obj) {
if (!checkErrorReturn(obj)) return;
self.testList = obj.results;
//log ("testlist: " + self.testList);
callback.call(window, self.testList);
},
function () {alert ("requestTestList: Error talking to " + getdatacgi + ""); });
},
requestSearchList: function (branch, machine, testname, callback) {
var self = this;
limiters = "";
if (branch != null) limiters += "&branch=" + branch;
if (machine != null) limiters += "&machine=" + machine;
if (testname != null) limiters += "&test=" + testname;
//log(getdatacgi + "getlist=1&type=discrete" + limiters);
loadJSONDoc(getdatacgi + "getlist=1&type=discrete" + limiters)
.addCallbacks(
function (obj) {
if (!checkErrorReturn(obj)) return;
callback.call(window, obj.results);
},
function () {alert ("requestSearchList: Error talking to " + getdatacgi); });
},
};
function ExtraDataTinderboxData() {
};
ExtraDataTinderboxData.prototype = {
__proto__: new TinderboxData(),
init: function () {
},
requestTestList: function (limitDate, branch, machine, testname, callback) {
var self = this;
//netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")
var limiters = "";
var tDate = 0;
if (limitDate != null) {
tDate = new Date().getTime();
tDate -= limitDate * 86400 * 1000;
//log ("returning test lists greater than this date" + (new Date(tDate)).toGMTString());
//TODO hack hack hack
tDate = Math.floor(tDate/1000)
}
if (branch != null) limiters += "&branch=" + branch;
if (machine != null) limiters += "&machine=" + machine;
if (testname != null) limiters += "&test=" + testname;
//log("drequestTestList: " + getdatacgi + "type=discrete&datelimit=" + tDate + limiters);
loadJSONDoc(getdatacgi + "type=discrete&graphby=bydata&datelimit=" + tDate + limiters)
.addCallbacks(
function (obj) {
if (!checkErrorReturn(obj)) return;
self.testList = obj.results;
//log ("testlist: " + self.testList);
callback.call(window, self.testList);
},
function () {alert ("requestTestList: Error talking to " + getdatacgi + ""); });
},
requestSearchList: function (branch, machine, testname, callback) {
var self = this;
limiters = "";
if (branch != null) limiters += "&branch=" + branch;
if (machine != null) limiters += "&machine=" + machine;
if (testname != null) limiters += "&test=" + testname;
//log(getdatacgi + "getlist=1&type=discrete" + limiters);
loadJSONDoc(getdatacgi + "getlist=1&type=discrete" + limiters)
.addCallbacks(
function (obj) {
if (!checkErrorReturn(obj)) return;
callback.call(window, obj.results);
},
function () {alert ("requestSearchList: Error talking to " + getdatacgi); });
},
// arg1 = startTime, arg2 = endTime, arg3 = callback
// arg1 = callback, arg2/arg3 == null
requestDataSetFor: function (testId, arg1, arg2, arg3) {
var self = this;
var startTime = arg1;
var endTime = arg2;
var callback = arg3;
var tempArray = new Array();
tempArray = testId.split("_",2);
testId = tempArray[0];
var extradata = tempArray[1];
if (arg1 && arg2 == null && arg3 == null) {
callback = arg1;
if (this.defaultLoadRange) {
startTime = this.defaultLoadRange[0];
endTime = this.defaultLoadRange[1];
//log ("load range using default", startTime, endTime);
} else {
startTime = null;
endTime = null;
}
}
if (testId in this.testData) {
var ds = this.testData[testId];
//log ("Can maybe use cached?");
if ((ds.requestedFirstTime == null && ds.requestedLastTime == null) ||
(ds.requestedFirstTime <= startTime &&
ds.requestedLastTime >= endTime))
{
//log ("Using cached ds");
callback.call (window, testId, ds);
return;
}
// this can be optimized, if we request just the bookend bits,
// but that's overkill
if (ds.firstTime < startTime)
startTime = ds.firstTime;
if (ds.lastTime > endTime)
endTime = ds.lastTime;
}
var cb =
function (type, args, obj) {
if (args[0] != testId ||
args[2] > startTime ||
args[3] < endTime)
{
// not useful for us; there's another
// outstanding request for our time range, so wait for that
return;
}
self.onDataSetAvailable.unsubscribe(cb, obj);
obj.call (window, args[0], args[1]);
};
this.onDataSetAvailable.subscribe (cb, callback);
//netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")
var reqstr = getdatacgi + "setid=" + testId;
if (startTime)
reqstr += "&starttime=" + startTime;
if (endTime)
reqstr += "&endtime=" + endTime;
//raw data is the extra_data column
if (this.raw)
reqstr += "&raw=1";
reqstr += "&graphby=bydata";
reqstr += "&extradata=" + extradata;
//log (reqstr);
loadJSONDoc(reqstr)
.addCallbacks(
function (obj) {
if (!checkErrorReturn(obj)) return;
var ds = new TimeValueDataSet(obj.results);
//this is the the case of a discrete graph - where the entire test run is always requested
//so the start and end points are the first and last entries in the returned data set
if (!startTime && !endTime) {
startTime = ds.data[0];
endTime = ds.data[ds.data.length -2];
}
ds.requestedFirstTime = startTime;
ds.requestedLastTime = endTime;
self.testData[testId] = ds;
if (obj.annotations)
ds.annotations = new TimeStringDataSet(obj.annotations);
if (obj.baselines)
ds.baselines = obj.baselines;
if (obj.rawdata)
ds.rawdata = obj.rawdata;
if (obj.stats)
ds.stats = obj.stats;
self.onDataSetAvailable.fire(testId, ds, startTime, endTime);
},
function (obj) {alert ("Error talking to " + getdatacgi + " (" + obj + ")"); log (obj.stack); });
},
};

View File

@@ -1,381 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is new-graph code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com> (Original Author)
* Alice Nodelman <anodelman@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var GraphFormModules = [];
var GraphFormModuleCount = 0;
function DiscreteGraphFormModule(userConfig, userName) {
GraphFormModuleCount++;
//log("userName: " + userName);
//this.__proto__.__proto__.constructor.call(this, "graphForm" + GraphFormModuleCount, userConfig, userName);
this.init("graphForm" + GraphFormModuleCount, userConfig, userName);
}
DiscreteGraphFormModule.prototype = {
__proto__: new YAHOO.widget.Module(),
imageRoot: "",
testId: null,
testIds: null,
testText: "",
baseline: false,
average: false,
name: "",
limitDays: null,
isLimit: null,
onLoadingDone : new YAHOO.util.CustomEvent("onloadingdone"),
onLoading : new YAHOO.util.CustomEvent("onloading"),
addedInitialInfo : new YAHOO.util.CustomEvent("addedinitialinfo"),
init: function (el, userConfig, userName) {
var self = this;
//log("el " + el + " userConfig " + userConfig + " userName " + userName);
this.__proto__.__proto__.init.call(this, el/*, userConfig*/);
this.cfg = new YAHOO.util.Config(this);
this.cfg.addProperty("testid", { suppressEvent: true });
this.cfg.addProperty("average", { suppressEvent: true });
this.cfg.addProperty("baseline", { suppressEvent: true });
if (userConfig)
this.cfg.applyConfig(userConfig, true);
var form, td, el;
var tbl;
var tbl_row;
var tbl_col;
tbl = new TABLE({});
tbl_row = new TR({});
tbl_col = new TD({colspan: 2});
appendChildNodes(tbl_col,"Limit selection list by:");
appendChildNodes(tbl_row, tbl_col);
tbl_col = new TD({});
appendChildNodes(tbl_col,"Choose test(s) to graph:");
appendChildNodes(tbl_row, tbl_col);
tbl.appendChild(tbl_row);
tbl_row = new TR({});
form = new DIV({ class: "graphform-line" });
tbl_col = new TD({});
el = new INPUT({ name: "dataload" + GraphFormModules.length,
id: "all-days-radio",
type: "radio",
checked: 1,
onchange: function(event) { self.update(null, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value); } });
tbl_col.appendChild(el);
appendChildNodes(tbl_col, "all tests");
tbl_col.appendChild(new DIV({}));
el = new INPUT({ name: "dataload" + GraphFormModules.length,
type: "radio",
onchange: function(event) { self.update(self.limitDays.value, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value);} });
this.isLimit = el;
tbl_col.appendChild(el);
appendChildNodes(tbl_col, "previous ");
el = new INPUT({ name: "load-days-entry",
id: "load-days-entry",
type: "text",
size: "3",
value: "5",
onchange: function(event) { if (self.isLimit.checked) {
self.update(self.limitDays.value, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value);} } });
this.limitDays = el;
tbl_col.appendChild(el);
appendChildNodes(tbl_col, " days");
tbl_row.appendChild(tbl_col);
tbl_col = new TD({});
appendChildNodes(tbl_col, "Branch: ");
appendChildNodes(tbl_col, new BR({}));
el = new SELECT({ name: "branchname",
class: "other",
size: 5,
onchange: function(event) { if (self.isLimit.checked) {
self.update(self.limitDays.value, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value);}
else self.update(null, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value); } });
this.branchSelect = el;
Tinderbox.requestSearchList(1, null, null, function (list) {
var opts = [];
opts.push(new OPTION({value: null, selected: true}, "all"));
for each (var listvalue in list) {
opts.push(new OPTION({ value: listvalue.value}, listvalue.value));
}
replaceChildNodes(self.branchSelect, opts);
});
tbl_col.appendChild(el);
tbl_row.appendChild(tbl_col);
tbl_col = new TD({rowspan: 2, colspan: 2});
span = new SPAN({id: "listname"});
appendChildNodes(tbl_col, span);
appendChildNodes(tbl_col, new BR({}));
el = new SELECT({ name: "testname",
class: "testname",
multiple: true,
center: true,
size: 20,
onchange: function(event) { self.onChangeTest(); } });
this.testSelect = el;
tbl_col.appendChild(el);
tbl_row.appendChild(tbl_col);
tbl.appendChild(tbl_row);
tbl_row = new TR({});
tbl_col = new TD({});
appendChildNodes(tbl_col, "Machine: ");
appendChildNodes(tbl_col, new BR({}));
el = new SELECT({ name: "machinename",
class: "other",
size: 5,
onchange: function(event) { if (self.isLimit.checked) {
self.update(self.limitDays.value, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value);}
else self.update(null, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value); } });
this.machineSelect = el;
Tinderbox.requestSearchList(null, 1, null, function (list) {
var opts = [];
opts.push(new OPTION({value: null, selected: true}, "all"));
for each (var listvalue in list) {
opts.push(new OPTION({ value: listvalue.value}, listvalue.value));
}
replaceChildNodes(self.machineSelect, opts);
});
tbl_col.appendChild(el);
tbl_row.appendChild(tbl_col);
tbl_col = new TD({});
appendChildNodes(tbl_col, "Test name: ");
appendChildNodes(tbl_col, new BR({}));
el = new SELECT({ name: "testtypename",
class: "other",
size: 5,
onchange: function(event) { if (self.isLimit.checked) {
self.update(self.limitDays.value, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value);}
else self.update(null, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value); } });
this.testtypeSelect = el;
var forceTestIds = null;
this.average = false;
if (userConfig) {
forceTestIds = userConfig;
}
//log ("userName: " + userName);
Tinderbox.requestSearchList(null, null, 1, function (list) {
var opts = [];
//opts.push(new OPTION({value: null, selected: true}, "all"));
for each (var listvalue in list) {
if ((userName) && (userName == listvalue.value)) {
opts.push(new OPTION({ value: listvalue.value, selected : true}, listvalue.value));
}
else {
opts.push(new OPTION({ value: listvalue.value}, listvalue.value));
}
}
replaceChildNodes(self.testtypeSelect, opts);
if (forceTestIds == null) {
self.testtypeSelect.options[0].selected = true;
self.update(null, null, null, self.testtypeSelect.value, forceTestIds);
}
else {
self.update(null, null, null, userName, forceTestIds);
}
});
tbl_col.appendChild(el);
tbl_row.appendChild(tbl_col);
/*
tbl_col = new TD({rowspan: 2, colspan: 2});
el = new SELECT({ name: "testname",
class: "testname",
multiple: true,
size: 20,
onchange: function(event) { self.onChangeTest(); } });
this.testSelect = el;
tbl_col.appendChild(el);
tbl_row.appendChild(tbl_col);
*/
tbl.appendChild(tbl_row);
form.appendChild(tbl);
this.setBody (form);
/*
var forceTestIds = null;
this.average = false;
if (userConfig) {
forceTestIds = userConfig;
}
*/
//self.update(null, null, null, null, forceTestIds);
GraphFormModules.push(this);
},
getQueryString: function (prefix) {
var qstring = '';
ctr = 1;
for each (var opt in this.testSelect.options) {
if (opt.selected) {
prefixed = prefix + ctr;
qstring += "&" + prefixed + "tid=" + opt.value + "&" + prefixed + "bl=" + (this.baseline ? "1" : "0")
+ "&" + prefixed + "avg=" + (this.average? "1" : "0");
ctr++
}
}
return qstring;
},
getDumpString: function () {
var prefix = '';
var dstring = '';
for each (var opt in this.testSelect.options) {
if (opt.selected) {
dstring += prefix + "setid=" + opt.value;
prefix = "&";
}
}
return dstring;
},
onChangeTest: function (forceTestIds) {
this.testId = this.testSelect.value;
//log("setting testId: " + this.testId);
this.testIds = [];
for each (var opt in this.testSelect.options) {
if (opt.selected) {
//log("opt: " + opt.value);
this.testIds.push([opt.value, opt.text]);
}
}
//log("testIDs: " + this.testIds);
//log(this.testSelect.options[this.testSelect.selectedIndex].text);
this.testText = this.testSelect.options[this.testSelect.selectedIndex];
this.addedInitialInfo.fire();
this.name = this.testtypeSelect.value;
},
onBaseLineRadioClick: function () {
GraphFormModules.forEach(function (g) { g.baseline = false; });
this.baseline = true;
},
remove: function () {
var nf = [];
for each (var f in GraphFormModules) {
if (f != this)
nf.push(f);
}
GraphFormModules = nf;
this.destroy();
},
update: function (limitD, branch, machine, testname, forceTestIds) {
var self = this;
this.onLoading.fire("updating test list");
//log ("attempting to update graphformmodule, forceTestIds " + forceTestIds);
Tinderbox.requestTestList(limitD, branch, machine, testname, function (tests) {
var opts = [];
var branch_opts = [];
if (tests == '') {
log("empty test list");
self.onLoadingDone.fire();
replaceChildNodes(self.testSelect, null);
btn = getElement("graphbutton");
btn.disabled = true;
return;
}
// let's sort by machine name
var sortedTests = Array.sort(tests, function (a, b) {
if (a.machine < b.machine) return -1;
if (a.machine > b.machine) return 1;
if (a.test < b.test) return -1;
if (a.test > b.test) return 1;
if (a.test_type < b.test_type) return -1;
if (a.test_type > b.test_type) return 1;
if (a.date < b.date) return -1;
if (a.date > b.date) return 1;
return 0;
});
for each (var test in sortedTests) {
var d = new Date(test.date*1000);
var s1 = (d.getHours() < 10 ? "0" : "") + d.getHours() + (d.getMinutes() < 10 ? ":0" : ":") + d.getMinutes() +
//(d.getSeconds() < 10 ? ":0" : ":") + d.getSeconds() +
" " + (d.getDate() < 10 ? "0" : "") + d.getDate();
s1 += "/" + MONTH_ABBREV[d.getMonth()] + "/" + (d.getFullYear() -2000 < 10 ? "0" : "") + (d.getFullYear() - 2000);
//(d.getYear() + 1900);
var padstr = "--------------------";
var tstr = "" + //test.test + padstr.substr(0, 20-test.test.length) +
test.branch.toString() + padstr.substr(0, 6-test.branch.toString().length) +
"-" + test.machine + padstr.substr(0, 10-test.machine.length) +
"-" + s1;
startSelected = false;
if (forceTestIds != null) {
if ((forceTestIds == test.id) || (forceTestIds.indexOf(Number(test.id)) > -1)) {
startSelected = true;
}
}
if (startSelected) {
//log("starting with an initial selection");
opts.push(new OPTION({ value: test.id, selected: true}, tstr));
}
else {
opts.push(new OPTION({ value: test.id}, tstr));
}
}
replaceChildNodes(self.testSelect, opts);
if (forceTestIds == null) {
self.testSelect.options[0].selected = true;
//self.testSelect.value = sortedTests[0].id;
}
replaceChildNodes("listname", null);
appendChildNodes("listname","Select from " + testname + ":");
btn = getElement("graphbutton");
btn.disabled = false;
setTimeout(function () { self.onChangeTest(forceTestIds); }, 0);
self.onLoadingDone.fire();
});
},
};

View File

@@ -1,376 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is new-graph code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com> (Original Author)
* Alice Nodelman <anodelman@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var GraphFormModules = [];
var GraphFormModuleCount = 0;
function ExtraDataGraphFormModule(userConfig, userName) {
GraphFormModuleCount++;
//log("userName: " + userName);
//this.__proto__.__proto__.constructor.call(this, "graphForm" + GraphFormModuleCount, userConfig, userName);
this.init("graphForm" + GraphFormModuleCount, userConfig, userName);
}
ExtraDataGraphFormModule.prototype = {
__proto__: new YAHOO.widget.Module(),
imageRoot: "",
testId: null,
testIds: null,
testText: "",
baseline: false,
average: false,
name: "",
limitDays: null,
isLimit: null,
onLoadingDone : new YAHOO.util.CustomEvent("onloadingdone"),
onLoading : new YAHOO.util.CustomEvent("onloading"),
addedInitialInfo : new YAHOO.util.CustomEvent("addedinitialinfo"),
init: function (el, userConfig, userName) {
var self = this;
//log("el " + el + " userConfig " + userConfig + " userName " + userName);
this.__proto__.__proto__.init.call(this, el/*, userConfig*/);
this.cfg = new YAHOO.util.Config(this);
this.cfg.addProperty("testid", { suppressEvent: true });
this.cfg.addProperty("average", { suppressEvent: true });
this.cfg.addProperty("baseline", { suppressEvent: true });
if (userConfig)
this.cfg.applyConfig(userConfig, true);
var form, td, el;
var tbl;
var tbl_row;
var tbl_col;
tbl = new TABLE({});
tbl_row = new TR({});
tbl_col = new TD({colspan: 2});
appendChildNodes(tbl_col,"Limit selection list by:");
appendChildNodes(tbl_row, tbl_col);
tbl_col = new TD({});
appendChildNodes(tbl_col,"Choose test(s) to graph:");
appendChildNodes(tbl_row, tbl_col);
tbl.appendChild(tbl_row);
tbl_row = new TR({});
form = new DIV({ class: "graphform-line" });
tbl_col = new TD({});
el = new INPUT({ name: "dataload" + GraphFormModules.length,
id: "all-days-radio",
type: "radio",
checked: 1,
onchange: function(event) { self.update(null, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value); } });
tbl_col.appendChild(el);
appendChildNodes(tbl_col, "all tests");
tbl_col.appendChild(new DIV({}));
el = new INPUT({ name: "dataload" + GraphFormModules.length,
type: "radio",
onchange: function(event) { self.update(self.limitDays.value, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value);} });
this.isLimit = el;
tbl_col.appendChild(el);
appendChildNodes(tbl_col, "previous ");
el = new INPUT({ name: "load-days-entry",
id: "load-days-entry",
type: "text",
size: "3",
value: "5",
onchange: function(event) { if (self.isLimit.checked) {
self.update(self.limitDays.value, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value);} } });
this.limitDays = el;
tbl_col.appendChild(el);
appendChildNodes(tbl_col, " days");
tbl_row.appendChild(tbl_col);
tbl_col = new TD({});
appendChildNodes(tbl_col, "Branch: ");
appendChildNodes(tbl_col, new BR({}));
el = new SELECT({ name: "branchname",
class: "other",
size: 5,
onchange: function(event) { if (self.isLimit.checked) {
self.update(self.limitDays.value, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value);}
else self.update(null, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value); } });
this.branchSelect = el;
Tinderbox.requestSearchList(1, null, null, function (list) {
var opts = [];
opts.push(new OPTION({value: null, selected: true}, "all"));
for each (var listvalue in list) {
opts.push(new OPTION({ value: listvalue.value}, listvalue.value));
}
replaceChildNodes(self.branchSelect, opts);
});
tbl_col.appendChild(el);
tbl_row.appendChild(tbl_col);
tbl_col = new TD({rowspan: 2, colspan: 2});
span = new SPAN({id: "listname"});
appendChildNodes(tbl_col, span);
appendChildNodes(tbl_col, new BR({}));
el = new SELECT({ name: "testname",
class: "testname",
multiple: true,
center: true,
size: 20,
onchange: function(event) { self.onChangeTest(); } });
this.testSelect = el;
tbl_col.appendChild(el);
tbl_row.appendChild(tbl_col);
tbl.appendChild(tbl_row);
tbl_row = new TR({});
tbl_col = new TD({});
appendChildNodes(tbl_col, "Machine: ");
appendChildNodes(tbl_col, new BR({}));
el = new SELECT({ name: "machinename",
class: "other",
size: 5,
onchange: function(event) { if (self.isLimit.checked) {
self.update(self.limitDays.value, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value);}
else self.update(null, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value); } });
this.machineSelect = el;
Tinderbox.requestSearchList(null, 1, null, function (list) {
var opts = [];
opts.push(new OPTION({value: null, selected: true}, "all"));
for each (var listvalue in list) {
opts.push(new OPTION({ value: listvalue.value}, listvalue.value));
}
replaceChildNodes(self.machineSelect, opts);
});
tbl_col.appendChild(el);
tbl_row.appendChild(tbl_col);
tbl_col = new TD({});
appendChildNodes(tbl_col, "Test name: ");
appendChildNodes(tbl_col, new BR({}));
el = new SELECT({ name: "testtypename",
class: "other",
size: 5,
onchange: function(event) { if (self.isLimit.checked) {
self.update(self.limitDays.value, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value);}
else self.update(null, self.branchSelect.value, self.machineSelect.value, self.testtypeSelect.value); } });
this.testtypeSelect = el;
var forceTestIds = null;
this.average = false;
if (userConfig) {
forceTestIds = userConfig;
}
//log ("userName: " + userName);
Tinderbox.requestSearchList(null, null, 1, function (list) {
var opts = [];
//opts.push(new OPTION({value: null, selected: true}, "all"));
for each (var listvalue in list) {
if ((userName) && (userName == listvalue.value)) {
opts.push(new OPTION({ value: listvalue.value, selected : true}, listvalue.value));
}
else {
opts.push(new OPTION({ value: listvalue.value}, listvalue.value));
}
}
replaceChildNodes(self.testtypeSelect, opts);
if (forceTestIds == null) {
self.testtypeSelect.options[0].selected = true;
self.update(null, null, null, self.testtypeSelect.value, forceTestIds);
}
else {
self.update(null, null, null, userName, forceTestIds);
}
});
tbl_col.appendChild(el);
tbl_row.appendChild(tbl_col);
/*
tbl_col = new TD({rowspan: 2, colspan: 2});
el = new SELECT({ name: "testname",
class: "testname",
multiple: true,
size: 20,
onchange: function(event) { self.onChangeTest(); } });
this.testSelect = el;
tbl_col.appendChild(el);
tbl_row.appendChild(tbl_col);
*/
tbl.appendChild(tbl_row);
form.appendChild(tbl);
this.setBody (form);
/*
var forceTestIds = null;
this.average = false;
if (userConfig) {
forceTestIds = userConfig;
}
*/
//self.update(null, null, null, null, forceTestIds);
GraphFormModules.push(this);
},
getQueryString: function (prefix) {
var qstring = '';
ctr = 1;
for each (var opt in this.testSelect.options) {
if (opt.selected) {
prefixed = prefix + ctr;
qstring += "&" + prefixed + "tid=" + opt.value + "&" + prefixed + "bl=" + (this.baseline ? "1" : "0")
+ "&" + prefixed + "avg=" + (this.average? "1" : "0");
ctr++
}
}
return qstring;
},
getDumpString: function () {
var prefix = '';
var dstring = '';
for each (var opt in this.testSelect.options) {
if (opt.selected) {
dstring += prefix + "setid=" + opt.value;
prefix = "&";
}
}
return dstring;
},
onChangeTest: function (forceTestIds) {
this.testId = this.testSelect.value;
//log("setting testId: " + this.testId);
this.testIds = [];
for each (var opt in this.testSelect.options) {
if (opt.selected) {
//log("opt: " + opt.value);
this.testIds.push([opt.value, opt.text]);
}
}
//log("testIDs: " + this.testIds);
//log(this.testSelect.options[this.testSelect.selectedIndex].text);
this.testText = this.testSelect.options[this.testSelect.selectedIndex];
this.addedInitialInfo.fire();
this.name = this.testtypeSelect.value;
},
onBaseLineRadioClick: function () {
GraphFormModules.forEach(function (g) { g.baseline = false; });
this.baseline = true;
},
remove: function () {
var nf = [];
for each (var f in GraphFormModules) {
if (f != this)
nf.push(f);
}
GraphFormModules = nf;
this.destroy();
},
update: function (limitD, branch, machine, testname, forceTestIds) {
var self = this;
this.onLoading.fire("updating test list");
//log ("attempting to update graphformmodule, forceTestIds " + forceTestIds);
Tinderbox.requestTestList(limitD, branch, machine, testname, function (tests) {
var opts = [];
var branch_opts = [];
if (tests == '') {
log("empty test list");
self.onLoadingDone.fire();
replaceChildNodes(self.testSelect, null);
btn = getElement("graphbutton");
btn.disabled = true;
return;
}
// let's sort by machine name
var sortedTests = Array.sort(tests, function (a, b) {
if (a.machine < b.machine) return -1;
if (a.machine > b.machine) return 1;
if (a.test < b.test) return -1;
if (a.test > b.test) return 1;
if (a.test_type < b.test_type) return -1;
if (a.test_type > b.test_type) return 1;
if (a.data < b.data) return -1;
if (a.data > b.data) return 1;
return 0;
});
for each (var test in sortedTests) {
var s1 = test.data;
var padstr = "--------------------";
var tstr = "" + //test.test + padstr.substr(0, 20-test.test.length) +
test.branch.toString() + padstr.substr(0, 6-test.branch.toString().length) +
"-" + test.machine + padstr.substr(0, 10-test.machine.length) +
"-" + s1;
startSelected = false;
if (forceTestIds != null) {
if ((forceTestIds == test.id) || (forceTestIds.indexOf(Number(test.id)) > -1)) {
startSelected = true;
}
}
if (startSelected) {
//log("starting with an initial selection");
opts.push(new OPTION({ value: test.id + "_" + test.data, selected: true}, tstr));
}
else {
opts.push(new OPTION({ value: test.id + "_" + test.data}, tstr));
}
}
replaceChildNodes(self.testSelect, opts);
if (forceTestIds == null) {
self.testSelect.options[0].selected = true;
//self.testSelect.value = sortedTests[0].id;
}
replaceChildNodes("listname", null);
appendChildNodes("listname","Select from " + testname + ":");
btn = getElement("graphbutton");
btn.disabled = false;
setTimeout(function () { self.onChangeTest(forceTestIds); }, 0);
self.onLoadingDone.fire();
});
},
};

View File

@@ -1,87 +0,0 @@
.graphconfig {
background-color: #cccccc;
-moz-border-radius: 10px 0 0 10px;
padding: 10px;
width: 15em;
}
.dgraphconfig {
background-color: #cccccc;
-moz-border-radius: 10px 0 0 10px;
padding: 10px;
width: 7em;
}
.graphconfig-list {
background-color: #cccccc;
-moz-border-radius: 0 10px 10px 0;
padding: 10px;
}
/* Yuck */
.graphform-line, .baseline {
margin-bottom: 5px;
}
.graphform-first-span {
/* font-weight: bold; */
}
/*
#graphforms div .bd .graphform-line .graphform-first-span:after {
content: "For ";
}
.module + .module .bd .graphform-line .graphform-first-span:after {
content: "and " ! important;
}
*/
select.tinderbox, select.testname {
font-family: monospace;
width: 350px;
}
select.other {
font-family: monospace;
width: 225px;
}
.plusminus {
padding: 3px;
vertical-align: middle;
}
.plusminus:hover {
background: #999;
}
.plusminushidden {
width: 20px;
height: 20px;
visibility: hidden;
}
.y-axis-label {
font-family: Tahoma, Verdana, Vera Sans, "Bitstream Vera Sans", Arial, Helvetica, sans-serif;
font-size: 75%;
vertical-align: middle;
text-align: right;
}
.x-axis-label {
font-family: Tahoma, Verdana, Vera Sans, "Bitstream Vera Sans", Arial, Helvetica, sans-serif;
font-size: 75%;
padding: 0px;
vertical-align: top;
text-align: center;
}
.status {
color: blue;
}
/* debug */
/*div { border: 1px solid blue; }*/

View File

@@ -1,661 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is new-graph code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com> (Original Author)
* Alice Nodelman <anodelman@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// all times are in seconds
const ONE_HOUR_SECONDS = 60*60;
const ONE_DAY_SECONDS = 24*ONE_HOUR_SECONDS;
const ONE_WEEK_SECONDS = 7*ONE_DAY_SECONDS;
const ONE_YEAR_SECONDS = 365*ONE_DAY_SECONDS; // leap years whatever.
const MONTH_ABBREV = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
const CONTINUOUS_GRAPH = 0;
const DISCRETE_GRAPH = 1;
const DATA_GRAPH = 2;
const bonsaicgi = "bonsaibouncer.cgi";
// more days than this and we'll force user confirmation for the bonsai query
const bonsaiNoForceDays = 90;
// the default average interval
var gAverageInterval = 3*ONE_HOUR_SECONDS;
var gCurrentLoadRange = null;
var gForceBonsai = false;
var Tinderbox;
var BigPerfGraph;
var SmallPerfGraph;
var Bonsai;
var graphType;
function loadingDone(graphTypePref) {
//createLoggingPane(true);
graphType = graphTypePref;
if (graphType == CONTINUOUS_GRAPH) {
Tinderbox = new TinderboxData();
SmallPerfGraph = new CalendarTimeGraph("smallgraph");
BigPerfGraph = new CalendarTimeGraph("graph");
onDataLoadChanged();
} else if (graphType == DATA_GRAPH) {
Tinderbox = new ExtraDataTinderboxData();
SmallPerfGraph = new CalendarTimeGraph("smallgraph");
BigPerfGraph = new CalendarTimeGraph("graph");
}
else {
Tinderbox = new DiscreteTinderboxData();
Tinderbox.raw = 1;
SmallPerfGraph = new DiscreteGraph("smallgraph");
BigPerfGraph = new DiscreteGraph("graph");
onDiscreteDataLoadChanged();
}
Tinderbox.init();
if (BonsaiService)
Bonsai = new BonsaiService();
SmallPerfGraph.yLabelHeight = 20;
SmallPerfGraph.setSelectionType("range");
BigPerfGraph.setSelectionType("cursor");
BigPerfGraph.setCursorType("free");
SmallPerfGraph.onSelectionChanged.
subscribe (function (type, args, obj) {
log ("selchanged");
if (args[0] == "range") {
if (args[1] && args[2]) {
var t1 = args[1];
var t2 = args[2];
var foundIndexes = [];
// make sure that there are at least two points
// on at least one graph for this
var foundPoints = false;
var dss = BigPerfGraph.dataSets;
for (var i = 0; i < dss.length; i++) {
var idcs = dss[i].indicesForTimeRange(t1, t2);
if (idcs[1] - idcs[0] > 1) {
foundPoints = true;
break;
}
foundIndexes.push(idcs);
}
if (!foundPoints) {
// we didn't find at least two points in at least
// one graph; so munge the time numbers until we do.
log("Orig t1 " + t1 + " t2 " + t2);
for (var i = 0; i < dss.length; i++) {
if (foundIndexes[i][0] > 0) {
t1 = Math.min(dss[i].data[(foundIndexes[i][0] - 1) * 2], t1);
} else if (foundIndexes[i][1]+1 < (ds.data.length/2)) {
t2 = Math.max(dss[i].data[(foundIndexes[i][1] + 1) * 2], t2);
}
}
log("Fixed t1 " + t1 + " t2 " + t2);
}
BigPerfGraph.setTimeRange (t1, t2);
} else {
BigPerfGraph.setTimeRange (SmallPerfGraph.startTime, SmallPerfGraph.endTime);
}
BigPerfGraph.autoScale();
BigPerfGraph.redraw();
}
updateLinkToThis();
updateDumpToCsv();
});
if (graphType == CONTINUOUS_GRAPH) {
BigPerfGraph.onCursorMoved.
subscribe (function (type, args, obj) {
var time = args[0];
var val = args[1];
if (time != null && val != null) {
// cheat
showStatus("Date: " + formatTime(time) + " Value: " + val.toFixed(2));
} else {
showStatus(null);
}
});
BigPerfGraph.onNewGraph.
subscribe (function(type, args, obj) {
if (args[0].length >= GraphFormModules.length) {
clearLoadingAnimation();
}
});
}
else if (graphType == DATA_GRAPH) {
BigPerfGraph.onCursorMoved.
subscribe (function (type, args, obj) {
var time = args[0];
var val = args[1];
if (time != null && val != null) {
// cheat
showStatus("Date: " + formatTime(time) + " Value: " + val.toFixed(2));
} else {
showStatus(null);
}
});
BigPerfGraph.onNewGraph.
subscribe (function(type, args, obj) {
showGraphList(args[0]);
});
}
else {
BigPerfGraph.onCursorMoved.
subscribe (function (type, args, obj) {
var time = args[0];
var val = args[1];
var extra_data = args[2]
if (time != null && val != null) {
// cheat
showStatus("Interval: " + Math.floor(time) + " Value: " + val.toFixed(2) + " " + extra_data);
} else {
showStatus(null);
}
});
BigPerfGraph.onNewGraph.
subscribe (function(type, args, obj) {
showGraphList(args[0]);
});
}
if (document.location.hash) {
handleHash(document.location.hash);
} else {
if (graphType == CONTINUOUS_GRAPH) {
addGraphForm();
}
else if ( graphType == DATA_GRAPH ) {
addExtraDataGraphForm();
}
else {
addDiscreteGraphForm();
}
}
}
function addExtraDataGraphForm(config, name) {
showLoadingAnimation("populating lists");
var ed = new ExtraDataGraphFormModule(config, name);
ed.onLoading.subscribe (function(type,args,obj) { showLoadingAnimation(args[0]);});
ed.onLoadingDone.subscribe (function(type,args,obj) { clearLoadingAnimation();});
if (config) {
ed.addedInitialInfo.subscribe(function(type,args,obj) { graphInitial();});
}
ed.render (getElement("graphforms"));
return ed;
}
function addDiscreteGraphForm(config, name) {
showLoadingAnimation("populating lists");
//log("name: " + name);
var m = new DiscreteGraphFormModule(config, name);
m.onLoading.subscribe (function(type,args,obj) { showLoadingAnimation(args[0]);});
m.onLoadingDone.subscribe (function(type,args,obj) { clearLoadingAnimation();});
if (config) {
m.addedInitialInfo.subscribe(function(type,args,obj) { graphInitial();});
}
m.render (getElement("graphforms"));
//m.setColor(randomColor());
return m;
}
function addGraphForm(config) {
showLoadingAnimation("populating list");
var m = new GraphFormModule(config);
m.render (getElement("graphforms"));
m.setColor(randomColor());
m.onLoading.subscribe (function(type,args,obj) { showLoadingAnimation(args[0]);});
m.onLoadingDone.subscribe (function(type,args,obj) { clearLoadingAnimation();});
return m;
}
function onNoBaseLineClick() {
GraphFormModules.forEach (function (g) { g.baseline = false; });
}
// whether the bonsai data query should redraw the graph or not
var gReadyForRedraw = true;
function onUpdateBonsai() {
BigPerfGraph.deleteAllMarkers();
getElement("bonsaibutton").disabled = true;
if (gCurrentLoadRange) {
if ((gCurrentLoadRange[1] - gCurrentLoadRange[0]) < (bonsaiNoForceDays * ONE_DAY_SECONDS) || gForceBonsai) {
Bonsai.requestCheckinsBetween (gCurrentLoadRange[0], gCurrentLoadRange[1],
function (bdata) {
for (var i = 0; i < bdata.times.length; i++) {
BigPerfGraph.addMarker (bdata.times[i], bdata.who[i] + ": " + bdata.comment[i]);
}
if (gReadyForRedraw)
BigPerfGraph.redraw();
getElement("bonsaibutton").disabled = false;
});
}
}
}
function onGraph() {
showLoadingAnimation("building graph");
showStatus(null);
for each (var g in [BigPerfGraph, SmallPerfGraph]) {
g.clearDataSets();
g.setTimeRange(null, null);
}
gReadyForRedraw = false;
// do the actual graph data request
var baselineModule = null;
GraphFormModules.forEach (function (g) { if (g.baseline) baselineModule = g; });
if (baselineModule) {
Tinderbox.requestDataSetFor (baselineModule.testId,
function (testid, ds) {
try {
//log ("Got results for baseline: '" + testid + "' ds: " + ds);
ds.color = baselineModule.color;
onGraphLoadRemainder(ds);
} catch(e) { log(e); }
});
} else {
onGraphLoadRemainder();
}
}
function onGraphLoadRemainder(baselineDataSet) {
for each (var graphModule in GraphFormModules) {
//log ("onGraphLoadRemainder: ", graphModule.id, graphModule.testId, "color:", graphModule.color, "average:", graphModule.average);
// this would have been loaded earlier
if (graphModule.baseline)
continue;
var autoExpand = true;
if (SmallPerfGraph.selectionType == "range" &&
SmallPerfGraph.selectionStartTime &&
SmallPerfGraph.selectionEndTime)
{
if (gCurrentLoadRange && (SmallPerfGraph.selectionStartTime < gCurrentLoadRange[0] ||
SmallPerfGraph.selectionEndTime > gCurrentLoadRange[1]))
{
SmallPerfGraph.selectionStartTime = Math.max (SmallPerfGraph.selectionStartTime, gCurrentLoadRange[0]);
SmallPerfGraph.selectionEndTime = Math.min (SmallPerfGraph.selectionEndTime, gCurrentLoadRange[1]);
}
BigPerfGraph.setTimeRange (SmallPerfGraph.selectionStartTime, SmallPerfGraph.selectionEndTime);
autoExpand = false;
}
// we need a new closure here so that we can get the right value
// of graphModule in our closure
var makeCallback = function (module, color, title) {
return function (testid, ds) {
try {
log("ds.firstTime " + ds.firstTime + " ds.lastTime " + ds.lastTime);
if (undefined == ds.firstTime || !ds.lastTime) {
// got a data set with no data in this time range, or damaged data
// better to not graph
for each (g in [BigPerfGraph, SmallPerfGraph]) {
g.clearGraph();
}
showStatus("No data in the given time range");
clearLoadingAnimation();
}
else {
ds.color = color;
if (title) {
ds.title = title;
}
if (baselineDataSet)
ds = ds.createRelativeTo(baselineDataSet);
//log ("got ds: (", module.id, ")", ds.firstTime, ds.lastTime, ds.data.length);
var avgds = null;
if (baselineDataSet == null &&
module.average)
{
avgds = ds.createAverage(gAverageInterval);
}
if (avgds)
log ("got avgds: (", module.id, ")", avgds.firstTime, avgds.lastTime, avgds.data.length);
for each (g in [BigPerfGraph, SmallPerfGraph]) {
g.addDataSet(ds);
if (avgds)
g.addDataSet(avgds);
if (g == SmallPerfGraph || autoExpand) {
g.expandTimeRange(Math.max(ds.firstTime, gCurrentLoadRange ? gCurrentLoadRange[0] : ds.firstTime),
Math.min(ds.lastTime, gCurrentLoadRange ? gCurrentLoadRange[1] : ds.lastTime));
}
g.autoScale();
g.redraw();
gReadyForRedraw = true;
}
//if (graphType == CONTINUOUS_GRAPH) {
updateLinkToThis();
updateDumpToCsv();
//}
}
} catch(e) { log(e); }
};
};
if (graphModule.testIds) {
for each (var testId in graphModule.testIds) {
// log ("working with testId: " + testId);
Tinderbox.requestDataSetFor (testId[0], makeCallback(graphModule, randomColor(), testId[1]));
}
}
else {
// log ("working with standard, single testId");
Tinderbox.requestDataSetFor (graphModule.testId, makeCallback(graphModule, graphModule.color));
}
}
}
function onDataLoadChanged() {
log ("loadchanged");
if (getElement("load-days-radio").checked) {
var dval = new Number(getElement("load-days-entry").value);
log ("dval", dval);
if (dval <= 0) {
//getElement("load-days-entry").style.background-color = "red";
return;
} else {
//getElement("load-days-entry").style.background-color = "inherit";
}
var d2 = Math.ceil(Date.now() / 1000);
d2 = (d2 - (d2 % ONE_DAY_SECONDS)) + ONE_DAY_SECONDS;
var d1 = Math.floor(d2 - (dval * ONE_DAY_SECONDS));
log ("drange", d1, d2);
Tinderbox.defaultLoadRange = [d1, d2];
gCurrentLoadRange = [d1, d2];
} else {
Tinderbox.defaultLoadRange = null;
gCurrentLoadRange = null;
}
Tinderbox.clearValueDataSets();
// hack, reset colors
randomColorBias = 0;
}
function onExtraDataLoadChanged() {
log ("loadchanged");
Tinderbox.defaultLoadRange = null;
gCurrentLoadRange = null;
// hack, reset colors
randomColorBias = 0;
}
function onDiscreteDataLoadChanged() {
log ("loadchanged");
Tinderbox.defaultLoadRange = null;
gCurrentLoadRange = null;
// hack, reset colors
randomColorBias = 0;
}
function findGraphModule(testId) {
for each (var gm in GraphFormModules) {
if (gm.testId == testId)
return gm;
}
return null;
}
function updateDumpToCsv() {
var ds = "?"
prefix = ""
for each (var gm in GraphFormModules) {
ds += prefix + gm.getDumpString();
prefix = "&"
}
log ("ds");
getElement("dumptocsv").href = "http://" + document.location.host + "/dumpdata.cgi" + ds;
}
function updateLinkToThis() {
var qs = "";
qs += SmallPerfGraph.getQueryString("sp");
qs += "&";
qs += BigPerfGraph.getQueryString("bp");
if (graphType == CONTINUOUS_GRAPH) {
var ctr = 1;
for each (var gm in GraphFormModules) {
qs += "&" + gm.getQueryString("m" + ctr);
ctr++;
}
}
else {
qs += "&";
qs += "name=" + GraphFormModules[0].name;
for each (var gm in GraphFormModules) {
qs += gm.getQueryString("m");
}
}
getElement("linktothis").href = document.location.pathname + "#" + qs;
}
function handleHash(hash) {
var qsdata = {};
for each (var s in hash.substring(1).split("&")) {
var q = s.split("=");
qsdata[q[0]] = q[1];
}
if (graphType == CONTINUOUS_GRAPH) {
var ctr = 1;
while (("m" + ctr + "tid") in qsdata) {
var prefix = "m" + ctr;
addGraphForm({testid: qsdata[prefix + "tid"],
average: qsdata[prefix + "avg"]});
ctr++;
}
}
else {
var ctr=1;
testids = [];
while (("m" + ctr + "tid") in qsdata) {
var prefix = "m" + ctr;
testids.push(Number(qsdata[prefix + "tid"]));
ctr++;
}
// log("qsdata[name] " + qsdata["name"]);
addDiscreteGraphForm(testids, qsdata["name"]);
}
SmallPerfGraph.handleQueryStringData("sp", qsdata);
BigPerfGraph.handleQueryStringData("bp", qsdata);
var tstart = new Number(qsdata["spstart"]);
var tend = new Number(qsdata["spend"]);
//Tinderbox.defaultLoadRange = [tstart, tend];
if (graphType == CONTINUOUS_GRAPH) {
Tinderbox.requestTestList(function (tests) {
setTimeout (onGraph, 0); // let the other handlers do their thing
});
}
}
function graphInitial() {
GraphFormModules[0].addedInitialInfo.unsubscribeAll();
Tinderbox.requestTestList(null, null, null, null, function (tests) {
setTimeout(onGraph, 0);
});
}
function showStatus(s) {
replaceChildNodes("status", s);
}
function showLoadingAnimation(message) {
//log("starting loading animation: " + message);
td = new SPAN();
el = new IMG({ src: "js/img/Throbber-small.gif"});
appendChildNodes(td, el);
appendChildNodes(td, " loading: " + message + " ");
replaceChildNodes("loading", td);
}
function clearLoadingAnimation() {
//log("ending loading animation");
replaceChildNodes("loading", null);
}
function showGraphList(s) {
replaceChildNodes("graph-label-list",null);
// log("s: " +s);
var tbl = new TABLE({});
var tbl_tr = new TR();
appendChildNodes(tbl_tr, new TD(""));
appendChildNodes(tbl_tr, new TD("avg"));
appendChildNodes(tbl_tr, new TD("max"));
appendChildNodes(tbl_tr, new TD("min"));
appendChildNodes(tbl_tr, new TD("test name"));
appendChildNodes(tbl, tbl_tr);
for each (var ds in s) {
var tbl_tr = new TR();
var rstring = ds.stats + " ";
var colorDiv = new DIV({ id: "whee", style: "display: inline; border: 1px solid black; height: 15; " +
"padding-right: 15; vertical-align: middle; margin: 3px;" });
colorDiv.style.backgroundColor = colorToRgbString(ds.color);
// log("ds.stats" + ds.stats);
appendChildNodes(tbl_tr, colorDiv);
for each (var val in ds.stats) {
appendChildNodes(tbl_tr, new TD(val.toFixed(2)));
}
appendChildNodes(tbl, tbl_tr);
appendChildNodes(tbl_tr, new TD(ds.title));
}
appendChildNodes("graph-label-list", tbl);
if (s.length == GraphFormModules[0].testIds.length) {
clearLoadingAnimation();
}
//replaceChildNodes("graph-label-list",rstring);
}
/* Get some pre-set colors in for the first 5 graphs, thens start randomly generating stuff */
var presetColorIndex = 0;
var presetColors = [
[0.0, 0.0, 0.7, 1.0],
[0.0, 0.5, 0.0, 1.0],
[0.7, 0.0, 0.0, 1.0],
[0.7, 0.0, 0.7, 1.0],
[0.0, 0.7, 0.7, 1.0]
];
var randomColorBias = 0;
function randomColor() {
if (presetColorIndex < presetColors.length) {
return presetColors[presetColorIndex++];
}
var col = [
(Math.random()*0.5) + ((randomColorBias==0) ? 0.5 : 0.2),
(Math.random()*0.5) + ((randomColorBias==1) ? 0.5 : 0.2),
(Math.random()*0.5) + ((randomColorBias==2) ? 0.5 : 0.2),
1.0
];
randomColorBias++;
if (randomColorBias == 3)
randomColorBias = 0;
return col;
}
function lighterColor(col) {
return [
Math.min(0.85, col[0] * 1.2),
Math.min(0.85, col[1] * 1.2),
Math.min(0.85, col[2] * 1.2),
col[3]
];
}
function colorToRgbString(col) {
// log ("in colorToRgbString");
if (col[3] < 1) {
return "rgba("
+ Math.floor(col[0]*255) + ","
+ Math.floor(col[1]*255) + ","
+ Math.floor(col[2]*255) + ","
+ col[3]
+ ")";
}
return "rgb("
+ Math.floor(col[0]*255) + ","
+ Math.floor(col[1]*255) + ","
+ Math.floor(col[2]*255) + ")";
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

View File

@@ -1,637 +0,0 @@
/***
MochiKit.Async 1.3.1
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2005 Bob Ippolito. All rights Reserved.
***/
if (typeof(dojo) != 'undefined') {
dojo.provide("MochiKit.Async");
dojo.require("MochiKit.Base");
}
if (typeof(JSAN) != 'undefined') {
JSAN.use("MochiKit.Base", []);
}
try {
if (typeof(MochiKit.Base) == 'undefined') {
throw "";
}
} catch (e) {
throw "MochiKit.Async depends on MochiKit.Base!";
}
if (typeof(MochiKit.Async) == 'undefined') {
MochiKit.Async = {};
}
MochiKit.Async.NAME = "MochiKit.Async";
MochiKit.Async.VERSION = "1.3.1";
MochiKit.Async.__repr__ = function () {
return "[" + this.NAME + " " + this.VERSION + "]";
};
MochiKit.Async.toString = function () {
return this.__repr__();
};
MochiKit.Async.Deferred = function (/* optional */ canceller) {
this.chain = [];
this.id = this._nextId();
this.fired = -1;
this.paused = 0;
this.results = [null, null];
this.canceller = canceller;
this.silentlyCancelled = false;
this.chained = false;
};
MochiKit.Async.Deferred.prototype = {
repr: function () {
var state;
if (this.fired == -1) {
state = 'unfired';
} else if (this.fired === 0) {
state = 'success';
} else {
state = 'error';
}
return 'Deferred(' + this.id + ', ' + state + ')';
},
toString: MochiKit.Base.forwardCall("repr"),
_nextId: MochiKit.Base.counter(),
cancel: function () {
var self = MochiKit.Async;
if (this.fired == -1) {
if (this.canceller) {
this.canceller(this);
} else {
this.silentlyCancelled = true;
}
if (this.fired == -1) {
this.errback(new self.CancelledError(this));
}
} else if ((this.fired === 0) && (this.results[0] instanceof self.Deferred)) {
this.results[0].cancel();
}
},
_pause: function () {
/***
Used internally to signal that it's waiting on another Deferred
***/
this.paused++;
},
_unpause: function () {
/***
Used internally to signal that it's no longer waiting on another
Deferred.
***/
this.paused--;
if ((this.paused === 0) && (this.fired >= 0)) {
this._fire();
}
},
_continue: function (res) {
/***
Used internally when a dependent deferred fires.
***/
this._resback(res);
this._unpause();
},
_resback: function (res) {
/***
The primitive that means either callback or errback
***/
this.fired = ((res instanceof Error) ? 1 : 0);
this.results[this.fired] = res;
this._fire();
},
_check: function () {
if (this.fired != -1) {
if (!this.silentlyCancelled) {
throw new MochiKit.Async.AlreadyCalledError(this);
}
this.silentlyCancelled = false;
return;
}
},
callback: function (res) {
this._check();
if (res instanceof MochiKit.Async.Deferred) {
throw new Error("Deferred instances can only be chained if they are the result of a callback");
}
this._resback(res);
},
errback: function (res) {
this._check();
var self = MochiKit.Async;
if (res instanceof self.Deferred) {
throw new Error("Deferred instances can only be chained if they are the result of a callback");
}
if (!(res instanceof Error)) {
res = new self.GenericError(res);
}
this._resback(res);
},
addBoth: function (fn) {
if (arguments.length > 1) {
fn = MochiKit.Base.partial.apply(null, arguments);
}
return this.addCallbacks(fn, fn);
},
addCallback: function (fn) {
if (arguments.length > 1) {
fn = MochiKit.Base.partial.apply(null, arguments);
}
return this.addCallbacks(fn, null);
},
addErrback: function (fn) {
if (arguments.length > 1) {
fn = MochiKit.Base.partial.apply(null, arguments);
}
return this.addCallbacks(null, fn);
},
addCallbacks: function (cb, eb) {
if (this.chained) {
throw new Error("Chained Deferreds can not be re-used");
}
this.chain.push([cb, eb]);
if (this.fired >= 0) {
this._fire();
}
return this;
},
_fire: function () {
/***
Used internally to exhaust the callback sequence when a result
is available.
***/
var chain = this.chain;
var fired = this.fired;
var res = this.results[fired];
var self = this;
var cb = null;
while (chain.length > 0 && this.paused === 0) {
// Array
var pair = chain.shift();
var f = pair[fired];
if (f === null) {
continue;
}
try {
res = f(res);
fired = ((res instanceof Error) ? 1 : 0);
if (res instanceof MochiKit.Async.Deferred) {
cb = function (res) {
self._continue(res);
};
this._pause();
}
} catch (err) {
fired = 1;
if (!(err instanceof Error)) {
err = new MochiKit.Async.GenericError(err);
}
res = err;
}
}
this.fired = fired;
this.results[fired] = res;
if (cb && this.paused) {
// this is for "tail recursion" in case the dependent deferred
// is already fired
res.addBoth(cb);
res.chained = true;
}
}
};
MochiKit.Base.update(MochiKit.Async, {
evalJSONRequest: function (/* req */) {
return eval('(' + arguments[0].responseText + ')');
},
succeed: function (/* optional */result) {
var d = new MochiKit.Async.Deferred();
d.callback.apply(d, arguments);
return d;
},
fail: function (/* optional */result) {
var d = new MochiKit.Async.Deferred();
d.errback.apply(d, arguments);
return d;
},
getXMLHttpRequest: function () {
var self = arguments.callee;
if (!self.XMLHttpRequest) {
var tryThese = [
function () { return new XMLHttpRequest(); },
function () { return new ActiveXObject('Msxml2.XMLHTTP'); },
function () { return new ActiveXObject('Microsoft.XMLHTTP'); },
function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); },
function () {
throw new MochiKit.Async.BrowserComplianceError("Browser does not support XMLHttpRequest");
}
];
for (var i = 0; i < tryThese.length; i++) {
var func = tryThese[i];
try {
self.XMLHttpRequest = func;
return func();
} catch (e) {
// pass
}
}
}
return self.XMLHttpRequest();
},
_nothing: function () {},
_xhr_onreadystatechange: function (d) {
// MochiKit.Logging.logDebug('this.readyState', this.readyState);
if (this.readyState == 4) {
// IE SUCKS
try {
this.onreadystatechange = null;
} catch (e) {
try {
this.onreadystatechange = MochiKit.Async._nothing;
} catch (e) {
}
}
var status = null;
try {
status = this.status;
if (!status && MochiKit.Base.isNotEmpty(this.responseText)) {
// 0 or undefined seems to mean cached or local
status = 304;
}
} catch (e) {
// pass
// MochiKit.Logging.logDebug('error getting status?', repr(items(e)));
}
// 200 is OK, 304 is NOT_MODIFIED
if (status == 200 || status == 304) { // OK
d.callback(this);
} else {
var err = new MochiKit.Async.XMLHttpRequestError(this, "Request failed");
if (err.number) {
// XXX: This seems to happen on page change
d.errback(err);
} else {
// XXX: this seems to happen when the server is unreachable
d.errback(err);
}
}
}
},
_xhr_canceller: function (req) {
// IE SUCKS
try {
req.onreadystatechange = null;
} catch (e) {
try {
req.onreadystatechange = MochiKit.Async._nothing;
} catch (e) {
}
}
req.abort();
},
sendXMLHttpRequest: function (req, /* optional */ sendContent) {
if (typeof(sendContent) == "undefined" || sendContent === null) {
sendContent = "";
}
var m = MochiKit.Base;
var self = MochiKit.Async;
var d = new self.Deferred(m.partial(self._xhr_canceller, req));
try {
req.onreadystatechange = m.bind(self._xhr_onreadystatechange,
req, d);
req.send(sendContent);
} catch (e) {
try {
req.onreadystatechange = null;
} catch (ignore) {
// pass
}
d.errback(e);
}
return d;
},
doSimpleXMLHttpRequest: function (url/*, ...*/) {
var self = MochiKit.Async;
var req = self.getXMLHttpRequest();
if (arguments.length > 1) {
var m = MochiKit.Base;
var qs = m.queryString.apply(null, m.extend(null, arguments, 1));
if (qs) {
url += "?" + qs;
}
}
req.open("GET", url, true);
return self.sendXMLHttpRequest(req);
},
loadJSONDoc: function (url) {
var self = MochiKit.Async;
var d = self.doSimpleXMLHttpRequest.apply(self, arguments);
d = d.addCallback(self.evalJSONRequest);
return d;
},
wait: function (seconds, /* optional */value) {
var d = new MochiKit.Async.Deferred();
var m = MochiKit.Base;
if (typeof(value) != 'undefined') {
d.addCallback(function () { return value; });
}
var timeout = setTimeout(
m.bind("callback", d),
Math.floor(seconds * 1000));
d.canceller = function () {
try {
clearTimeout(timeout);
} catch (e) {
// pass
}
};
return d;
},
callLater: function (seconds, func) {
var m = MochiKit.Base;
var pfunc = m.partial.apply(m, m.extend(null, arguments, 1));
return MochiKit.Async.wait(seconds).addCallback(
function (res) { return pfunc(); }
);
}
});
MochiKit.Async.DeferredLock = function () {
this.waiting = [];
this.locked = false;
this.id = this._nextId();
};
MochiKit.Async.DeferredLock.prototype = {
__class__: MochiKit.Async.DeferredLock,
acquire: function () {
d = new MochiKit.Async.Deferred();
if (this.locked) {
this.waiting.push(d);
} else {
this.locked = true;
d.callback(this);
}
return d;
},
release: function () {
if (!this.locked) {
throw TypeError("Tried to release an unlocked DeferredLock");
}
this.locked = false;
if (this.waiting.length > 0) {
this.locked = true;
this.waiting.shift().callback(this);
}
},
_nextId: MochiKit.Base.counter(),
repr: function () {
var state;
if (this.locked) {
state = 'locked, ' + this.waiting.length + ' waiting';
} else {
state = 'unlocked';
}
return 'DeferredLock(' + this.id + ', ' + state + ')';
},
toString: MochiKit.Base.forwardCall("repr")
};
MochiKit.Async.DeferredList = function (list, /* optional */fireOnOneCallback, fireOnOneErrback, consumeErrors, canceller) {
this.list = list;
this.resultList = new Array(this.list.length);
// Deferred init
this.chain = [];
this.id = this._nextId();
this.fired = -1;
this.paused = 0;
this.results = [null, null];
this.canceller = canceller;
this.silentlyCancelled = false;
if (this.list.length === 0 && !fireOnOneCallback) {
this.callback(this.resultList);
}
this.finishedCount = 0;
this.fireOnOneCallback = fireOnOneCallback;
this.fireOnOneErrback = fireOnOneErrback;
this.consumeErrors = consumeErrors;
var index = 0;
MochiKit.Base.map(MochiKit.Base.bind(function (d) {
d.addCallback(MochiKit.Base.bind(this._cbDeferred, this), index, true);
d.addErrback(MochiKit.Base.bind(this._cbDeferred, this), index, false);
index += 1;
}, this), this.list);
};
MochiKit.Base.update(MochiKit.Async.DeferredList.prototype,
MochiKit.Async.Deferred.prototype);
MochiKit.Base.update(MochiKit.Async.DeferredList.prototype, {
_cbDeferred: function (index, succeeded, result) {
this.resultList[index] = [succeeded, result];
this.finishedCount += 1;
if (this.fired !== 0) {
if (succeeded && this.fireOnOneCallback) {
this.callback([index, result]);
} else if (!succeeded && this.fireOnOneErrback) {
this.errback(result);
} else if (this.finishedCount == this.list.length) {
this.callback(this.resultList);
}
}
if (!succeeded && this.consumeErrors) {
result = null;
}
return result;
}
});
MochiKit.Async.gatherResults = function (deferredList) {
var d = new MochiKit.Async.DeferredList(deferredList, false, true, false);
d.addCallback(function (results) {
var ret = [];
for (var i = 0; i < results.length; i++) {
ret.push(results[i][1]);
}
return ret;
});
return d;
};
MochiKit.Async.maybeDeferred = function (func) {
var self = MochiKit.Async;
var result;
try {
var r = func.apply(null, MochiKit.Base.extend([], arguments, 1));
if (r instanceof self.Deferred) {
result = r;
} else if (r instanceof Error) {
result = self.fail(r);
} else {
result = self.succeed(r);
}
} catch (e) {
result = self.fail(e);
}
return result;
};
MochiKit.Async.EXPORT = [
"AlreadyCalledError",
"CancelledError",
"BrowserComplianceError",
"GenericError",
"XMLHttpRequestError",
"Deferred",
"succeed",
"fail",
"getXMLHttpRequest",
"doSimpleXMLHttpRequest",
"loadJSONDoc",
"wait",
"callLater",
"sendXMLHttpRequest",
"DeferredLock",
"DeferredList",
"gatherResults",
"maybeDeferred"
];
MochiKit.Async.EXPORT_OK = [
"evalJSONRequest"
];
MochiKit.Async.__new__ = function () {
var m = MochiKit.Base;
var ne = m.partial(m._newNamedError, this);
ne("AlreadyCalledError",
function (deferred) {
/***
Raised by the Deferred if callback or errback happens
after it was already fired.
***/
this.deferred = deferred;
}
);
ne("CancelledError",
function (deferred) {
/***
Raised by the Deferred cancellation mechanism.
***/
this.deferred = deferred;
}
);
ne("BrowserComplianceError",
function (msg) {
/***
Raised when the JavaScript runtime is not capable of performing
the given function. Technically, this should really never be
raised because a non-conforming JavaScript runtime probably
isn't going to support exceptions in the first place.
***/
this.message = msg;
}
);
ne("GenericError",
function (msg) {
this.message = msg;
}
);
ne("XMLHttpRequestError",
function (req, msg) {
/***
Raised when an XMLHttpRequest does not complete for any reason.
***/
this.req = req;
this.message = msg;
try {
// Strange but true that this can raise in some cases.
this.number = req.status;
} catch (e) {
// pass
}
}
);
this.EXPORT_TAGS = {
":common": this.EXPORT,
":all": m.concat(this.EXPORT, this.EXPORT_OK)
};
m.nameFunctions(this);
};
MochiKit.Async.__new__();
MochiKit.Base._exportSymbols(this, MochiKit.Async);

File diff suppressed because it is too large Load Diff

View File

@@ -1,825 +0,0 @@
/***
MochiKit.Color 1.3.1
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2005 Bob Ippolito and others. All rights Reserved.
***/
if (typeof(dojo) != 'undefined') {
dojo.provide('MochiKit.Color');
dojo.require('MochiKit.Base');
}
if (typeof(JSAN) != 'undefined') {
JSAN.use("MochiKit.Base", []);
}
try {
if (typeof(MochiKit.Base) == 'undefined') {
throw "";
}
} catch (e) {
throw "MochiKit.Color depends on MochiKit.Base";
}
if (typeof(MochiKit.Color) == "undefined") {
MochiKit.Color = {};
}
MochiKit.Color.NAME = "MochiKit.Color";
MochiKit.Color.VERSION = "1.3.1";
MochiKit.Color.__repr__ = function () {
return "[" + this.NAME + " " + this.VERSION + "]";
};
MochiKit.Color.toString = function () {
return this.__repr__();
};
MochiKit.Color.Color = function (red, green, blue, alpha) {
if (typeof(alpha) == 'undefined' || alpha === null) {
alpha = 1.0;
}
this.rgb = {
r: red,
g: green,
b: blue,
a: alpha
};
};
// Prototype methods
MochiKit.Color.Color.prototype = {
__class__: MochiKit.Color.Color,
colorWithAlpha: function (alpha) {
var rgb = this.rgb;
var m = MochiKit.Color;
return m.Color.fromRGB(rgb.r, rgb.g, rgb.b, alpha);
},
colorWithHue: function (hue) {
// get an HSL model, and set the new hue...
var hsl = this.asHSL();
hsl.h = hue;
var m = MochiKit.Color;
// convert back to RGB...
return m.Color.fromHSL(hsl);
},
colorWithSaturation: function (saturation) {
// get an HSL model, and set the new hue...
var hsl = this.asHSL();
hsl.s = saturation;
var m = MochiKit.Color;
// convert back to RGB...
return m.Color.fromHSL(hsl);
},
colorWithLightness: function (lightness) {
// get an HSL model, and set the new hue...
var hsl = this.asHSL();
hsl.l = lightness;
var m = MochiKit.Color;
// convert back to RGB...
return m.Color.fromHSL(hsl);
},
darkerColorWithLevel: function (level) {
var hsl = this.asHSL();
hsl.l = Math.max(hsl.l - level, 0);
var m = MochiKit.Color;
return m.Color.fromHSL(hsl);
},
lighterColorWithLevel: function (level) {
var hsl = this.asHSL();
hsl.l = Math.min(hsl.l + level, 1);
var m = MochiKit.Color;
return m.Color.fromHSL(hsl);
},
blendedColor: function (other, /* optional */ fraction) {
if (typeof(fraction) == 'undefined' || fraction === null) {
fraction = 0.5;
}
var sf = 1.0 - fraction;
var s = this.rgb;
var d = other.rgb;
var df = fraction;
return MochiKit.Color.Color.fromRGB(
(s.r * sf) + (d.r * df),
(s.g * sf) + (d.g * df),
(s.b * sf) + (d.b * df),
(s.a * sf) + (d.a * df)
);
},
compareRGB: function (other) {
var a = this.asRGB();
var b = other.asRGB();
return MochiKit.Base.compare(
[a.r, a.g, a.b, a.a],
[b.r, b.g, b.b, b.a]
);
},
isLight: function () {
return this.asHSL().b > 0.5;
},
isDark: function () {
return (!this.isLight());
},
toHSLString: function () {
var c = this.asHSL();
var ccc = MochiKit.Color.clampColorComponent;
var rval = this._hslString;
if (!rval) {
var mid = (
ccc(c.h, 360).toFixed(0)
+ "," + ccc(c.s, 100).toPrecision(4) + "%"
+ "," + ccc(c.l, 100).toPrecision(4) + "%"
);
var a = c.a;
if (a >= 1) {
a = 1;
rval = "hsl(" + mid + ")";
} else {
if (a <= 0) {
a = 0;
}
rval = "hsla(" + mid + "," + a + ")";
}
this._hslString = rval;
}
return rval;
},
toRGBString: function () {
var c = this.rgb;
var ccc = MochiKit.Color.clampColorComponent;
var rval = this._rgbString;
if (!rval) {
var mid = (
ccc(c.r, 255).toFixed(0)
+ "," + ccc(c.g, 255).toFixed(0)
+ "," + ccc(c.b, 255).toFixed(0)
);
if (c.a != 1) {
rval = "rgba(" + mid + "," + c.a + ")";
} else {
rval = "rgb(" + mid + ")";
}
this._rgbString = rval;
}
return rval;
},
asRGB: function () {
return MochiKit.Base.clone(this.rgb);
},
toHexString: function () {
var m = MochiKit.Color;
var c = this.rgb;
var ccc = MochiKit.Color.clampColorComponent;
var rval = this._hexString;
if (!rval) {
rval = ("#" +
m.toColorPart(ccc(c.r, 255)) +
m.toColorPart(ccc(c.g, 255)) +
m.toColorPart(ccc(c.b, 255))
);
this._hexString = rval;
}
return rval;
},
asHSV: function () {
var hsv = this.hsv;
var c = this.rgb;
if (typeof(hsv) == 'undefined' || hsv === null) {
hsv = MochiKit.Color.rgbToHSV(this.rgb);
this.hsv = hsv;
}
return MochiKit.Base.clone(hsv);
},
asHSL: function () {
var hsl = this.hsl;
var c = this.rgb;
if (typeof(hsl) == 'undefined' || hsl === null) {
hsl = MochiKit.Color.rgbToHSL(this.rgb);
this.hsl = hsl;
}
return MochiKit.Base.clone(hsl);
},
toString: function () {
return this.toRGBString();
},
repr: function () {
var c = this.rgb;
var col = [c.r, c.g, c.b, c.a];
return this.__class__.NAME + "(" + col.join(", ") + ")";
}
};
// Constructor methods
MochiKit.Base.update(MochiKit.Color.Color, {
fromRGB: function (red, green, blue, alpha) {
// designated initializer
var Color = MochiKit.Color.Color;
if (arguments.length == 1) {
var rgb = red;
red = rgb.r;
green = rgb.g;
blue = rgb.b;
if (typeof(rgb.a) == 'undefined') {
alpha = undefined;
} else {
alpha = rgb.a;
}
}
return new Color(red, green, blue, alpha);
},
fromHSL: function (hue, saturation, lightness, alpha) {
var m = MochiKit.Color;
return m.Color.fromRGB(m.hslToRGB.apply(m, arguments));
},
fromHSV: function (hue, saturation, value, alpha) {
var m = MochiKit.Color;
return m.Color.fromRGB(m.hsvToRGB.apply(m, arguments));
},
fromName: function (name) {
var Color = MochiKit.Color.Color;
// Opera 9 seems to "quote" named colors(?!)
if (name.charAt(0) == '"') {
name = name.substr(1, name.length - 2);
}
var htmlColor = Color._namedColors[name.toLowerCase()];
if (typeof(htmlColor) == 'string') {
return Color.fromHexString(htmlColor);
} else if (name == "transparent") {
return Color.transparentColor();
}
return null;
},
fromString: function (colorString) {
var self = MochiKit.Color.Color;
var three = colorString.substr(0, 3);
if (three == "rgb") {
return self.fromRGBString(colorString);
} else if (three == "hsl") {
return self.fromHSLString(colorString);
} else if (colorString.charAt(0) == "#") {
return self.fromHexString(colorString);
}
return self.fromName(colorString);
},
fromHexString: function (hexCode) {
if (hexCode.charAt(0) == '#') {
hexCode = hexCode.substring(1);
}
var components = [];
var i, hex;
if (hexCode.length == 3) {
for (i = 0; i < 3; i++) {
hex = hexCode.substr(i, 1);
components.push(parseInt(hex + hex, 16) / 255.0);
}
} else {
for (i = 0; i < 6; i += 2) {
hex = hexCode.substr(i, 2);
components.push(parseInt(hex, 16) / 255.0);
}
}
var Color = MochiKit.Color.Color;
return Color.fromRGB.apply(Color, components);
},
_fromColorString: function (pre, method, scales, colorCode) {
// parses either HSL or RGB
if (colorCode.indexOf(pre) === 0) {
colorCode = colorCode.substring(colorCode.indexOf("(", 3) + 1, colorCode.length - 1);
}
var colorChunks = colorCode.split(/\s*,\s*/);
var colorFloats = [];
for (var i = 0; i < colorChunks.length; i++) {
var c = colorChunks[i];
var val;
var three = c.substring(c.length - 3);
if (c.charAt(c.length - 1) == '%') {
val = 0.01 * parseFloat(c.substring(0, c.length - 1));
} else if (three == "deg") {
val = parseFloat(c) / 360.0;
} else if (three == "rad") {
val = parseFloat(c) / (Math.PI * 2);
} else {
val = scales[i] * parseFloat(c);
}
colorFloats.push(val);
}
return this[method].apply(this, colorFloats);
},
fromComputedStyle: function (elem, style, mozillaEquivalentCSS) {
var d = MochiKit.DOM;
var cls = MochiKit.Color.Color;
for (elem = d.getElement(elem); elem; elem = elem.parentNode) {
var actualColor = d.computedStyle.apply(d, arguments);
if (!actualColor) {
continue;
}
var color = cls.fromString(actualColor);
if (!color) {
break;
}
if (color.asRGB().a > 0) {
return color;
}
}
return null;
},
fromBackground: function (elem) {
var cls = MochiKit.Color.Color;
return cls.fromComputedStyle(
elem, "backgroundColor", "background-color") || cls.whiteColor();
},
fromText: function (elem) {
var cls = MochiKit.Color.Color;
return cls.fromComputedStyle(
elem, "color", "color") || cls.blackColor();
},
namedColors: function () {
return MochiKit.Base.clone(MochiKit.Color.Color._namedColors);
}
});
// Module level functions
MochiKit.Base.update(MochiKit.Color, {
clampColorComponent: function (v, scale) {
v *= scale;
if (v < 0) {
return 0;
} else if (v > scale) {
return scale;
} else {
return v;
}
},
_hslValue: function (n1, n2, hue) {
if (hue > 6.0) {
hue -= 6.0;
} else if (hue < 0.0) {
hue += 6.0;
}
var val;
if (hue < 1.0) {
val = n1 + (n2 - n1) * hue;
} else if (hue < 3.0) {
val = n2;
} else if (hue < 4.0) {
val = n1 + (n2 - n1) * (4.0 - hue);
} else {
val = n1;
}
return val;
},
hsvToRGB: function (hue, saturation, value, alpha) {
if (arguments.length == 1) {
var hsv = hue;
hue = hsv.h;
saturation = hsv.s;
value = hsv.v;
alpha = hsv.a;
}
var red;
var green;
var blue;
if (saturation === 0) {
red = 0;
green = 0;
blue = 0;
} else {
var i = Math.floor(hue * 6);
var f = (hue * 6) - i;
var p = value * (1 - saturation);
var q = value * (1 - (saturation * f));
var t = value * (1 - (saturation * (1 - f)));
switch (i) {
case 1: red = q; green = value; blue = p; break;
case 2: red = p; green = value; blue = t; break;
case 3: red = p; green = q; blue = value; break;
case 4: red = t; green = p; blue = value; break;
case 5: red = value; green = p; blue = q; break;
case 6: // fall through
case 0: red = value; green = t; blue = p; break;
}
}
return {
r: red,
g: green,
b: blue,
a: alpha
};
},
hslToRGB: function (hue, saturation, lightness, alpha) {
if (arguments.length == 1) {
var hsl = hue;
hue = hsl.h;
saturation = hsl.s;
lightness = hsl.l;
alpha = hsl.a;
}
var red;
var green;
var blue;
if (saturation === 0) {
red = lightness;
green = lightness;
blue = lightness;
} else {
var m2;
if (lightness <= 0.5) {
m2 = lightness * (1.0 + saturation);
} else {
m2 = lightness + saturation - (lightness * saturation);
}
var m1 = (2.0 * lightness) - m2;
var f = MochiKit.Color._hslValue;
var h6 = hue * 6.0;
red = f(m1, m2, h6 + 2);
green = f(m1, m2, h6);
blue = f(m1, m2, h6 - 2);
}
return {
r: red,
g: green,
b: blue,
a: alpha
};
},
rgbToHSV: function (red, green, blue, alpha) {
if (arguments.length == 1) {
var rgb = red;
red = rgb.r;
green = rgb.g;
blue = rgb.b;
alpha = rgb.a;
}
var max = Math.max(Math.max(red, green), blue);
var min = Math.min(Math.min(red, green), blue);
var hue;
var saturation;
var value = max;
if (min == max) {
hue = 0;
saturation = 0;
} else {
var delta = (max - min);
saturation = delta / max;
if (red == max) {
hue = (green - blue) / delta;
} else if (green == max) {
hue = 2 + ((blue - red) / delta);
} else {
hue = 4 + ((red - green) / delta);
}
hue /= 6;
if (hue < 0) {
hue += 1;
}
if (hue > 1) {
hue -= 1;
}
}
return {
h: hue,
s: saturation,
v: value,
a: alpha
};
},
rgbToHSL: function (red, green, blue, alpha) {
if (arguments.length == 1) {
var rgb = red;
red = rgb.r;
green = rgb.g;
blue = rgb.b;
alpha = rgb.a;
}
var max = Math.max(red, Math.max(green, blue));
var min = Math.min(red, Math.min(green, blue));
var hue;
var saturation;
var lightness = (max + min) / 2.0;
var delta = max - min;
if (delta === 0) {
hue = 0;
saturation = 0;
} else {
if (lightness <= 0.5) {
saturation = delta / (max + min);
} else {
saturation = delta / (2 - max - min);
}
if (red == max) {
hue = (green - blue) / delta;
} else if (green == max) {
hue = 2 + ((blue - red) / delta);
} else {
hue = 4 + ((red - green) / delta);
}
hue /= 6;
if (hue < 0) {
hue += 1;
}
if (hue > 1) {
hue -= 1;
}
}
return {
h: hue,
s: saturation,
l: lightness,
a: alpha
};
},
toColorPart: function (num) {
num = Math.round(num);
var digits = num.toString(16);
if (num < 16) {
return '0' + digits;
}
return digits;
},
__new__: function () {
var m = MochiKit.Base;
this.Color.fromRGBString = m.bind(
this.Color._fromColorString, this.Color, "rgb", "fromRGB",
[1.0/255.0, 1.0/255.0, 1.0/255.0, 1]
);
this.Color.fromHSLString = m.bind(
this.Color._fromColorString, this.Color, "hsl", "fromHSL",
[1.0/360.0, 0.01, 0.01, 1]
);
var third = 1.0 / 3.0;
var colors = {
// NSColor colors plus transparent
black: [0, 0, 0],
blue: [0, 0, 1],
brown: [0.6, 0.4, 0.2],
cyan: [0, 1, 1],
darkGray: [third, third, third],
gray: [0.5, 0.5, 0.5],
green: [0, 1, 0],
lightGray: [2 * third, 2 * third, 2 * third],
magenta: [1, 0, 1],
orange: [1, 0.5, 0],
purple: [0.5, 0, 0.5],
red: [1, 0, 0],
transparent: [0, 0, 0, 0],
white: [1, 1, 1],
yellow: [1, 1, 0]
};
var makeColor = function (name, r, g, b, a) {
var rval = this.fromRGB(r, g, b, a);
this[name] = function () { return rval; };
return rval;
};
for (var k in colors) {
var name = k + "Color";
var bindArgs = m.concat(
[makeColor, this.Color, name],
colors[k]
);
this.Color[name] = m.bind.apply(null, bindArgs);
}
var isColor = function () {
for (var i = 0; i < arguments.length; i++) {
if (!(arguments[i] instanceof Color)) {
return false;
}
}
return true;
};
var compareColor = function (a, b) {
return a.compareRGB(b);
};
m.nameFunctions(this);
m.registerComparator(this.Color.NAME, isColor, compareColor);
this.EXPORT_TAGS = {
":common": this.EXPORT,
":all": m.concat(this.EXPORT, this.EXPORT_OK)
};
}
});
MochiKit.Color.EXPORT = [
"Color"
];
MochiKit.Color.EXPORT_OK = [
"clampColorComponent",
"rgbToHSL",
"hslToRGB",
"rgbToHSV",
"hsvToRGB",
"toColorPart"
];
MochiKit.Color.__new__();
MochiKit.Base._exportSymbols(this, MochiKit.Color);
// Full table of css3 X11 colors <http://www.w3.org/TR/css3-color/#X11COLORS>
MochiKit.Color.Color._namedColors = {
aliceblue: "#f0f8ff",
antiquewhite: "#faebd7",
aqua: "#00ffff",
aquamarine: "#7fffd4",
azure: "#f0ffff",
beige: "#f5f5dc",
bisque: "#ffe4c4",
black: "#000000",
blanchedalmond: "#ffebcd",
blue: "#0000ff",
blueviolet: "#8a2be2",
brown: "#a52a2a",
burlywood: "#deb887",
cadetblue: "#5f9ea0",
chartreuse: "#7fff00",
chocolate: "#d2691e",
coral: "#ff7f50",
cornflowerblue: "#6495ed",
cornsilk: "#fff8dc",
crimson: "#dc143c",
cyan: "#00ffff",
darkblue: "#00008b",
darkcyan: "#008b8b",
darkgoldenrod: "#b8860b",
darkgray: "#a9a9a9",
darkgreen: "#006400",
darkgrey: "#a9a9a9",
darkkhaki: "#bdb76b",
darkmagenta: "#8b008b",
darkolivegreen: "#556b2f",
darkorange: "#ff8c00",
darkorchid: "#9932cc",
darkred: "#8b0000",
darksalmon: "#e9967a",
darkseagreen: "#8fbc8f",
darkslateblue: "#483d8b",
darkslategray: "#2f4f4f",
darkslategrey: "#2f4f4f",
darkturquoise: "#00ced1",
darkviolet: "#9400d3",
deeppink: "#ff1493",
deepskyblue: "#00bfff",
dimgray: "#696969",
dimgrey: "#696969",
dodgerblue: "#1e90ff",
firebrick: "#b22222",
floralwhite: "#fffaf0",
forestgreen: "#228b22",
fuchsia: "#ff00ff",
gainsboro: "#dcdcdc",
ghostwhite: "#f8f8ff",
gold: "#ffd700",
goldenrod: "#daa520",
gray: "#808080",
green: "#008000",
greenyellow: "#adff2f",
grey: "#808080",
honeydew: "#f0fff0",
hotpink: "#ff69b4",
indianred: "#cd5c5c",
indigo: "#4b0082",
ivory: "#fffff0",
khaki: "#f0e68c",
lavender: "#e6e6fa",
lavenderblush: "#fff0f5",
lawngreen: "#7cfc00",
lemonchiffon: "#fffacd",
lightblue: "#add8e6",
lightcoral: "#f08080",
lightcyan: "#e0ffff",
lightgoldenrodyellow: "#fafad2",
lightgray: "#d3d3d3",
lightgreen: "#90ee90",
lightgrey: "#d3d3d3",
lightpink: "#ffb6c1",
lightsalmon: "#ffa07a",
lightseagreen: "#20b2aa",
lightskyblue: "#87cefa",
lightslategray: "#778899",
lightslategrey: "#778899",
lightsteelblue: "#b0c4de",
lightyellow: "#ffffe0",
lime: "#00ff00",
limegreen: "#32cd32",
linen: "#faf0e6",
magenta: "#ff00ff",
maroon: "#800000",
mediumaquamarine: "#66cdaa",
mediumblue: "#0000cd",
mediumorchid: "#ba55d3",
mediumpurple: "#9370db",
mediumseagreen: "#3cb371",
mediumslateblue: "#7b68ee",
mediumspringgreen: "#00fa9a",
mediumturquoise: "#48d1cc",
mediumvioletred: "#c71585",
midnightblue: "#191970",
mintcream: "#f5fffa",
mistyrose: "#ffe4e1",
moccasin: "#ffe4b5",
navajowhite: "#ffdead",
navy: "#000080",
oldlace: "#fdf5e6",
olive: "#808000",
olivedrab: "#6b8e23",
orange: "#ffa500",
orangered: "#ff4500",
orchid: "#da70d6",
palegoldenrod: "#eee8aa",
palegreen: "#98fb98",
paleturquoise: "#afeeee",
palevioletred: "#db7093",
papayawhip: "#ffefd5",
peachpuff: "#ffdab9",
peru: "#cd853f",
pink: "#ffc0cb",
plum: "#dda0dd",
powderblue: "#b0e0e6",
purple: "#800080",
red: "#ff0000",
rosybrown: "#bc8f8f",
royalblue: "#4169e1",
saddlebrown: "#8b4513",
salmon: "#fa8072",
sandybrown: "#f4a460",
seagreen: "#2e8b57",
seashell: "#fff5ee",
sienna: "#a0522d",
silver: "#c0c0c0",
skyblue: "#87ceeb",
slateblue: "#6a5acd",
slategray: "#708090",
slategrey: "#708090",
snow: "#fffafa",
springgreen: "#00ff7f",
steelblue: "#4682b4",
tan: "#d2b48c",
teal: "#008080",
thistle: "#d8bfd8",
tomato: "#ff6347",
turquoise: "#40e0d0",
violet: "#ee82ee",
wheat: "#f5deb3",
white: "#ffffff",
whitesmoke: "#f5f5f5",
yellow: "#ffff00",
yellowgreen: "#9acd32"
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,208 +0,0 @@
/***
MochiKit.DateTime 1.3.1
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2005 Bob Ippolito. All rights Reserved.
***/
if (typeof(dojo) != 'undefined') {
dojo.provide('MochiKit.DateTime');
}
if (typeof(MochiKit) == 'undefined') {
MochiKit = {};
}
if (typeof(MochiKit.DateTime) == 'undefined') {
MochiKit.DateTime = {};
}
MochiKit.DateTime.NAME = "MochiKit.DateTime";
MochiKit.DateTime.VERSION = "1.3.1";
MochiKit.DateTime.__repr__ = function () {
return "[" + this.NAME + " " + this.VERSION + "]";
};
MochiKit.DateTime.toString = function () {
return this.__repr__();
};
MochiKit.DateTime.isoDate = function (str) {
str = str + "";
if (typeof(str) != "string" || str.length === 0) {
return null;
}
var iso = str.split('-');
if (iso.length === 0) {
return null;
}
return new Date(iso[0], iso[1] - 1, iso[2]);
};
MochiKit.DateTime._isoRegexp = /(\d{4,})(?:-(\d{1,2})(?:-(\d{1,2})(?:[T ](\d{1,2}):(\d{1,2})(?::(\d{1,2})(?:\.(\d+))?)?(?:(Z)|([+-])(\d{1,2})(?::(\d{1,2}))?)?)?)?)?/;
MochiKit.DateTime.isoTimestamp = function (str) {
str = str + "";
if (typeof(str) != "string" || str.length === 0) {
return null;
}
var res = str.match(MochiKit.DateTime._isoRegexp);
if (typeof(res) == "undefined" || res === null) {
return null;
}
var year, month, day, hour, min, sec, msec;
year = parseInt(res[1], 10);
if (typeof(res[2]) == "undefined" || res[2] === '') {
return new Date(year);
}
month = parseInt(res[2], 10) - 1;
day = parseInt(res[3], 10);
if (typeof(res[4]) == "undefined" || res[4] === '') {
return new Date(year, month, day);
}
hour = parseInt(res[4], 10);
min = parseInt(res[5], 10);
sec = (typeof(res[6]) != "undefined" && res[6] !== '') ? parseInt(res[6], 10) : 0;
if (typeof(res[7]) != "undefined" && res[7] !== '') {
msec = Math.round(1000.0 * parseFloat("0." + res[7]));
} else {
msec = 0;
}
if ((typeof(res[8]) == "undefined" || res[8] === '') && (typeof(res[9]) == "undefined" || res[9] === '')) {
return new Date(year, month, day, hour, min, sec, msec);
}
var ofs;
if (typeof(res[9]) != "undefined" && res[9] !== '') {
ofs = parseInt(res[10], 10) * 3600000;
if (typeof(res[11]) != "undefined" && res[11] !== '') {
ofs += parseInt(res[11], 10) * 60000;
}
if (res[9] == "-") {
ofs = -ofs;
}
} else {
ofs = 0;
}
return new Date(Date.UTC(year, month, day, hour, min, sec, msec) - ofs);
};
MochiKit.DateTime.toISOTime = function (date, realISO/* = false */) {
if (typeof(date) == "undefined" || date === null) {
return null;
}
var hh = date.getHours();
var mm = date.getMinutes();
var ss = date.getSeconds();
var lst = [
((realISO && (hh < 10)) ? "0" + hh : hh),
((mm < 10) ? "0" + mm : mm),
((ss < 10) ? "0" + ss : ss)
];
return lst.join(":");
};
MochiKit.DateTime.toISOTimestamp = function (date, realISO/* = false*/) {
if (typeof(date) == "undefined" || date === null) {
return null;
}
var sep = realISO ? "T" : " ";
var foot = realISO ? "Z" : "";
if (realISO) {
date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000));
}
return MochiKit.DateTime.toISODate(date) + sep + MochiKit.DateTime.toISOTime(date, realISO) + foot;
};
MochiKit.DateTime.toISODate = function (date) {
if (typeof(date) == "undefined" || date === null) {
return null;
}
var _padTwo = MochiKit.DateTime._padTwo;
return [
date.getFullYear(),
_padTwo(date.getMonth() + 1),
_padTwo(date.getDate())
].join("-");
};
MochiKit.DateTime.americanDate = function (d) {
d = d + "";
if (typeof(d) != "string" || d.length === 0) {
return null;
}
var a = d.split('/');
return new Date(a[2], a[0] - 1, a[1]);
};
MochiKit.DateTime._padTwo = function (n) {
return (n > 9) ? n : "0" + n;
};
MochiKit.DateTime.toPaddedAmericanDate = function (d) {
if (typeof(d) == "undefined" || d === null) {
return null;
}
var _padTwo = MochiKit.DateTime._padTwo;
return [
_padTwo(d.getMonth() + 1),
_padTwo(d.getDate()),
d.getFullYear()
].join('/');
};
MochiKit.DateTime.toAmericanDate = function (d) {
if (typeof(d) == "undefined" || d === null) {
return null;
}
return [d.getMonth() + 1, d.getDate(), d.getFullYear()].join('/');
};
MochiKit.DateTime.EXPORT = [
"isoDate",
"isoTimestamp",
"toISOTime",
"toISOTimestamp",
"toISODate",
"americanDate",
"toPaddedAmericanDate",
"toAmericanDate"
];
MochiKit.DateTime.EXPORT_OK = [];
MochiKit.DateTime.EXPORT_TAGS = {
":common": MochiKit.DateTime.EXPORT,
":all": MochiKit.DateTime.EXPORT
};
MochiKit.DateTime.__new__ = function () {
// MochiKit.Base.nameFunctions(this);
var base = this.NAME + ".";
for (var k in this) {
var o = this[k];
if (typeof(o) == 'function' && typeof(o.NAME) == 'undefined') {
try {
o.NAME = base + k;
} catch (e) {
// pass
}
}
}
};
MochiKit.DateTime.__new__();
if (typeof(MochiKit.Base) != "undefined") {
MochiKit.Base._exportSymbols(this, MochiKit.DateTime);
} else {
(function (globals, module) {
if ((typeof(JSAN) == 'undefined' && typeof(dojo) == 'undefined')
|| (typeof(MochiKit.__compat__) == 'boolean' && MochiKit.__compat__)) {
var all = module.EXPORT_TAGS[":all"];
for (var i = 0; i < all.length; i++) {
globals[all[i]] = module[all[i]];
}
}
})(this, MochiKit.DateTime);
}

View File

@@ -1,294 +0,0 @@
/***
MochiKit.Format 1.3.1
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2005 Bob Ippolito. All rights Reserved.
***/
if (typeof(dojo) != 'undefined') {
dojo.provide('MochiKit.Format');
}
if (typeof(MochiKit) == 'undefined') {
MochiKit = {};
}
if (typeof(MochiKit.Format) == 'undefined') {
MochiKit.Format = {};
}
MochiKit.Format.NAME = "MochiKit.Format";
MochiKit.Format.VERSION = "1.3.1";
MochiKit.Format.__repr__ = function () {
return "[" + this.NAME + " " + this.VERSION + "]";
};
MochiKit.Format.toString = function () {
return this.__repr__();
};
MochiKit.Format._numberFormatter = function (placeholder, header, footer, locale, isPercent, precision, leadingZeros, separatorAt, trailingZeros) {
return function (num) {
num = parseFloat(num);
if (typeof(num) == "undefined" || num === null || isNaN(num)) {
return placeholder;
}
var curheader = header;
var curfooter = footer;
if (num < 0) {
num = -num;
} else {
curheader = curheader.replace(/-/, "");
}
var me = arguments.callee;
var fmt = MochiKit.Format.formatLocale(locale);
if (isPercent) {
num = num * 100.0;
curfooter = fmt.percent + curfooter;
}
num = MochiKit.Format.roundToFixed(num, precision);
var parts = num.split(/\./);
var whole = parts[0];
var frac = (parts.length == 1) ? "" : parts[1];
var res = "";
while (whole.length < leadingZeros) {
whole = "0" + whole;
}
if (separatorAt) {
while (whole.length > separatorAt) {
var i = whole.length - separatorAt;
//res = res + fmt.separator + whole.substring(i, whole.length);
res = fmt.separator + whole.substring(i, whole.length) + res;
whole = whole.substring(0, i);
}
}
res = whole + res;
if (precision > 0) {
while (frac.length < trailingZeros) {
frac = frac + "0";
}
res = res + fmt.decimal + frac;
}
return curheader + res + curfooter;
};
};
MochiKit.Format.numberFormatter = function (pattern, placeholder/* = "" */, locale/* = "default" */) {
// http://java.sun.com/docs/books/tutorial/i18n/format/numberpattern.html
// | 0 | leading or trailing zeros
// | # | just the number
// | , | separator
// | . | decimal separator
// | % | Multiply by 100 and format as percent
if (typeof(placeholder) == "undefined") {
placeholder = "";
}
var match = pattern.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/);
if (!match) {
throw TypeError("Invalid pattern");
}
var header = pattern.substr(0, match.index);
var footer = pattern.substr(match.index + match[0].length);
if (header.search(/-/) == -1) {
header = header + "-";
}
var whole = match[1];
var frac = (typeof(match[2]) == "string" && match[2] != "") ? match[2] : "";
var isPercent = (typeof(match[3]) == "string" && match[3] != "");
var tmp = whole.split(/,/);
var separatorAt;
if (typeof(locale) == "undefined") {
locale = "default";
}
if (tmp.length == 1) {
separatorAt = null;
} else {
separatorAt = tmp[1].length;
}
var leadingZeros = whole.length - whole.replace(/0/g, "").length;
var trailingZeros = frac.length - frac.replace(/0/g, "").length;
var precision = frac.length;
var rval = MochiKit.Format._numberFormatter(
placeholder, header, footer, locale, isPercent, precision,
leadingZeros, separatorAt, trailingZeros
);
var m = MochiKit.Base;
if (m) {
var fn = arguments.callee;
var args = m.concat(arguments);
rval.repr = function () {
return [
self.NAME,
"(",
map(m.repr, args).join(", "),
")"
].join("");
};
}
return rval;
};
MochiKit.Format.formatLocale = function (locale) {
if (typeof(locale) == "undefined" || locale === null) {
locale = "default";
}
if (typeof(locale) == "string") {
var rval = MochiKit.Format.LOCALE[locale];
if (typeof(rval) == "string") {
rval = arguments.callee(rval);
MochiKit.Format.LOCALE[locale] = rval;
}
return rval;
} else {
return locale;
}
};
MochiKit.Format.twoDigitAverage = function (numerator, denominator) {
if (denominator) {
var res = numerator / denominator;
if (!isNaN(res)) {
return MochiKit.Format.twoDigitFloat(numerator / denominator);
}
}
return "0";
};
MochiKit.Format.twoDigitFloat = function (someFloat) {
var sign = (someFloat < 0 ? '-' : '');
var s = Math.floor(Math.abs(someFloat) * 100).toString();
if (s == '0') {
return s;
}
if (s.length < 3) {
while (s.charAt(s.length - 1) == '0') {
s = s.substring(0, s.length - 1);
}
return sign + '0.' + s;
}
var head = sign + s.substring(0, s.length - 2);
var tail = s.substring(s.length - 2, s.length);
if (tail == '00') {
return head;
} else if (tail.charAt(1) == '0') {
return head + '.' + tail.charAt(0);
} else {
return head + '.' + tail;
}
};
MochiKit.Format.lstrip = function (str, /* optional */chars) {
str = str + "";
if (typeof(str) != "string") {
return null;
}
if (!chars) {
return str.replace(/^\s+/, "");
} else {
return str.replace(new RegExp("^[" + chars + "]+"), "");
}
};
MochiKit.Format.rstrip = function (str, /* optional */chars) {
str = str + "";
if (typeof(str) != "string") {
return null;
}
if (!chars) {
return str.replace(/\s+$/, "");
} else {
return str.replace(new RegExp("[" + chars + "]+$"), "");
}
};
MochiKit.Format.strip = function (str, /* optional */chars) {
var self = MochiKit.Format;
return self.rstrip(self.lstrip(str, chars), chars);
};
MochiKit.Format.truncToFixed = function (aNumber, precision) {
aNumber = Math.floor(aNumber * Math.pow(10, precision));
var res = (aNumber * Math.pow(10, -precision)).toFixed(precision);
if (res.charAt(0) == ".") {
res = "0" + res;
}
return res;
};
MochiKit.Format.roundToFixed = function (aNumber, precision) {
return MochiKit.Format.truncToFixed(
aNumber + 0.5 * Math.pow(10, -precision),
precision
);
};
MochiKit.Format.percentFormat = function (someFloat) {
return MochiKit.Format.twoDigitFloat(100 * someFloat) + '%';
};
MochiKit.Format.EXPORT = [
"truncToFixed",
"roundToFixed",
"numberFormatter",
"formatLocale",
"twoDigitAverage",
"twoDigitFloat",
"percentFormat",
"lstrip",
"rstrip",
"strip"
];
MochiKit.Format.LOCALE = {
en_US: {separator: ",", decimal: ".", percent: "%"},
de_DE: {separator: ".", decimal: ",", percent: "%"},
fr_FR: {separator: " ", decimal: ",", percent: "%"},
"default": "en_US"
};
MochiKit.Format.EXPORT_OK = [];
MochiKit.Format.EXPORT_TAGS = {
':all': MochiKit.Format.EXPORT,
':common': MochiKit.Format.EXPORT
};
MochiKit.Format.__new__ = function () {
// MochiKit.Base.nameFunctions(this);
var base = this.NAME + ".";
var k, v, o;
for (k in this.LOCALE) {
o = this.LOCALE[k];
if (typeof(o) == "object") {
o.repr = function () { return this.NAME; };
o.NAME = base + "LOCALE." + k;
}
}
for (k in this) {
o = this[k];
if (typeof(o) == 'function' && typeof(o.NAME) == 'undefined') {
try {
o.NAME = base + k;
} catch (e) {
// pass
}
}
}
};
MochiKit.Format.__new__();
if (typeof(MochiKit.Base) != "undefined") {
MochiKit.Base._exportSymbols(this, MochiKit.Format);
} else {
(function (globals, module) {
if ((typeof(JSAN) == 'undefined' && typeof(dojo) == 'undefined')
|| (typeof(MochiKit.__compat__) == 'boolean' && MochiKit.__compat__)) {
var all = module.EXPORT_TAGS[":all"];
for (var i = 0; i < all.length; i++) {
globals[all[i]] = module[all[i]];
}
}
})(this, MochiKit.Format);
}

View File

@@ -1,789 +0,0 @@
/***
MochiKit.Iter 1.3.1
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2005 Bob Ippolito. All rights Reserved.
***/
if (typeof(dojo) != 'undefined') {
dojo.provide('MochiKit.Iter');
dojo.require('MochiKit.Base');
}
if (typeof(JSAN) != 'undefined') {
JSAN.use("MochiKit.Base", []);
}
try {
if (typeof(MochiKit.Base) == 'undefined') {
throw "";
}
} catch (e) {
throw "MochiKit.Iter depends on MochiKit.Base!";
}
if (typeof(MochiKit.Iter) == 'undefined') {
MochiKit.Iter = {};
}
MochiKit.Iter.NAME = "MochiKit.Iter";
MochiKit.Iter.VERSION = "1.3.1";
MochiKit.Base.update(MochiKit.Iter, {
__repr__: function () {
return "[" + this.NAME + " " + this.VERSION + "]";
},
toString: function () {
return this.__repr__();
},
registerIteratorFactory: function (name, check, iterfactory, /* optional */ override) {
MochiKit.Iter.iteratorRegistry.register(name, check, iterfactory, override);
},
iter: function (iterable, /* optional */ sentinel) {
var self = MochiKit.Iter;
if (arguments.length == 2) {
return self.takewhile(
function (a) { return a != sentinel; },
iterable
);
}
if (typeof(iterable.next) == 'function') {
return iterable;
} else if (typeof(iterable.iter) == 'function') {
return iterable.iter();
}
try {
return self.iteratorRegistry.match(iterable);
} catch (e) {
var m = MochiKit.Base;
if (e == m.NotFound) {
e = new TypeError(typeof(iterable) + ": " + m.repr(iterable) + " is not iterable");
}
throw e;
}
},
count: function (n) {
if (!n) {
n = 0;
}
var m = MochiKit.Base;
return {
repr: function () { return "count(" + n + ")"; },
toString: m.forwardCall("repr"),
next: m.counter(n)
};
},
cycle: function (p) {
var self = MochiKit.Iter;
var m = MochiKit.Base;
var lst = [];
var iterator = self.iter(p);
return {
repr: function () { return "cycle(...)"; },
toString: m.forwardCall("repr"),
next: function () {
try {
var rval = iterator.next();
lst.push(rval);
return rval;
} catch (e) {
if (e != self.StopIteration) {
throw e;
}
if (lst.length === 0) {
this.next = function () {
throw self.StopIteration;
};
} else {
var i = -1;
this.next = function () {
i = (i + 1) % lst.length;
return lst[i];
};
}
return this.next();
}
}
};
},
repeat: function (elem, /* optional */n) {
var m = MochiKit.Base;
if (typeof(n) == 'undefined') {
return {
repr: function () {
return "repeat(" + m.repr(elem) + ")";
},
toString: m.forwardCall("repr"),
next: function () {
return elem;
}
};
}
return {
repr: function () {
return "repeat(" + m.repr(elem) + ", " + n + ")";
},
toString: m.forwardCall("repr"),
next: function () {
if (n <= 0) {
throw MochiKit.Iter.StopIteration;
}
n -= 1;
return elem;
}
};
},
next: function (iterator) {
return iterator.next();
},
izip: function (p, q/*, ...*/) {
var m = MochiKit.Base;
var next = MochiKit.Iter.next;
var iterables = m.map(iter, arguments);
return {
repr: function () { return "izip(...)"; },
toString: m.forwardCall("repr"),
next: function () { return m.map(next, iterables); }
};
},
ifilter: function (pred, seq) {
var m = MochiKit.Base;
seq = MochiKit.Iter.iter(seq);
if (pred === null) {
pred = m.operator.truth;
}
return {
repr: function () { return "ifilter(...)"; },
toString: m.forwardCall("repr"),
next: function () {
while (true) {
var rval = seq.next();
if (pred(rval)) {
return rval;
}
}
// mozilla warnings aren't too bright
return undefined;
}
};
},
ifilterfalse: function (pred, seq) {
var m = MochiKit.Base;
seq = MochiKit.Iter.iter(seq);
if (pred === null) {
pred = m.operator.truth;
}
return {
repr: function () { return "ifilterfalse(...)"; },
toString: m.forwardCall("repr"),
next: function () {
while (true) {
var rval = seq.next();
if (!pred(rval)) {
return rval;
}
}
// mozilla warnings aren't too bright
return undefined;
}
};
},
islice: function (seq/*, [start,] stop[, step] */) {
var self = MochiKit.Iter;
var m = MochiKit.Base;
seq = self.iter(seq);
var start = 0;
var stop = 0;
var step = 1;
var i = -1;
if (arguments.length == 2) {
stop = arguments[1];
} else if (arguments.length == 3) {
start = arguments[1];
stop = arguments[2];
} else {
start = arguments[1];
stop = arguments[2];
step = arguments[3];
}
return {
repr: function () {
return "islice(" + ["...", start, stop, step].join(", ") + ")";
},
toString: m.forwardCall("repr"),
next: function () {
var rval;
while (i < start) {
rval = seq.next();
i++;
}
if (start >= stop) {
throw self.StopIteration;
}
start += step;
return rval;
}
};
},
imap: function (fun, p, q/*, ...*/) {
var m = MochiKit.Base;
var self = MochiKit.Iter;
var iterables = m.map(self.iter, m.extend(null, arguments, 1));
var map = m.map;
var next = self.next;
return {
repr: function () { return "imap(...)"; },
toString: m.forwardCall("repr"),
next: function () {
return fun.apply(this, map(next, iterables));
}
};
},
applymap: function (fun, seq, self) {
seq = MochiKit.Iter.iter(seq);
var m = MochiKit.Base;
return {
repr: function () { return "applymap(...)"; },
toString: m.forwardCall("repr"),
next: function () {
return fun.apply(self, seq.next());
}
};
},
chain: function (p, q/*, ...*/) {
// dumb fast path
var self = MochiKit.Iter;
var m = MochiKit.Base;
if (arguments.length == 1) {
return self.iter(arguments[0]);
}
var argiter = m.map(self.iter, arguments);
return {
repr: function () { return "chain(...)"; },
toString: m.forwardCall("repr"),
next: function () {
while (argiter.length > 1) {
try {
return argiter[0].next();
} catch (e) {
if (e != self.StopIteration) {
throw e;
}
argiter.shift();
}
}
if (argiter.length == 1) {
// optimize last element
var arg = argiter.shift();
this.next = m.bind("next", arg);
return this.next();
}
throw self.StopIteration;
}
};
},
takewhile: function (pred, seq) {
var self = MochiKit.Iter;
seq = self.iter(seq);
return {
repr: function () { return "takewhile(...)"; },
toString: MochiKit.Base.forwardCall("repr"),
next: function () {
var rval = seq.next();
if (!pred(rval)) {
this.next = function () {
throw self.StopIteration;
};
this.next();
}
return rval;
}
};
},
dropwhile: function (pred, seq) {
seq = MochiKit.Iter.iter(seq);
var m = MochiKit.Base;
var bind = m.bind;
return {
"repr": function () { return "dropwhile(...)"; },
"toString": m.forwardCall("repr"),
"next": function () {
while (true) {
var rval = seq.next();
if (!pred(rval)) {
break;
}
}
this.next = bind("next", seq);
return rval;
}
};
},
_tee: function (ident, sync, iterable) {
sync.pos[ident] = -1;
var m = MochiKit.Base;
var listMin = m.listMin;
return {
repr: function () { return "tee(" + ident + ", ...)"; },
toString: m.forwardCall("repr"),
next: function () {
var rval;
var i = sync.pos[ident];
if (i == sync.max) {
rval = iterable.next();
sync.deque.push(rval);
sync.max += 1;
sync.pos[ident] += 1;
} else {
rval = sync.deque[i - sync.min];
sync.pos[ident] += 1;
if (i == sync.min && listMin(sync.pos) != sync.min) {
sync.min += 1;
sync.deque.shift();
}
}
return rval;
}
};
},
tee: function (iterable, n/* = 2 */) {
var rval = [];
var sync = {
"pos": [],
"deque": [],
"max": -1,
"min": -1
};
if (arguments.length == 1) {
n = 2;
}
var self = MochiKit.Iter;
iterable = self.iter(iterable);
var _tee = self._tee;
for (var i = 0; i < n; i++) {
rval.push(_tee(i, sync, iterable));
}
return rval;
},
list: function (iterable) {
// Fast-path for Array and Array-like
var m = MochiKit.Base;
if (typeof(iterable.slice) == 'function') {
return iterable.slice();
} else if (m.isArrayLike(iterable)) {
return m.concat(iterable);
}
var self = MochiKit.Iter;
iterable = self.iter(iterable);
var rval = [];
try {
while (true) {
rval.push(iterable.next());
}
} catch (e) {
if (e != self.StopIteration) {
throw e;
}
return rval;
}
// mozilla warnings aren't too bright
return undefined;
},
reduce: function (fn, iterable, /* optional */initial) {
var i = 0;
var x = initial;
var self = MochiKit.Iter;
iterable = self.iter(iterable);
if (arguments.length < 3) {
try {
x = iterable.next();
} catch (e) {
if (e == self.StopIteration) {
e = new TypeError("reduce() of empty sequence with no initial value");
}
throw e;
}
i++;
}
try {
while (true) {
x = fn(x, iterable.next());
}
} catch (e) {
if (e != self.StopIteration) {
throw e;
}
}
return x;
},
range: function (/* [start,] stop[, step] */) {
var start = 0;
var stop = 0;
var step = 1;
if (arguments.length == 1) {
stop = arguments[0];
} else if (arguments.length == 2) {
start = arguments[0];
stop = arguments[1];
} else if (arguments.length == 3) {
start = arguments[0];
stop = arguments[1];
step = arguments[2];
} else {
throw new TypeError("range() takes 1, 2, or 3 arguments!");
}
if (step === 0) {
throw new TypeError("range() step must not be 0");
}
return {
next: function () {
if ((step > 0 && start >= stop) || (step < 0 && start <= stop)) {
throw MochiKit.Iter.StopIteration;
}
var rval = start;
start += step;
return rval;
},
repr: function () {
return "range(" + [start, stop, step].join(", ") + ")";
},
toString: MochiKit.Base.forwardCall("repr")
};
},
sum: function (iterable, start/* = 0 */) {
var x = start || 0;
var self = MochiKit.Iter;
iterable = self.iter(iterable);
try {
while (true) {
x += iterable.next();
}
} catch (e) {
if (e != self.StopIteration) {
throw e;
}
}
return x;
},
exhaust: function (iterable) {
var self = MochiKit.Iter;
iterable = self.iter(iterable);
try {
while (true) {
iterable.next();
}
} catch (e) {
if (e != self.StopIteration) {
throw e;
}
}
},
forEach: function (iterable, func, /* optional */self) {
var m = MochiKit.Base;
if (arguments.length > 2) {
func = m.bind(func, self);
}
// fast path for array
if (m.isArrayLike(iterable)) {
try {
for (var i = 0; i < iterable.length; i++) {
func(iterable[i]);
}
} catch (e) {
if (e != MochiKit.Iter.StopIteration) {
throw e;
}
}
} else {
self = MochiKit.Iter;
self.exhaust(self.imap(func, iterable));
}
},
every: function (iterable, func) {
var self = MochiKit.Iter;
try {
self.ifilterfalse(func, iterable).next();
return false;
} catch (e) {
if (e != self.StopIteration) {
throw e;
}
return true;
}
},
sorted: function (iterable, /* optional */cmp) {
var rval = MochiKit.Iter.list(iterable);
if (arguments.length == 1) {
cmp = MochiKit.Base.compare;
}
rval.sort(cmp);
return rval;
},
reversed: function (iterable) {
var rval = MochiKit.Iter.list(iterable);
rval.reverse();
return rval;
},
some: function (iterable, func) {
var self = MochiKit.Iter;
try {
self.ifilter(func, iterable).next();
return true;
} catch (e) {
if (e != self.StopIteration) {
throw e;
}
return false;
}
},
iextend: function (lst, iterable) {
if (MochiKit.Base.isArrayLike(iterable)) {
// fast-path for array-like
for (var i = 0; i < iterable.length; i++) {
lst.push(iterable[i]);
}
} else {
var self = MochiKit.Iter;
iterable = self.iter(iterable);
try {
while (true) {
lst.push(iterable.next());
}
} catch (e) {
if (e != self.StopIteration) {
throw e;
}
}
}
return lst;
},
groupby: function(iterable, /* optional */ keyfunc) {
var m = MochiKit.Base;
var self = MochiKit.Iter;
if (arguments.length < 2) {
keyfunc = m.operator.identity;
}
iterable = self.iter(iterable);
// shared
var pk = undefined;
var k = undefined;
var v;
function fetch() {
v = iterable.next();
k = keyfunc(v);
};
function eat() {
var ret = v;
v = undefined;
return ret;
};
var first = true;
return {
repr: function () { return "groupby(...)"; },
next: function() {
// iterator-next
// iterate until meet next group
while (k == pk) {
fetch();
if (first) {
first = false;
break;
}
}
pk = k;
return [k, {
next: function() {
// subiterator-next
if (v == undefined) { // Is there something to eat?
fetch();
}
if (k != pk) {
throw self.StopIteration;
}
return eat();
}
}];
}
};
},
groupby_as_array: function (iterable, /* optional */ keyfunc) {
var m = MochiKit.Base;
var self = MochiKit.Iter;
if (arguments.length < 2) {
keyfunc = m.operator.identity;
}
iterable = self.iter(iterable);
var result = [];
var first = true;
var prev_key;
while (true) {
try {
var value = iterable.next();
var key = keyfunc(value);
} catch (e) {
if (e == self.StopIteration) {
break;
}
throw e;
}
if (first || key != prev_key) {
var values = [];
result.push([key, values]);
}
values.push(value);
first = false;
prev_key = key;
}
return result;
},
arrayLikeIter: function (iterable) {
var i = 0;
return {
repr: function () { return "arrayLikeIter(...)"; },
toString: MochiKit.Base.forwardCall("repr"),
next: function () {
if (i >= iterable.length) {
throw MochiKit.Iter.StopIteration;
}
return iterable[i++];
}
};
},
hasIterateNext: function (iterable) {
return (iterable && typeof(iterable.iterateNext) == "function");
},
iterateNextIter: function (iterable) {
return {
repr: function () { return "iterateNextIter(...)"; },
toString: MochiKit.Base.forwardCall("repr"),
next: function () {
var rval = iterable.iterateNext();
if (rval === null || rval === undefined) {
throw MochiKit.Iter.StopIteration;
}
return rval;
}
};
}
});
MochiKit.Iter.EXPORT_OK = [
"iteratorRegistry",
"arrayLikeIter",
"hasIterateNext",
"iterateNextIter",
];
MochiKit.Iter.EXPORT = [
"StopIteration",
"registerIteratorFactory",
"iter",
"count",
"cycle",
"repeat",
"next",
"izip",
"ifilter",
"ifilterfalse",
"islice",
"imap",
"applymap",
"chain",
"takewhile",
"dropwhile",
"tee",
"list",
"reduce",
"range",
"sum",
"exhaust",
"forEach",
"every",
"sorted",
"reversed",
"some",
"iextend",
"groupby",
"groupby_as_array"
];
MochiKit.Iter.__new__ = function () {
var m = MochiKit.Base;
this.StopIteration = new m.NamedError("StopIteration");
this.iteratorRegistry = new m.AdapterRegistry();
// Register the iterator factory for arrays
this.registerIteratorFactory(
"arrayLike",
m.isArrayLike,
this.arrayLikeIter
);
this.registerIteratorFactory(
"iterateNext",
this.hasIterateNext,
this.iterateNextIter
);
this.EXPORT_TAGS = {
":common": this.EXPORT,
":all": m.concat(this.EXPORT, this.EXPORT_OK)
};
m.nameFunctions(this);
};
MochiKit.Iter.__new__();
//
// XXX: Internet Explorer blows
//
if (!MochiKit.__compat__) {
reduce = MochiKit.Iter.reduce;
}
MochiKit.Base._exportSymbols(this, MochiKit.Iter);

View File

@@ -1,290 +0,0 @@
/***
MochiKit.Logging 1.3.1
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2005 Bob Ippolito. All rights Reserved.
***/
if (typeof(dojo) != 'undefined') {
dojo.provide('MochiKit.Logging');
dojo.require('MochiKit.Base');
}
if (typeof(JSAN) != 'undefined') {
JSAN.use("MochiKit.Base", []);
}
try {
if (typeof(MochiKit.Base) == 'undefined') {
throw "";
}
} catch (e) {
throw "MochiKit.Logging depends on MochiKit.Base!";
}
if (typeof(MochiKit.Logging) == 'undefined') {
MochiKit.Logging = {};
}
MochiKit.Logging.NAME = "MochiKit.Logging";
MochiKit.Logging.VERSION = "1.3.1";
MochiKit.Logging.__repr__ = function () {
return "[" + this.NAME + " " + this.VERSION + "]";
};
MochiKit.Logging.toString = function () {
return this.__repr__();
};
MochiKit.Logging.EXPORT = [
"LogLevel",
"LogMessage",
"Logger",
"alertListener",
"logger",
"log",
"logError",
"logDebug",
"logFatal",
"logWarning"
];
MochiKit.Logging.EXPORT_OK = [
"logLevelAtLeast",
"isLogMessage",
"compareLogMessage"
];
MochiKit.Logging.LogMessage = function (num, level, info) {
this.num = num;
this.level = level;
this.info = info;
this.timestamp = new Date();
};
MochiKit.Logging.LogMessage.prototype = {
repr: function () {
var m = MochiKit.Base;
return 'LogMessage(' +
m.map(
m.repr,
[this.num, this.level, this.info]
).join(', ') + ')';
},
toString: MochiKit.Base.forwardCall("repr")
};
MochiKit.Base.update(MochiKit.Logging, {
logLevelAtLeast: function (minLevel) {
var self = MochiKit.Logging;
if (typeof(minLevel) == 'string') {
minLevel = self.LogLevel[minLevel];
}
return function (msg) {
var msgLevel = msg.level;
if (typeof(msgLevel) == 'string') {
msgLevel = self.LogLevel[msgLevel];
}
return msgLevel >= minLevel;
};
},
isLogMessage: function (/* ... */) {
var LogMessage = MochiKit.Logging.LogMessage;
for (var i = 0; i < arguments.length; i++) {
if (!(arguments[i] instanceof LogMessage)) {
return false;
}
}
return true;
},
compareLogMessage: function (a, b) {
return MochiKit.Base.compare([a.level, a.info], [b.level, b.info]);
},
alertListener: function (msg) {
alert(
"num: " + msg.num +
"\nlevel: " + msg.level +
"\ninfo: " + msg.info.join(" ")
);
}
});
MochiKit.Logging.Logger = function (/* optional */maxSize) {
this.counter = 0;
if (typeof(maxSize) == 'undefined' || maxSize === null) {
maxSize = -1;
}
this.maxSize = maxSize;
this._messages = [];
this.listeners = {};
this.useNativeConsole = false;
};
MochiKit.Logging.Logger.prototype = {
clear: function () {
this._messages.splice(0, this._messages.length);
},
logToConsole: function (msg) {
if (typeof(window) != "undefined" && window.console
&& window.console.log) {
// Safari
window.console.log(msg);
} else if (typeof(opera) != "undefined" && opera.postError) {
// Opera
opera.postError(msg);
} else if (typeof(printfire) == "function") {
// FireBug
printfire(msg);
}
},
dispatchListeners: function (msg) {
for (var k in this.listeners) {
var pair = this.listeners[k];
if (pair.ident != k || (pair[0] && !pair[0](msg))) {
continue;
}
pair[1](msg);
}
},
addListener: function (ident, filter, listener) {
if (typeof(filter) == 'string') {
filter = MochiKit.Logging.logLevelAtLeast(filter);
}
var entry = [filter, listener];
entry.ident = ident;
this.listeners[ident] = entry;
},
removeListener: function (ident) {
delete this.listeners[ident];
},
baseLog: function (level, message/*, ...*/) {
var msg = new MochiKit.Logging.LogMessage(
this.counter,
level,
MochiKit.Base.extend(null, arguments, 1)
);
this._messages.push(msg);
this.dispatchListeners(msg);
if (this.useNativeConsole) {
this.logToConsole(msg.level + ": " + msg.info.join(" "));
}
this.counter += 1;
while (this.maxSize >= 0 && this._messages.length > this.maxSize) {
this._messages.shift();
}
},
getMessages: function (howMany) {
var firstMsg = 0;
if (!(typeof(howMany) == 'undefined' || howMany === null)) {
firstMsg = Math.max(0, this._messages.length - howMany);
}
return this._messages.slice(firstMsg);
},
getMessageText: function (howMany) {
if (typeof(howMany) == 'undefined' || howMany === null) {
howMany = 30;
}
var messages = this.getMessages(howMany);
if (messages.length) {
var lst = map(function (m) {
return '\n [' + m.num + '] ' + m.level + ': ' + m.info.join(' ');
}, messages);
lst.unshift('LAST ' + messages.length + ' MESSAGES:');
return lst.join('');
}
return '';
},
debuggingBookmarklet: function (inline) {
if (typeof(MochiKit.LoggingPane) == "undefined") {
alert(this.getMessageText());
} else {
MochiKit.LoggingPane.createLoggingPane(inline || false);
}
}
};
MochiKit.Logging.__new__ = function () {
this.LogLevel = {
ERROR: 40,
FATAL: 50,
WARNING: 30,
INFO: 20,
DEBUG: 10
};
var m = MochiKit.Base;
m.registerComparator("LogMessage",
this.isLogMessage,
this.compareLogMessage
);
var partial = m.partial;
var Logger = this.Logger;
var baseLog = Logger.prototype.baseLog;
m.update(this.Logger.prototype, {
debug: partial(baseLog, 'DEBUG'),
log: partial(baseLog, 'INFO'),
error: partial(baseLog, 'ERROR'),
fatal: partial(baseLog, 'FATAL'),
warning: partial(baseLog, 'WARNING')
});
// indirectly find logger so it can be replaced
var self = this;
var connectLog = function (name) {
return function () {
self.logger[name].apply(self.logger, arguments);
};
};
this.log = connectLog('log');
this.logError = connectLog('error');
this.logDebug = connectLog('debug');
this.logFatal = connectLog('fatal');
this.logWarning = connectLog('warning');
this.logger = new Logger();
this.logger.useNativeConsole = true;
this.EXPORT_TAGS = {
":common": this.EXPORT,
":all": m.concat(this.EXPORT, this.EXPORT_OK)
};
m.nameFunctions(this);
};
if (typeof(printfire) == "undefined" &&
typeof(document) != "undefined" && document.createEvent &&
typeof(dispatchEvent) != "undefined") {
// FireBug really should be less lame about this global function
printfire = function () {
printfire.args = arguments;
var ev = document.createEvent("Events");
ev.initEvent("printfire", false, true);
dispatchEvent(ev);
};
}
MochiKit.Logging.__new__();
MochiKit.Base._exportSymbols(this, MochiKit.Logging);

View File

@@ -1,356 +0,0 @@
/***
MochiKit.LoggingPane 1.3.1
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2005 Bob Ippolito. All rights Reserved.
***/
if (typeof(dojo) != 'undefined') {
dojo.provide('MochiKit.LoggingPane');
dojo.require('MochiKit.Logging');
dojo.require('MochiKit.Base');
}
if (typeof(JSAN) != 'undefined') {
JSAN.use("MochiKit.Logging", []);
JSAN.use("MochiKit.Base", []);
}
try {
if (typeof(MochiKit.Base) == 'undefined' || typeof(MochiKit.Logging) == 'undefined') {
throw "";
}
} catch (e) {
throw "MochiKit.LoggingPane depends on MochiKit.Base and MochiKit.Logging!";
}
if (typeof(MochiKit.LoggingPane) == 'undefined') {
MochiKit.LoggingPane = {};
}
MochiKit.LoggingPane.NAME = "MochiKit.LoggingPane";
MochiKit.LoggingPane.VERSION = "1.3.1";
MochiKit.LoggingPane.__repr__ = function () {
return "[" + this.NAME + " " + this.VERSION + "]";
};
MochiKit.LoggingPane.toString = function () {
return this.__repr__();
};
MochiKit.LoggingPane.createLoggingPane = function (inline/* = false */) {
var m = MochiKit.LoggingPane;
inline = !(!inline);
if (m._loggingPane && m._loggingPane.inline != inline) {
m._loggingPane.closePane();
m._loggingPane = null;
}
if (!m._loggingPane || m._loggingPane.closed) {
m._loggingPane = new m.LoggingPane(inline, MochiKit.Logging.logger);
}
return m._loggingPane;
};
MochiKit.LoggingPane.LoggingPane = function (inline/* = false */, logger/* = MochiKit.Logging.logger */) {
/* Use a div if inline, pop up a window if not */
/* Create the elements */
if (typeof(logger) == "undefined" || logger === null) {
logger = MochiKit.Logging.logger;
}
this.logger = logger;
var update = MochiKit.Base.update;
var updatetree = MochiKit.Base.updatetree;
var bind = MochiKit.Base.bind;
var clone = MochiKit.Base.clone;
var win = window;
var uid = "_MochiKit_LoggingPane";
if (typeof(MochiKit.DOM) != "undefined") {
win = MochiKit.DOM.currentWindow();
}
if (!inline) {
// name the popup with the base URL for uniqueness
var url = win.location.href.split("?")[0].replace(/[:\/.><&]/g, "_");
var name = uid + "_" + url;
var nwin = win.open("", name, "dependent,resizable,height=200");
if (!nwin) {
alert("Not able to open debugging window due to pop-up blocking.");
return undefined;
}
nwin.document.write(
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" '
+ '"http://www.w3.org/TR/html4/loose.dtd">'
+ '<html><head><title>[MochiKit.LoggingPane]</title></head>'
+ '<body></body></html>'
);
nwin.document.close();
nwin.document.title += ' ' + win.document.title;
win = nwin;
}
var doc = win.document;
this.doc = doc;
// Connect to the debug pane if it already exists (i.e. in a window orphaned by the page being refreshed)
var debugPane = doc.getElementById(uid);
var existing_pane = !!debugPane;
if (debugPane && typeof(debugPane.loggingPane) != "undefined") {
debugPane.loggingPane.logger = this.logger;
debugPane.loggingPane.buildAndApplyFilter();
return debugPane.loggingPane;
}
if (existing_pane) {
// clear any existing contents
var child;
while ((child = debugPane.firstChild)) {
debugPane.removeChild(child);
}
} else {
debugPane = doc.createElement("div");
debugPane.id = uid;
}
debugPane.loggingPane = this;
var levelFilterField = doc.createElement("input");
var infoFilterField = doc.createElement("input");
var filterButton = doc.createElement("button");
var loadButton = doc.createElement("button");
var clearButton = doc.createElement("button");
var closeButton = doc.createElement("button");
var logPaneArea = doc.createElement("div");
var logPane = doc.createElement("div");
/* Set up the functions */
var listenerId = uid + "_Listener";
this.colorTable = clone(this.colorTable);
var messages = [];
var messageFilter = null;
var messageLevel = function (msg) {
var level = msg.level;
if (typeof(level) == "number") {
level = MochiKit.Logging.LogLevel[level];
}
return level;
};
var messageText = function (msg) {
return msg.info.join(" ");
};
var addMessageText = bind(function (msg) {
var level = messageLevel(msg);
var text = messageText(msg);
var c = this.colorTable[level];
var p = doc.createElement("span");
p.className = "MochiKit-LogMessage MochiKit-LogLevel-" + level;
p.style.cssText = "margin: 0px; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; white-space: pre-line; word-wrap: break-word; wrap-option: emergency; color: " + c;
p.appendChild(doc.createTextNode(level + ": " + text));
logPane.appendChild(p);
logPane.appendChild(doc.createElement("br"));
if (logPaneArea.offsetHeight > logPaneArea.scrollHeight) {
logPaneArea.scrollTop = 0;
} else {
logPaneArea.scrollTop = logPaneArea.scrollHeight;
}
}, this);
var addMessage = function (msg) {
messages[messages.length] = msg;
addMessageText(msg);
};
var buildMessageFilter = function () {
var levelre, infore;
try {
/* Catch any exceptions that might arise due to invalid regexes */
levelre = new RegExp(levelFilterField.value);
infore = new RegExp(infoFilterField.value);
} catch(e) {
/* If there was an error with the regexes, do no filtering */
logDebug("Error in filter regex: " + e.message);
return null;
}
return function (msg) {
return (
levelre.test(messageLevel(msg)) &&
infore.test(messageText(msg))
);
};
};
var clearMessagePane = function () {
while (logPane.firstChild) {
logPane.removeChild(logPane.firstChild);
}
};
var clearMessages = function () {
messages = [];
clearMessagePane();
};
var closePane = bind(function () {
if (this.closed) {
return;
}
this.closed = true;
if (MochiKit.LoggingPane._loggingPane == this) {
MochiKit.LoggingPane._loggingPane = null;
}
this.logger.removeListener(listenerId);
debugPane.loggingPane = null;
if (inline) {
debugPane.parentNode.removeChild(debugPane);
} else {
this.win.close();
}
}, this);
var filterMessages = function () {
clearMessagePane();
for (var i = 0; i < messages.length; i++) {
var msg = messages[i];
if (messageFilter === null || messageFilter(msg)) {
addMessageText(msg);
}
}
};
this.buildAndApplyFilter = function () {
messageFilter = buildMessageFilter();
filterMessages();
this.logger.removeListener(listenerId);
this.logger.addListener(listenerId, messageFilter, addMessage);
};
var loadMessages = bind(function () {
messages = this.logger.getMessages();
filterMessages();
}, this);
var filterOnEnter = bind(function (event) {
event = event || window.event;
key = event.which || event.keyCode;
if (key == 13) {
this.buildAndApplyFilter();
}
}, this);
/* Create the debug pane */
var style = "display: block; z-index: 1000; left: 0px; bottom: 0px; position: fixed; width: 100%; background-color: white; font: " + this.logFont;
if (inline) {
style += "; height: 10em; border-top: 2px solid black";
} else {
style += "; height: 100%;";
}
debugPane.style.cssText = style;
if (!existing_pane) {
doc.body.appendChild(debugPane);
}
/* Create the filter fields */
style = {"cssText": "width: 33%; display: inline; font: " + this.logFont};
updatetree(levelFilterField, {
"value": "FATAL|ERROR|WARNING|INFO|DEBUG",
"onkeypress": filterOnEnter,
"style": style
});
debugPane.appendChild(levelFilterField);
updatetree(infoFilterField, {
"value": ".*",
"onkeypress": filterOnEnter,
"style": style
});
debugPane.appendChild(infoFilterField);
/* Create the buttons */
style = "width: 8%; display:inline; font: " + this.logFont;
filterButton.appendChild(doc.createTextNode("Filter"));
filterButton.onclick = bind("buildAndApplyFilter", this);
filterButton.style.cssText = style;
debugPane.appendChild(filterButton);
loadButton.appendChild(doc.createTextNode("Load"));
loadButton.onclick = loadMessages;
loadButton.style.cssText = style;
debugPane.appendChild(loadButton);
clearButton.appendChild(doc.createTextNode("Clear"));
clearButton.onclick = clearMessages;
clearButton.style.cssText = style;
debugPane.appendChild(clearButton);
closeButton.appendChild(doc.createTextNode("Close"));
closeButton.onclick = closePane;
closeButton.style.cssText = style;
debugPane.appendChild(closeButton);
/* Create the logging pane */
logPaneArea.style.cssText = "overflow: auto; width: 100%";
logPane.style.cssText = "width: 100%; height: " + (inline ? "8em" : "100%");
logPaneArea.appendChild(logPane);
debugPane.appendChild(logPaneArea);
this.buildAndApplyFilter();
loadMessages();
if (inline) {
this.win = undefined;
} else {
this.win = win;
}
this.inline = inline;
this.closePane = closePane;
this.closed = false;
return this;
};
MochiKit.LoggingPane.LoggingPane.prototype = {
"logFont": "8pt Verdana,sans-serif",
"colorTable": {
"ERROR": "red",
"FATAL": "darkred",
"WARNING": "blue",
"INFO": "black",
"DEBUG": "green"
}
};
MochiKit.LoggingPane.EXPORT_OK = [
"LoggingPane"
];
MochiKit.LoggingPane.EXPORT = [
"createLoggingPane"
];
MochiKit.LoggingPane.__new__ = function () {
this.EXPORT_TAGS = {
":common": this.EXPORT,
":all": MochiKit.Base.concat(this.EXPORT, this.EXPORT_OK)
};
MochiKit.Base.nameFunctions(this);
MochiKit.LoggingPane._loggingPane = null;
};
MochiKit.LoggingPane.__new__();
MochiKit.Base._exportSymbols(this, MochiKit.LoggingPane);

View File

@@ -1,152 +0,0 @@
/***
MochiKit.MochiKit 1.3.1
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2005 Bob Ippolito. All rights Reserved.
***/
if (typeof(MochiKit) == 'undefined') {
MochiKit = {};
}
if (typeof(MochiKit.MochiKit) == 'undefined') {
MochiKit.MochiKit = {};
}
MochiKit.MochiKit.NAME = "MochiKit.MochiKit";
MochiKit.MochiKit.VERSION = "1.3.1";
MochiKit.MochiKit.__repr__ = function () {
return "[" + this.NAME + " " + this.VERSION + "]";
};
MochiKit.MochiKit.toString = function () {
return this.__repr__();
};
MochiKit.MochiKit.SUBMODULES = [
"Base",
"Iter",
"Logging",
"DateTime",
"Format",
"Async",
"DOM",
"LoggingPane",
"Color",
"Signal",
"Visual"
];
if (typeof(JSAN) != 'undefined' || typeof(dojo) != 'undefined') {
if (typeof(dojo) != 'undefined') {
dojo.provide('MochiKit.MochiKit');
dojo.require("MochiKit.*");
}
if (typeof(JSAN) != 'undefined') {
// hopefully this makes it easier for static analysis?
JSAN.use("MochiKit.Base", []);
JSAN.use("MochiKit.Iter", []);
JSAN.use("MochiKit.Logging", []);
JSAN.use("MochiKit.DateTime", []);
JSAN.use("MochiKit.Format", []);
JSAN.use("MochiKit.Async", []);
JSAN.use("MochiKit.DOM", []);
JSAN.use("MochiKit.LoggingPane", []);
JSAN.use("MochiKit.Color", []);
JSAN.use("MochiKit.Signal", []);
JSAN.use("MochiKit.Visual", []);
}
(function () {
var extend = MochiKit.Base.extend;
var self = MochiKit.MochiKit;
var modules = self.SUBMODULES;
var EXPORT = [];
var EXPORT_OK = [];
var EXPORT_TAGS = {};
var i, k, m, all;
for (i = 0; i < modules.length; i++) {
m = MochiKit[modules[i]];
extend(EXPORT, m.EXPORT);
extend(EXPORT_OK, m.EXPORT_OK);
for (k in m.EXPORT_TAGS) {
EXPORT_TAGS[k] = extend(EXPORT_TAGS[k], m.EXPORT_TAGS[k]);
}
all = m.EXPORT_TAGS[":all"];
if (!all) {
all = extend(null, m.EXPORT, m.EXPORT_OK);
}
var j;
for (j = 0; j < all.length; j++) {
k = all[j];
self[k] = m[k];
}
}
self.EXPORT = EXPORT;
self.EXPORT_OK = EXPORT_OK;
self.EXPORT_TAGS = EXPORT_TAGS;
}());
} else {
if (typeof(MochiKit.__compat__) == 'undefined') {
MochiKit.__compat__ = true;
}
(function () {
var scripts = document.getElementsByTagName("script");
var kXULNSURI = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var base = null;
var baseElem = null;
var allScripts = {};
var i;
for (i = 0; i < scripts.length; i++) {
var src = scripts[i].getAttribute("src");
if (!src) {
continue;
}
allScripts[src] = true;
if (src.match(/MochiKit.js$/)) {
base = src.substring(0, src.lastIndexOf('MochiKit.js'));
baseElem = scripts[i];
}
}
if (base === null) {
return;
}
var modules = MochiKit.MochiKit.SUBMODULES;
for (var i = 0; i < modules.length; i++) {
if (MochiKit[modules[i]]) {
continue;
}
var uri = base + modules[i] + '.js';
if (uri in allScripts) {
continue;
}
if (document.documentElement &&
document.documentElement.namespaceURI == kXULNSURI) {
// XUL
var s = document.createElementNS(kXULNSURI, 'script');
s.setAttribute("id", "MochiKit_" + base + modules[i]);
s.setAttribute("src", uri);
s.setAttribute("type", "application/x-javascript");
baseElem.parentNode.appendChild(s);
} else {
// HTML
/*
DOM can not be used here because Safari does
deferred loading of scripts unless they are
in the document or inserted with document.write
This is not XHTML compliant. If you want XHTML
compliance then you must use the packed version of MochiKit
or include each script individually (basically unroll
these document.write calls into your XHTML source)
*/
document.write('<script src="' + uri +
'" type="text/javascript"></script>');
}
};
})();
}

View File

@@ -1,73 +0,0 @@
/***
MochiKit.MockDOM 1.3.1
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2005 Bob Ippolito. All rights Reserved.
***/
if (typeof(MochiKit) == "undefined") {
var MochiKit = {};
}
if (typeof(MochiKit.MockDOM) == "undefined") {
MochiKit.MockDOM = {};
}
MochiKit.MockDOM.NAME = "MochiKit.MockDOM";
MochiKit.MockDOM.VERSION = "1.3.1";
MochiKit.MockDOM.__repr__ = function () {
return "[" + this.NAME + " " + this.VERSION + "]";
};
MochiKit.MockDOM.toString = function () {
return this.__repr__();
};
MochiKit.MockDOM.createDocument = function () {
var doc = new MochiKit.MockDOM.MockElement("DOCUMENT");
doc.body = doc.createElement("BODY");
doc.appendChild(doc.body);
return doc;
};
MochiKit.MockDOM.MockElement = function (name, data) {
this.nodeName = name.toUpperCase();
if (typeof(data) == "string") {
this.nodeValue = data;
this.nodeType = 3;
} else {
this.nodeType = 1;
this.childNodes = [];
}
if (name.substring(0, 1) == "<") {
var nameattr = name.substring(
name.indexOf('"') + 1, name.lastIndexOf('"'));
name = name.substring(1, name.indexOf(" "));
this.nodeName = name.toUpperCase();
this.setAttribute("name", nameattr);
}
};
MochiKit.MockDOM.MockElement.prototype = {
createElement: function (nodeName) {
return new MochiKit.MockDOM.MockElement(nodeName);
},
createTextNode: function (text) {
return new MochiKit.MockDOM.MockElement("text", text);
},
setAttribute: function (name, value) {
this[name] = value;
},
getAttribute: function (name) {
return this[name];
},
appendChild: function (child) {
this.childNodes.push(child);
},
toString: function () {
return "MockElement(" + this.nodeName + ")";
}
};

View File

@@ -1,680 +0,0 @@
/***
MochiKit.Signal 1.3.1
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2006 Jonathan Gardner, Beau Hartshorne, Bob Ippolito. All rights Reserved.
***/
if (typeof(dojo) != 'undefined') {
dojo.provide('MochiKit.Signal');
dojo.require('MochiKit.Base');
dojo.require('MochiKit.DOM');
}
if (typeof(JSAN) != 'undefined') {
JSAN.use('MochiKit.Base', []);
JSAN.use('MochiKit.DOM', []);
}
try {
if (typeof(MochiKit.Base) == 'undefined') {
throw '';
}
} catch (e) {
throw 'MochiKit.Signal depends on MochiKit.Base!';
}
try {
if (typeof(MochiKit.DOM) == 'undefined') {
throw '';
}
} catch (e) {
throw 'MochiKit.Signal depends on MochiKit.DOM!';
}
if (typeof(MochiKit.Signal) == 'undefined') {
MochiKit.Signal = {};
}
MochiKit.Signal.NAME = 'MochiKit.Signal';
MochiKit.Signal.VERSION = '1.3.1';
MochiKit.Signal._observers = [];
MochiKit.Signal.Event = function (src, e) {
this._event = e || window.event;
this._src = src;
};
MochiKit.Base.update(MochiKit.Signal.Event.prototype, {
__repr__: function() {
var repr = MochiKit.Base.repr;
var str = '{event(): ' + repr(this.event()) +
', src(): ' + repr(this.src()) +
', type(): ' + repr(this.type()) +
', target(): ' + repr(this.target()) +
', modifier(): ' + '{alt: ' + repr(this.modifier().alt) +
', ctrl: ' + repr(this.modifier().ctrl) +
', meta: ' + repr(this.modifier().meta) +
', shift: ' + repr(this.modifier().shift) +
', any: ' + repr(this.modifier().any) + '}';
if (this.type() && this.type().indexOf('key') === 0) {
str += ', key(): {code: ' + repr(this.key().code) +
', string: ' + repr(this.key().string) + '}';
}
if (this.type() && (
this.type().indexOf('mouse') === 0 ||
this.type().indexOf('click') != -1 ||
this.type() == 'contextmenu')) {
str += ', mouse(): {page: ' + repr(this.mouse().page) +
', client: ' + repr(this.mouse().client);
if (this.type() != 'mousemove') {
str += ', button: {left: ' + repr(this.mouse().button.left) +
', middle: ' + repr(this.mouse().button.middle) +
', right: ' + repr(this.mouse().button.right) + '}}';
} else {
str += '}';
}
}
if (this.type() == 'mouseover' || this.type() == 'mouseout') {
str += ', relatedTarget(): ' + repr(this.relatedTarget());
}
str += '}';
return str;
},
toString: function () {
return this.__repr__();
},
src: function () {
return this._src;
},
event: function () {
return this._event;
},
type: function () {
return this._event.type || undefined;
},
target: function () {
return this._event.target || this._event.srcElement;
},
relatedTarget: function () {
if (this.type() == 'mouseover') {
return (this._event.relatedTarget ||
this._event.fromElement);
} else if (this.type() == 'mouseout') {
return (this._event.relatedTarget ||
this._event.toElement);
}
// throw new Error("relatedTarget only available for 'mouseover' and 'mouseout'");
return undefined;
},
modifier: function () {
var m = {};
m.alt = this._event.altKey;
m.ctrl = this._event.ctrlKey;
m.meta = this._event.metaKey || false; // IE and Opera punt here
m.shift = this._event.shiftKey;
m.any = m.alt || m.ctrl || m.shift || m.meta;
return m;
},
key: function () {
var k = {};
if (this.type() && this.type().indexOf('key') === 0) {
/*
If you're looking for a special key, look for it in keydown or
keyup, but never keypress. If you're looking for a Unicode
chracter, look for it with keypress, but never keyup or
keydown.
Notes:
FF key event behavior:
key event charCode keyCode
DOWN ku,kd 0 40
DOWN kp 0 40
ESC ku,kd 0 27
ESC kp 0 27
a ku,kd 0 65
a kp 97 0
shift+a ku,kd 0 65
shift+a kp 65 0
1 ku,kd 0 49
1 kp 49 0
shift+1 ku,kd 0 0
shift+1 kp 33 0
IE key event behavior:
(IE doesn't fire keypress events for special keys.)
key event keyCode
DOWN ku,kd 40
DOWN kp undefined
ESC ku,kd 27
ESC kp 27
a ku,kd 65
a kp 97
shift+a ku,kd 65
shift+a kp 65
1 ku,kd 49
1 kp 49
shift+1 ku,kd 49
shift+1 kp 33
Safari key event behavior:
(Safari sets charCode and keyCode to something crazy for
special keys.)
key event charCode keyCode
DOWN ku,kd 63233 40
DOWN kp 63233 63233
ESC ku,kd 27 27
ESC kp 27 27
a ku,kd 97 65
a kp 97 97
shift+a ku,kd 65 65
shift+a kp 65 65
1 ku,kd 49 49
1 kp 49 49
shift+1 ku,kd 33 49
shift+1 kp 33 33
*/
/* look for special keys here */
if (this.type() == 'keydown' || this.type() == 'keyup') {
k.code = this._event.keyCode;
k.string = (MochiKit.Signal._specialKeys[k.code] ||
'KEY_UNKNOWN');
return k;
/* look for characters here */
} else if (this.type() == 'keypress') {
/*
Special key behavior:
IE: does not fire keypress events for special keys
FF: sets charCode to 0, and sets the correct keyCode
Safari: sets keyCode and charCode to something stupid
*/
k.code = 0;
k.string = '';
if (typeof(this._event.charCode) != 'undefined' &&
this._event.charCode !== 0 &&
!MochiKit.Signal._specialMacKeys[this._event.charCode]) {
k.code = this._event.charCode;
k.string = String.fromCharCode(k.code);
} else if (this._event.keyCode &&
typeof(this._event.charCode) == 'undefined') { // IE
k.code = this._event.keyCode;
k.string = String.fromCharCode(k.code);
}
return k;
}
}
// throw new Error('This is not a key event');
return undefined;
},
mouse: function () {
var m = {};
var e = this._event;
if (this.type() && (
this.type().indexOf('mouse') === 0 ||
this.type().indexOf('click') != -1 ||
this.type() == 'contextmenu')) {
m.client = new MochiKit.DOM.Coordinates(0, 0);
if (e.clientX || e.clientY) {
m.client.x = (!e.clientX || e.clientX < 0) ? 0 : e.clientX;
m.client.y = (!e.clientY || e.clientY < 0) ? 0 : e.clientY;
}
m.page = new MochiKit.DOM.Coordinates(0, 0);
if (e.pageX || e.pageY) {
m.page.x = (!e.pageX || e.pageX < 0) ? 0 : e.pageX;
m.page.y = (!e.pageY || e.pageY < 0) ? 0 : e.pageY;
} else {
/*
IE keeps the document offset in:
document.documentElement.clientTop ||
document.body.clientTop
and:
document.documentElement.clientLeft ||
document.body.clientLeft
see:
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getboundingclientrect.asp
The offset is (2,2) in standards mode and (0,0) in quirks
mode.
*/
var de = MochiKit.DOM._document.documentElement;
var b = MochiKit.DOM._document.body;
m.page.x = e.clientX +
(de.scrollLeft || b.scrollLeft) -
(de.clientLeft || b.clientLeft);
m.page.y = e.clientY +
(de.scrollTop || b.scrollTop) -
(de.clientTop || b.clientTop);
}
if (this.type() != 'mousemove') {
m.button = {};
m.button.left = false;
m.button.right = false;
m.button.middle = false;
/* we could check e.button, but which is more consistent */
if (e.which) {
m.button.left = (e.which == 1);
m.button.middle = (e.which == 2);
m.button.right = (e.which == 3);
/*
Mac browsers and right click:
- Safari doesn't fire any click events on a right
click:
http://bugzilla.opendarwin.org/show_bug.cgi?id=6595
- Firefox fires the event, and sets ctrlKey = true
- Opera fires the event, and sets metaKey = true
oncontextmenu is fired on right clicks between
browsers and across platforms.
*/
} else {
m.button.left = !!(e.button & 1);
m.button.right = !!(e.button & 2);
m.button.middle = !!(e.button & 4);
}
}
return m;
}
// throw new Error('This is not a mouse event');
return undefined;
},
stop: function () {
this.stopPropagation();
this.preventDefault();
},
stopPropagation: function () {
if (this._event.stopPropagation) {
this._event.stopPropagation();
} else {
this._event.cancelBubble = true;
}
},
preventDefault: function () {
if (this._event.preventDefault) {
this._event.preventDefault();
} else {
this._event.returnValue = false;
}
}
});
/* Safari sets keyCode to these special values onkeypress. */
MochiKit.Signal._specialMacKeys = {
3: 'KEY_ENTER',
63289: 'KEY_NUM_PAD_CLEAR',
63276: 'KEY_PAGE_UP',
63277: 'KEY_PAGE_DOWN',
63275: 'KEY_END',
63273: 'KEY_HOME',
63234: 'KEY_ARROW_LEFT',
63232: 'KEY_ARROW_UP',
63235: 'KEY_ARROW_RIGHT',
63233: 'KEY_ARROW_DOWN',
63302: 'KEY_INSERT',
63272: 'KEY_DELETE'
};
/* for KEY_F1 - KEY_F12 */
for (i = 63236; i <= 63242; i++) {
MochiKit.Signal._specialMacKeys[i] = 'KEY_F' + (i - 63236 + 1); // no F0
}
/* Standard keyboard key codes. */
MochiKit.Signal._specialKeys = {
8: 'KEY_BACKSPACE',
9: 'KEY_TAB',
12: 'KEY_NUM_PAD_CLEAR', // weird, for Safari and Mac FF only
13: 'KEY_ENTER',
16: 'KEY_SHIFT',
17: 'KEY_CTRL',
18: 'KEY_ALT',
19: 'KEY_PAUSE',
20: 'KEY_CAPS_LOCK',
27: 'KEY_ESCAPE',
32: 'KEY_SPACEBAR',
33: 'KEY_PAGE_UP',
34: 'KEY_PAGE_DOWN',
35: 'KEY_END',
36: 'KEY_HOME',
37: 'KEY_ARROW_LEFT',
38: 'KEY_ARROW_UP',
39: 'KEY_ARROW_RIGHT',
40: 'KEY_ARROW_DOWN',
44: 'KEY_PRINT_SCREEN',
45: 'KEY_INSERT',
46: 'KEY_DELETE',
59: 'KEY_SEMICOLON', // weird, for Safari and IE only
91: 'KEY_WINDOWS_LEFT',
92: 'KEY_WINDOWS_RIGHT',
93: 'KEY_SELECT',
106: 'KEY_NUM_PAD_ASTERISK',
107: 'KEY_NUM_PAD_PLUS_SIGN',
109: 'KEY_NUM_PAD_HYPHEN-MINUS',
110: 'KEY_NUM_PAD_FULL_STOP',
111: 'KEY_NUM_PAD_SOLIDUS',
144: 'KEY_NUM_LOCK',
145: 'KEY_SCROLL_LOCK',
186: 'KEY_SEMICOLON',
187: 'KEY_EQUALS_SIGN',
188: 'KEY_COMMA',
189: 'KEY_HYPHEN-MINUS',
190: 'KEY_FULL_STOP',
191: 'KEY_SOLIDUS',
192: 'KEY_GRAVE_ACCENT',
219: 'KEY_LEFT_SQUARE_BRACKET',
220: 'KEY_REVERSE_SOLIDUS',
221: 'KEY_RIGHT_SQUARE_BRACKET',
222: 'KEY_APOSTROPHE'
// undefined: 'KEY_UNKNOWN'
};
/* for KEY_0 - KEY_9 */
for (var i = 48; i <= 57; i++) {
MochiKit.Signal._specialKeys[i] = 'KEY_' + (i - 48);
}
/* for KEY_A - KEY_Z */
for (i = 65; i <= 90; i++) {
MochiKit.Signal._specialKeys[i] = 'KEY_' + String.fromCharCode(i);
}
/* for KEY_NUM_PAD_0 - KEY_NUM_PAD_9 */
for (i = 96; i <= 105; i++) {
MochiKit.Signal._specialKeys[i] = 'KEY_NUM_PAD_' + (i - 96);
}
/* for KEY_F1 - KEY_F12 */
for (i = 112; i <= 123; i++) {
MochiKit.Signal._specialKeys[i] = 'KEY_F' + (i - 112 + 1); // no F0
}
MochiKit.Base.update(MochiKit.Signal, {
__repr__: function () {
return '[' + this.NAME + ' ' + this.VERSION + ']';
},
toString: function () {
return this.__repr__();
},
_unloadCache: function () {
var self = MochiKit.Signal;
var observers = self._observers;
for (var i = 0; i < observers.length; i++) {
self._disconnect(observers[i]);
}
delete self._observers;
try {
window.onload = undefined;
} catch(e) {
// pass
}
try {
window.onunload = undefined;
} catch(e) {
// pass
}
},
_listener: function (src, func, obj, isDOM) {
var E = MochiKit.Signal.Event;
if (!isDOM) {
return MochiKit.Base.bind(func, obj);
}
obj = obj || src;
if (typeof(func) == "string") {
return function (nativeEvent) {
obj[func].apply(obj, [new E(src, nativeEvent)]);
};
} else {
return function (nativeEvent) {
func.apply(obj, [new E(src, nativeEvent)]);
};
}
},
connect: function (src, sig, objOrFunc/* optional */, funcOrStr) {
src = MochiKit.DOM.getElement(src);
var self = MochiKit.Signal;
if (typeof(sig) != 'string') {
throw new Error("'sig' must be a string");
}
var obj = null;
var func = null;
if (typeof(funcOrStr) != 'undefined') {
obj = objOrFunc;
func = funcOrStr;
if (typeof(funcOrStr) == 'string') {
if (typeof(objOrFunc[funcOrStr]) != "function") {
throw new Error("'funcOrStr' must be a function on 'objOrFunc'");
}
} else if (typeof(funcOrStr) != 'function') {
throw new Error("'funcOrStr' must be a function or string");
}
} else if (typeof(objOrFunc) != "function") {
throw new Error("'objOrFunc' must be a function if 'funcOrStr' is not given");
} else {
func = objOrFunc;
}
if (typeof(obj) == 'undefined' || obj === null) {
obj = src;
}
var isDOM = !!(src.addEventListener || src.attachEvent);
var listener = self._listener(src, func, obj, isDOM);
if (src.addEventListener) {
src.addEventListener(sig.substr(2), listener, false);
} else if (src.attachEvent) {
src.attachEvent(sig, listener); // useCapture unsupported
}
var ident = [src, sig, listener, isDOM, objOrFunc, funcOrStr];
self._observers.push(ident);
return ident;
},
_disconnect: function (ident) {
// check isDOM
if (!ident[3]) { return; }
var src = ident[0];
var sig = ident[1];
var listener = ident[2];
if (src.removeEventListener) {
src.removeEventListener(sig.substr(2), listener, false);
} else if (src.detachEvent) {
src.detachEvent(sig, listener); // useCapture unsupported
} else {
throw new Error("'src' must be a DOM element");
}
},
disconnect: function (ident) {
var self = MochiKit.Signal;
var observers = self._observers;
var m = MochiKit.Base;
if (arguments.length > 1) {
// compatibility API
var src = MochiKit.DOM.getElement(arguments[0]);
var sig = arguments[1];
var obj = arguments[2];
var func = arguments[3];
for (var i = observers.length - 1; i >= 0; i--) {
var o = observers[i];
if (o[0] === src && o[1] === sig && o[4] === obj && o[5] === func) {
self._disconnect(o);
observers.splice(i, 1);
return true;
}
}
} else {
var idx = m.findIdentical(observers, ident);
if (idx >= 0) {
self._disconnect(ident);
observers.splice(idx, 1);
return true;
}
}
return false;
},
disconnectAll: function(src/* optional */, sig) {
src = MochiKit.DOM.getElement(src);
var m = MochiKit.Base;
var signals = m.flattenArguments(m.extend(null, arguments, 1));
var self = MochiKit.Signal;
var disconnect = self._disconnect;
var observers = self._observers;
if (signals.length === 0) {
// disconnect all
for (var i = observers.length - 1; i >= 0; i--) {
var ident = observers[i];
if (ident[0] === src) {
disconnect(ident);
observers.splice(i, 1);
}
}
} else {
var sigs = {};
for (var i = 0; i < signals.length; i++) {
sigs[signals[i]] = true;
}
for (var i = observers.length - 1; i >= 0; i--) {
var ident = observers[i];
if (ident[0] === src && ident[1] in sigs) {
disconnect(ident);
observers.splice(i, 1);
}
}
}
},
signal: function (src, sig) {
var observers = MochiKit.Signal._observers;
src = MochiKit.DOM.getElement(src);
var args = MochiKit.Base.extend(null, arguments, 2);
var errors = [];
for (var i = 0; i < observers.length; i++) {
var ident = observers[i];
if (ident[0] === src && ident[1] === sig) {
try {
ident[2].apply(src, args);
} catch (e) {
errors.push(e);
}
}
}
if (errors.length == 1) {
throw errors[0];
} else if (errors.length > 1) {
var e = new Error("Multiple errors thrown in handling 'sig', see errors property");
e.errors = errors;
throw e;
}
}
});
MochiKit.Signal.EXPORT_OK = [];
MochiKit.Signal.EXPORT = [
'connect',
'disconnect',
'signal',
'disconnectAll'
];
MochiKit.Signal.__new__ = function (win) {
var m = MochiKit.Base;
this._document = document;
this._window = win;
try {
this.connect(window, 'onunload', this._unloadCache);
} catch (e) {
// pass: might not be a browser
}
this.EXPORT_TAGS = {
':common': this.EXPORT,
':all': m.concat(this.EXPORT, this.EXPORT_OK)
};
m.nameFunctions(this);
};
MochiKit.Signal.__new__(this);
//
// XXX: Internet Explorer blows
//
if (!MochiKit.__compat__) {
connect = MochiKit.Signal.connect;
disconnect = MochiKit.Signal.disconnect;
disconnectAll = MochiKit.Signal.disconnectAll;
signal = MochiKit.Signal.signal;
}
MochiKit.Base._exportSymbols(this, MochiKit.Signal);

View File

@@ -1,181 +0,0 @@
/***
MochiKit.Test 1.3.1
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2005 Bob Ippolito. All rights Reserved.
***/
if (typeof(dojo) != 'undefined') {
dojo.provide('MochiKit.Test');
dojo.require('MochiKit.Base');
}
if (typeof(JSAN) != 'undefined') {
JSAN.use("MochiKit.Base", []);
}
try {
if (typeof(MochiKit.Base) == 'undefined') {
throw "";
}
} catch (e) {
throw "MochiKit.Test depends on MochiKit.Base!";
}
if (typeof(MochiKit.Test) == 'undefined') {
MochiKit.Test = {};
}
MochiKit.Test.NAME = "MochiKit.Test";
MochiKit.Test.VERSION = "1.3.1";
MochiKit.Test.__repr__ = function () {
return "[" + this.NAME + " " + this.VERSION + "]";
};
MochiKit.Test.toString = function () {
return this.__repr__();
};
MochiKit.Test.EXPORT = ["runTests"];
MochiKit.Test.EXPORT_OK = [];
MochiKit.Test.runTests = function (obj) {
if (typeof(obj) == "string") {
obj = JSAN.use(obj);
}
var suite = new MochiKit.Test.Suite();
suite.run(obj);
};
MochiKit.Test.Suite = function () {
this.testIndex = 0;
MochiKit.Base.bindMethods(this);
};
MochiKit.Test.Suite.prototype = {
run: function (obj) {
try {
obj(this);
} catch (e) {
this.traceback(e);
}
},
traceback: function (e) {
var items = MochiKit.Iter.sorted(MochiKit.Base.items(e));
print("not ok " + this.testIndex + " - Error thrown");
for (var i = 0; i < items.length; i++) {
var kv = items[i];
if (kv[0] == "stack") {
kv[1] = kv[1].split(/\n/)[0];
}
this.print("# " + kv.join(": "));
}
},
print: function (s) {
print(s);
},
is: function (got, expected, /* optional */message) {
var res = 1;
var msg = null;
try {
res = MochiKit.Base.compare(got, expected);
} catch (e) {
msg = "Can not compare " + typeof(got) + ":" + typeof(expected);
}
if (res) {
msg = "Expected value did not compare equal";
}
if (!res) {
return this.testResult(true, message);
}
return this.testResult(false, message,
[[msg], ["got:", got], ["expected:", expected]]);
},
testResult: function (pass, msg, failures) {
this.testIndex += 1;
if (pass) {
this.print("ok " + this.testIndex + " - " + msg);
return;
}
this.print("not ok " + this.testIndex + " - " + msg);
if (failures) {
for (var i = 0; i < failures.length; i++) {
this.print("# " + failures[i].join(" "));
}
}
},
isDeeply: function (got, expected, /* optional */message) {
var m = MochiKit.Base;
var res = 1;
try {
res = m.compare(got, expected);
} catch (e) {
// pass
}
if (res === 0) {
return this.ok(true, message);
}
var gk = m.keys(got);
var ek = m.keys(expected);
gk.sort();
ek.sort();
if (m.compare(gk, ek)) {
// differing keys
var cmp = {};
var i;
for (i = 0; i < gk.length; i++) {
cmp[gk[i]] = "got";
}
for (i = 0; i < ek.length; i++) {
if (ek[i] in cmp) {
delete cmp[ek[i]];
} else {
cmp[ek[i]] = "expected";
}
}
var diffkeys = m.keys(cmp);
diffkeys.sort();
var gotkeys = [];
var expkeys = [];
while (diffkeys.length) {
var k = diffkeys.shift();
if (k in Object.prototype) {
continue;
}
(cmp[k] == "got" ? gotkeys : expkeys).push(k);
}
}
return this.testResult((!res), msg,
(msg ? [["got:", got], ["expected:", expected]] : undefined)
);
},
ok: function (res, message) {
return this.testResult(res, message);
}
};
MochiKit.Test.__new__ = function () {
var m = MochiKit.Base;
this.EXPORT_TAGS = {
":common": this.EXPORT,
":all": m.concat(this.EXPORT, this.EXPORT_OK)
};
m.nameFunctions(this);
};
MochiKit.Test.__new__();
MochiKit.Base._exportSymbols(this, MochiKit.Test);

View File

@@ -1,402 +0,0 @@
/***
MochiKit.Visual 1.3.1
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2005 Bob Ippolito and others. All rights Reserved.
***/
if (typeof(dojo) != 'undefined') {
dojo.provide('MochiKit.Visual');
dojo.require('MochiKit.Base');
dojo.require('MochiKit.DOM');
dojo.require('MochiKit.Color');
}
if (typeof(JSAN) != 'undefined') {
JSAN.use("MochiKit.Base", []);
JSAN.use("MochiKit.DOM", []);
JSAN.use("MochiKit.Color", []);
}
try {
if (typeof(MochiKit.Base) == 'undefined' ||
typeof(MochiKit.DOM) == 'undefined' ||
typeof(MochiKit.Color) == 'undefined') {
throw "";
}
} catch (e) {
throw "MochiKit.Visual depends on MochiKit.Base, MochiKit.DOM and MochiKit.Color!";
}
if (typeof(MochiKit.Visual) == "undefined") {
MochiKit.Visual = {};
}
MochiKit.Visual.NAME = "MochiKit.Visual";
MochiKit.Visual.VERSION = "1.3.1";
MochiKit.Visual.__repr__ = function () {
return "[" + this.NAME + " " + this.VERSION + "]";
};
MochiKit.Visual.toString = function () {
return this.__repr__();
};
MochiKit.Visual._RoundCorners = function (e, options) {
e = MochiKit.DOM.getElement(e);
this._setOptions(options);
if (this.options.__unstable__wrapElement) {
e = this._doWrap(e);
}
var color = this.options.color;
var C = MochiKit.Color.Color;
if (this.options.color == "fromElement") {
color = C.fromBackground(e);
} else if (!(color instanceof C)) {
color = C.fromString(color);
}
this.isTransparent = (color.asRGB().a <= 0);
var bgColor = this.options.bgColor;
if (this.options.bgColor == "fromParent") {
bgColor = C.fromBackground(e.offsetParent);
} else if (!(bgColor instanceof C)) {
bgColor = C.fromString(bgColor);
}
this._roundCornersImpl(e, color, bgColor);
};
MochiKit.Visual._RoundCorners.prototype = {
_doWrap: function (e) {
var parent = e.parentNode;
var doc = MochiKit.DOM.currentDocument();
if (typeof(doc.defaultView) == "undefined"
|| doc.defaultView === null) {
return e;
}
var style = doc.defaultView.getComputedStyle(e, null);
if (typeof(style) == "undefined" || style === null) {
return e;
}
var wrapper = MochiKit.DOM.DIV({"style": {
display: "block",
// convert padding to margin
marginTop: style.getPropertyValue("padding-top"),
marginRight: style.getPropertyValue("padding-right"),
marginBottom: style.getPropertyValue("padding-bottom"),
marginLeft: style.getPropertyValue("padding-left"),
// remove padding so the rounding looks right
padding: "0px"
/*
paddingRight: "0px",
paddingLeft: "0px"
*/
}});
wrapper.innerHTML = e.innerHTML;
e.innerHTML = "";
e.appendChild(wrapper);
return e;
},
_roundCornersImpl: function (e, color, bgColor) {
if (this.options.border) {
this._renderBorder(e, bgColor);
}
if (this._isTopRounded()) {
this._roundTopCorners(e, color, bgColor);
}
if (this._isBottomRounded()) {
this._roundBottomCorners(e, color, bgColor);
}
},
_renderBorder: function (el, bgColor) {
var borderValue = "1px solid " + this._borderColor(bgColor);
var borderL = "border-left: " + borderValue;
var borderR = "border-right: " + borderValue;
var style = "style='" + borderL + ";" + borderR + "'";
el.innerHTML = "<div " + style + ">" + el.innerHTML + "</div>";
},
_roundTopCorners: function (el, color, bgColor) {
var corner = this._createCorner(bgColor);
for (var i = 0; i < this.options.numSlices; i++) {
corner.appendChild(
this._createCornerSlice(color, bgColor, i, "top")
);
}
el.style.paddingTop = 0;
el.insertBefore(corner, el.firstChild);
},
_roundBottomCorners: function (el, color, bgColor) {
var corner = this._createCorner(bgColor);
for (var i = (this.options.numSlices - 1); i >= 0; i--) {
corner.appendChild(
this._createCornerSlice(color, bgColor, i, "bottom")
);
}
el.style.paddingBottom = 0;
el.appendChild(corner);
},
_createCorner: function (bgColor) {
var dom = MochiKit.DOM;
return dom.DIV({style: {backgroundColor: bgColor.toString()}});
},
_createCornerSlice: function (color, bgColor, n, position) {
var slice = MochiKit.DOM.SPAN();
var inStyle = slice.style;
inStyle.backgroundColor = color.toString();
inStyle.display = "block";
inStyle.height = "1px";
inStyle.overflow = "hidden";
inStyle.fontSize = "1px";
var borderColor = this._borderColor(color, bgColor);
if (this.options.border && n === 0) {
inStyle.borderTopStyle = "solid";
inStyle.borderTopWidth = "1px";
inStyle.borderLeftWidth = "0px";
inStyle.borderRightWidth = "0px";
inStyle.borderBottomWidth = "0px";
// assumes css compliant box model
inStyle.height = "0px";
inStyle.borderColor = borderColor.toString();
} else if (borderColor) {
inStyle.borderColor = borderColor.toString();
inStyle.borderStyle = "solid";
inStyle.borderWidth = "0px 1px";
}
if (!this.options.compact && (n == (this.options.numSlices - 1))) {
inStyle.height = "2px";
}
this._setMargin(slice, n, position);
this._setBorder(slice, n, position);
return slice;
},
_setOptions: function (options) {
this.options = {
corners: "all",
color: "fromElement",
bgColor: "fromParent",
blend: true,
border: false,
compact: false,
__unstable__wrapElement: false
};
MochiKit.Base.update(this.options, options);
this.options.numSlices = (this.options.compact ? 2 : 4);
},
_whichSideTop: function () {
var corners = this.options.corners;
if (this._hasString(corners, "all", "top")) {
return "";
}
var has_tl = (corners.indexOf("tl") != -1);
var has_tr = (corners.indexOf("tr") != -1);
if (has_tl && has_tr) {
return "";
}
if (has_tl) {
return "left";
}
if (has_tr) {
return "right";
}
return "";
},
_whichSideBottom: function () {
var corners = this.options.corners;
if (this._hasString(corners, "all", "bottom")) {
return "";
}
var has_bl = (corners.indexOf('bl') != -1);
var has_br = (corners.indexOf('br') != -1);
if (has_bl && has_br) {
return "";
}
if (has_bl) {
return "left";
}
if (has_br) {
return "right";
}
return "";
},
_borderColor: function (color, bgColor) {
if (color == "transparent") {
return bgColor;
} else if (this.options.border) {
return this.options.border;
} else if (this.options.blend) {
return bgColor.blendedColor(color);
}
return "";
},
_setMargin: function (el, n, corners) {
var marginSize = this._marginSize(n) + "px";
var whichSide = (
corners == "top" ? this._whichSideTop() : this._whichSideBottom()
);
var style = el.style;
if (whichSide == "left") {
style.marginLeft = marginSize;
style.marginRight = "0px";
} else if (whichSide == "right") {
style.marginRight = marginSize;
style.marginLeft = "0px";
} else {
style.marginLeft = marginSize;
style.marginRight = marginSize;
}
},
_setBorder: function (el, n, corners) {
var borderSize = this._borderSize(n) + "px";
var whichSide = (
corners == "top" ? this._whichSideTop() : this._whichSideBottom()
);
var style = el.style;
if (whichSide == "left") {
style.borderLeftWidth = borderSize;
style.borderRightWidth = "0px";
} else if (whichSide == "right") {
style.borderRightWidth = borderSize;
style.borderLeftWidth = "0px";
} else {
style.borderLeftWidth = borderSize;
style.borderRightWidth = borderSize;
}
},
_marginSize: function (n) {
if (this.isTransparent) {
return 0;
}
var o = this.options;
if (o.compact && o.blend) {
var smBlendedMarginSizes = [1, 0];
return smBlendedMarginSizes[n];
} else if (o.compact) {
var compactMarginSizes = [2, 1];
return compactMarginSizes[n];
} else if (o.blend) {
var blendedMarginSizes = [3, 2, 1, 0];
return blendedMarginSizes[n];
} else {
var marginSizes = [5, 3, 2, 1];
return marginSizes[n];
}
},
_borderSize: function (n) {
var o = this.options;
var borderSizes;
if (o.compact && (o.blend || this.isTransparent)) {
return 1;
} else if (o.compact) {
borderSizes = [1, 0];
} else if (o.blend) {
borderSizes = [2, 1, 1, 1];
} else if (o.border) {
borderSizes = [0, 2, 0, 0];
} else if (this.isTransparent) {
borderSizes = [5, 3, 2, 1];
} else {
return 0;
}
return borderSizes[n];
},
_hasString: function (str) {
for (var i = 1; i< arguments.length; i++) {
if (str.indexOf(arguments[i]) != -1) {
return true;
}
}
return false;
},
_isTopRounded: function () {
return this._hasString(this.options.corners,
"all", "top", "tl", "tr"
);
},
_isBottomRounded: function () {
return this._hasString(this.options.corners,
"all", "bottom", "bl", "br"
);
},
_hasSingleTextChild: function (el) {
return (el.childNodes.length == 1 && el.childNodes[0].nodeType == 3);
}
};
MochiKit.Visual.roundElement = function (e, options) {
new MochiKit.Visual._RoundCorners(e, options);
};
MochiKit.Visual.roundClass = function (tagName, className, options) {
var elements = MochiKit.DOM.getElementsByTagAndClassName(
tagName, className
);
for (var i = 0; i < elements.length; i++) {
MochiKit.Visual.roundElement(elements[i], options);
}
};
// Compatibility with MochiKit 1.0
MochiKit.Visual.Color = MochiKit.Color.Color;
MochiKit.Visual.getElementsComputedStyle = MochiKit.DOM.computedStyle;
/* end of Rico adaptation */
MochiKit.Visual.__new__ = function () {
var m = MochiKit.Base;
m.nameFunctions(this);
this.EXPORT_TAGS = {
":common": this.EXPORT,
":all": m.concat(this.EXPORT, this.EXPORT_OK)
};
};
MochiKit.Visual.EXPORT = [
"roundElement",
"roundClass"
];
MochiKit.Visual.EXPORT_OK = [];
MochiKit.Visual.__new__();
MochiKit.Base._exportSymbols(this, MochiKit.Visual);

View File

@@ -1,17 +0,0 @@
dojo.hostenv.conditionalLoadModule({
"common": [
"MochiKit.Base",
"MochiKit.Iter",
"MochiKit.Logging",
"MochiKit.DateTime",
"MochiKit.Format",
"MochiKit.Async",
"MochiKit.Color"
],
"browser": [
"MochiKit.DOM",
"MochiKit.LoggingPane",
"MochiKit.Visual"
]
});
dojo.hostenv.moduleLoaded("MochiKit.*");

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 971 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 591 B

View File

@@ -1,163 +0,0 @@
/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
/* Container Styles */
.calcontainer {*height:1%;} /* IE */
.calcontainer:after {content:'.';clear:both;display:block;visibility:hidden;height:0;} /* others */
.calbordered {
float:left;
padding:5px;
background-color:#F7F9FB;
border:1px solid #7B9EBD;
}
.calbordered .title {
font:73% Arial,Helvetica,sans-serif;
color:#000;
font-weight:bold;
margin-bottom:5px;
height:auto;
width:304px;
position:relative;
}
.title .close-icon {
position:absolute;
right:0;
top:0;
border:none;
}
.cal2up {
float:left;
}
.calnavleft {
position:absolute;
top:0;
bottom:0;
height:12px;
left:2px;
}
.calnavright {
position:absolute;
top:0;
bottom:0;
height:12px;
right:2px;
}
/* Calendar element styles */
.calendar {
font:73% Arial,Helvetica,sans-serif;
text-align:center;
border-spacing:0;
}
td.calcell {
width:1.5em;
height:1em;
border:1px solid #E0E0E0;
background-color:#FFF;
}
.calendar.wait td.calcell {
color:#999;
background-color:#CCC;
}
.calendar.wait td.calcell a {
color:#999;
font-style:italic;
}
td.calcell a {
color:#003DB8;
text-decoration:none;
}
td.calcell.today {
border:1px solid #000;
}
td.calcell.oom {
cursor:default;
color:#999;
background-color:#EEE;
border:1px solid #E0E0E0;
}
td.calcell.selected {
color:#003DB8;
background-color:#FFF19F;
border:1px solid #FF9900;
}
td.calcell.calcellhover {
cursor:pointer;
color:#FFF;
background-color:#FF9900;
border:1px solid #FF9900;
}
/* Added to perform some correction for Opera 8.5
hover redraw bug */
table:hover {
background-color:#FFF;
}
td.calcell.calcellhover a {
color:#FFF;
}
td.calcell.restricted {
text-decoration:line-through;
}
td.calcell.previous {
color:#CCC;
}
td.calcell.highlight1 { background-color:#CCFF99; }
td.calcell.highlight2 { background-color:#99CCFF; }
td.calcell.highlight3 { background-color:#FFCCCC; }
td.calcell.highlight4 { background-color:#CCFF99; }
.calhead {
border:1px solid #E0E0E0;
vertical-align:middle;
background-color:#FFF;
}
.calheader {
position:relative;
width:100%;
}
.calheader img {
border:none;
}
.calweekdaycell {
color:#666;
font-weight:normal;
}
.calfoot {
background-color:#EEE;
}
.calrowhead, .calrowfoot {
color:#666;
font-size:9px;
font-style:italic;
font-weight:normal;
width:15px;
}
.calrowhead {
border-right-width:2px;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 B

View File

@@ -1,206 +0,0 @@
.overlay {
position:absolute;
display:block;
}
.tt {
visibility:hidden;
position:absolute;
color:#333;
background-color:#FDFFB4;
font-family:arial,helvetica,verdana,sans-serif;
padding:2px;
border:1px solid #FCC90D;
font:100% sans-serif;
width:auto;
}
* html body.masked select {
visibility:hidden;
}
* html div.panel-container select {
visibility:inherit;
}
* html div.drag select {
visibility:hidden;
}
* html div.hide-select select {
visibility:hidden;
}
.mask {
z-index:0;
display:none;
position:absolute;
top:0;
left:0;
background-color:#CCC;
-moz-opacity: 0.5;
opacity:.50;
filter: alpha(opacity=50);
}
.mask[id]{ /* IE6 and below Can't See This */
position:fixed;
}
.hide-scrollbars * {
overflow:hidden;
}
.hide-scrollbars textarea, .hide-scrollbars select {
overflow:hidden;
display:none;
}
.show-scrollbars textarea, .show-scrollbars select {
overflow:visible;
}
.panel-container {
position:absolute;
background-color:transparent;
z-index:6;
visibility:hidden;
overflow:visible;
width:auto;
}
.panel-container.matte {
padding:3px;
background-color:#FFF;
}
.panel-container.matte .underlay {
display:none;
}
.panel-container.shadow {
padding:0px;
background-color:transparent;
}
.panel-container.shadow .underlay {
visibility:inherit;
position:absolute;
background-color:#CCC;
top:3px;left:3px;
z-index:0;
width:100%;
height:100%;
-moz-opacity: 0.7;
opacity:.70;
filter:alpha(opacity=70);
}
.panel {
visibility:hidden;
border-collapse:separate;
position:relative;
left:0px;top:0px;
font:1em Arial;
background-color:#FFF;
border:1px solid #000;
z-index:1;
overflow:auto;
}
.panel .hd {
background-color:#3d77cb;
color:#FFF;
font-size:1em;
height:1em;
border:1px solid #FFF;
border-bottom:1px solid #000;
font-weight:bold;
overflow:hidden;
padding:4px;
}
.panel .bd {
overflow:hidden;
padding:4px;
}
.panel .bd p {
margin:0 0 1em;
}
.panel .close {
position:absolute;
top:5px;
right:4px;
z-index:6;
height:12px;
width:12px;
margin:0px;
padding:0px;
background-repeat:no-repeat;
cursor:pointer;
visibility:inherit;
}
.panel .close.nonsecure {
background-image:url(http://us.i1.yimg.com/us.yimg.com/i/nt/ic/ut/alt3/close12_1.gif);
}
.panel .close.secure {
background-image:url(https://a248.e.akamai.net/sec.yimg.com/i/nt/ic/ut/alt3/close12_1.gif);
}
.panel .ft {
padding:4px;
overflow:hidden;
}
.simple-dialog .bd .icon {
background-repeat:no-repeat;
width:16px;
height:16px;
margin-right:10px;
float:left;
}
.dialog .ft, .simple-dialog .ft {
padding-bottom:5px;
padding-right:5px;
text-align:right;
}
.dialog form, .simple-dialog form {
margin:0;
}
.button-group button {
font:100 76% verdana;
text-decoration:none;
background-color: #E4E4E4;
color: #333;
cursor: hand;
vertical-align: middle;
border: 2px solid #797979;
border-top-color:#FFF;
border-left-color:#FFF;
margin:2px;
padding:2px;
}
.button-group button.default {
font-weight:bold;
}
.button-group button:hover, .button-group button.hover {
border:2px solid #90A029;
background-color:#EBF09E;
border-top-color:#FFF;
border-left-color:#FFF;
}
.button-group button:active {
border:2px solid #E4E4E4;
background-color:#BBB;
border-top-color:#333;
border-left-color:#333;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 B

View File

@@ -1,264 +0,0 @@
/*
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
*/
/* Menu styles */
div.yuimenu {
z-index:1;
visibility:hidden;
background-color:#f6f7ee;
border:solid 1px #c4c4be;
padding:1px;
}
/* MenuBar Styles */
div.yuimenubar {
background-color:#f6f7ee;
}
/*
Application of "zoom:1" triggers "haslayout" in IE so that the module's
body clears its floated elements
*/
div.yuimenubar div.bd {
zoom:1;
}
/*
Clear the module body for other browsers
*/
div.yuimenubar div.bd:after {
content:'.';
display:block;
clear:both;
visibility:hidden;
height:0;
}
/* Matches the group title (H6) inside a Menu or MenuBar instance */
div.yuimenu h6,
div.yuimenubar h6 {
font-size:100%;
font-weight:normal;
margin:0;
border:solid 1px #c4c4be;
color:#b9b9b9;
}
div.yuimenubar h6 {
float:left;
display:inline; /* Prevent margin doubling in IE */
padding:4px 12px;
border-width:0 1px 0 0;
}
div.yuimenu h6 {
float:none;
display:block;
border-width:1px 0 0 0;
padding:5px 10px 0 10px;
}
/* Matches the UL inside a Menu or MenuBar instance */
div.yuimenubar ul {
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
div.yuimenu ul {
list-style-type:none;
border:solid 1px #c4c4be;
border-width:1px 0 0 0;
margin:0;
padding:10px 0;
}
div.yuimenu ul.first,
div.yuimenu ul.hastitle,
div.yuimenu h6.first {
border-width:0;
}
/* MenuItem and MenuBarItem styles */
div.yuimenu li,
div.yuimenubar li {
font-size:85%;
cursor:pointer;
cursor:hand;
white-space:nowrap;
text-align:left;
}
div.yuimenu li.yuimenuitem {
padding:2px 24px;
}
div.yuimenu li li,
div.yuimenubar li li {
font-size:100%;
}
/* Matches the help text for a MenuItem instance */
div.yuimenu li em {
font-style:normal;
margin:0 0 0 40px;
}
div.yuimenu li a em {
margin:0;
}
div.yuimenu li a,
div.yuimenubar li a {
/*
"zoom:1" triggers "haslayout" in IE to ensure that the mouseover and
mouseout events bubble to the parent LI in IE.
*/
zoom:1;
color:#000;
text-decoration:none;
}
/* Matches the sub menu indicator for a MenuItem instance */
div.yuimenu li img {
margin:0 -16px 0 10px;
border:0;
}
div.yuimenu li.hassubmenu,
div.yuimenu li.hashelptext {
text-align:right;
}
div.yuimenu li.hassubmenu a.hassubmenu,
div.yuimenu li.hashelptext a.hashelptext {
float:left;
display:inline; /* Prevent margin doubling in IE */
text-align:left;
}
/* Matches focused and selected MenuItem instances */
div.yuimenu li.selected,
div.yuimenubar li.selected {
background-color:#8c8ad0;
}
div.yuimenu li.selected a.selected,
div.yuimenubar li.selected a.selected {
text-decoration:underline;
}
div.yuimenu li.selected a.selected,
div.yuimenu li.selected em.selected,
div.yuimenubar li.selected a.selected {
color:#fff;
}
/* Matches disabled MenuItem instances */
div.yuimenu li.disabled,
div.yuimenubar li.disabled {
cursor:default;
}
div.yuimenu li.disabled a.disabled,
div.yuimenu li.disabled em.disabled,
div.yuimenubar li.disabled a.disabled {
color:#b9b9b9;
cursor:default;
}
div.yuimenubar li.yuimenubaritem {
float:left;
display:inline; /* Prevent margin doubling in IE */
border-width:0 0 0 1px;
border-style:solid;
border-color:#c4c4be;
padding:4px 24px;
margin:0;
}
div.yuimenubar li.yuimenubaritem.first {
border-width:0;
}
div.yuimenubar li.yuimenubaritem img {
margin:0 0 0 10px;
vertical-align:middle;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 568 B

View File

@@ -1,98 +0,0 @@
/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
/* first or middle sibling, no children */
.ygtvtn {
width:16px; height:22px;
background: url(../../../../../../../i/us/nt/widg/tree/dflt/tn.gif) 0 0 no-repeat;
}
/* first or middle sibling, collapsable */
.ygtvtm {
width:16px; height:22px;
cursor:pointer ;
background: url(../../../../../../../i/us/nt/widg/tree/dflt/tm.gif) 0 0 no-repeat;
}
/* first or middle sibling, collapsable, hover */
.ygtvtmh {
width:16px; height:22px;
cursor:pointer ;
background: url(../../../../../../../i/us/nt/widg/tree/dflt/tmh.gif) 0 0 no-repeat;
}
/* first or middle sibling, expandable */
.ygtvtp {
width:16px; height:22px;
cursor:pointer ;
background: url(../../../../../../../i/us/nt/widg/tree/dflt/tp.gif) 0 0 no-repeat;
}
/* first or middle sibling, expandable, hover */
.ygtvtph {
width:16px; height:22px;
cursor:pointer ;
background: url(../../../../../../../i/us/nt/widg/tree/dflt/tph.gif) 0 0 no-repeat;
}
/* last sibling, no children */
.ygtvln {
width:16px; height:22px;
background: url(../../../../../../../i/us/nt/widg/tree/dflt/ln.gif) 0 0 no-repeat;
}
/* Last sibling, collapsable */
.ygtvlm {
width:16px; height:22px;
cursor:pointer ;
background: url(../../../../../../../i/us/nt/widg/tree/dflt/lm.gif) 0 0 no-repeat;
}
/* Last sibling, collapsable, hover */
.ygtvlmh {
width:16px; height:22px;
cursor:pointer ;
background: url(../../../../../../../i/us/nt/widg/tree/dflt/lmh.gif) 0 0 no-repeat;
}
/* Last sibling, expandable */
.ygtvlp {
width:16px; height:22px;
cursor:pointer ;
background: url(../../../../../../../i/us/nt/widg/tree/dflt/lp.gif) 0 0 no-repeat;
}
/* Last sibling, expandable, hover */
.ygtvlph {
width:16px; height:22px; cursor:pointer ;
background: url(../../../../../../../i/us/nt/widg/tree/dflt/lph.gif) 0 0 no-repeat;
}
/* Loading icon */
.ygtvloading {
width:16px; height:22px;
background: url(../../../../../../../i/us/nt/widg/tree/dflt/loading.gif) 0 0 no-repeat;
}
/* the style for the empty cells that are used for rendering the depth
* of the node */
.ygtvdepthcell {
width:16px; height:22px;
background: url(../../../../../../../i/us/nt/widg/tree/dflt/vline.gif) 0 0 no-repeat;
}
.ygtvblankdepthcell { width:16px; height:22px; }
/* the style of the div around each node */
.ygtvitem { }
/* the style of the div around each node's collection of children */
.ygtvchildren { }
* html .ygtvchildren { height:2%; }
/* the style of the text label in ygTextNode */
.ygtvlabel, .ygtvlabel:link, .ygtvlabel:visited, .ygtvlabel:hover {
margin-left:2px;
text-decoration: none;
}
.ygtvspacer { height: 10px; width: 10px; margin: 2px; }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 580 B

View File

@@ -1,135 +0,0 @@
YAHOO.widget.AutoComplete=function(inputEl,containerEl,oDataSource,oConfigs){if(inputEl&&containerEl&&oDataSource){if(oDataSource.getResults){this.dataSource=oDataSource;}
else{return;}
if(YAHOO.util.Dom.inDocument(inputEl)){if(typeof inputEl=="string"){this._sName=inputEl+YAHOO.widget.AutoComplete._nIndex;this._oTextbox=document.getElementById(inputEl);}
else{this._sName=(inputEl.id)?inputEl.id+YAHOO.widget.AutoComplete._nIndex:"yac_inputEl"+YAHOO.widget.AutoComplete._nIndex;this._oTextbox=inputEl;}}
else{return;}
if(YAHOO.util.Dom.inDocument(containerEl)){if(typeof containerEl=="string"){this._oContainer=document.getElementById(containerEl);}
else{this._oContainer=containerEl;}}
else{return;}
if(typeof oConfigs=="object"){for(var sConfig in oConfigs){if(sConfig){this[sConfig]=oConfigs[sConfig];}}}
var oSelf=this;var oTextbox=this._oTextbox;var oContainer=this._oContainer;YAHOO.util.Event.addListener(oTextbox,'keyup',oSelf._onTextboxKeyUp,oSelf);YAHOO.util.Event.addListener(oTextbox,'keydown',oSelf._onTextboxKeyDown,oSelf);YAHOO.util.Event.addListener(oTextbox,'keypress',oSelf._onTextboxKeyPress,oSelf);YAHOO.util.Event.addListener(oTextbox,'focus',oSelf._onTextboxFocus,oSelf);YAHOO.util.Event.addListener(oTextbox,'blur',oSelf._onTextboxBlur,oSelf);YAHOO.util.Event.addListener(oContainer,'mouseover',oSelf._onContainerMouseover,oSelf);YAHOO.util.Event.addListener(oContainer,'mouseout',oSelf._onContainerMouseout,oSelf);YAHOO.util.Event.addListener(oContainer,'scroll',oSelf._onContainerScroll,oSelf);if(oTextbox.form&&this.allowBrowserAutocomplete){YAHOO.util.Event.addListener(oTextbox.form,'submit',oSelf._onFormSubmit,oSelf);}
this.textboxFocusEvent=new YAHOO.util.CustomEvent("textboxFocus",this);this.textboxKeyEvent=new YAHOO.util.CustomEvent("textboxKey",this);this.dataRequestEvent=new YAHOO.util.CustomEvent("dataRequest",this);this.dataReturnEvent=new YAHOO.util.CustomEvent("dataReturn",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.containerExpandEvent=new YAHOO.util.CustomEvent("containerExpand",this);this.typeAheadEvent=new YAHOO.util.CustomEvent("typeAhead",this);this.itemMouseOverEvent=new YAHOO.util.CustomEvent("itemMouseOver",this);this.itemMouseOutEvent=new YAHOO.util.CustomEvent("itemMouseOut",this);this.itemArrowToEvent=new YAHOO.util.CustomEvent("itemArrowTo",this);this.itemArrowFromEvent=new YAHOO.util.CustomEvent("itemArrowFrom",this);this.itemSelectEvent=new YAHOO.util.CustomEvent("itemSelect",this);this.selectionEnforceEvent=new YAHOO.util.CustomEvent("selectionEnforce",this);this.containerCollapseEvent=new YAHOO.util.CustomEvent("containerCollapse",this);this.textboxBlurEvent=new YAHOO.util.CustomEvent("textboxBlur",this);oTextbox.setAttribute("autocomplete","off");this._initProps();}
else{}};YAHOO.widget.AutoComplete.prototype.dataSource=null;YAHOO.widget.AutoComplete.prototype.minQueryLength=1;YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed=10;YAHOO.widget.AutoComplete.prototype.queryDelay=0.5;YAHOO.widget.AutoComplete.prototype.highlightClassName="highlight";YAHOO.widget.AutoComplete.prototype.delimChar=null;YAHOO.widget.AutoComplete.prototype.typeAhead=false;YAHOO.widget.AutoComplete.prototype.animHoriz=false;YAHOO.widget.AutoComplete.prototype.animVert=true;YAHOO.widget.AutoComplete.prototype.animSpeed=0.3;YAHOO.widget.AutoComplete.prototype.forceSelection=false;YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete=true;YAHOO.widget.AutoComplete.prototype.getName=function(){return this._sName;};YAHOO.widget.AutoComplete.prototype.getListIds=function(){return this._aListIds;};YAHOO.widget.AutoComplete.prototype.setHeader=function(sHeader){if(sHeader){this._oHeader.innerHTML=sHeader;this._oHeader.style.display="block";}};YAHOO.widget.AutoComplete.prototype.setFooter=function(sFooter){if(sFooter){this._oFooter.innerHTML=sFooter;this._oFooter.style.display="block";}};YAHOO.widget.AutoComplete.prototype.useIFrame=false;YAHOO.widget.AutoComplete.prototype.formatResult=function(oResultItem,sQuery){var sResult=oResultItem[0];if(sResult){return sResult;}
else{return"";}};YAHOO.widget.AutoComplete.prototype.textboxFocusEvent=null;YAHOO.widget.AutoComplete.prototype.textboxKeyEvent=null;YAHOO.widget.AutoComplete.prototype.dataRequestEvent=null;YAHOO.widget.AutoComplete.prototype.dataReturnEvent=null;YAHOO.widget.AutoComplete.prototype.dataErrorEvent=null;YAHOO.widget.AutoComplete.prototype.containerExpandEvent=null;YAHOO.widget.AutoComplete.prototype.typeAheadEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowToEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent=null;YAHOO.widget.AutoComplete.prototype.itemSelectEvent=null;YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent=null;YAHOO.widget.AutoComplete.prototype.containerCollapseEvent=null;YAHOO.widget.AutoComplete.prototype.textboxBlurEvent=null;YAHOO.widget.AutoComplete._nIndex=0;YAHOO.widget.AutoComplete.prototype._sName=null;YAHOO.widget.AutoComplete.prototype._oTextbox=null;YAHOO.widget.AutoComplete.prototype._bFocused=true;YAHOO.widget.AutoComplete.prototype._oAnim=null;YAHOO.widget.AutoComplete.prototype._oContainer=null;YAHOO.widget.AutoComplete.prototype._bContainerOpen=false;YAHOO.widget.AutoComplete.prototype._bOverContainer=false;YAHOO.widget.AutoComplete.prototype._oIFrame=null;YAHOO.widget.AutoComplete.prototype._oContent=null;YAHOO.widget.AutoComplete.prototype._oHeader=null;YAHOO.widget.AutoComplete.prototype._oFooter=null;YAHOO.widget.AutoComplete.prototype._aListIds=null;YAHOO.widget.AutoComplete.prototype._nDisplayedItems=0;YAHOO.widget.AutoComplete.prototype._sCurQuery=null;YAHOO.widget.AutoComplete.prototype._sSavedQuery=null;YAHOO.widget.AutoComplete.prototype._oCurItem=null;YAHOO.widget.AutoComplete.prototype._bItemSelected=false;YAHOO.widget.AutoComplete.prototype._nKeyCode=null;YAHOO.widget.AutoComplete.prototype._nDelayID=-1;YAHOO.widget.AutoComplete.prototype._initProps=function(){var minQueryLength=this.minQueryLength;if(isNaN(minQueryLength)||(minQueryLength<1)){minQueryLength=1;}
var maxResultsDisplayed=this.maxResultsDisplayed;if(isNaN(this.maxResultsDisplayed)||(this.maxResultsDisplayed<1)){this.maxResultsDisplayed=10;}
var queryDelay=this.queryDelay;if(isNaN(this.queryDelay)||(this.queryDelay<0)){this.queryDelay=0.5;}
var aDelimChar=(this.delimChar)?this.delimChar:null;if(aDelimChar){if(typeof aDelimChar=="string"){this.delimChar=[aDelimChar];}
else if(aDelimChar.constructor!=Array){this.delimChar=null;}}
var animSpeed=this.animSpeed;if(this.animHoriz||this.animVert){if(isNaN(animSpeed)||(animSpeed<0)){animSpeed=0.3;}
if(!this._oAnim&&YAHOO.util.Anim){this._oAnim=new YAHOO.util.Anim(this._oContainer,{},animSpeed);}
else if(this._oAnim){this._oAnim.duration=animSpeed;}}
if(this.forceSelection&&this.delimChar){}
if(!this._aListIds){this._aListIds=[];}
if(!this._aListIds||(this.maxResultsDisplayed!=this._aListIds.length)){this._initContainer();}};YAHOO.widget.AutoComplete.prototype._initContainer=function(){this._aListIds=[];var aItemsMarkup=[];var sName=this._sName;var sPrefix=sName+"item";var sHeaderID=sName+"header";var sFooterID=sName+"footer";for(var i=this.maxResultsDisplayed-1;i>=0;i--){var sItemID=sPrefix+i;this._aListIds[i]=sItemID;aItemsMarkup.unshift("<li id='"+sItemID+"'></li>\n");}
var sList="<ul id='"+sName+"list'>"+
aItemsMarkup.join("")+"</ul>";var sContent=(this.useIFrame)?["<div id='",sName,"content'>","<div id='",sHeaderID,"' class='ac_hd'></div><div class='ac_bd'>",sList,"</div><div id='",sFooterID,"' class='ac_ft'></div>","</div><iframe id='",sName,"iframe' src='about:blank' frameborder='0' scrolling='no'>","</iframe>"]:["<div id='",sHeaderID,"' class='ac_hd'></div><div class='ac_bd'>",sList,"</div><div id='",sFooterID,"' class='ac_ft'></div>"];sContent=sContent.join("");this._oContainer.innerHTML=sContent;this._oHeader=document.getElementById(sHeaderID);this._oFooter=document.getElementById(sFooterID);if(this.useIFrame){this._oContent=document.getElementById(sName+"content");this._oIFrame=document.getElementById(sName+"iframe");this._oContent.style.position="relative";this._oIFrame.style.position="relative";this._oContent.style.zIndex=9050;}
this._oContainer.style.display="none";this._oHeader.style.display="none";this._oFooter.style.display="none";this._initItems();};YAHOO.widget.AutoComplete.prototype._initItems=function(){for(var i=this.maxResultsDisplayed-1;i>=0;i--){var oItem=document.getElementById(this._aListIds[i]);this._initItem(oItem,i);}};YAHOO.widget.AutoComplete.prototype._initItem=function(oItem,nItemIndex){var oSelf=this;oItem.style.display="none";oItem._nItemIndex=nItemIndex;oItem.mouseover=oItem.mouseout=oItem.onclick=null;YAHOO.util.Event.addListener(oItem,'mouseover',oSelf._onItemMouseover,oSelf);YAHOO.util.Event.addListener(oItem,'mouseout',oSelf._onItemMouseout,oSelf);YAHOO.util.Event.addListener(oItem,'click',oSelf._onItemMouseclick,oSelf);};YAHOO.widget.AutoComplete.prototype._onItemMouseover=function(v,oSelf){oSelf._toggleHighlight(this,'mouseover');oSelf.itemMouseOverEvent.fire(oSelf,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseout=function(v,oSelf){oSelf._toggleHighlight(this,'mouseout');oSelf.itemMouseOutEvent.fire(oSelf,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseclick=function(v,oSelf){oSelf._toggleHighlight(this,'mouseover');oSelf._selectItem(this);};YAHOO.widget.AutoComplete.prototype._onContainerMouseover=function(v,oSelf){oSelf._bOverContainer=true;};YAHOO.widget.AutoComplete.prototype._onContainerMouseout=function(v,oSelf){oSelf._bOverContainer=false;if(oSelf._oCurItem){oSelf._toggleHighlight(oSelf._oCurItem,'mouseover');}};YAHOO.widget.AutoComplete.prototype._onContainerScroll=function(v,oSelf){oSelf._oTextbox.focus();};YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown=function(v,oSelf){var nKeyCode=v.keyCode;switch(nKeyCode){case 9:if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
if(oSelf._oCurItem){oSelf._selectItem(oSelf._oCurItem);}
else{oSelf._clearList();}
break;case 13:if(oSelf._nKeyCode!=nKeyCode){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
if(oSelf._oCurItem){oSelf._selectItem(oSelf._oCurItem);}
else{oSelf._clearList();}
break;case 27:oSelf._clearList();return;case 39:oSelf._jumpSelection();break;case 38:YAHOO.util.Event.stopEvent(v);oSelf._moveSelection(nKeyCode);break;case 40:YAHOO.util.Event.stopEvent(v);oSelf._moveSelection(nKeyCode);break;default:break;}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress=function(v,oSelf){var nKeyCode=v.keyCode;switch(nKeyCode){case 9:case 13:if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
break;case 38:case 40:YAHOO.util.Event.stopEvent(v);break;default:break;}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp=function(v,oSelf){oSelf._initProps();var nKeyCode=v.keyCode;oSelf._nKeyCode=nKeyCode;var sChar=String.fromCharCode(nKeyCode);var sText=this.value;if(oSelf._isIgnoreKey(nKeyCode)||(sText.toLowerCase()==this._sCurQuery)){return;}
else{oSelf.textboxKeyEvent.fire(oSelf,nKeyCode);}
if(oSelf.queryDelay>0){var nDelayID=setTimeout(function(){oSelf._sendQuery(sText);},(oSelf.queryDelay*1000));if(oSelf._nDelayID!=-1){clearTimeout(oSelf._nDelayID);}
oSelf._nDelayID=nDelayID;}
else{oSelf._sendQuery(sText);}};YAHOO.widget.AutoComplete.prototype._isIgnoreKey=function(nKeyCode){if(this.typeAhead){if((nKeyCode==8)||(nKeyCode==39)||(nKeyCode==46)){return true;}}
if((nKeyCode==9)||(nKeyCode==13)||(nKeyCode==16)||(nKeyCode==17)||(nKeyCode>=18&&nKeyCode<=20)||(nKeyCode==27)||(nKeyCode>=33&&nKeyCode<=35)||(nKeyCode>=36&&nKeyCode<=38)||(nKeyCode==40)||(nKeyCode>=44&&nKeyCode<=45)){return true;}
return false;};YAHOO.widget.AutoComplete.prototype._onTextboxFocus=function(v,oSelf){oSelf._oTextbox.setAttribute("autocomplete","off");oSelf._bFocused=true;oSelf.textboxFocusEvent.fire(oSelf);};YAHOO.widget.AutoComplete.prototype._onTextboxBlur=function(v,oSelf){if(!oSelf._bOverContainer||(oSelf._nKeyCode==9)){if(oSelf.forceSelection&&!oSelf._bItemSelected){if(!oSelf._bContainerOpen||(oSelf._bContainerOpen&&!oSelf._textMatchesOption())){oSelf._clearSelection();}}
if(oSelf._bContainerOpen){oSelf._clearList();}
oSelf._bFocused=false;oSelf.textboxBlurEvent.fire(oSelf);}};YAHOO.widget.AutoComplete.prototype._onFormSubmit=function(v,oSelf){oSelf._oTextbox.setAttribute("autocomplete","on");};YAHOO.widget.AutoComplete.prototype._sendQuery=function(sQuery){var aDelimChar=(this.delimChar)?this.delimChar:null;if(aDelimChar){var nDelimIndex=-1;for(var i=aDelimChar.length-1;i>=0;i--){var nNewIndex=sQuery.lastIndexOf(aDelimChar[i]);if(nNewIndex>nDelimIndex){nDelimIndex=nNewIndex;}}
if(aDelimChar[i]==" "){for(var j=aDelimChar.length-1;j>=0;j--){if(sQuery[nDelimIndex-1]==aDelimChar[j]){nDelimIndex--;break;}}}
if(nDelimIndex>-1){var nQueryStart=nDelimIndex+1;while(sQuery.charAt(nQueryStart)==" "){nQueryStart+=1;}
this._sSavedQuery=sQuery.substring(0,nQueryStart);sQuery=sQuery.substr(nQueryStart);}
else if(sQuery.indexOf(this._sSavedQuery)<0){this._sSavedQuery=null;}}
if(sQuery.length<this.minQueryLength){if(this._nDelayID!=-1){clearTimeout(this._nDelayID);}
this._clearList();return;}
sQuery=encodeURI(sQuery);this._nDelayID=-1;this.dataRequestEvent.fire(this,sQuery);this.dataSource.getResults(this._populateList,sQuery,this);};YAHOO.widget.AutoComplete.prototype._clearList=function(){this._oContainer.scrollTop=0;var aItems=this._aListIds;for(var i=aItems.length-1;i>=0;i--){document.getElementById(aItems[i]).style.display="none";}
if(this._oCurItem){this._toggleHighlight(this._oCurItem,'mouseout');}
this._oCurItem=null;this._nDisplayedItems=0;this._sCurQuery=null;this._toggleContainer(false);};YAHOO.widget.AutoComplete.prototype._populateList=function(sQuery,aResults,oSelf){if(aResults===null){oSelf.dataErrorEvent.fire(oSelf,sQuery);}
else{oSelf.dataReturnEvent.fire(oSelf,sQuery,aResults);}
if(!oSelf._bFocused||!aResults){return;}
var isOpera=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);oSelf._oContainer.style.width=(!isOpera)?null:"";oSelf._oContainer.style.height=(!isOpera)?null:"";var sCurQuery=decodeURI(sQuery);oSelf._sCurQuery=sCurQuery;var aItems=oSelf._aListIds;oSelf._bItemSelected=false;var nItems=Math.min(aResults.length,oSelf.maxResultsDisplayed);oSelf._nDisplayedItems=nItems;if(nItems>0){for(var i=nItems-1;i>=0;i--){var oItemi=document.getElementById(aItems[i]);var oResultItemi=aResults[i];oItemi.innerHTML=oSelf.formatResult(oResultItemi,sCurQuery);oItemi.style.display="list-item";oItemi._sResultKey=oResultItemi[0];oItemi._oResultData=oResultItemi;}
for(var j=aItems.length-1;j>=nItems;j--){var oItemj=document.getElementById(aItems[j]);oItemj.innerHTML=null;oItemj.style.display="none";oItemj._sResultKey=null;oItemj._oResultData=null;}
var oFirstItem=document.getElementById(aItems[0]);oSelf._toggleHighlight(oFirstItem,'mouseover');oSelf._toggleContainer(true);oSelf.itemArrowToEvent.fire(oSelf,oFirstItem);oSelf._typeAhead(oFirstItem,sQuery);oSelf._oCurItem=oFirstItem;}
else{oSelf._clearList();}};YAHOO.widget.AutoComplete.prototype._clearSelection=function(){var sValue=this._oTextbox.value;var sChar=(this.delimChar)?this.delimChar[0]:null;var nIndex=(sChar)?sValue.lastIndexOf(sChar,sValue.length-2):-1;if(nIndex>-1){this._oTextbox.value=sValue.substring(0,nIndex);}
else{this._oTextbox.value="";}
this._sSavedQuery=this._oTextbox.value;this.selectionEnforceEvent.fire(this);};YAHOO.widget.AutoComplete.prototype._textMatchesOption=function(){var foundMatch=false;for(var i=this._nDisplayedItems-1;i>=0;i--){var oItem=document.getElementById(this._aListIds[i]);var sMatch=oItem._sResultKey.toLowerCase();if(sMatch==this._sCurQuery.toLowerCase()){foundMatch=true;break;}}
return(foundMatch);};YAHOO.widget.AutoComplete.prototype._typeAhead=function(oItem,sQuery){var oTextbox=this._oTextbox;var sValue=this._oTextbox.value;if(!this.typeAhead){return;}
if(!oTextbox.setSelectionRange&&!oTextbox.createTextRange){return;}
var nStart=sValue.length;this._updateValue(oItem);var nEnd=oTextbox.value.length;this._selectText(oTextbox,nStart,nEnd);var sPrefill=oTextbox.value.substr(nStart,nEnd);this.typeAheadEvent.fire(this,sQuery,sPrefill);};YAHOO.widget.AutoComplete.prototype._selectText=function(oTextbox,nStart,nEnd){if(oTextbox.setSelectionRange){oTextbox.setSelectionRange(nStart,nEnd);}
else if(oTextbox.createTextRange){var oTextRange=oTextbox.createTextRange();oTextRange.moveStart("character",nStart);oTextRange.moveEnd("character",nEnd-oTextbox.value.length);oTextRange.select();}
else{oTextbox.select();}};YAHOO.widget.AutoComplete.prototype._toggleContainer=function(bShow){var oContainer=this._oContainer;if(!bShow&&!this._bContainerOpen){oContainer.style.display="none";return;}
var oContent=this._oContent;var oIFrame=this._oIFrame;if(bShow&&oContent&&oIFrame){var sDisplay=oContainer.style.display;oContainer.style.display="block";oIFrame.style.width=oContent.offsetWidth+"px";oIFrame.style.height=oContent.offsetHeight+"px";oIFrame.style.marginTop="-"+oContent.offsetHeight+"px";oContainer.style.display=sDisplay;}
var oAnim=this._oAnim;if(oAnim&&oAnim.getEl()&&(this.animHoriz||this.animVert)){if(oAnim.isAnimated()){oAnim.stop();}
var oClone=oContainer.cloneNode(true);oContainer.parentNode.appendChild(oClone);oClone.style.top="-9000px";oClone.style.display="block";var wExp=oClone.offsetWidth;var hExp=oClone.offsetHeight;var wColl=(this.animHoriz)?0:wExp;var hColl=(this.animVert)?0:hExp;oAnim.attributes=(bShow)?{width:{to:wExp},height:{to:hExp}}:{width:{to:wColl},height:{to:hColl}};if(bShow&&!this._bContainerOpen){oContainer.style.width=wColl+"px";oContainer.style.height=hColl+"px";}
else{oContainer.style.width=wExp+"px";oContainer.style.height=hExp+"px";}

View File

@@ -1,211 +0,0 @@
/*
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 0.10.0
*/
YAHOO.widget.DateMath=new function(){this.DAY="D";this.WEEK="W";this.YEAR="Y";this.MONTH="M";this.ONE_DAY_MS=1000*60*60*24;this.add=function(date,field,amount){var d=new Date(date.getTime());switch(field)
{case this.MONTH:var newMonth=date.getMonth()+amount;var years=0;if(newMonth<0){while(newMonth<0)
{newMonth+=12;years-=1;}}else if(newMonth>11){while(newMonth>11)
{newMonth-=12;years+=1;}}
d.setMonth(newMonth);d.setFullYear(date.getFullYear()+years);break;case this.DAY:d.setDate(date.getDate()+amount);break;case this.YEAR:d.setFullYear(date.getFullYear()+amount);break;case this.WEEK:d.setDate(date.getDate()+7);break;}
return d;};this.subtract=function(date,field,amount){return this.add(date,field,(amount*-1));};this.before=function(date,compareTo){var ms=compareTo.getTime();if(date.getTime()<ms){return true;}else{return false;}};this.after=function(date,compareTo){var ms=compareTo.getTime();if(date.getTime()>ms){return true;}else{return false;}};this.getJan1=function(calendarYear){return new Date(calendarYear,0,1);};this.getDayOffset=function(date,calendarYear){var beginYear=this.getJan1(calendarYear);var dayOffset=Math.ceil((date.getTime()-beginYear.getTime())/this.ONE_DAY_MS);return dayOffset;};this.getWeekNumber=function(date,calendarYear,weekStartsOn){if(!weekStartsOn){weekStartsOn=0;}
if(!calendarYear){calendarYear=date.getFullYear();}
var weekNum=-1;var jan1=this.getJan1(calendarYear);var jan1DayOfWeek=jan1.getDay();var month=date.getMonth();var day=date.getDate();var year=date.getFullYear();var dayOffset=this.getDayOffset(date,calendarYear);if(dayOffset<0&&dayOffset>=(-1*jan1DayOfWeek)){weekNum=1;}else{weekNum=1;var testDate=this.getJan1(calendarYear);while(testDate.getTime()<date.getTime()&&testDate.getFullYear()==calendarYear){weekNum+=1;testDate=this.add(testDate,this.WEEK,1);}}
return weekNum;};this.isYearOverlapWeek=function(weekBeginDate){var overlaps=false;var nextWeek=this.add(weekBeginDate,this.DAY,6);if(nextWeek.getFullYear()!=weekBeginDate.getFullYear()){overlaps=true;}
return overlaps;};this.isMonthOverlapWeek=function(weekBeginDate){var overlaps=false;var nextWeek=this.add(weekBeginDate,this.DAY,6);if(nextWeek.getMonth()!=weekBeginDate.getMonth()){overlaps=true;}
return overlaps;};this.findMonthStart=function(date){var start=new Date(date.getFullYear(),date.getMonth(),1);return start;};this.findMonthEnd=function(date){var start=this.findMonthStart(date);var nextMonth=this.add(start,this.MONTH,1);var end=this.subtract(nextMonth,this.DAY,1);return end;};this.clearTime=function(date){date.setHours(0,0,0,0);return date;};}
YAHOO.widget.Calendar_Core=function(id,containerId,monthyear,selected){if(arguments.length>0)
{this.init(id,containerId,monthyear,selected);}}
YAHOO.widget.Calendar_Core.IMG_ROOT=(window.location.href.toLowerCase().indexOf("https")==0?"https://a248.e.akamai.net/sec.yimg.com/i/":"http://us.i1.yimg.com/us.yimg.com/i/");YAHOO.widget.Calendar_Core.DATE="D";YAHOO.widget.Calendar_Core.MONTH_DAY="MD";YAHOO.widget.Calendar_Core.WEEKDAY="WD";YAHOO.widget.Calendar_Core.RANGE="R";YAHOO.widget.Calendar_Core.MONTH="M";YAHOO.widget.Calendar_Core.DISPLAY_DAYS=42;YAHOO.widget.Calendar_Core.STOP_RENDER="S";YAHOO.widget.Calendar_Core.prototype={Config:null,parent:null,index:-1,cells:null,weekHeaderCells:null,weekFooterCells:null,cellDates:null,id:null,oDomContainer:null,today:null,renderStack:null,_renderStack:null,pageDate:null,_pageDate:null,minDate:null,maxDate:null,selectedDates:null,_selectedDates:null,shellRendered:false,table:null,headerCell:null};YAHOO.widget.Calendar_Core.prototype.init=function(id,containerId,monthyear,selected){this.setupConfig();this.id=id;this.cellDates=new Array();this.cells=new Array();this.renderStack=new Array();this._renderStack=new Array();this.oDomContainer=document.getElementById(containerId);this.today=new Date();YAHOO.widget.DateMath.clearTime(this.today);var month;var year;if(monthyear)
{var aMonthYear=monthyear.split(this.Locale.DATE_FIELD_DELIMITER);month=parseInt(aMonthYear[this.Locale.MY_MONTH_POSITION-1]);year=parseInt(aMonthYear[this.Locale.MY_YEAR_POSITION-1]);}else{month=this.today.getMonth()+1;year=this.today.getFullYear();}
this.pageDate=new Date(year,month-1,1);this._pageDate=new Date(this.pageDate.getTime());if(selected)
{this.selectedDates=this._parseDates(selected);this._selectedDates=this.selectedDates.concat();}else{this.selectedDates=new Array();this._selectedDates=new Array();}
this.wireDefaultEvents();this.wireCustomEvents();};YAHOO.widget.Calendar_Core.prototype.wireDefaultEvents=function(){this.doSelectCell=function(e,cal){var cell=this;var index=cell.index;var d=cal.cellDates[index];var date=new Date(d[0],d[1]-1,d[2]);if(!cal.isDateOOM(date)&&!YAHOO.util.Dom.hasClass(cell,cal.Style.CSS_CELL_RESTRICTED)&&!YAHOO.util.Dom.hasClass(cell,cal.Style.CSS_CELL_OOB)){if(cal.Options.MULTI_SELECT){var link=cell.getElementsByTagName("A")[0];link.blur();var cellDate=cal.cellDates[index];var cellDateIndex=cal._indexOfSelectedFieldArray(cellDate);if(cellDateIndex>-1)
{cal.deselectCell(index);}else{cal.selectCell(index);}}else{var link=cell.getElementsByTagName("A")[0];link.blur()
cal.selectCell(index);}}}
this.doCellMouseOver=function(e,cal){var cell=this;var index=cell.index;var d=cal.cellDates[index];var date=new Date(d[0],d[1]-1,d[2]);if(!cal.isDateOOM(date)&&!YAHOO.util.Dom.hasClass(cell,cal.Style.CSS_CELL_RESTRICTED)&&!YAHOO.util.Dom.hasClass(cell,cal.Style.CSS_CELL_OOB)){YAHOO.widget.Calendar_Core.prependCssClass(cell,cal.Style.CSS_CELL_HOVER);}}
this.doCellMouseOut=function(e,cal){YAHOO.widget.Calendar_Core.removeCssClass(this,cal.Style.CSS_CELL_HOVER);}
this.doNextMonth=function(e,cal){cal.nextMonth();}
this.doPreviousMonth=function(e,cal){cal.previousMonth();}}
YAHOO.widget.Calendar_Core.prototype.wireCustomEvents=function(){}
YAHOO.widget.Calendar_Core.prototype.setupConfig=function(){this.Config=new Object();this.Config.Style={CSS_ROW_HEADER:"calrowhead",CSS_ROW_FOOTER:"calrowfoot",CSS_CELL:"calcell",CSS_CELL_SELECTED:"selected",CSS_CELL_RESTRICTED:"restricted",CSS_CELL_TODAY:"today",CSS_CELL_OOM:"oom",CSS_CELL_OOB:"previous",CSS_HEADER:"calheader",CSS_HEADER_TEXT:"calhead",CSS_WEEKDAY_CELL:"calweekdaycell",CSS_WEEKDAY_ROW:"calweekdayrow",CSS_FOOTER:"calfoot",CSS_CALENDAR:"calendar",CSS_BORDER:"calbordered",CSS_CONTAINER:"calcontainer",CSS_NAV_LEFT:"calnavleft",CSS_NAV_RIGHT:"calnavright",CSS_CELL_TOP:"calcelltop",CSS_CELL_LEFT:"calcellleft",CSS_CELL_RIGHT:"calcellright",CSS_CELL_BOTTOM:"calcellbottom",CSS_CELL_HOVER:"calcellhover",CSS_CELL_HIGHLIGHT1:"highlight1",CSS_CELL_HIGHLIGHT2:"highlight2",CSS_CELL_HIGHLIGHT3:"highlight3",CSS_CELL_HIGHLIGHT4:"highlight4"};this.Style=this.Config.Style;this.Config.Locale={MONTHS_SHORT:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],MONTHS_LONG:["January","February","March","April","May","June","July","August","September","October","November","December"],WEEKDAYS_1CHAR:["S","M","T","W","T","F","S"],WEEKDAYS_SHORT:["Su","Mo","Tu","We","Th","Fr","Sa"],WEEKDAYS_MEDIUM:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],WEEKDAYS_LONG:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],DATE_DELIMITER:",",DATE_FIELD_DELIMITER:"/",DATE_RANGE_DELIMITER:"-",MY_MONTH_POSITION:1,MY_YEAR_POSITION:2,MD_MONTH_POSITION:1,MD_DAY_POSITION:2,MDY_MONTH_POSITION:1,MDY_DAY_POSITION:2,MDY_YEAR_POSITION:3};this.Locale=this.Config.Locale;this.Config.Options={MULTI_SELECT:false,SHOW_WEEKDAYS:true,START_WEEKDAY:0,SHOW_WEEK_HEADER:false,SHOW_WEEK_FOOTER:false,HIDE_BLANK_WEEKS:false,NAV_ARROW_LEFT:YAHOO.widget.Calendar_Core.IMG_ROOT+"us/tr/callt.gif",NAV_ARROW_RIGHT:YAHOO.widget.Calendar_Core.IMG_ROOT+"us/tr/calrt.gif"};this.Options=this.Config.Options;this.customConfig();if(!this.Options.LOCALE_MONTHS){this.Options.LOCALE_MONTHS=this.Locale.MONTHS_LONG;}
if(!this.Options.LOCALE_WEEKDAYS){this.Options.LOCALE_WEEKDAYS=this.Locale.WEEKDAYS_SHORT;}
if(this.Options.START_WEEKDAY>0)
{for(var w=0;w<this.Options.START_WEEKDAY;++w){this.Locale.WEEKDAYS_SHORT.push(this.Locale.WEEKDAYS_SHORT.shift());this.Locale.WEEKDAYS_MEDIUM.push(this.Locale.WEEKDAYS_MEDIUM.shift());this.Locale.WEEKDAYS_LONG.push(this.Locale.WEEKDAYS_LONG.shift());}}};YAHOO.widget.Calendar_Core.prototype.customConfig=function(){};YAHOO.widget.Calendar_Core.prototype.buildMonthLabel=function(){var text=this.Options.LOCALE_MONTHS[this.pageDate.getMonth()]+" "+this.pageDate.getFullYear();return text;};YAHOO.widget.Calendar_Core.prototype.buildDayLabel=function(workingDate){var day=workingDate.getDate();return day;};YAHOO.widget.Calendar_Core.prototype.buildShell=function(){this.table=document.createElement("TABLE");this.table.cellSpacing=0;YAHOO.widget.Calendar_Core.setCssClasses(this.table,[this.Style.CSS_CALENDAR]);this.table.id=this.id;this.buildShellHeader();this.buildShellBody();this.buildShellFooter();YAHOO.util.Event.addListener(window,"unload",this._unload,this);};YAHOO.widget.Calendar_Core.prototype.buildShellHeader=function(){var head=document.createElement("THEAD");var headRow=document.createElement("TR");var headerCell=document.createElement("TH");var colSpan=7;if(this.Config.Options.SHOW_WEEK_HEADER){this.weekHeaderCells=new Array();colSpan+=1;}
if(this.Config.Options.SHOW_WEEK_FOOTER){this.weekFooterCells=new Array();colSpan+=1;}
headerCell.colSpan=colSpan;YAHOO.widget.Calendar_Core.setCssClasses(headerCell,[this.Style.CSS_HEADER_TEXT]);this.headerCell=headerCell;headRow.appendChild(headerCell);head.appendChild(headRow);if(this.Options.SHOW_WEEKDAYS)
{var row=document.createElement("TR");var fillerCell;YAHOO.widget.Calendar_Core.setCssClasses(row,[this.Style.CSS_WEEKDAY_ROW]);if(this.Config.Options.SHOW_WEEK_HEADER){fillerCell=document.createElement("TH");YAHOO.widget.Calendar_Core.setCssClasses(fillerCell,[this.Style.CSS_WEEKDAY_CELL]);row.appendChild(fillerCell);}
for(var i=0;i<this.Options.LOCALE_WEEKDAYS.length;++i)
{var cell=document.createElement("TH");YAHOO.widget.Calendar_Core.setCssClasses(cell,[this.Style.CSS_WEEKDAY_CELL]);cell.innerHTML=this.Options.LOCALE_WEEKDAYS[i];row.appendChild(cell);}
if(this.Config.Options.SHOW_WEEK_FOOTER){fillerCell=document.createElement("TH");YAHOO.widget.Calendar_Core.setCssClasses(fillerCell,[this.Style.CSS_WEEKDAY_CELL]);row.appendChild(fillerCell);}
head.appendChild(row);}
this.table.appendChild(head);};YAHOO.widget.Calendar_Core.prototype.buildShellBody=function(){this.tbody=document.createElement("TBODY");for(var r=0;r<6;++r)
{var row=document.createElement("TR");for(var c=0;c<this.headerCell.colSpan;++c)
{var cell;if(this.Config.Options.SHOW_WEEK_HEADER&&c===0){cell=document.createElement("TH");this.weekHeaderCells[this.weekHeaderCells.length]=cell;}else if(this.Config.Options.SHOW_WEEK_FOOTER&&c==(this.headerCell.colSpan-1)){cell=document.createElement("TH");this.weekFooterCells[this.weekFooterCells.length]=cell;}else{cell=document.createElement("TD");this.cells[this.cells.length]=cell;YAHOO.widget.Calendar_Core.setCssClasses(cell,[this.Style.CSS_CELL]);YAHOO.util.Event.addListener(cell,"click",this.doSelectCell,this);YAHOO.util.Event.addListener(cell,"mouseover",this.doCellMouseOver,this);YAHOO.util.Event.addListener(cell,"mouseout",this.doCellMouseOut,this);}
row.appendChild(cell);}
this.tbody.appendChild(row);}
this.table.appendChild(this.tbody);};YAHOO.widget.Calendar_Core.prototype.buildShellFooter=function(){};YAHOO.widget.Calendar_Core.prototype.renderShell=function(){this.oDomContainer.appendChild(this.table);this.shellRendered=true;};YAHOO.widget.Calendar_Core.prototype.render=function(){if(!this.shellRendered)
{this.buildShell();this.renderShell();}
this.resetRenderers();this.cellDates.length=0;var workingDate=YAHOO.widget.DateMath.findMonthStart(this.pageDate);this.renderHeader();this.renderBody(workingDate);this.renderFooter();this.onRender();};YAHOO.widget.Calendar_Core.prototype.renderHeader=function(){this.headerCell.innerHTML="";var headerContainer=document.createElement("DIV");headerContainer.className=this.Style.CSS_HEADER;headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));this.headerCell.appendChild(headerContainer);};YAHOO.widget.Calendar_Core.prototype.renderBody=function(workingDate){this.preMonthDays=workingDate.getDay();if(this.Options.START_WEEKDAY>0){this.preMonthDays-=this.Options.START_WEEKDAY;}
if(this.preMonthDays<0){this.preMonthDays+=7;}
this.monthDays=YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();this.postMonthDays=YAHOO.widget.Calendar_Core.DISPLAY_DAYS-this.preMonthDays-this.monthDays;workingDate=YAHOO.widget.DateMath.subtract(workingDate,YAHOO.widget.DateMath.DAY,this.preMonthDays);var weekRowIndex=0;for(var c=0;c<this.cells.length;++c)
{var cellRenderers=new Array();var cell=this.cells[c];this.clearElement(cell);cell.index=c;cell.id=this.id+"_cell"+c;this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()];if(workingDate.getDay()==this.Options.START_WEEKDAY){var rowHeaderCell=null;var rowFooterCell=null;if(this.Options.SHOW_WEEK_HEADER){rowHeaderCell=this.weekHeaderCells[weekRowIndex];this.clearElement(rowHeaderCell);}
if(this.Options.SHOW_WEEK_FOOTER){rowFooterCell=this.weekFooterCells[weekRowIndex];this.clearElement(rowFooterCell);}
if(this.Options.HIDE_BLANK_WEEKS&&this.isDateOOM(workingDate)&&!YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)){continue;}else{if(rowHeaderCell){this.renderRowHeader(workingDate,rowHeaderCell);}
if(rowFooterCell){this.renderRowFooter(workingDate,rowFooterCell);}}}
var renderer=null;if(workingDate.getFullYear()==this.today.getFullYear()&&workingDate.getMonth()==this.today.getMonth()&&workingDate.getDate()==this.today.getDate())
{cellRenderers[cellRenderers.length]=this.renderCellStyleToday;}
if(this.isDateOOM(workingDate))
{cellRenderers[cellRenderers.length]=this.renderCellNotThisMonth;}else{for(var r=0;r<this.renderStack.length;++r)
{var rArray=this.renderStack[r];var type=rArray[0];var month;var day;var year;switch(type){case YAHOO.widget.Calendar_Core.DATE:month=rArray[1][1];day=rArray[1][2];year=rArray[1][0];if(workingDate.getMonth()+1==month&&workingDate.getDate()==day&&workingDate.getFullYear()==year)
{renderer=rArray[2];this.renderStack.splice(r,1);}
break;case YAHOO.widget.Calendar_Core.MONTH_DAY:month=rArray[1][0];day=rArray[1][1];if(workingDate.getMonth()+1==month&&workingDate.getDate()==day)
{renderer=rArray[2];this.renderStack.splice(r,1);}
break;case YAHOO.widget.Calendar_Core.RANGE:var date1=rArray[1][0];var date2=rArray[1][1];var d1month=date1[1];var d1day=date1[2];var d1year=date1[0];var d1=new Date(d1year,d1month-1,d1day);var d2month=date2[1];var d2day=date2[2];var d2year=date2[0];var d2=new Date(d2year,d2month-1,d2day);if(workingDate.getTime()>=d1.getTime()&&workingDate.getTime()<=d2.getTime())
{renderer=rArray[2];if(workingDate.getTime()==d2.getTime()){this.renderStack.splice(r,1);}}
break;case YAHOO.widget.Calendar_Core.WEEKDAY:var weekday=rArray[1][0];if(workingDate.getDay()+1==weekday)
{renderer=rArray[2];}
break;case YAHOO.widget.Calendar_Core.MONTH:month=rArray[1][0];if(workingDate.getMonth()+1==month)
{renderer=rArray[2];}
break;}
if(renderer){cellRenderers[cellRenderers.length]=renderer;}}}
if(this._indexOfSelectedFieldArray([workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()])>-1)
{cellRenderers[cellRenderers.length]=this.renderCellStyleSelected;}
if(this.minDate)
{this.minDate=YAHOO.widget.DateMath.clearTime(this.minDate);}
if(this.maxDate)
{this.maxDate=YAHOO.widget.DateMath.clearTime(this.maxDate);}
if((this.minDate&&(workingDate.getTime()<this.minDate.getTime()))||(this.maxDate&&(workingDate.getTime()>this.maxDate.getTime()))){cellRenderers[cellRenderers.length]=this.renderOutOfBoundsDate;}else{cellRenderers[cellRenderers.length]=this.renderCellDefault;}
for(var x=0;x<cellRenderers.length;++x)
{var ren=cellRenderers[x];if(ren.call(this,workingDate,cell)==YAHOO.widget.Calendar_Core.STOP_RENDER){break;}}
workingDate=YAHOO.widget.DateMath.add(workingDate,YAHOO.widget.DateMath.DAY,1);if(workingDate.getDay()==this.Options.START_WEEKDAY){weekRowIndex+=1;}
YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL);if(c>=0&&c<=6){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_TOP);}
if((c%7)==0){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_LEFT);}
if(((c+1)%7)==0){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_RIGHT);}
var postDays=this.postMonthDays;if(postDays>=7&&this.Options.HIDE_BLANK_WEEKS){var blankWeeks=Math.floor(postDays/7);for(var p=0;p<blankWeeks;++p){postDays-=7;}}
if(c>=((this.preMonthDays+postDays+this.monthDays)-7)){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_BOTTOM);}}};YAHOO.widget.Calendar_Core.prototype.renderFooter=function(){};YAHOO.widget.Calendar_Core.prototype._unload=function(e,cal){for(var c in cal.cells){c=null;}
cal.cells=null;cal.tbody=null;cal.oDomContainer=null;cal.table=null;cal.headerCell=null;cal=null;};YAHOO.widget.Calendar_Core.prototype.renderOutOfBoundsDate=function(workingDate,cell){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_OOB);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar_Core.STOP_RENDER;}
YAHOO.widget.Calendar_Core.prototype.renderRowHeader=function(workingDate,cell){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_ROW_HEADER);var useYear=this.pageDate.getFullYear();if(!YAHOO.widget.DateMath.isYearOverlapWeek(workingDate)){useYear=workingDate.getFullYear();}
var weekNum=YAHOO.widget.DateMath.getWeekNumber(workingDate,useYear,this.Options.START_WEEKDAY);cell.innerHTML=weekNum;if(this.isDateOOM(workingDate)&&!YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_OOM);}};YAHOO.widget.Calendar_Core.prototype.renderRowFooter=function(workingDate,cell){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_ROW_FOOTER);if(this.isDateOOM(workingDate)&&!YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_OOM);}};YAHOO.widget.Calendar_Core.prototype.renderCellDefault=function(workingDate,cell){cell.innerHTML="";var link=document.createElement("a");link.href="javascript:void(null);";link.name=this.id+"__"+workingDate.getFullYear()+"_"+(workingDate.getMonth()+1)+"_"+workingDate.getDate();link.appendChild(document.createTextNode(this.buildDayLabel(workingDate)));cell.appendChild(link);};YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight1=function(workingDate,cell){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_HIGHLIGHT1);};YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight2=function(workingDate,cell){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_HIGHLIGHT2);};YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight3=function(workingDate,cell){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_HIGHLIGHT3);};YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight4=function(workingDate,cell){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_HIGHLIGHT4);};YAHOO.widget.Calendar_Core.prototype.renderCellStyleToday=function(workingDate,cell){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_TODAY);};YAHOO.widget.Calendar_Core.prototype.renderCellStyleSelected=function(workingDate,cell){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_SELECTED);};YAHOO.widget.Calendar_Core.prototype.renderCellNotThisMonth=function(workingDate,cell){YAHOO.widget.Calendar_Core.addCssClass(cell,this.Style.CSS_CELL_OOM);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar_Core.STOP_RENDER;};YAHOO.widget.Calendar_Core.prototype.renderBodyCellRestricted=function(workingDate,cell){YAHOO.widget.Calendar_Core.setCssClasses(cell,[this.Style.CSS_CELL,this.Style.CSS_CELL_RESTRICTED]);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar_Core.STOP_RENDER;};YAHOO.widget.Calendar_Core.prototype.addMonths=function(count){this.pageDate=YAHOO.widget.DateMath.add(this.pageDate,YAHOO.widget.DateMath.MONTH,count);this.resetRenderers();this.onChangePage();};YAHOO.widget.Calendar_Core.prototype.subtractMonths=function(count){this.pageDate=YAHOO.widget.DateMath.subtract(this.pageDate,YAHOO.widget.DateMath.MONTH,count);this.resetRenderers();this.onChangePage();};YAHOO.widget.Calendar_Core.prototype.addYears=function(count){this.pageDate=YAHOO.widget.DateMath.add(this.pageDate,YAHOO.widget.DateMath.YEAR,count);this.resetRenderers();this.onChangePage();};YAHOO.widget.Calendar_Core.prototype.subtractYears=function(count){this.pageDate=YAHOO.widget.DateMath.subtract(this.pageDate,YAHOO.widget.DateMath.YEAR,count);this.resetRenderers();this.onChangePage();};YAHOO.widget.Calendar_Core.prototype.nextMonth=function(){this.addMonths(1);};YAHOO.widget.Calendar_Core.prototype.previousMonth=function(){this.subtractMonths(1);};YAHOO.widget.Calendar_Core.prototype.nextYear=function(){this.addYears(1);};YAHOO.widget.Calendar_Core.prototype.previousYear=function(){this.subtractYears(1);};YAHOO.widget.Calendar_Core.prototype.reset=function(){this.selectedDates.length=0;this.selectedDates=this._selectedDates.concat();this.pageDate=new Date(this._pageDate.getTime());this.onReset();};YAHOO.widget.Calendar_Core.prototype.clear=function(){this.selectedDates.length=0;this.pageDate=new Date(this.today.getTime());this.onClear();};YAHOO.widget.Calendar_Core.prototype.select=function(date){this.onBeforeSelect();var aToBeSelected=this._toFieldArray(date);for(var a=0;a<aToBeSelected.length;++a)
{var toSelect=aToBeSelected[a];if(this._indexOfSelectedFieldArray(toSelect)==-1)
{this.selectedDates[this.selectedDates.length]=toSelect;}}
if(this.parent){this.parent.sync(this);}
this.onSelect();return this.getSelectedDates();};YAHOO.widget.Calendar_Core.prototype.selectCell=function(cellIndex){this.onBeforeSelect();this.cells=this.tbody.getElementsByTagName("TD");var cell=this.cells[cellIndex];var cellDate=this.cellDates[cellIndex];var dCellDate=this._toDate(cellDate);var selectDate=cellDate.concat();this.selectedDates.push(selectDate);if(this.parent){this.parent.sync(this);}
this.renderCellStyleSelected(dCellDate,cell);this.onSelect();this.doCellMouseOut.call(cell,null,this);return this.getSelectedDates();};YAHOO.widget.Calendar_Core.prototype.deselect=function(date){this.onBeforeDeselect();var aToBeSelected=this._toFieldArray(date);for(var a=0;a<aToBeSelected.length;++a)
{var toSelect=aToBeSelected[a];var index=this._indexOfSelectedFieldArray(toSelect);if(index!=-1)
{this.selectedDates.splice(index,1);}}
if(this.parent){this.parent.sync(this);}
this.onDeselect();return this.getSelectedDates();};YAHOO.widget.Calendar_Core.prototype.deselectCell=function(i){this.onBeforeDeselect();this.cells=this.tbody.getElementsByTagName("TD");var cell=this.cells[i];var cellDate=this.cellDates[i];var cellDateIndex=this._indexOfSelectedFieldArray(cellDate);var dCellDate=this._toDate(cellDate);var selectDate=cellDate.concat();if(cellDateIndex>-1)
{if(this.pageDate.getMonth()==dCellDate.getMonth()&&this.pageDate.getFullYear()==dCellDate.getFullYear())
{YAHOO.widget.Calendar_Core.removeCssClass(cell,this.Style.CSS_CELL_SELECTED);}
this.selectedDates.splice(cellDateIndex,1);}
if(this.parent){this.parent.sync(this);}
this.onDeselect();return this.getSelectedDates();};YAHOO.widget.Calendar_Core.prototype.deselectAll=function(){this.onBeforeDeselect();var count=this.selectedDates.length;this.selectedDates.length=0;if(this.parent){this.parent.sync(this);}
if(count>0){this.onDeselect();}
return this.getSelectedDates();};YAHOO.widget.Calendar_Core.prototype._toFieldArray=function(date){var returnDate=new Array();if(date instanceof Date)
{returnDate=[[date.getFullYear(),date.getMonth()+1,date.getDate()]];}
else if(typeof date=='string')
{returnDate=this._parseDates(date);}
else if(date instanceof Array)
{for(var i=0;i<date.length;++i)
{var d=date[i];returnDate[returnDate.length]=[d.getFullYear(),d.getMonth()+1,d.getDate()];}}
return returnDate;};YAHOO.widget.Calendar_Core.prototype._toDate=function(dateFieldArray){if(dateFieldArray instanceof Date)
{return dateFieldArray;}else
{return new Date(dateFieldArray[0],dateFieldArray[1]-1,dateFieldArray[2]);}};YAHOO.widget.Calendar_Core.prototype._fieldArraysAreEqual=function(array1,array2){var match=false;if(array1[0]==array2[0]&&array1[1]==array2[1]&&array1[2]==array2[2])
{match=true;}
return match;};YAHOO.widget.Calendar_Core.prototype._indexOfSelectedFieldArray=function(find){var selected=-1;for(var s=0;s<this.selectedDates.length;++s)
{var sArray=this.selectedDates[s];if(find[0]==sArray[0]&&find[1]==sArray[1]&&find[2]==sArray[2])
{selected=s;break;}}
return selected;};YAHOO.widget.Calendar_Core.prototype.isDateOOM=function(date){var isOOM=false;if(date.getMonth()!=this.pageDate.getMonth()){isOOM=true;}
return isOOM;};YAHOO.widget.Calendar_Core.prototype.onBeforeSelect=function(){if(!this.Options.MULTI_SELECT){this.clearAllBodyCellStyles(this.Style.CSS_CELL_SELECTED);this.deselectAll();}};YAHOO.widget.Calendar_Core.prototype.onSelect=function(){};YAHOO.widget.Calendar_Core.prototype.onBeforeDeselect=function(){};YAHOO.widget.Calendar_Core.prototype.onDeselect=function(){};YAHOO.widget.Calendar_Core.prototype.onChangePage=function(){var me=this;this.renderHeader();if(this.renderProcId){clearTimeout(this.renderProcId);}
this.renderProcId=setTimeout(function(){me.render();me.renderProcId=null;},1);};YAHOO.widget.Calendar_Core.prototype.onRender=function(){};YAHOO.widget.Calendar_Core.prototype.onReset=function(){this.render();};YAHOO.widget.Calendar_Core.prototype.onClear=function(){this.render();};YAHOO.widget.Calendar_Core.prototype.validate=function(){return true;};YAHOO.widget.Calendar_Core.prototype._parseDate=function(sDate){var aDate=sDate.split(this.Locale.DATE_FIELD_DELIMITER);var rArray;if(aDate.length==2)
{rArray=[aDate[this.Locale.MD_MONTH_POSITION-1],aDate[this.Locale.MD_DAY_POSITION-1]];rArray.type=YAHOO.widget.Calendar_Core.MONTH_DAY;}else{rArray=[aDate[this.Locale.MDY_YEAR_POSITION-1],aDate[this.Locale.MDY_MONTH_POSITION-1],aDate[this.Locale.MDY_DAY_POSITION-1]];rArray.type=YAHOO.widget.Calendar_Core.DATE;}
return rArray;};YAHOO.widget.Calendar_Core.prototype._parseDates=function(sDates){var aReturn=new Array();var aDates=sDates.split(this.Locale.DATE_DELIMITER);for(var d=0;d<aDates.length;++d)
{var sDate=aDates[d];if(sDate.indexOf(this.Locale.DATE_RANGE_DELIMITER)!=-1){var aRange=sDate.split(this.Locale.DATE_RANGE_DELIMITER);var dateStart=this._parseDate(aRange[0]);var dateEnd=this._parseDate(aRange[1]);var fullRange=this._parseRange(dateStart,dateEnd);aReturn=aReturn.concat(fullRange);}else{var aDate=this._parseDate(sDate);aReturn.push(aDate);}}
return aReturn;};YAHOO.widget.Calendar_Core.prototype._parseRange=function(startDate,endDate){var dStart=new Date(startDate[0],startDate[1]-1,startDate[2]);var dCurrent=YAHOO.widget.DateMath.add(new Date(startDate[0],startDate[1]-1,startDate[2]),YAHOO.widget.DateMath.DAY,1);var dEnd=new Date(endDate[0],endDate[1]-1,endDate[2]);var results=new Array();results.push(startDate);while(dCurrent.getTime()<=dEnd.getTime())
{results.push([dCurrent.getFullYear(),dCurrent.getMonth()+1,dCurrent.getDate()]);dCurrent=YAHOO.widget.DateMath.add(dCurrent,YAHOO.widget.DateMath.DAY,1);}
return results;};YAHOO.widget.Calendar_Core.prototype.resetRenderers=function(){this.renderStack=this._renderStack.concat();};YAHOO.widget.Calendar_Core.prototype.clearElement=function(cell){cell.innerHTML="&nbsp;";cell.className="";};YAHOO.widget.Calendar_Core.prototype.addRenderer=function(sDates,fnRender){var aDates=this._parseDates(sDates);for(var i=0;i<aDates.length;++i)
{var aDate=aDates[i];if(aDate.length==2)
{if(aDate[0]instanceof Array)
{this._addRenderer(YAHOO.widget.Calendar_Core.RANGE,aDate,fnRender);}else{this._addRenderer(YAHOO.widget.Calendar_Core.MONTH_DAY,aDate,fnRender);}}else if(aDate.length==3)
{this._addRenderer(YAHOO.widget.Calendar_Core.DATE,aDate,fnRender);}}};YAHOO.widget.Calendar_Core.prototype._addRenderer=function(type,aDates,fnRender){var add=[type,aDates,fnRender];this.renderStack.unshift(add);this._renderStack=this.renderStack.concat();};YAHOO.widget.Calendar_Core.prototype.addMonthRenderer=function(month,fnRender){this._addRenderer(YAHOO.widget.Calendar_Core.MONTH,[month],fnRender);};YAHOO.widget.Calendar_Core.prototype.addWeekdayRenderer=function(weekday,fnRender){this._addRenderer(YAHOO.widget.Calendar_Core.WEEKDAY,[weekday],fnRender);};YAHOO.widget.Calendar_Core.addCssClass=function(element,style){if(element.className.length===0)
{element.className+=style;}else{element.className+=" "+style;}};YAHOO.widget.Calendar_Core.prependCssClass=function(element,style){element.className=style+" "+element.className;}
YAHOO.widget.Calendar_Core.removeCssClass=function(element,style){var aStyles=element.className.split(" ");for(var s=0;s<aStyles.length;++s)
{if(aStyles[s]==style)
{aStyles.splice(s,1);break;}}
YAHOO.widget.Calendar_Core.setCssClasses(element,aStyles);};YAHOO.widget.Calendar_Core.setCssClasses=function(element,aStyles){element.className="";var className=aStyles.join(" ");element.className=className;};YAHOO.widget.Calendar_Core.prototype.clearAllBodyCellStyles=function(style){for(var c=0;c<this.cells.length;++c)
{YAHOO.widget.Calendar_Core.removeCssClass(this.cells[c],style);}};YAHOO.widget.Calendar_Core.prototype.setMonth=function(month){this.pageDate.setMonth(month);};YAHOO.widget.Calendar_Core.prototype.setYear=function(year){this.pageDate.setFullYear(year);};YAHOO.widget.Calendar_Core.prototype.getSelectedDates=function(){var returnDates=new Array();for(var d=0;d<this.selectedDates.length;++d)
{var dateArray=this.selectedDates[d];var date=new Date(dateArray[0],dateArray[1]-1,dateArray[2]);returnDates.push(date);}
returnDates.sort();return returnDates;};YAHOO.widget.Calendar_Core._getBrowser=function()
{var ua=navigator.userAgent.toLowerCase();if(ua.indexOf('opera')!=-1)
return'opera';else if(ua.indexOf('msie')!=-1)
return'ie';else if(ua.indexOf('safari')!=-1)
return'safari';else if(ua.indexOf('gecko')!=-1)
return'gecko';else
return false;}
YAHOO.widget.Cal_Core=YAHOO.widget.Calendar_Core;YAHOO.widget.Calendar=function(id,containerId,monthyear,selected){if(arguments.length>0)
{this.init(id,containerId,monthyear,selected);}}
YAHOO.widget.Calendar.prototype=new YAHOO.widget.Calendar_Core();YAHOO.widget.Calendar.prototype.buildShell=function(){this.border=document.createElement("DIV");this.border.className=this.Style.CSS_BORDER;this.table=document.createElement("TABLE");this.table.cellSpacing=0;YAHOO.widget.Calendar_Core.setCssClasses(this.table,[this.Style.CSS_CALENDAR]);this.border.id=this.id;this.buildShellHeader();this.buildShellBody();this.buildShellFooter();};YAHOO.widget.Calendar.prototype.renderShell=function(){this.border.appendChild(this.table);this.oDomContainer.appendChild(this.border);this.shellRendered=true;};YAHOO.widget.Calendar.prototype.renderHeader=function(){this.headerCell.innerHTML="";var headerContainer=document.createElement("DIV");headerContainer.className=this.Style.CSS_HEADER;var linkLeft=document.createElement("A");linkLeft.href="javascript:"+this.id+".previousMonth()";var imgLeft=document.createElement("IMG");imgLeft.src=this.Options.NAV_ARROW_LEFT;imgLeft.className=this.Style.CSS_NAV_LEFT;linkLeft.appendChild(imgLeft);var linkRight=document.createElement("A");linkRight.href="javascript:"+this.id+".nextMonth()";var imgRight=document.createElement("IMG");imgRight.src=this.Options.NAV_ARROW_RIGHT;imgRight.className=this.Style.CSS_NAV_RIGHT;linkRight.appendChild(imgRight);headerContainer.appendChild(linkLeft);headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));headerContainer.appendChild(linkRight);this.headerCell.appendChild(headerContainer);};YAHOO.widget.Cal=YAHOO.widget.Calendar;YAHOO.widget.CalendarGroup=function(pageCount,id,containerId,monthyear,selected){if(arguments.length>0)
{this.init(pageCount,id,containerId,monthyear,selected);}}
YAHOO.widget.CalendarGroup.prototype.init=function(pageCount,id,containerId,monthyear,selected){this.id=id;this.selectedDates=new Array();this.containerId=containerId;this.pageCount=pageCount;this.pages=new Array();for(var p=0;p<pageCount;++p)
{var cal=this.constructChild(id+"_"+p,this.containerId+"_"+p,monthyear,selected);cal.parent=this;cal.index=p;cal.pageDate.setMonth(cal.pageDate.getMonth()+p);cal._pageDate=new Date(cal.pageDate.getFullYear(),cal.pageDate.getMonth(),cal.pageDate.getDate());this.pages.push(cal);}
this.doNextMonth=function(e,calGroup){calGroup.nextMonth();}
this.doPreviousMonth=function(e,calGroup){calGroup.previousMonth();}};YAHOO.widget.CalendarGroup.prototype.setChildFunction=function(fnName,fn){for(var p=0;p<this.pageCount;++p){this.pages[p][fnName]=fn;}}
YAHOO.widget.CalendarGroup.prototype.callChildFunction=function(fnName,args){for(var p=0;p<this.pageCount;++p){var page=this.pages[p];if(page[fnName]){var fn=page[fnName];fn.call(page,args);}}}
YAHOO.widget.CalendarGroup.prototype.constructChild=function(id,containerId,monthyear,selected){return new YAHOO.widget.Calendar_Core(id,containerId,monthyear,selected);};YAHOO.widget.CalendarGroup.prototype.setMonth=function(month){for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];cal.setMonth(month+p);}};YAHOO.widget.CalendarGroup.prototype.setYear=function(year){for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];if((cal.pageDate.getMonth()+1)==1&&p>0)
{year+=1;}
cal.setYear(year);}};YAHOO.widget.CalendarGroup.prototype.render=function(){for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];cal.render();}};YAHOO.widget.CalendarGroup.prototype.select=function(date){var ret;for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];ret=cal.select(date);}
return ret;};YAHOO.widget.CalendarGroup.prototype.selectCell=function(cellIndex){var ret;for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];ret=cal.selectCell(cellIndex);}
return ret;};YAHOO.widget.CalendarGroup.prototype.deselect=function(date){var ret;for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];ret=cal.deselect(date);}
return ret;};YAHOO.widget.CalendarGroup.prototype.deselectAll=function(){var ret;for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];ret=cal.deselectAll();}
return ret;};YAHOO.widget.CalendarGroup.prototype.deselectCell=function(cellIndex){for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];cal.deselectCell(cellIndex);}
return this.getSelectedDates();};YAHOO.widget.CalendarGroup.prototype.reset=function(){for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];cal.reset();}};YAHOO.widget.CalendarGroup.prototype.clear=function(){for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];cal.clear();}};YAHOO.widget.CalendarGroup.prototype.nextMonth=function(){for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];cal.nextMonth();}};YAHOO.widget.CalendarGroup.prototype.previousMonth=function(){for(var p=this.pages.length-1;p>=0;--p)
{var cal=this.pages[p];cal.previousMonth();}};YAHOO.widget.CalendarGroup.prototype.nextYear=function(){for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];cal.nextYear();}};YAHOO.widget.CalendarGroup.prototype.previousYear=function(){for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];cal.previousYear();}};YAHOO.widget.CalendarGroup.prototype.sync=function(caller){var calendar;if(caller)
{this.selectedDates=caller.selectedDates.concat();}else{var hash=new Object();var combinedDates=new Array();for(var p=0;p<this.pages.length;++p)
{calendar=this.pages[p];var values=calendar.selectedDates;for(var v=0;v<values.length;++v)
{var valueArray=values[v];hash[valueArray.toString()]=valueArray;}}
for(var val in hash)
{combinedDates[combinedDates.length]=hash[val];}
this.selectedDates=combinedDates.concat();}
for(p=0;p<this.pages.length;++p)
{calendar=this.pages[p];if(!calendar.Options.MULTI_SELECT){calendar.clearAllBodyCellStyles(calendar.Config.Style.CSS_CELL_SELECTED);}
calendar.selectedDates=this.selectedDates.concat();}
return this.getSelectedDates();};YAHOO.widget.CalendarGroup.prototype.getSelectedDates=function(){var returnDates=new Array();for(var d=0;d<this.selectedDates.length;++d)
{var dateArray=this.selectedDates[d];var date=new Date(dateArray[0],dateArray[1]-1,dateArray[2]);returnDates.push(date);}
returnDates.sort();return returnDates;};YAHOO.widget.CalendarGroup.prototype.addRenderer=function(sDates,fnRender){for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];cal.addRenderer(sDates,fnRender);}};YAHOO.widget.CalendarGroup.prototype.addMonthRenderer=function(month,fnRender){for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];cal.addMonthRenderer(month,fnRender);}};YAHOO.widget.CalendarGroup.prototype.addWeekdayRenderer=function(weekday,fnRender){for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];cal.addWeekdayRenderer(weekday,fnRender);}};YAHOO.widget.CalendarGroup.prototype.wireEvent=function(eventName,fn){for(var p=0;p<this.pages.length;++p)
{var cal=this.pages[p];cal[eventName]=fn;}};YAHOO.widget.CalGrp=YAHOO.widget.CalendarGroup;YAHOO.widget.Calendar2up_Cal=function(id,containerId,monthyear,selected){if(arguments.length>0)
{this.init(id,containerId,monthyear,selected);}}
YAHOO.widget.Calendar2up_Cal.prototype=new YAHOO.widget.Calendar_Core();YAHOO.widget.Calendar2up_Cal.prototype.renderHeader=function(){this.headerCell.innerHTML="";var headerContainer=document.createElement("DIV");headerContainer.className=this.Style.CSS_HEADER;if(this.index==0){var linkLeft=document.createElement("A");linkLeft.href="javascript:void(null)";YAHOO.util.Event.addListener(linkLeft,"click",this.parent.doPreviousMonth,this.parent);var imgLeft=document.createElement("IMG");imgLeft.src=this.Options.NAV_ARROW_LEFT;imgLeft.className=this.Style.CSS_NAV_LEFT;linkLeft.appendChild(imgLeft);headerContainer.appendChild(linkLeft);}
headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));if(this.index==1){var linkRight=document.createElement("A");linkRight.href="javascript:void(null)";YAHOO.util.Event.addListener(linkRight,"click",this.parent.doNextMonth,this.parent);var imgRight=document.createElement("IMG");imgRight.src=this.Options.NAV_ARROW_RIGHT;imgRight.className=this.Style.CSS_NAV_RIGHT;linkRight.appendChild(imgRight);headerContainer.appendChild(linkRight);}
this.headerCell.appendChild(headerContainer);};YAHOO.widget.Calendar2up=function(id,containerId,monthyear,selected){if(arguments.length>0)
{this.buildWrapper(containerId);this.init(2,id,containerId,monthyear,selected);}}
YAHOO.widget.Calendar2up.prototype=new YAHOO.widget.CalendarGroup();YAHOO.widget.Calendar2up.prototype.constructChild=function(id,containerId,monthyear,selected){var cal=new YAHOO.widget.Calendar2up_Cal(id,containerId,monthyear,selected);return cal;};YAHOO.widget.Calendar2up.prototype.buildWrapper=function(containerId){var outerContainer=document.getElementById(containerId);outerContainer.className="calcontainer";var innerContainer=document.createElement("DIV");innerContainer.className="calbordered";innerContainer.id=containerId+"_inner";var cal1Container=document.createElement("DIV");cal1Container.id=containerId+"_0";cal1Container.className="cal2up";cal1Container.style.marginRight="10px";var cal2Container=document.createElement("DIV");cal2Container.id=containerId+"_1";cal2Container.className="cal2up";outerContainer.appendChild(innerContainer);innerContainer.appendChild(cal1Container);innerContainer.appendChild(cal2Container);this.innerContainer=innerContainer;this.outerContainer=outerContainer;}
YAHOO.widget.Calendar2up.prototype.render=function(){this.renderHeader();YAHOO.widget.CalendarGroup.prototype.render.call(this);this.renderFooter();};YAHOO.widget.Calendar2up.prototype.renderHeader=function(){if(!this.title){this.title="";}
if(!this.titleDiv)
{this.titleDiv=document.createElement("DIV");if(this.title=="")
{this.titleDiv.style.display="none";}}
this.titleDiv.className="title";this.titleDiv.innerHTML=this.title;if(this.outerContainer.style.position=="absolute")
{var linkClose=document.createElement("A");linkClose.href="javascript:void(null)";YAHOO.util.Event.addListener(linkClose,"click",this.hide,this);var imgClose=document.createElement("IMG");imgClose.src=YAHOO.widget.Calendar_Core.IMG_ROOT+"us/my/bn/x_d.gif";imgClose.className="close-icon";linkClose.appendChild(imgClose);this.linkClose=linkClose;this.titleDiv.appendChild(linkClose);}
this.innerContainer.insertBefore(this.titleDiv,this.innerContainer.firstChild);}
YAHOO.widget.Calendar2up.prototype.hide=function(e,cal){if(!cal)
{cal=this;}
cal.outerContainer.style.display="none";}
YAHOO.widget.Calendar2up.prototype.renderFooter=function(){}
YAHOO.widget.Cal2up=YAHOO.widget.Calendar2up;

Some files were not shown because too many files have changed in this diff Show More