Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bump Spark apps
Browse files Browse the repository at this point in the history
  • Loading branch information
spark-bot committed Jun 18, 2015
1 parent dac3e6f commit ac61ff6
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 78 deletions.
6 changes: 5 additions & 1 deletion distros/spark/apps/customizer/js/addon-concat.js
Expand Up @@ -6038,12 +6038,16 @@ var MainController = (function (Controller) {
var MainController = function MainController(options) {
Controller.call(this, options);

this._checkOpenFromLauncher();
this._waitToBeOpened();

this._visibilitychangeHandler = this._visibilitychangeHandler.bind(this);
window.addEventListener("visibilitychange", this._visibilitychangeHandler);

// Wait 1 second before checking with Customizer Launcher to
// prevent the Customizer DOM from getting wiped out by the
// app initialization.
setTimeout(this._checkOpenFromLauncher.bind(this), 1000);

console.log("[Customizer] Initialized MainController", this);
};

Expand Down
6 changes: 5 additions & 1 deletion distros/spark/apps/customizer/js/controllers/main.js
Expand Up @@ -17,12 +17,16 @@ define(["exports"], function (exports) {
var MainController = function MainController(options) {
Controller.call(this, options);

this._checkOpenFromLauncher();
this._waitToBeOpened();

this._visibilitychangeHandler = this._visibilitychangeHandler.bind(this);
window.addEventListener("visibilitychange", this._visibilitychangeHandler);

// Wait 1 second before checking with Customizer Launcher to
// prevent the Customizer DOM from getting wiped out by the
// app initialization.
setTimeout(this._checkOpenFromLauncher.bind(this), 1000);

console.log("[Customizer] Initialized MainController", this);
};

Expand Down
60 changes: 60 additions & 0 deletions distros/spark/apps/directory/apps.json
@@ -0,0 +1,60 @@
{
"http://fxos.github.io/camera/dist/app/manifest.webapp": {
"manifestURL": "http://fxos.github.io/camera/dist/app/manifest.webapp",
"name": "camera",
"description": "Take pictures and stuff.",
"author": "Justin D'Arcangelo",
"type": "hosted",
"url": "https://github.com/fxos/camera",
"revision": "8b5a7d9061a0d0210f24ff253110a8ce935104ca"
},
"http://fxos.github.io/dialer/dist/app/manifest.webapp": {
"manifestURL": "http://fxos.github.io/dialer/dist/app/manifest.webapp",
"name": "dialer",
"description": "A replacement for the built-in dialer app.",
"author": "Doug Sherk",
"type": "hosted",
"url": "https://github.com/fxos/dialer",
"revision": "835af6ccf608a51bc87711d1c40fc4f33a1fc12b"
},
"http://mikehenrty.github.io/fxos-magnifier/manifest.webapp": {
"manifestURL": "http://mikehenrty.github.io/fxos-magnifier/manifest.webapp",
"name": "magnifier",
"description": "Tap three times and hold to magnify the screen.",
"icon": "http://mikehenrty.github.io/fxos-magnifier/style/icons/60.png",
"author": "David Flanagan",
"type": "addon",
"url": "https://github.com/mikehenrty/fxos-magnifier",
"revision": "262d9e1cbae2d267009294ebeb045da4e4920eb4"
},
"https://callahad.github.io/fxos-tabswitcher-addon/src/manifest.webapp": {
"manifestURL": "https://callahad.github.io/fxos-tabswitcher-addon/src/manifest.webapp",
"name": "Tab Switcher Shortcut",
"description": "Adds a button to the browser that immediately opens the tab switcher",
"icon": "https://callahad.github.io/fxos-tabswitcher-addon/src/icon-128x128.png",
"author": "Dan Callahan",
"type": "addon",
"url": "https://github.com/callahad/fxos-tabswitcher-addon",
"revision": "7096c0545980e250ee5be505b746421ffb9b19ce"
},
"http://mikehenrty.github.io/fxos-cracked/manifest.webapp": {
"manifestURL": "http://mikehenrty.github.io/fxos-cracked/manifest.webapp",
"name": "cracked",
"description": "A virtual cracked screen for your FirefoxOS device.",
"icon": "http://mikehenrty.github.io/fxos-cracked/style/icons/128.png",
"author": "David Flanagan",
"type": "addon",
"url": "https://github.com/mikehenrty/fxos-cracked",
"revision": "16016c86f464c23e0465b22d43c08f52c1cc7349"
},
"https://callahad.github.io/disconnected-ensemble-src/src/manifest.webapp": {
"manifestURL": "https://callahad.github.io/disconnected-ensemble-src/src/manifest.webapp",
"name": "disconnected ensemble",
"description": "An app for Firefox OS that lets you share a number of musical toys that can run in your friends' devices, served from your phone, either by typing in the IP address of the phone server, or by bumping NFC devices together.",
"icon": "https://callahad.github.io/disconnected-ensemble-src/src/img/icons/icon128x128.png",
"author": "soledad penadés",
"type": "packaged",
"url": "https://github.com/callahad/disconnected-ensemble-src",
"revision": "94ad2d961aa5a902fe8150b280a38f48d84607eb"
}
}
67 changes: 46 additions & 21 deletions distros/spark/apps/directory/js/controller/list_controller.js
@@ -1,4 +1,4 @@
define(["exports", "components/fxos-mvc/dist/mvc", "js/model/list_model", "js/view/tabs_view", "js/view/app_list_view", "js/view/addon_list_view", "js/view/details_view"], function (exports, _componentsFxosMvcDistMvc, _jsModelListModel, _jsViewTabsView, _jsViewAppListView, _jsViewAddonListView, _jsViewDetailsView) {
define(["exports", "components/fxos-mvc/dist/mvc", "js/model/list_model", "js/view/tabs_view", "js/view/offline_view", "js/view/app_list_view", "js/view/addon_list_view", "js/view/details_view"], function (exports, _componentsFxosMvcDistMvc, _jsModelListModel, _jsViewTabsView, _jsViewOfflineView, _jsViewAppListView, _jsViewAddonListView, _jsViewDetailsView) {
"use strict";

var _extends = function (child, parent) {
Expand All @@ -16,6 +16,7 @@ define(["exports", "components/fxos-mvc/dist/mvc", "js/model/list_model", "js/vi
var Controller = _componentsFxosMvcDistMvc.Controller;
var ListModel = _jsModelListModel["default"];
var TabsView = _jsViewTabsView["default"];
var OfflineView = _jsViewOfflineView["default"];
var AppListView = _jsViewAppListView["default"];
var AddonListView = _jsViewAddonListView["default"];
var DetailsView = _jsViewDetailsView["default"];
Expand All @@ -25,6 +26,7 @@ define(["exports", "components/fxos-mvc/dist/mvc", "js/model/list_model", "js/vi

this.model = new ListModel();
this.tabsView = new TabsView();
this.offlineView = new OfflineView();
this.appView = new AppListView();
this.addonView = new AddonListView();
this.detailsView = new DetailsView();
Expand All @@ -39,7 +41,7 @@ define(["exports", "components/fxos-mvc/dist/mvc", "js/model/list_model", "js/vi
var hash = window.location.hash;
var tab = hash && hash.slice(1);

if (!this.alreadyCreated) {
if (!this.initialized) {
this.createList(tab);
}
this.activateTab(tab);
Expand All @@ -51,6 +53,8 @@ define(["exports", "components/fxos-mvc/dist/mvc", "js/model/list_model", "js/vi
};

ListController.prototype.createList = function (tab) {
this.offlineView.render();
document.body.appendChild(this.offlineView.el);
this.tabsView.render(tab);
document.body.appendChild(this.tabsView.el);
this.appView.render();
Expand All @@ -61,22 +65,43 @@ define(["exports", "components/fxos-mvc/dist/mvc", "js/model/list_model", "js/vi
document.body.appendChild(this.detailsView.el);
this.alertDialog = document.body.querySelector("#alert-dialog");

this.list = this.model.getAppList();
this.appView.update(this.list);
this.addonView.update(this.list);
this.appView.onInstall(this.handleInstall.bind(this));
this.addonView.onInstall(this.handleInstall.bind(this));
this.appView.onDetails(this.handleDetails.bind(this));
this.addonView.onDetails(this.handleDetails.bind(this));
this.detailsView.onClose(this.handleCloseDetails.bind(this));
this.detailsView.onInstall(this.handleInstall.bind(this));
this.refreshInstalledList();

this.alreadyCreated = true;
this.getApps();
this.watchConnection();

this.initialized = true;
};

ListController.prototype.refreshInstalledList = function () {
ListController.prototype.getApps = function () {
var _this = this;
this.model.getAppList().then(function (list) {
_this.list = list;
_this.refreshInstalledList();
});
};

ListController.prototype.watchConnection = function () {
window.addEventListener("online", this.handleConnection.bind(this));
window.addEventListener("offline", this.handleConnection.bind(this));
this.handleConnection();
};

ListController.prototype.handleConnection = function () {
var online = navigator.onLine;
this.offlineView.update(online);
if (online) {
this.getApps();
}
};

ListController.prototype.refreshInstalledList = function () {
var _this2 = this;
this.installedApps = Object.create(null);

// Use mgmt.getAll if available to fetch apps,
Expand All @@ -94,20 +119,20 @@ define(["exports", "components/fxos-mvc/dist/mvc", "js/model/list_model", "js/vi
apps.forEach(function (app) {
installedApps[app.manifestURL] = app;
});
for (var manifestURL in _this.list) {
_this.list[manifestURL].installed = !!installedApps[manifestURL];
_this.list[manifestURL].mozApp = installedApps[manifestURL] || false;
if (_this.detailsView.isShowing(manifestURL)) {
for (var manifestURL in _this2.list) {
_this2.list[manifestURL].installed = !!installedApps[manifestURL];
_this2.list[manifestURL].mozApp = installedApps[manifestURL] || false;
if (_this2.detailsView.isShowing(manifestURL)) {
// If it's showing, repopulate the details view with new app data.
_this.detailsView.show(_this.list[manifestURL]);
_this2.detailsView.show(_this2.list[manifestURL]);
}
}
_this.appView.update(_this.list);
_this.addonView.update(_this.list);
_this2.appView.update(_this2.list);
_this2.addonView.update(_this2.list);
};

req.onerror = function (e) {
_this.showAlertDialog("error fetching install apps: " + e.message);
_this2.showAlertDialog("error fetching install apps: " + e.message);
console.log("error fetching installed apps: ", e);
};
};
Expand Down Expand Up @@ -146,8 +171,8 @@ define(["exports", "components/fxos-mvc/dist/mvc", "js/model/list_model", "js/vi
}
};

ListController.prototype.handleDetails = function (data) {
this.detailsView.show(data);
ListController.prototype.handleDetails = function (manifestURL) {
this.detailsView.show(this.list[manifestURL]);
};

ListController.prototype.handleCloseDetails = function () {
Expand All @@ -156,7 +181,7 @@ define(["exports", "components/fxos-mvc/dist/mvc", "js/model/list_model", "js/vi
};

ListController.prototype.install = function (appData) {
var _this2 = this;
var _this3 = this;
var manifest = appData.manifestURL;
var type = appData.type;
var installReq;
Expand Down Expand Up @@ -205,15 +230,15 @@ define(["exports", "components/fxos-mvc/dist/mvc", "js/model/list_model", "js/vi
break;
}

_this2.showAlertDialog("INSTALL ERROR: " + errorMsg);
_this3.showAlertDialog("INSTALL ERROR: " + errorMsg);
};

installReq.onsuccess = function () {
if (type === "addon") {
// Enable add-ons immediately by default.
navigator.mozApps.mgmt.setEnabled(installReq.result, true);
}
_this2.refreshInstalledList();
_this3.refreshInstalledList();
window.dispatchEvent(new CustomEvent("achievement-rewarded", {
detail: {
criteria: "achievements/fab-finder",
Expand Down
84 changes: 36 additions & 48 deletions distros/spark/apps/directory/js/model/list_model.js
Expand Up @@ -22,54 +22,42 @@ define(["exports", "components/fxos-mvc/dist/mvc"], function (exports, _componen
_extends(ListModel, Model);

ListModel.prototype.getAppList = function () {
return {
"http://fxos.github.io/sharing/dist/app/manifest.webapp": {
manifestURL: "http://fxos.github.io/sharing/dist/app/manifest.webapp",
name: "sharing",
description: "Share applications with your friends over Wifi.",
author: "Doug Sherk",
type: "hosted",
url: "https://github.com/fxos/sharing",
revision: "e908d4eff5799b038fd318084254a8b93709bada"
},
"http://fxos.github.io/camera/dist/app/manifest.webapp": {
manifestURL: "http://fxos.github.io/camera/dist/app/manifest.webapp",
name: "camera",
description: "Take pictures and stuff.",
author: "Justin D'Arcangelo",
type: "hosted",
url: "https://github.com/fxos/camera",
revision: "8b5a7d9061a0d0210f24ff253110a8ce935104ca"
},
"http://fxos.github.io/video/app/manifest.webapp": {
manifestURL: "http://fxos.github.io/video/app/manifest.webapp",
name: "video",
description: "Become the next Steven Spielberg.",
author: "Justin D'Arcangelo",
type: "hosted",
url: "https://github.com/fxos/video",
revision: "b3c913669bc7039e980586bd9d319a0ca2ac6003"
},
"http://fxos.github.io/dialer/dist/app/manifest.webapp": {
manifestURL: "http://fxos.github.io/dialer/dist/app/manifest.webapp",
name: "dialer",
description: "A replacement for the built-in dialer app.",
author: "Doug Sherk",
type: "hosted",
url: "https://github.com/fxos/dialer",
revision: "835af6ccf608a51bc87711d1c40fc4f33a1fc12b"
},
"http://mikehenrty.github.io/fxos-cracked/manifest.webapp": {
manifestURL: "http://mikehenrty.github.io/fxos-cracked/manifest.webapp",
name: "cracked",
description: "A virtual cracked screen for your FirefoxOS device.",
icon: "http://mikehenrty.github.io/fxos-cracked/style/icons/128.png",
author: "David Flanagan",
type: "addon",
url: "https://github.com/mikehenrty/fxos-cracked",
revision: "16016c86f464c23e0465b22d43c08f52c1cc7349"
}
};
var _this = this;
return new Promise(function (resolve, reject) {
var localApps = _this.loadApps("/apps.json");
var remoteApps = _this.loadApps("http://directory.fxosapps.org/apps.json");
Promise.all([localApps, remoteApps]).then(function (sources) {
localApps = sources[0];
remoteApps = sources[1];

// Try to fetch the remote app list, but if it fails, use the packaged
// one instead.
resolve(Object.keys(remoteApps).length ? remoteApps : localApps);
});
});
};

ListModel.prototype.loadApps = function (url) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest({ mozSystem: true, mozAnon: true });
xhr.open("GET", url, true);
xhr.responseType = "json";
xhr.onload = function () {
var apps = {};
if (xhr.status === 200) {
apps = xhr.response;
localStorage.setItem("apps", JSON.stringify(apps));
} else {
console.log("Error fetching app list", xhr.status);
}
resolve(apps);
};
xhr.onerror = function (e) {
console.log("Error fetching app list", e);
resolve({});
};
xhr.send();
});
};

return ListModel;
Expand Down
6 changes: 3 additions & 3 deletions distros/spark/apps/directory/js/view/list_view.js
Expand Up @@ -76,14 +76,14 @@ define(["exports", "components/fxos-mvc/dist/mvc", "components/gaia-list/gaia-li
IconHelper.setImage(item.querySelector(".icon"), data.icon);
this.el.appendChild(item);

item.addEventListener("click", function (data, evt) {
item.addEventListener("click", function (manifestURL, evt) {
if (evt.target.classList.contains("install-button")) {
return;
}
this.detailsHandlers.forEach(function (handler) {
handler(data);
handler(manifestURL);
});
}.bind(this, data));
}.bind(this, data.manifestURL));

item.querySelector(".install-button").addEventListener("click", function (data) {
this.installHandlers.forEach(function (handler) {
Expand Down

0 comments on commit ac61ff6

Please sign in to comment.