summaryrefslogtreecommitdiffstats
path: root/src/js/apps.js
diff options
context:
space:
mode:
authorHumberto Alfonso Díaz <humberto.alfonso@asvito.es>2019-12-11 08:39:27 +0100
committerLorenzo Tilve <ltilve@igalia.com>2020-02-04 19:12:47 +0100
commit6d8916c58d823b13b89477f59bf05373e87f3a98 (patch)
tree97142e38adc872fe58999b7d01f806d66153be3e /src/js/apps.js
parentfb39b8f31f9323f5e56670de2f382f7b19daed08 (diff)
RESTRUCT Upadate homescreen layout
Diffstat (limited to 'src/js/apps.js')
-rw-r--r--src/js/apps.js31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/js/apps.js b/src/js/apps.js
index c7d50a0..9fe7107 100644
--- a/src/js/apps.js
+++ b/src/js/apps.js
@@ -1,12 +1,16 @@
+import { load as load_template } from './templates';
import { homescreen, afmMain } from 'agl-js-api';
import Mustache from 'mustache';
var configjson = require('../config.json');
var template;
-var parent;
+var root;
+var page = {
+ apps: []
+};
-function renderApp(app) {
- parent.innerHTML = Mustache.render(template, app) + parent.innerHTML;
+function show() {
+ root.innerHTML = Mustache.render(template, page);
}
function locateApp(appId, appList) {
@@ -21,7 +25,7 @@ function load_application_list() {
var internalApp = locateApp(app.id, result);
if( internalApp ) {
- renderApp({
+ page.apps.push({
id: internalApp.id,
name: internalApp.name,
icon: app.icon
@@ -35,19 +39,24 @@ function load_application_list() {
}
});
+
+ show();
});
}
-export function start(node) {
- var appId = node.getAttribute('app-id');
+export function start(appId) {
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();
+export function init(node) {
+ load_template('apps.template.html').then(function(result) {
+ template = result;
+ root = node;
+ Mustache.parse(template);
+ load_application_list();
+ }, function(error) {
+ console.error('ERRROR loading main template', error);
+ });
} \ No newline at end of file