blob: c7d50a02694b6d251ca1f589cd9ba487b6f63c2c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
import { homescreen, afmMain } from 'agl-js-api';
import Mustache from 'mustache';
var configjson = require('../config.json');
var template;
var parent;
function renderApp(app) {
parent.innerHTML = Mustache.render(template, app) + parent.innerHTML;
}
function locateApp(appId, appList) {
return appList.find(function(app){
return app.id.split('@')[0] === appId
});
}
function load_application_list() {
afmMain.runnables().then(function(result) {
configjson.apps.forEach(function(app) {
var internalApp = locateApp(app.id, result);
if( internalApp ) {
renderApp({
id: internalApp.id,
name: internalApp.name,
icon: app.icon
});
if( app.id === configjson.launch ) {
afmMain.start(internalApp.id).then(function(result) {
console.log("success: " + result);
});
}
}
});
});
}
export function start(node) {
var appId = node.getAttribute('app-id');
homescreen.showWindow(appId.split('@')[0]).then(function(result) {
console.log("success: " + result);
});
}
export function init() {
template = document.getElementById('app-template').innerHTML;
parent = document.getElementById('app-template').parentNode
Mustache.parse(template);
load_application_list();
}
|