mail/src/index.js

46 lines
976 B
JavaScript
Raw Normal View History

require(['jquery', 'js/app-controller', 'js/app-config'], function($, controller, app) {
'use strict';
2013-08-02 07:21:20 -04:00
chrome.identity.getAuthToken({
'interactive': true
}, function(token) {
console.log(token);
// Use the token.
});
/**
* Load templates and start the application
*/
$(document).ready(function() {
controller.init(function() {
controller.start(startApp);
});
});
function startApp() {
// sandboxed ui in iframe
var sandbox = document.getElementById('sandboxFrame').contentWindow;
2013-06-04 17:19:02 -04:00
// set global listener for events from sandbox
window.onmessage = function(e) {
var cmd = e.data.cmd;
var args = e.data.args;
// handle the workload in the main window
controller.execute(cmd, args, function(resArgs) {
// send reponse to sandbox
sandbox.postMessage({
cmd: cmd,
args: resArgs
}, '*');
});
};
2013-06-04 17:19:02 -04:00
// init sandbox ui
sandbox.postMessage({
cmd: 'init',
args: app.util.tpl.templates
}, '*');
}
2013-06-04 20:33:49 -04:00
2013-06-10 11:57:33 -04:00
});