Introduction
Before moving further, let us look at the previous articles of the series
- Voice of a Developer: JavaScript Data Types - Part One
- Voice of a Developer: JavaScript Objects - Part Two
- Voice of a Developer: JavaScript Engines - Part Three
- Voice of a Developer: JavaScript Common Mistakes - Part Four
- Voice of a Developer: Editors - Part Five
- Voice of a Developer: VSCode - Part Six
- Voice of a Developer: Debugging Capabilities of VSCode - Part Seven
- Voice of a Developer: JavaScript OOP - Part Eight
- Voice of a Developer: JavaScript Useful Reserved Keywords - Part Nine
- Voice of a Developer: JavaScript Functions - Part Ten
- Voice of a Developer: JavaScript Functions Invocations - Part Eleven
- Voice of a Developer: JavaScript Anonymous Functions - Part Twelve
- Voice of a Developer: JavaScript Pure And Impure Function - Part Thirteen
- Voice of a Developer: JavaScript Closures - Part Fourteen
- Voice of a Developer: JavaScript Currying - Part Fifteen
- Voice of a Developer: JavaScript Chaining - Part Sixteen
- Voice of a Developer: JavaScript Array Methods - Part Seventeen
- Voice of a Developer: JavaScript ECMAScript 6 - Part Eighteen
- Voice of a Developer: JavaScript ECMAScript 6 Features v1 - Part Nineteen
- Voice of a Developer: JavaScript ECMAScript 6 Features v2 - Part Twenty
- Voice of a Developer: JavaScript Web Workers - Part Twenty One
- Voice of a Developer: JavaScript JSLint v1 - Part Twenty-Two
- Voice of a Developer: JavaScript JSLint v2 - Part Twenty Three
- Voice of a Developer: XMLHttpRequest API - Part Twenty Four
- Voice of a Developer: Web Storage API - Part Twenty-Five
- Voice of a Developer: Application Cache API - Part Twenty-Six
- Voice of a Developer: Javascript WebSocket - Part Twenty-Seven
- Voice of a Developer: Parse JSON - Part Twenty-Eight
- Voice of a Developer: Save Coding Time With Lodash.js - Part Twenty Nine
- Voice of a Developer: ChakraCore JavaScript Engine by Microsoft - Part Thirty
- Voice of a Developer: JavaScript Web App Performance Best Practices - Part 31
- Voice of a Developer: ECMAScript Promises - Part Thirty-Two
- Voice of a Developer: Browser Runtime - Part Thirty-Three
- Voice of A Developer: JavaScript Unit Test - Part Thirty-Four
- Voice Of A Developer: Decoupling Your Application - Part Thirty-Five
JavaScript
JavaScript is a language of the Web. This series of articles will talk about my observations learned during my decade of software development experience with JavaScript, and what mistakes a developer generally makes and what differences they should be aware of.
WinJS is a Windows library for JavaScript. WinJS provides the controls. You need to make your app professional, equipped with the modern UI controls and include JS, CSS, and HTML all in one place. It is an open-source library by Microsoft and the source code is available at GitHub.
WinJS contains the standard implementation of Win 8 controls which aren’t covered by HTML5. It makes it possible to add Windows UI controls in HTML such as:

What’s the use of WinJS?
- AppBar
- DatePicker
- FlipView
- Flyout
- ListView
- Rating
- SemanticZoom
- TimePicker
- ToggleSwitch
- Tooltip
- ViewBoxand many more…
I found these controls pretty cool as it enhances your webApp UI experience. Microsoft developed this for a universal experience across Win 8 and HTML apps, where you can add WinJS.
WinJS provides support to the three popular JavaScript frameworks via adapters. These are:
Which frameworks are supported by WinJS?
- Angular
- React
- Knockout
What is an adapter?
Create your first WinJS application
Setup basic AngularJS webapp
- Go to command prompt, type YO and it will show you the list of installed generators.



- Now, fire YO commands again and create a project using the “Angular” generator and it will prompt multiple options. Hence, select accordingly.

- Now, you are done with your basic scaffold Application.
- Run the basic Application, using GRUNT command. The default port on which it runs is 9000.
Output
- Go to the directory and the basic structure is ready for you.

Add WinJS in your application
- Download WinJS from GIT.
- Refer to CDN.
- Use command prompt tools npm, bower [I prefer this way].
- Fire the commands shown below in your WebApp console location.
npm install winjsbower install winjsThis will install WinJS files under the app\bower_components folder.
- As I mentioned earlier, we’ll add the AngularJS adapter, hence, fire the command shown below:
bower install angularjs-winjs
Goto directory app\bower_components and see the folder structure, shown below:

- Modify below files as
index.html: For our WebApp, we shall include all the relevant WinJS and the adapter files:The index.html will be transformed, as shown below:
- <script src="bower_components/angular/angular.js"></script>
- <script src="bower_components/angular-route/angular-route.js"></script>
- <script src="bower_components/winjs/js/base.js"></script>
- <script src="bower_components/winjs/js/ui.js"></script>
- <script src="bower_components/angular-winjs/js/angular-winjs.js"></script>
- <link href="bower_components/winjs/css/ui-dark.css" rel="stylesheet" />
- <!doctype html>
- <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
- <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
- <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
- <!--[if gt IE 8]><!-->
- <html class="no-js">
- <!--<![endif]-->
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title></title>
- <meta name="description" content="">
- <meta name="viewport" content="width=device-width">
- <!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
- <!-- build:css(.tmp) styles/main.css -->
- <link rel="stylesheet" href="styles/main.css">
- <!-- endbuild -->
- </head>
- <body ng-app="NewAppApp">
- <!--[if lt IE 7]>
- <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
- <![endif]-->
- <!--[if lt IE 9]>
- <script src="bower_components/es5-shim/es5-shim.js"></script>
- <script src="bower_components/json3/lib/json3.min.js"></script>
- <![endif]-->
- <!-- Add your site or application content here -->
- <div class="container" ng-view=""></div>
- <!-- Google Analytics: change UA-XXXXX-X to be your site's ID -->
- <script>
- (function(i, s, o, g, r, a, m)
- {
- i['GoogleAnalyticsObject'] = r;
- i[r] = i[r] || function()
- {
- (i[r].q = i[r].q || []).push(arguments)
- }, i[r].l = 1 * new Date();
- a = s.createElement(o),
- m = s.getElementsByTagName(o)[0];
- a.async = 1;
- a.src = g;
- m.parentNode.insertBefore(a, m)
- })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
- ga('create', 'UA-XXXXX-X');
- ga('send', 'pageview');
- </script>
- <script src="bower_components/angular/angular.js"></script>
- <script src="bower_components/angular-route/angular-route.js"></script>
- <script src="bower_components/winjs/js/base.js"></script>
- <script src="bower_components/winjs/js/ui.js"></script>
- <script src="bower_components/angular-winjs/js/angular-winjs.js"></script>
- <link href="bower_components/winjs/css/ui-dark.css" rel="stylesheet" />
- <!-- build:js({.tmp,app}) scripts/scripts.js -->
- <script src="scripts/app.js"></script>
- <script src="scripts/controllers/main.js"></script>
- <!-- endbuild -->
- </body>
- </html>
App.js: We know this is the starting file of AngularJS and we shall include WinJS module dependency, as shown below:- 'use strict';
- angular.module('NewAppApp', ['winjs', 'ngRoute'])
- .config(function($routeProvider)
- {
- $routeProvider
- .when('/',
- {
- templateUrl: 'views/main.html',
- controller: 'MainCtrl'
- })
- .otherwise
- ({
- redirectTo: '/'
- });
- });
Main.html: Modify main.html file and include the directive win-rating, as shown below:- <win-rating max-rating="maxRating" user-rating="rating"></win-rating>
- <div>
- <h2 class="win-h2">Rating: {{rating}}</h2>
- <input class="win-slider" type="range" min="1" max="{{maxRating}}" ng-model="rating" />
- </div>
- <div>
- <h2 class="win-h2">Maximum Rating: {{maxRating}}</h2>
- <input class="win-slider" type="range" min="1" max="50" ng-model="maxRating" />
- </div>
Main.js: In above main.html, we are using two variable, “rating” and “maxRating,” and we can initialize their value in MainCtrl (controller),- 'use strict';
- angular.module('NewAppApp')
- .controller('MainCtrl', function($scope)
- {
- $scope.rating = 1;
- $scope.maxRating = 5;
- });
Output
See that the “win-rating” directive has added stars according to the value of the slider.
You can download the code shown above from my GitHub Repository.
Note: Once you clone, please don’t forget to run “node install” and “bower install” commands.
There are many other such Win 8 controls which you can try:
- win-date-picker: Add below code in “main.html” and date control will show up,
Output
- <win-date-picker current="date" on-change="dateChanged()"></win-date-picker>

- win-date-picker: Add the code shown below in “main.html” and click the button to see flyout effect.
- <button id="flyoutAnchor">Flyout!</button>
- <win-flyout anchor="'#flyoutAnchor'">Happy coding!</win-flyout>
Output
- win-time-picker: Add the code generated below in “main.html” and see time control.
Output
- <win-time-picker current="time"></win-time-picker>

There are many other nice controls available and you can do a lot to enhance your UI experience.
If you would like to try using WinJS without installing the above stuff, you can go to two playgrounds.
Playground
Test the various samples that are provided. For example,
Please try the GitHub code and samples given above. I appreciate your feedback.

Santhakumar MunuswamyPosted Jun 25, 2016, 2:31 AM
Nice share
Guest UserPosted Jun 17, 2016, 6:46 AM
Thanks guys! please help me to understand, what more topics are you interested to read ...
Vignesh ManiPosted Jun 17, 2016, 5:17 AM
Nice
RajaPosted Jun 17, 2016, 12:48 AM
Good One..
Debasis SahaPosted Jun 17, 2016, 12:46 AM
Nice one..
Thiruppathi RPosted Jun 16, 2016, 11:05 PM
Nice info..