Skip to content

Instantly share code, notes, and snippets.

@mrlacey
Created March 9, 2015 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrlacey/934abc50c1e35c3935be to your computer and use it in GitHub Desktop.
Save mrlacey/934abc50c1e35c3935be to your computer and use it in GitHub Desktop.
Things you can do with Windows 10 Web Apps
addAppointment = function(e, t, n) {
if ("undefined" != typeof Windows) {
var o = new Windows.ApplicationModel.Appointments.Appointment;
o.allDay = !0, o.startTime = new Date(i(t, "dddd, Do MMM YYYY").format()), o.subject = "Trip to " + n, Windows.ApplicationModel.Appointments.AppointmentManager.showAddAppointmentAsync(o, {
x: 300,
y: 0,
width: 600,
height: 100
}).done(function(t) {
t ? (console.log("created!"), e()) : console.log("issue")
})
}
}
addContact = function(e) {
if (console.log("plugin: addContact"), "undefined" != typeof Windows) {
var t = new Windows.ApplicationModel.Contacts.ContactPicker;
t.desiredFieldsWithContactFieldType.append(Windows.ApplicationModel.Contacts.ContactFieldType.email), t.pickContactAsync().done(function(t) {
if (null !== t) {
var n = t.displayName;
console.log(n), e({
name: n
}, null)
} else console.log("No contact was selected"), e(null, "No contact was selected")
})
} else console.log("ERROR: No Windows namespace was detected"), e({
name: "[name]"
}, null)
}
showToast = function(e) {
if (console.log("OUTPUT: " + e), "undefined" != typeof Windows) {
var t = Windows.UI.Notifications,
n = t.ToastTemplateType.toastImageAndText01,
i = t.ToastNotificationManager.getTemplateContent(n),
o = i.getElementsByTagName("text");
o[0].appendChild(i.createTextNode(e));
var r = i.getElementsByTagName("image");
r[0].setAttribute("src", "https://raw.githubusercontent.com/seksenov/ContosoTravel/master/build/images/storelogo.png"), r[0].setAttribute("alt", "red graphic");
var s = i.selectSingleNode("/toast");
s.setAttribute("duration", "long");
var s = i.selectSingleNode("/toast"),
a = i.createElement("audio");
a.setAttribute("src", "ms-winsoundevent:Notification.IM"), i.selectSingleNode("/toast").setAttribute("launch", '{"type":"toast","param1":"12345","param2":"67890"}');
var l = new t.ToastNotification(i),
c = t.ToastNotificationManager.createToastNotifier();
c.show(l)
} else console.log("ERROR: No Windows namespace was detected")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment