This file is indexed.

/usr/share/qterm/scripts/console.js is in qterm 1:0.7.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
// Shamelessly stole from Amarok.

function globalScopeEval( inputCode )
{
  try
  {
      result = eval( inputCode ) + " ";
  }
  catch( error )
  {
      result = error + " ";
  }
  return result;
}

function ScriptConsoleMainWindow()
{
  QMainWindow.call( this, null );

  var mainWidget = new QWidget( this );
  this.historyList = new QListWidget( mainWidget );
  this.historyList.sizeHint = new QSize(900, 600);
  this.historyList.size = new QSize(900, 600);
  this.historyList.verticalScrollMode = QAbstractItemView.ScrollPerPixel;
  this.inputLine = new QTextEdit( mainWidget );
  this.executeButton = new QPushButton( mainWidget );
  this.commandArray = [];
  this.commandPos = -1;
  this.executeButton.clicked.connect( this, this.executeLine );
  this.executeButton.text = qsTr("Execute Code");
  this.windowTitle = qsTr("QTerm Script Console");
  //the following line doesn't work for some reason:
  //executeButton.shortcut = new QKeySequence( "CTRL+Return" );

  var executeShortcut = new QShortcut( this );
  executeShortcut.key =  new QKeySequence( "CTRL+Return" );
  executeShortcut.activated.connect( this, this.executeLine );

  var backHistoryShortcut = new QShortcut( this );
  backHistoryShortcut.key = new QKeySequence( QKeySequence.StandardKey( QKeySequence.MoveToPreviousPage ) );
  backHistoryShortcut.activated.connect( this, this.backHistory );

  var forwardHistoryShortcut = new QShortcut( this );
  forwardHistoryShortcut.key = new QKeySequence( QKeySequence.StandardKey( QKeySequence.MoveToNextPage ) );
  forwardHistoryShortcut.activated.connect( this, this.forwardHistory );

  var explanationItem = new QListWidgetItem(qsTr(
"The QTerm Script Console allows you to easily execute JavaScript with access to\nall functions and methods you would have in an QTerm script.Information on\nscripting for QTerm can be found in the doc directory of the QTerm source code.\nExecute code: CTRL-Enter\nBack in code history: Page Up\nForward in code history: Page Down"));
  //explanationItem.setForeground( new QBrush( new QColor(Qt.darkGray) ) );
  explanationItem.setFlags( !Qt.ItemIsSelectable );
  this.historyList.addItem( explanationItem );

  var layout = new QGridLayout( mainWidget );
  layout.addWidget( this.historyList, 0, 0, 1, 2 );
  layout.addWidget( this.inputLine, 1, 0, 3, 2 );
  layout.addWidget( this.executeButton, 4, 1 );
  mainWidget.setLayout( layout );
  this.setCentralWidget( mainWidget );
  this.resize(750, 400);
  this.hide();
}

ScriptConsoleMainWindow.prototype = new QMainWindow();

ScriptConsoleMainWindow.prototype.executeLine = function()
{
    command = new QListWidgetItem( this.inputLine.plainText );
    this.commandArray.unshift( this.inputLine.plainText );
    boldFont = new QFont();
    boldFont.setBold( true );
    command.setFont( boldFont );
    result = globalScopeEval.call( null, this.inputLine.plainText );
    resultsRow = new QListWidgetItem( result );
    this.historyList.addItem( command  );
    this.historyList.addItem( resultsRow );
    this.historyList.setCurrentItem( resultsRow );
    this.inputLine.plainText = "";
    this.commandPos = -1;
}

ScriptConsoleMainWindow.prototype.backHistory = function()
{
  if( this.commandArray.length > ( this.commandPos + 1 ) )
  {
      this.commandPos++;
  }
  if( this.commandArray.length > 0 )
  {
    this.inputLine.plainText = this.commandArray[ this.commandPos ];
  }
}

ScriptConsoleMainWindow.prototype.forwardHistory = function()
{
  if( this.commandArray.length > 0 )
  {
    if( this.commandPos > 0 )
    {
      this.commandPos--;
    }
    this.inputLine.plainText = this.commandArray[ this.commandPos ];
  }
}

scriptConsoleMainWindow = new ScriptConsoleMainWindow();
if (QTerm.addPopupMenu( "scriptConsole", qsTr("Script Console...") ) ) {
        QTerm.scriptConsole.triggered.connect(scriptConsoleMainWindow.show);
}