Debugging apps sample code (JavaScript)
The code in this topic is the sample file for Quickstart: Debugging apps (JavaScript). The errors present by design in the QuickStart are fixed in this version of the code.
Sample Code
The following HTML code is used in the <body> tag in the QuickStart.
<div id="flipTemplate" data-win-control="WinJS.Binding.Template"
style="display:none">
<div class="fixedItem" >
<img data-win-bind="src: flipImg" />
</div>
</div>
<div id="fView" style="width:100%;height:100%;background-color:#0094ff"
data-win-control="WinJS.UI.FlipView" data-win-options= "{
itemDataSource: pages.dataSource, itemTemplate: flipTemplate }" >
</div>
The following code example shows the complete JavaScript code in default.js. The references to WinJS namespaces for this code are in the template’s default.html file.
(function () {
"use strict";
var app = WinJS.Application;
var activation = Windows.ApplicationModel.Activation;
var myData = [];
for (var x = 0; x < 4; x++) {
myData[x] = { flipImg: "/images/logo.png" }
};
var pages = new WinJS.Binding.List(myData, { proxy: true });
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
if (args.detail.previousExecutionState !==
activation.ApplicationExecutionState.terminated) {
// TODO: . . .
} else {
// TODO: . . .
}
args.setPromise(WinJS.UI.processAll());
updateImages();
}
};
function updateImages() {
pages.push(0, { flipImg: "https://go.microsoft.com/fwlink/?LinkID=223195" });
pages.push(1, { flipImg: "https://go.microsoft.com/fwlink/?LinkID=223196" });
pages.push(2, { flipImg: "https://go.microsoft.com/fwlink/?LinkID=223197" });
};
app.oncheckpoint = function (args) {
};
app.start();
var publicMembers = {
items: pages
};
WinJS.Namespace.define("Data", publicMembers);
})();