All pastes #1202543 Raw Edit

$include

public javascript v1 · immutable
#1202543 ·published 2008-09-14 14:15 UTC
rendered paste body
/*----------------------------------------------------------------------------*-Function:	$includeParams:	file - File to include.Return:	-Notes:	Includes a script into the current document to import all their functions	etc.  Checks for prior inclusions and only include if required.-*----------------------------------------------------------------------------*/var	YSI_g_headElement = null;$include = function (file){	var		ext = file.lastIndexOf('.');	if (ext == -1)	{		return;	}	var		name = file.substring(0, ext);	// Check if there's an array list of scripts	if ($include._scripts)	{		// Check if this script is included already		if ($include._scripts[name])		{			// Yes, exit			return;		}	}	else	{		// No array, create one		$include._scripts = [];	} 	// This script doesn't exist so mark it as now included	// Create the code to go into the browser	try	{		var			script = document.createElement('script');		if (script)		{			script.src = file;			script.language = 'JavaScript1.2';			script.type = 'text/javascript';			script.defer = false;			if (!YSI_g_headElement)			{				YSI_g_headElement = document.getElementsByTagName('head')[0];			}			YSI_g_headElement.appendChild(script);			$include._scripts[name] = true;		}	}	catch (e)	{		throw e;	}}