{"size": 1819, "ext": "js", "max_stars_repo_path": "archived/UserDataAccountManager/js/js/sample-configuration.js", "max_stars_repo_name": "dujianxin/Windows-universal-samples", "max_stars_repo_stars_event_min_datetime": "2019-05-07T06:56:42.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T19:37:59.000Z", "max_issues_repo_path": "archived/UserDataAccountManager/js/js/sample-configuration.js", "max_issues_repo_name": "dujianxin/Windows-universal-samples", "max_issues_repo_issues_event_min_datetime": "2019-05-08T16:56:30.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-21T07:13:45.000Z", "max_forks_repo_path": "archived/UserDataAccountManager/js/js/sample-configuration.js", "max_forks_repo_name": "dujianxin/Windows-universal-samples", "max_forks_repo_forks_event_min_datetime": "2019-05-07T00:47:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T21:12:31.000Z"}
{"max_stars_count": 2504, "max_issues_count": 314, "max_forks_count": 2219, "avg_line_length": 35.6666666667, "max_line_length": 166, "alphanum_fraction": 0.6030786146}
﻿//// Copyright (c) Microsoft Corporation. All rights reserved

(function () {
    "use strict";

    var sampleTitle = "Sample Title here";

    var scenarios = [
        { url: "/html/scenario1-addAccount.html", title: "Add an account" },
        { url: "/html/scenario2-manageAccount.html", title: "Manage an account" },
        { url: "/html/scenario3-fixAccount.html", title: "Fix an account" }
    ];

    var userDataAccounts = Windows.ApplicationModel.UserDataAccounts;

    function loadDataAccountsAsync(accountSelect)
    {
        var length = accountSelect.length;
        for (var i = 0; i < length; i++) {
            accountSelect.removeChild(accountSelect[0]);
        }

        return userDataAccounts.UserDataAccountManager.requestStoreAsync(userDataAccounts.UserDataAccountStoreAccessType.AllAccountsReadOnly).then(function (store) {
            if (store == null) {
                WinJS.log && WinJS.log("Access to Contacts, Calendar and Email has been revoked", "sample", "error");
                return;
            }

            return store.findAccountsAsync().then(function (accounts) {
                accounts.forEach(function (account) {
                    addOption(accountSelect, account);
                });
            });
        });
    }

    function addOption(accountSelect, dataAccount)
    {
        var newOption = document.createElement("option");
        newOption.text = dataAccount.userDisplayName;
        newOption.value = dataAccount.id;
        newOption.selected = false;
        accountSelect.add(newOption);
    }

    WinJS.Namespace.define("SdkSample", {
        sampleTitle: sampleTitle,
        scenarios: new WinJS.Binding.List(scenarios),
        loadDataAccountsAsync: loadDataAccountsAsync
    });
})();