2013-07-30 04:07:42 -04:00
|
|
|
require(['jquery', 'js/app-controller', 'js/app-config'], function($, controller, app) {
|
2013-06-04 15:36:13 -04:00
|
|
|
'use strict';
|
|
|
|
|
2013-08-02 07:21:20 -04:00
|
|
|
chrome.identity.getAuthToken({
|
|
|
|
'interactive': true
|
|
|
|
}, function(token) {
|
|
|
|
console.log(token);
|
|
|
|
// Use the token.
|
|
|
|
});
|
|
|
|
|
2013-07-30 04:07:42 -04:00
|
|
|
/**
|
|
|
|
* Load templates and start the application
|
|
|
|
*/
|
|
|
|
$(document).ready(function() {
|
|
|
|
controller.init(function() {
|
|
|
|
controller.start(startApp);
|
2013-06-06 09:00:51 -04:00
|
|
|
});
|
2013-07-30 04:07:42 -04:00
|
|
|
});
|
2013-06-04 15:36:13 -04:00
|
|
|
|
2013-07-30 04:07:42 -04:00
|
|
|
function startApp() {
|
|
|
|
// sandboxed ui in iframe
|
|
|
|
var sandbox = document.getElementById('sandboxFrame').contentWindow;
|
2013-06-04 17:19:02 -04:00
|
|
|
|
2013-07-30 04:07:42 -04:00
|
|
|
// set global listener for events from sandbox
|
|
|
|
window.onmessage = function(e) {
|
|
|
|
var cmd = e.data.cmd;
|
|
|
|
var args = e.data.args;
|
2013-06-06 07:34:22 -04:00
|
|
|
|
2013-07-30 04:07:42 -04:00
|
|
|
// 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
|
|
|
|
2013-07-30 04:07:42 -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
|
|
|
});
|