How to automatically remove phonegap.js (cordova.js) from GitHub before build by phonegap build service.

If you want to use the PhoneGap Build service, you must remove the phonegap.js (cordova.js) from your source files, because PhoneGap requires a different phonegap.js JavaScript file for each platform and using an incompatible phonegap.js will result in errors when running your application.

 

For this I use the .gitignore file (https://help.github.com/articles/ignoring-files), so the phonegap.js is never pushed to the GitHub repository, but it can be used during development on the localmachine.

Wrapping the MSApp.execUnsafeLocalFunction

Microsoft’s MSApp.execUnsafeLocalFunction can be used to dynamically add potentially unsafe code to the DOM. If you want to use this function in a cross platform HTML 5 app, you might want to wrap the function like:

if ("undefined" === typeof Utilities)
{
Utilities = {};
}
Utilities.executeUnsafe = function (func)
{
if ("undefined" !== typeof MSApp)
{
MSApp.execUnsafeLocalFunction(function ()
{
func();
});
}
else
{
func();
}
};

Now you can call a potentially unsafe function, like:

Utilities.executeUnsafe(App.myFunction);

Where App.myFunction should be replaced by your function.

How to add dynamic html content with jQuery 2.0.0 to a Windows Store app.

If you directly append html to the DOM that contains HTLM 5 data attributes or event handlers, like the onclick event to a Windows store app, you might get the exception during runtime:

 

Unhandled exception at line 5, column 18611 in ms-appx://3bce315e-3d91-43e6-8149-06d6377f04a1/js/libraries/jquery-2.0.0.min.js

0x800c001c – JavaScript runtime error: Unable to add dynamic content. A script attempted to inject dynamic content, or elements previously modified dynamically, that might be unsafe. For example, using the innerHTML property to add script or malformed HTML will generate this exception. Use the toStaticHTML method to filter dynamic content, or explicitly create elements and attributes with a method such as createElement.  For more information, see http://go.microsoft.com/fwlink/?LinkID=247104.

 

This exception even crashes my Windows Store app, because it is not caught anywhere in the code.

 

In my case this was caused by the following code:

var content = "";
content += ' <ul data-val="users" onclick="console.log(\'Clicked on users list.\');"> ';
content += ' <li>User1</li> ';
content += ' </ul> ';
var container = $('#content');
container.empty();
container.append(content);

This can be fixed by using jQuery document fragments:

var ul = $('<ul>', { 'data-val': 'listOfNames', 'onclick': 'console.log("Clicked on users list.");' });
ul.append('<li>' + 'User1' + '</li>');
var container = $('#content');
container.empty();
container.append(ul);

 

For more information on globally killing this exception, without changing the code (not recommended), see

http://blog.jonathanchannon.com/2013/01/24/using-angularjsbackbonejs-in-windows-8-javascript-app/

It uses jQuery.isUnsafe = true; so all calls to .append and appendTo are wrapped with Microsoft’s MSApp.execUnsafeLocalFunction.

Adjusting TFS 2012 Kanban board columns (count and titles) without changing the default process template statuses.

The screencast below explains, how different teams can layout their Kanban board, without changing the default process template statuses "New", "Active", "Resolved", "Closed"

http://channel9.msdn.com/posts/Customize-your-kanban-board-columns-in-Team-Foundation-ServiceServer

 

Example

Team A (less columns, then statuses)

Backlog | Active | Done

 

Team B (more columns, then statuses)

Backlog | UAT | Development | Code Review | Test | Done

 

Because both Kanban boards use the same statuses under the covers, queries and reports can span multiple teams.