using System;
namespace UDDI.Web
{
public class ClientScripts
{
/// ****************************************************************
/// public ShowHelp [static]
/// ----------------------------------------------------------------
///
/// Shows the given help url.
///
/// ----------------------------------------------------------------
///
/// The URL to load.
///
/// ----------------------------------------------------------------
///
/// The client script to show the help.
///
/// ****************************************************************
///
public static string ShowHelp( string url )
{
string script = @"
";
script = script.Replace( "{url}", url.Replace( "\"", "\\\"" ) );
return script;
}
/// ****************************************************************
/// public ReloadTop [static]
/// ----------------------------------------------------------------
///
/// Reloads the top window with the given url.
///
/// ----------------------------------------------------------------
///
/// The URL to load in the top window.
///
/// ----------------------------------------------------------------
///
/// The client script to reload the top window.
///
/// ****************************************************************
///
public static string ReloadTop( string url )
{
string script = @"
";
script = script.Replace( "{url}", url.Replace( "\"", "\\\"" ) );
return script;
}
/// ****************************************************************
/// public ReloadViewPane [static]
/// ----------------------------------------------------------------
///
/// Reloads the view pane with the given url.
///
/// ----------------------------------------------------------------
///
/// The URL to load in the view pane.
///
/// ----------------------------------------------------------------
///
/// The client script to reload the view pane.
///
/// ****************************************************************
///
public static string ReloadViewPane( string url )
{
string script = @"
";
script = script.Replace( "{url}", url.Replace( "\"", "\\\"" ) );
return script;
}
/// ****************************************************************
/// public ReloadExplorerPane [static]
/// ----------------------------------------------------------------
///
/// Reloads the explorer pane.
///
/// ----------------------------------------------------------------
///
/// The client script to reload the explorer pane.
///
/// ****************************************************************
///
public static string ReloadExplorerPane()
{
string script = @"
";
return script;
}
/// ****************************************************************
/// public ReloadExplorerPane [static]
/// ----------------------------------------------------------------
///
/// Reloads the explorer pane.
///
/// ----------------------------------------------------------------
///
/// The node key to select.
///
/// ----------------------------------------------------------------
///
/// The client script to reload the explorer pane.
///
/// ****************************************************************
///
public static string ReloadExplorerPane( string key )
{
string script = @"
";
script = script.Replace( "{key}", key.Replace( "\"", "\\\"" ) );
return script;
}
/// ****************************************************************
/// public ReloadExplorerAndViewPanes [static]
/// ----------------------------------------------------------------
///
/// Reloads the explorer and view panes.
///
/// ----------------------------------------------------------------
///
/// The URL to load in the view pane.
///
///
///
/// The node key to select in the explorer pane.
///
/// ----------------------------------------------------------------
///
/// The client script to reload the explorer and view panes.
///
/// ****************************************************************
///
public static string ReloadExplorerAndViewPanes( string url, string key )
{
string script = @"
";
script = script.Replace( "{url}", url.Replace( "\"", "\\\"" ) );
script = script.Replace( "{key}", key.Replace( "\"", "\\\"" ) );
return script;
}
/// ****************************************************************
/// public Confirm [static]
/// ----------------------------------------------------------------
///
/// Displays a confirmation dialog and then proceeds to one
/// of two URL's depending on the user's choice.
///
/// ----------------------------------------------------------------
///
/// The message to display.
///
///
///
/// The URL to go to if the user selects OK.
///
/// ----------------------------------------------------------------
///
/// The client script to display the confirm dialog.
///
/// ****************************************************************
///
public static string Confirm( string message, string urlOk )
{
string script = @"
";
script = script.Replace( "{message}", message.Replace( "\"", "\\\"" ).Replace( "\n", " " ) );
script = script.Replace( "{urlOk}", urlOk.Replace( "\"", "\\\"" ) );
return script;
}
/// ****************************************************************
/// public Confirm [static]
/// ----------------------------------------------------------------
///
/// Displays a confirmation dialog and then proceeds to one
/// of two URL's depending on the user's choice.
///
/// ----------------------------------------------------------------
///
/// The message to display.
///
///
///
/// The URL to go to if the user selects OK.
///
///
///
/// The URL to go to if the user selects Cancel.
///
/// ----------------------------------------------------------------
///
/// The client script to display the confirm dialog.
///
/// ****************************************************************
///
public static string Confirm( string message, string urlOk, string urlCancel )
{
string script = @"
";
script = script.Replace( "{message}", message.Replace( "\"", "\\\"" ).Replace( "\n", " " ) );
script = script.Replace( "{urlOk}", urlOk.Replace( "\"", "\\\"" ) );
script = script.Replace( "{urlCancel}", urlCancel.Replace( "\"", "\\\"" ) );
return script;
}
/// ****************************************************************
/// public ShowModalDialog [static]
/// ----------------------------------------------------------------
///
/// Displays a modal dialog.
///
/// ----------------------------------------------------------------
///
/// The URL of the dialog to display.
///
///
///
/// The width of the dialog.
///
///
///
/// The height of the dialog.
///
/// ----------------------------------------------------------------
///
/// The client script to display the dialog.
///
/// ****************************************************************
///
public static string ShowModalDialog( string url, string width, string height, bool resizable, bool scrollbars, bool status )
{
string script = @"
";
script = script.Replace( "{url}", url.Replace( "\"", "\\\"" ) );
script = script.Replace( "{width}", width );
script = script.Replace( "{height}", height );
script = script.Replace( "{resizable}", resizable ? "yes" : "no" );
script = script.Replace( "{scrollbars}", scrollbars ? "yes" : "no" );
script = script.Replace( "{status}", status ? "yes" : "no" );
return script;
}
/// ****************************************************************
/// public CloseWindow [static]
/// ----------------------------------------------------------------
///
/// Closes the window.
///
/// ----------------------------------------------------------------
///
/// The client script to close the window.
///
/// ****************************************************************
///
public static string CloseWindow()
{
string script = @"
";
return script;
}
}
public class ClientScriptRegisterCollection : System.Collections.CollectionBase
{
public ClientScriptRegister this[ int index ]
{
get{ return (ClientScriptRegister)this.List[ index ] ; }
set{ this.List[ index ]=value; }
}
public int Add( ClientScriptRegister script )
{
return this.List.Add( script );
}
public void Remove( ClientScriptRegister script )
{
this.List.Remove( script );
}
public void Remove( int index )
{
this.List.RemoveAt( index );
}
}
public class ClientScriptRegister : System.Web.UI.WebControls.PlaceHolder
{
private string source;
public string Source
{
get{ return source; }
set{ source=value; }
}
private string language;
public string Language
{
get{ return language; }
set{ language=value; }
}
protected override void Render( System.Web.UI.HtmlTextWriter output )
{
//if source is provided, then render a link
if( null!=source )
{
output.Write(
""
);
}
else//else render the control
{
//render script tag
if( null!=Language )
output.AddAttribute( "language", Language );
output.RenderBeginTag( System.Web.UI.HtmlTextWriterTag.Script );
base.Render( output );
//close script tag
output.RenderEndTag();
}
}
}
}