<commit_before>/*
 *  (c) <NAME>. 3DaGoGo, Inc. (<EMAIL>)
 *
 *  Distributed under the GNU Affero General Public License http://www.gnu.org/licenses/agpl.html
 */

var AppRouter = Backbone.Router.extend({
  homeView: null,
  filesView: null,
  controlView: null,
  // adding filament-wizard views
  filamentLoadView: null,
  filamentUnloadView: null,
  settingsView: null,
  printingView: null,
  terminalView: null,
  cameraView: null,
  suppliesView: null,
  helpView: null,
  utilityView: null,
  aboutView: null,
  routes: {
    "": "home",
    "files": "files",
    "file-info/:fileId": "fileInfo",
    "control": "control",
    // adding routes for the filament-wizards
    "filament-load-wizard": "filamentLoad",
    "filament-unload-wizard": "filamentUnload",
    "printing": "printing",
    "settings": "settings",
    "utilities": "utilities",
    "about":"about",
    "settings/:page": "settings",
    "gcode-terminal": "terminal",
    "camera": "camera",
    "supplies": "supplies",
    "help": "help",
    "*notFound": "notFound"
  },
  turningOff: false,
  execute: function(callback, args)
  {
    if (callback) {
      is_paused = app.socketData.get('paused');
      is_printing = app.socketData.get('printing');

      if (is_printing || is_paused) {
        app.setPrinting();

        if  (callback != this.printing &&
          (callback != this.control || !is_paused)
        ) {
          this.navigate('printing', {trigger: true, replace:true});
          return;
        }
      } else if (callback == this.printing) {
        this.navigate('', {trigger: true, replace:true});
        return;
      }

      callback.apply(this, args);
    }
  },
  home: function()
  {
    if (!this.homeView) {
      this.homeView = new HomeView({forceSync: false});
    }

    this.selectView(this.homeView);
    app.selectQuickNav('dash');
  },
  files: function()
  {
    this.loadFilesView(false);
    this.selectView(this.filesView);
    app.selectQuickNav('files');
  },
  fileInfo: function(fileId)
  {
    var showDlg = _.bind(function(success) {
      if (success) {
        this.filesView.fileInfo(fileId);
      }
    }, this);

    if (this.filesView) {
      this.filesView.printFilesListView.refresh(true, showDlg);
    } else {
      this.filesView = new FilesView({
        forceSync: true,
        syncCompleted: showDlg
      });
    }

    this.navigate('files', {trigger: true, replace:true});
  },
  control: function()
  {
    if (!this.controlView) {
      this.controlView = new ControlView();
    }

    this.selectView(this.controlView);
    app.selectQuickNav('control');
  },
  /*
    adding function to handle the routing for 'filament-load' & 'filament-unload'
    wizard
  */
  filamentLoad: function() {
    if (!this.filamentLoadView) {
      this.filamentLoadView = new FilamentLoadView();
    }

    this.selectView(this.filamentLoadView);
  },
  filamentUnload: function() {
    if (!this.filamentUnloadView) {
      this.filamentUnloadView = new FilamentUnloadView();
    }

    this.selectView(this.filamentUnloadView);
  },
  printing: function()
  {
    if (!this.printingView) {
      this.printingView = new PrintingView();
    }

    this.selectView(this.printingView);
  },
  settings: function(page)
  {
    if (!this.settingsView) {
      this.settingsView = new SettingsView();
    }

    this.selectView(this.settingsView);
    this.settingsView.menu.changeActive(page || 'printer-connection');
    app.selectQuickNav('settings');
  },
   utilities: function()<commit_msg>Added routes for the 'print-from-storage' module<commit_after>/*
 *  (c) <NAME>. 3DaGoGo, Inc. (<EMAIL>.com)
 *
 *  Distributed under the GNU Affero General Public License http://www.gnu.org/licenses/agpl.html
 */

var AppRouter = Backbone.Router.extend({
  homeView: null,
  filesView: null,
  controlView: null,
  // adding filament-wizard views
  filamentLoadView: null,
  filamentUnloadView: null,
  // adding print-from-storage view
  printFromStorageView: null,
  settingsView: null,
  printingView: null,
  terminalView: null,
  cameraView: null,
  suppliesView: null,
  helpView: null,
  utilityView: null,
  aboutView: null,
  routes: {
    "": "home",
    "files": "files",
    "file-info/:fileId": "fileInfo",
    "control": "control",
    // adding routes for the filament-wizards
    "filament-load-wizard": "filamentLoad",
    "filament-unload-wizard": "filamentUnload",
    // adding routes for the print-from-storage
    "print-from-storage": "printFromStorage",
    "printing": "printing",
    "settings": "settings",
    "utilities": "utilities",
    "about":"about",
    "settings/:page": "settings",
    "gcode-terminal": "terminal",
    "camera": "camera",
    "supplies": "supplies",
    "help": "help",
    "*notFound": "notFound"
  },
  turningOff: false,
  execute: function(callback, args)
  {
    if (callback) {
      is_paused = app.socketData.get('paused');
      is_printing = app.socketData.get('printing');

      if (is_printing || is_paused) {
        app.setPrinting();

        if  (callback != this.printing &&
          (callback != this.control || !is_paused)
        ) {
          this.navigate('printing', {trigger: true, replace:true});
          return;
        }
      } else if (callback == this.printing) {
        this.navigate('', {trigger: true, replace:true});
        return;
      }

      callback.apply(this, args);
    }
  },
  home: function()
  {
    if (!this.homeView) {
      this.homeView = new HomeView({forceSync: false});
    }

    this.selectView(this.homeView);
    app.selectQuickNav('dash');
  },
  files: function()
  {
    this.loadFilesView(false);
    this.selectView(this.filesView);
    app.selectQuickNav('files');
  },
  fileInfo: function(fileId)
  {
    var showDlg = _.bind(function(success) {
      if (success) {
        this.filesView.fileInfo(fileId);
      }
    }, this);

    if (this.filesView) {
      this.filesView.printFilesListView.refresh(true, showDlg);
    } else {
      this.filesView = new FilesView({
        forceSync: true,
        syncCompleted: showDlg
      });
    }

    this.navigate('files', {trigger: true, replace:true});
  },
  control: function()
  {
    if (!this.controlView) {
      this.controlView = new ControlView();
    }

    this.selectView(this.controlView);
    app.selectQuickNav('control');
  },
  /*
    adding function to handle the routing for 'filament-load' & 'filament-unload'
    wizard
  */
  filamentLoad: function() {
    if (!this.filamentLoadView) {
      this.filamentLoadView = new FilamentLoadView();
    }

    this.selectView(this.filamentLoadView);
  },
  filamentUnload: function() {
    if (!this.filamentUnloadView) {
      this.filamentUnloadView = new FilamentUnloadView();
    }

    this.selectView(this.filamentUnloadView);
  },
  /*
    adding function to handle the routing for 'print-from-storage'
  */
  printFromStorage: function() {
    if(!this.printFromStorageView) {
      this.printFromStorageView = new PrintFromStorageView();
    }

    this.selectView(this.printFromStorageView);
  },
  printing: function()
  {
    if (!this.printingView) {
      this.printingView = new PrintingView();
    }

    this.selectView(this.printingView);
  },
  settings: function(page)
  {
    if (!this.settingsView) {
      this.settingsView = new SettingsView();
    }

    this.selectView(this.settingsView);
    this.settingsView.menu.changeActive(page || 'printer-connection');
    app.selectQuickNav('settings');
  },
   utilities: function()
{'fraction_non_alphanumeric': 0.14788732394366197, 'fraction_numerical': 0.00026574541589157585, 'mean_word_length': 2.9449685534591197, 'pattern_counts': {'":': 33, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1067862', 'n_tokens_mistral': 2485, 'n_tokens_neox': 2456, 'n_words': 463}