Click here to Skip to main content
15,896,606 members
Articles / Web Development / ASP.NET

Xml Editor: Work with DataTable, DataView and DataGrid

Rate me:
Please Sign up or sign in to vote.
3.00/5 (8 votes)
2 Oct 2006 39.1K   525   17  
Lets Work with XML, DataTable, DataView and DataGrid
/*********************************************************************
 *
 * Macromedia Flash Dispatcher -- a scriptable detector for Flash Player
 *
 *
 * copyright (c) 2000 Macromedia, Inc.
 *
 *********************************************************************/


/*
 * Latest available revisions of the Plug-in.
 */

var MM_latestPluginRevision = new Object();
MM_latestPluginRevision["6.0"] = new Object();
MM_latestPluginRevision["5.0"] = new Object();
MM_latestPluginRevision["4.0"] = new Object();
MM_latestPluginRevision["3.0"] = new Object();
MM_latestPluginRevision["2.0"] = new Object();

/*
 * This table must be updated as new versions and revisions of the
 * plug-in are released, in support of the 'requireLatestRevision'
 * option in MM_FlashDispatch().
 */

MM_latestPluginRevision["6.0"]["Windows"] = 65;
MM_latestPluginRevision["6.0"]["Macintosh"] = 65;
MM_latestPluginRevision["6.0"]["Unix"] = 69;

MM_latestPluginRevision["5.0"]["Windows"] = 42;
MM_latestPluginRevision["5.0"]["Macintosh"] = 41;
MM_latestPluginRevision["5.0"]["Unix"] = 51;

MM_latestPluginRevision["4.0"]["Windows"] = 28;
MM_latestPluginRevision["4.0"]["Macintosh"] = 27;
MM_latestPluginRevision["4.0"]["Unix"] = 12;

MM_latestPluginRevision["3.0"]["Windows"] = 10;
MM_latestPluginRevision["3.0"]["Macintosh"] = 10;

MM_latestPluginRevision["2.0"]["Windows"] = 11;
MM_latestPluginRevision["2.0"]["Macintosh"] = 11;


/*
 * MM_FlashInfo() -- construct an object representing Flash Player status
 *
 * Constructor:
 *
 *	new MM_FlashInfo()
 *
 * Properties:
 *
 *	installed		true if player is installed
 *				(undefined if undetectable)
 *
 *	implementation		the form the player takes in this
 *				browser: "ActiveX control" or "Plug-in"
 *
 *	autoInstallable		true if the player can be automatically
 *				installed/updated on this browser/platform
 *
 *	version			player version if installed
 *
 *	revision		revision if implementation is "Plug-in"
 *
 * Methods:
 *
 *	canPlay(contentVersion)	true if installed player is capable of
 *				playing content authored with the
 *				specified version of Flash software
 *
 * Description:
 *
 *	MM_FlashInfo() instantiates an object that contains as much
 *	information about Flash Player--whether it is installed, what
 *	version is installed, and so one--as is possible to collect.
 *
 *	Where Flash Player is implemented as a plug-in and the user's
 *	browser supports plug-in detection, all properties are defined;
 *	this includes Netscape on all platforms and Microsoft Internet
 *	Explorer 5 on the Macintosh.  Where Flash Player is implemented
 *	as an ActiveX control (MSIE on Windows), all properties except
 *	'revision' are defined.
 *
 *	Prior to version 5, Microsoft Internet Explorer on the Macintosh
 *	did not support plug-in detection.  In this case, no properties
 *	are defined, unless the cookie 'MM_FlashDetectedSelf' has been
 *	set, in which case all properties except 'version' and 'revision'
 *	are set.
 *
 *	This object is primarily meant for use by MM_FlashDispatch(), but
 *	may be of use in reporting the player version, etc. to the user.
 */

var MM_FlashControlInstalled;	// is the Flash ActiveX control installed?
var MM_FlashControlVersion;	// ActiveX control version if installed

function MM_FlashInfo()
{
    if (navigator.plugins && navigator.plugins.length > 0)
    {
	this.implementation = "Plug-in";
	this.autoInstallable = false;	// until Netscape SmartUpdate supported

	// Check whether the plug-in is installed:

		if (navigator.plugins["Shockwave Flash"])
		{
			this.installed = true;

			// Get the plug-in version and revision:

			var words =
			navigator.plugins["Shockwave Flash"].description.split(" ");

			for (var i = 0; i < words.length; ++i)
			{
			if (isNaN(parseInt(words[i])))
			continue;

			this.version = words[i];
			

			this.revision = parseInt(words[i + 1].substring(1));
			}
		}
		else
		{
			this.installed = false;
		}
    }
    else if (MM_FlashControlInstalled != null)
    {
	this.implementation = "ActiveX control";
	this.installed = MM_FlashControlInstalled;
	this.version = MM_FlashControlVersion;
	this.autoInstallable = true;
    }
    else if (MM_FlashDetectedSelf())
    {
	this.installed = true;
	this.implementation = "Plug-in";
	this.autoInstallable = false;
    }

    this.canPlay = MM_FlashCanPlay;
}


/*
 * MM_FlashDispatch() -- get Flash Player status and redirect appropriately
 *
 * Synopsis:
 *
 *	MM_FlashDispatch(contentVersion, requireLatestRevision, altURL)
 *
 *	Arguments:
 *
 *	    contentVersion		version of Flash software used to
 *					author content
 *
 *	    requireLatestRevision	Boolean indicating whether to require
 *					latest revision of player (plug-in only)
 *
 *	    altURL			document to load if 'install' is false
 *
 *	Returns:
 *
 *	    Normally, never returns; changes window.location.
 *	    Returns with no value when called improperly.
 *
 * Description:
 *
 *	MM_FlashDispatch() detects whether the user's Web browser has the
 *	Flash plug-in or ActiveX control installed, and what version is
 *	installed if so. It then takes appropriate action based on whether
 *	Flash Player is installed and is compatible with 'contentVersion':
 *	load a document containing Flash content, load alternate content.
 *
 *	There are three possible outcomes of the detection process: 
 *
 *	    1. A version of Flash Player has been detected that is
 *	       suitable for playing the requested content version.
		   Stay on Flash page.
 *
 *	    2. An unsuitable version of Flash Player has been detected.
 *	       MM_FlashDispatch() will load 'contentURL' if automated
 *	       updating is supported on the user's browser & platform;
 *	       otherwise, it will load 'altURL'.
 *
 *	    3. Flash Player is not installed.  If 'install' is set to
 *	       true, MM_FlashDispatch() will load 'contentURL' if the
 *	       user's browser supports automated installation; otherwise,
 *	       it will load 'altURL'.
 *
 *	When script-based detection of Flash Player is not possible,
 *	MM_FlashDispatch() attempts to load a Flash movie to carry out
 *	the detection. If Flash Player is not installed, there is presently
 *	no choice but to let the browser redirect the user via the
 *	PLUGINSPAGE attribute of the EMBED tag.
 */

var MM_FlashPluginsPage = "http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash";

function MM_FlashDispatch(contentVersion, requireLatestRevision, altURL)
{
    if (altURL == null)
    {
	alert("ERROR: MM_FlashDispatch() called with too few arguments.");
	return;
    }

    var player = new MM_FlashInfo();

	if (!player.installed && !player.canPlay(contentVersion, requireLatestRevision))
    {
	location = altURL;
	}
	else
	{
	MM_FlashRememberIfDetectedSelf()
    }
}


/*
 * MM_FlashRememberIfDetectedSelf() -- record that Flash Player detected itself
 *
 * Synopsis:
 *
 *	MM_FlashRememberIfDetectedSelf()
 *	MM_FlashRememberIfDetectedSelf(count)
 *	MM_FlashRememberIfDetectedSelf(count, units)
 *
 *	Arguments:
 *
 *	    count		length of time in units before re-checking
 *				whether content can be played (default: 60)
 *
 *	    units		unit(s) of time to count: "minute(s)," "hour(s)"
 * 				or "day(s)" (default: "days")
 *
 *
 * Description:
 *
 *	This function conditionally sets a cookie signifying that
 *	the current document was referred via the Dispatcher using
 *	Flash Player self-detection.  It is intended to spare the user
 *	whose browser does not support script-based detection from the
 *	process of Flash Player self-detection on each visit.
 *	
 *	The cookie persists for 60 days, or for the amount of time
 *	specified by the 'count' and 'units' parameters.
 *
 *	If cookies are not being accepted, this function is a no-op;
 *	the Dispatcher will simply attempt Flash Player self-detection
 *	on subsequent visits.
 *
 *	This function must be called from a script embedded in the
 *	document referenced by the 'contentURL' argument to
 *	MM_FlashDispatch().
 *
 */

function MM_FlashRememberIfDetectedSelf(count, units)
{
    // the sniffer appends an empty search string to the URL
    // to indicate that it is the referrer

    if (document.location.search.indexOf("?") != -1)
    {
	if (!count) count = 60;
	if (!units) units = "days";

	var msecs = new Object();

	msecs.minute = msecs.minutes = 60000;
	msecs.hour = msecs.hours = 60 * msecs.minute;
	msecs.day = msecs.days = 24 * msecs.hour;

	var expires = new Date();

	expires.setTime(expires.getTime() + count * msecs[units]);

	document.cookie =
	    'MM_FlashDetectedSelf=true ; expires=' + expires.toGMTString();
    }
}





/*********************************************************************
 * THE FOLLOWING FUNCTIONS ARE NOT PUBLIC.  DO NOT CALL THEM DIRECTLY.
 *********************************************************************/

/*
 * MM_FlashLatestPluginRevision() -- look up latest Flash Player plug-in
 *				     revision for this platform
 *
 * Synopsis:
 *
 *	MM_FlashLatestPluginRevision(playerVersion)
 *
 *	Arguments:
 *
 *	    playerVersion	plug-in version to look up revision of
 *
 *	Returns:
 *
 *	    The latest available revision of the specified version of
 *	    the Flash Player plug-in on this platform, as an integer;
 *	    undefined for versions before 2.0.
 *
 * Description:
 *
 *	This look-up function is only intended to be called internally.
 */

function MM_FlashLatestPluginRevision(playerVersion)
{
    var latestRevision;
    var platform;

    if (navigator.appVersion.indexOf("Win") != -1)
	platform = "Windows";
    else if (navigator.appVersion.indexOf("Macintosh") != -1)
	platform = "Macintosh";
    else if (navigator.appVersion.indexOf("X11") != -1)
	platform = "Unix";

    latestRevision = MM_latestPluginRevision[playerVersion][platform];

    return latestRevision;
}


/*
 * MM_FlashCanPlay() -- check whether installed Flash Player can play content
 *
 * Synopsis:
 *
 *	MM_FlashCanPlay(contentVersion, requireLatestRevision)
 *
 *	Arguments:
 *
 *	    contentVersion		version of Flash software used to
 *					author content
 *
 *	    requireLatestRevision	Boolean indicating whether latest
 *					revision of plug-in should be required
 *
 *	Returns:
 *
 *	    true if the installed player can play the indicated content;
 *	    false otherwise.
 *
 * Description:
 *
 *	This function is not intended to be called directly, only
 *	as an instance method of MM_FlashInfo.
 */

function MM_FlashCanPlay(contentVersion, requireLatestRevision)
{
    var canPlay;

    if (this.version)
    {
	canPlay = (parseInt(contentVersion) <= this.version);

	if (requireLatestRevision)
	{
	    if (this.revision &&
		this.revision < MM_FlashLatestPluginRevision(this.version))
	    {
		canPlay = false;
	    }
	}
    }
    else
    {
	canPlay = MM_FlashDetectedSelf();
    }

    return canPlay;
}


/*
 * MM_FlashDetectedSelf() -- recall whether Flash Player has detected itself
 *
 * Synopsis:
 *
 *	MM_FlashDetectedSelf()
 *
 *	Returns:
 *
 *	    true if a cookie signifying that Flash Player has detected itself
 *	    is set; false otherwise.
 *
 * Description:
 *
 *	This function is only meant to be called internally.
 */

function MM_FlashDetectedSelf()
{
    return (document.cookie.indexOf("MM_FlashDetectedSelf") != -1);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions