1
ļ»æ///////////////////////////////////////////////////////////////////////////////
3
// Silverlight.js version 2.0.30523.6
5
// This file is provided by Microsoft as a helper file for websites that
6
// incorporate Silverlight Objects. This file is provided under the Microsoft
7
// Public License available at
8
// http://code.msdn.microsoft.com/silverlightjs/Project/License.aspx.
9
// You may not use or distribute this file or the code in this file except as
10
// expressly permitted under that license.
12
// Copyright (c) Microsoft Corporation. All rights reserved.
14
///////////////////////////////////////////////////////////////////////////////
16
if (!window.Silverlight)
18
window.Silverlight = { };
21
//////////////////////////////////////////////////////////////////
25
// Counter of globalized event handlers
27
//////////////////////////////////////////////////////////////////
28
Silverlight._silverlightCount = 0;
30
//////////////////////////////////////////////////////////////////
34
// Prefix for fwlink URL's
36
//////////////////////////////////////////////////////////////////
37
Silverlight.fwlinkRoot='http://go2.microsoft.com/fwlink/?LinkID=';
39
//////////////////////////////////////////////////////////////////
43
// Called by Silverlight.GetSilverlight to notify the page that a user
44
// has requested the Silverlight installer
46
//////////////////////////////////////////////////////////////////
47
Silverlight.onGetSilverlight = null;
49
//////////////////////////////////////////////////////////////////
51
// onSilverlightInstalled:
53
// Called by Silverlight.WaitForInstallCompletion when the page detects
54
// that Silverlight has been installed. The event handler is not called
55
// in upgrade scenarios.
57
//////////////////////////////////////////////////////////////////
58
Silverlight.onSilverlightInstalled = function () {window.location.reload(false);};
60
//////////////////////////////////////////////////////////////////
64
// Checks to see if the correct version is installed
66
//////////////////////////////////////////////////////////////////
67
Silverlight.isInstalled = function(version)
69
var isVersionSupported=false;
78
control = new ActiveXObject('AgControl.AgControl');
79
if ( version == null )
81
isVersionSupported = true;
83
else if ( control.IsVersionSupported(version) )
85
isVersionSupported = true;
91
var plugin = navigator.plugins["Silverlight Plug-In"] ;
94
if ( version === null )
96
isVersionSupported = true;
100
var actualVer = plugin.description;
101
if ( actualVer === "1.0.30226.2")
102
actualVer = "2.0.30226.2";
103
var actualVerArray =actualVer.split(".");
104
while ( actualVerArray.length > 3)
106
actualVerArray.pop();
108
while ( actualVerArray.length < 4)
110
actualVerArray.push(0);
112
var reqVerArray = version.split(".");
113
while ( reqVerArray.length > 4)
118
var requiredVersionPart ;
119
var actualVersionPart
125
requiredVersionPart = parseInt(reqVerArray[index]);
126
actualVersionPart = parseInt(actualVerArray[index]);
129
while (index < reqVerArray.length && requiredVersionPart === actualVersionPart);
131
if ( requiredVersionPart <= actualVersionPart && !isNaN(requiredVersionPart) )
133
isVersionSupported = true;
141
isVersionSupported = false;
145
document.body.removeChild(container);
148
return isVersionSupported;
150
//////////////////////////////////////////////////////////////////
152
// WaitForInstallCompletion:
154
// Occasionally checks for Silverlight installation status. If it
155
// detects that Silverlight has been installed then it calls
156
// Silverlight.onSilverlightInstalled();. This is only supported
157
// if Silverlight was not previously installed on this computer.
159
//////////////////////////////////////////////////////////////////
160
Silverlight.WaitForInstallCompletion = function()
162
if ( ! Silverlight.isBrowserRestartRequired && Silverlight.onSilverlightInstalled )
166
navigator.plugins.refresh();
171
if ( Silverlight.isInstalled(null) )
173
Silverlight.onSilverlightInstalled();
177
setTimeout(Silverlight.WaitForInstallCompletion, 3000);
181
//////////////////////////////////////////////////////////////////
185
// Performs startup tasks
186
//////////////////////////////////////////////////////////////////
187
Silverlight.__startup = function()
189
Silverlight.isBrowserRestartRequired = Silverlight.isInstalled(null);
190
if ( !Silverlight.isBrowserRestartRequired)
192
Silverlight.WaitForInstallCompletion();
194
if (window.removeEventListener) {
195
window.removeEventListener('load', Silverlight.__startup , false);
198
window.detachEvent('onload', Silverlight.__startup );
202
if (window.addEventListener)
204
window.addEventListener('load', Silverlight.__startup , false);
208
window.attachEvent('onload', Silverlight.__startup );
211
///////////////////////////////////////////////////////////////////////////////
214
// Inserts a Silverlight <object> tag or installation experience into the HTML
215
// DOM based on the current installed state of Silverlight.
217
/////////////////////////////////////////////////////////////////////////////////
219
Silverlight.createObject = function(source, parentElement, id, properties, events, initParams, userContext)
221
var slPluginHelper = new Object();
222
var slProperties = properties;
223
var slEvents = events;
225
slPluginHelper.version = slProperties.version;
226
slProperties.source = source;
227
slPluginHelper.alt = slProperties.alt;
229
//rename properties to their tag property names. For bacwards compatibility
230
//with Silverlight.js version 1.0
232
slProperties.initParams = initParams;
233
if ( slProperties.isWindowless && !slProperties.windowless)
234
slProperties.windowless = slProperties.isWindowless;
235
if ( slProperties.framerate && !slProperties.maxFramerate)
236
slProperties.maxFramerate = slProperties.framerate;
237
if ( id && !slProperties.id)
238
slProperties.id = id;
240
// remove elements which are not to be added to the instantiation tag
241
delete slProperties.ignoreBrowserVer;
242
delete slProperties.inplaceInstallPrompt;
243
delete slProperties.version;
244
delete slProperties.isWindowless;
245
delete slProperties.framerate;
246
delete slProperties.data;
247
delete slProperties.src;
248
delete slProperties.alt;
251
// detect that the correct version of Silverlight is installed, else display install
253
if (Silverlight.isInstalled(slPluginHelper.version))
255
//move unknown events to the slProperties array
256
for (var name in slEvents)
260
if ( name == "onLoad" && typeof slEvents[name] == "function" && slEvents[name].length != 1 )
262
var onLoadHandler = slEvents[name];
263
slEvents[name]=function (sender){ return onLoadHandler(document.getElementById(id), userContext, sender)};
265
var handlerName = Silverlight.__getHandlerName(slEvents[name]);
266
if ( handlerName != null )
268
slProperties[name] = handlerName;
269
slEvents[name] = null;
273
throw "typeof events."+name+" must be 'function' or 'string'";
277
slPluginHTML = Silverlight.buildHTML(slProperties);
279
//The control could not be instantiated. Show the installation prompt
282
slPluginHTML = Silverlight.buildPromptHTML(slPluginHelper);
285
// insert or return the HTML
288
parentElement.innerHTML = slPluginHTML;
297
///////////////////////////////////////////////////////////////////////////////
301
// create HTML that instantiates the control
303
///////////////////////////////////////////////////////////////////////////////
304
Silverlight.buildHTML = function( slProperties)
306
var htmlBuilder = [];
308
htmlBuilder.push('<object type=\"application/x-silverlight\" data="data:application/x-silverlight,"');
309
if ( slProperties.id != null )
311
htmlBuilder.push(' id="' + slProperties.id + '"');
313
if ( slProperties.width != null )
315
htmlBuilder.push(' width="' + slProperties.width+ '"');
317
if ( slProperties.height != null )
319
htmlBuilder.push(' height="' + slProperties.height + '"');
321
htmlBuilder.push(' >');
323
delete slProperties.id;
324
delete slProperties.width;
325
delete slProperties.height;
327
for (var name in slProperties)
329
if (slProperties[name])
331
htmlBuilder.push('<param name="'+Silverlight.HtmlAttributeEncode(name)+'" value="'+Silverlight.HtmlAttributeEncode(slProperties[name])+'" />');
334
htmlBuilder.push('<\/object>');
335
return htmlBuilder.join('');
340
//////////////////////////////////////////////////////////////////
344
// takes a single parameter of all createObject
345
// parameters enclosed in {}
347
//////////////////////////////////////////////////////////////////
349
Silverlight.createObjectEx = function(params)
351
var parameters = params;
352
var html = Silverlight.createObject(parameters.source, parameters.parentElement, parameters.id, parameters.properties, parameters.events, parameters.initParams, parameters.context);
353
if (parameters.parentElement == null)
359
///////////////////////////////////////////////////////////////////////////////////////////////
363
// Builds the HTML to prompt the user to download and install Silverlight
365
///////////////////////////////////////////////////////////////////////////////////////////////
366
Silverlight.buildPromptHTML = function(slPluginHelper)
368
var slPluginHTML = "";
369
var urlRoot = Silverlight.fwlinkRoot;
370
var shortVer = slPluginHelper.version ;
371
if ( slPluginHelper.alt )
373
slPluginHTML = slPluginHelper.alt;
381
slPluginHTML = "<a href='javascript:Silverlight.getSilverlight(\"{1}\");' style='text-decoration: none;'><img src='{2}' alt='Get Microsoft Silverlight' style='border-style: none'/></a>";
382
slPluginHTML = slPluginHTML.replace('{1}', shortVer );
383
slPluginHTML = slPluginHTML.replace('{2}', urlRoot + '108181');
389
///////////////////////////////////////////////////////////////////////////////////////////////
393
// Navigates the browser to the appropriate Silverlight installer
395
///////////////////////////////////////////////////////////////////////////////////////////////
396
Silverlight.getSilverlight = function(version)
398
if (Silverlight.onGetSilverlight )
400
Silverlight.onGetSilverlight();
404
var reqVerArray = String(version).split(".");
405
if (reqVerArray.length > 1)
407
var majorNum = parseInt(reqVerArray[0] );
408
if ( isNaN(majorNum) || majorNum < 2 )
414
shortVer = reqVerArray[0]+'.'+reqVerArray[1];
420
if (shortVer.match(/^\d+\056\d+$/) )
422
verArg = "&v="+shortVer;
425
Silverlight.followFWLink("114576" + verArg);
429
///////////////////////////////////////////////////////////////////////////////////////////////
433
// Navigates to a url based on fwlinkid
435
///////////////////////////////////////////////////////////////////////////////////////////////
436
Silverlight.followFWLink = function(linkid)
438
top.location=Silverlight.fwlinkRoot+String(linkid);
441
///////////////////////////////////////////////////////////////////////////////////////////////
443
// HtmlAttributeEncode:
445
// Encodes special characters in input strings as charcodes
447
///////////////////////////////////////////////////////////////////////////////////////////////
448
Silverlight.HtmlAttributeEncode = function( strInput )
458
for(var cnt = 0; cnt < strInput.length; cnt++)
460
c = strInput.charCodeAt(cnt);
462
if (( ( c > 96 ) && ( c < 123 ) ) ||
463
( ( c > 64 ) && ( c < 91 ) ) ||
464
( ( c > 43 ) && ( c < 58 ) && (c!=47)) ||
467
retVal = retVal + String.fromCharCode(c);
471
retVal = retVal + '&#' + c + ';';
477
///////////////////////////////////////////////////////////////////////////////
479
// default_error_handler:
481
// Default error handling function
483
///////////////////////////////////////////////////////////////////////////////
485
Silverlight.default_error_handler = function (sender, args)
488
var errorType = args.ErrorType;
490
iErrorCode = args.ErrorCode;
492
var errMsg = "\nSilverlight error message \n" ;
494
errMsg += "ErrorCode: "+ iErrorCode + "\n";
497
errMsg += "ErrorType: " + errorType + " \n";
498
errMsg += "Message: " + args.ErrorMessage + " \n";
500
if (errorType == "ParserError")
502
errMsg += "XamlFile: " + args.xamlFile + " \n";
503
errMsg += "Line: " + args.lineNumber + " \n";
504
errMsg += "Position: " + args.charPosition + " \n";
506
else if (errorType == "RuntimeError")
508
if (args.lineNumber != 0)
510
errMsg += "Line: " + args.lineNumber + " \n";
511
errMsg += "Position: " + args.charPosition + " \n";
513
errMsg += "MethodName: " + args.methodName + " \n";
518
///////////////////////////////////////////////////////////////////////////////////////////////
522
// Releases event handler resources when the page is unloaded
524
///////////////////////////////////////////////////////////////////////////////////////////////
525
Silverlight.__cleanup = function ()
527
for (var i = Silverlight._silverlightCount - 1; i >= 0; i--) {
528
window['__slEvent' + i] = null;
530
Silverlight._silverlightCount = 0;
531
if (window.removeEventListener) {
532
window.removeEventListener('unload', Silverlight.__cleanup , false);
535
window.detachEvent('onunload', Silverlight.__cleanup );
539
///////////////////////////////////////////////////////////////////////////////////////////////
543
// Generates named event handlers for delegates.
545
///////////////////////////////////////////////////////////////////////////////////////////////
546
Silverlight.__getHandlerName = function (handler)
548
var handlerName = "";
549
if ( typeof handler == "string")
551
handlerName = handler;
553
else if ( typeof handler == "function" )
555
if (Silverlight._silverlightCount == 0)
557
if (window.addEventListener)
559
window.addEventListener('onunload', Silverlight.__cleanup , false);
563
window.attachEvent('onunload', Silverlight.__cleanup );
566
var count = Silverlight._silverlightCount++;
567
handlerName = "__slEvent"+count;
569
window[handlerName]=handler;
b'\\ No newline at end of file'