0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-30 02:32:43 +01:00
construct/share/webapp/construct.js

94 lines
2.1 KiB
JavaScript
Raw Normal View History

/*
2018-02-04 03:22:01 +01:00
// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
*/
'use strict';
/**************************************
* Final Initialization.
*/
/**
* Main client controller attached to the #charybdis root div element in the application.
* Only one instance of this controller is made.
*/
mc.ng.app.controller('mc', class extends mc.ng.controller
{
constructor($scope, $timeout)
{
super("mc", $scope, $timeout);
$scope['$'] = $;
2017-11-16 02:34:42 +01:00
$scope.exists = (id) => $(id).length > 0;
$scope.Object = Object;
$scope.JSON = JSON;
$scope.parseInt = parseInt;
$scope.console = console;
$scope.test = mc.test;
$scope.debug = debug;
$scope._typeof = (val) => typeof(val);
$scope.maybe = maybe;
$scope.empty = empty;
$scope.length = length;
$scope.togdel = togdel;
$scope.togswap = togswap;
$scope.ircd = ircd;
$scope.mc = mc;
//TODO: XXX: arbitrary
mc.watch.$scope = $scope;
mc.timeout.$timeout = $timeout;
}
});
mc.ready = async function(event)
{
let status; try
{
console.log("IRCd Charybdis Client: Hello.");
status = await mc.main();
console.warn("IRCd Charybdis Client: Main exited: " + status);
}
catch(error)
{
console.error("IRCd Charybdis Client: Main exited (error): " + error + " " + error.stack);
//mc.unhandled(error);
mc.abort(error);
}
finally
{
mc.count++;
}
};
window.addEventListener("unload", async function(event)
{
if(mc.execution) try
{
await mc.execution;
console.log("IRCd Charybdis Client: Goodbye.");
}
finally
{
console.log("---------------------------------------------------------------");
}
});
2017-09-29 12:09:32 +02:00
mc.run = async function(event = {})
{
mc.execution = mc.ready(event);
2017-09-29 12:09:32 +02:00
}
$(document).ready((event) =>
{
mc.run(event);
});