PageSourceSearch

https://africanfossils.org/sites/all/themes/fossil/js/AC_QuickTime.js?t079dz

js africanfossils.org collected 2026-10-02 05:31:13 UTC 10,750 bytes, 362 lines download raw bytes

1/*
2
3File: AC_QuickTime.js
4
5Abstract: This file contains functions to generate OBJECT and EMBED tags for QuickTime content.
6
7Version: <1.2>
8
9Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
10Computer, Inc. ("Apple") in consideration of your agreement to the
11following terms, and your use, installation, modification or
12redistribution of this Apple software constitutes acceptance of these
13terms.  If you do not agree with these terms, please do not use,
14install, modify or redistribute this Apple software.
15
16In consideration of your agreement to abide by the following terms, and
17subject to these terms, Apple grants you a personal, non-exclusive
18license, under Apple's copyrights in this original Apple software (the
19"Apple Software"), to use, reproduce, modify and redistribute the Apple
20Software, with or without modifications, in source and/or binary forms;
21provided that if you redistribute the Apple Software in its entirety and
22without modifications, you must retain this notice and the following
23text and disclaimers in all such redistributions of the Apple Software. 
24Neither the name, trademarks, service marks or logos of Apple Computer,
25Inc. may be used to endorse or promote products derived from the Apple
26Software without specific prior written permission from Apple.  Except
27as expressly stated in this notice, no other rights or licenses, express
28or implied, are granted by Apple herein, including but not limited to
29any patent rights that may be infringed by your derivative works or by
30other works in which the Apple Software may be incorporated.
31
32The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
33MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
34THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
35FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
36OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
37
38IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
39OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
40SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
41INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
42MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
43AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
44STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
45POSSIBILITY OF SUCH DAMAGE.
46
47Copyright © 2006-2007 Apple Computer, Inc., All Rights Reserved
48
49*/ 
50
51/*
52 * This file contains functions to generate OBJECT and EMBED tags for QuickTime content. 
53 */
54
55/************** LOCALIZABLE GLOBAL VARIABLES ****************/
56
57var gArgCountErr =	'The "%%" function requires an even number of arguments.'
58				+	'\nArguments should be in the form "atttributeName", "attributeValue", ...';
59
60/******************** END LOCALIZABLE **********************/
61
62var gTagAttrs				= null;
63var gQTGeneratorVersion		= 1.2;
64var gQTBehaviorID			= "qt_event_source";
65var gQTEventsEnabled		= false;
66
67function AC_QuickTimeVersion()	{ return gQTGeneratorVersion; }
68
69function _QTComplain(callingFcnName, errMsg)
70{
71    errMsg = errMsg.replace("%%", callingFcnName);
72	alert(errMsg);
73}
74
75function _QTIsMSIE()
76{
77    var ua = navigator.userAgent.toLowerCase();
78	var msie = /msie/.test(ua) && !/opera/.test(ua);
79
80	return msie;
81}
82
83
84function _QTGenerateBehavior()
85{
86	return objTag = '<!--[if IE]>'
87				 + '<object id="' + gQTBehaviorID + '" classid="clsid:CB927D12-4FF7-4a9e-A169-56E4B8A75598"></object>'
88				 + '<![endif]-->';
89}
90
91function _QTPageHasBehaviorObject(callingFcnName, args)
92{
93	var haveBehavior = false;
94	var objects = document.getElementsByTagName('object');
95	
96	for ( var ndx = 0, obj; obj = objects[ndx]; ndx++ )
97	{
98		if ( obj.getAttribute('classid') == "clsid:CB927D12-4FF7-4a9e-A169-56E4B8A75598" )
99		{
100			if ( obj.getAttribute('id') == gQTBehaviorID )
101				haveBehavior = false;
102			break;
103		}
104	}
105
106	return haveBehavior;
107}
108
109
110function _QTShouldInsertBehavior()
111{
112	var		shouldDo = false;
113
114	if ( gQTEventsEnabled && _QTIsMSIE() && !_QTPageHasBehaviorObject() )
115		shouldDo = true;
116	
117	return shouldDo;
118}
119
120
121function _QTAddAttribute(prefix, slotName, tagName)
122{
123	var		value;
124
125	value = gTagAttrs[prefix + slotName];
126	if ( null == value )
127		value = gTagAttrs[slotName];
128
129	if ( null != value )
130	{
131		if ( 0 == slotName.indexOf(prefix) && (null == tagName) )
132			tagName = slotName.substring(prefix.length); 
133		if ( null == tagName ) 
134			tagName = slotName;
135		return ' ' + tagName + '="' + value + '"';
136	}
137	else
138		return "";
139}
140
141function _QTAddObjectAttr(slotName, tagName)
142{
143	// don't bother if it is only for the embed tag
144	if ( 0 == slotName.indexOf("emb#") )
145		return "";
146
147	if ( 0 == slotName.indexOf("obj#") && (null == tagName) )
148		tagName = slotName.substring(4); 
149
150	return _QTAddAttribute("obj#", slotName, tagName);
151}
152
153function _QTAddEmbedAttr(slotName, tagName)
154{
155	// don't bother if it is only for the object tag
156	if ( 0 == slotName.indexOf("obj#") )
157		return "";
158
159	if ( 0 == slotName.indexOf("emb#") && (null == tagName) )
160		tagName = slotName.substring(4); 
161
162	return _QTAddAttribute("emb#", slotName, tagName);
163}
164
165
166function _QTAddObjectParam(slotName, generateXHTML)
167{
168	var		paramValue;
169	var		paramStr = "";
170	var		endTagChar = (generateXHTML) ? ' />' : '>';
171
172	if ( -1 == slotName.indexOf("emb#") )
173	{
174		// look for the OBJECT-only param first. if there is none, look for a generic one
175		paramValue = gTagAttrs["obj#" + slotName];
176		if ( null == paramValue )
177			paramValue = gTagAttrs[slotName];
178
179		if ( 0 == slotName.indexOf("obj#") )
180			slotName = slotName.substring(4); 
181	
182		if ( null != paramValue )
183			paramStr = '<param name="' + slotName + '" value="' + paramValue + '"' + endTagChar;
184	}
185
186	return paramStr;
187}
188
189function _QTDeleteTagAttrs()
190{
191	for ( var ndx = 0; ndx < arguments.length; ndx++ )
192	{
193		var attrName = arguments[ndx];
194		delete gTagAttrs[attrName];
195		delete gTagAttrs["emb#" + attrName];
196		delete gTagAttrs["obj#" + attrName];
197	}
198}
199
200
201// generate an embed and object tag, return as a string
202function _QTGenerate(callingFcnName, generateXHTML, args)
203{
204	// is the number of optional arguments even?
205	if ( args.length < 4 || (0 != (args.length % 2)) )
206	{
207		_QTComplain(callingFcnName, gArgCountErr);
208		return "";
209	}
210	
211	// allocate an array, fill in the required attributes with fixed place params and defaults
212	gTagAttrs = new Object();
213	gTagAttrs["src"] = args[0];
214	gTagAttrs["width"] = args[1];
215	gTagAttrs["height"] = args[2];
216	gTagAttrs["classid"] = "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";
217		//Impportant note: It is recommended that you use this exact classid in order to ensure a seamless experience for all viewers
218	gTagAttrs["pluginspage"] = "http://www.apple.com/quicktime/download/";
219
220	// set up codebase attribute with specified or default version before parsing args so
221	//  anything passed in will override
222	var activexVers = args[3]
223	if ( (null == activexVers) || ("" == activexVers) )
224		activexVers = "7,3,0,0";
225	gTagAttrs["codebase"] = "http://www.apple.com/qtactivex/qtplugin.cab#version=" + activexVers;
226
227	var	attrName,
228		attrValue;
229
230	// add all of the optional attributes to the array
231	for ( var ndx = 4; ndx < args.length; ndx += 2)
232	{
233		attrName = args[ndx].toLowerCase();
234		attrValue = args[ndx + 1];
235
236		gTagAttrs[attrName] = attrValue;
237
238		if ( ("postdomevents" == attrName) && (attrValue.toLowerCase() != "false") )
239		{
240			gQTEventsEnabled = true;
241			if ( _QTIsMSIE() )
242				gTagAttrs["obj#style"] = "behavior:url(#" + gQTBehaviorID + ")";
243		}
244	}
245
246	// init both tags with the required and "special" attributes
247	var objTag =  '<object '
248					+ _QTAddObjectAttr("classid")
249					+ _QTAddObjectAttr("width")
250					+ _QTAddObjectAttr("height")
251					+ _QTAddObjectAttr("codebase")
252					+ _QTAddObjectAttr("name")
253					+ _QTAddObjectAttr("id")
254					+ _QTAddObjectAttr("tabindex")
255					+ _QTAddObjectAttr("hspace")
256					+ _QTAddObjectAttr("vspace")
257					+ _QTAddObjectAttr("border")
258					+ _QTAddObjectAttr("align")
259					+ _QTAddObjectAttr("class")
260					+ _QTAddObjectAttr("title")
261					+ _QTAddObjectAttr("accesskey")
262					+ _QTAddObjectAttr("noexternaldata")
263					+ _QTAddObjectAttr("obj#style")
264					+ '>'
265					+ _QTAddObjectParam("src", generateXHTML);
266	var embedTag = '<embed '
267					+ _QTAddEmbedAttr("src")
268					+ _QTAddEmbedAttr("width")
269					+ _QTAddEmbedAttr("height")
270					+ _QTAddEmbedAttr("pluginspage")
271					+ _QTAddEmbedAttr("name")
272					+ _QTAddEmbedAttr("id")
273					+ _QTAddEmbedAttr("align")
274					+ _QTAddEmbedAttr("tabindex");
275
276	// delete the attributes/params we have already added
277	_QTDeleteTagAttrs("src","width","height","pluginspage","classid","codebase","name","tabindex",
278					"hspace","vspace","border","align","noexternaldata","class","title","accesskey","id","style");
279
280	// and finally, add all of the remaining attributes to the embed and object
281	for ( var attrName in gTagAttrs )
282	{
283		attrValue = gTagAttrs[attrName];
284		if ( null != attrValue )
285		{
286			embedTag += _QTAddEmbedAttr(attrName);
287			objTag += _QTAddObjectParam(attrName, generateXHTML);
288		}
289	} 
290
291	// end both tags, we're done
292	return objTag + embedTag + '></em' + 'bed></ob' + 'ject' + '>';
293}
294
295
296// return the object/embed as a string
297function QT_GenerateOBJECTText()
298{
299	var	txt = _QTGenerate("QT_GenerateOBJECTText", false, arguments);
300	if ( _QTShouldInsertBehavior() )
301		txt = _QTGenerateBehavior() + txt;
302	return txt;
303}
304
305function QT_GenerateOBJECTText_XHTML()
306{
307	var	txt = _QTGenerate("QT_GenerateOBJECTText_XHTML", true, arguments);
308	if ( _QTShouldInsertBehavior() )
309		txt = _QTGenerateBehavior() + txt;
310	return txt;
311}
312
313function QT_WriteOBJECT()
314{
315	var	txt = _QTGenerate("QT_WriteOBJECT", false, arguments);
316	if ( _QTShouldInsertBehavior() )
317		document.writeln(_QTGenerateBehavior());
318	document.writeln(txt);
319}
320
321function QT_WriteOBJECT_XHTML()
322{
323	var	txt = _QTGenerate("QT_WriteOBJECT_XHTML", true, arguments);
324	if ( _QTShouldInsertBehavior() )
325		document.writeln(_QTGenerateBehavior());
326	document.writeln(txt);
327}
328
329function QT_GenerateBehaviorOBJECT()
330{
331	return _QTGenerateBehavior();
332}
333
334function QT_ReplaceElementContents()
335{
336	var element = arguments[0];
337	var args = [];
338
339	// copy all other arguments we want to pass through to the fcn
340	for ( var ndx = 1; ndx < arguments.length; ndx++ )
341		args.push(arguments[ndx]);
342
343	var	txt = _QTGenerate("QT_ReplaceElementContents", false, args);
344	if ( txt.length > 0 )
345		element.innerHTML = txt;
346}
347
348
349function QT_ReplaceElementContents_XHTML()
350{
351	var element = arguments[0];
352	var args = [];
353
354	// copy all other arguments we want to pass through to the fcn
355	for ( var ndx = 1; ndx < arguments.length; ndx++ )
356		args.push(arguments[ndx]);
357
358	var	txt = _QTGenerate("QT_ReplaceElementContents_XHTML", true, args
358);
359	if ( txt.length > 0 )
360		element.innerHTML = txt;
361}
362

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.