[gnome-sound-recorder/wip/jtojnar/es6: 1/5] Revert "sound-recorder: Use var instead of let or const"



commit 4b7feed46775d3934ce85e254270a84fbec68ffa
Author: Jan Tojnar <jtojnar gmail com>
Date:   Fri Jan 18 00:20:47 2019 +0100

    Revert "sound-recorder: Use var instead of let or const"
    
    This reverts commit b6ca7244012fa4c8e6340ff052067f4dd0b6ce05.

 src/application.js  |  46 +++++------
 src/audioProfile.js |  30 +++----
 src/fileUtil.js     |  50 ++++++------
 src/info.js         |  36 ++++-----
 src/listview.js     | 104 ++++++++++++------------
 src/main.js         |   2 +-
 src/mainWindow.js   | 224 ++++++++++++++++++++++++++--------------------------
 src/params.js       |  10 +--
 src/play.js         |  56 ++++++-------
 src/preferences.js  |  38 ++++-----
 src/record.js       | 120 ++++++++++++++--------------
 src/util.js         |  10 +--
 src/waveform.js     | 100 +++++++++++------------
 13 files changed, 413 insertions(+), 413 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index e3858fc..cd01c03 100644
--- a/src/application.js
+++ b/src/application.js
@@ -17,24 +17,24 @@
 *
 */
 
-var Gio = imports.gi.Gio;
-var GLib = imports.gi.GLib;
-var Gst = imports.gi.Gst;
-var Gtk = imports.gi.Gtk;
-var Lang = imports.lang;
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const Gst = imports.gi.Gst;
+const Gtk = imports.gi.Gtk;
+const Lang = imports.lang;
 
-var MainWindow = imports.mainWindow;
-var Preferences = imports.preferences;
-var Util = imports.util;
+const MainWindow = imports.mainWindow;
+const Preferences = imports.preferences;
+const Util = imports.util;
 
-var SIGINT = 2;
-var SIGTERM = 15;
+const SIGINT = 2;
+const SIGTERM = 15;
 
-var application = null;
-var settings = null;
+let application = null;
+let settings = null;
 
 
-var Application = new Lang.Class({
+const Application = new Lang.Class({
     Name: 'Application',
     Extends: Gtk.Application,
 
@@ -44,21 +44,21 @@ var Application = new Lang.Class({
     },
 
     _initAppMenu: function() {
-        var preferences = new Gio.SimpleAction({ name: 'preferences' });
+        let preferences = new Gio.SimpleAction({ name: 'preferences' });
         preferences.connect('activate', Lang.bind(this,
             function() {
                 this._showPreferences();
             }));
         this.add_action(preferences);
 
-        var aboutAction = new Gio.SimpleAction({ name: 'about' });
+        let aboutAction = new Gio.SimpleAction({ name: 'about' });
         aboutAction.connect('activate', Lang.bind(this,
             function() {
                 this._showAbout();
             }));
         this.add_action(aboutAction);
 
-        var quitAction = new Gio.SimpleAction({ name: 'quit' });
+        let quitAction = new Gio.SimpleAction({ name: 'quit' });
         quitAction.connect('activate', Lang.bind(this,
             function() {
                 this.quit();
@@ -81,7 +81,7 @@ var Application = new Lang.Class({
 
     ensure_directory: function() {
         /* Translators: "Recordings" here refers to the name of the directory where the application places 
files */
-        var path = GLib.build_filenamev([GLib.get_home_dir(), _("Recordings")]);
+        let path = GLib.build_filenamev([GLib.get_home_dir(), _("Recordings")]);
 
         // Ensure Recordings directory
         GLib.mkdir_with_parents(path, parseInt("0755", 8));
@@ -103,7 +103,7 @@ var Application = new Lang.Class({
     },
 
     _showPreferences: function() {
-        var preferencesDialog = new Preferences.Preferences();
+        let preferencesDialog = new Preferences.Preferences();
 
         preferencesDialog.widget.connect('response', Lang.bind(this,
             function(widget, response) {
@@ -112,7 +112,7 @@ var Application = new Lang.Class({
     },
 
     getPreferences: function() {
-        var set = settings.get_int("media-type-preset");
+        let set = settings.get_int("media-type-preset");
         return set;
      },
 
@@ -121,7 +121,7 @@ var Application = new Lang.Class({
     },
 
     getChannelsPreferences: function() {
-        var set = settings.get_int("channel");
+        let set = settings.get_int("channel");
         return set;
     },
 
@@ -130,7 +130,7 @@ var Application = new Lang.Class({
     },
 
     getMicVolume: function() {
-        var micVolLevel = settings.get_double("mic-volume");
+        let micVolLevel = settings.get_double("mic-volume");
         return micVolLevel;
     },
 
@@ -139,7 +139,7 @@ var Application = new Lang.Class({
     },
 
     getSpeakerVolume: function() {
-        var speakerVolLevel = settings.get_double("speaker-volume");
+        let speakerVolLevel = settings.get_double("speaker-volume");
         return speakerVolLevel;
     },
 
@@ -148,7 +148,7 @@ var Application = new Lang.Class({
     },
 
     _showAbout: function() {
-        var aboutDialog = new Gtk.AboutDialog();
+        let aboutDialog = new Gtk.AboutDialog();
         aboutDialog.artists = [ 'Reda Lazri <the red shortcut gmail com>',
                                 'Garrett LeSage <garrettl gmail com>',
                                 'Hylke Bons <hylkebons gmail com>',
diff --git a/src/audioProfile.js b/src/audioProfile.js
index d5bacb8..5143701 100644
--- a/src/audioProfile.js
+++ b/src/audioProfile.js
@@ -17,17 +17,17 @@
  *
  */
 
-var _ = imports.gettext.gettext;
-var Gio = imports.gi.Gio;
-var Gst = imports.gi.Gst;
-var GstPbutils = imports.gi.GstPbutils;
-var Lang = imports.lang;
-var Mainloop = imports.mainloop;
+const _ = imports.gettext.gettext;
+const Gio = imports.gi.Gio;
+const Gst = imports.gi.Gst;
+const GstPbutils = imports.gi.GstPbutils;
+const Lang = imports.lang;
+const Mainloop = imports.mainloop;
 
-var MainWindow = imports.mainWindow;
-var Preferences = imports.preferences;
+const MainWindow = imports.mainWindow;
+const Preferences = imports.preferences;
 
-var comboBoxMap = {
+const comboBoxMap = {
     OGG_VORBIS: 0,
     OPUS: 1,
     FLAC: 2,
@@ -35,7 +35,7 @@ var comboBoxMap = {
     MP4: 4
 };
 
-var containerProfileMap = {
+const containerProfileMap = {
     OGG: "application/ogg",
     ID3: "application/x-id3",
     MP4: "video/quicktime,variant=(string)iso",
@@ -43,7 +43,7 @@ var containerProfileMap = {
 };
 
 
-var audioCodecMap = {
+const audioCodecMap = {
     FLAC: "audio/x-flac",
     MP3: "audio/mpeg,mpegversion=(int)1,layer=(int)3",
     MP4: "audio/mpeg,mpegversion=(int)4",
@@ -52,7 +52,7 @@ var audioCodecMap = {
 };
 
 
-var AudioProfile = new Lang.Class({
+const AudioProfile = new Lang.Class({
     Name: 'AudioProfile',
 
     profile: function(profileName){
@@ -89,10 +89,10 @@ var AudioProfile = new Lang.Class({
     },
 
     mediaProfile: function(){
-        var audioCaps;
+        let audioCaps;
         this._containerProfile = null;
         if (this._values.audio && this._values.container) {
-            var caps = Gst.Caps.from_string(this._values.container);
+            let caps = Gst.Caps.from_string(this._values.container);
             this._containerProfile = GstPbutils.EncodingContainerProfile.new("record", null, caps, null);
             audioCaps = Gst.Caps.from_string(this._values.audio);
             this.encodingProfile = GstPbutils.EncodingAudioProfile.new(audioCaps, null, null, 1);
@@ -108,7 +108,7 @@ var AudioProfile = new Lang.Class({
     },
 
     fileExtensionReturner: function() {
-        var suffixName;
+        let suffixName;
 
         if (this._values.audio) {
             if (this._containerProfile != null)
diff --git a/src/fileUtil.js b/src/fileUtil.js
index 2eca15f..f4364ef 100644
--- a/src/fileUtil.js
+++ b/src/fileUtil.js
@@ -17,25 +17,25 @@
  *
  */
 
-var Gettext = imports.gettext;
-var _ = imports.gettext.gettext;
-var Gio = imports.gi.Gio;
-var GLib = imports.gi.GLib;
-var GObject = imports.gi.GObject;
-var Gst = imports.gi.Gst;
-var GstPbutils = imports.gi.GstPbutils;
-var Lang = imports.lang;
-var Signals = imports.signals;
+const Gettext = imports.gettext;
+const _ = imports.gettext.gettext;
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const GObject = imports.gi.GObject;
+const Gst = imports.gi.Gst;
+const GstPbutils = imports.gi.GstPbutils;
+const Lang = imports.lang;
+const Signals = imports.signals;
 
-var Listview = imports.listview;
-var MainWindow = imports.mainWindow;
-var Record = imports.record;
+const Listview = imports.listview;
+const MainWindow = imports.mainWindow;
+const Record = imports.record;
 
-var _OFFSET_STEP = 20;
-var CurrentEndIdx;
-var totItems;
+const _OFFSET_STEP = 20;
+let CurrentEndIdx;
+let totItems;
 
-var OffsetController = new Lang.Class({
+const OffsetController = new Lang.Class({
     Name: 'OffsetController',
 
     _init: function(context) {
@@ -69,18 +69,18 @@ var OffsetController = new Lang.Class({
     }
 });
 
-var DisplayTime = new Lang.Class({
+const DisplayTime = new Lang.Class({
     Name: 'DisplayTime',
 
     getDisplayTime: function(mtime) {
-        var text = "";
-        var DAY = 86400000000;
-        var now = GLib.DateTime.new_now_local();
-        var difference = now.difference(mtime);
-        var days = Math.floor(difference / DAY);
-        var weeks = Math.floor(difference / (7 * DAY));
-        var months = Math.floor(difference / (30 * DAY));
-        var years = Math.floor(difference / (365 * DAY));
+        let text = "";
+        let DAY = 86400000000;
+        let now = GLib.DateTime.new_now_local();
+        let difference = now.difference(mtime);
+        let days = Math.floor(difference / DAY);
+        let weeks = Math.floor(difference / (7 * DAY));
+        let months = Math.floor(difference / (30 * DAY));
+        let years = Math.floor(difference / (365 * DAY));
 
         if (difference < DAY) {
             text = mtime.format('%X');
diff --git a/src/info.js b/src/info.js
index 3bc27e8..5a4e298 100644
--- a/src/info.js
+++ b/src/info.js
@@ -18,21 +18,21 @@
  *
  */
 
-var Gio = imports.gi.Gio;
-var GLib = imports.gi.GLib;
-var Gtk = imports.gi.Gtk;
-var Lang = imports.lang;
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const Gtk = imports.gi.Gtk;
+const Lang = imports.lang;
 
-var _ = imports.gettext.gettext;
-var C_ = imports.gettext.pgettext;
+const _ = imports.gettext.gettext;
+const C_ = imports.gettext.pgettext;
 
-var MainWindow = imports.mainWindow;
+const MainWindow = imports.mainWindow;
 
-var InfoDialog = new Lang.Class({
+const InfoDialog = new Lang.Class({
     Name: 'InfoDialog',
 
     _init: function(fileNav) {
-        var fileName = fileNav;
+        let fileName = fileNav;
 
         this._file = Gio.File.new_for_uri(fileNav.uri);
 
@@ -41,26 +41,26 @@ var InfoDialog = new Lang.Class({
                                         destroy_with_parent: true,
                                         default_width: 400 });
         this.widget.set_transient_for(Gio.Application.get_default().get_active_window());
-        var header = new Gtk.HeaderBar({ title: _("Info") });
+        let header = new Gtk.HeaderBar({ title: _("Info") });
         header.set_show_close_button(false);
         this.widget.set_titlebar(header);
 
-        var cancelButton = new Gtk.Button({ label: _("Cancel") });
+        let cancelButton = new Gtk.Button({ label: _("Cancel") });
         cancelButton.connect("clicked", Lang.bind(this, this.onCancelClicked));
 
         header.pack_start(cancelButton);
 
-        var doneButton = new Gtk.Button({ label: _("Done") });
+        let doneButton = new Gtk.Button({ label: _("Done") });
         doneButton.connect("clicked", Lang.bind(this, this.onDoneClicked));
 
         header.pack_end(doneButton);
 
-        var headerBarSizeGroup = new Gtk.SizeGroup({ mode: Gtk.SizeGroupMode.HORIZONTAL });
+        let headerBarSizeGroup = new Gtk.SizeGroup({ mode: Gtk.SizeGroupMode.HORIZONTAL });
 
         headerBarSizeGroup.add_widget(cancelButton);
         headerBarSizeGroup.add_widget(doneButton);
 
-        var grid = new Gtk.Grid ({ orientation: Gtk.Orientation.VERTICAL,
+        let grid = new Gtk.Grid ({ orientation: Gtk.Orientation.VERTICAL,
                                    row_homogeneous: true,
                                    column_homogeneous: true,
                                    halign: Gtk.Align.CENTER,
@@ -71,7 +71,7 @@ var InfoDialog = new Lang.Class({
                                    margin_start: 18,
                                    margin_top: 18 });
 
-        var contentArea = this.widget.get_content_area();
+        let contentArea = this.widget.get_content_area();
         contentArea.pack_start(grid, true, true, 2);
 
         // File Name item
@@ -125,8 +125,8 @@ var InfoDialog = new Lang.Class({
         grid.attach_next_to(this._fileNameEntry, this._name, Gtk.PositionType.RIGHT, 2, 1);
 
         // Source value
-        var sourceLink = this._file.get_parent();
-        var sourcePath = sourceLink.get_path();
+        let sourceLink = this._file.get_parent();
+        let sourcePath = sourceLink.get_path();
 
         this._sourceData = new Gtk.LinkButton({ label: sourcePath,
                                                 uri: sourceLink.get_uri(),
@@ -157,7 +157,7 @@ var InfoDialog = new Lang.Class({
     },
 
     onDoneClicked: function() {
-        var newFileName = this._fileNameEntry.get_text();
+        let newFileName = this._fileNameEntry.get_text();
         this._file.set_display_name_async(newFileName, GLib.PRIORITY_DEFAULT, null, null);
         this.widget.destroy();
     },
diff --git a/src/listview.js b/src/listview.js
index c39a3f5..afe508a 100644
--- a/src/listview.js
+++ b/src/listview.js
@@ -18,25 +18,25 @@
  *
  */
 
-var _ = imports.gettext.gettext;
-var Gio = imports.gi.Gio;
-var GLib = imports.gi.GLib;
-var GObject = imports.gi.GObject;
-var Gst = imports.gi.Gst;
-var GstPbutils = imports.gi.GstPbutils;
-var Lang = imports.lang;
-var Signals = imports.signals;
-
-var AudioProfile = imports.audioProfile;
-var MainWindow = imports.mainWindow;
-var Record = imports.record;
-
-var EnumeratorState = {
+const _ = imports.gettext.gettext;
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const GObject = imports.gi.GObject;
+const Gst = imports.gi.Gst;
+const GstPbutils = imports.gi.GstPbutils;
+const Lang = imports.lang;
+const Signals = imports.signals;
+
+const AudioProfile = imports.audioProfile;
+const MainWindow = imports.mainWindow;
+const Record = imports.record;
+
+const EnumeratorState = {
     ACTIVE: 0,
     CLOSED: 1
 };
 
-var mediaTypeMap = {
+const mediaTypeMap = {
     FLAC: "FLAC",
     OGG_VORBIS: "Ogg Vorbis",
     OPUS: "Opus",
@@ -44,25 +44,25 @@ var mediaTypeMap = {
     MP4: "MP4"
 };
 
-var ListType = {
+const ListType = {
     NEW: 0,
     REFRESH: 1
 };
 
-var CurrentlyEnumerating = {
+const CurrentlyEnumerating = {
     TRUE: 0,
     FALSE: 1
 };
 
-var allFilesInfo = null;
-var currentlyEnumerating = null;
-var fileInfo = null;
-var listType = null;
-var startRecording = false;
-var stopVal = null;
+let allFilesInfo = null;
+let currentlyEnumerating = null;
+let fileInfo = null;
+let listType = null;
+let startRecording = false;
+let stopVal = null;
 var trackNumber = 0;
 
-var Listview = new Lang.Class({
+const Listview = new Lang.Class({
     Name: "Listview",
 
     _init: function() {
@@ -100,14 +100,14 @@ var Listview = new Lang.Class({
         try{
             this._enumerator.next_files_async(20, GLib.PRIORITY_DEFAULT, null, Lang.bind(this,
                 function(obj, res) {
-                    var files = obj.next_files_finish(res);
+                    let files = obj.next_files_finish(res);
 
                     if (files.length) {
                         files.forEach(Lang.bind(this,
                             function(file) {
-                                var returnedName = file.get_attribute_as_string("standard::display-name");
+                                let returnedName = file.get_attribute_as_string("standard::display-name");
                                 try {
-                                    var returnedNumber = parseInt(returnedName.split(" ")[1]);
+                                    let returnedNumber = parseInt(returnedName.split(" ")[1]);
                                     if (returnedNumber > trackNumber)
                                         trackNumber = returnedNumber;
 
@@ -118,19 +118,19 @@ var Listview = new Lang.Class({
                                     log("Tracknumber not returned");
                                     // Don't handle the error
                                 }
-                                var finalFileName = GLib.build_filenamev([this._saveDir.get_path(),
+                                let finalFileName = GLib.build_filenamev([this._saveDir.get_path(),
                                                                           returnedName]);
-                                var fileUri = GLib.filename_to_uri(finalFileName, null);
-                                var timeVal = file.get_modification_time();
-                                var date = GLib.DateTime.new_from_timeval_local(timeVal);
-                                var dateModifiedSortString = date.format("%Y%m%d%H%M%S");
-                                var dateTime = GLib.DateTime.new_from_timeval_local(timeVal);
-                                var dateModifiedDisplayString = 
MainWindow.displayTime.getDisplayTime(dateTime);
-                                var dateCreatedYes = file.has_attribute("time::created");
-                                var dateCreatedString = null;
+                                let fileUri = GLib.filename_to_uri(finalFileName, null);
+                                let timeVal = file.get_modification_time();
+                                let date = GLib.DateTime.new_from_timeval_local(timeVal);
+                                let dateModifiedSortString = date.format("%Y%m%d%H%M%S");
+                                let dateTime = GLib.DateTime.new_from_timeval_local(timeVal);
+                                let dateModifiedDisplayString = 
MainWindow.displayTime.getDisplayTime(dateTime);
+                                let dateCreatedYes = file.has_attribute("time::created");
+                                let dateCreatedString = null;
                                 if (this.dateCreatedYes) {
-                                    var dateCreatedVal = file.get_attribute_uint64("time::created");
-                                    var dateCreated = GLib.DateTime.new_from_timeval_local(dateCreatedVal);
+                                    let dateCreatedVal = file.get_attribute_uint64("time::created");
+                                    let dateCreated = GLib.DateTime.new_from_timeval_local(dateCreatedVal);
                                     dateCreatedString = MainWindow.displayTime.getDisplayTime(dateCreated);
                                 }
 
@@ -191,9 +191,9 @@ var Listview = new Lang.Class({
         this.idx = 0;
         this._discoverer = new GstPbutils.Discoverer();
         this._discoverer.start();
-        for (var i = 0; i <= this.endIdx; i++) {
-            var file = allFilesInfo[i];
-            var uri = file.uri;
+        for (let i = 0; i <= this.endIdx; i++) {
+            let file = allFilesInfo[i];
+            let uri = file.uri;
             this._discoverer.discover_uri_async(uri);
         }
         this._runDiscover();
@@ -202,7 +202,7 @@ var Listview = new Lang.Class({
      _runDiscover: function() {
           this._discoverer.connect('discovered', Lang.bind(this,
             function(_discoverer, info, error) {
-                var result = info.get_result();
+                let result = info.get_result();
                 this._onDiscovererFinished(result, info, error);
              }));
     },
@@ -211,16 +211,16 @@ var Listview = new Lang.Class({
         this.result = res;
         if (this.result == GstPbutils.DiscovererResult.OK && allFilesInfo[this.idx]) {
             this.tagInfo = info.get_tags();
-            var appString = "";
+            let appString = "";
             appString = this.tagInfo.get_value_index(Gst.TAG_APPLICATION_NAME, 0);
-            var dateTimeTag = this.tagInfo.get_date_time('datetime')[1];
-            var durationInfo = info.get_duration();
+            let dateTimeTag = this.tagInfo.get_date_time('datetime')[1];
+            let durationInfo = info.get_duration();
             allFilesInfo[this.idx].duration = durationInfo;
 
             /* this.file.dateCreated will usually be null since time::created it doesn't usually exist.
                Therefore, we prefer to set it with tags */
             if (dateTimeTag != null) {
-                var dateTimeCreatedString = dateTimeTag.to_g_date_time();
+                let dateTimeCreatedString = dateTimeTag.to_g_date_time();
 
                 if (dateTimeCreatedString) {
                     allFilesInfo[this.idx].dateCreated = 
MainWindow.displayTime.getDisplayTime(dateTimeCreatedString);
@@ -312,12 +312,12 @@ var Listview = new Lang.Class({
     },
 
     _getCapsForList: function(info) {
-        var discovererStreamInfo = null;
+        let discovererStreamInfo = null;
         discovererStreamInfo = info.get_stream_info();
-        var containerStreams = info.get_container_streams()[0];
-        var containerCaps = discovererStreamInfo.get_caps();
-        var audioStreams = info.get_audio_streams()[0];
-        var audioCaps =  audioStreams.get_caps();
+        let containerStreams = info.get_container_streams()[0];
+        let containerCaps = discovererStreamInfo.get_caps();
+        let audioStreams = info.get_audio_streams()[0];
+        let audioCaps =  audioStreams.get_caps();
 
         if (containerCaps.can_intersect(this.capTypes(AudioProfile.containerProfileMap.AUDIO_OGG))) {
 
@@ -348,7 +348,7 @@ var Listview = new Lang.Class({
     },
 
     capTypes: function(capString) {
-       var caps = Gst.Caps.from_string(capString);
+       let caps = Gst.Caps.from_string(capString);
        return caps;
     },
 
diff --git a/src/main.js b/src/main.js
index 8e44f1f..80e4f2a 100644
--- a/src/main.js
+++ b/src/main.js
@@ -36,7 +36,7 @@ pkg.require({ 'Gdk': '3.0',
               'GstAudio': '1.0',
               'GstPbutils': '1.0' });
 
-var Application = imports.application;
+const Application = imports.application;
 
 function main(argv) {
     return (new Application.Application()).run(argv);
diff --git a/src/mainWindow.js b/src/mainWindow.js
index dca8038..183cc8c 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -17,75 +17,75 @@
 *
 */
 
-var Gettext = imports.gettext;
-var _ = imports.gettext.gettext;
-var Gdk = imports.gi.Gdk;
-var GdkPixbuf = imports.gi.GdkPixbuf;
-var Gio = imports.gi.Gio;
-var GLib = imports.gi.GLib;
-var Gst = imports.gi.Gst;
-var Gtk = imports.gi.Gtk;
-var Lang = imports.lang;
-var Pango = imports.gi.Pango;
-
-var Application = imports.application;
-var AudioProfile = imports.audioProfile;
-var FileUtil = imports.fileUtil;
-var Info = imports.info;
-var Listview = imports.listview;
-var Params = imports.params;
-var Play = imports.play;
-var Preferences = imports.preferences;
-var Record = imports.record;
-var Waveform = imports.waveform;
-
-var activeProfile = null;
-var audioProfile = null;
-var displayTime = null;
-var grid = null;
-var groupGrid;
-var header;
-var list = null;
-var loadMoreButton = null;
-var offsetController = null;
-var play = null;
-var previousSelRow = null;
-var recordPipeline = null;
-var recordButton = null;
-var appMenuButton = null;
-var selectable = null;
-var setVisibleID = null;
-var UpperBoundVal = 182;
-var view = null;
-var volumeValue = [];
-var wave = null;
-
-var ActiveArea = {
+const Gettext = imports.gettext;
+const _ = imports.gettext.gettext;
+const Gdk = imports.gi.Gdk;
+const GdkPixbuf = imports.gi.GdkPixbuf;
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const Gst = imports.gi.Gst;
+const Gtk = imports.gi.Gtk;
+const Lang = imports.lang;
+const Pango = imports.gi.Pango;
+
+const Application = imports.application;
+const AudioProfile = imports.audioProfile;
+const FileUtil = imports.fileUtil;
+const Info = imports.info;
+const Listview = imports.listview;
+const Params = imports.params;
+const Play = imports.play;
+const Preferences = imports.preferences;
+const Record = imports.record;
+const Waveform = imports.waveform;
+
+let activeProfile = null;
+let audioProfile = null;
+let displayTime = null;
+let grid = null;
+let groupGrid;
+let header;
+let list = null;
+let loadMoreButton = null;
+let offsetController = null;
+let play = null;
+let previousSelRow = null;
+let recordPipeline = null;
+let recordButton = null;
+let appMenuButton = null;
+let selectable = null;
+let setVisibleID = null;
+let UpperBoundVal = 182;
+let view = null;
+let volumeValue = [];
+let wave = null;
+
+const ActiveArea = {
     RECORD: 0,
     PLAY: 1
 };
 
-var ListColumns = {
+const ListColumns = {
     NAME: 0,
     MENU: 1
 };
 
-var PipelineStates = {
+const PipelineStates = {
     PLAYING: 0,
     PAUSED: 1,
     STOPPED: 2
 };
 
-var RecordPipelineStates = {
+const RecordPipelineStates = {
     PLAYING: 0,
     PAUSED: 1,
     STOPPED: 2
 };
 
-var _TIME_DIVISOR = 60;
-var _SEC_TIMEOUT = 100;
+const _TIME_DIVISOR = 60;
+const _SEC_TIMEOUT = 100;
 
-var MainWindow = new Lang.Class({
+const MainWindow = new Lang.Class({
     Name: 'MainWindow',
     Extends: Gtk.ApplicationWindow,
 
@@ -122,7 +122,7 @@ var MainWindow = new Lang.Class({
     },
 
     _addAppMenu: function() {
-        var menu = new Gio.Menu();
+        let menu = new Gio.Menu();
         menu.append(_("Preferences"), 'app.preferences');
         menu.append(_("About Sound Recorder"), 'app.about');
 
@@ -134,7 +134,7 @@ var MainWindow = new Lang.Class({
     }
 });
 
-var MainView = new Lang.Class({
+const MainView = new Lang.Class({
     Name: 'MainView',
     Extends: Gtk.Stack,
 
@@ -157,16 +157,16 @@ var MainView = new Lang.Class({
                                         valign: Gtk.Align.CENTER });
         this._scrolledWin.add(this.emptyGrid);
 
-        var emptyPageImage = new Gtk.Image({ icon_name: 'audio-input-microphone-symbolic',
+        let emptyPageImage = new Gtk.Image({ icon_name: 'audio-input-microphone-symbolic',
                                              icon_size: Gtk.IconSize.DIALOG });
         emptyPageImage.get_style_context().add_class('dim-label');
         this.emptyGrid.add(emptyPageImage);
-        var emptyPageTitle = new Gtk.Label({ label: _("Add Recordings"),
+        let emptyPageTitle = new Gtk.Label({ label: _("Add Recordings"),
                                              halign: Gtk.Align.CENTER,
                                              valign: Gtk.Align.CENTER });
         emptyPageTitle.get_style_context().add_class('dim-label');
         this.emptyGrid.add(emptyPageTitle);
-        var emptyPageDirections = new Gtk.Label({ label: _("Use the <b>Record</b> button to make sound 
recordings"),
+        let emptyPageDirections = new Gtk.Label({ label: _("Use the <b>Record</b> button to make sound 
recordings"),
                                                   use_markup: true,
                                                   max_width_chars: 30,
                                                   halign: Gtk.Align.CENTER,
@@ -191,8 +191,8 @@ var MainView = new Lang.Class({
     onPlayStopClicked: function() {
         if (play.getPipeStates() == PipelineStates.PLAYING) {
             play.stopPlaying();
-            var listRow = this.listBox.get_selected_row();
-            var rowGrid = listRow.get_child();
+            let listRow = this.listBox.get_selected_row();
+            let rowGrid = listRow.get_child();
             rowGrid.foreach(Lang.bind(this,
                 function(child) {
 
@@ -232,18 +232,18 @@ var MainView = new Lang.Class({
 
     _formatTime: function(unformattedTime) {
         this.unformattedTime = unformattedTime;
-        var seconds = Math.floor(this.unformattedTime);
-        var hours = parseInt(seconds / Math.pow(_TIME_DIVISOR, 2));
-        var hoursString = ""
+        let seconds = Math.floor(this.unformattedTime);
+        let hours = parseInt(seconds / Math.pow(_TIME_DIVISOR, 2));
+        let hoursString = ""
 
         if (hours > 10)
             hoursString = hours + ":"
         else if (hours < 10 && hours > 0)
             hoursString = "0" + hours + ":"
 
-        var minuteString = parseInt(seconds / _TIME_DIVISOR) % _TIME_DIVISOR;
-        var secondString = parseInt(seconds % _TIME_DIVISOR);
-        var timeString =
+        let minuteString = parseInt(seconds / _TIME_DIVISOR) % _TIME_DIVISOR;
+        let secondString = parseInt(seconds % _TIME_DIVISOR);
+        let timeString =
             hoursString +
             (minuteString < 10 ? "0" + minuteString : minuteString)+
             ":" +
@@ -253,7 +253,7 @@ var MainView = new Lang.Class({
     },
 
     _updatePositionCallback: function() {
-        var position = MainWindow.play.queryPosition();
+        let position = MainWindow.play.queryPosition();
 
         if (position >= 0) {
             this.progressScale.set_value(position);
@@ -280,7 +280,7 @@ var MainView = new Lang.Class({
     },
 
     getVolume: function() {
-        var volumeValue = this.playVolume.get_value();
+        let volumeValue = this.playVolume.get_value();
 
         return volumeValue;
     },
@@ -288,8 +288,8 @@ var MainView = new Lang.Class({
     listBoxAdd: function() {
         selectable = true;
         this.groupGrid = groupGrid;
-        var playVolume = Application.application.getSpeakerVolume();
-        var micVolume = Application.application.getMicVolume();
+        let playVolume = Application.application.getSpeakerVolume();
+        let micVolume = Application.application.getMicVolume();
         volumeValue.push({ record: micVolume, play: playVolume });
         activeProfile = Application.application.getPreferences();
 
@@ -326,7 +326,7 @@ var MainView = new Lang.Class({
         this.toolbarStart.get_style_context().add_class(Gtk.STYLE_CLASS_LINKED);
 
         // finish button (stop recording)
-        var stopRecord = new Gtk.Button({ label: _("Done"),
+        let stopRecord = new Gtk.Button({ label: _("Done"),
                                           halign: Gtk.Align.FILL,
                                           valign: Gtk.Align.CENTER,
                                           hexpand: true,
@@ -360,8 +360,8 @@ var MainView = new Lang.Class({
 
         this.groupGrid.add(this._scrolledWin);
         this._scrolledWin.show();
-        var sounds = list.getItemCount();
-        var title;
+        let sounds = list.getItemCount();
+        let title;
         if (sounds > 0) {
             // Translators: This is the title in the headerbar
             title = Gettext.ngettext("%d Recorded Sound",
@@ -394,7 +394,7 @@ var MainView = new Lang.Class({
             this._files = [];
             this._files = list.getFilesInfoForList();
 
-            for (var i = this._startIdx; i <= this._endIdx; i++) {
+            for (let i = this._startIdx; i <= this._endIdx; i++) {
                 this.rowGrid = new Gtk.Grid({ name: i.toString(),
                                               height_request: 45,
                                               orientation: Gtk.Orientation.VERTICAL,
@@ -416,12 +416,12 @@ var MainView = new Lang.Class({
                 this._playListButton.show();
                 this._playListButton.connect('clicked', Lang.bind(this,
                     function(button){
-                        var row = button.get_parent().get_parent();
+                        let row = button.get_parent().get_parent();
                         this.listBox.select_row(row);
                         play.passSelected(row);
-                        var gridForName = row.get_child();
-                        var idx = parseInt(gridForName.name);
-                        var file = this._files[idx];
+                        let gridForName = row.get_child();
+                        let idx = parseInt(gridForName.name);
+                        let file = this._files[idx];
                         this.onPlayPauseToggled(row, file);
                     }));
 
@@ -437,7 +437,7 @@ var MainView = new Lang.Class({
                 this._pauseListButton.hide();
                 this._pauseListButton.connect('clicked', Lang.bind(this,
                     function(button){
-                        var row = button.get_parent().get_parent();
+                        let row = button.get_parent().get_parent();
                         this.listBox.select_row(row);
                         this.onPause(row);
                     }));
@@ -451,7 +451,7 @@ var MainView = new Lang.Class({
                                                  use_markup: true,
                                                  width_chars: 35,
                                                  xalign: 0 });
-                var markup = ('<b>'+ this._files[i].fileName + '</b>');
+                let markup = ('<b>'+ this._files[i].fileName + '</b>');
                 this._fileName.label = markup;
                 this._fileName.set_no_show_all(true);
                 this.rowGrid.attach(this._fileName, 3, 0, 10, 3);
@@ -518,11 +518,11 @@ var MainView = new Lang.Class({
                 this._info.image = Gtk.Image.new_from_icon_name("dialog-information-symbolic", 
Gtk.IconSize.BUTTON);
                 this._info.connect("clicked", Lang.bind(this,
                     function(button) {
-                        var row = button.get_parent().get_parent();
+                        let row = button.get_parent().get_parent();
                         this.listBox.select_row(row);
-                        var gridForName = row.get_child();
-                        var idx = parseInt(gridForName.name);
-                        var file = this._files[idx];
+                        let gridForName = row.get_child();
+                        let idx = parseInt(gridForName.name);
+                        let file = this._files[idx];
                         this._onInfoButton(file);
                     }));
                 this._info.set_tooltip_text(_("Info"));
@@ -536,7 +536,7 @@ var MainView = new Lang.Class({
                 this._delete.image = Gtk.Image.new_from_icon_name("user-trash-symbolic", 
Gtk.IconSize.BUTTON);
                 this._delete.connect("clicked", Lang.bind(this,
                     function(button) {
-                        var row = button.get_parent().get_parent();
+                        let row = button.get_parent().get_parent();
                         this.listBox.select_row(row);
                         this._deleteFile(row);
                     }));
@@ -591,10 +591,10 @@ var MainView = new Lang.Class({
     hasPreviousSelRow: function() {
        this.destroyLoadMoreButton();
            if (previousSelRow != null) {
-              var rowGrid = previousSelRow.get_child();
+              let rowGrid = previousSelRow.get_child();
               rowGrid.foreach(Lang.bind(this,
                 function(child) {
-                    var alwaysShow = child.get_no_show_all();
+                    let alwaysShow = child.get_no_show_all();
 
                     if (!alwaysShow)
                         child.hide();
@@ -631,7 +631,7 @@ var MainView = new Lang.Class({
     },
 
     rowGridCallback: function() {
-        var selectedRow = this.listBox.get_selected_row();
+        let selectedRow = this.listBox.get_selected_row();
         this.destroyLoadMoreButton();
 
         if (selectedRow) {
@@ -641,11 +641,11 @@ var MainView = new Lang.Class({
             }
 
             previousSelRow = selectedRow;
-            var selectedRowGrid = previousSelRow.get_child();
+            let selectedRowGrid = previousSelRow.get_child();
             selectedRowGrid.show_all();
             selectedRowGrid.foreach(Lang.bind(this,
                 function(child) {
-                    var alwaysShow = child.get_no_show_all();
+                    let alwaysShow = child.get_no_show_all();
 
                     if (!alwaysShow)
                         child.sensitive = true;
@@ -662,14 +662,14 @@ var MainView = new Lang.Class({
     },
 
     _getFileFromRow: function(selected) {
-        var fileForAction = null;
-        var rowGrid = selected.get_child();
+        let fileForAction = null;
+        let rowGrid = selected.get_child();
         rowGrid.foreach(Lang.bind(this,
             function(child) {
 
                 if (child.name == "FileNameLabel") {
-                    var name = child.get_text();
-                    var application = Gio.Application.get_default();
+                    let name = child.get_text();
+                    let application = Gio.Application.get_default();
                     fileForAction = application.saveDir.get_child_for_display_name(name);
                 }
              }));
@@ -678,18 +678,18 @@ var MainView = new Lang.Class({
     },
 
     _deleteFile: function(selected) {
-        var fileToDelete = this._getFileFromRow(selected);
+        let fileToDelete = this._getFileFromRow(selected);
         fileToDelete.trash_async(GLib.PRIORITY_DEFAULT, null, null);
     },
 
     loadPlay: function(selected) {
-        var fileToPlay = this._getFileFromRow(selected);
+        let fileToPlay = this._getFileFromRow(selected);
 
         return fileToPlay;
     },
 
     _onInfoButton: function(selected) {
-        var infoDialog = new Info.InfoDialog(selected);
+        let infoDialog = new Info.InfoDialog(selected);
 
         infoDialog.widget.connect('response', Lang.bind(this,
             function(widget, response) {
@@ -711,14 +711,14 @@ var MainView = new Lang.Class({
     },
 
     setNameLabel: function(newName, oldName, index) {
-        var selected = this.listBox.get_row_at_index(index);
-        var rowGrid = selected.get_child();
+        let selected = this.listBox.get_row_at_index(index);
+        let rowGrid = selected.get_child();
         rowGrid.foreach(Lang.bind(this,
             function(child) {
 
                 if (child.name == "FileNameLabel") {
-                    var name = child.get_text();
-                    var markup = ('<b>'+ newName + '</b>');
+                    let name = child.get_text();
+                    let markup = ('<b>'+ newName + '</b>');
                     child.label = markup;
                 }
              }));
@@ -726,11 +726,11 @@ var MainView = new Lang.Class({
     },
 
     onPause: function(listRow) {
-        var activeState = play.getPipeStates();
+        let activeState = play.getPipeStates();
 
         if (activeState == PipelineStates.PLAYING) {
             play.pausePlaying();
-            var rowGrid = listRow.get_child();
+            let rowGrid = listRow.get_child();
             rowGrid.foreach(Lang.bind(this,
                 function(child) {
 
@@ -749,12 +749,12 @@ var MainView = new Lang.Class({
 
     onPlayPauseToggled: function(listRow, selFile) {
         setVisibleID = ActiveArea.PLAY;
-        var activeState = play.getPipeStates();
+        let activeState = play.getPipeStates();
 
         if (activeState != PipelineStates.PLAYING) {
             play.startPlaying();
 
-            var rowGrid = listRow.get_child();
+            let rowGrid = listRow.get_child();
             rowGrid.foreach(Lang.bind(this,
                 function(child) {
 
@@ -795,7 +795,7 @@ var MainView = new Lang.Class({
     }
 });
 
-var RecordButton = new Lang.Class({
+const RecordButton = new Lang.Class({
     Name: "RecordButton",
     Extends: Gtk.Button,
 
@@ -832,16 +832,16 @@ var RecordButton = new Lang.Class({
     }
 });
 
-var EncoderComboBox = new Lang.Class({
+const EncoderComboBox = new Lang.Class({
     Name: "EncoderComboBox",
     Extends: Gtk.ComboBoxText,
 
     // encoding setting labels in combobox
     _init: function() {
         this.parent();
-        var combo = [_("Ogg Vorbis"), _("Opus"), _("FLAC"), _("MP3"), _("MOV")];
+        let combo = [_("Ogg Vorbis"), _("Opus"), _("FLAC"), _("MP3"), _("MOV")];
 
-        for (var i = 0; i < combo.length; i++)
+        for (let i = 0; i < combo.length; i++)
             this.append_text(combo[i]);
         this.set_property('valign', Gtk.Align.CENTER);
         this.set_sensitive(true);
@@ -856,31 +856,31 @@ var EncoderComboBox = new Lang.Class({
     }
 });
 
-var ChannelsComboBox = new Lang.Class({
+const ChannelsComboBox = new Lang.Class({
     Name: "ChannelsComboBox",
     Extends: Gtk.ComboBoxText,
 
     // channel setting labels in combobox
     _init: function() {
         this.parent();
-        var combo = [_("Mono"), _("Stereo")];
+        let combo = [_("Mono"), _("Stereo")];
 
-        for (var i = 0; i < combo.length; i++)
+        for (let i = 0; i < combo.length; i++)
             this.append_text(combo[i]);
         this.set_property('valign', Gtk.Align.CENTER);
         this.set_sensitive(true);
-        var chanProfile = Application.application.getChannelsPreferences();
+        let chanProfile = Application.application.getChannelsPreferences();
         this.set_active(chanProfile);
         this.connect("changed", Lang.bind(this, this._onChannelComboBoxTextChanged));
     },
 
     _onChannelComboBoxTextChanged: function() {
-        var channelProfile = this.get_active();
+        let channelProfile = this.get_active();
         Application.application.setChannelsPreferences(channelProfile);
     }
 });
 
-var LoadMoreButton = new Lang.Class({
+const LoadMoreButton = new Lang.Class({
     Name: 'LoadMoreButton',
     Extends: Gtk.Button,
 
diff --git a/src/params.js b/src/params.js
index e8d5663..4074ef9 100644
--- a/src/params.js
+++ b/src/params.js
@@ -24,10 +24,10 @@ var $API_VERSION = [1, 0];
 // Extend a method to allow more params in a subclass
 // The superclass can safely use Params.parse(), it won't see
 // the extensions.
-// var MyClass = new Lang.Class({
+// const MyClass = new Lang.Class({
 //       ...
 //       method: function(params) {
-//           var mine = Params.filter(params, { anInt: 42 });
+//           let mine = Params.filter(params, { anInt: 42 });
 //           this.parent(params);
 //           ... mine.anInt ...
 //       }
@@ -48,7 +48,7 @@ var $API_VERSION = [1, 0];
 // Return value: a new object, containing the merged parameters from
 // @params and @defaults
 function parse(params, defaults) {
-    var ret = {}, prop;
+    let ret = {}, prop;
     params = params || {};
 
     for (prop in params) {
@@ -78,7 +78,7 @@ function parse(params, defaults) {
 // Return value: a new object, containing the merged parameters from
 // @params and @defaults
 function fill(params, defaults) {
-    var ret = {}, prop;
+    let ret = {}, prop;
     params = params || {};
 
     for (prop in params)
@@ -109,7 +109,7 @@ function fill(params, defaults) {
 // Return value: a new object, containing the merged parameters from
 // @params and @defaults
 function filter(params, defaults) {
-    var ret = {}, prop;
+    let ret = {}, prop;
     params = params || {};
 
     for (prop in defaults) {
diff --git a/src/play.js b/src/play.js
index b27edc1..e20dd4e 100644
--- a/src/play.js
+++ b/src/play.js
@@ -17,42 +17,42 @@
  *
  */
 
-var _ = imports.gettext.gettext;
-var Gio = imports.gi.Gio;
-var GLib = imports.gi.GLib;
-var Gst = imports.gi.Gst;
-var GstAudio = imports.gi.GstAudio;
-var GstPbutils = imports.gi.GstPbutils;
-var Gtk = imports.gi.Gtk;
-var Lang = imports.lang;
-var Mainloop = imports.mainloop;
-
-var Application = imports.application;
-var MainWindow = imports.mainWindow;
-var Waveform = imports.waveform;
-
-var PipelineStates = {
+const _ = imports.gettext.gettext;
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const Gst = imports.gi.Gst;
+const GstAudio = imports.gi.GstAudio;
+const GstPbutils = imports.gi.GstPbutils;
+const Gtk = imports.gi.Gtk;
+const Lang = imports.lang;
+const Mainloop = imports.mainloop;
+
+const Application = imports.application;
+const MainWindow = imports.mainWindow;
+const Waveform = imports.waveform;
+
+const PipelineStates = {
     PLAYING: 0,
     PAUSED: 1,
     STOPPED: 2,
     NULL: 3
 };
 
-var ErrState = {
+const ErrState = {
     OFF: 0,
     ON: 1
 }
 
-var errorDialogState;
+let errorDialogState;
 
-var _TENTH_SEC = 100000000;
+const _TENTH_SEC = 100000000;
 
-var Play = new Lang.Class({
+const Play = new Lang.Class({
     Name: "Play",
 
     _playPipeline: function() {
         errorDialogState = ErrState.OFF;
-        var uri = this._fileToPlay.get_uri();
+        let uri = this._fileToPlay.get_uri();
         this.play = Gst.ElementFactory.make("playbin", "play");
         this.play.set_property("uri", uri);
         this.sink = Gst.ElementFactory.make("pulsesink", "sink");
@@ -134,7 +134,7 @@ var Play = new Lang.Class({
 
     _onMessageReceived: function(message) {
         this.localMsg = message;
-        var msg = message.type;
+        let msg = message.type;
         switch(msg) {
 
         case Gst.MessageType.EOS:
@@ -142,12 +142,12 @@ var Play = new Lang.Class({
             break;
 
         case Gst.MessageType.WARNING:
-            var warningMessage = message.parse_warning()[0];
+            let warningMessage = message.parse_warning()[0];
             log(warningMessage.toString());
             break;
 
         case Gst.MessageType.ERROR:
-            var errorMessage = message.parse_error()[0];
+            let errorMessage = message.parse_error()[0];
             this._showErrorDialog(errorMessage.toString());
             errorDialogState = ErrState.ON;
             break;
@@ -178,7 +178,7 @@ var Play = new Lang.Class({
     },
 
     _updateTime: function() {
-        var time = this.play.query_position(Gst.Format.TIME)[1]/Gst.SECOND;
+        let time = this.play.query_position(Gst.Format.TIME)[1]/Gst.SECOND;
         this.trackDuration = this.play.query_duration(Gst.Format.TIME)[1];
         this.trackDurationSecs = this.trackDuration/Gst.SECOND;
 
@@ -188,7 +188,7 @@ var Play = new Lang.Class({
             MainWindow.view.setLabel(0);
         }
 
-        var absoluteTime = 0;
+        let absoluteTime = 0;
 
         if  (this.clock == null) {
             this.clock = this.play.get_clock();
@@ -203,7 +203,7 @@ var Play = new Lang.Class({
             this.baseTime = absoluteTime;
 
         this.runTime = absoluteTime- this.baseTime;
-        var approxTime = Math.round(this.runTime/_TENTH_SEC);
+        let approxTime = Math.round(this.runTime/_TENTH_SEC);
 
         if (MainWindow.wave != null) {
             MainWindow.wave._drawEvent(approxTime);
@@ -213,7 +213,7 @@ var Play = new Lang.Class({
     },
 
     queryPosition: function() {
-        var position = 0;
+        let position = 0;
         while (position == 0) {
             position = this.play.query_position(Gst.Format.TIME)[1]/Gst.SECOND;
         }
@@ -239,7 +239,7 @@ var Play = new Lang.Class({
 
     _showErrorDialog: function(errorStrOne, errorStrTwo) {
         if (errorDialogState == ErrState.OFF) {
-            var errorDialog = new Gtk.MessageDialog ({ destroy_with_parent: true,
+            let errorDialog = new Gtk.MessageDialog ({ destroy_with_parent: true,
                                                        buttons: Gtk.ButtonsType.OK,
                                                        message_type: Gtk.MessageType.WARNING });
 
diff --git a/src/preferences.js b/src/preferences.js
index e0b56fd..800902f 100644
--- a/src/preferences.js
+++ b/src/preferences.js
@@ -17,23 +17,23 @@
 *
 */
 
-var Gio = imports.gi.Gio;
-var GLib = imports.gi.GLib;
-var Gtk = imports.gi.Gtk;
-var Lang = imports.lang;
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const Gtk = imports.gi.Gtk;
+const Lang = imports.lang;
 
-var _ = imports.gettext.gettext;
-var C_ = imports.gettext.pgettext;
+const _ = imports.gettext.gettext;
+const C_ = imports.gettext.pgettext;
 
-var MainWindow = imports.mainWindow;
-var Main = imports.main;
+const MainWindow = imports.mainWindow;
+const Main = imports.main;
 
-var formatComboBoxText = null;
-var channelsComboBoxText = null;
-var recordVolume= null;
-var playVolume = null;
+let formatComboBoxText = null;
+let channelsComboBoxText = null;
+let recordVolume= null;
+let playVolume = null;
 
-var Preferences = new Lang.Class({
+const Preferences = new Lang.Class({
     Name: 'Preferences',
     
      _init: function() {    
@@ -48,7 +48,7 @@ var Preferences = new Lang.Class({
                                         
         this.widget.set_transient_for(Gio.Application.get_default().get_active_window());
         
-        var grid = new Gtk.Grid ({ orientation: Gtk.Orientation.VERTICAL,
+        let grid = new Gtk.Grid ({ orientation: Gtk.Orientation.VERTICAL,
                                    row_homogeneous: true,
                                    column_homogeneous: true,
                                    halign: Gtk.Align.CENTER,
@@ -58,10 +58,10 @@ var Preferences = new Lang.Class({
                                    margin_end: 24,
                                    margin_start: 24,
                                    margin_top: 12 });
-        var contentArea = this.widget.get_content_area();
+        let contentArea = this.widget.get_content_area();
         contentArea.pack_start(grid, true, true, 2);
         
-        var formatLabel = new Gtk.Label({ label: _("Preferred format"),
+        let formatLabel = new Gtk.Label({ label: _("Preferred format"),
                                           halign: Gtk.Align.END });
         formatLabel.get_style_context().add_class('dim-label');
         grid.attach(formatLabel, 0, 0, 2, 1);
@@ -69,7 +69,7 @@ var Preferences = new Lang.Class({
         formatComboBoxText = new MainWindow.EncoderComboBox();
         grid.attach(formatComboBoxText, 2, 0, 2, 1);
         
-        var channelsLabel = new Gtk.Label({ label: _("Default mode"),
+        let channelsLabel = new Gtk.Label({ label: _("Default mode"),
                                             halign: Gtk.Align.END });
         channelsLabel.get_style_context().add_class('dim-label');
         grid.attach(channelsLabel, 0, 1, 2, 1);
@@ -77,7 +77,7 @@ var Preferences = new Lang.Class({
         channelsComboBoxText = new MainWindow.ChannelsComboBox();
         grid.attach(channelsComboBoxText, 2, 1, 2, 1);
 
-        var volumeLabel = new Gtk.Label({ label: _("Volume"),
+        let volumeLabel = new Gtk.Label({ label: _("Volume"),
                                           halign: Gtk.Align.END });
         volumeLabel.get_style_context().add_class('dim-label');
         grid.attach(volumeLabel, 0, 2, 2, 1);
@@ -92,7 +92,7 @@ var Preferences = new Lang.Class({
             }));
         grid.attach(playVolume, 2, 2, 2, 1);
         
-        var micVolLabel = new Gtk.Label({ label: _("Microphone"),
+        let micVolLabel = new Gtk.Label({ label: _("Microphone"),
                                           halign: Gtk.Align.END });
         micVolLabel.get_style_context().add_class('dim-label');
         grid.attach(micVolLabel, 0, 3, 2, 1);
diff --git a/src/record.js b/src/record.js
index 97169c2..73de73b 100644
--- a/src/record.js
+++ b/src/record.js
@@ -17,45 +17,45 @@
  *
  */
 
-var _ = imports.gettext.gettext;
-var Gio = imports.gi.Gio;
-var GLib = imports.gi.GLib;
-var GObject = imports.gi.GObject;
-var Gst = imports.gi.Gst;
-var GstAudio = imports.gi.GstAudio;
-var GstPbutils = imports.gi.GstPbutils;
-var Gtk = imports.gi.Gtk;
-var Pango = imports.gi.Pango;
-var Lang = imports.lang;
-var Mainloop = imports.mainloop;
-var Signals = imports.signals;
-
-var Application = imports.application;
-var AudioProfile = imports.audioProfile;
-var MainWindow = imports.mainWindow;
-var Listview = imports.listview;
-
-var PipelineStates = {
+const _ = imports.gettext.gettext;
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const GObject = imports.gi.GObject;
+const Gst = imports.gi.Gst;
+const GstAudio = imports.gi.GstAudio;
+const GstPbutils = imports.gi.GstPbutils;
+const Gtk = imports.gi.Gtk;
+const Pango = imports.gi.Pango;
+const Lang = imports.lang;
+const Mainloop = imports.mainloop;
+const Signals = imports.signals;
+
+const Application = imports.application;
+const AudioProfile = imports.audioProfile;
+const MainWindow = imports.mainWindow;
+const Listview = imports.listview;
+
+const PipelineStates = {
     PLAYING: 0,
     PAUSED: 1,
     STOPPED: 2
 };
 
-var ErrState = {
+const ErrState = {
     OFF: 0,
     ON: 1
 }
 
-var Channels = {
+const Channels = {
     MONO: 0,
     STEREO: 1
 }
 
-var _TENTH_SEC = 100000000;
+const _TENTH_SEC = 100000000;
 
-var errorDialogState;
+let errorDialogState;
 
-var Record = new Lang.Class({
+const Record = new Lang.Class({
     Name: "Record",
 
     _recordPipeline: function() {
@@ -64,7 +64,7 @@ var Record = new Lang.Class({
         this._view = MainWindow.view;
         this._buildFileName = new BuildFileName();
         this.initialFileName = this._buildFileName.buildInitialFilename();
-        var localDateTime = this._buildFileName.getOrigin();
+        let localDateTime = this._buildFileName.getOrigin();
         this.gstreamerDateTime = Gst.DateTime.new_from_g_date_time(localDateTime);
 
         if (this.initialFileName == -1) {
@@ -77,9 +77,9 @@ var Record = new Lang.Class({
         this.srcElement = Gst.ElementFactory.make("pulsesrc", "srcElement");
 
         if (this.srcElement == null) {
-            var inspect = "gst-inspect-1.0 pulseaudio";
-            var [res, out, err, status] =  GLib.spawn_command_line_sync(inspect);
-            var err_str = String(err)
+            let inspect = "gst-inspect-1.0 pulseaudio";
+            let [res, out, err, status] =  GLib.spawn_command_line_sync(inspect);
+            let err_str = String(err)
             if (err_str.replace(/\W/g, ''))
                 this._showErrorDialog(_("Please install the GStreamer 1.0 PulseAudio plugin."));
             else
@@ -111,7 +111,7 @@ var Record = new Lang.Class({
         this.ebin = Gst.ElementFactory.make("encodebin", "ebin");
         this.ebin.connect("element-added", Lang.bind(this,
             function(ebin, element) {
-                var factory = element.get_factory();
+                let factory = element.get_factory();
 
                 if (factory != null) {
                         this.hasTagSetter = factory.has_interface("GstTagSetter");
@@ -127,8 +127,8 @@ var Record = new Lang.Class({
                 }
             }));
         this.pipeline.add(this.ebin);
-        var ebinProfile = this.ebin.set_property("profile", this._mediaProfile);
-        var srcpad = this.ebin.get_static_pad("src");
+        let ebinProfile = this.ebin.set_property("profile", this._mediaProfile);
+        let srcpad = this.ebin.get_static_pad("src");
         this.filesink = Gst.ElementFactory.make("filesink", "filesink");
         this.filesink.set_property("location", this.initialFileName);
         this.pipeline.add(this.filesink);
@@ -139,11 +139,11 @@ var Record = new Lang.Class({
             this.onEndOfStream();
         }
 
-        var srcLink = this.srcElement.link(this.audioConvert);
-        var audioConvertLink = this.audioConvert.link_filtered(this.level, this.caps);
-        var levelLink = this.level.link(this.volume);
-        var volLink = this.volume.link(this.ebin);
-        var ebinLink = this.ebin.link(this.filesink);
+        let srcLink = this.srcElement.link(this.audioConvert);
+        let audioConvertLink = this.audioConvert.link_filtered(this.level, this.caps);
+        let levelLink = this.level.link(this.volume);
+        let volLink = this.volume.link(this.ebin);
+        let ebinLink = this.ebin.link(this.filesink);
 
         if (!srcLink || !audioConvertLink || !levelLink || !ebinLink) {
             this._showErrorDialog(_("Not all of the elements were linked."));
@@ -156,7 +156,7 @@ var Record = new Lang.Class({
     },
 
     _updateTime: function() {
-        var time = this.pipeline.query_position(Gst.Format.TIME)[1]/Gst.SECOND;
+        let time = this.pipeline.query_position(Gst.Format.TIME)[1]/Gst.SECOND;
 
         if (time >= 0) {
             this._view.setLabel(time, 0);
@@ -178,7 +178,7 @@ var Record = new Lang.Class({
         if (!this.pipeline || this.pipeState == PipelineStates.STOPPED )
             this._recordPipeline();
 
-        var ret = this.pipeline.set_state(Gst.State.PLAYING);
+        let ret = this.pipeline.set_state(Gst.State.PLAYING);
         this.pipeState = PipelineStates.PLAYING;
 
         if (ret == Gst.StateChangeReturn.FAILURE) {
@@ -195,7 +195,7 @@ var Record = new Lang.Class({
     },
 
     stopRecording: function() {
-        var sent = this.pipeline.send_event(Gst.Event.new_eos());
+        let sent = this.pipeline.send_event(Gst.Event.new_eos());
 
         if (this.timeout) {
             GLib.source_remove(this.timeout);
@@ -219,19 +219,19 @@ var Record = new Lang.Class({
 
     _onMessageReceived: function(message) {
         this.localMsg = message;
-        var msg = message.type;
+        let msg = message.type;
         switch(msg) {
 
         case Gst.MessageType.ELEMENT:
             if (GstPbutils.is_missing_plugin_message(this.localMsg)) {
-                var errorOne = null;
-                var errorTwo = null;
-                var detail = GstPbutils.missing_plugin_message_get_installer_detail(this.localMsg);
+                let errorOne = null;
+                let errorTwo = null;
+                let detail = GstPbutils.missing_plugin_message_get_installer_detail(this.localMsg);
 
                 if (detail != null)
                     errorOne = detail;
 
-                var description = GstPbutils.missing_plugin_message_get_description(this.localMsg);
+                let description = GstPbutils.missing_plugin_message_get_description(this.localMsg);
 
                 if (description != null)
                     errorTwo = description;
@@ -241,23 +241,23 @@ var Record = new Lang.Class({
                 break;
             }
 
-            var s = message.get_structure();
+            let s = message.get_structure();
                 if (s) {
                     if (s.has_name("level")) {
-                        var p = null;
-                        var peakVal = 0;
-                        var val = 0;
-                        var st = s.get_value("timestamp");
-                        var dur = s.get_value("duration");
-                        var runTime = s.get_value("running-time");
+                        let p = null;
+                        let peakVal = 0;
+                        let val = 0;
+                        let st = s.get_value("timestamp");
+                        let dur = s.get_value("duration");
+                        let runTime = s.get_value("running-time");
                         peakVal = s.get_value("peak");
 
                         if (peakVal) {
-                            var val = peakVal.get_nth(0);
+                            let val = peakVal.get_nth(0);
 
                             if (val > 0)
                                            val = 0;
-                            var value = Math.pow(10, val/20);
+                            let value = Math.pow(10, val/20);
                             this.peak = value;
 
 
@@ -275,7 +275,7 @@ var Record = new Lang.Class({
                                 this.baseTime = this.absoluteTime;
 
                             this.runTime = this.absoluteTime- this.baseTime;
-                            var approxTime = Math.round(this.runTime/_TENTH_SEC);
+                            let approxTime = Math.round(this.runTime/_TENTH_SEC);
                             MainWindow.wave._drawEvent(approxTime, this.peak);
                             }
                         }
@@ -287,12 +287,12 @@ var Record = new Lang.Class({
             break;
 
         case Gst.MessageType.WARNING:
-            var warningMessage = message.parse_warning()[0];
+            let warningMessage = message.parse_warning()[0];
             log(warningMessage.toString());
             break;
 
         case Gst.MessageType.ERROR:
-            var errorMessage = message.parse_error();
+            let errorMessage = message.parse_error();
             this._showErrorDialog(errorMessage.toString());
             errorDialogState = ErrState.ON;
             break;
@@ -307,8 +307,8 @@ var Record = new Lang.Class({
 
     _getChannels: function() {
 
-        var channels = null;
-        var channelsPref = Application.application.getChannelsPreferences();
+        let channels = null;
+        let channelsPref = Application.application.getChannelsPreferences();
 
         switch(channelsPref) {
         case Channels.MONO:
@@ -328,7 +328,7 @@ var Record = new Lang.Class({
 
     _showErrorDialog: function(errorStrOne, errorStrTwo) {
         if (errorDialogState == ErrState.OFF) {
-            var errorDialog = new Gtk.MessageDialog ({ modal: true,
+            let errorDialog = new Gtk.MessageDialog ({ modal: true,
                                                        destroy_with_parent: true,
                                                        buttons: Gtk.ButtonsType.OK,
                                                        message_type: Gtk.MessageType.WARNING });
@@ -351,7 +351,7 @@ var Record = new Lang.Class({
     }
 });
 
-var BuildFileName = new Lang.Class({
+const BuildFileName = new Lang.Class({
     Name: "BuildFileName",
 
     buildInitialFilename: function() {
diff --git a/src/util.js b/src/util.js
index 854058b..67c4faa 100644
--- a/src/util.js
+++ b/src/util.js
@@ -25,13 +25,13 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-var Gdk = imports.gi.Gdk;
-var Gio = imports.gi.Gio;
-var Gtk = imports.gi.Gtk;
+const Gdk = imports.gi.Gdk;
+const Gio = imports.gi.Gio;
+const Gtk = imports.gi.Gtk;
 
 function loadStyleSheet() {
-    var uri = 'resource:///org/gnome/SoundRecorder/css/application.css';
-    var provider = new Gtk.CssProvider();
+    let uri = 'resource:///org/gnome/SoundRecorder/css/application.css';
+    let provider = new Gtk.CssProvider();
     provider.load_from_file(Gio.File.new_for_uri(uri));
     Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
                                              provider,
diff --git a/src/waveform.js b/src/waveform.js
index 66ae36c..ca7e2cc 100644
--- a/src/waveform.js
+++ b/src/waveform.js
@@ -19,40 +19,40 @@
 
 // based on code from Pitivi
 
-var Cairo = imports.cairo;
-var Gio = imports.gi.Gio;
-var GLib = imports.gi.GLib;
-var GObject = imports.gi.GObject;
-var Gst = imports.gi.Gst;
-var GstAudio = imports.gi.GstAudio;
-var Gtk = imports.gi.Gtk;
-var Lang = imports.lang;
-var Mainloop = imports.mainloop;
-
-var _ = imports.gettext.gettext;
-var C_ = imports.gettext.pgettext;
-
-var MainWindow = imports.mainWindow;
-var Application = imports.application;
-
-var INTERVAL = 100000000;
-var peaks = [];
-var pauseVal = 10;
-var waveSamples = 40;
-
-var WaveType = {
+const Cairo = imports.cairo;
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+const GObject = imports.gi.GObject;
+const Gst = imports.gi.Gst;
+const GstAudio = imports.gi.GstAudio;
+const Gtk = imports.gi.Gtk;
+const Lang = imports.lang;
+const Mainloop = imports.mainloop;
+
+const _ = imports.gettext.gettext;
+const C_ = imports.gettext.pgettext;
+
+const MainWindow = imports.mainWindow;
+const Application = imports.application;
+
+const INTERVAL = 100000000;
+const peaks = [];
+const pauseVal = 10;
+const waveSamples = 40;
+
+const WaveType = {
     RECORD: 0,
     PLAY: 1
 };
 
-var WaveForm = new Lang.Class({
+const WaveForm = new Lang.Class({
     Name: 'WaveForm',
 
     _init: function(grid, file) {
         this._grid = grid;
 
-        var placeHolder = -100;
-        for (var i = 0; i < 40; i++)
+        let placeHolder = -100;
+        for (let i = 0; i < 40; i++)
             peaks.push(placeHolder);
         if (file) {
             this.waveType = WaveType.PLAY;
@@ -63,9 +63,9 @@ var WaveForm = new Lang.Class({
           this.waveType = WaveType.RECORD;
         }
 
-        var gridWidth = 0;
-        var drawingWidth = 0;
-        var drawingHeight = 0;
+        let gridWidth = 0;
+        let drawingWidth = 0;
+        let drawingHeight = 0;
         this.drawing = Gtk.DrawingArea.new();
         if (this.waveType == WaveType.RECORD) {
             this.drawing.set_property("valign", Gtk.Align.FILL);
@@ -92,8 +92,8 @@ var WaveForm = new Lang.Class({
         this.pipeline =
             Gst.parse_launch("uridecodebin name=decode uri=" + this._uri + " ! audioconvert ! 
audio/x-raw,channels=2 ! level name=level interval=100000000 post-messages=true ! fakesink qos=false");
         this._level = this.pipeline.get_by_name("level");
-        var decode = this.pipeline.get_by_name("decode");
-        var bus = this.pipeline.get_bus();
+        let decode = this.pipeline.get_by_name("decode");
+        let bus = this.pipeline.get_bus();
         bus.add_signal_watch();
         GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, Application.SIGINT, 
Application.application.onWindowDestroy);
         GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, Application.SIGTERM, 
Application.application.onWindowDestroy);
@@ -110,28 +110,28 @@ var WaveForm = new Lang.Class({
     },
 
     _messageCb: function(message) {
-        var msg = message.type;
+        let msg = message.type;
 
         switch(msg) {
         case Gst.MessageType.ELEMENT:
-            var s = message.get_structure();
+            let s = message.get_structure();
 
             if (s) {
 
                 if (s.has_name("level")) {
-                    var peaknumber = 0;
-                    var st = s.get_value("timestamp");
-                    var dur = s.get_value("duration");
-                    var runTime = s.get_value("running-time");
-                    var peakVal = s.get_value("peak");
+                    let peaknumber = 0;
+                    let st = s.get_value("timestamp");
+                    let dur = s.get_value("duration");
+                    let runTime = s.get_value("running-time");
+                    let peakVal = s.get_value("peak");
 
                     if (peakVal) {
-                        var val = peakVal.get_nth(0);
+                        let val = peakVal.get_nth(0);
 
                         if (val > 0)
                             val = 0;
 
-                        var value = Math.pow(10, val/20);
+                        let value = Math.pow(10, val/20);
                         peaks.push(value);
                     }
                 }
@@ -161,7 +161,7 @@ var WaveForm = new Lang.Class({
     },
 
     fillSurface: function(drawing, cr) {
-        var start = 0;
+        let start = 0;
 
         if (this.waveType == WaveType.PLAY) {
 
@@ -175,14 +175,14 @@ var WaveForm = new Lang.Class({
             start = this.recordTime;
         }
 
-        var i = 0;
-        var xAxis = 0;
-        var end = start + 40;
-        var width = this.drawing.get_allocated_width();
-        var waveheight = this.drawing.get_allocated_height();
-        var length = this.nSamples;
-        var pixelsPerSample = width/waveSamples;
-        var gradient = new Cairo.LinearGradient(0, 0, width , waveheight);
+        let i = 0;
+        let xAxis = 0;
+        let end = start + 40;
+        let width = this.drawing.get_allocated_width();
+        let waveheight = this.drawing.get_allocated_height();
+        let length = this.nSamples;
+        let pixelsPerSample = width/waveSamples;
+        let gradient = new Cairo.LinearGradient(0, 0, width , waveheight);
         if (this.waveType == WaveType.PLAY) {
               gradient.addColorStopRGBA(0.75, 0.94, 1.0, 0.94, 0.75);
               gradient.addColorStopRGBA(0.0, 0.94, 1.0, 0.94, 0.22);
@@ -204,7 +204,7 @@ var WaveForm = new Lang.Class({
 
             // Start drawing when we reach the first non-null array member
             if (peaks[i] != null && peaks[i] >= 0) {
-                var idx = i - 1;
+                let idx = i - 1;
 
                 if (start >= 40 && xAxis == 0) {
                      cr.moveTo((xAxis * pixelsPerSample), waveheight);
@@ -224,7 +224,7 @@ var WaveForm = new Lang.Class({
     },
 
     _drawEvent: function(playTime, recPeaks) {
-        var lastTime;
+        let lastTime;
 
         if (this.waveType == WaveType.PLAY) {
             lastTime = this.playTime;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]