Skip to content

Instantly share code, notes, and snippets.

@pc035860
Created July 13, 2012 10:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pc035860/3104034 to your computer and use it in GitHub Desktop.
Save pc035860/3104034 to your computer and use it in GitHub Desktop.
Make direct command on Metro style app settings (JavaScript)
(function () {
var standard_commands,
special_commands;
standard_commands = {
game: {title: 'game settings'}
};
special_commands = {
popup: {title: 'go Facebook.com', cmd: function () {
window.open('http://www.facebook.com');
}}
};
WinJS.Application.onsettings = function (e) {
// populate standard commands
e.detail.applicationcommands = standard_commands;
WinJS.UI.SettingsFlyout.populateSettings(e);
// populate special commands -> extract from BingFinance app
var appSettings = Windows.UI.ApplicationSettings,
vector = e.detail.e.request.applicationCommands;
for (var key in special_commands) {
var entry = special_commands[key],
cmd = new appSettings.SettingsCommand(key, entry.title, entry.command);
vector.append(cmd);
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment