bunti-node/js/app.js

50 lines
1.4 KiB
JavaScript
Raw Normal View History

var app = {
module: function () {
var modules = {};
return function (name) {
if (modules[name]) {
return modules[name];
}
return modules[name] = { Views: {} };
};
} ()
};
jQuery(function ($) {
// load the modules
app.room = app.module('room');
app.control = app.module('control');
app.option = app.module('option');
app.util = app.module('util');
// load the data -- dummy -- struts/node backend
var model = {
rooms: [
{
roomId: 1,
title: "Raum 1",
controls: [
{ controlId: 1, type: "switch", options: [{ status: "off"}] },
{ controlId: 2, type: "switch", options: [{ status: "on"}] },
]
},
{ roomId: 2, title: "Raum 2" },
{ roomId: 3, title: "Raum 3" },
{ roomId: 4, title: "Raum 4" },
{ roomId: 5, title: "Raum 5" }
]
};
var myTestTemplate = app.util.loadTemplate('js/templates/test.handlebars', function(data) {
source = data;
template = Handlebars.compile(source);
//$('#target').html(template(jsondata));
$('#content').append(template(model));
});
// create the model
dashboard = new app.room.List(model.rooms);
});