Skip to content

Instantly share code, notes, and snippets.

View Gr8Gatsby's full-sized avatar
🎯
Focusing

Kevin Hill Gr8Gatsby

🎯
Focusing
View GitHub Profile
@Gr8Gatsby
Gr8Gatsby / Windows.ApplicationModel.Appointments.js
Last active August 29, 2015 14:15
Windows.ApplicationModel.Appointments JavaScript example
if(Windows && Windows.ApplicationModel && Windows.ApplicationModel.Appointments) {}
// Create an Appointment that should be added the user's appointments provider app.
var appointment = new Windows.ApplicationModel.Appointments.Appointment();
// Get the selection rect of the button pressed to add this appointment
var boundingRect = e.srcElement.getBoundingClientRect();
var selectionRect = { x: boundingRect.left, y: boundingRect.top, width: boundingRect.width, height: boundingRect.height };
// ShowAddAppointmentAsync returns an appointment id if the appointment given was added to the user's calendar.
// This value should be stored in app data and roamed so that the appointment can be replaced or removed in the future.
// An empty string return value indicates that the user canceled the operation before the appointment was added.
Windows.ApplicationModel.Appointments.AppointmentManager.showAddAppointmentAsync(appointment, selectionRect, Windows.UI.Popups.Placement.default)
@Gr8Gatsby
Gr8Gatsby / Windows.UI.Popups.MessageDialog.js
Last active September 10, 2015 16:27
This shows how to create a Windows System prompt.
if(typeof Windows !== 'undefined' &&
typeof Windows.UI !== 'undefined' &&
typeof Windows.UI.Popups !== 'undefined' ) {
// Create the message dialog and set its content
var msg = new Windows.UI.Popups.MessageDialog(message);
// Add commands
msg.commands.append(new Windows.UI.Popups.UICommand("Okay", systemAlertCommandInvokedHandler));
// Set default command
msg.defaultCommandIndex = 0;
// Show the message dialog
@Gr8Gatsby
Gr8Gatsby / Windows.UI.Notifications.js
Last active September 30, 2020 13:16
Windows.UI.Notifications JavaScript example
if(Windows !== 'undefined' &&
Windows.UI !== 'undefined' &&
Windows.UI.Notifications !== 'undefined') {
var notifications = Windows.UI.Notifications;
//Get the XML template where the notification content will be suplied
var template = notifications.ToastTemplateType.toastImageAndText01;
var toastXml = notifications.ToastNotificationManager.getTemplateContent(template);
//Supply the text to the XML content
var toastTextElements = toastXml.getElementsByTagName("text");
toastTextElements[0].appendChild(toastXml.createTextNode(message));
if(typeof Windows != 'undefined') {
// Create the picker
var picker = new Windows.ApplicationModel.Contacts.ContactPicker();
picker.desiredFieldsWithContactFieldType.append(Windows.ApplicationModel.Contacts.ContactFieldType.email);
// Open the picker for the user to select a contact
picker.pickContactAsync().done(function (contact) {
if (contact !== null) {
var output = "Selected contact:\n" + contact.displayName;
console.log(output);
} else {