//////////////////////////////////////////////////////////////////////////////// // // THIS CODE IS NOT APPROVED FOR USE IN/ON ANY OTHER UI ELEMENT OR PRODUCT COMPONENT. // Copyright (c) 2007 Microsoft Corporation. All rights reserved. // //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // // GLOBAL VARIABLES // //////////////////////////////////////////////////////////////////////////////// var g_defaultShowBroadbandContent = true; var g_defaultBroadbandContentCount = 6; var g_defaultShowRecordedTVItem = true; var g_defaultRecordedTVItemCount = 6; var g_defaultTransitionTime = 10; var g_keyShowBroadbandContent = "mceShowBroadbandContent"; var g_keyBroadbandContentCount = "mceBroadbandContentCount"; var g_keyShowRecordedTVItem = "mceShowRecordedTVItem"; var g_keyRecordedTVItemCount = "mceRecordedTVItemCount"; var g_keyTransitionTime = "mceTransitionTime"; var g_maxBBSourceCount = 20; var g_regKeyBBSourceTitle = "BBSourceTitle"; var g_regKeyBBSourceShow = "BBSourceShow"; //////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// function load() { System.Gadget.onSettingsClosing = OnSettingsClosing; GetMCEGadgetSettings(); LoadString(); } function LoadString() { L_SETTINGS_TEXT1.innerText = System.Gadget.Settings.read("mceSettingText1"); L_SETTINGS_TEXT2.innerText = System.Gadget.Settings.read("mceSettingText2"); L_SETTINGS_TEXT3.innerText = System.Gadget.Settings.read("mceSettingText3"); L_SETTINGS_TRANSITIONTIME.innerText = System.Gadget.Settings.read("mceSettingText5"); L_SETTINGS_INTERNETTV_TITLE.innerText = System.Gadget.Settings.read("mceSettingInternetTVTitle"); L_SETTINGS_INTERNETTV_COUNT.innerText = System.Gadget.Settings.read("mceSettingInternetTVCount"); } function SetDefaultSettingsValue() { var mceShowBroadbandContent = System.Gadget.Settings.read(g_keyShowBroadbandContent); var mceBroadbandContentCount = System.Gadget.Settings.read(g_keyBroadbandContentCount); var mceShowRecordedTVItem = System.Gadget.Settings.read(g_keyShowRecordedTVItem); var mceRecordedTVItemCount = System.Gadget.Settings.read(g_keyRecordedTVItemCount); var mceTransitionTime = System.Gadget.Settings.read(g_keyTransitionTime); ////////////////////////////////////////////////////////////////////////////////////// // Set default value if it is not ever set if(mceBroadbandContentCount == "") { // Set default value for RecordedTVItemCount when there is no saved data mceBroadbandContentCount = g_defaultBroadbandContentCount; System.Gadget.Settings.write(g_keyBroadbandContentCount, mceBroadbandContentCount); // Set default value for ShowRecordedTVItem when there is no saved data mceShowBroadbandContent = g_defaultShowBroadbandContent; System.Gadget.Settings.write(g_keyShowBroadbandContent, mceShowBroadbandContent); } if(mceRecordedTVItemCount == "") { // Set default value for RecordedTVItemCount when there is no saved data mceRecordedTVItemCount = g_defaultRecordedTVItemCount; System.Gadget.Settings.write(g_keyRecordedTVItemCount, mceRecordedTVItemCount); // Set default value for ShowRecordedTVItem when there is no saved data mceShowRecordedTVItem = g_defaultShowRecordedTVItem; System.Gadget.Settings.write(g_keyShowRecordedTVItem, mceShowRecordedTVItem); } // Set default value for TransitionTime when there is no saved data if(mceTransitionTime == "") { mceTransitionTime = g_defaultTransitionTime; System.Gadget.Settings.write(g_keyTransitionTime, mceTransitionTime); } } //////////////////////////////////////////////////////////////////////////////// // Retrieve values from registry //////////////////////////////////////////////////////////////////////////////// function GetMCEGadgetSettings() { var mceShowBroadbandContent = System.Gadget.Settings.read(g_keyShowBroadbandContent); var mceBroadbandContentCount = System.Gadget.Settings.read(g_keyBroadbandContentCount); var mceShowRecordedTVItem = System.Gadget.Settings.read(g_keyShowRecordedTVItem); var mceRecordedTVItemCount = System.Gadget.Settings.read(g_keyRecordedTVItemCount); var mceTransitionTime = System.Gadget.Settings.read(g_keyTransitionTime); SetDefaultSettingsValue(); ////////////////////////////////////////////////////////////////////////////////////// // Apply the previous value to UI // set "ShowRecoredTVItem" check box with previous value mceShowRecordedTVItemCheck.checked = mceShowRecordedTVItem; // Set "RecordedTVItemCount" combobox box with previous value for(var i = 0; i < mceRecordedTVItemCountSelection.options.length; i++) { if(mceRecordedTVItemCount == mceRecordedTVItemCountSelection.options(i).text) { mceRecordedTVItemCountSelection.options(i).selected = true; break; } } // Set "ShowBroadband" check box with previous value mceShowBroadbandContentCheck.checked = mceShowBroadbandContent; // Set "BroadbandContentCount" combobox box with previous value for(var i = 0; i < mceBroadbandContentCountSelection.options.length; i++) { if(mceBroadbandContentCount == mceBroadbandContentCountSelection.options(i).text) { mceBroadbandContentCountSelection.options(i).selected = true; break; } } // Set checkbox title with broadband source name. var count = 0; for(count = 0; count < g_maxBBSourceCount; count++) { var checkboxname = "checkboxTitleBBSource" + count; var key = g_regKeyBBSourceTitle + count; var sourceTitle = System.Gadget.Settings.read(key); if (sourceTitle == "") { break; } document.getElementById(checkboxname).innerText = sourceTitle; // Set checkbox to be checked/unchecked with the last users setting. var checkbox = "checkBoxBBSource" + count; key = g_regKeyBBSourceShow + sourceTitle; if (System.Gadget.Settings.read(key) == "Hide") { document.getElementById(checkbox).checked = false; } else { document.getElementById(checkbox).checked = true; } } if (count == 0) { document.getElementById("SourceListDiv").style.display = "none"; } // hide checkbox controls if sources are not enough. for(; count