﻿(function () {
    "use strict";

    var appdata = Windows.Storage.ApplicationData.current;
    var tileColors = q("#tileColors > div");
    
    WinJS.UI.Pages.define("/pages/settings/settings.html", {
        ready: function (element, options) {
            init();
            loadPrefs();
        }
    });

    function init() {
        q("#showPrefs").onclick = function (e) {
            WinJS.UI.SettingsFlyout.showSettings("preferencesDiv", "/pages/settings/settings.html");
        };

        var colors = ["#0098ab", "#0070a9", "#d9532c", "#a400ac", "#009086", "#5838b4", "#ae193e", "#2c86ee", "#009c00"];
        tileColors.forEach(function (d, i) {
            d.style.backgroundColor = colors[i];
            d.onclick = function (e) {
                tileColors.forEach(function (d) { d.classList.remove("selected"); });
                e.target.classList.add("selected");
            };
        });
    }
    
    function loadPrefs() {
        var tileColor = appdata.roamingSettings.values["tileColor"];
        if(!tileColor) tileColor = "#0098ab";
        tileColors.forEach(function (d) { if (d.style.backgroundColor == tileColor) d.target.classList.add("selected"); });
    }
})();

@@ -113,33 +113,8 @@
 lors
- = q(%22#tileColors %3E div%22)
 ;%0D%0A 
@@ -314,24 +314,80 @@
 n init() %7B%0D%0A
+        tileColors = q(%22#tileColors %3E div%22);%0D%0A        %0D%0A
         q(%22#

Fix bug in Settings | Preferences