| Server IP : 123.56.80.60 / Your IP : 216.73.216.78 Web Server : Apache/2.4.54 (Win32) OpenSSL/1.1.1s PHP/7.4.33 mod_fcgid/2.3.10-dev System : Windows NT iZhx3sob14hnz7Z 10.0 build 14393 (Windows Server 2016) i586 User : SYSTEM ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Windows/SystemApps/Microsoft.Windows.CloudExperienceHost_cw5n1h2txyewy/js/ |
Upload File : |
(function () {
"use strict";
var localAccountResources = {};
var bridge = new CloudExperienceHost.Bridge();
var validator = new uiHelpers.Validator();
var errorClass = new uiHelpers.ErrorUI();
WinJS.UI.Pages.define("/views/localAccount.html", {
init: function (element, options) {
var languagePromise = bridge.invoke("CloudExperienceHost.Globalization.Language.getPreferredLang").then(function (preferredLang) {
_htmlRoot.setAttribute("lang", preferredLang);
}, function () { });
var dirPromise = bridge.invoke("CloudExperienceHost.Globalization.Language.getReadingDirection").then(function (dirVal) {
_htmlRoot.setAttribute("dir", dirVal);
}, function () { });
var stringPromise = bridge.invoke("CloudExperienceHost.LocalAccount.localizedStrings").then(function (result) {
localAccountResources = JSON.parse(result);
});
var cssPromise = uiHelpers.LoadCssPromise(document.head, "..", bridge);
return WinJS.Promise.join({ languagePromise: languagePromise, dirPromise: dirPromise, stringPromise: stringPromise, cssPromise: cssPromise });
},
ready: function (element, options) {
userName.setAttribute('maxLength', '20');
var setContentFor = [Title, LeadText, UserNameLegend, PasswordLegend, NextButton, BackButton];
var i = 0;
for (i = 0; i < setContentFor.length; i++) {
setContentFor[i].textContent = localAccountResources[setContentFor[i].id];
}
var placeholderKey = [userName, password, passwordValidate, passwordHint];
var placeholderValue = ['UserPlaceholder', 'PasswordPlaceholder', 'ReenterPlaceholder', 'HintPlaceholder'];
for (i = 0; i < placeholderKey.length; i++) {
placeholderKey[i].setAttribute('placeholder', localAccountResources[placeholderValue[i]]);
}
NextButton.addEventListener("click", function (event) {
event.preventDefault();
_onNext.apply(this);
}.bind(this));
var checkAmersandFor = [NextButton, BackButton];
checkAmersandFor.forEach(function (eachElement) {
var result = CloudExperienceHost.ResourceManager.GetContentAndAccesskey(localAccountResources[eachElement.id]);
eachElement.textContent = result.content;
eachElement.accessKey = result.accessKey;
});
bridge.invoke("CloudExperienceHost.Environment.hasInternetAccess").done(function (isConnectedToNetwork) {
uiHelpers.SetElementVisibility(BackButton, isConnectedToNetwork);
});
BackButton.addEventListener("click", function () {
bridge.fireEvent(CloudExperienceHost.Events.goBack);
});
userName.addEventListener("blur", function () {
var errorCode = validator.validateUsername(userName);
if (errorCode !== ErrorCodes.SUCCESS) {
this._showError(errorCode, false );
}
}.bind(this));
userName.addEventListener("keyup", function () {
if (validator.validateUsername(userName) === ErrorCodes.SUCCESS) {
errorClass.HideError(userName, userName_errorDialog);
}
});
password.addEventListener("blur", function () {
if ((passwordValidate.value.length >= 1) || (password.value.length === 0)) {
var errorCode = validator.preCheckPassword(password, passwordValidate);
if (errorCode !== ErrorCodes.SUCCESS) {
this._showError(errorCode, false );
}
}
}.bind(this));
password.addEventListener("keyup", function () {
if (validator.preCheckPassword(password, passwordValidate) === ErrorCodes.SUCCESS) {
errorClass.HideError(passwordValidate, passwordValidate_errorDialog);
}
});
passwordValidate.addEventListener("blur", function () {
var errorCode = validator.preCheckPassword(password, passwordValidate);
if (errorCode !== ErrorCodes.SUCCESS) {
this._showError(errorCode, false );
}
}.bind(this));
passwordValidate.addEventListener("keyup", function () {
if (validator.preCheckPassword(password, passwordValidate) === ErrorCodes.SUCCESS) {
errorClass.HideError(passwordValidate, passwordValidate_errorDialog);
}
});
passwordHint.addEventListener("blur", function () {
var errorCode = validator.validateHint(password, passwordHint);
if (errorCode !== ErrorCodes.SUCCESS) {
this._showError(errorCode, false );
}
}.bind(this));
passwordHint.addEventListener("keyup", function () {
if (validator.validateHint(password, passwordHint) === ErrorCodes.SUCCESS) {
errorClass.HideError(passwordHint, passwordHint_errorDialog);
}
});
uiHelpers.RegisterEaseOfAccess(easeOfAccess, bridge);
uiHelpers.RegisterInputSwitcher(inputSwitcher, bridge);
bridge.fireEvent(CloudExperienceHost.Events.visible, true);
function _onNext() {
_setProgressState(true);
var result = validator.validateAll(userName, password, passwordValidate, passwordHint);
if (result === ErrorCodes.SUCCESS) {
bridge.invoke("CloudExperienceHost.LocalAccount.createLocalAccount", userName.value.trim(), password.value, passwordHint.value).done(function () {
bridge.invoke("CloudExperienceHost.Telemetry.logEvent", "LocalAccountCreationSuccess", (password.value.length > 0) ? "Password" : "NoPassword");
bridge.fireEvent(CloudExperienceHost.Events.done, CloudExperienceHost.AppResult.success);
}, function (e) {
_setProgressState(false);
this._showError(this._getErrorCode(e.number), true );
bridge.invoke("CloudExperienceHost.Telemetry.logEvent", "LocalAccountCreationFailure", JSON.stringify({ errorNumber: e.number.toString(16), errorStack: e.asyncOpSource.stack }));
}.bind(this));
}
else {
_setProgressState(false);
this._showError(result, true );
}
}
function _setProgressState(waiting) {
NextButton.disabled = waiting;
uiHelpers.SetElementVisibility(progressRing, waiting);
userName.disabled = waiting;
password.disabled = waiting;
passwordValidate.disabled = waiting;
passwordHint.disabled = waiting;
}
},
error: function (e) {
bridge.invoke("CloudExperienceHost.Telemetry.logEvent", "LocalAccountPageError", JSON.stringify({ number: e && e.number, stack: e && e.asyncOpSource && e.asyncOpSource.stack }));
bridge.fireEvent(CloudExperienceHost.Events.done, CloudExperienceHost.AppResult.fail);
},
_getErrorCode: function (errorNumber) {
var errorCode = null;
switch (errorNumber) {
case -0x7ff8fadd:
errorCode = ErrorCodes.Username_Error;
break;
case -0x7ff8fadc:
errorCode = ErrorCodes.UserExists_Error;
break;
case -0x7ff8fd46:
errorCode = ErrorCodes.UserReserved_Error;
break;
case -0x7ff8ffcc:
errorCode = ErrorCodes.UserIsComputer_Error_Title;
break;
case -0x7ff8fb78:
errorCode = ErrorCodes.UserEmpty_Error_Title;
break;
case -0x7ff8fad1:
errorCode = ErrorCodes.UsernameContainsAt_Error;
break;
case -0x7ff8fad3:
case -0x2fffff94:
errorCode = ErrorCodes.PasswordPolicy_Error;
break;
case -0x7ff8fad5:
errorCode = ErrorCodes.PasswordConfirm_Error;
break;
case -0x7ff8df84:
errorCode = ErrorCodes.PasswordHint_Empty_Error;
break;
default:
errorCode = ErrorCodes.Error_Creating_Account_Warning;
break;
}
return errorCode;
},
_showError: function (errorCode, setFocus) {
var resourceId = null, inputField = null;
switch (errorCode) {
case ErrorCodes.PasswordPlaceholder:
resourceId = 'PasswordPlaceholder';
inputField = passwordValidate;
break;
case ErrorCodes.ReenterPlaceholder:
resourceId = 'ReenterPlaceholder';
inputField = passwordValidate;
break;
case ErrorCodes.HintPlaceholder:
resourceId = 'HintPlaceholder';
inputField = passwordHint;
break;
case ErrorCodes.UserEmpty_Error_Title:
resourceId = 'UserEmpty_Error_Title';
inputField = userName;
break;
case ErrorCodes.LocalUser_NoUsername_Error:
resourceId = 'LocalUser_NoUsername_Error';
inputField = userName;
break;
case ErrorCodes.Username_Too_Long:
resourceId = 'Username_Too_Long';
inputField = userName;
break;
case ErrorCodes.Username_Error:
resourceId = 'Username_Error';
inputField = userName;
break;
case ErrorCodes.UsernameContainsAt_Error:
resourceId = 'UsernameContainsAt_Error';
inputField = userName;
break;
case ErrorCodes.UserExists_Error:
resourceId = 'UserExists_Error';
inputField = userName;
break;
case ErrorCodes.UserReserved_Error:
resourceId = 'UserReserved_Error';
inputField = userName;
break;
case ErrorCodes.UserIsComputer_Error_Title:
resourceId = 'UserIsComputer_Error_Title';
inputField = userName;
break;
case ErrorCodes.PasswordHint_Empty_Error:
resourceId = 'PasswordHint_Empty_Error';
inputField = passwordHint;
break;
case ErrorCodes.PasswordHint_Invalid_Error:
resourceId = 'PasswordHint_Invalid_Error';
inputField = passwordHint;
break;
case ErrorCodes.PasswordConfirm_Error:
resourceId = 'PasswordConfirm_Error';
inputField = passwordValidate;
break;
case ErrorCodes.PasswordPolicy_Error:
resourceId = 'PasswordPolicy_Error';
inputField = passwordValidate;
break;
case ErrorCodes.Error_Creating_Account_Warning:
resourceId = 'Error_Creating_Account_Warning';
inputField = passwordHint;
break;
default:
break;
}
if (resourceId && inputField) {
errorClass.ShowError(inputField, document.getElementById(inputField.id + '_errorDialog'), localAccountResources[resourceId]);
if (setFocus) {
inputField.focus();
}
}
},
});
})();