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.

63 lines
1.9 KiB

  1. 
  2. define(["sugar-web/activity/activity","webL10n","sugar-web/graphics/radiobuttonsgroup","sugar-web/datastore"], function (activity, _l10n, radioButtonsGroup, datastore) {
  3. l10n = _l10n;
  4. var app = null;
  5. // Manipulate the DOM only when it is ready.
  6. requirejs(['domReady!'], function (doc) {
  7. // Initialize the activity
  8. FoodChain.activity = activity;
  9. FoodChain.activity.setup();
  10. // Initialize buttons
  11. var languageRadio = new radioButtonsGroup.RadioButtonsGroup([
  12. document.getElementById("en-button"),
  13. document.getElementById("fr-button")]
  14. );
  15. document.getElementById("en-button").onclick = function() {
  16. l10n.language.code = "en";
  17. FoodChain.setLocale();
  18. };
  19. document.getElementById("fr-button").onclick = function() {
  20. l10n.language.code = "fr";
  21. FoodChain.setLocale();
  22. };
  23. document.getElementById("pt_BR-button").onclick = function() {
  24. l10n.language.code = "pt_BR";
  25. FoodChain.setLocale();
  26. };
  27. // Wait for locale load
  28. var localized_received = function() {
  29. // Init activity
  30. if (app == null) {
  31. // Init sound component
  32. FoodChain.sound = new FoodChain.Audio();
  33. FoodChain.sound.renderInto(document.getElementById("header"));
  34. // Create and display first screen
  35. FoodChain.context.home = app = new FoodChain.App().renderInto(document.getElementById("body"));
  36. FoodChain.setLocale();
  37. // Load context
  38. FoodChain.loadContext(function() {
  39. app.playGame({
  40. name: FoodChain.context.game.replace("FoodChain.", ""),
  41. level: FoodChain.context.level
  42. });
  43. });
  44. } else {
  45. // Just change locale
  46. FoodChain.setLocale();
  47. }
  48. };
  49. window.addEventListener('localized', localized_received, false);
  50. // Stop sound at end of game to sanitize media environment, specifically on Android
  51. document.getElementById("stop-button").addEventListener('click', function (event) {
  52. FoodChain.sound.pause();
  53. });
  54. });
  55. });