Modify Tables or Plots - Remove JavaScript from Selected Tables and Plots

From Q
Jump to navigation Jump to search

This QScript removes Table or Plot JavaScript from selected items in the Report.

Technical Details

This QScript only works in version of Q prior to Q 4.8. In more recent versions, you should use the Automation tab to remove custom Table JavaScript rules instead of using this script. The method to do so is:

  1. Select your tables and charts.
  2. Select Automations.
  3. Select the custom Table JavaScript rule from the list.
  4. Select Delete Rule.

How to apply this QScript

  • Start typing the name of the QScript into the Search features and data box in the top right of the Q window.
  • Click on the QScript when it appears in the QScripts and Rules section of the search results.

OR

  • Select Automate > Browse Online Library.
  • Select this QScript from the list.

Customizing the QScript

This QScript is written in JavaScript and can be customized by copying and modifying the JavaScript.

Customizing QScripts in Q4.11 and more recent versions

  • Start typing the name of the QScript into the Search features and data box in the top right of the Q window.
  • Hover your mouse over the QScript when it appears in the QScripts and Rules section of the search results.
  • Press Edit a Copy (bottom-left corner of the preview).
  • Modify the JavaScript (see QScripts for more detail on this).
  • Either:
    • Run the QScript, by pressing the blue triangle button.
    • Save the QScript and run it at a later time, using Automate > Run QScript (Macro) from File.

Customizing QScripts in older versions

  • Copy the JavaScript shown on this page.
  • Create a new text file, giving it a file extension of .QScript. See here for more information about how to do this.
  • Modify the JavaScript (see QScripts for more detail on this).
  • Run the file using Automate > Run QScript (Macro) from File.

JavaScript

includeWeb('QScript Table Functions');
includeWeb('QScript Selection Functions');
includeWeb("QScript Functions to Generate Outputs");


if (fileFormatVersion() > 8.12)
    log('This script only applied for Q versions lower than 4.8. To remove a custom Table JavaScript automation, you should:\r\n'
    + '1. Select your tables and plots.\r\n'
    + '2. Select Automations.\r\n' 
    + '3. Select the custom Table JavaScript rule from the list.\r\n'
    + '4. Select Delete Rule.');
else {
    // Selection of tables and plots
    var tables_plots = selectManyTablesAndPlotsWithGroupNamesAndTypes("Please select the tables and plots that you wish to remove JavaScript from: ", project.report).items;
    var num_items = tables_plots.length;
    for (var j = 0; j < num_items; j++) {
        var cur_item = tables_plots[j];
        var cur_java = cur_item.tableJavaScript;
        if (cur_java != null) {
            cur_java = "// Table or Plot JavaScript Removed by QScript: 'Modifying Tables or Plots - Remove JavaScript From Selected Tables and Plots'";
            cur_item.tableJavaScript = cur_java;
        }
    }
    conditionallyEmptyLog("QScript finished.");
}

See also