You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1 KiB

  1. const perf = require('./performance');
  2. // import default stylesheet with variables
  3. require('font-awesome/css/font-awesome.css');
  4. require('mastodon-application-style');
  5. function onDomContentLoaded(callback) {
  6. if (document.readyState !== 'loading') {
  7. callback();
  8. } else {
  9. document.addEventListener('DOMContentLoaded', callback);
  10. }
  11. }
  12. function main() {
  13. perf.start('main()');
  14. const Mastodon = require('mastodon/containers/mastodon').default;
  15. const React = require('react');
  16. const ReactDOM = require('react-dom');
  17. require.context('../images/', true);
  18. if (window.history && history.replaceState) {
  19. const { pathname, search, hash } = window.location;
  20. const path = pathname + search + hash;
  21. if (!(/^\/web[$/]/).test(path)) {
  22. history.replaceState(null, document.title, `/web${path}`);
  23. }
  24. }
  25. onDomContentLoaded(() => {
  26. const mountNode = document.getElementById('mastodon');
  27. const props = JSON.parse(mountNode.getAttribute('data-props'));
  28. ReactDOM.render(<Mastodon {...props} />, mountNode);
  29. perf.stop('main()');
  30. });
  31. }
  32. export default main;