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.

73 lines
2.1 KiB

  1. define(["sugar-web/env", "sugar-web/activity/activity", "sugar-web/datastore"], function (env, activity, datastore) {
  2. var sugarizerCompatibility = {
  3. activity: activity,
  4. data: {allProjects: "[]"},
  5. env: env,
  6. xoColor: {
  7. stroke: "#00A0FF",
  8. fill: "#8BFF7A"
  9. },
  10. saveLocally: function (callback) {
  11. var t = this;
  12. activity.getDatastoreObject().setDataAsText(JSON.stringify(t.data));
  13. activity.getDatastoreObject().save(function () {
  14. if (callback) {
  15. callback();
  16. }
  17. });
  18. },
  19. isInsideSugarizer: function () {
  20. return env.isSugarizer();
  21. },
  22. loadData: function (callback) {
  23. var t = this;
  24. activity.getDatastoreObject().loadAsText(function (error, metadata, jsonData) {
  25. if (jsonData !== undefined && jsonData !== null) {
  26. t.data = JSON.parse(jsonData);
  27. }
  28. if (metadata.buddy_color) {
  29. t.xoColor = metadata.buddy_color;
  30. }
  31. if (callback !== undefined) {
  32. callback();
  33. }
  34. });
  35. },
  36. sugarizerStop: function () {
  37. document.getElementById("stop-button").click();
  38. },
  39. getLanguage: function () {
  40. var defaultSettings = {
  41. name: "",
  42. language: (typeof chrome != 'undefined' && chrome.app && chrome.app.runtime) ? chrome.i18n.getUILanguage() : navigator.language
  43. };
  44. if (!env.isSugarizer()) {
  45. callback();
  46. return defaultSettings.language;
  47. }
  48. var loadedSettings = datastore.localStorage.getValue('sugar_settings')
  49. return loadedSettings.language;
  50. },
  51. setup: function () {
  52. if (this.isInsideSugarizer() === false) {
  53. return;
  54. }
  55. ;
  56. activity.setup();
  57. }
  58. };
  59. window.sugarizerCompatibility = sugarizerCompatibility;
  60. sugarizerCompatibility.setup();
  61. return sugarizerCompatibility;
  62. });