You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/09/11 01:57:44 UTC
[28/52] [abbrv] [partial] re-org
http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/samples/TestAppCordova/TestAppCordova/js/script.js
----------------------------------------------------------------------
diff --git a/samples/TestAppCordova/TestAppCordova/js/script.js b/samples/TestAppCordova/TestAppCordova/js/script.js
deleted file mode 100644
index 4b92c2e..0000000
--- a/samples/TestAppCordova/TestAppCordova/js/script.js
+++ /dev/null
@@ -1,154 +0,0 @@
-function alert(message) {
- navigator.notification.alert(message, function () { });
-};
-
-function id(elementId) {
- return document.getElementById(elementId);
-}
-
-function getGeoQuick() {
- // onSuccess Callback
- // This method accepts a `Position` object, which contains
- // the current GPS coordinates
- //
- var onSuccess = function (position) {
- id('geoLatQuick').innerText = position.coords.latitude;
- id('geoLongQuick').innerText = position.coords.longitude;
- id('geoAccQuick').innerText = position.coords.accuracy;
- id('geoAltQuick').innerText = position.coords.altitude;
- id('geoAltAccQuick').innerText = position.coords.altitudeAccuracy;
- id('geoHeadQuick').innerText = position.coords.heading;
- id('geoVelQuick').innerText = position.coords.speed;
- id('geoTimeQuick').innerText = new Date(position.timestamp);
- };
-
- // onError Callback receives a PositionError object
- //
- function onError(error) {
- alert('code: ' + error.code + '\n' +
- 'message: ' + error.message + '\n');
- }
-
- navigator.geolocation.getCurrentPosition(onSuccess, onError);
-};
-
-function getAccelQuick() {
- function onSuccess(acceleration) {
- id('accXQuick').innerText = acceleration.x;
- id('accYQuick').innerText = acceleration.y;
- id('accZQuick').innerText = acceleration.z;
- id('accTimeQuick').innerText = acceleration.timestamp;
- };
-
- function onError() {
- alert('onError!');
- };
-
- navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
-
-};
-
-function getCompQuick() {
- function onSuccess(heading) {
- id('compHeadQuick').innerText = heading.magneticHeading;
- id('compTimeQuick').innerText = new Date(heading.timestamp);
- };
-
- function onError(error) {
- alert('CompassError: ' + error.code);
- };
-
- navigator.compass.getCurrentHeading(onSuccess, onError);
-
-};
-
-
-var geoPersist = false;
-var accelPersist = false;
-var compPersist = false;
-var geoWatchID;
-var accWatchID;
-var compWatchID;
-
-function hitGeoPersist() {
- if (geoPersist) {
- geoPersist = false;
- id('btnGeoPersist').innerHTML = 'Watch Gelocation';
-
- navigator.geolocation.clearWatch(geoWatchID);
- } else {
- geoPersist = true;
- id('btnGeoPersist').innerHTML = 'Stop Gelocation';
-
- var onSuccess = function (position) {
- id('geoLatPersist').innerText = position.coords.latitude;
- id('geoLongPersist').innerText = position.coords.longitude;
- id('geoAccPersist').innerText = position.coords.accuracy;
- id('geoAltPersist').innerText = position.coords.altitude;
- id('geoAltAccPersist').innerText = position.coords.altitudeAccuracy;
- id('geoHeadPersist').innerText = position.coords.heading;
- id('geoVelPersist').innerText = position.coords.speed;
- id('geoTimePersist').innerText = new Date(position.timestamp);
- };
-
- function onError(error) {
- alert('code: ' + error.code + '\n' +
- 'message: ' + error.message + '\n');
- }
-
- geoWatchID = navigator.geolocation.watchPosition(onSuccess, onError, {frequency: 2000});
- }
-};
-
-function hitAccelPersist() {
- if (accelPersist) {
- accelPersist = false;
- id('btnAccPersist').innerHTML = 'Watch Acceleration';
-
- navigator.accelerometer.clearWatch(accWatchID);
- } else {
- accelPersist = true;
- id('btnAccPersist').innerHTML = 'Stop Acceleration';
-
- function onSuccess(acceleration) {
- id('accXPersist').innerText = acceleration.x;
- id('accYPersist').innerText = acceleration.y;
- id('accZPersist').innerText = acceleration.z;
- id('accTimePersist').innerText = acceleration.timestamp;
- };
-
- function onError() {
- alert('onError!');
- };
-
- navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
-
- accWatchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, { frequency: 100 });
- }
-
-};
-
-function hitCompPersist() {
- if (compPersist) {
- compPersist = false;
- id('btnCompPersist').innerHTML = 'Watch Compass';
-
- navigator.compass.clearWatch(compWatchID);
- } else {
- compPersist = true;
- id('btnCompPersist').innerHTML = 'Stop Compass';
-
- function onSuccess(heading) {
- id('compHeadPersist').innerText = heading.magneticHeading;
- id('compTimePersist').innerText = new Date(heading.timestamp);
- };
-
- function onError(error) {
- alert('CompassError: ' + error.code);
- };
-
- navigator.compass.getCurrentHeading(onSuccess, onError);
-
- compWatchID = navigator.compass.watchHeading(onSuccess, onError, { frequency: 100 });
- }
-};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex-async-agent.js
----------------------------------------------------------------------
diff --git a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex-async-agent.js b/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex-async-agent.js
deleted file mode 100644
index 3f25c89..0000000
--- a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex-async-agent.js
+++ /dev/null
@@ -1,75 +0,0 @@
-(function () {
- var init = function (root) {
-
- if (!root.modules || !root.modules["async"]) {
- throw new Error('Missing essential component, please initialize "async" module first.');
- }
-
- if (root.modules["async-agent"]) {
- return;
- }
-
- var Task = root.Async.Task;
-
- var Agent = function () {
- this._messages = [];
- this._tasks = [];
- }
- Agent.prototype = {
- receive: function () {
- var _this = this;
-
- return Task.create(function (t) {
- if (_this._messages.length > 0) {
- var msg = _this._messages.shift();
- t.complete("success", msg);
- } else {
- _this._tasks.push(t);
- }
- });
- },
-
- post: function (msg) {
- if (this._tasks.length > 0) {
- var t = this._tasks.shift();
- t.complete("success", msg);
- } else {
- this._messages.push(msg);
- }
- },
-
- currentQueueLength: function () {
- return this._messages.length;
- }
- };
-
- root.Async.Agent = Agent;
-
- root.modules["async-agent"] = true;
- }
-
- // CommonJS
- var isCommonJS = (typeof require === "function" && typeof module !== "undefined" && module.exports);
- // CommongJS Wrapping
- var isWrapping = (typeof define === "function" && !define.amd);
- // CommonJS AMD
- var isAmd = (typeof require === "function" && typeof define === "function" && define.amd);
-
- if (isCommonJS) {
- module.exports.init = init;
- } else if (isWrapping) {
- define("jscex-async-agent", ["jscex-async"], function (require, exports, module) {
- module.exports.init = init;
- });
- } else if (isAmd) {
- define("jscex-async-agent", ["jscex-async"], function () {
- return { init: init };
- });
- } else {
- if (typeof Jscex === "undefined") {
- throw new Error('Missing the root object, please load "jscex" module first.');
- }
-
- init(Jscex);
- }
-})();
http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex-async-include.js
----------------------------------------------------------------------
diff --git a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex-async-include.js b/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex-async-include.js
deleted file mode 100644
index a076b08..0000000
--- a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex-async-include.js
+++ /dev/null
@@ -1,63 +0,0 @@
-(function () {
-
- var init = function (root) {
- if (root.modules["async-include"]) {
- return;
- }
-
- if (!root.modules["async"]) {
- throw new Error('Missing essential components, please initialize "jscex-async" module first.');
- }
-
-
- root.modules["async-include"] = true;
-
- var Async = root.Async;
- var Task = Async.Task
- Async.include = function (path) {
- return Task.create(function (t) {
- var script = document.createElement("script");
- if(script.onload == null) {
- script.onload = function () {
- t.complete("success");
- }
- }
- else if(script.onreadystatechange == null){
- script.onreadystatechange = function () {
- if(this.readyState=='load')
- t.complete("success");
- }
- }
- script.src = path;
-
- document.getElementsByTagName("head")[0].appendChild(script);
-
- });
-
- }
- }
- // CommonJS
- var isCommonJS = (typeof require === "function" && typeof module !== "undefined" && module.exports);
- // CommongJS Wrapping
- var isWrapping = (typeof define === "function" && !define.amd);
- // CommonJS AMD
- var isAmd = (typeof require === "function" && typeof define === "function" && define.amd);
-
- if (isCommonJS) {
- module.exports.init = init;
- } else if (isWrapping) {
- define("jscex-async-include", ["jscex-async"], function (require, exports, module) {
- module.exports.init = init;
- });
- } else if (isAmd) {
- define("jscex-async-include", ["jscex-async"], function () {
- return { init: init };
- });
- } else {
- if (typeof Jscex === "undefined") {
- throw new Error('Missing the root object, please load "jscex" module first.');
- }
-
- init(Jscex);
- }
-})();
http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex.async.xhr.js
----------------------------------------------------------------------
diff --git a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex.async.xhr.js b/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex.async.xhr.js
deleted file mode 100644
index 7adc9a2..0000000
--- a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex.async.xhr.js
+++ /dev/null
@@ -1,21 +0,0 @@
-XMLHttpRequest.prototype.receiveAsync = function () {
- var _this = this;
-
- var delegate = {
- "onStart": function (callback) {
- _this.onreadystatechange = function () {
- if (_this.readyState == 4) {
- callback("success", _this.responseText);
- }
- }
-
- _this.send();
- },
-
- "onCancel": function (callback) {
- _this.abort();
- }
- };
-
- return new Jscex.Async.Task(delegate);
-}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex.seq.js
----------------------------------------------------------------------
diff --git a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex.seq.js b/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex.seq.js
deleted file mode 100644
index 86c35ba..0000000
--- a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex.seq.js
+++ /dev/null
@@ -1,70 +0,0 @@
-Jscex.Seq = { };
-
-(function () {
-
- var SeqBuilder = function () { }
-
- var Iterator = Jscex.Seq.Iterator = function (delegate) {
- this._delegate = delegate;
- }
- Iterator.prototype.moveNext = function () {
-
- var step = this._delegate();
- if (step) {
- this._delegate = step.nextDelegate;
- this.current = step.item;
- return true;
- } else {
- delete this._delegate;
- delete this.current;
- return false;
- }
- }
-
- var TempStep = null;
-
- SeqBuilder.prototype = {
- "binder": "$yield",
-
- "Start": function (_this, step) {
-
- var delegate = function () {
- TempStep = null;
- step.next(_this, function (type, value) {
- if (type == "throw") console.log(value);
- });
-
- var tempStep = TempStep;
- TempStep = null;
- return tempStep;
- }
-
- return new Jscex.Seq.Iterator(delegate);
- },
-
- "Bind": function (value, generator) {
- return {
- "next": function (_this, callback) {
- TempStep = {
- item: value,
- nextDelegate: function () {
- TempStep = null;
- generator.call(_this).next(_this, callback);
-
- var tempStep = TempStep;
- TempStep = null;
- return tempStep;
- }
- };
- }
- };
- }
- }
-
- for (var m in Jscex.builderBase) {
- SeqBuilder.prototype[m] = Jscex.builderBase[m];
- }
-
- Jscex.builders["seq"] = new SeqBuilder();
-
-})();
http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex.seq.powerpack.js
----------------------------------------------------------------------
diff --git a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex.seq.powerpack.js b/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex.seq.powerpack.js
deleted file mode 100644
index 0691005..0000000
--- a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/incubations/jscex.seq.powerpack.js
+++ /dev/null
@@ -1,61 +0,0 @@
-(function () {
-
- var filter = eval(Jscex.compile("seq", function (iter, predicate) {
- while (iter.moveNext()) {
- if (predicate(iter.current)) {
- $yield(iter.current);
- }
- }
- }));
-
- var map = eval(Jscex.compile("seq", function (iter, mapper) {
- while (iter.moveNext()) {
- $yield(mapper(iter.current));
- }
- }));
-
- var zip = eval(Jscex.compile("seq", function (iter1, iter2) {
- while (iter1.moveNext() && iter2.moveNext()) {
- $yield([iter1.current, iter2.current]);
- }
- }));
-
- var skip = eval(Jscex.compile("seq", function (iter, n) {
- for (var i = 0; i < n; i++) {
- if (!iter.moveNext()) {
- return;
- }
- }
-
- while (iter.moveNext()) {
- $yield(iter.current);
- }
- }));
-
- var take = eval(Jscex.compile("seq", function (iter, n) {
- var count = 0;
- while (iter.moveNext()) {
- if (count++ < n) {
- $yield(iter.current);
- } else {
- return;
- }
- }
- }));
-
- var each = function (iter, action) {
- while (iter.moveNext()) {
- action(iter.current);
- }
- };
-
- var p = Jscex.Seq.Iterator.prototype;
- p.filter = function (predicate) { return filter(this, predicate); }
- p.map = function (mapper) { return map(this, mapper); }
- p.zip = function (iter) { return zip(this, iter); }
- p.skip = function (n) { return skip(this, n); }
- p.take = function (n) { return take(this, n); }
- p.each = function (action) { each(this, action); }
-
-})();
-
http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/jscex-async-powerpack.js
----------------------------------------------------------------------
diff --git a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/jscex-async-powerpack.js b/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/jscex-async-powerpack.js
deleted file mode 100644
index a35c1c2..0000000
--- a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/jscex-async-powerpack.js
+++ /dev/null
@@ -1,442 +0,0 @@
-(function () {
- "use strict";
-
- var Jscex, Task, CanceledError, _;
-
- var collectCallbackArgNames = function (args) {
- if (args.length <= 1) return null;
-
- var result = [];
- for (var i = 1; i < args.length; i++) {
- result.push(args[i]);
- }
-
- return result;
- }
-
- var collectArgs = function (args, requiredArgs) {
- var result = [];
- for (var i = 0; i < args.length; i++) {
- result.push(args[i]);
- }
-
- while (result.length < requiredArgs) {
- result.push(undefined);
- }
-
- return result;
- }
-
- // Async members
-
- var AggregateErrorTypeID = "4a73efb8-c2e2-4305-a05c-72385288650a";
- var AggregateError = function (errors) {
- this.children = [];
-
- if (errors) {
- for (var i = 0; i < errors.length; i++) {
- this.children.push(errors[i]);
- }
- }
- }
- AggregateError.prototype = {
- _typeId: AggregateErrorTypeID,
- message: "This is an error contains sub-errors, please check the 'children' collection for more details.",
- isTypeOf: function (ex) {
- return ex._typeId == AggregateErrorTypeID;
- }
- }
-
- var sleep = function (delay, /* CancellationToken */ ct) {
- return Task.create(function (t) {
- if (ct && ct.isCancellationRequested) {
- t.complete("failure", new CanceledError());
- }
-
- var seed;
- var cancelHandler;
-
- if (ct) {
- cancelHandler = function () {
- clearTimeout(seed);
- t.complete("failure", new CanceledError());
- }
- }
-
- var seed = setTimeout(function () {
- if (ct) {
- ct.unregister(cancelHandler);
- }
-
- t.complete("success");
- }, delay);
-
- if (ct) {
- ct.register(cancelHandler);
- }
- });
- }
-
- var onEvent = function (target, eventName, /* CancellationToken*/ ct) {
- return Task.create(function (t) {
- if (ct && ct.isCancellationRequested) {
- t.complete("failure", new CanceledError());
- }
-
- var cleanUp = function () {
- if (target.removeEventListener) {
- target.removeEventListener(eventName, eventHandler);
- } else if (target.removeListener) {
- target.removeListener(eventName, eventHandler);
- } else {
- target.detachEvent(eventName, eventHandler);
- }
- }
-
- var eventHandler;
- var cancelHandler;
-
- if (ct) {
- cancelHandler = function () {
- cleanUp();
- t.complete("failure", new CanceledError());
- }
- }
-
- var eventHandler = function (ev) {
- if (ct) {
- ct.unregister(cancelHandler);
- }
-
- cleanUp();
- t.complete("success", ev);
- }
-
- if (target.addEventListener) {
- target.addEventListener(eventName, eventHandler);
- } else if (target.addListener) {
- target.addListener(eventName, eventHandler);
- } else {
- target.attachEvent(eventName, eventHandler);
- }
-
- if (ct) {
- ct.register(cancelHandler);
- }
- });
- }
-
- // Task members
-
- var whenAll = function () {
- var inputTasks;
-
- if (arguments.length == 1) {
- var arg = arguments[0];
-
- if (Task.isTask(arg)) { // a single task
- inputTasks = [arg];
- } else {
- inputTasks = arg;
- }
- } else {
- inputTasks = new Array(arguments.length);
- for (var i = 0; i < arguments.length; i++) {
- inputTasks[i] = arguments[i];
- }
- }
-
- return Task.create(function (taskWhenAll) {
- var taskKeys = {};
-
- _.each(inputTasks, function (key, task) {
- if (!task) return;
-
- if (!Task.isTask(task)) {
- inputTasks[key] = task = whenAll(task);
- }
-
- taskKeys[task.id] = key;
- });
-
- // start all the tasks
- _.each(taskKeys, function (id, key) {
- var task = inputTasks[key];
- if (task.status === "ready") {
- task.start();
- }
- });
-
- var done = function () {
- var results = _.isArray(inputTasks) ? new Array(inputTasks.length) : { };
- var errors = [];
-
- _.each(taskKeys, function (id, key) {
- var task = inputTasks[key];
- if (task.error) {
- errors.push(task.error);
- } else {
- results[key] = task.result;
- }
- });
-
- if (errors.length > 0) {
- taskWhenAll.complete("failure", new AggregateError(errors));
- } else {
- taskWhenAll.complete("success", results);
- }
- }
-
- var runningNumber = 0;
-
- _.each(taskKeys, function (id, key) {
- var task = inputTasks[key];
-
- if (task.status == "running") {
- runningNumber++;
-
- task.addEventListener("complete", function () {
- if (--runningNumber == 0) {
- done();
- }
- });
- }
- });
-
- if (runningNumber == 0) {
- done();
- }
- });
- };
-
- var whenAny = function () {
-
- var tasks = { };
-
- if (arguments.length == 1) {
- var arg = arguments[0];
- if (Task.isTask(arg)) {
- tasks[0] = arg;
- } else {
- tasks = arg;
- }
- } else {
- for (var i = 0; i < arguments.length; i++)
- tasks[i] = arguments[i];
- }
-
- return Task.create(function (taskWhenAny) {
- var taskKeys = {};
- for (var key in tasks) {
- if (tasks.hasOwnProperty(key)) {
- var t = tasks[key];
- if (Task.isTask(t)) {
- taskKeys[t.id] = key;
- }
- }
- }
-
- // start all the tasks
- for (var id in taskKeys) {
- var t = tasks[taskKeys[id]];
- if (t.status == "ready") {
- t.start();
- }
- }
-
- // if there's a task already failed/succeeded, then return
- for (var id in taskKeys) {
- var key = taskKeys[id];
- var t = tasks[key];
- if (t.error || t.status == "succeeded") {
- taskWhenAny.complete("success", { key: key, task: t });
- return;
- }
- }
-
- var onComplete = function (t) {
- for (var id in taskKeys) {
- tasks[taskKeys[id]].removeEventListener("complete", onComplete);
- }
-
- taskWhenAny.complete("success", { key: taskKeys[this.id], task: this });
- }
-
- // now all the tasks are in "running" status.
- for (var id in taskKeys) {
- tasks[taskKeys[id]].addEventListener("complete", onComplete);
- }
- });
- }
-
- var then = function (nextGenerator) {
- var firstTask = this;
-
- return Task.create(function (t) {
-
- var nextOnComplete = function () {
- if (this.error) {
- t.complete("failure", this.error);
- } else {
- t.complete("success", this.result);
- }
- };
-
- var processNext = function (nextTask) {
- if (nextTask.status == "ready") {
- nextTask.start();
- }
-
- if (nextTask.status == "running") {
- nextTask.addEventListener("complete", nextOnComplete);
- } else {
- nextOnComplete.call(nextTask);
- }
- };
-
- var firstOnComplete = function () {
- if (this.error) {
- return t.complete("failure", this.error);
- }
-
- var nextTask;
- try {
- nextTask = nextGenerator(this.result);
- } catch (ex) {
- return t.complete("failure", ex);
- }
-
- processNext(nextTask);
- };
-
- if (firstTask.status == "ready") {
- firstTask.start();
- }
-
- if (firstTask.status == "running") {
- firstTask.addEventListener("complete", firstOnComplete);
- } else {
- firstOnComplete.call(firstTask);
- }
- });
- };
-
- // Binding members
-
- var fromStandard = function (fn) {
- var callbackArgNames = collectCallbackArgNames(arguments);
-
- return function () {
- var _this = this;
- var args = collectArgs(arguments, fn.length - 1);
-
- return Task.create(function (t) {
- args.push(function (error, result) {
- if (error) {
- t.complete("failure", error);
- } else if (!callbackArgNames) {
- t.complete("success", result);
- } else {
- var data = {};
- for (var i = 0; i < callbackArgNames.length; i++) {
- data[callbackArgNames[i]] = arguments[i + 1];
- }
-
- return t.complete("success", data);
- }
- });
-
- fn.apply(_this, args);
- });
- };
- };
-
- var fromCallback = function (fn) {
- var callbackArgNames = collectCallbackArgNames(arguments);
-
- return function () {
- var _this = this;
- var args = collectArgs(arguments, fn.length - 1);
-
- return Task.create(function (t) {
- args.push(function (result) {
- if (callbackArgNames) {
- var data = {};
- for (var i = 0; i < callbackArgNames.length; i++) {
- data[callbackArgNames[i]] = arguments[i];
- }
-
- t.complete("success", data);
- } else {
- t.complete("success", result);
- }
- });
-
- fn.apply(_this, args);
- });
- };
- };
-
- // CommonJS
- var isCommonJS = !!(typeof require === "function" && typeof module !== "undefined" && module.exports);
- // CommonJS AMD
- var isAmd = !!(typeof require === "function" && typeof define === "function" && define.amd);
-
- var defineModule = function () {
- Jscex.define({
- name: "async-powerpack",
- version: "0.6.5",
- exports: isCommonJS && module.exports,
- require: isCommonJS && require,
- dependencies: { async: "~0.6.5" },
- init: function () {
-
- _ = Jscex._;
- Task = Jscex.Async.Task;
- CanceledError = Jscex.Async.CanceledError;
-
- var Async = Jscex.Async;
- Async.sleep = sleep;
- Async.onEvent = onEvent;
- Async.AggregateError = AggregateError;
-
- Task.whenAll = whenAll;
- Task.whenAny = whenAny;
- Task.prototype.then = Task.prototype.continueWith = then;
-
- if (!Async.Binding) {
- Async.Binding = {};
- }
-
- var Binding = Async.Binding;
- Async.Jscexify = Binding;
-
- Binding.fromStandard = fromStandard;
- Binding.fromCallback = fromCallback;
- }
- });
- }
-
- if (isCommonJS) {
- try {
- Jscex = require("./jscex");
- } catch (ex) {
- Jscex = require("jscex");
- }
-
- defineModule();
- } else if (isAmd) {
- require(["jscex"], function (jscex) {
- Jscex = jscex;
- defineModule();
- });
- } else {
- var Fn = Function, global = Fn('return this')();
- if (!global.Jscex) {
- throw new Error('Missing the root object, please load "jscex" component first.');
- }
-
- Jscex = global.Jscex;
- defineModule();
- }
-})();
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/jscex-async.js
----------------------------------------------------------------------
diff --git a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/jscex-async.js b/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/jscex-async.js
deleted file mode 100644
index 50a6779..0000000
--- a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/jscex-async.js
+++ /dev/null
@@ -1,283 +0,0 @@
-(function () {
- "use strict";
-
- var Jscex;
-
- var CanceledErrorTypeID = "670a1076-712b-4edd-9b70-64b152fe1cd9";
- var isCanceledError = function (ex) { return ex._typeId == CanceledErrorTypeID; }
- var CanceledError = function () { }
- CanceledError.prototype = {
- isTypeOf: isCanceledError,
- _typeId: CanceledErrorTypeID,
- message: "The task has been cancelled."
- }
-
- var Fn = Function, global = Fn('return this')();
-
- // seed defined in global
- if (global.__jscex__async__taskIdSeed === undefined) {
- global.__jscex__async__taskIdSeed = 0;
- }
-
- var isTask = function (t) {
- return (typeof t.start === "function") && (typeof t.addEventListener) === "function" && (typeof t.removeEventListener) === "function" && (typeof t.complete) === "function";
- }
-
- var CancellationToken = function () { }
- CancellationToken.prototype = {
- register: function (handler) {
- if (this.isCancellationRequested) {
- handler();
- }
-
- if (!this._handlers) {
- this._handlers = [];
- }
-
- this._handlers.push(handler);
- },
-
- unregister: function (handler) {
- if (!this._handlers) {
- return;
- }
-
- var index = this._handlers.indexOf(handler);
- if (index >= 0) {
- this._handlers.splice(index, 1);
- }
- },
-
- cancel: function () {
- if (this.isCancellationRequested) {
- return;
- }
-
- this.isCancellationRequested = true;
-
- var handlers = this._handlers;
- delete this._handlers;
-
- for (var i = 0; i < handlers.length; i++) {
- try {
- handlers[i]();
- } catch (ex) {
- Jscex.logger.warn("[WARNING] Cancellation handler threw an error: " + ex);
- }
- }
- },
-
- throwIfCancellationRequested: function () {
- if (this.isCancellationRequested) {
- throw new CanceledError();
- }
- }
- };
-
- var Task = function (delegate) {
- this.id = (++__jscex__async__taskIdSeed);
- this._delegate = delegate;
- this._listeners = { };
- this.status = "ready";
- }
- Task.prototype = {
- start: function () {
- if (this.status != "ready") {
- throw new Error('Task can only be started in "ready" status.');
- }
-
- this.status = "running";
- this._delegate(this);
-
- return this;
- },
-
- complete: function (type, value) {
- if (this.status != "running") {
- throw new Error('The "complete" method can only be called in "running" status.');
- }
-
- var listeners = this._listeners;
- delete this._listeners;
-
- if (type == "success") {
-
- this.result = value;
- this.status = "succeeded";
- this._notify("success", listeners["success"]);
-
- } else if (type == "failure") {
-
- this.error = value;
-
- if (isCanceledError(value)) {
- this.status = "canceled";
- } else {
- this.status = "faulted";
- }
-
- this._notify("failure", listeners["failure"]);
-
- } else {
- throw new Error("Unsupported type: " + type);
- }
-
- this._notify("complete", listeners["complete"]);
-
- if (this.error && !listeners["failure"] && !listeners["complete"]) {
- Jscex.logger.warn("[WARNING] An unhandled error occurred: " + this.error);
- }
- },
-
- _notify: function (ev, listeners) {
- if (!listeners) {
- return;
- }
-
- for (var i = 0; i < listeners.length; i++) {
- listeners[i].call(this);
- }
- },
-
- addEventListener: function (ev, listener) {
- if (!this._listeners) {
- return this;
- }
-
- if (!this._listeners[ev]) {
- this._listeners[ev] = [];
- }
-
- this._listeners[ev].push(listener);
- return this;
- },
-
- removeEventListener: function (ev, listener) {
- if (!this._listeners) {
- return this;
- }
-
- var evListeners = this._listeners[ev];
- if (!evListeners) return this;
-
- var index = evListeners.indexOf(listener);
- if (index >= 0) {
- evListeners.splice(index, 1);
- }
-
- return this;
- }
- };
-
- Task.create = function (delegate) {
- return new Task(delegate);
- }
-
- Task.isTask = isTask;
-
- var AsyncBuilder = function () { }
- AsyncBuilder.prototype = {
- Start: function (_this, task) {
- return Task.create(function (t) {
- task.next(_this, function (type, value, target) {
- if (type == "normal" || type == "return") {
- t.complete("success", value);
- } else if (type == "throw") {
- t.complete("failure", value);
- } else {
- throw new Error("Unsupported type: " + type);
- }
- });
- });
- },
-
- Bind: function (task, generator) {
- return {
- next: function (_this, callback) {
-
- var onComplete = function (t) {
- if (this.error) {
- callback("throw", this.error);
- } else {
- var nextTask;
- try {
- nextTask = generator.call(_this, this.result);
- } catch (ex) {
- callback("throw", ex);
- return;
- }
-
- nextTask.next(_this, callback);
- }
- }
-
- if (task.status == "ready") {
- task.addEventListener("complete", onComplete);
- task.start();
- } else if (task.status == "running") {
- task.addEventListener("complete", onComplete);
- } else {
- onComplete(task);
- }
- }
- };
- }
- }
-
- // CommonJS
- var isCommonJS = !!(typeof require === "function" && typeof module !== "undefined" && module.exports);
- // CommonJS AMD
- var isAmd = !!(typeof require === "function" && typeof define === "function" && define.amd);
-
- var defineModule = function () {
- Jscex.define({
- name: "async",
- version: "0.6.5",
- exports: isCommonJS && module.exports,
- require: isCommonJS && require,
- autoloads: [ "builderbase" ],
- dependencies: { builderbase: "~0.6.5" },
- init: function () {
-
- Jscex._.each(Jscex.BuilderBase.prototype, function (m, fn) {
- AsyncBuilder.prototype[m] = fn;
- });
-
- if (!Jscex.Async) {
- Jscex.Async = {};
- }
-
- var Async = Jscex.Async;
- Async.CancellationToken = CancellationToken;
- Async.CanceledError = CanceledError;
- Async.Task = Task;
- Async.AsyncBuilder = AsyncBuilder;
-
- Jscex.binders["async"] = "$await";
- Jscex.builders["async"] = new AsyncBuilder();
- }
- });
- }
-
- if (isCommonJS) {
- try {
- Jscex = require("./jscex");
- } catch (ex) {
- Jscex = require("jscex");
- }
-
- defineModule();
- } else if (isAmd) {
- require(["jscex"], function (jscex) {
- Jscex = jscex;
- defineModule();
- });
- } else {
- if (!global.Jscex) {
- throw new Error('Missing the root object, please load "jscex" component first.');
- }
-
- Jscex = global.Jscex;
- defineModule();
- }
-})();
http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/03bf0cde/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/jscex-builderbase.js
----------------------------------------------------------------------
diff --git a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/jscex-builderbase.js b/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/jscex-builderbase.js
deleted file mode 100644
index 41f6e5d..0000000
--- a/samples/TestAppCordova/TestAppCordova/lib/Jscex/src/jscex-builderbase.js
+++ /dev/null
@@ -1,334 +0,0 @@
-(function () {
- "use strict";
-
- var BuilderBase = function () { }
- BuilderBase.prototype = {
- For: function (condition, update, body) {
- return {
- next: function (_this, callback) {
-
- var loop = function (skipUpdate) {
- try {
- if (update && !skipUpdate) {
- update.call(_this);
- }
-
- if (!condition || condition.call(_this)) {
- body.next(_this, function (type, value, target) {
- if (type == "normal" || type == "continue") {
- loop(false);
- } else if (type == "throw" || type == "return") {
- callback(type, value);
- } else if (type == "break") {
- callback("normal");
- } else {
- throw new Error('Invalid type for "Loop": ' + type);
- }
- });
- } else {
- callback("normal");
- }
- } catch (ex) {
- callback("throw", ex);
- }
- }
-
- loop(true);
- }
- };
- },
-
- ForIn: function (obj, bodyGenerator) {
- return {
- next: function (_this, callback) {
-
- var keys = [];
- for (var k in obj) {
- keys.push(k);
- }
-
- var loop = function (i) {
- try {
- if (i < keys.length) {
- var body = bodyGenerator(keys[i]);
- body.next(_this, function (type, value, target) {
- if (type == "normal" || type == "continue") {
- loop(i + 1);
- } else if (type == "throw" || type == "return") {
- callback(type, value);
- } else if (type == "break") {
- callback("normal");
- } else {
- throw new Error('Invalid type for "Loop": ' + type);
- }
- });
- } else {
- callback("normal");
- }
- } catch (ex) {
- callback("throw", ex);
- }
- }
-
- loop(0);
- }
- };
- },
-
- While: function (condition, body) {
- return {
- next: function (_this, callback) {
- var loop = function () {
- try {
- if (condition.call(_this)) {
- body.next(_this, function (type, value, target) {
- if (type == "normal" || type == "continue") {
- loop();
- } else if (type == "throw" || type == "return") {
- callback(type, value);
- } else if (type == "break") {
- callback("normal");
- } else {
- throw new Error('Invalid type for "Loop": ' + type);
- }
- });
- } else {
- callback("normal");
- }
- } catch (ex) {
- callback("throw", ex);
- }
- }
-
- loop();
- }
- };
- },
-
- Do: function (body, condition) {
- return {
- next: function (_this, callback) {
-
- var loop = function () {
- body.next(_this, function (type, value, target) {
- if (type == "normal" || type == "continue") {
- try {
- if (condition.call(_this)) {
- loop();
- } else {
- callback("normal");
- }
- } catch (ex) {
- callback("throw", ex);
- }
- } else if (type == "throw" || type == "return") {
- callback(type, value);
- } else if (type == "break") {
- callback("normal");
- } else {
- throw new Error('Invalid type for "Loop": ' + type);
- }
- });
- };
-
- loop();
- }
- };
- },
-
- Delay: function (generator) {
- return {
- next: function (_this, callback) {
- try {
- var step = generator.call(_this);
- step.next(_this, callback);
- } catch (ex) {
- callback("throw", ex);
- }
- }
- };
- },
-
- Combine: function (s1, s2) {
- return {
- next: function (_this, callback) {
- s1.next(_this, function (type, value, target) {
- if (type == "normal") {
- try {
- s2.next(_this, callback);
- } catch (ex) {
- callback("throw", ex);
- }
- } else {
- callback(type, value, target);
- }
- });
- }
- };
- },
-
- Return: function (result) {
- return {
- next: function (_this, callback) {
- callback("return", result);
- }
- };
- },
-
- Normal: function () {
- return {
- next: function (_this, callback) {
- callback("normal");
- }
- };
- },
-
- Break: function () {
- return {
- next: function (_this, callback) {
- callback("break");
- }
- };
- },
-
- Continue: function () {
- return {
- next: function (_this, callback) {
- callback("continue");
- }
- };
- },
-
- Throw: function (ex) {
- return {
- next: function (_this, callback) {
- callback("throw", ex);
- }
- };
- },
-
- Try: function (tryTask, catchGenerator, finallyStep) {
- return {
- next: function (_this, callback) {
- tryTask.next(_this, function (type, value, target) {
- if (type != "throw" || !catchGenerator) {
- if (!finallyStep) {
- callback(type, value, target);
- } else {
- finallyStep.next(_this, function (finallyType, finallyValue, finallyTarget) {
- if (finallyType == "normal") {
- callback(type, value, target);
- } else {
- callback(finallyType, finallyValue, finallyTarget);
- }
- });
- }
- } else {
-
- if (catchGenerator) {
-
- var catchTask;
- try {
- catchTask = catchGenerator.call(_this, value);
- } catch (ex) {
- if (finallyStep) {
- finallyStep.next(_this, function (finallyType, finallyValue, finallyTarget) {
- if (finallyType == "normal") {
- callback("throw", ex);
- } else {
- callback(finallyType, finallyValue, finallyTarget);
- }
- });
- } else {
- callback("throw", ex);
- }
- }
-
- if (catchTask) {
- catchTask.next(_this, function (catchType, catchValue, catchTarget) {
- if (catchType == "throw") {
- if (finallyStep) {
- finallyStep.next(_this, function (finallyType, finallyValue, finallyTarget) {
- if (finallyType == "normal") {
- callback(catchType, catchValue, catchTarget);
- } else {
- callback(finallyType, finallyValue, finallyTarget);
- }
- });
- } else {
- callback(catchType, catchValue, catchTarget);
- }
- } else {
- if (finallyStep) {
- finallyStep.next(_this, function (finallyType, finallyValue, finallyTarget) {
- if (finallyType == "normal") {
- callback(catchType, catchValue, catchTarget);
- } else {
- callback(finallyType, finallyValue, finallyTarget);
- }
- });
- } else {
- callback(catchType, catchValue, catchTarget);
- }
- }
- });
- }
- } else {
- finallyStep.next(_this, function (finallyType, finallyValue, finallyTarget) {
- if (finallyType == "normal") {
- callback(type, value, target);
- } else {
- callback(finallyType, finallyValue, finallyTarget);
- }
- });
- }
- }
- });
- }
- };
- }
- }
-
- // CommonJS
- var isCommonJS = !!(typeof require === "function" && typeof module !== "undefined" && module.exports);
- // CommonJS AMD
- var isAmd = !!(typeof require === "function" && typeof define === "function" && define.amd);
-
- var Jscex;
-
- var defineModule = function () {
- Jscex.define({
- name: "builderbase",
- version: "0.6.5",
- exports: isCommonJS && module.exports,
- require: isCommonJS && require,
- coreDependency: "~0.6.5",
- init: function () {
- Jscex.BuilderBase = BuilderBase;
- }
- });
- }
-
- if (isCommonJS) {
- try {
- Jscex = require("./jscex");
- } catch (ex) {
- Jscex = require("jscex");
- }
-
- defineModule();
- } else if (isAmd) {
- require(["jscex"], function (jscex) {
- Jscex = jscex;
- defineModule();
- });
- } else {
- var Fn = Function, global = Fn('return this')();
- if (!global.Jscex) {
- throw new Error('Missing the root object, please load "jscex" component first.');
- }
-
- Jscex = global.Jscex;
- defineModule();
- }
-})();
\ No newline at end of file