not really known
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.

70 lines
2.1 KiB

  1. // Desktop handling
  2. define(["webL10n", "sugar-web/graphics/icon", "sugar-web/graphics/xocolor", "sugar-web/graphics/radiobuttonsgroup", "sugar-web/datastore", "sugar-web/presence", "settings", "server", "humane", "util", "tutorial", "stats", "autosync"], function (_l10n, _iconLib, _xoPalette, _radioButtonsGroup, _datastore, _presence, _preferences, _myserver, _humane, _util, _tutorial, _stats, _autosync) {
  3. // Load required library
  4. l10n = _l10n;
  5. l10n.start();
  6. iconLib = _iconLib;
  7. xoPalette = _xoPalette;
  8. radioButtonsGroup = _radioButtonsGroup;
  9. datastore = _datastore;
  10. presence = _presence;
  11. preferences = _preferences;
  12. myserver = _myserver;
  13. humane = _humane;
  14. tutorial = _tutorial;
  15. stats = _stats;
  16. autosync = _autosync;
  17. util = _util;
  18. var toload = 2;
  19. var preferenceset = false;
  20. // Main program
  21. var main = function() {
  22. if (!preferenceset) {
  23. app = new Sugar.FirstScreen();
  24. } else {
  25. app = new Sugar.Desktop();
  26. }
  27. document.onmousemove = function(e) { mouse.position = {x: e.pageX, y: e.pageY}; } // Save mouse position
  28. util.handleVolumeButtons();
  29. app.renderInto(document.getElementById("canvas"));
  30. }
  31. // Wait for preferences
  32. var loadpreference = function() {
  33. enyo.platform.electron = /Electron/.test(navigator.userAgent);
  34. if (util.getClientType() == constant.appType && !enyo.platform.android && !enyo.platform.androidChrome && !enyo.platform.ios) {
  35. var getUrlParameter = function(name) {
  36. var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
  37. return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
  38. };
  39. if (getUrlParameter('rst') == 1) {
  40. // Electron app parameter to start from a fresh install
  41. util.cleanDatastore(true);
  42. }
  43. }
  44. preferences.load(function(load) {
  45. preferenceset = load;
  46. main();
  47. });
  48. }
  49. // Wait for localized strings are here
  50. window.addEventListener('localized', function() {
  51. if (app) {
  52. app.getToolbar().localize();
  53. app.render();
  54. } else if (--toload == 0) {
  55. loadpreference();
  56. }
  57. }, false);
  58. // Wait for DOM is ready.
  59. requirejs(['domReady!'], function (doc) {
  60. if (--toload == 0) {
  61. loadpreference();
  62. }
  63. });
  64. });