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.

68 lines
2.3 KiB

  1. //This file only shows the libs loading event
  2. //Please look at calculateapp.js to see the related functions
  3. /* Start of the app, we require everything that is needed */
  4. define(["sugar-web/activity/activity","mustache","sugar-web/graphics/palette","activity/calculate-activity","activity/calculate-app","math","parser","nanomodal"], function (activity, mustache, calcpalette) {
  5. CalculateApp.libs.palette = calcpalette;
  6. //function-plot depends on d3.
  7. requirejs(["d3"], function(d) {
  8. requirejs(["function-plot"], function(p) {
  9. CalculateApp.libs.functionPlot = p;
  10. });
  11. });
  12. CalculateApp.libs.activity = activity;
  13. CalculateApp.libs.mustache = mustache;
  14. requirejs(['domReady!', 'activity/trigo-palette', 'activity/algebra-palette', 'webL10n', 'sugar-web/datastore'], function(doc, trigoPaletteLib, algebraPaletteLib, webL10n, datastore) {
  15. CalculateApp.libs.webL10n = webL10n;
  16. CalculateApp.libs.trigopalette = trigoPaletteLib;
  17. CalculateApp.libs.algebrapalette = algebraPaletteLib;
  18. initGui();
  19. //Localization handling
  20. window.addEventListener('localized', function() {
  21. if (datastore !== undefined && datastore.localStorage !== undefined) {
  22. var preferences = datastore.localStorage.getValue('sugar_settings');
  23. if (preferences === null || preferences.name === undefined) {
  24. return;
  25. }
  26. if (preferences.language !== undefined) {
  27. if (CalculateApp.libs.webL10n.language.code !== preferences.language)
  28. CalculateApp.libs.webL10n.language.code = preferences.language;
  29. }
  30. }
  31. CalculateApp.transateGui();
  32. }, false);
  33. //We auto focus if needed
  34. CalculateApp.focus();
  35. //We auto fire the onResize event
  36. CalculateApp.onResize();
  37. //Launch of the activity, color and data fetch
  38. activity.setup();
  39. activity.getXOColor(function(s, color) {
  40. if (color !== undefined) {
  41. CalculateApp.data.buddyColor = color;
  42. CalculateApp.displayAllCalculations();
  43. }
  44. });
  45. activity.getDatastoreObject().loadAsText(function(error, metadata, jsonData) {
  46. var data = JSON.parse(jsonData);
  47. if (data !== undefined) {
  48. CalculateApp.data.calculations = data;
  49. CalculateApp.displayAllCalculations();
  50. }
  51. });
  52. });
  53. });