Skip to content

Instantly share code, notes, and snippets.

View seksenov's full-sized avatar

Kiril Seksenov seksenov

  • Salesforce
  • Seattle
View GitHub Profile
if(typeof Windows != 'undefined') {
var captureUI = new Windows.Media.Capture.CameraCaptureUI();
//Set the format of the picture that's going to be captured (.png, .jpg, ...)
captureUI.photoSettings.format = Windows.Media.Capture.CameraCaptureUIPhotoFormat.png;
//Pop up the camera UI to take a picture
captureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).then(function (capturedItem) {
// Do something with the picture
});
}
@seksenov
seksenov / windowsNotification.js
Last active October 21, 2016 08:34
JavaScript function that displays a toast notification in Universal Windows Apps. For Web Apps, Hosted Web Apps and WebView with Windows Runtume Access.
function showToast () {
if(typeof Windows !== undefined) {
var notifications = Windows.UI.Notifications;
var template = notifications.ToastTemplateType.toastImageAndText01;
var toastXml = notifications.ToastNotificationManager.getTemplateContent(template);
var toastTextElements = toastXml.getElementsByTagName("text");
toastTextElements[0].appendChild(toastXml.createTextNode("Toast from Codepen"));
var toastImageElements = toastXml.getElementsByTagName("image");
toastImageElements[0].setAttribute("src", "http://assets.codepen.io/assets/social/facebook-default.png");
toastImageElements[0].setAttribute("alt", "red graphic");
@seksenov
seksenov / codepenACUR.xml
Created June 9, 2015 15:49
Application Content URI Rules Example
StartPage="http://codepen.io/seksenov/pen/wBbVyb/?editors=101">
<uap:ApplicationContentUriRules>
<uap:Rule Match="http://codepen.io/seksenov/pen/wBbVyb/?editors=101" Type="include" WindowsRuntimeAccess="all"/>
<uap:Rule Match="http://*.codepen.io/" Type="include" WindowsRuntimeAccess="all"/>
</uap:ApplicationContentUriRules>
@seksenov
seksenov / cortana.html
Last active May 28, 2022 21:51
Cortana integration from a hosted web app on Windows. To do this you'll need a meta tag in your html page pointint to an xml voice command definition file on your server. You'll also need to handle the Cortana activation event in your JavaScript.
<!DOCTYPE html>
<html>
<head>
<title>Cortana Example</title>
<!--Cortana meta tag pointing to VCD file on the server-->
<meta name="msapplication-cortanavcd" content="https://mysite.com/vcd.xml"/>
</head>
<body>
</body>
@seksenov
seksenov / windowsFeatureDetect.js
Last active August 29, 2015 14:24
Feature detecting for notifications on Windows
if (typeof Windows !== 'undefined' &&
typeof Windows.UI !== 'undefined' &&
typeof Windows.UI.Notifications !== 'undefined') {
//Call Windows.UI.Notifications
}
function updateTile(message, imgUrl, imgAlt) {
// Namespace: Windows.UI.Notifications
if (typeof Windows !== 'undefined'&&
typeof Windows.UI !== 'undefined' &&
typeof Windows.UI.Notifications !== 'undefined') {
var notifications = Windows.UI.Notifications,
tile = notifications.TileTemplateType.tileSquare150x150PeekImageAndText01,
tileContent = notifications.TileUpdateManager.getTemplateContent(tile),
tileText = tileContent.getElementsByTagName('text'),
function cameraCapture() {
if(typeof Windows != 'undefined') {
var captureUI = new Windows.Media.Capture.CameraCaptureUI();
//Set the format of the picture that's going to be captured (.png, .jpg, ...)
captureUI.photoSettings.format = Windows.Media.Capture.CameraCaptureUIPhotoFormat.png;
//Pop up the camera UI to take a picture
captureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).then(function (capturedItem) {
// Do something with the picture
});
}
@seksenov
seksenov / fileDownload.js
Created December 8, 2015 23:59
This gist shows how a web app running as a Hosted Web App with Windows API Access is able to download and
'use strict'
var client = null;
document.addEventListener("DOMContentLoaded", init);
function init() {
var btn = document.getElementById("saveFile");
btn.addEventListener("click", () => downloadAndSave("./img/detroitSkyline.jpg"));
}
@seksenov
seksenov / changeAppTitleBarColors.js
Created December 10, 2015 23:51 — forked from Gr8Gatsby/changeAppTitleBarColors.js
This Gist shows how to set the application titlebar colors. There is a helper function that accepts an HTML hexString and converts it to an RGBA color object for Windows.
/*
This function expects two hexStrings and relies on hexStrToRGBA to convert
to a JSON object that represents RGBA for the underlying Windows API to
understand.
Examples of valid values:
setAppBarColors('#FFFFFF','#000000');
setAppBarColors('#FFF','#000');
setAppBarColors('FFFFFF','000000');
setAppBarColors('FFF','000');
'use strict';
var systemMediaControls;
(function () {
// Add the event listener to handle Windows activated event
if (typeof Windows !== 'undefined') {
systemMediaControls = Windows.Media.SystemMediaTransportControls.getForCurrentView();
systemMediaControls.addEventListener("buttonpressed", systemMediaControlsButtonPressed, false);