Type.registerNamespace("Microsoft.UpdateServices.Catalog");
Microsoft.UpdateServices.Catalog.Exception = function(sMessage, iCode)
{
Microsoft.UpdateServices.Catalog.Exception.initializeBase(this);
this.message = sMessage;
this.code = iCode;
this.get_code = function()
{
return this._code;
}
}
Microsoft.UpdateServices.Catalog.Exception.registerClass("Microsoft.UpdateServices.Catalog.Exception");
Microsoft.UpdateServices.Catalog.UpdateException = function(sMessage, iCode)
{
Microsoft.UpdateServices.Catalog.UpdateException.initializeBase(this, arguments);
}
Microsoft.UpdateServices.Catalog.UpdateException.registerClass("Microsoft.UpdateServices.Catalog.UpdateException", Microsoft.UpdateServices.Catalog.Exception);
Microsoft.UpdateServices.Catalog.ArgumentException = function(sMessage, iCode)
{
Microsoft.UpdateServices.Catalog.ArgumentException.initializeBase(this);
}
Microsoft.UpdateServices.Catalog.ArgumentException.registerClass("Microsoft.UpdateServices.Catalog.ArgumentException", Microsoft.UpdateServices.Catalog.Exception);
Microsoft.UpdateServices.Catalog.Update = function(uidInfo)
{
this.size = 0;
this.languages = "";
this.uidInfo = uidInfo;
var firstSeparatorIndex = this.uidInfo.indexOf(Microsoft.UpdateServices.Catalog.Constants.UpdateInfoSeparator);
if(firstSeparatorIndex != -1)
{
this.updateID = this.uidInfo.substr(0, firstSeparatorIndex);
var sizelanguages = this.uidInfo.substring(firstSeparatorIndex + 1);
var secondSeparatorIndex = sizelanguages.indexOf(Microsoft.UpdateServices.Catalog.Constants.UpdateInfoSeparator);
if(secondSeparatorIndex != -1)
{
this.size = parseInt(sizelanguages.substr(0, secondSeparatorIndex));
if(isNaN(this.size ))
{
this.size = 0 ;
}
this.languages = sizelanguages.substring(secondSeparatorIndex + 1);
}
}
else
{
this.updateID = uidInfo;
}
this.get_uid = function()
{
return this.updateID;
}
this.get_size = function()
{
return this.size;
}
this.get_languages = function()
{
return this.languages;
}
this.getSerializationData = function()
{
return this.uidInfo;
}
}
Microsoft.UpdateServices.Catalog.Update.VERSION = 1;
Microsoft.UpdateServices.Catalog.Update.fromSerializationData = function(serializedData, version)
{
switch(version)
{
case 1 :
return constructUpdateFromVersion1(serializedData);
default:
throw new Microsoft.UpdateServices.Catalog.UpdateException("Version in unknown.", Microsoft.UpdateServices.Catalog.Constants.ErrorPersistenceUpdateVersionUnknown);
}
function constructUpdateFromVersion1(serializedData)
{
return new Microsoft.UpdateServices.Catalog.Update(serializedData);
}
}
Microsoft.UpdateServices.Catalog.Update.registerClass("Microsoft.UpdateServices.Catalog.Update");
Type.registerNamespace("Microsoft.UpdateServices.Catalog.UI");
Microsoft.UpdateServices.Catalog.UI.ClientControl = function(controlElement, version)
{
var ReadyStateComplete = 4;
this._version = version;
this._ctrlElement = controlElement;
this._readyStateDelegate = null;
this._redirect = true;
Microsoft.UpdateServices.Catalog.UI.ClientControl.initializeBase(this);
this.initialize = function()
{
Microsoft.UpdateServices.Catalog.UI.ClientControl.callBaseMethod(this, 'initialize');
if(window.location.href.indexOf(Microsoft.UpdateServices.Catalog.Constants.PageInstall) == -1)
{
this._redirect = false;
}
var cpuClass = navigator.cpuClass.toLowerCase();
if(Microsoft.UpdateServices.Catalog.Constants.x86 == cpuClass || Microsoft.UpdateServices.Catalog.Constants.x64 ==cpuClass)
{
var now = new Date();
var codeBase = "ClientControl/" + "en/" + cpuClass + "/MuCatalogWebControl.cab?" + now.getTime() + "#version=" + this._version;
this._ctrlElement.outerHTML = "<object style='display: none;' id='MuCatWebCtl' classid='CLSID:5AE58FCF-6F6A-49B2-B064-02492C66E3F4' codebase='" + codeBase + "'></object>";
this._ctrlElement = $get('MuCatWebCtl');
this._readyStateDelegate = Function.createDelegate(this, this.handleReadyState);
this._ctrlElement.attachEvent('onreadystatechange', this._readyStateDelegate);
}
}
this.dispose = function()
{
if(null != this._readyStateDelegate)
{
this._ctrlElement.detachEvent('onreadystatechange', this._readyStateDelegate);
}
Microsoft.UpdateServices.Catalog.UI.ClientControl.callBaseMethod(this, 'dispose');
}
this.handleReadyState = function()
{
if(ReadyStateComplete == this._ctrlElement.readyState && this.isInstalled() && true == this._redirect)
{
var qs=window.location.search.toLowerCase();
var qsObj = new Microsoft.UpdateServices.Catalog.QueryString(qs);
var referringPage = qsObj.getValue(Microsoft.UpdateServices.Catalog.Constants.QueryStringReferringPage);
if(referringPage && (referringPage.toLowerCase() == Microsoft.UpdateServices.Catalog.Constants.PageSearch.toLowerCase()
||referringPage.toLowerCase()== Microsoft.UpdateServices.Catalog.Constants.PageScopedView.toLowerCase()
|| referringPage.toLowerCase()== Microsoft.UpdateServices.Catalog.Constants.PageHome.toLowerCase() ))
{
var qs = qsObj.removeKey(Microsoft.UpdateServices.Catalog.Constants.QueryStringReferringPage);
var redirectURL = referringPage;
if(qs.length > 1)
{
redirectURL = redirectURL + '?' + qs;
}
window.location.href = redirectURL;
}
else
{
window.location.href = Microsoft.UpdateServices.Catalog.Constants.PageHome + qs;
}
}
}
this.isInstalled = function()
{
return (null != this._ctrlElement.object);
}
this.getObject = function()
{
return this._ctrlElement.object;
}
}
Microsoft.UpdateServices.Catalog.UI.ClientControl.registerClass("Microsoft.UpdateServices.Catalog.UI.ClientControl", Sys.Component);
Microsoft.UpdateServices.Catalog.UI.ClientValidator = function(catalogControl)
{
this._catalogControl = catalogControl;
Microsoft.UpdateServices.Catalog.UI.ClientValidator.initializeBase(this);
this.checkWsusAPI = function(sku)
{
var control;
var wsusAPIpresent;
try
{
control = this._catalogControl.object;
wsusAPIpresent = control.IsWsusApiPresent();
}
catch(e)
{
window.location.href = Microsoft.UpdateServices.Catalog.Constants.PageError + "?id=" + e.number;
return false;
}
if(sku != Microsoft.UpdateServices.Catalog.Constants.EmptyString)
{
if(
!(
sku == Microsoft.UpdateServices.Catalog.Constants.SkuWsus ||
sku == Microsoft.UpdateServices.Catalog.Constants.SkuSms ||
sku == Microsoft.UpdateServices.Catalog.Constants.SkuSce
)
||
!(wsusAPIpresent)
)
{
window.location.href = Microsoft.UpdateServices.Catalog.Constants.PageError + "?id=" + Microsoft.UpdateServices.Catalog.Constants.ErrorWsusImportApiNotPresent;
return false;
}
}
return true;
}
}
Microsoft.UpdateServices.Catalog.UI.ClientValidator.registerClass("Microsoft.UpdateServices.Catalog.UI.ClientValidator", Sys.Component);
Microsoft.UpdateServices.Catalog.QueryString = function(queryString)
{
if(queryString.length > 1)
{
this._queryString = queryString.substring(1, queryString.length);
}
else
{
this._queryString = null;
}
this._keyValuePairs = new Array();
if(this._queryString != null)
{
for(var i=0; i < this._queryString.split("&").length; i++)
{
this._keyValuePairs[i] = this._queryString.split("&")[i];
}
}
this.getValue = function(key)
{
for(var j=0; j < this._keyValuePairs.length; j++)
{
if(this._keyValuePairs[j].split("=")[0] == key)
return this._keyValuePairs[j].split("=")[1];
}
return false;
}
this.removeKey = function(key)
{
var keyIndex=-1;
for(var i=0; i < this._keyValuePairs.length; i++)
{
if(this._keyValuePairs[i].split("=")[0] == key)
{
keyIndex=i;
break;
}
}
this._keyValuePairs.splice(keyIndex,1);
this._reBuildQS();
return(this._queryString);
}
this._reBuildQS = function()
{
var queryStringNew = '';
for(var j=0; j < this._keyValuePairs.length; j++)
{
queryStringNew += this._keyValuePairs[j];
if(j < this._keyValuePairs.length-1)
{
queryStringNew +='&';
}
}
this._queryString=queryStringNew;
}
this.appendErrorsQS = function(prefix)
{
var ret = Microsoft.UpdateServices.Catalog.Constants.EmptyString;
if(typeof(prefix) != typeof(Microsoft.UpdateServices.Catalog.Constants.UndefinedValue) && prefix.length > 0)
{
ret = prefix;
}
var qsErrVal = this.getValue(Microsoft.UpdateServices.Catalog.Constants.QueryStringErrors);
if(qsErrVal)
{
if(ret.length > 0)
{
ret = ret + "&" + Microsoft.UpdateServices.Catalog.Constants.QueryStringErrors + "=" + qsErrVal;
}
else
{
ret = "?" + Microsoft.UpdateServices.Catalog.Constants.QueryStringErrors + "=" + qsErrVal;
}
}
return ret;
}
}
Microsoft.UpdateServices.Catalog.QueryString.registerClass("Microsoft.UpdateServices.Catalog.QueryString");
Microsoft.UpdateServices.Catalog.UI.Utility = function()
{
}
Microsoft.UpdateServices.Catalog.UI.Utility.formatSize = function(size)
{
var sizeStr = Microsoft.UpdateServices.Catalog.Constants.EmptyString;
if(size >= (1000 * Microsoft.UpdateServices.Catalog.Constants.UnitKB))
{
sizeStr = Number(size / Microsoft.UpdateServices.Catalog.Constants.UnitMB).toFixed(1) + ' MB';
sizeStr = sizeStr.replace(".", Microsoft.UpdateServices.Catalog.Constants.NumberDecimalSeparator);
}
else if(size >= 0)
{
sizeStr = Number(size / Microsoft.UpdateServices.Catalog.Constants.UnitKB).toFixed(0) + ' KB';
}
return sizeStr;
}
Microsoft.UpdateServices.Catalog.UI.Utility.validateEmail = function(emailString)
{
var emailFilter="^[A-z0-9a-z!#$%&'*+-/=?^_`{|}~]+@[A-z0-9a-z!#$%&'*+-/=?^_`{|}~]+\\.[A-z0-9a-z!#$%&'*+-/=?^_`{|}~]+$";
var emailRegExp = new RegExp(emailFilter);
var validEmail = true;
validEmail = emailRegExp.test(emailString);
return validEmail;
}
Microsoft.UpdateServices.Catalog.UI.Utility.registerClass("Microsoft.UpdateServices.Catalog.UI.Utility");
Microsoft.UpdateServices.Catalog.Event = function(owner, autoInvoke)
{
var _owner = owner;
var _handlers = null;
var _actions = null;
var _autoInvoke = autoInvoke;
var _invoked = false;
this.get_autoInvoke = function()
{
return _autoInvoke;
}
this._getActions = function()
{
if (_actions && _actions.length && !_owner)
throw "Actions are only supported on events that have an owner.";
if (_actions == null)
{
_actions = [];
}
return _actions;
}
this._getHandlers = function()
{
if (_handlers == null) {
_handlers = [];
}
return _handlers;
}
this._getOwner = function()
{
return _owner;
}
this.isActive = function()
{
return ((_handlers != null) && (_handlers.length != 0)) ||
((_actions != null) && (_actions.length != 0));
}
this.get_isInvoked = function()
{
return _invoked;
}
this.dispose = function()
{
if (_handlers) {
for (var h = _handlers.length - 1; h >= 0; h--) {
_handlers[h] = null;
}
_handlers = null;
}
if (_actions) {
for (var i = _actions.length - 1; i >= 0; i--) {
_actions[i].dispose();
}
_actions = null;
}
_owner = null;
}
this._setInvoked = function(value)
{
_invoked = true;
}
}
Microsoft.UpdateServices.Catalog.Event.registerClass('Microsoft.UpdateServices.Catalog.Event', null, Sys.IDisposable);
Microsoft.UpdateServices.Catalog.Event.prototype.add = function(handler) {
Array.add(this._getHandlers(),handler);
if (this.get_autoInvoke() && this.get_isInvoked()) {
handler(this._getOwner(), null);
}
}
Microsoft.UpdateServices.Catalog.Event.prototype.addAction = function(action) {
action.setOwner(this._getOwner());
Array.add(this._getActions(),action);
}
Microsoft.UpdateServices.Catalog.Event.prototype.remove = function(handler) {
Array.remove(this._getHandlers(),handler);
}
Microsoft.UpdateServices.Catalog.Event.prototype.removeAction = function(action) {
action.dispose();
Array.remove(this._getActions(),action);
}
Microsoft.UpdateServices.Catalog.Event.prototype.invoke = function(sender, eventArgs) {
if (this.isActive()) {
var actions = this._getActions();
var handlers = this._getHandlers();
var hasPostActions = false;
var i;
for (i = 0; i < actions.length; i++) {
if (actions[i].get_sequence() == Sys.ActionSequence.BeforeEventHandler) {
actions[i].execute(sender, eventArgs);
}
else {
hasPostActions = true;
}
}
for (i = 0; i < handlers.length; i++) {
handlers[i](sender, eventArgs);
}
if (hasPostActions) {
for (i = 0; i < actions.length; i++) {
if (actions[i].get_sequence() == Sys.ActionSequence.AfterEventHandler) {
actions[i].execute(sender, eventArgs);
}
}
}
this._setInvoked();
}
}
Microsoft.UpdateServices.Catalog.Logger =
{
logLevelFatal : 1,
logLevelWarning : 2,
logLevelInfo : 3,
logLevelVerbose : 4,
initialize : function(control)
{
if(!Microsoft.UpdateServices.Catalog.Logger.control)
{
Microsoft.UpdateServices.Catalog.Logger.control = control;
}
},
log : function(level, message)
{
if(Microsoft.UpdateServices.Catalog.Logger.control)
{
if(level >= Microsoft.UpdateServices.Catalog.Logger.logLevelFatal &&
level <= Microsoft.UpdateServices.Catalog.Logger.logLevelVerbose &&
message != null)
{
Microsoft.UpdateServices.Catalog.Logger.control.Log(level, message);
}
}
}
}
window.logger = Microsoft.UpdateServices.Catalog.Logger;
