You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/10/24 03:55:50 UTC
[11/21] Many tweaks. Moved dirs.
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah/views/add.html
----------------------------------------------------------------------
diff --git a/www/cdvah/views/add.html b/www/cdvah/views/add.html
new file mode 100644
index 0000000..b0c2e9b
--- /dev/null
+++ b/www/cdvah/views/add.html
@@ -0,0 +1,30 @@
+<form name="addForm" ng-controller="AddCtrl" ng-submit="addApp()">
+ <label>How to retrieve the app:<br>
+ <select ng-model="appData.installerType">
+ <option value="serve">cordova serve</option>
+ <option value="cdvh">.cdvh file</option>
+ </select>
+ </label>
+ <div ng-show="appData.installerType == 'serve'">
+ <label>Enter server URL
+ <div><input class="topcoat-text-input" style="width:100%;-webkit-box-sizing:border-box" type="text" ng-model="appData.appUrl" autocorrect="off" autocapitalize="off"></div>
+ </label>
+ <button class="topcoat-button" ng-click="fetchQR(appData, 'appUrl')" ng-show="qr_enabled">QR Code</button>
+ <select ng-model="appData.serveTemplateValue" ng-change="selectTemplate()">
+ <option value="">Template</option>
+ <option value="localhost:8000">localhost</option>
+ <option value="KEY.t.proxylocal.com">ProxyLocal</option>
+ <option value="KEY.localtunnel.com">LocalTunnel</option>
+ </select>
+ </div>
+ <div ng-show="appData.installerType == 'cdvh'">
+ <label>Enter URL<br>
+ <input class="topcoat-text-input" type="text" ng-model="appData.appUrl" autocorrect="off" autocapitalize="off">
+ </label>
+ <button class="topcoat-button" ng-click="fetchQR(appData, 'appUrl')" ng-show="qr_enabled">Scan QR Code</button><br>
+ </div>
+ <div class="buttons">
+ <input type="submit" value="Add" class="topcoat-button--cta"></button>
+ <a href="#/"><button class="topcoat-button" ng-click="back()">Back</button></a>
+ </div>
+</form>
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah/views/list.html
----------------------------------------------------------------------
diff --git a/www/cdvah/views/list.html b/www/cdvah/views/list.html
new file mode 100644
index 0000000..ca82771
--- /dev/null
+++ b/www/cdvah/views/list.html
@@ -0,0 +1,19 @@
+<div class="topcoat-list__container">
+ <h3 class="topcoat-list__header">Installed Apps</h3>
+ <ul class="topcoat-list">
+ <li class="topcoat-list__item" ng-repeat="app in appList">
+ <div>{{app.appId}}</div>
+ <div>{{app.url}}</div>
+ <div ng-show="app.updatingStatus === null">Last updated: {{app.lastUpdated || 'never'}}</div>
+ <div ng-show="app.updatingStatus !== null">Update in progress: {{app.updatingStatus}}%</div>
+ <button ng-click="launchApp(app)">Launch</button>
+ <button ng-click="updateApp(app)">Update</button>
+ <button ng-click="removeApp(app)">Remove</button>
+ </li>
+ </ul>
+</div>
+<br />
+<div class="buttons">
+ <a href="#/add"><button class="topcoat-button--cta">Add app</button></a>
+ <button class="topcoat-button" ng-click="loadAppsList()">Reload</button>
+</div>
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_contextMenu.html
----------------------------------------------------------------------
diff --git a/www/cdvah_contextMenu.html b/www/cdvah_contextMenu.html
deleted file mode 100644
index c00aacb..0000000
--- a/www/cdvah_contextMenu.html
+++ /dev/null
@@ -1,93 +0,0 @@
-<!DOCTYPE html>
-<html onclick="parent.postMessage('ContextMenuHide', '*');">
-<head>
- <style>
- body
- {
- background-color:rgba(0,0,0,0.75);
- width: 100%;
- height: 100%;
- }
- p, label
- {
- color: white;
- text-align: center;
- }
- ul
- {
- list-style-type: none;
- margin-left: 20%;
- margin-right: 20%;
- padding: 0;
- width: 60%;
- }
- li
- {
- margin-bottom: 0.5cm;
- width : 100%;
- min-height: 1cm;
- border-bottom: 1px solid grey;
- }
- .fullwidthElement
- {
- width: 100%;
- min-height: 1cm;
- }
- .halfwidthElement
- {
- min-height: 1cm;
- width: 48%;
- padding-left: 0;
- padding-right: 0;
- }
- </style>
- <script type="text/javascript">
- var currentWeinreName;
-
- function updateWeinreName(){
- var newName = document.getElementById("WeinreName").value;
- if(newName !== currentWeinreName){
- var el = document.getElementById("WeinreLink");
- var newVal = "http://debug.phonegap.com/client/#" + newName;
- el.href = newVal;
- el.innerText = newVal;
- parent.postMessage("ContextMenuWeinre:" + newName, "*");
- currentWeinreName = newName;
- }
- }
-
- // Set up listener for incoming messages
- window.addEventListener("message", function(e){
- if(e.data.indexOf("AppHarnessAppName:") === 0){
- var appName = e.data.substring("AppHarnessAppName:".length);
- document.getElementById("WeinreName").value = appName;
- }
- } , false);
- </script>
-</head>
-<body>
- <p>Tap Anywhere to Close</p>
- <ul>
- <li>
- <button class="fullwidthElement" onclick="parent.postMessage('ContextMenuUpdate', '*');">Update</button>
- </li>
- <li>
- <button class="fullwidthElement" onclick="parent.postMessage('ContextMenuRestart', '*');">Restart</button>
- </li>
- <li>
- <button class="fullwidthElement" onclick="parent.postMessage('ContextMenuFirebug', '*');">Firebug</button>
- </li>
- <li>
- <label for="WeinreName"><p>Phonegap Weinre</p></label>
- <br />
- <input class="halfwidthElement" id="WeinreName" type="text" value="default" onclick="event.stopPropagation();" />
- <button class="halfwidthElement" onclick="updateWeinreName();">Add PhoneGap Weinre Link</button>
- <br />
- <a href="http://debug.phonegap.com/client/#default"><p id="WeinreLink"></p></a>
- </li>
- <li>
- <button class="fullwidthElement" onclick="parent.postMessage('ContextMenuMainMenu', '*');">Back to Main Menu</button>
- </li>
- </ul>
-</body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_index.html
----------------------------------------------------------------------
diff --git a/www/cdvah_index.html b/www/cdvah_index.html
deleted file mode 100644
index 313c3b8..0000000
--- a/www/cdvah_index.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <title>Cordova App Harness</title>
- <script type="text/javascript" src="cordova.js"></script>
- <script type="text/javascript" src="cdvah_js/libs/q.min.js"></script>
- <script type="text/javascript" src="cdvah_js/libs/angular.js"></script>
- <script type="text/javascript" src="cdvah_js/libs/angular-route.js"></script>
- <script type="text/javascript" src="cdvah_js/app.js"></script>
- <script type="text/javascript" src="cdvah_js/ContextMenuInjectScript.js"></script>
- <script type="text/javascript" src="cdvah_js/Installer.js"></script>
- <script type="text/javascript" src="cdvah_js/ServeInstaller.js"></script>
- <script type="text/javascript" src="cdvah_js/ResourcesLoader.js"></script>
- <script type="text/javascript" src="cdvah_js/AppsService.js"></script>
- <script type="text/javascript" src="cdvah_js/AppBundleAlias.js"></script>
- <script type="text/javascript" src="cdvah_js/ListCtrl.js"></script>
- <script type="text/javascript" src="cdvah_js/AddCtrl.js"></script>
- <script type="text/javascript" src="cdvah_js/Notify.js"></script>
- <link rel="stylesheet" type="text/css" href="css/topcoat-mobile-light.min.css" />
- <link rel="stylesheet" type="text/css" href="css/style.css" />
- <script>alert(1)</script>
- </head>
- <body>
- <div class="topcoat-navigation-bar">
- <div class="topcoat-navigation-bar__item center full">
- <h1 class="topcoat-navigation-bar__title">{{ appTitle }}</h1>
- </div>
- </div>
-
- <cdvah-notify></cdvah-notify>
-
- <div ng-view></div>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_js/AddCtrl.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/AddCtrl.js b/www/cdvah_js/AddCtrl.js
deleted file mode 100644
index 2066ca5..0000000
--- a/www/cdvah_js/AddCtrl.js
+++ /dev/null
@@ -1,48 +0,0 @@
-(function(){
- "use strict";
- /* global myApp */
- myApp.controller("AddCtrl", ["notifier", "$rootScope", "$scope", "$window", "AppsService", function (notifier, $rootScope, $scope, $window, AppsService) {
-
- $rootScope.appTitle = 'Add App';
-
- $scope.appData = {
- appUrl : 'localhost',
- installerType: 'serve'
- };
-
- $scope.addApp = function() {
- var serviceCall = AppsService.addApp($scope.appData.installerType, $scope.appData.appUrl);
-
- serviceCall.then(function(handler) {
- console.log('successfully installed');
- notifier.success('Successfully installed');
- return AppsService.updateApp(handler);
- }, function(error) {
- console.error(error);
- notifier.error('Unable to add application because: ' + error.message);
- });
- };
-
- // True if the optional barcodescanner plugin is installed.
- $scope.qr_enabled = !!(cordova.plugins && cordova.plugins.barcodeScanner);
-
- // Scans a QR code, placing the URL into the currently selected of source and pattern.
- $scope.fetchQR = function() {
- console.log('calling');
- $window.cordova.plugins.barcodeScanner.scan(function(result) {
- console.log('success');
- if (!result || result.cancelled || !result.text) {
- notifier.error('No QR code received.');
- } else {
- $scope.appData.appUrl = result.text;
- notifier.success('QR code received');
- $scope.$apply();
- }
- },
- function(error) {
- console.log('error: ' + error);
- notifier.error('Error retrieving QR code: ' + error);
- });
- };
- }]);
-})();
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_js/AppBundleAlias.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/AppBundleAlias.js b/www/cdvah_js/AppBundleAlias.js
deleted file mode 100644
index a06b1d4..0000000
--- a/www/cdvah_js/AppBundleAlias.js
+++ /dev/null
@@ -1,51 +0,0 @@
-(function() {
- "use strict";
- /* global myApp */
- myApp.factory("AppBundle", ['$q', '$window', function($q, $window) {
-
- // URI aliasing : the ability to launch an app in the harness, query the document.location and get the same location as would have been got if you run the app separately
- // Without URI aliasing, document.location in the harness would give something like file:///APP_HARNESS_INSTALLED_APPS_LOCATION/www/index.html
-
- function aliasUri(sourceUriMatchRegex, sourceUriReplaceRegex, replaceString, redirectToReplacedUrl){
- var deferred = $q.defer();
- cordova.plugins.appBundle.addAlias(sourceUriMatchRegex, sourceUriReplaceRegex, replaceString, redirectToReplacedUrl, function(succeded) {
- if (succeded){
- deferred.resolve();
- } else {
- deferred.reject(new Error("Unable to set up uri aliasing"));
- }
- });
- return deferred.promise;
- }
-
- function setResetUrl(url) {
- var deferred = $q.defer();
- cordova.plugins.appBundle.setResetUrl(url, deferred.resolve);
- return deferred.promise;
- }
-
- function injectJsForUrl(url, js) {
- var deferred = $q.defer();
- cordova.plugins.appBundle.injectJsForUrl(url, js, deferred.resolve);
- return deferred.promise;
- }
-
- function reset() {
- var deferred = $q.defer();
- cordova.plugins.appBundle.clearAllAliases(deferred.resolve);
- return deferred.promise;
- }
-
- function escapeRegExp(str) {
- return str.replace(/[-\[\]\/{}()*+?.\\^$|]/g, '\\$&');
- }
-
- return {
- aliasUri: aliasUri,
- reset: reset,
- setResetUrl: setResetUrl,
- injectJsForUrl: injectJsForUrl
- };
-
- }]);
-})();
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_js/AppsService.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/AppsService.js b/www/cdvah_js/AppsService.js
deleted file mode 100644
index 6b14e08..0000000
--- a/www/cdvah_js/AppsService.js
+++ /dev/null
@@ -1,126 +0,0 @@
-(function() {
- "use strict";
- /* global myApp */
- myApp.factory("AppsService", ["$q", "ResourcesLoader", "INSTALL_DIRECTORY", "APPS_JSON", function($q, ResourcesLoader, INSTALL_DIRECTORY, APPS_JSON) {
-
- var platformId = cordova.platformId;
- // Map of type -> installer.
- var _installerFactories = {};
-
- var _installers = null;
- var _lastLaunchedAppId = null;
-
- function createInstallHandlersFromJson(json) {
- var appList = json['appList'] || [];
- var ret = [];
- for (var i = 0, entry; entry = appList[i]; ++i) {
- var factory = _installerFactories[entry['appType']];
- var installer = factory.createFromJson(entry['appUrl'], entry['appId']);
- installer.lastUpdated = entry['lastUpdated'] && new Date(entry['lastUpdated']);
- installer.installPath = entry['installPath'];
- ret.push(installer);
- }
- return ret;
- }
-
- function readAppsJson() {
- var deferred = $q.defer();
- ResourcesLoader.readJSONFileContents(APPS_JSON)
- .then(function(result) {
- deferred.resolve(result);
- }, function() {
- // Error means first run.
- deferred.resolve({});
- });
- return deferred.promise;
- }
-
- function initHandlers() {
- if (_installers) {
- return $q.when();
- }
-
- return readAppsJson()
- .then(function(appsJson) {
- _lastLaunchedAppId = appsJson['lastLaunched'];
- _installers = createInstallHandlersFromJson(appsJson);
- });
- }
-
- function writeAppsJson() {
- var appsJson = {
- 'lastLaunched': _lastLaunchedAppId,
- 'appList': []
- };
- var appList = appsJson['appList'];
- for (var i = 0, installer; installer = _installers[i]; ++i) {
- appList.push({
- 'appId' : installer.appId,
- 'appType' : installer.type,
- 'appUrl' : installer.url,
- 'lastUpdated': installer.lastUpdated && +installer.lastUpdated,
- 'installPath': installer.installPath
- });
- }
-
- var stringContents = JSON.stringify(appsJson);
- return ResourcesLoader.writeFileContents(APPS_JSON, stringContents);
- }
-
- return {
- // return promise with the array of apps
- getAppList : function() {
- return initHandlers()
- .then(function() {
- return _installers.slice();
- });
- },
-
- launchApp : function(installer) {
- _lastLaunchedAppId = installer.appId;
- return writeAppsJson()
- .then(function() {
- var installPath = INSTALL_DIRECTORY + '/' + installer.appId;
- return installer.launch(installPath);
- })
- .then(function(launchUrl) {
- window.location = launchUrl;
- });
- },
-
- addApp : function(installerType, appUrl) {
- var installerFactory = _installerFactories[installerType];
- return installerFactory.createFromUrl(appUrl)
- .then(function(installer) {
- _installers.push(installer);
- return writeAppsJson()
- .then(function() {
- return installer;
- });
- });
- },
-
- uninstallApp : function(installer) {
- return installer.deleteFiles()
- .then(function() {
- _installers.splice(_installers.indexOf(installer), 1);
- return writeAppsJson()
- });
- },
-
- getLastRunApp : function() {
- throw new Error('Not implemented.');
- },
-
- updateApp : function(installer){
- var installPath = INSTALL_DIRECTORY + '/' + installer.appId;
- return installer.updateApp(installPath)
- .then(writeAppsJson);
- },
-
- registerInstallerFactory : function(installerFactory) {
- _installerFactories[installerFactory.type] = installerFactory;
- }
- };
- }]);
-})();
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_js/CdvhPackageHandler.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/CdvhPackageHandler.js b/www/cdvah_js/CdvhPackageHandler.js
deleted file mode 100644
index a37ba86..0000000
--- a/www/cdvah_js/CdvhPackageHandler.js
+++ /dev/null
@@ -1,52 +0,0 @@
-(function(){
- "use strict";
- /* global myApp */
- myApp.run(["$q", "AppsService", "ResourcesLoader", "ContextMenuInjectScript", function($q, AppsService, ResourcesLoader, ContextMenuInjectScript){
-
- var platformId = cordova.require("cordova/platform").id;
-
- function copyFile(startUrl, targetLocation){
- /************ Begin Work around for File system bug ************/
- if(targetLocation.indexOf("file://") === 0) {
- targetLocation = targetLocation.substring("file://".length);
- }
- /************ End Work around for File system bug **************/
- return ResourcesLoader.xhrGet(startUrl)
- .then(function(xhr){
- return ResourcesLoader.ensureDirectoryExists(targetLocation)
- .then(function(){
- return ResourcesLoader.writeFileContents(targetLocation, xhr.responseText);
- });
- });
- }
-
- AppsService.registerPackageHandler("cdvh", {
- extractPackageToDirectory : function (appName, fileName, outputDirectory){
- var dataToAppend = ContextMenuInjectScript.getInjectString(appName);
- var platformDirectory = outputDirectory + "/" + platformId + "/www/";
- var cordovaFile = platformDirectory + "cordova.js";
- var pluginsFile = platformDirectory + "cordova_plugins.js";
-
- // We need to
- // 1) Modify the cordova.js file
- // 2) Copy the cordova_plugins.json we have, as the app that is being installed may have other plugins included which aren't in the harness.
- // If we allow unavailable plugins to be included in this file, the plugin initialiser breaks
- return ResourcesLoader.extractZipFile(fileName, outputDirectory)
- .then(function(){
- return ResourcesLoader.doesFileExist(cordovaFile);
- })
- .then(function(fileExists){
- if(fileExists){
- return $q.all([
- ResourcesLoader.appendFileContents(cordovaFile, dataToAppend),
- copyFile("app-bundle:///cdvh_files/www/cordova_plugins.js", pluginsFile)
- ]);
- } else {
- throw new Error("The package does not seem to have the files required for the platform: " + platformId);
- }
- });
- }
- });
-
- }]);
-})();
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_js/ContextMenu.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/ContextMenu.js b/www/cdvah_js/ContextMenu.js
deleted file mode 100644
index 12d20ae..0000000
--- a/www/cdvah_js/ContextMenu.js
+++ /dev/null
@@ -1,123 +0,0 @@
-(function () {
-
- function initialise() {
- setupIframe();
- sendAppNameToIframe();
- setupIframeMessaging();
- //loadFirebug(false);
- attachErrorListener();
- }
-
- var contextMenuIframe = "__cordovaappharness_contextMenu_iframe";
- function setupIframe(){
- var contextHTMLUrl = "app-bundle:///cdvah_contextMenu.html";
- var el = document.createElement("iframe");
- el.setAttribute("id", contextMenuIframe);
- el.setAttribute("src", contextHTMLUrl);
- el.setAttribute("style", "position: fixed; left : 0px; top : 0px; z-index: 2000; width: 100%; height: 100%; display : none;");
- document.body.appendChild(el);
- // Setup the listeners to toggle the context menu
- document.addEventListener("touchmove", function (event) {
- if(event.touches.length >= 3) {
- document.getElementById(contextMenuIframe).style.display = "inline";
- }
- }, false);
- }
-
- function sendAppNameToIframe(){
- if(window.__cordovaAppHarnessAppName){
- var el = document.getElementById(contextMenuIframe);
- el.onload = function(){
- el.contentWindow.postMessage("AppHarnessAppName:" + window.__cordovaAppHarnessAppName, "*");
- };
- }
- }
-
- function onContextMenuUpdateClicked(){
- window.location = "app-bundle:///cdvah_index.html#/?updateLastLaunched=true";
- }
- function onContextMenuRestartClicked(){
- window.location = "app-bundle:///cdvah_index.html#/?lastLaunched=true";
- }
- var firebugFirstOpen = true;
- function onContextMenuFirebugClicked(){
- try {
- if(firebugFirstOpen){
- console.warn("Note that messages logged to the console at the app startup may not be visible here.");
- console.warn("Do not use the close button on Firebug. Your console logs will be cleared. Use minimize instead.");
- firebugFirstOpen = false;
- }
- window.Firebug.chrome.open();
- } catch(e) {
- // hack - FirebugLite appears to have several bugs. One of which is - open firebug, user shuts down FirebugLite through the UI.
- // FirebugLite is now in a bad state of neither being usable or removable. Any calls to open throw an error.
- // The following lines removes the flags that FirebugLite looks for manually and makes it think it has not loaded it yet
- // Then FirebugLite is loaded into the page again
- // This hack should be revisited when FirebugLite moves from version 1.4
- // Either the hack won't be needed anymore or the hack should be checked too see if it still works.
- var el = document.getElementById("FirebugLite");
- if(el) {
- el.setAttribute("id", "");
- }
- delete console.firebuglite;
- loadFirebug(true);
- }
- }
- function onContextMenuMainMenuClicked(){
- window.location = "app-bundle:///cdvah_index.html";
- }
- function onContextMenuHideClicked(){
- document.getElementById(contextMenuIframe).style.display = "none";
- }
- function onContextMenuWeinreNameChanged(newName){
- var el = document.createElement("script");
- el.setAttribute("src", "http://debug.phonegap.com/target/target-script-min.js#" + newName);
- document.head.appendChild(el);
- }
-
- var messageHandler = {
- "ContextMenuUpdate" : onContextMenuUpdateClicked,
- "ContextMenuRestart" : onContextMenuRestartClicked,
- "ContextMenuFirebug" : onContextMenuFirebugClicked,
- "ContextMenuMainMenu" : onContextMenuMainMenuClicked,
- "ContextMenuHide" : onContextMenuHideClicked,
- "ContextMenuWeinre" : onContextMenuWeinreNameChanged
- };
- function setupIframeMessaging(){
- window.addEventListener("message", function(e){
- if (!e || !e.data || typeof e.data !== 'string') {
- return;
- }
-
- var messageParts = [ e.data ];
- var loc = e.data.indexOf(":");
- if(loc !== -1){
- messageParts = [ e.data.substring(0, loc),
- e.data.substring(loc + 1)
- ];
- }
- if(messageHandler[messageParts[0]]){
- messageHandler[messageParts[0]](messageParts[1]);
- }
- } , false);
- }
-
- function loadFirebug(startOpened){
- var el = document.createElement("script");
- el.setAttribute("id", "FirebugLite");
- el.setAttribute("src", "https://getfirebug.com/firebug-lite-beta.js");
- el.setAttribute("FirebugLite", "4");
- el.innerHTML = el.innerHTML = "{ debug : false, startOpened : " + startOpened + ", showIconWhenHidden : false, saveCommandLineHistory : true, saveCookies : false }";
- document.head.appendChild(el);
- }
-
- // FirebugLite doesn't catch errors from window.onerror like desktop browser's dev tools do. So we add it manually.
- function attachErrorListener(){
- window.onerror = function(msg, url, line) {
- console.error("Error: " + msg + " on line: " + line + " in file: " + url);
- };
- }
-
- initialise();
-})();
-
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_js/ContextMenuInjectScript.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/ContextMenuInjectScript.js b/www/cdvah_js/ContextMenuInjectScript.js
deleted file mode 100644
index 4ff261e..0000000
--- a/www/cdvah_js/ContextMenuInjectScript.js
+++ /dev/null
@@ -1,23 +0,0 @@
-(function() {
- "use strict";
- /* global myApp */
- myApp.factory("ContextMenuInjectScript", [ function () {
- var toInject = function() {
- document.addEventListener('deviceready', function() {
- console.log("Injecting menu script");
- var contextScript = document.createElement("script");
- contextScript.setAttribute("src", "app-bundle:///ContextMenu.js");
- window.__cordovaAppHarnessAppName = "appPlaceHolder";
- document.getElementsByTagName("head")[0].appendChild(contextScript);
- });
- };
-
- return {
- getInjectString : function(appName){
- var string = "\n(" + toInject.toString() + ")();";
- string = string.replace("appPlaceHolder", appName);
- return string;
- }
- };
- }]);
-})();
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_js/CrxPackageHandler.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/CrxPackageHandler.js b/www/cdvah_js/CrxPackageHandler.js
deleted file mode 100644
index 5ac73c4..0000000
--- a/www/cdvah_js/CrxPackageHandler.js
+++ /dev/null
@@ -1,64 +0,0 @@
-(function(){
- "use strict";
- /* global myApp */
- myApp.run(["$q", "AppsService", "ResourcesLoader", "ContextMenuInjectScript", function($q, AppsService, ResourcesLoader, ContextMenuInjectScript){
-
- var platformId = cordova.require("cordova/platform").id;
-
- function copyFile(startUrl, targetLocation){
- /************ Begin Work around for File system bug ************/
- if(targetLocation.indexOf("file://") === 0) {
- targetLocation = targetLocation.substring("file://".length);
- }
- /************ End Work around for File system bug **************/
- return ResourcesLoader.xhrGet(startUrl)
- .then(function(xhr){
- return ResourcesLoader.ensureDirectoryExists(targetLocation)
- .then(function(){
- return ResourcesLoader.writeFileContents(targetLocation, xhr.responseText);
- });
- });
- }
-
- AppsService.registerPackageHandler("crx", {
- extractPackageToDirectory : function (appName, fileName, outputDirectory){
- console.log('extracting the crx');
- var dataToAppend = ContextMenuInjectScript.getInjectString(appName);
- var platformDirectory = outputDirectory + "/" + platformId + "/";
- var platformWWWDirectory = platformDirectory + "www/";
- var cordovaFile = platformWWWDirectory + "cordova.js";
-
- // We need to
- // 1) Copy over the files required to convert a crx to a normal web app
- // 2) Modify the cordova.js file
- return ResourcesLoader.extractZipFile(fileName, platformWWWDirectory)
- .then(function(){
- var plugins = cordova.require('cordova/plugin_list');
- if (!plugins) {
- throw new Error('Error loading cordova_plugins.json');
- }
-
- var copies = [
- copyFile("app-bundle:///cordova.js", cordovaFile),
- copyFile("app-bundle:///crx_files/config." + platformId + ".xml", platformDirectory + "config.xml"),
- copyFile("app-bundle:///cordova_plugins.js", platformWWWDirectory + "cordova_plugins.js"),
- copyFile("app-bundle:///chromeapp.html", platformWWWDirectory + "chromeapp.html"),
- copyFile("app-bundle:///chromeappstyles.css", platformWWWDirectory + "chromeappstyles.css"),
- copyFile("app-bundle:///chromebgpage.html", platformWWWDirectory + "chromebgpage.html"),
- copyFile("app-bundle:///cdvah_js/ContextMenu.js", platformWWWDirectory + "ContextMenu.js")
- ];
-
- for(var i = 0; i < plugins.length; i++) {
- console.log('copying ' + plugins[i].file);
- copies.push(copyFile("app-bundle:///" + plugins[i].file, platformWWWDirectory + plugins[i].file));
- }
-
- return $q.all(copies);
- })
- .then(function(){
- return ResourcesLoader.appendFileContents(cordovaFile, dataToAppend);
- });
- }
- });
- }]);
-})();
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_js/Installer.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/Installer.js b/www/cdvah_js/Installer.js
deleted file mode 100644
index 9aff2de..0000000
--- a/www/cdvah_js/Installer.js
+++ /dev/null
@@ -1,96 +0,0 @@
-(function(){
- "use strict";
- /* global myApp */
- myApp.factory("Installer", ["$q", "AppBundle", "ResourcesLoader", "ContextMenuInjectScript", function($q, AppBundle, ResourcesLoader, ContextMenuInjectScript) {
-
- function getAppStartPageFromConfig(configFile) {
- return ResourcesLoader.readFileContents(configFile)
- .then(function(contents) {
- if(!contents) {
- throw new Error("Config file is empty. Unable to find a start page for your app.");
- } else {
- var startLocation = 'index.html';
- var parser = new DOMParser();
- var xmlDoc = parser.parseFromString(contents, "text/xml");
- var els = xmlDoc.getElementsByTagName("content");
-
- if(els.length > 0) {
- // go through all "content" elements looking for the "src" attribute in reverse order
- for(var i = els.length - 1; i >= 0; i--) {
- var el = els[i];
- var srcValue = el.getAttribute("src");
- if (srcValue) {
- startLocation = srcValue;
- break;
- }
- }
- }
-
- return startLocation;
- }
- });
- }
-
- function Installer(url, appId) {
- this.url = url;
- this.appId = appId || '';
- this.lastUpdated = null;
- this.installPath = null;
- }
-
- Installer.prototype.type = '';
-
- Installer.prototype.updateApp = function(installPath) {
- this.installPath = installPath;
- this.lastUpdated = new Date();
- };
-
- Installer.prototype.deleteFiles = function() {
- this.lastUpdated = null;
- if (this.installPath) {
- return ResourcesLoader.deleteDirectory(this.installPath);
- }
- return $q.when();
- };
-
- Installer.prototype.launch = function() {
- var installPath = this.installPath;
- if (!installPath) {
- throw new Error('App ' + this.appId + ' requires an update');
- }
- var configLocation = installPath + '/config.xml';
-
- return getAppStartPageFromConfig(configLocation)
- .then(function(rawStartLocation) {
- var harnessUrl = cordova.require('cordova/urlutil').makeAbsolute(location.pathname);
- var harnessDir = harnessUrl.replace(/\/[^\/]*$/, '');
- var installUrl = cordova.require('cordova/urlutil').makeAbsolute(installPath);
- var injectString = ContextMenuInjectScript.getInjectString();
- // Inject the context menu script for all pages except the harness menu.
- AppBundle.injectJsForUrl('^(?!' + harnessUrl + ')', injectString);
- // Allow navigations back to the menu.
- AppBundle.setResetUrl('^' + harnessUrl);
- // Make any references to www/ point to the app's install location.
- AppBundle.aliasUri('^' + harnessDir, '^' + harnessDir, installUrl + '/www', false /* redirect */);
- // Override cordova.js and cordova_plugins.js.
- AppBundle.aliasUri('/cordova\\.js.*', '.+', harnessDir + '/cordova.js', false /* redirect */);
- AppBundle.aliasUri('/cordova_plugins\\.js.*', '.+', harnessDir + '/cordova_plugins.js', false /* redirect */);
- // Set-up app-bundle: scheme to point at the harness.
- AppBundle.aliasUri('^app-bundle:///cdvah_index.html', '^app-bundle://', harnessDir, true);
- return AppBundle.aliasUri('^app-bundle:', '^app-bundle://', harnessDir, false)
- .then(function() {
- var startLocation = cordova.require('cordova/urlutil').makeAbsolute(rawStartLocation);
- // On iOS, file:// URLs can't be re-routed via an NSURLProtocol for top-level navications.
- // http://stackoverflow.com/questions/12058203/using-a-custom-nsurlprotocol-on-ios-for-file-urls-causes-frame-load-interrup
- // The work-around (using loadData:) breaks history.back().
- // So, for file:// start pages, we just point to the install location.
- if (cordova.platformId == 'ios') {
- return startLocation.replace(harnessDir, installUrl + '/www')
- }
- return startLocation;
- });
- });
- };
- return Installer;
- }]);
-})();
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_js/ListCtrl.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/ListCtrl.js b/www/cdvah_js/ListCtrl.js
deleted file mode 100644
index 2144fd1..0000000
--- a/www/cdvah_js/ListCtrl.js
+++ /dev/null
@@ -1,100 +0,0 @@
-(function(){
- "use strict";
- /* global myApp */
- myApp.controller("ListCtrl", [ "AppBundle", "notifier", "$rootScope", "$scope", "$routeParams", "AppsService", function (AppBundle, notifier, $rootScope, $scope, $routeParams, AppsService) {
- $scope.appList = [];
- $rootScope.appTitle = 'Cordova App Harness';
-
- initialise();
-
- function initialise() {
- //if we are navigating here after running an app, reset any aliases set for the app by app harness or any aliases setup by the previous app
- return AppBundle.reset()
- .then(function(){
- if($routeParams.lastLaunched) {
- return AppsService.getLastRunApp()
- .then(AppsService.launchApp, function(e){
- e = e || {};
- console.error("Error launching last run app: " + e);
- notifier.error('' + e);
- });
- }
- else if($routeParams.updateLastLaunched) {
- var app;
- // updating may take a while so we show the apps list like we normally do
- return $scope.loadAppsList(true)
- .then(AppsService.getLastRunApp)
- .then(function(_app){
- app = _app;
- return AppsService.updateApp(app);
- })
- .then(function(){
- return AppsService.launchApp(app);
- }, function(e){
- e = e || {};
- console.error("Error updating last run app: " + e);
- notifier.error('' + e);
- });
- }
- else {
- return $scope.loadAppsList(true);
- }
- });
- }
-
- $scope.loadAppsList = function(callApply) {
- return AppsService.getAppList()
- .then(function(newAppsList){
- newAppsList.sort(function(a, b){
- if (a.appId < b.appId) {
- return -1;
- } else if(a.appId > b.appId) {
- return 1;
- }
- return 0;
- });
- $scope.appList = newAppsList;
- if(callApply) {
- $scope.$apply();
- }
- }, function(error){
- var str = "There was an error retrieving the apps list";
- console.error(str + ": " + error);
- notifier.error('' + error);
- });
- };
-
- $scope.launchApp = function(app){
- return AppsService.launchApp(app)
- .then(null, function(error){
- console.error("Error during loading of app " + app.appId + ": " + error);
- notifier.error('' + error);
- });
- };
-
- $scope.updateApp = function(app) {
- return AppsService.updateApp(app)
- .then(function(){
- notifier.success("Updated successfully");
- console.log('successfully updated');
- }, function(error){
- console.error("Error during updating of app " + app.appId + ": " + error);
- notifier.error('' + error);
- });
- };
-
- $scope.removeApp = function(app) {
- var shouldUninstall = confirm("Are you sure you want to uninstall " + app.appId + "?");
- if(shouldUninstall) {
- return AppsService.uninstallApp(app)
- .then(function() { $scope.loadAppsList(true); },
- function(error) {
- console.error(error);
- notifier.error('' + error);
- });
- }
- }
- }]);
-})();
-
-
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_js/Notify.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/Notify.js b/www/cdvah_js/Notify.js
deleted file mode 100644
index e76dc4b..0000000
--- a/www/cdvah_js/Notify.js
+++ /dev/null
@@ -1,36 +0,0 @@
-(function() {
- "use strict";
- /* global myApp */
- myApp.directive("cdvahNotify", [ "$rootScope", "$timeout", function($rootScope, $timeout) {
- return {
- scope: {},
- restrict: 'E',
- template: '<div class="notification-container" ng-show="showNotify"><div class="notification" ng-class="notification.css">{{ notification.message }}</div></div>',
- replace: true,
- link: function(scope, element, attrs) {
- $rootScope.$watch('notification', function(newValue) {
- scope.showNotify = !!newValue;
- if (newValue) {
- scope.notification = {};
- scope.notification.message = newValue.message;
- scope.notification.css = 'notification-' + newValue.type;
- }
- });
- }
- };
- }]);
-
- myApp.factory('notifier', ['$rootScope', function($rootScope) {
- return {
- success: function(msg) {
- $rootScope.notification = { message: msg, type: 'success' };
- $rootScope.$apply();
- },
- error: function(msg) {
- $rootScope.notification = { message: msg, type: 'error' };
- $rootScope.$apply();
- }
- };
- }]);
-})();
-
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_js/ResourcesLoader.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/ResourcesLoader.js b/www/cdvah_js/ResourcesLoader.js
deleted file mode 100644
index 34fdbc8..0000000
--- a/www/cdvah_js/ResourcesLoader.js
+++ /dev/null
@@ -1,321 +0,0 @@
-(function() {
- "use strict";
-
- /* global myApp */
- myApp.factory("ResourcesLoader", ["$q", "$window", function($q, $window) {
- var rootDir;
-
- function initialiseFileSystem() {
- // HACK: Need to discuss better way to get the root entry.
- return $q.when(rootDir = new $window.DirectoryEntry('/', '/'));
- }
-
- //promise returns full path to downloaded file
- function downloadFromUrl(url, fullFilePath) {
- var deferred = $q.defer();
-
- var downloadFail = function(error) {
- var str = "There was an error while downloading the file " + JSON.stringify(error);
- deferred.reject(new Error(str));
- };
-
- var downloadSuccess = function(fileEntry) {
- deferred.resolve(fileEntry.fullPath);
- };
-
- var fileTransfer = new $window.FileTransfer();
- fileTransfer.download(url, fullFilePath, downloadSuccess, downloadFail);
- return deferred.promise;
- }
-
- function trim(str) {
- return str && str.replace(/^\s+|\s+$/g, "");
- }
-
- function fixFilePath(path) {
- if(path && path.indexOf("file://") === 0) {
- path = path.substring("file://".length);
- }
- return path;
- }
-
- function getScheme(uri){
- var ret = uri.match(/^[a-z0-9+.-]+(?=:)/);
- if(!ret){
- return;
- }
- return ret[0];
- }
-
- //promise returns the directory entry
- function getDirectoryEntry(directoryName) {
- var deferred = $q.defer();
-
- var errorWhileGettingDirectoryEntry = function(error) {
- var str = "There was an error while getting the directory entry for directory " + directoryName + " " + JSON.stringify(error);
- deferred.reject(new Error(str));
- };
- var success = function(directoryEntry) {
- deferred.resolve(directoryEntry);
- };
- rootDir.getDirectory(directoryName, {create: true, exclusive: false}, success, errorWhileGettingDirectoryEntry);
- return deferred.promise;
- }
-
- //promise returns the file entry
- function getFileEntry(fileName, createFlag) {
- var deferred = $q.defer();
-
- var errorWhileGettingFileEntry = function(error) {
- var str = "There was an error while getting the file entry for file " + fileName + " " + JSON.stringify(error);
- deferred.reject(new Error(str));
- };
- var success = function(fileEntry) {
- deferred.resolve(fileEntry);
- };
- // !! - ensures a boolean value
- rootDir.getFile(fixFilePath(fileName), {create: !!createFlag, exclusive: false}, success, errorWhileGettingFileEntry);
- return deferred.promise;
- }
-
- //promise returns the file
- function getFile(fileName) {
- return getFileEntry(fileName, true /* create */).
- then(function(fileEntry){
- var deferred = $q.defer();
-
- var errorWhileGettingFile = function(error) {
- var str = "There was an error while getting the file for file " + fileName + " " + JSON.stringify(error);
- deferred.reject(new Error(str));
- };
-
- fileEntry.file(deferred.resolve, errorWhileGettingFile);
- return deferred.promise;
- });
- }
-
- function truncateToDirectoryPath(path) {
- return path.replace(/\/[^\/]+$/, '/');
- }
-
- function getPathSegments(path){
- //truncate leading and trailing slashes
- if(path.charAt(0) === "/"){
- path = path.substring(1);
- }
- if(path.charAt(path.length - 1) === "/"){
- path = path.substring(0, path.length - 1);
- }
- var segments = path.split("/");
- return segments;
- }
-
- function ensureSingleDirectoryExists(directory){
- var deferred = $q.defer();
-
- var gotDirEntry = function(dirEntry) {
- deferred.resolve(dirEntry.fullPath);
- };
-
- var failedToGetDirEntry = function(error) {
- var str = "There was an error checking the directory: " + directory + " " + JSON.stringify(error);
- deferred.reject(new Error(str));
- };
-
- rootDir.getDirectory(directory, {create: true, exclusive: false}, gotDirEntry, failedToGetDirEntry);
- return deferred.promise;
- }
-
- function ensureDirectoryExists(directory){
- directory = truncateToDirectoryPath(directory);
- directory = fixFilePath(directory);
- var segments = getPathSegments(directory);
- var currentDir = directory.charAt(0) === "/"? "/" : "";
- var promiseArr = [];
- while(segments.length !== 0) {
- currentDir += segments.shift() + "/";
- promiseArr.push(ensureSingleDirectoryExists(currentDir));
- }
- return $q.all(promiseArr)
- .then(function(paths){
- return paths[paths.length - 1];
- });
- }
-
- function writeToFile(fileName, contents, append) {
- return getFileEntry(fileName, true)
- .then(function(fileEntry){
- var deferred = $q.defer();
-
- var errorGettingFileWriter = function(error) {
- var str = "There was an error writing the file." + JSON.stringify(error);
- deferred.reject(new Error(str));
- };
-
- var gotFileWriter = function(writer) {
- writer.onwrite = deferred.resolve;
- writer.onerror = function(evt) {
- deferred.reject(new Error(evt));
- };
- if(append){
- writer.seek(writer.length);
- }
- writer.write(contents);
- };
- fileEntry.createWriter(gotFileWriter, errorGettingFileWriter);
- return deferred.promise;
- });
- }
-
- function xhrGet(url){
- var deferred = $q.defer();
- var xhr = new XMLHttpRequest();
- xhr.onreadystatechange = function() {
- if (xhr.readyState === 4) {
- if(xhr.status === 200) {
- deferred.resolve(xhr);
- } else {
- deferred.reject(new Error("XHR return status: " + xhr.status + " for url: " + url));
- }
- }
- };
- xhr.open("GET", url, true);
- xhr.send();
- return deferred.promise;
- }
-
- return {
- doesFileExist : function(fileName){
- return initialiseFileSystem()
- .then(function(){
- return getFileEntry(fileName, false /* create */);
- })
- .then(function(){
- return true;
- }, function(){
- return false;
- });
- },
-
- // returns a promise with a full path to the dir
- ensureDirectoryExists : function(directory) {
- return initialiseFileSystem()
- .then(function(){
- return ensureDirectoryExists(directory);
- });
- },
-
- // returns a promise with a full path to the downloaded file
- downloadFromUrl : downloadFromUrl,
-
- //returns a promise with the contents of the file
- readFileContents : function(fileName) {
- var scheme = getScheme(fileName);
- // assume file scheme by default
- if (!scheme || scheme === "file") {
- return initialiseFileSystem()
- .then(function(){
- return getFile(fileName);
- })
- .then(function(file){
- var deferred = $q.defer();
-
- var reader = new $window.FileReader();
- reader.onload = function(evt) {
- var text = evt.target.result;
- deferred.resolve(text);
- };
- reader.onerror = function(evt) {
- deferred.reject(new Error(evt));
- };
- reader.readAsText(file);
-
- return deferred.promise;
- });
- } else if(scheme === "http" || scheme === "https") {
- return xhrGet(fileName)
- .then(function(xhr){
- return xhr.responseText;
- });
- }
- throw new Error("Cannot read file " + fileName);
- },
-
- //returns a promise with the json contents of the file
- readJSONFileContents : function(fileName) {
- return this.readFileContents(fileName)
- .then(function (text) {
- text = trim(text);
- var resultJson = {};
- if(text) {
- resultJson = JSON.parse(text);
- }
- return resultJson;
- });
- },
-
- //returns a promise when file is written
- writeFileContents : function(fileName, contents) {
- return initialiseFileSystem()
- .then(function(){
- var scheme = getScheme(fileName);
- // assume file scheme by default
- if(!scheme || scheme === "file") {
- return writeToFile(fileName, contents, false /* append */);
- } else {
- throw new Error("Cannot write to " + fileName);
- }
- });
- },
-
- //returns a promise when file is appended
- appendFileContents : function(fileName, contents) {
- return initialiseFileSystem()
- .then(function(){
- return writeToFile(fileName, contents, true /* append */);
- });
- },
-
- deleteDirectory : function(directoryName) {
- return initialiseFileSystem()
- .then(function(){
- return getDirectoryEntry(directoryName);
- })
- .then(function(dirEntry){
- var deferred = $q.defer();
- var failedToDeleteDirectory = function(error) {
- var str = "There was an error deleting the directory: " + directoryName + " " + JSON.stringify(error);
- deferred.reject(new Error(str));
- };
- dirEntry.removeRecursively(deferred.resolve, failedToDeleteDirectory);
- return deferred.promise;
- });
- },
-
- extractZipFile : function(fileName, outputDirectory){
- return initialiseFileSystem()
- .then(function(){
- return ensureDirectoryExists(outputDirectory);
- })
- .then(function(){
- var deferred = $q.defer();
-
- var onZipDone = function(returnCode) {
- if(returnCode !== 0) {
- deferred.reject(new Error("Something went wrong during the unzipping of: " + fileName));
- } else {
- deferred.resolve();
- }
- };
-
- /* global zip */
- zip.unzip(fileName, outputDirectory, onZipDone);
- return deferred.promise;
- });
- },
-
- xhrGet : xhrGet
- };
- }]);
-
-})();
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_js/ServeInstaller.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/ServeInstaller.js b/www/cdvah_js/ServeInstaller.js
deleted file mode 100644
index 4cbb7f9..0000000
--- a/www/cdvah_js/ServeInstaller.js
+++ /dev/null
@@ -1,87 +0,0 @@
-(function(){
- "use strict";
- /* global myApp */
- myApp.run(["Installer", "AppsService", "ResourcesLoader", function(Installer, AppsService, ResourcesLoader) {
- var platformId = cordova.platformId;
-
- function ServeInstaller(url, appId) {
- Installer.call(this, url, appId);
- this._cachedProjectJson = null;
- this._cachedConfigXml = null;
- }
- ServeInstaller.prototype = Object.create(Installer.prototype);
-
- ServeInstaller.prototype.type = 'serve';
-
- ServeInstaller.prototype._updateAppMeta = function() {
- var self = this;
- return ResourcesLoader.xhrGet(this.url + '/' + platformId + '/project.json')
- .then(function(xhr) {
- self._cachedProjectJson = JSON.parse(xhr.responseText);
- return ResourcesLoader.xhrGet(self.url + self._cachedProjectJson['configPath']);
- })
- .then(function(xhr) {
- self._cachedConfigXml = xhr.responseText;
- var configXml = new DOMParser().parseFromString(self._cachedConfigXml, 'text/xml');
- self.appId = configXml.firstChild.getAttribute('id');
- });
- };
-
- // TODO: update should be more atomic. Maybe download to a new directory?
- ServeInstaller.prototype.updateApp = function(installPath) {
- var self = this;
- return this._updateAppMeta()
- .then(function() {
- var wwwPath = self._cachedProjectJson['wwwPath'];
- var files = self._cachedProjectJson['wwwFileList'];
- var i = 0;
- function downloadNext() {
- // Don't download cordova.js. We want to use the version bundled with the harness.
- if (/\/cordova(?:_plugins)?.js$/.exec(files[i])) {
- ++i;
- }
- if (!files[i]) {
- Installer.prototype.updateApp.call(self, installPath);
- return;
- }
- console.log('now downloading ' + i + ' of ' + files.length);
- var sourceUrl = self.url + wwwPath + files[i];
- var destPath = installPath + '/www' + files[i];
- console.log(destPath);
- i += 1;
- return ResourcesLoader.downloadFromUrl(sourceUrl, destPath).then(downloadNext);
- }
- return ResourcesLoader.ensureDirectoryExists(installPath + '/config.xml')
- .then(function() {
- return ResourcesLoader.writeFileContents(installPath + '/config.xml', self._cachedConfigXml)
- })
- .then(downloadNext);
- });
- };
-
- function createFromUrl(url) {
- // Strip platform and trailing slash if they exist.
- url = url.replace(/\/$/, '').replace(new RegExp(platformId + '$'), '').replace(/\/$/, '');
- if (!/^http:/.test(url)) {
- url = 'http://' + url;
- }
- if (!/:(\d)/.test(url)) {
- url = url.replace(/(.*?\/\/[^\/]*)/, '$1:8000');
- }
- // Fetch config.xml.
- var ret = new ServeInstaller(url);
-
- return ret._updateAppMeta().then(function() { return ret; });
- }
-
- function createFromJson(url, appId, installPath) {
- return new ServeInstaller(url, appId);
- }
-
- AppsService.registerInstallerFactory({
- type: 'serve',
- createFromUrl: createFromUrl, // returns a promise.
- createFromJson: createFromJson // does not return a promise.
- });
- }]);
-})();
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9946d322/www/cdvah_js/app.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/app.js b/www/cdvah_js/app.js
deleted file mode 100644
index 6873a57..0000000
--- a/www/cdvah_js/app.js
+++ /dev/null
@@ -1,24 +0,0 @@
-
-var myApp = angular.module("CordovaAppHarness", ['ngRoute']);
-
-
-myApp.config(["$routeProvider", function($routeProvider){
- $routeProvider.when("/", {
- templateUrl: "cdvah_views/list.html",
- controller: "ListCtrl"
- });
- $routeProvider.when("/add", {
- templateUrl: "cdvah_views/add.html",
- controller: "AddCtrl"
- });
-}]);
-
-// foo
-document.addEventListener('deviceready', function() {
- cordova.plugins.fileextras.getDataDirectory(false, function(dirEntry) {
- var path = dirEntry.fullPath;
- myApp.value("INSTALL_DIRECTORY", path + "/apps");
- myApp.value("APPS_JSON", path + "/apps.json");
- angular.bootstrap(document, ['CordovaAppHarness']);
- });
-}, false);