Skip to content

Commit

Permalink
Update about:apps to use new mozApps API
Browse files Browse the repository at this point in the history
  • Loading branch information
anantn committed Feb 16, 2012
1 parent 2813e93 commit 8f1d473
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
47 changes: 25 additions & 22 deletions addons/jetpack/data/about.js
Expand Up @@ -50,15 +50,16 @@ var appDict;
function refresh() {
if (!pending) {
pending = true;
mozApps.mgmt.list(function(aList) {
var pendingGetAll = mozApps.mgmt.getAll();
pendingGetAll.onsuccess = function(aList) {
let aDict = {};
for (let i = 0; i < aList.length; i++) {
aDict[aList[i].origin] = aList[i];
}
appDict = aDict;
pending = false;
render();
});
};
}
}

Expand Down Expand Up @@ -182,27 +183,29 @@ function render() {
for (let appID in appDict) {
empty = false;

function makeLaunchFn(appID) {
function makeLaunchFn(app) {
return function() {
mozApps.mgmt.launch(appID);
app.launch();
}
}

function makeDeleteFn(appID, container) {
function makeDeleteFn(app, container) {
return function() {
mozApps.mgmt.uninstall(appID, function() {});
container.style.minHeight = "0px";
container.style.height = container.clientHeight + "px";
window.setTimeout(function() {
container.style.height = "0px";
container.style.paddingTop = 0;
container.style.paddingBottom = 0;
container.style.marginBottom = 0;
}, 0);
window.setTimeout(function() {
appListContainer.removeChild(container)
}, 500);
return false;
var pendingUninstall = app.uninstall();
pendingUninstall.onsuccess = function() {
container.style.minHeight = "0px";
container.style.height = container.clientHeight + "px";
window.setTimeout(function() {
container.style.height = "0px";
container.style.paddingTop = 0;
container.style.paddingBottom = 0;
container.style.marginBottom = 0;
}, 0);
window.setTimeout(function() {
appListContainer.removeChild(container)
}, 500);
return false;
};
}
}

Expand Down Expand Up @@ -232,7 +235,7 @@ function render() {
appCfg.appendChild(viewSrcLink);
var deleteLink = elem("a");
deleteLink.href = "#";
deleteLink.onclick = makeDeleteFn(appID, appRow);
deleteLink.onclick = makeDeleteFn(theApp, appRow);
deleteLink.appendChild(document.createTextNode("Delete"));
appCfg.appendChild(deleteLink);

Expand All @@ -248,18 +251,18 @@ function render() {
}
appIcon.setAttribute("style", "background-image:url(\"" + iconUrl + "\")");
}
appIcon.onclick = makeLaunchFn(appID);
appIcon.onclick = makeLaunchFn(theApp);

appName.appendChild(document.createTextNode(theApp.manifest.name));
appReceipt.appendChild(document.createTextNode("Installed " + formatDate(theApp.install_time) + ", "));
appReceipt.appendChild(document.createTextNode("Installed " + formatDate(theApp.installTime) + ", "));

if (theApp.install_origin == "chrome://openwebapps") {
appReceipt.appendChild(document.createTextNode("directly from the site"));
} else {
var domainLink = elem("a");
domainLink.href = theApp.install_origin;
domainLink.target = "_blank";
domainLink.appendChild(document.createTextNode(theApp.install_origin));
domainLink.appendChild(document.createTextNode(theApp.installOrigin));
appReceipt.appendChild(document.createTextNode("from "));
appReceipt.appendChild(domainLink);
}
Expand Down
2 changes: 1 addition & 1 deletion addons/jetpack/lib/main.js
Expand Up @@ -149,7 +149,7 @@ openwebapps.prototype = {
"https?://apps.mozillalabs.com",
"https?://localhost",
"http://127.0.0.1:60172/*",
"about:apps"
"about:apps*"
];

pageMod.PageMod({
Expand Down

0 comments on commit 8f1d473

Please sign in to comment.