<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8">
		<meta name="generator" content="Adobe GoLive">
		<title>Translate SDK Script Extension</title>
	</head>

	<body>
		<hr>
		<p>ADOBE SYSTEMS INCORPORATED</p>
		<p>Copyright 2003 Adobe Systems Incorporated<br>All Rights Reserved</p>
		<p>NOTICE: Adobe permits you to use, modify, and distribute this 
		file in accordance with the terms of the Adobe license agreement 
		accompanying it. If you have received this file from a source other 
		than Adobe, then your use, modification, or distribution of it requires 
		the prior written permission of Adobe.</p>
		<hr>
		<p><b>Extension Name:</b> Translate SDK Script</p>
		<p><b>Folder name:</b> Translate SDK Script</p>
		<hr>
		<p><b>Description:</b></p>
		<p>This sample demonstrates how to use the JSXTranslator object and how to implement a markup translator. See the documentation for more information on JSXTranslator. A markup translator is called before the GoLive parser parses the file. The translator is able to modify the document markup before it is sent to the parser.</p>
		<p>This sample translates a special script tag.</p>
		<hr>
		<p><b>Module Definition:</b></p>
		<jsxmodule name="Translate GoLive Script" info="Add the AGL Script object to your Web page and create design time dynamic content. The result of the script is inserted in the document when you update." debug="false">
		<p><b>Scripts:</b></p>
		<script><!--
//--------------------------------------------------------------------
// GLOBAL VARIABLES
//--------------------------------------------------------------------

// define global variables here


//--------------------------------------------------------------------
// CALLBACK FUNCTIONS
//--------------------------------------------------------------------

var prefix	= "<script type=\"text/aglscript\"><!--\n";
var postfix	= "\n" + "/" + "/" + "-" + "-" + ">" + "<" + "/" + "s" + "c" + "r" + "i" + "p" + "t" + ">";


//---------------------------------------------------------
// controlSignal -  called when the state of a control has changed
//
// Description:
//   Use to extract the state of the control, and react to the state
//   change.
//
// Warning: see documentation for warnings about reparse, 
//   reformat, setInnerHTML, and setOuterHTML.

function controlSignal (control) 
{
	if (control.name == "update") {
		var script	= inspector.content.value;
		var newContent	= "";
		
		newContent += prefix;
		newContent += script;
		newContent += postfix;

		app.translator.rewriteSnippet (newContent, module.localize("AGL Script Change"));
	}
}


//---------------------------------------------------------
// inspectTranslation -  inspect the translated tag
//
// Description:
//   Use it to fill in the controls of the inspector with
//   current values.

function inspectTranslation (inspector, source) 
{
	var pattern		= /<!--\s*([\s\S]*)\n\/\/\s*-->/im;
	var script	= "";
	var match	= pattern.exec (source);

	try
	{
		if (match[1] != null && match[1] != undefined) 
			script = match[1];
	}
	catch( exp )
	{
		writeln("BUG");
	}
	
	inspector.content.value = script;
}


//---------------------------------------------------------
// translate -  implement the document translation
//
// Description:
//   Called when the translator detects a match
//   with its defined file types and one of its regular
//   expressions.

function translate (documentURL, siteURL, source) 
{
	var pattern		= /<script.*type=\"text\/aglscript\".*[^>]*>[\s\S]*<!--\s*([\s\S]*)\n\/\/\s*-->\s*<\/script>/gim;
	var translation	= "";
	var	idx;

	while (true)
		{
		var match = pattern.exec (source);
		if (match == null)
			{
			break;
			}
					
		idx			= match.index;
		subMatch	= match [1];
		match		= match [0];

		try
			{
			translation = eval(subMatch);
			}
		catch (e)
			{
			translation = e.description;
			}

		app.translator.translateSnippet (idx, match.length, translation);
		}
}


//--------------------------------------------------------------------
// HELPER FUNCTIONS
//--------------------------------------------------------------------
//-->
</script>
		<hr>
		<p><b>User Interface Tags:</b></p>
		<p><b>Image</b> Define images here. These are referenced by the picture attribute of the 
		jsxpaletteentry and jsxpalettegroup tags.</p>
		<p>The little icon displayed in the Objects palette tab:</p>
		<img src="Images/script_groupicon.gif" name="paletteGroupIcon">
		<p>The icon to be displayed in the Objects palette:</p>
		<img src="Images/AGLscript.gif" name="paletteIcon">
		<img src="Images/AGLscript_hilite.gif" name="hilitePaletteIcon">

		<p><b>Translator</b> Define a translator that imitates server side replacements.</p>
		<jsxtranslator classid="aglClass" direction="oneway">
			<param name ="extension" value="html">
			<param name ="extension" value="htm">
			<param name ="expression" value="aglscript">
		</jsxtranslator>

		<p><b>Inspectors</b> Define Inspectors for custom tags</p>
		<jsxinspector name="inspector" title="AGL Script Inspector" classid="aglClass" width="215" height="164">
			<table border="0" cellspacing="0" cellpadding="0" cool width="215" height="164" gridx="5" gridy="5" usegridx="yes" usegridy="yes" showgridx="yes" showgridy="yes">
				<tr height="3">
					<td width="5" height="163" rowspan="4"></td>
					<td width="124" height="5" rowspan="2"></td>
					<td width="85" height="3"></td>
					<td width="1" height="3"><spacer type="block" width="1" height="3"></td>
				</tr>
				<tr height="2">
					<td width="85" height="22" rowspan="2" valign="top" align="left" xpos="129">
						<jsxcontrol halign="right" name="update" type="button" value="Update" posx="129" posy="3" width="80" height="19">
					</td>
					<td width="1" height="2"><spacer type="block" width="1" height="2"></td>
				</tr>
				<tr height="20">
					<td width="124" height="20" valign="top" align="left" xpos="5">
						<jsxcontrol name="static" type="static" value="Script:" posx="5" posy="5" width="38" height="16">
					</td>
					<td width="1" height="20"><spacer type="block" width="1" height="20"></td>
				</tr>
				<tr height="138">
					<td width="209" height="138" colspan="2" valign="top" align="left" xpos="5">
						<jsxcontrol halign="scale" type="editarea" name="content" posx="5" posy="25" valign="scale" value="a=&quot;The evaluation value of this script will be the translation&quot;; a;" width="205" height="135">
					</td>
					<td width="1" height="138"><spacer type="block" width="1" height="138"></td>
				</tr>
				<tr height="1" cntrlrow>
					<td width="5" height="1"><spacer type="block" width="5" height="1"></td>
					<td width="124" height="1"><spacer type="block" width="124" height="1"></td>
					<td width="85" height="1"><spacer type="block" width="85" height="1"></td>
					<td width="1" height="1"></td>
				</tr>
			</table>
		</jsxinspector>

		
		<p><b>Palette Group</b> Define a new tab for the Object Palette, or add to an existing tab.</p>
		<jsxpalettegroup name="TRANS" display="Dynamic Script Tags" taborder="3000" picture="paletteGroupIcon" order="3000">
			<jsxpaletteentry display="AGL Script" classid="aglClass" picture="paletteIcon" hilitepicture="hilitePaletteIcon">
				<script type="text/aglscript"><!--
				a = "The value of this script is the content!"; a;
// --></script>
			</jsxpaletteentry>
		</jsxpalettegroup>

		<p><b>JSXLocale</b> Specify localized versions of strings used in menu items, dialogs, alerts, etc.</p>
		<jsxlocale src="locale.html">
		</jsxlocale>
		<p></p>
	</body>

</html>

