<commit_before>/* Start of the app, we require everything that is needed */
define(["sugar-web/activity/activity","tutorial","webL10n","sugar-web/env","activity/paint-activity","activity/paint-app","sugar-web/graphics/presencepalette","activity/palettes/color-palette","activity/palettes/stamp-palette","activity/palettes/text-palette","activity/palettes/drawings-palette","activity/palettes/filters-palette","activity/buttons/size-button","activity/buttons/clear-button","activity/buttons/undo-button","activity/buttons/redo-button","activity/modes/modes-pen","activity/modes/modes-eraser","activity/modes/modes-bucket","activity/modes/modes-text","activity/modes/modes-stamp","activity/modes/modes-copy","activity/modes/modes-paste","activity/collaboration","activity/buttons/insertimage-button"], function (activity,tutorial,webL10n,env,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21) {
  window.PaintApp = p2;

  PaintApp.libs.activity = activity;

  /* Fetching and storing of the palettes */
  PaintApp.palettes.presencePalette = p3;
  PaintApp.palettes.colorPalette = p4;
  PaintApp.palettes.stampPalette = p5;
  PaintApp.palettes.textPalette = p6;
  PaintApp.palettes.drawingsPalette = p7;
  PaintApp.palettes.filtersPalette = p8;

  /* Fetching and storing of the buttons */
  PaintApp.buttons.sizeButton = p9;
  PaintApp.buttons.clearButton = p10;
  PaintApp.buttons.undoButton = p11;
  PaintApp.buttons.redoButton = p12;
  PaintApp.buttons.insertImageButton = p21;

  /* Fetching and storing of the modes */
  PaintApp.modes.Pen = p13;
  PaintApp.modes.Eraser = p14;
  PaintApp.modes.Bucket = p15;
  PaintApp.modes.Text = p16;
  PaintApp.modes.Stamp = p17;
  PaintApp.modes.Copy = p18;
  PaintApp.modes.Paste = p19;

  PaintApp.collaboration = p20;

  requirejs(['domReady!', 'sugar-web/datastore', 'paper-core', 'mustache', 'lzstring', 'humane'], function(doc, datastore, _paper, mustache, lzstring, humane) {

    /* Fetching and storing libraries */
    PaintApp.libs.mustache = mustache;
    PaintApp.libs.humane = humane;
    PaintApp.libs.lzstring = lzstring;

    //Setup of the activity
    activity.setup();

    /* Fetch and store UI elements */
    initGui();
    var currentenv;
    env.getEnvironment(function(err, environment) {
      currentenv = environment;
      // Set current language to Sugarizer
      var defaultLanguage = (typeof chrome != 'undefined' && chrome.app && chrome.app.runtime) ? chrome.i18n.getUILanguage() : navigator.language;
      var language = environment.user ? environment.user.language : defaultLanguage;
      webL10n.language.code = language;
    });

	// Export as PNG image 
	document.getElementById("save-image-button").addEventListener('click', function () {
		var mimetype = 'image/png';
		var inputData = document.getElementById("paint-canvas").toDataURL(mimetype, 1);
		var metadata = {
			mimetype: mimetype,
			title: webL10n.get("PaintBy", { name: currentenv.user.name }),
			activity: "org.olpcfrance.MediaViewerActivity",
			timestamp: new Date().getTime(),
			creation_time: new Date().getTime(),
			file_size: 0
		};
		datastore.create(metadata, function () {
			humane.log(webL10n.get('PaintImageSaved'))
			console.log("export done.")
		}, inputData);
	});

    document.getElementById("stop-button").addEventListener('click', function(event) {
      var data = {
        width: PaintApp.elements.canvas.width / window.devicePixelRatio,
        height: PaintApp.elements.canvas.height / window.devicePixelRatio,
        src: PaintApp.collaboration.compress(PaintApp.elements.canvas.toDataURL())
      }

      var jsonData = JSON.stringify(data);

      activity.getDatastoreObject().setDataAsText(jsonData);<commit_msg>Updated Indentation in activity with tabsize 8<commit_after>/* Start of the app, we require everything that is needed */
define(["sugar-web/activity/activity","tutorial","webL10n","sugar-web/env","activity/paint-activity","activity/paint-app","sugar-web/graphics/presencepalette","activity/palettes/color-palette","activity/palettes/stamp-palette","activity/palettes/text-palette","activity/palettes/drawings-palette","activity/palettes/filters-palette","activity/buttons/size-button","activity/buttons/clear-button","activity/buttons/undo-button","activity/buttons/redo-button","activity/modes/modes-pen","activity/modes/modes-eraser","activity/modes/modes-bucket","activity/modes/modes-text","activity/modes/modes-stamp","activity/modes/modes-copy","activity/modes/modes-paste","activity/collaboration","activity/buttons/insertimage-button"], function (activity,tutorial,webL10n,env,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21) {
  window.PaintApp = p2;

  PaintApp.libs.activity = activity;

  /* Fetching and storing of the palettes */
  PaintApp.palettes.presencePalette = p3;
  PaintApp.palettes.colorPalette = p4;
  PaintApp.palettes.stampPalette = p5;
  PaintApp.palettes.textPalette = p6;
  PaintApp.palettes.drawingsPalette = p7;
  PaintApp.palettes.filtersPalette = p8;

  /* Fetching and storing of the buttons */
  PaintApp.buttons.sizeButton = p9;
  PaintApp.buttons.clearButton = p10;
  PaintApp.buttons.undoButton = p11;
  PaintApp.buttons.redoButton = p12;
  PaintApp.buttons.insertImageButton = p21;

  /* Fetching and storing of the modes */
  PaintApp.modes.Pen = p13;
  PaintApp.modes.Eraser = p14;
  PaintApp.modes.Bucket = p15;
  PaintApp.modes.Text = p16;
  PaintApp.modes.Stamp = p17;
  PaintApp.modes.Copy = p18;
  PaintApp.modes.Paste = p19;

  PaintApp.collaboration = p20;

  requirejs(['domReady!', 'sugar-web/datastore', 'paper-core', 'mustache', 'lzstring', 'humane'], function(doc, datastore, _paper, mustache, lzstring, humane) {

    /* Fetching and storing libraries */
    PaintApp.libs.mustache = mustache;
    PaintApp.libs.humane = humane;
    PaintApp.libs.lzstring = lzstring;

    //Setup of the activity
    activity.setup();

    /* Fetch and store UI elements */
    initGui();
    var currentenv;
    env.getEnvironment(function(err, environment) {
      currentenv = environment;
      // Set current language to Sugarizer
      var defaultLanguage = (typeof chrome != 'undefined' && chrome.app && chrome.app.runtime) ? chrome.i18n.getUILanguage() : navigator.language;
      var language = environment.user ? environment.user.language : defaultLanguage;
      webL10n.language.code = language;
    });

    // Export as PNG image 
    document.getElementById("save-image-button").addEventListener('click', function () {
      var mimetype = 'image/png';
      var inputData = document.getElementById("paint-canvas").toDataURL(mimetype, 1);
      var metadata = {
	mimetype: mimetype,
	title: webL10n.get("PaintBy", { name: currentenv.user.name }),
	activity: "org.olpcfrance.MediaViewerActivity",
	timestamp: new Date().getTime(),
	creation_time: new Date().getTime(),
	file_size: 0
	};
      datastore.create(metadata, function () {
	humane.log(webL10n.get('PaintImageSaved'))
	console.log("export done.")
      }, inputData);
    });

    document.getElementById("stop-button").addEventListener('click', function(event) {
      var data = {
        width: PaintApp.elements.canvas.width / window.devicePixelRatio,
        height: PaintApp.elements.canvas.height / window.devicePixelRatio,
        src: PaintApp.collaboration.compress(PaintApp.elements.canvas.toDataURL())
      }

      var jsonData = JSON.stringify(data);

      activity.getDatastoreObject().setDataAsText(jsonData);
{'fraction_non_alphanumeric': 0.14260916010148217, 'fraction_numerical': 0.021231139003872346, 'mean_word_length': 4.49523110785033, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3092398', 'n_tokens_mistral': 2657, 'n_tokens_neox': 2409, 'n_words': 379}