Skip to content

Commit 0f6a5a7

Browse files
committed
create addon for firefox os
1 parent 7ecab6e commit 0f6a5a7

File tree

8 files changed

+110
-2
lines changed

8 files changed

+110
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ build/Release
2525
# Dependency directory
2626
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
2727
node_modules
28+
29+
application.zip

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1-
# kill-all-apps
2-
This is an add-on for Firefox OS. It adds an extra button at card view to kill all opened apps.
1+
# Kill All Actives
2+
3+
Kill All Actives is an addon for Firefox OS. It creates a button for killing all active apps at task manager.
4+
5+
## build
6+
7+
```
8+
$ npm install
9+
$ gulp
10+
```
11+
12+
If you do any changes, you may only run `gulp` to rebuild it.

gulpfile.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var gulp = require('gulp');
2+
var zip = require('gulp-zip');
3+
4+
gulp.task('default', function() {
5+
return gulp.src(['main.js', 'manifest.webapp', 'LICENSE', 'icons/*'])
6+
.pipe(zip('application.zip'))
7+
.pipe(gulp.dest('./'));
8+
});

icons/128.png

16 KB
Loading

icons/256.png

16 KB
Loading

main.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
(function() {
2+
function createKillAllButton() {
3+
var cardsView = document.getElementById('cards-view');
4+
5+
var button = document.createElement('button');
6+
// set it as type to prevent form submit.
7+
button.type = 'button';
8+
button.textContent = '🈳';
9+
button.style.background = 'none';
10+
button.style.border = 'none';
11+
button.style.outline = 'none';
12+
button.style.fontSize = '3rem';
13+
button.style.position = 'absolute';
14+
button.style.top = '3rem';
15+
button.style.right = '3rem';
16+
17+
button.addEventListener('touchstart', function() {
18+
var taskMgr = window.wrappedJSObject.appWindowManager.taskManager;
19+
if (taskMgr.cardsList.children.length > 0) {
20+
for (var appId in taskMgr.cardsByAppID) {
21+
taskMgr.cardsByAppID[appId].killApp();
22+
}
23+
taskMgr.exitToApp();
24+
}
25+
}, true);
26+
27+
window.addEventListener('taskmanager-activated', function() {
28+
var taskMgr = window.wrappedJSObject.appWindowManager.taskManager;
29+
button.style.display = taskMgr.cardsList.children.length === 0 ?
30+
'none' : 'inline-block';
31+
});
32+
33+
cardsView.insertBefore(button, cardsView.firstElementChild);
34+
}
35+
36+
if (document.readyState !== 'loading') {
37+
createKillAllButton();
38+
} else {
39+
document.addEventListener('readystatechange',
40+
function readyStateChange() {
41+
if (document.readyState == 'interactive') {
42+
document.removeEventListener('readystatechange',
43+
readyStateChange);
44+
createKillAllButton();
45+
}
46+
});
47+
}
48+
})();

manifest.webapp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "Kill-Actives",
3+
"description": "Add a button to kill all active apps",
4+
"developer": {
5+
"name": "John Hu"
6+
},
7+
"locales": {
8+
"en-US": {
9+
"name": "Kill All Actives",
10+
"description": "Add a button to kill all active apps"
11+
}
12+
},
13+
"default_locale": "en-US",
14+
"package_path": "application.zip",
15+
"role": "addon",
16+
"type": "certified",
17+
"customizations": [
18+
{
19+
"filter": "app://system.gaiamobile.org",
20+
"scripts": [
21+
"main.js"
22+
]
23+
}
24+
],
25+
"icons": {
26+
"128": "/icons/128.png",
27+
"256": "/icons/256.png"
28+
}
29+
}

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "kill-all-actives",
3+
"description": "Add a button to kill all active apps",
4+
"developer": {
5+
"name": "John Hu"
6+
},
7+
"dependencies": {
8+
"gulp": "*",
9+
"gulp-zip": "*"
10+
}
11+
}

0 commit comments

Comments
 (0)