"use strict"; var __extends = this.__extends || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } __.prototype = b.prototype; d.prototype = new __(); }; var CloudExperienceHost; (function (CloudExperienceHost) { var OEMRegistrationInfo; (function (OEMRegistrationInfo_1) { (function (ElementType) { ElementType[ElementType["Text"] = 0] = "Text"; ElementType[ElementType["EMail"] = 1] = "EMail"; ElementType[ElementType["Select"] = 2] = "Select"; ElementType[ElementType["Checkbox"] = 3] = "Checkbox"; ElementType[ElementType["Link"] = 4] = "Link"; ElementType[ElementType["Paragraph"] = 5] = "Paragraph"; })(OEMRegistrationInfo_1.ElementType || (OEMRegistrationInfo_1.ElementType = {})); var ElementType = OEMRegistrationInfo_1.ElementType; var Element = (function () { function Element(type, id) { this.type = type; this.id = id; } return Element; })(); OEMRegistrationInfo_1.Element = Element; var TextElement = (function (_super) { __extends(TextElement, _super); function TextElement(id, placeHolder, value) { _super.call(this, ElementType.Text, id); this.placeHolder = placeHolder; this.value = value; } return TextElement; })(Element); OEMRegistrationInfo_1.TextElement = TextElement; var EMailElement = (function (_super) { __extends(EMailElement, _super); function EMailElement(id, placeHolder, value) { _super.call(this, ElementType.EMail, id); this.placeHolder = placeHolder; this.value = value; } return EMailElement; })(Element); OEMRegistrationInfo_1.EMailElement = EMailElement; var SelectElement = (function (_super) { __extends(SelectElement, _super); function SelectElement(id, placeHolder, option, options) { _super.call(this, ElementType.Select, id); this.placeHolder = placeHolder; this.option = option; this.options = options; } return SelectElement; })(Element); OEMRegistrationInfo_1.SelectElement = SelectElement; var CheckboxElement = (function (_super) { __extends(CheckboxElement, _super); function CheckboxElement(id, text, checked) { _super.call(this, ElementType.Checkbox, id); this.text = text; this.checked = checked; } return CheckboxElement; })(Element); OEMRegistrationInfo_1.CheckboxElement = CheckboxElement; var LinkElement = (function (_super) { __extends(LinkElement, _super); function LinkElement(id, text, fileName) { _super.call(this, ElementType.Link, id); this.text = text; this.fileName = fileName; } return LinkElement; })(Element); OEMRegistrationInfo_1.LinkElement = LinkElement; var ParagraphElement = (function (_super) { __extends(ParagraphElement, _super); function ParagraphElement(id, text, visibility) { _super.call(this, ElementType.Paragraph, id); this.text = text; this.visibility = visibility; } return ParagraphElement; })(Element); OEMRegistrationInfo_1.ParagraphElement = ParagraphElement; var OEMRegistrationInfo = (function () { function OEMRegistrationInfo(registrationInfo, keyNames) { this._keyNames = keyNames; this._registrationDefinition = registrationInfo; } OEMRegistrationInfo.prototype.getTitle = function () { return this._registrationDefinition[this._keyNames.title]; }; OEMRegistrationInfo.prototype.getSubtitle = function () { return this._registrationDefinition[this._keyNames.subtitle]; }; OEMRegistrationInfo.prototype.getHideskip = function () { return this._registrationDefinition[this._keyNames.hideSkip]; }; OEMRegistrationInfo.prototype.getCustomerinfo = function () { var customerInfo = null; var ci = this._registrationDefinition[this._keyNames.customerInfo]; if (ci) { customerInfo = { label: ci[this._keyNames.label], value: ci[this._keyNames.value], }; } return customerInfo; }; OEMRegistrationInfo.prototype.getFields = function () { var result = new Array(); var fields = this._registrationDefinition[this._keyNames.fields]; if (fields) { fields.forEach(function (field) { result.push({ type: field[this._keyNames.type], id: field[this._keyNames.id], label: field[this._keyNames.label], value: field[this._keyNames.value], }); }, this); } return result; }; OEMRegistrationInfo.prototype.getKeyNames = function () { return this._keyNames; }; return OEMRegistrationInfo; })(); var Strings = (function () { function Strings() { this.firstNamePlaceholder = ""; this.lastNamePlaceholder = ""; this.emailPlaceholder = ""; this.regionDefaultOption = ""; this.prepopulatedInfoLabel = ""; this.emailInvalidError = ""; this.skipButton = ""; this.nextButton = ""; } return Strings; })(); var CustomerInfoFieldId = (function () { function CustomerInfoFieldId() { } CustomerInfoFieldId.firstName = "text1"; CustomerInfoFieldId.lastName = "text2"; CustomerInfoFieldId.email = "text3"; CustomerInfoFieldId.country = "text4"; CustomerInfoFieldId.consent = "consentCheckbox"; return CustomerInfoFieldId; })(); var OEMRegistrationHelper = (function () { function OEMRegistrationHelper(bridge) { this._bridge = null; this._keyNames = null; this._strings = null; this._userInfo = null; this._bridge = bridge; } OEMRegistrationHelper.prototype.initialize = function () { return new WinJS.Promise(function (completeDispatch, errorDispatch ) { this._getOEMRegistrationKeyNames().then(function () { this._getUserInfo().then(function () { this._getStrings().then(function () { completeDispatch(); }.bind(this), errorDispatch); }.bind(this), errorDispatch); }.bind(this), errorDispatch); }.bind(this)); }; OEMRegistrationHelper.prototype.getPageDescriptor = function () { return new WinJS.Promise(function (completeDispatch, errorDispatch ) { var pd = { title: "", subTitle: "", hideSkip: false, emailInvalidError: "", nextButton: "", skipButton: "", fields: [] }; this._getOEMRegistrationInfo().then(function (def) { this._addCustomerInfo(pd, def).then(function () { pd.title = def.getTitle(); pd.subTitle = def.getSubtitle(); pd.hideSkip = def.getHideskip(); pd.emailInvalidError = this._strings.emailInvalidError; pd.nextButton = this._strings.nextButton; pd.skipButton = this._strings.skipButton; this._addFields(pd, def); completeDispatch(pd); }.bind(this), errorDispatch); }.bind(this), errorDispatch); }.bind(this)); }; OEMRegistrationHelper.prototype.saveOEMRegistrationInfo = function (elements) { return new WinJS.Promise(function (completeDispatch, errorDispatch ) { var customerInfo = null; var fields = new Array(); elements.forEach(function (element) { var field = null; switch (element.type) { case ElementType.EMail: case ElementType.Text: var textElement = element; field = new Object(); field[this._keyNames.type] = this._keyNames.textboxType; field[this._keyNames.id] = textElement.id; field[this._keyNames.label] = textElement.placeHolder; field[this._keyNames.value] = textElement.value; break; case ElementType.Checkbox: var checkElement = element; if (checkElement.id === CustomerInfoFieldId.consent) { customerInfo = new Object(); customerInfo[this._keyNames.label] = checkElement.text; customerInfo[this._keyNames.value] = checkElement.checked; } else { field = new Object(); field[this._keyNames.type] = this._keyNames.checkboxType; field[this._keyNames.id] = checkElement.id; field[this._keyNames.label] = checkElement.text; field[this._keyNames.value] = checkElement.checked; } break; default: throw "Invalid Field Type"; break; } if (field) { fields.push(field); } }, this); var registrationInfo = new Object(); if (fields.length > 0) { registrationInfo[this._keyNames.fields] = fields; } if (customerInfo) { registrationInfo[this._keyNames.customerInfo] = customerInfo; } this._bridge.invoke("CloudExperienceHost.OEMRegistrationInfo.saveOEMRegisrationInfo", JSON.stringify(registrationInfo)).then(function () { completeDispatch(); }.bind(this), errorDispatch); }.bind(this)); }; OEMRegistrationHelper.prototype.getLinkFileContent = function (filePath) { return new WinJS.Promise(function (completeDispatch, errorDispatch ) { this._bridge.invoke("CloudExperienceHost.OEMRegistrationInfo.getLinkFileContent", filePath).then(function (content) { completeDispatch(content); }.bind(this), errorDispatch); }.bind(this)); }; OEMRegistrationHelper.prototype._getStrings = function () { return new WinJS.Promise(function (completeDispatch, errorDispatch ) { this._bridge.invoke("CloudExperienceHost.Resources.getStrings", "oemRegistration", new Strings()).then(function (strings) { this._strings = strings; completeDispatch(); }.bind(this), errorDispatch); }.bind(this)); }; OEMRegistrationHelper.prototype._getUserInfo = function () { return new WinJS.Promise(function (completeDispatch, errorDispatch ) { this._bridge.invoke("CloudExperienceHost.MSA.getUserInfo").then(function (userInfo) { this._userInfo = userInfo; completeDispatch(); }.bind(this), errorDispatch); }.bind(this)); }; OEMRegistrationHelper.prototype._getOEMRegistrationKeyNames = function () { return new WinJS.Promise(function (completeDispatch, errorDispatch ) { this._bridge.invoke("CloudExperienceHost.OEMRegistrationInfo.getOEMRegistrationKeyNames").then(function (keyNames) { this._keyNames = keyNames; completeDispatch(); }.bind(this), errorDispatch); }.bind(this)); }; OEMRegistrationHelper.prototype._getOEMRegistrationInfo = function () { return new WinJS.Promise(function (completeDispatch, errorDispatch ) { this._bridge.invoke("CloudExperienceHost.OEMRegistrationInfo.retrieveOEMRegisrationInfo").then(function (registrationInfo) { completeDispatch(new OEMRegistrationInfo(JSON.parse(registrationInfo), this._keyNames)); }.bind(this), errorDispatch); }.bind(this)); }; OEMRegistrationHelper.prototype._addCustomerInfo = function (pd, def) { return new WinJS.Promise(function (completeDispatch, errorDispatch ) { if (def.getCustomerinfo()) { var firstName = null; var lastName = null; var email = null; var country = null; var prepopulated = false; if (this._userInfo) { firstName = this._userInfo.firstName; lastName = this._userInfo.lastName; email = this._userInfo.email; country = this._userInfo.country; prepopulated = true; } this._bridge.invoke("CloudExperienceHost.Globalization.GeographicRegion.getAll").then(function (regions) { pd.fields.push([new TextElement(CustomerInfoFieldId.firstName, this._strings.firstNamePlaceholder, firstName), new TextElement(CustomerInfoFieldId.lastName, this._strings.lastNamePlaceholder, lastName)]); pd.fields.push([new EMailElement(CustomerInfoFieldId.email, this._strings.emailPlaceholder, email), new SelectElement(CustomerInfoFieldId.country, this._strings.regionDefaultOption, country, regions)]); pd.fields.push([new ParagraphElement("prepopulated", this._strings.prepopulatedInfoLabel, prepopulated)]); pd.fields.push([new CheckboxElement(CustomerInfoFieldId.consent, def.getCustomerinfo().label, def.getCustomerinfo().value)]); completeDispatch(); }.bind(this), errorDispatch); } else { completeDispatch(); } }.bind(this)); }; OEMRegistrationHelper.prototype._addFields = function (pd, def) { def.getFields().forEach(function (field) { var element = null; switch (field.type) { case def.getKeyNames().checkboxType: element = new CheckboxElement(field.id, field.label, field.value); break; case def.getKeyNames().linkType: element = new LinkElement(field.id, field.label, field.value); break; case def.getKeyNames().textboxType: default: throw "Invalid Field Type"; break; } pd.fields.push([element]); }, this); }; return OEMRegistrationHelper; })(); OEMRegistrationInfo_1.OEMRegistrationHelper = OEMRegistrationHelper; })(OEMRegistrationInfo = CloudExperienceHost.OEMRegistrationInfo || (CloudExperienceHost.OEMRegistrationInfo = {})); })(CloudExperienceHost || (CloudExperienceHost = {})); x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586