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.

88 lines
3.2 KiB

  1. /* Start of the app, we require everything that is needed */
  2. define(["sugar-web/activity/activity","sugar-web/presence","activity/capture-helper","sugar-web/datastore","webL10n"], function (activity,presence,captureHelper,datastore,webL10n) {
  3. requirejs(['domReady!'], function (doc) {
  4. window.addEventListener('localized', function() {
  5. window.l10n = webL10n;
  6. if (datastore !== undefined && datastore.localStorage !== undefined) {
  7. var preferences = datastore.localStorage.getValue('sugar_settings');
  8. if (preferences === null || preferences.name === undefined) {
  9. return;
  10. }
  11. if (preferences.language !== undefined) {
  12. if (webL10n.language.code !== preferences.language)
  13. webL10n.language.code = preferences.language;
  14. }
  15. }
  16. if (webL10n.get("by") !== undefined && webL10n.get("by").length > 0) {
  17. captureHelper.by = webL10n.get("by");
  18. }
  19. }, false);
  20. activity.setup();
  21. if (typeof chrome != 'undefined' && chrome.app && chrome.app.runtime) {
  22. chrome.storage.local.get('sugar_settings', function (values) {
  23. captureHelper.buddy_name = JSON.parse(values.sugar_settings).name
  24. });
  25. } else {
  26. captureHelper.buddy_name = JSON.parse(localStorage.sugar_settings).name
  27. }
  28. captureHelper.init();
  29. var photoButton = document.getElementById("photo-button");
  30. var audioButton = document.getElementById("audio-button");
  31. var videoButton = document.getElementById("video-button");
  32. var vidDisplay = document.getElementById("vidDisplay");
  33. function handleVideo(stream){
  34. document.querySelector('#vidDisplay').srcObject = stream;
  35. }
  36. function videoError(e){
  37. alert("There was some error");
  38. }
  39. photoButton.addEventListener("click", function () {
  40. captureHelper.helper.takePicture();
  41. if(vidDisplay.style.display == "none"){
  42. vidDisplay.style.display = "block" ;
  43. }
  44. });
  45. audioButton.addEventListener("click", function () {
  46. if(vidDisplay.style.display != "none"){
  47. vidDisplay.style.display = "none" ;
  48. }
  49. captureHelper.helper.recordAudio();
  50. });
  51. videoButton.addEventListener("click", function () {
  52. if(vidDisplay.style.display == "none"){
  53. vidDisplay.style.display = "block" ;
  54. }
  55. captureHelper.helper.recordVideo();
  56. });
  57. activity.getDatastoreObject().loadAsText(function(error, metadata, jsonData) {
  58. if (jsonData == null) {
  59. return;
  60. }
  61. var data = JSON.parse(jsonData);
  62. if (data == null) {
  63. return;
  64. }
  65. captureHelper.ids = data.ids;
  66. if (data.ids && data.ids.length > 0) {
  67. captureHelper.getData(data.ids, function(oldData) {
  68. captureHelper.displayAllData(oldData)
  69. });;
  70. }
  71. });
  72. })
  73. });