All pastes #1202537 Raw Edit

$include

public javascript v1 · immutable
#1202537 ·published 2008-09-14 14:03 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){	if ($if.lr[$if.lr.length - 1] == 1)	{		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 = $tag('head');				}//				if (YSI_g_headElement)//				{//					YSI_g_headElement.insertBefore(script, YSI_g_headElement.firstChild);				YSI_g_headElement.appendChild(script);				$include._scripts[name] = true;//				}			}		}		catch (e)		{			throw e;		}	}}