$('#arduinoFirmware-startupload').click(function () {
  fileReader.onload = function (evnt) {
    console.log('Upload event: ' + selectedFile.name);
    self.cockpit.socket.emit('arduinofirmware-upload', {
      'filename': selectedFile.name,
      data: evnt.target.result
    });
  };
  if (!selectedFile) {
    selectedFile = {};
    selectedFile.name = 'fromSource';
    self.cockpit.socket.emit('arduinofirmware-uploadfromsource');
  }
  console.log('Starting upload: ' + selectedFile.name);
  self.cockpit.socket.emit('arduinofirmware-startupload', {
    'filename': selectedFile.name,
    'size': selectedFile.size
  });
  selectedFile = null;
});
$('#arduinoFirmware-closeupload').click(function () {
  self.arduinoFirmwareVM.reset();  //$('#firmware-upload-dialog').modal('hide');
});
$('#arduinoFirmware-showdetails').click(function () {
  self.arduinoFirmwareVM.toggleDetails();
});/*
 * Created for OpenROV:  www.openrov.com
 * Author:  Dominik
 * Date: 06/03/12
 *
 * Description:
 * This file acts as a mock implementation for the camera module. It reads jpg files from a directory and returns them.
 *
 */
var EventEmitter = require('events').EventEmitter, fs = require('fs'), path = require('path'), CONFIG = require('./config'), logger = require('./logger').create(CONFIG), spawn = require('child_process').spawn;
var FirmwareInstaller = function (eventLoop) {
  var globalEventLoop = eventLoop;
  var installer = new EventEmitter();
  var baseDirectory = path.join(__dirname, '..', '..', 'linux', 'arduino');
  var installscript = 'firmware-install.sh';
  installer.installfromsource = function () {
    installscript = 'firmware-installfromsource.sh';
    installer.install('');
  };
  installer.install = function (filename) {
    var cmd = path.join(baseDirectory, installscript);
    var args = [filename];
    var process = spawn(cmd, args);
    process.on('exit', function (code) {
      if (code !== 0) {
        console.log('---- Error detected in Arduino Firmware update process ----');
        installer.emit('firmwareinstaller-failed', '');
      }
      globalEventLoop.emit('serial-start');
      installer.emit('firmwareinstaller-completed', '');
    });
    process.stderr.on('data', function (data) {
      console.log(data.toString());
      installer.emit('firmwareinstaller-output', data.toString());
    });
    process.stdout.on('data', function (data) {
      if (data.toString().indexOf('unpacking') === 0) {
        installer.emit('firmwareinstaller-unpacking');
      }
      if (data.toString().indexOf('unpacked') === 0) {
        installer.emit('firmwareinstaller-unpacked', '');
      }
      if (data.toString().indexOf('compilling') === 0) {
      }
      if (data.toString().indexOf('compilled') === 0) {
        installer.emit('firmwareinstaller-compilled', '');
        globalEventLoop.emit('serial-stop');  //avrdude.firmwareuploader();
      }
      if (data.toString().indexOf('uploading') === 0) {
      }
      if (data.toString().indexOf('uploaded') === 0) {
        installer.emit('firmwareinstaller-uploaded', '');
      }
    });
  };
  return installer;
};
module.exports = FirmwareInstaller;

@@ -1,897 +1,4 @@
-$('#arduinoFirmware-startupload').click(function () %7B%0A  fileReader.onload = function (evnt) %7B%0A    console.log('Upload event: ' + selectedFile.name);%0A    self.cockpit.socket.emit('arduinofirmware-upload', %7B%0A      'filename': selectedFile.name,%0A      data: evnt.target.result%0A    %7D);%0A  %7D;%0A  if (!selectedFile) %7B%0A    selectedFile = %7B%7D;%0A    selectedFile.name = 'fromSource';%0A    self.cockpit.socket.emit('arduinofirmware-uploadfromsource');%0A  %7D%0A  console.log('Starting upload: ' + selectedFile.name);%0A  self.cockpit.socket.emit('arduinofirmware-startupload', %7B%0A    'filename': selectedFile.name,%0A    'size': selectedFile.size%0A  %7D);%0A  selectedFile = null;%0A%7D);%0A$('#arduinoFirmware-closeupload').click(function () %7B%0A  self.arduinoFirmwareVM.reset();  //$('#firmware-upload-dialog').modal('hide');%0A%7D);%0A$('#arduinoFirmware-showdetails').click(function () %7B%0A  self.arduinoFirmwareVM.toggleDetails();%0A%7D);
 /*%0A 

Fix breaking code from commit 905305cf